Skip to content

Commit 72e50fe

Browse files
committed
usb: device_next: uvc: Initial ISO EP Descriptors
Additional UVC descriptors for catering to the Isochronous Video Streaming Endpoint Signed-off-by: Zacck Osiemo <coderv63@gmail.com>
1 parent e8cb9ba commit 72e50fe

File tree

2 files changed

+134
-55
lines changed

2 files changed

+134
-55
lines changed

‎subsys/usb/device_next/class/Kconfig.uvc‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ config USBD_VIDEO_CLASS
1111

1212
if USBD_VIDEO_CLASS
1313

14+
config USBD_VIDEO_ISO
15+
bool "USB Video Class ISO EP Implementation"
16+
help
17+
This allows the USB Video class to use an ISO Endpoint Implementation
18+
1419
config USBD_VIDEO_MAX_FORMATS
1520
int "Max number of format descriptors"
1621
range 1 254

‎subsys/usb/device_next/class/usbd_uvc.c‎

Lines changed: 129 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,133 @@ static int uvc_preinit(const struct device *dev)
20262026
return 0;
20272027
}
20282028

2029+
#if CONFIG_USBD_VIDEO_ISO
2030+
#define USBD_VIDEO_ENDPOINT_DESC \
2031+
.if1 = { \
2032+
.bLength = sizeof(struct usb_if_descriptor), \
2033+
.bDescriptorType = USB_DESC_INTERFACE, \
2034+
.bInterfaceNumber = 1, \
2035+
.bAlternateSetting = 0, \
2036+
.bNumEndpoints = 0, \
2037+
.bInterfaceClass = USB_BCC_VIDEO, \
2038+
.bInterfaceSubClass = UVC_SC_VIDEOSTREAMING, \
2039+
.bInterfaceProtocol = 0, \
2040+
.iInterface = 0, \
2041+
}, \
2042+
\
2043+
.if1_hdr = { \
2044+
.bLength = sizeof(struct uvc_stream_header_descriptor), \
2045+
.bDescriptorType = USB_DESC_CS_INTERFACE, \
2046+
.bDescriptorSubtype = UVC_VS_INPUT_HEADER, \
2047+
.bNumFormats = 0, \
2048+
.wTotalLength = sys_cpu_to_le16( \
2049+
sizeof(struct uvc_stream_header_descriptor)), \
2050+
.bEndpointAddress = 0x81, \
2051+
.bmInfo = 0, \
2052+
.bTerminalLink = UVC_UNIT_ID_OT, \
2053+
.bStillCaptureMethod = 0, \
2054+
.bTriggerSupport = 0, \
2055+
.bTriggerUsage = 0, \
2056+
.bControlSize = 0, \
2057+
}, \
2058+
\
2059+
.if1_color = { \
2060+
.bLength = sizeof(struct uvc_color_descriptor), \
2061+
.bDescriptorType = USB_DESC_CS_INTERFACE, \
2062+
.bDescriptorSubtype = UVC_VS_COLORFORMAT, \
2063+
.bColorPrimaries = UVC_COLOR_BT709, \
2064+
.bTransferCharacteristics = UVC_COLOR_BT709, \
2065+
.bMatrixCoefficients = UVC_COLOR_BT601, \
2066+
}, \
2067+
\
2068+
.if1_alt1 = { \
2069+
.bLength = sizeof(struct usb_if_descriptor), \
2070+
.bDescriptorType = USB_DESC_INTERFACE, \
2071+
.bInterfaceNumber = 1, \
2072+
.bAlternateSetting = 1, \
2073+
.bNumEndpoints = 1, /* operational */ \
2074+
.bInterfaceClass = USB_BCC_VIDEO, \
2075+
.bInterfaceSubClass = UVC_SC_VIDEOSTREAMING, \
2076+
.bInterfaceProtocol = 0, \
2077+
.iInterface = 0, \
2078+
}, \
2079+
\
2080+
.if1_ep_fs = { \
2081+
.bLength = sizeof(struct usb_ep_descriptor), \
2082+
.bDescriptorType = USB_DESC_ENDPOINT, \
2083+
.bEndpointAddress = 0x81, \
2084+
.bmAttributes = USB_EP_TYPE_ISO, \
2085+
.wMaxPacketSize = sys_cpu_to_le16(64), \
2086+
.bInterval = 1, \
2087+
}, \
2088+
\
2089+
.if1_ep_hs = { \
2090+
.bLength = sizeof(struct usb_ep_descriptor), \
2091+
.bDescriptorType = USB_DESC_ENDPOINT, \
2092+
.bEndpointAddress = 0x81, \
2093+
.bmAttributes = USB_EP_TYPE_ISO, \
2094+
.wMaxPacketSize = sys_cpu_to_le16(512), \
2095+
.bInterval = 1, \
2096+
},
2097+
#else
2098+
#define USBD_VIDEO_ENDPOINT_DESC \
2099+
.if1 = { \
2100+
.bLength = sizeof(struct usb_if_descriptor), \
2101+
.bDescriptorType = USB_DESC_INTERFACE, \
2102+
.bInterfaceNumber = 1, \
2103+
.bAlternateSetting = 0, \
2104+
.bNumEndpoints = 1, \
2105+
.bInterfaceClass = USB_BCC_VIDEO, \
2106+
.bInterfaceSubClass = UVC_SC_VIDEOSTREAMING, \
2107+
.bInterfaceProtocol = 0, \
2108+
.iInterface = 0, \
2109+
}, \
2110+
\
2111+
.if1_hdr = { \
2112+
.bLength = sizeof(struct uvc_stream_header_descriptor), \
2113+
.bDescriptorType = USB_DESC_CS_INTERFACE, \
2114+
.bDescriptorSubtype = UVC_VS_INPUT_HEADER, \
2115+
.bNumFormats = 0, \
2116+
.wTotalLength = sys_cpu_to_le16( \
2117+
sizeof(struct uvc_stream_header_descriptor)), \
2118+
.bEndpointAddress = 0x81, \
2119+
.bmInfo = 0, \
2120+
.bTerminalLink = UVC_UNIT_ID_OT, \
2121+
.bStillCaptureMethod = 0, \
2122+
.bTriggerSupport = 0, \
2123+
.bTriggerUsage = 0, \
2124+
.bControlSize = 0, \
2125+
}, \
2126+
\
2127+
.if1_color = { \
2128+
.bLength = sizeof(struct uvc_color_descriptor), \
2129+
.bDescriptorType = USB_DESC_CS_INTERFACE, \
2130+
.bDescriptorSubtype = UVC_VS_COLORFORMAT, \
2131+
.bColorPrimaries = UVC_COLOR_BT709, \
2132+
.bTransferCharacteristics = UVC_COLOR_BT709, \
2133+
.bMatrixCoefficients = UVC_COLOR_BT601, \
2134+
}, \
2135+
\
2136+
.if1_ep_fs = { \
2137+
.bLength = sizeof(struct usb_ep_descriptor), \
2138+
.bDescriptorType = USB_DESC_ENDPOINT, \
2139+
.bEndpointAddress = 0x81, \
2140+
.bmAttributes = USB_EP_TYPE_BULK, \
2141+
.wMaxPacketSize = sys_cpu_to_le16(64), \
2142+
.bInterval = 0, \
2143+
}, \
2144+
\
2145+
.if1_ep_hs = { \
2146+
.bLength = sizeof(struct usb_ep_descriptor), \
2147+
.bDescriptorType = USB_DESC_ENDPOINT, \
2148+
.bEndpointAddress = 0x81, \
2149+
.bmAttributes = USB_EP_TYPE_BULK, \
2150+
.wMaxPacketSize = sys_cpu_to_le16(512), \
2151+
.bInterval = 0, \
2152+
},
2153+
#endif
2154+
2155+
20292156
#define UVC_DEFINE_DESCRIPTOR(n) \
20302157
static struct uvc_desc uvc_desc_##n = { \
20312158
.iad = { \
@@ -2130,61 +2257,8 @@ static struct uvc_desc uvc_desc_##n = { \
21302257
.bSourceID = UVC_UNIT_ID_XU, \
21312258
.iTerminal = 0, \
21322259
}, \
2133-
\
2134-
.if1 = { \
2135-
.bLength = sizeof(struct usb_if_descriptor), \
2136-
.bDescriptorType = USB_DESC_INTERFACE, \
2137-
.bInterfaceNumber = 1, \
2138-
.bAlternateSetting = 0, \
2139-
.bNumEndpoints = 1, \
2140-
.bInterfaceClass = USB_BCC_VIDEO, \
2141-
.bInterfaceSubClass = UVC_SC_VIDEOSTREAMING, \
2142-
.bInterfaceProtocol = 0, \
2143-
.iInterface = 0, \
2144-
}, \
2145-
\
2146-
.if1_hdr = { \
2147-
.bLength = sizeof(struct uvc_stream_header_descriptor), \
2148-
.bDescriptorType = USB_DESC_CS_INTERFACE, \
2149-
.bDescriptorSubtype = UVC_VS_INPUT_HEADER, \
2150-
.bNumFormats = 0, \
2151-
.wTotalLength = sys_cpu_to_le16( \
2152-
sizeof(struct uvc_stream_header_descriptor)), \
2153-
.bEndpointAddress = 0x81, \
2154-
.bmInfo = 0, \
2155-
.bTerminalLink = UVC_UNIT_ID_OT, \
2156-
.bStillCaptureMethod = 0, \
2157-
.bTriggerSupport = 0, \
2158-
.bTriggerUsage = 0, \
2159-
.bControlSize = 0, \
2160-
}, \
2161-
\
2162-
.if1_color = { \
2163-
.bLength = sizeof(struct uvc_color_descriptor), \
2164-
.bDescriptorType = USB_DESC_CS_INTERFACE, \
2165-
.bDescriptorSubtype = UVC_VS_COLORFORMAT, \
2166-
.bColorPrimaries = UVC_COLOR_BT709, \
2167-
.bTransferCharacteristics = UVC_COLOR_BT709, \
2168-
.bMatrixCoefficients = UVC_COLOR_BT601, \
2169-
}, \
2170-
\
2171-
.if1_ep_fs = { \
2172-
.bLength = sizeof(struct usb_ep_descriptor), \
2173-
.bDescriptorType = USB_DESC_ENDPOINT, \
2174-
.bEndpointAddress = 0x81, \
2175-
.bmAttributes = USB_EP_TYPE_BULK, \
2176-
.wMaxPacketSize = sys_cpu_to_le16(64), \
2177-
.bInterval = 0, \
2178-
}, \
2179-
\
2180-
.if1_ep_hs = { \
2181-
.bLength = sizeof(struct usb_ep_descriptor), \
2182-
.bDescriptorType = USB_DESC_ENDPOINT, \
2183-
.bEndpointAddress = 0x81, \
2184-
.bmAttributes = USB_EP_TYPE_BULK, \
2185-
.wMaxPacketSize = sys_cpu_to_le16(512), \
2186-
.bInterval = 0, \
2187-
}, \
2260+
\
2261+
USBD_VIDEO_ENDPOINT_DESC \
21882262
}; \
21892263
\
21902264
struct usb_desc_header *uvc_fs_desc_##n[UVC_MAX_FS_DESC] = { \

0 commit comments

Comments
 (0)