summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2020-02-10 13:45:12 +0900
committerINSUN PYO <insun.pyo@samsung.com>2020-02-10 14:35:26 +0900
commit0c129c2561c2e62f2176e4435412a969b4617fb2 (patch)
tree6eb279c4180aa9f62f20674f81c25e2eb5447c34
parentafc9e97d20d06918ade6e6cc555226bc30131889 (diff)
downloadlibdevice-node-0c129c2561c2e62f2176e4435412a969b4617fb2.tar.gz
libdevice-node-0c129c2561c2e62f2176e4435412a969b4617fb2.tar.bz2
libdevice-node-0c129c2561c2e62f2176e4435412a969b4617fb2.zip
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
-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);