usbh_video.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. /*
  2. * Copyright (c) 2022, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "usbh_core.h"
  7. #include "usbh_video.h"
  8. #undef USB_DBG_TAG
  9. #define USB_DBG_TAG "usbh_video"
  10. #include "usb_log.h"
  11. #define DEV_FORMAT "/dev/video%d"
  12. /* general descriptor field offsets */
  13. #define DESC_bLength 0 /** Length offset */
  14. #define DESC_bDescriptorType 1 /** Descriptor type offset */
  15. #define DESC_bDescriptorSubType 2 /** Descriptor subtype offset */
  16. #define DESC_bNumFormats 3 /** Descriptor numformat offset */
  17. #define DESC_bNumFrameDescriptors 4 /** Descriptor numframe offset */
  18. #define DESC_bFormatIndex 3 /** Descriptor format index offset */
  19. #define DESC_bFrameIndex 3 /** Descriptor frame index offset */
  20. /* interface descriptor field offsets */
  21. #define INTF_DESC_bInterfaceNumber 2 /** Interface number offset */
  22. #define INTF_DESC_bAlternateSetting 3 /** Alternate setting offset */
  23. USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_video_buf[USB_ALIGN_UP(128, CONFIG_USB_ALIGN_SIZE)];
  24. static const char *format_type[] = { "uncompressed", "mjpeg" };
  25. static struct usbh_video g_video_class[CONFIG_USBHOST_MAX_VIDEO_CLASS];
  26. static uint32_t g_devinuse = 0;
  27. static struct usbh_video *usbh_video_class_alloc(void)
  28. {
  29. uint8_t devno;
  30. for (devno = 0; devno < CONFIG_USBHOST_MAX_VIDEO_CLASS; devno++) {
  31. if ((g_devinuse & (1U << devno)) == 0) {
  32. g_devinuse |= (1U << devno);
  33. memset(&g_video_class[devno], 0, sizeof(struct usbh_video));
  34. g_video_class[devno].minor = devno;
  35. return &g_video_class[devno];
  36. }
  37. }
  38. return NULL;
  39. }
  40. static void usbh_video_class_free(struct usbh_video *video_class)
  41. {
  42. uint8_t devno = video_class->minor;
  43. if (devno < 32) {
  44. g_devinuse &= ~(1U << devno);
  45. }
  46. memset(video_class, 0, sizeof(struct usbh_video));
  47. }
  48. int usbh_video_get(struct usbh_video *video_class, uint8_t request, uint8_t intf, uint8_t entity_id, uint8_t cs, uint8_t *buf, uint16_t len)
  49. {
  50. struct usb_setup_packet *setup;
  51. int ret;
  52. uint8_t retry;
  53. if (!video_class || !video_class->hport) {
  54. return -USB_ERR_INVAL;
  55. }
  56. setup = video_class->hport->setup;
  57. setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
  58. setup->bRequest = request;
  59. setup->wValue = cs << 8;
  60. setup->wIndex = (entity_id << 8) | intf;
  61. setup->wLength = len;
  62. retry = 0;
  63. while (1) {
  64. ret = usbh_control_transfer(video_class->hport, setup, g_video_buf);
  65. if (ret > 0) {
  66. break;
  67. }
  68. retry++;
  69. if (retry == 3) {
  70. return ret;
  71. }
  72. }
  73. if (buf) {
  74. memcpy(buf, g_video_buf, len);
  75. }
  76. return ret;
  77. }
  78. int usbh_video_set(struct usbh_video *video_class, uint8_t request, uint8_t intf, uint8_t entity_id, uint8_t cs, uint8_t *buf, uint16_t len)
  79. {
  80. struct usb_setup_packet *setup;
  81. int ret;
  82. if (!video_class || !video_class->hport) {
  83. return -USB_ERR_INVAL;
  84. }
  85. setup = video_class->hport->setup;
  86. setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
  87. setup->bRequest = request;
  88. setup->wValue = cs << 8;
  89. setup->wIndex = (entity_id << 8) | intf;
  90. setup->wLength = len;
  91. memcpy(g_video_buf, buf, len);
  92. ret = usbh_control_transfer(video_class->hport, setup, g_video_buf);
  93. usb_osal_msleep(50);
  94. return ret;
  95. }
  96. int usbh_videostreaming_get_cur_probe(struct usbh_video *video_class)
  97. {
  98. return usbh_video_get(video_class, VIDEO_REQUEST_GET_CUR, video_class->data_intf, 0x00, VIDEO_VS_PROBE_CONTROL, (uint8_t *)&video_class->probe, 26);
  99. }
  100. int usbh_videostreaming_set_cur_probe(struct usbh_video *video_class, uint8_t formatindex, uint8_t frameindex, uint32_t dwFrameInterval)
  101. {
  102. video_class->probe.bFormatIndex = formatindex;
  103. video_class->probe.bFrameIndex = frameindex;
  104. video_class->probe.dwMaxPayloadTransferSize = 0;
  105. video_class->probe.dwFrameInterval = dwFrameInterval;
  106. return usbh_video_set(video_class, VIDEO_REQUEST_SET_CUR, video_class->data_intf, 0x00, VIDEO_VS_PROBE_CONTROL, (uint8_t *)&video_class->probe, 26);
  107. }
  108. int usbh_videostreaming_set_cur_commit(struct usbh_video *video_class, uint8_t formatindex, uint8_t frameindex)
  109. {
  110. memcpy(&video_class->commit, &video_class->probe, sizeof(struct video_probe_and_commit_controls));
  111. video_class->commit.bFormatIndex = formatindex;
  112. video_class->commit.bFrameIndex = frameindex;
  113. return usbh_video_set(video_class, VIDEO_REQUEST_SET_CUR, video_class->data_intf, 0x00, VIDEO_VS_COMMIT_CONTROL, (uint8_t *)&video_class->commit, 26);
  114. }
  115. int usbh_video_open(struct usbh_video *video_class,
  116. uint8_t format_type,
  117. uint16_t wWidth,
  118. uint16_t wHeight,
  119. uint8_t altsetting)
  120. {
  121. struct usb_setup_packet *setup;
  122. struct usb_endpoint_descriptor *ep_desc;
  123. uint8_t mult;
  124. uint16_t mps;
  125. int ret;
  126. bool found = false;
  127. uint8_t formatidx = 0;
  128. uint8_t frameidx = 0;
  129. uint32_t dwDefaultFrameInterval = 0;
  130. uint8_t step;
  131. if (!video_class || !video_class->hport) {
  132. return -USB_ERR_INVAL;
  133. }
  134. setup = video_class->hport->setup;
  135. if (video_class->is_opened) {
  136. return 0;
  137. }
  138. for (uint8_t i = 0; i < video_class->num_of_formats; i++) {
  139. if (format_type == video_class->format[i].format_type) {
  140. formatidx = i + 1;
  141. for (uint8_t j = 0; j < video_class->format[i].num_of_frames; j++) {
  142. if ((wWidth == video_class->format[i].frame[j].wWidth) &&
  143. (wHeight == video_class->format[i].frame[j].wHeight)) {
  144. frameidx = j + 1;
  145. dwDefaultFrameInterval = video_class->format[i].frame[j].dwDefaultFrameInterval;
  146. found = true;
  147. break;
  148. }
  149. }
  150. }
  151. }
  152. if (found == false) {
  153. return -USB_ERR_NODEV;
  154. }
  155. if (altsetting > (video_class->num_of_intf_altsettings - 1)) {
  156. return -USB_ERR_INVAL;
  157. }
  158. /* Open video step:
  159. * Get CUR request (probe)
  160. * Set CUR request (probe)
  161. * Get CUR request (probe)
  162. * Get MAX request (probe)
  163. * Get MIN request (probe)
  164. * Get CUR request (probe)
  165. * Set CUR request (commit)
  166. *
  167. */
  168. step = 0;
  169. ret = usbh_videostreaming_get_cur_probe(video_class);
  170. if (ret < 0) {
  171. goto errout;
  172. }
  173. step = 1;
  174. ret = usbh_videostreaming_set_cur_probe(video_class, formatidx, frameidx, dwDefaultFrameInterval);
  175. if (ret < 0) {
  176. goto errout;
  177. }
  178. step = 2;
  179. ret = usbh_videostreaming_get_cur_probe(video_class);
  180. if (ret < 0) {
  181. goto errout;
  182. }
  183. step = 3;
  184. ret = usbh_video_get(video_class, VIDEO_REQUEST_GET_MAX, video_class->data_intf, 0x00, VIDEO_VS_PROBE_CONTROL, NULL, 26);
  185. if (ret < 0) {
  186. goto errout;
  187. }
  188. step = 4;
  189. ret = usbh_video_get(video_class, VIDEO_REQUEST_GET_MIN, video_class->data_intf, 0x00, VIDEO_VS_PROBE_CONTROL, NULL, 26);
  190. if (ret < 0) {
  191. goto errout;
  192. }
  193. step = 5;
  194. ret = usbh_videostreaming_set_cur_probe(video_class, formatidx, frameidx, dwDefaultFrameInterval);
  195. if (ret < 0) {
  196. goto errout;
  197. }
  198. step = 6;
  199. ret = usbh_videostreaming_get_cur_probe(video_class);
  200. if (ret < 0) {
  201. goto errout;
  202. }
  203. step = 7;
  204. ret = usbh_videostreaming_set_cur_commit(video_class, formatidx, frameidx);
  205. if (ret < 0) {
  206. goto errout;
  207. }
  208. step = 8;
  209. if (!video_class->is_bulk) {
  210. setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_INTERFACE;
  211. setup->bRequest = USB_REQUEST_SET_INTERFACE;
  212. setup->wValue = altsetting;
  213. setup->wIndex = video_class->data_intf;
  214. setup->wLength = 0;
  215. ret = usbh_control_transfer(video_class->hport, setup, NULL);
  216. if (ret < 0) {
  217. goto errout;
  218. }
  219. ep_desc = &video_class->hport->config.intf[video_class->data_intf].altsetting[altsetting].ep[0].ep_desc;
  220. mult = (ep_desc->wMaxPacketSize & USB_MAXPACKETSIZE_ADDITIONAL_TRANSCATION_MASK) >> USB_MAXPACKETSIZE_ADDITIONAL_TRANSCATION_SHIFT;
  221. mps = ep_desc->wMaxPacketSize & USB_MAXPACKETSIZE_MASK;
  222. if (ep_desc->bEndpointAddress & 0x80) {
  223. video_class->isoin_mps = mps * (mult + 1);
  224. USBH_EP_INIT(video_class->isoin, ep_desc);
  225. } else {
  226. return -USB_ERR_NODEV;
  227. }
  228. } else {
  229. ep_desc = &video_class->hport->config.intf[video_class->data_intf].altsetting[0].ep[0].ep_desc;
  230. USBH_EP_INIT(video_class->bulkin, ep_desc);
  231. }
  232. USB_LOG_INFO("Open video and select formatidx:%u, frameidx:%u, altsetting:%u\r\n", formatidx, frameidx, altsetting);
  233. video_class->is_opened = true;
  234. video_class->current_format = format_type;
  235. return ret;
  236. errout:
  237. USB_LOG_ERR("Fail to open video in step %u\r\n", step);
  238. return ret;
  239. }
  240. int usbh_video_close(struct usbh_video *video_class)
  241. {
  242. struct usb_setup_packet *setup;
  243. int ret = 0;
  244. if (!video_class || !video_class->hport) {
  245. return -USB_ERR_INVAL;
  246. }
  247. setup = video_class->hport->setup;
  248. USB_LOG_INFO("Close video device\r\n");
  249. video_class->is_opened = false;
  250. if (video_class->is_bulk) {
  251. setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_ENDPOINT;
  252. setup->bRequest = USB_REQUEST_CLEAR_FEATURE;
  253. setup->wValue = USB_FEATURE_ENDPOINT_HALT;
  254. setup->wIndex = video_class->bulkin->bEndpointAddress;
  255. setup->wLength = 0;
  256. } else {
  257. setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_INTERFACE;
  258. setup->bRequest = USB_REQUEST_SET_INTERFACE;
  259. setup->wValue = 0;
  260. setup->wIndex = video_class->data_intf;
  261. setup->wLength = 0;
  262. }
  263. ret = usbh_control_transfer(video_class->hport, setup, NULL);
  264. if (ret < 0) {
  265. return ret;
  266. }
  267. return ret;
  268. }
  269. void usbh_video_list_info(struct usbh_video *video_class)
  270. {
  271. struct usb_endpoint_descriptor *ep_desc;
  272. USB_LOG_INFO("============= Video device information ===================\r\n");
  273. USB_LOG_RAW("bcdVDC:%04x\r\n", video_class->bcdVDC);
  274. USB_LOG_RAW("Num of altsettings:%u (%s mode)\r\n", video_class->num_of_intf_altsettings, video_class->num_of_intf_altsettings == 1 ? "bulk" : "iso");
  275. video_class->is_bulk = video_class->num_of_intf_altsettings == 1 ? true : false;
  276. if (video_class->is_bulk) {
  277. ep_desc = &video_class->hport->config.intf[video_class->data_intf].altsetting[0].ep[0].ep_desc;
  278. USB_LOG_RAW("Ep=%02x Attr=%02u Mps=%d Interval=%02u Mult=%02u\r\n",
  279. ep_desc->bEndpointAddress,
  280. ep_desc->bmAttributes,
  281. USB_GET_MAXPACKETSIZE(ep_desc->wMaxPacketSize),
  282. ep_desc->bInterval,
  283. USB_GET_MULT(ep_desc->wMaxPacketSize));
  284. } else {
  285. for (uint8_t i = 0; i < video_class->num_of_intf_altsettings; i++) {
  286. if (i == 0) {
  287. USB_LOG_RAW("Ingore altsetting 0\r\n");
  288. continue;
  289. }
  290. ep_desc = &video_class->hport->config.intf[video_class->data_intf].altsetting[i].ep[0].ep_desc;
  291. USB_LOG_RAW("Altsetting:%u, Ep=%02x Attr=%02u Mps=%d Interval=%02u Mult=%02u\r\n",
  292. i,
  293. ep_desc->bEndpointAddress,
  294. ep_desc->bmAttributes,
  295. USB_GET_MAXPACKETSIZE(ep_desc->wMaxPacketSize),
  296. ep_desc->bInterval,
  297. USB_GET_MULT(ep_desc->wMaxPacketSize));
  298. }
  299. }
  300. USB_LOG_RAW("bNumFormats:%u\r\n", video_class->num_of_formats);
  301. for (uint8_t i = 0; i < video_class->num_of_formats; i++) {
  302. USB_LOG_RAW(" FormatIndex:%u\r\n", i + 1);
  303. USB_LOG_RAW(" FormatType:%s\r\n", format_type[video_class->format[i].format_type]);
  304. USB_LOG_RAW(" bNumFrames:%u\r\n", video_class->format[i].num_of_frames);
  305. USB_LOG_RAW(" Resolution:\r\n");
  306. for (uint8_t j = 0; j < video_class->format[i].num_of_frames; j++) {
  307. USB_LOG_RAW(" FrameIndex:%u\r\n", j + 1);
  308. USB_LOG_RAW(" wWidth: %d, wHeight: %d, fps: %d\r\n",
  309. video_class->format[i].frame[j].wWidth,
  310. video_class->format[i].frame[j].wHeight,
  311. (1000 / (video_class->format[i].frame[j].dwDefaultFrameInterval / 10000)));
  312. }
  313. }
  314. USB_LOG_INFO("============= Video device information ===================\r\n");
  315. }
  316. static int usbh_video_ctrl_connect(struct usbh_hubport *hport, uint8_t intf)
  317. {
  318. int ret;
  319. uint8_t cur_iface = 0xff;
  320. // uint8_t cur_alt_setting = 0xff;
  321. uint8_t frame_index = 0xff;
  322. uint8_t format_index = 0xff;
  323. uint8_t num_of_frames = 0xff;
  324. uint8_t *p;
  325. struct usbh_video *video_class = usbh_video_class_alloc();
  326. if (video_class == NULL) {
  327. USB_LOG_ERR("Fail to alloc video_class\r\n");
  328. return -USB_ERR_NOMEM;
  329. }
  330. video_class->hport = hport;
  331. video_class->ctrl_intf = intf;
  332. video_class->data_intf = intf + 1;
  333. video_class->num_of_intf_altsettings = hport->config.intf[intf + 1].altsetting_num;
  334. hport->config.intf[intf].priv = video_class;
  335. ret = usbh_video_close(video_class);
  336. if (ret < 0) {
  337. USB_LOG_ERR("Fail to close video device\r\n");
  338. return ret;
  339. }
  340. p = hport->raw_config_desc;
  341. while (p[DESC_bLength]) {
  342. switch (p[DESC_bDescriptorType]) {
  343. case USB_DESCRIPTOR_TYPE_INTERFACE:
  344. cur_iface = p[INTF_DESC_bInterfaceNumber];
  345. //cur_alt_setting = p[INTF_DESC_bAlternateSetting];
  346. break;
  347. case USB_DESCRIPTOR_TYPE_ENDPOINT:
  348. //ep_desc = (struct usb_endpoint_descriptor *)p;
  349. break;
  350. case VIDEO_CS_INTERFACE_DESCRIPTOR_TYPE:
  351. if (cur_iface == video_class->ctrl_intf) {
  352. switch (p[DESC_bDescriptorSubType]) {
  353. case VIDEO_VC_HEADER_DESCRIPTOR_SUBTYPE:
  354. video_class->bcdVDC = ((uint16_t)p[4] << 8) | (uint16_t)p[3];
  355. break;
  356. case VIDEO_VC_INPUT_TERMINAL_DESCRIPTOR_SUBTYPE:
  357. break;
  358. case VIDEO_VC_OUTPUT_TERMINAL_DESCRIPTOR_SUBTYPE:
  359. break;
  360. case VIDEO_VC_PROCESSING_UNIT_DESCRIPTOR_SUBTYPE:
  361. break;
  362. default:
  363. break;
  364. }
  365. } else if (cur_iface == video_class->data_intf) {
  366. switch (p[DESC_bDescriptorSubType]) {
  367. case VIDEO_VS_INPUT_HEADER_DESCRIPTOR_SUBTYPE:
  368. video_class->num_of_formats = p[DESC_bNumFormats];
  369. break;
  370. case VIDEO_VS_FORMAT_UNCOMPRESSED_DESCRIPTOR_SUBTYPE:
  371. format_index = p[DESC_bFormatIndex];
  372. num_of_frames = p[DESC_bNumFrameDescriptors];
  373. video_class->format[format_index - 1].num_of_frames = num_of_frames;
  374. video_class->format[format_index - 1].format_type = USBH_VIDEO_FORMAT_UNCOMPRESSED;
  375. break;
  376. case VIDEO_VS_FORMAT_MJPEG_DESCRIPTOR_SUBTYPE:
  377. format_index = p[DESC_bFormatIndex];
  378. num_of_frames = p[DESC_bNumFrameDescriptors];
  379. video_class->format[format_index - 1].num_of_frames = num_of_frames;
  380. video_class->format[format_index - 1].format_type = USBH_VIDEO_FORMAT_MJPEG;
  381. break;
  382. case VIDEO_VS_FRAME_UNCOMPRESSED_DESCRIPTOR_SUBTYPE:
  383. frame_index = p[DESC_bFrameIndex];
  384. video_class->format[format_index - 1].frame[frame_index - 1].wWidth = ((struct video_cs_if_vs_frame_uncompressed_descriptor *)p)->wWidth;
  385. video_class->format[format_index - 1].frame[frame_index - 1].wHeight = ((struct video_cs_if_vs_frame_uncompressed_descriptor *)p)->wHeight;
  386. video_class->format[format_index - 1].frame[frame_index - 1].dwDefaultFrameInterval = ((struct video_cs_if_vs_frame_uncompressed_descriptor *)p)->dwDefaultFrameInterval;
  387. break;
  388. case VIDEO_VS_FRAME_MJPEG_DESCRIPTOR_SUBTYPE:
  389. frame_index = p[DESC_bFrameIndex];
  390. video_class->format[format_index - 1].frame[frame_index - 1].wWidth = ((struct video_cs_if_vs_frame_mjpeg_descriptor *)p)->wWidth;
  391. video_class->format[format_index - 1].frame[frame_index - 1].wHeight = ((struct video_cs_if_vs_frame_mjpeg_descriptor *)p)->wHeight;
  392. video_class->format[format_index - 1].frame[frame_index - 1].dwDefaultFrameInterval = ((struct video_cs_if_vs_frame_mjpeg_descriptor *)p)->dwDefaultFrameInterval;
  393. break;
  394. default:
  395. break;
  396. }
  397. }
  398. break;
  399. default:
  400. break;
  401. }
  402. /* skip to next descriptor */
  403. p += p[DESC_bLength];
  404. }
  405. usbh_video_list_info(video_class);
  406. snprintf(hport->config.intf[intf].devname, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, video_class->minor);
  407. USB_LOG_INFO("Register Video Class:%s\r\n", hport->config.intf[intf].devname);
  408. usbh_video_run(video_class);
  409. return ret;
  410. }
  411. static int usbh_video_ctrl_disconnect(struct usbh_hubport *hport, uint8_t intf)
  412. {
  413. int ret = 0;
  414. struct usbh_video *video_class = (struct usbh_video *)hport->config.intf[intf].priv;
  415. if (video_class) {
  416. if (hport->config.intf[intf].devname[0] != '\0') {
  417. usb_osal_thread_schedule_other();
  418. USB_LOG_INFO("Unregister Video Class:%s\r\n", hport->config.intf[intf].devname);
  419. usbh_video_stop(video_class);
  420. }
  421. usbh_video_class_free(video_class);
  422. }
  423. return ret;
  424. }
  425. static int usbh_video_streaming_connect(struct usbh_hubport *hport, uint8_t intf)
  426. {
  427. (void)hport;
  428. (void)intf;
  429. return 0;
  430. }
  431. static int usbh_video_streaming_disconnect(struct usbh_hubport *hport, uint8_t intf)
  432. {
  433. (void)hport;
  434. (void)intf;
  435. return 0;
  436. }
  437. __WEAK void usbh_video_run(struct usbh_video *video_class)
  438. {
  439. (void)video_class;
  440. }
  441. __WEAK void usbh_video_stop(struct usbh_video *video_class)
  442. {
  443. (void)video_class;
  444. }
  445. const struct usbh_class_driver video_ctrl_class_driver = {
  446. .driver_name = "video_ctrl",
  447. .connect = usbh_video_ctrl_connect,
  448. .disconnect = usbh_video_ctrl_disconnect
  449. };
  450. const struct usbh_class_driver video_streaming_class_driver = {
  451. .driver_name = "video_streaming",
  452. .connect = usbh_video_streaming_connect,
  453. .disconnect = usbh_video_streaming_disconnect
  454. };
  455. CLASS_INFO_DEFINE const struct usbh_class_info video_ctrl_class_info = {
  456. .match_flags = USB_CLASS_MATCH_INTF_CLASS | USB_CLASS_MATCH_INTF_SUBCLASS | USB_CLASS_MATCH_INTF_PROTOCOL,
  457. .bInterfaceClass = USB_DEVICE_CLASS_VIDEO,
  458. .bInterfaceSubClass = VIDEO_SC_VIDEOCONTROL,
  459. .bInterfaceProtocol = VIDEO_PC_PROTOCOL_UNDEFINED,
  460. .id_table = NULL,
  461. .class_driver = &video_ctrl_class_driver
  462. };
  463. CLASS_INFO_DEFINE const struct usbh_class_info video_streaming_class_info = {
  464. .match_flags = USB_CLASS_MATCH_INTF_CLASS | USB_CLASS_MATCH_INTF_SUBCLASS | USB_CLASS_MATCH_INTF_PROTOCOL,
  465. .bInterfaceClass = USB_DEVICE_CLASS_VIDEO,
  466. .bInterfaceSubClass = VIDEO_SC_VIDEOSTREAMING,
  467. .bInterfaceProtocol = VIDEO_PC_PROTOCOL_UNDEFINED,
  468. .id_table = NULL,
  469. .class_driver = &video_streaming_class_driver
  470. };