summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2020-02-10 04:45:12 (GMT)
committerINSUN PYO <insun.pyo@samsung.com>2020-02-12 00:21:37 (GMT)
commit1f97debf475742c1f30ea0136b1622dad1a5d434 (patch)
tree6eb279c4180aa9f62f20674f81c25e2eb5447c34
parent4a9e04e4da8ec8173b259c9cd0ab213c5cd4f5e8 (diff)
downloadlibdevice-node-1f97debf475742c1f30ea0136b1622dad1a5d434.zip
libdevice-node-1f97debf475742c1f30ea0136b1622dad1a5d434.tar.gz
libdevice-node-1f97debf475742c1f30ea0136b1622dad1a5d434.tar.bz2
static const unsigned int usb_mode_features[SET_USB_MODE_MAX] = { [SET_USB_NONE] = USB_FUNCTION_NONE, [SET_USB_DEFAULT] = USB_FUNCTION_MTP | USB_FUNCTION_ACM, [SET_USB_SDB] = USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB, [SET_USB_SDB_DIAG] = USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DIAG, [SET_USB_RNDIS_TETHERING] = USB_FUNCTION_RNDIS | USB_FUNCTION_SDB | USB_FUNCTION_ACM, [SET_USB_RNDIS] = USB_FUNCTION_RNDIS, [SET_USB_RNDIS_SDB] = USB_FUNCTION_RNDIS | USB_FUNCTION_SDB | USB_FUNCTION_ACM, [SET_USB_DIAG_SDB] = USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DIAG, [SET_USB_RNDIS_DIAG] = USB_FUNCTION_RNDIS | USB_FUNCTION_DIAG, [SET_USB_DIAG_RMNET] = USB_FUNCTION_DIAG | USB_FUNCTION_RMNET, [SET_USB_ACM_SDB_DM] = USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DM, [SET_USB_RNDIS_SDB_ACM] = USB_FUNCTION_RNDIS | USB_FUNCTION_ACM | USB_FUNCTION_SDB, }; Change-Id: I357240c37f5ceb694929c7f9cde6a04587212dec (cherry picked from commit 0c129c2561c2e62f2176e4435412a969b4617fb2)
-rw-r--r--hw/usb_gadget_common.c63
1 files changed, 27 insertions, 36 deletions
diff --git a/hw/usb_gadget_common.c b/hw/usb_gadget_common.c
index 70d6c51..2ecef99 100644
--- a/hw/usb_gadget_common.c
+++ b/hw/usb_gadget_common.c
@@ -255,13 +255,7 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id,
gadget->attrs.idProduct = 0x685d;
break;
- case USB_FUNCTION_RNDIS:
- n_configs = 1;
- functions[0][0] = USB_FUNCTION_RNDIS;
- functions[0][1] = 0;
- gadget->attrs.idProduct = 0x6863;
- break;
-
+ /* MTP, ACM, SDB */
case USB_FUNCTION_MTP | USB_FUNCTION_ACM:
n_configs = 1;
functions[0][0] = USB_FUNCTION_MTP;
@@ -295,15 +289,7 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id,
gadget->attrs.idProduct = 0x6860;
break;
- case USB_FUNCTION_RNDIS | USB_FUNCTION_SDB:
- n_configs = 1;
- functions[0][0] = USB_FUNCTION_RNDIS;
- functions[0][1] = USB_FUNCTION_SDB;
- functions[0][2] = 0;
- gadget->attrs.idProduct = 0x6864;
- break;
-
-#if 0
+ /* DIAG */
case USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DIAG:
n_configs = 1;
functions[0][0] = USB_FUNCTION_MTP;
@@ -314,13 +300,19 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id,
gadget->attrs.idProduct = 0x6860;
break;
- case USB_FUNCTION_RNDIS | USB_FUNCTION_SDB | USB_FUNCTION_ACM | USB_FUNCTION_DIAG:
+ /* RNDIS */
+ case USB_FUNCTION_RNDIS:
n_configs = 1;
functions[0][0] = USB_FUNCTION_RNDIS;
- functions[0][1] = USB_FUNCTION_SDB;
- functions[0][2] = USB_FUNCTION_ACM;
- functions[0][3] = USB_FUNCTION_DIAG;
- functions[0][4] = 0;
+ functions[0][1] = 0;
+ gadget->attrs.idProduct = 0x6863;
+ break;
+
+ case USB_FUNCTION_SDB | USB_FUNCTION_RNDIS:
+ n_configs = 1;
+ functions[0][0] = USB_FUNCTION_SDB;
+ functions[0][1] = USB_FUNCTION_RNDIS;
+ functions[0][2] = 0;
gadget->attrs.idProduct = 0x6864;
break;
@@ -331,40 +323,39 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id,
functions[0][2] = 0;
gadget->attrs.idProduct = 0x6864;
break;
-#endif
- case USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DM:
+ case USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_RNDIS:
n_configs = 1;
functions[0][0] = USB_FUNCTION_ACM;
functions[0][1] = USB_FUNCTION_SDB;
- functions[0][2] = USB_FUNCTION_DM;
+ functions[0][2] = USB_FUNCTION_RNDIS;
functions[0][3] = 0;
- gadget->attrs.idProduct = 0x6860;
+ gadget->attrs.idProduct = 0x6864;
break;
- case USB_FUNCTION_DIAG | USB_FUNCTION_ACM | USB_FUNCTION_RMNET:
+ /* RMNET */
+ case USB_FUNCTION_DIAG | USB_FUNCTION_RMNET:
n_configs = 1;
functions[0][0] = USB_FUNCTION_DIAG;
- functions[0][1] = USB_FUNCTION_ACM;
- functions[0][2] = USB_FUNCTION_RMNET;
- functions[0][3] = 0;
+ functions[0][1] = USB_FUNCTION_RMNET;
+ functions[0][2] = 0;
gadget->attrs.idProduct = 0x685d;
break;
- case USB_FUNCTION_RNDIS | USB_FUNCTION_SDB | USB_FUNCTION_ACM:
+ /* DM */
+ case USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DM:
n_configs = 1;
- functions[0][0] = USB_FUNCTION_RNDIS;
+ functions[0][0] = USB_FUNCTION_ACM;
functions[0][1] = USB_FUNCTION_SDB;
- functions[0][2] = USB_FUNCTION_ACM;
+ functions[0][2] = USB_FUNCTION_DM;
functions[0][3] = 0;
- gadget->attrs.idProduct = 0x6864;
+ gadget->attrs.idProduct = 0x6860;
break;
- };
- if (n_configs > 2 || n_configs <= 0) {
+ default:
ret = -EINVAL;
goto free_gadget;
- }
+ };
n_functions = __builtin_popcount(gadget_id->function_mask);