From 025ca5345a8ffbb7de3b1c64fb0a5ddbbdacd3b0 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Sun, 9 Jul 2017 18:30:46 -0300 Subject: USBH: Added mechanism for out-of-tree class driver enumeration --- os/hal/src/usbh/hal_usbh_uvc.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'os/hal/src/usbh/hal_usbh_uvc.c') diff --git a/os/hal/src/usbh/hal_usbh_uvc.c b/os/hal/src/usbh/hal_usbh_uvc.c index b0507a0..ac3663e 100644 --- a/os/hal/src/usbh/hal_usbh_uvc.c +++ b/os/hal/src/usbh/hal_usbh_uvc.c @@ -66,14 +66,15 @@ USBHUVCDriver USBHUVCD[HAL_USBHUVC_MAX_INSTANCES]; - -static usbh_baseclassdriver_t *uvc_load(usbh_device_t *dev, +static void _uvc_init(void); +static usbh_baseclassdriver_t *_uvc_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem); -static void uvc_unload(usbh_baseclassdriver_t *drv); +static void _uvc_unload(usbh_baseclassdriver_t *drv); static const usbh_classdriver_vmt_t class_driver_vmt = { - uvc_load, - uvc_unload + _uvc_init, + _uvc_load, + _uvc_unload }; const usbh_classdriverinfo_t usbhuvcClassDriverInfo = { 0x0e, 0x03, 0x00, "UVC", &class_driver_vmt @@ -512,17 +513,7 @@ uint32_t usbhuvcEstimateRequiredEPSize(USBHUVCDriver *uvcdp, const uint8_t *form return (sz * mul) / div + 12; } -void usbhuvcObjectInit(USBHUVCDriver *uvcdp) { - osalDbgCheck(uvcdp != NULL); - memset(uvcdp, 0, sizeof(*uvcdp)); - uvcdp->info = &usbhuvcClassDriverInfo; - chMBObjectInit(&uvcdp->mb, uvcdp->mb_buff, HAL_USBHUVC_MAX_MAILBOX_SZ); - chMtxObjectInit(&uvcdp->mtx); - uvcdp->state = USBHUVC_STATE_STOP; -} - - -static usbh_baseclassdriver_t *uvc_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem) { +static usbh_baseclassdriver_t *_uvc_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem) { USBHUVCDriver *uvcdp; uint8_t i; @@ -710,7 +701,7 @@ alloc_ok: return (usbh_baseclassdriver_t *)uvcdp; } -static void uvc_unload(usbh_baseclassdriver_t *drv) { +static void _uvc_unload(usbh_baseclassdriver_t *drv) { USBHUVCDriver *const uvcdp = (USBHUVCDriver *)drv; usbhuvcStreamStop(uvcdp); @@ -727,10 +718,19 @@ static void uvc_unload(usbh_baseclassdriver_t *drv) { osalSysUnlock(); } -void usbhuvcInit(void) { +static void _object_init(USBHUVCDriver *uvcdp) { + osalDbgCheck(uvcdp != NULL); + memset(uvcdp, 0, sizeof(*uvcdp)); + uvcdp->info = &usbhuvcClassDriverInfo; + chMBObjectInit(&uvcdp->mb, uvcdp->mb_buff, HAL_USBHUVC_MAX_MAILBOX_SZ); + chMtxObjectInit(&uvcdp->mtx); + uvcdp->state = USBHUVC_STATE_STOP; +} + +static void _uvc_init(void) { uint8_t i; for (i = 0; i < HAL_USBHUVC_MAX_INSTANCES; i++) { - usbhuvcObjectInit(&USBHUVCD[i]); + _object_init(&USBHUVCD[i]); } } -- cgit v1.2.3 From 6b7161b90a3572bbb7717d0317306741043528e5 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Sun, 9 Jul 2017 19:42:36 -0300 Subject: USBH: moved usbh/desciter.h and usbh/debug.h to usbh/internal.h --- os/hal/src/usbh/hal_usbh_uvc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/hal/src/usbh/hal_usbh_uvc.c') diff --git a/os/hal/src/usbh/hal_usbh_uvc.c b/os/hal/src/usbh/hal_usbh_uvc.c index ac3663e..3f362a2 100644 --- a/os/hal/src/usbh/hal_usbh_uvc.c +++ b/os/hal/src/usbh/hal_usbh_uvc.c @@ -27,9 +27,9 @@ #error "USBHUVC needs HAL_USBH_USE_IAD" #endif +#include #include "usbh/dev/uvc.h" #include "usbh/internal.h" -#include #if USBHUVC_DEBUG_ENABLE_TRACE #define udbgf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__) -- cgit v1.2.3 From c044306ad058689783b1a6941a2a44d5baf738a2 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Thu, 13 Jul 2017 16:45:31 -0300 Subject: USBH: Add flexibility to the enumeration process --- os/hal/src/usbh/hal_usbh_uvc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'os/hal/src/usbh/hal_usbh_uvc.c') diff --git a/os/hal/src/usbh/hal_usbh_uvc.c b/os/hal/src/usbh/hal_usbh_uvc.c index 3f362a2..7777823 100644 --- a/os/hal/src/usbh/hal_usbh_uvc.c +++ b/os/hal/src/usbh/hal_usbh_uvc.c @@ -77,7 +77,7 @@ static const usbh_classdriver_vmt_t class_driver_vmt = { _uvc_unload }; const usbh_classdriverinfo_t usbhuvcClassDriverInfo = { - 0x0e, 0x03, 0x00, "UVC", &class_driver_vmt + "UVC", &class_driver_vmt }; static bool _request(USBHUVCDriver *uvcdp, @@ -518,7 +518,8 @@ static usbh_baseclassdriver_t *_uvc_load(usbh_device_t *dev, const uint8_t *desc USBHUVCDriver *uvcdp; uint8_t i; - if (descriptor[1] != USBH_DT_INTERFACE_ASSOCIATION) + if (_usbh_match_descriptor(descriptor, rem, USBH_DT_INTERFACE_ASSOCIATION, + 0x0e, 0x03, 0x00) != HAL_SUCCESS) return NULL; /* alloc driver */ -- cgit v1.2.3 From dee22cee18dd98502b19e41e45503f8c20f447d6 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Sun, 16 Jul 2017 20:01:50 -0300 Subject: USBH: remove unnecessary reschedules and add necessary ones --- os/hal/src/usbh/hal_usbh_uvc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'os/hal/src/usbh/hal_usbh_uvc.c') diff --git a/os/hal/src/usbh/hal_usbh_uvc.c b/os/hal/src/usbh/hal_usbh_uvc.c index 7777823..a795cd8 100644 --- a/os/hal/src/usbh/hal_usbh_uvc.c +++ b/os/hal/src/usbh/hal_usbh_uvc.c @@ -361,10 +361,8 @@ bool usbhuvcStreamStart(USBHUVCDriver *uvcdp, uint16_t min_ep_sz) { osalDbgCheck(msg); usbhURBObjectInit(&uvcdp->urb_iso, &uvcdp->ep_iso, _cb_iso, uvcdp, msg->data, uvcdp->ep_iso.wMaxPacketSize); } - osalSysLock(); - usbhURBSubmitI(&uvcdp->urb_iso); - osalOsRescheduleS(); - osalSysUnlock(); + + usbhURBSubmit(&uvcdp->urb_iso); ret = HAL_SUCCESS; goto exit; @@ -695,7 +693,7 @@ alloc_ok: osalSysLock(); usbhURBSubmitI(&uvcdp->urb_int); uvcdp->state = USBHUVC_STATE_ACTIVE; - osalOsRescheduleS(); + osalOsRescheduleS(); /* because of usbhURBSubmitI */ osalSysUnlock(); dev->keepFullCfgDesc++; -- cgit v1.2.3