From: INSUN PYO Date: Mon, 30 Dec 2019 07:21:12 +0000 (+0900) Subject: Add USB_FUNCTION_GROUP_WITH_POST_SERVICE for cfs post service. X-Git-Tag: submit/tizen/20191230.073928^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6312d5a191ccc31b8c20ec109d4e2e3ba8406899;p=platform%2Fcore%2Fsystem%2Flibdevice-node.git Add USB_FUNCTION_GROUP_WITH_POST_SERVICE for cfs post service. To support CFS acm and rndis mode, add new USB_FUNCTION_GROUP_WITH_POST_SERVICE mode. Legacy mode : usb prepare --> usb enable --> start sdb, mtp, rndis, and data-router service CFS sdb, mtp mode : usb prepare -> start sdb and mtp service -> usb enable CFS acm, rndis mode : usb prepare -> usb enable -> start acm and rndis service Change-Id: I7199636d0b2bcfeac068e1c1575e89926c8f7134 --- diff --git a/hw/usb_cfs_client_common.c b/hw/usb_cfs_client_common.c index 5d0ea75..8eff847 100755 --- a/hw/usb_cfs_client_common.c +++ b/hw/usb_cfs_client_common.c @@ -497,6 +497,7 @@ static bool cfs_is_function_supported(struct usb_client *usb, switch (func->function_group) { case USB_FUNCTION_GROUP_SIMPLE: + case USB_FUNCTION_GROUP_WITH_POST_SERVICE: ret = usbg_lookup_function_type(func->name); res = ret >= 0; break; @@ -702,6 +703,7 @@ static int cfs_set_gadget_config(struct cfs_client *cfs_client, switch (usb_func->function_group) { case USB_FUNCTION_GROUP_SIMPLE: + case USB_FUNCTION_GROUP_WITH_POST_SERVICE: type = usbg_lookup_function_type(usb_func->name); if (strlen(usb_func->instance) >= MAX_INSTANCE_LEN) return -ENAMETOOLONG; diff --git a/hw/usb_client_common.c b/hw/usb_client_common.c index abfa6b2..fab8ea1 100755 --- a/hw/usb_client_common.c +++ b/hw/usb_client_common.c @@ -555,8 +555,7 @@ static int legacy_enable(struct usb_client *usb) goto disable_gadget; for (i = 0; gadget->funcs[i]; ++i) { - if (gadget->funcs[i]->function_group != - USB_FUNCTION_GROUP_WITH_SERVICE) + if (gadget->funcs[i]->function_group == USB_FUNCTION_GROUP_SIMPLE) continue; fws = container_of(gadget->funcs[i], @@ -584,7 +583,7 @@ static int legacy_disable(struct usb_client *usb) return ret; for (i = 0; gadget->funcs[i]; ++i) { - if (gadget->funcs[i]->function_group != USB_FUNCTION_GROUP_WITH_SERVICE) + if (gadget->funcs[i]->function_group == USB_FUNCTION_GROUP_SIMPLE) continue; fws = container_of(gadget->funcs[i], struct usb_function_with_service, func); diff --git a/hw/usb_gadget.h b/hw/usb_gadget.h index 2b96ad6..e3f460b 100644 --- a/hw/usb_gadget.h +++ b/hw/usb_gadget.h @@ -50,9 +50,14 @@ /* Function IDX in array is number of trailing zeros */ #define FUNC_IDX_FROM_MASK(mask) _HELPER_CTZ(mask) +/** + * USB_FUNCTION_GROUP_WITH_POST_SERVICE is the same as USB_FUNCTION_GROUP_SIMPLE + * except running the service as a post. + */ typedef enum { USB_FUNCTION_GROUP_SIMPLE, USB_FUNCTION_GROUP_WITH_SERVICE, + USB_FUNCTION_GROUP_WITH_POST_SERVICE, } usb_function_group_e; struct usb_function { @@ -253,10 +258,25 @@ out: .service = _service, \ } -DEFINE_USB_FUNCTION_WITH_SERVICE(USB_FUNCTION_ACM, acm, "data-router"); DEFINE_USB_FUNCTION_WITH_SERVICE(USB_FUNCTION_SDB, sdb, "sdbd"); DEFINE_USB_FUNCTION_WITH_SERVICE(USB_FUNCTION_MTP, mtp, "mtp-responder"); -DEFINE_USB_FUNCTION_WITH_SERVICE(USB_FUNCTION_RNDIS, rndis, "rndis"); + +#define DEFINE_USB_FUNCTION_WITH_POST_SERVICE(_id, _name, _service) \ + static struct usb_function_with_service _##_name##_function = { \ + .func = { \ + .function_group = USB_FUNCTION_GROUP_WITH_POST_SERVICE, \ + .id = _id, \ + .name = #_name, \ + .instance = "default", \ + .clone = clone_func_with_service, \ + .free_func = free_func_with_service, \ + }, \ + .service = _service, \ + } + +DEFINE_USB_FUNCTION_WITH_POST_SERVICE(USB_FUNCTION_ACM, acm, "data-router"); +DEFINE_USB_FUNCTION_WITH_POST_SERVICE(USB_FUNCTION_RNDIS, rndis, "rndis"); + #define MAKE_FUNC_AVAILABLE(_name, _vname) \ [FUNC_IDX_FROM_MASK(USB_FUNCTION_##_name)] = &_##_vname##_function