usbh_video.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2022, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef USBH_VIDEO_H
  7. #define USBH_VIDEO_H
  8. #include "usb_video.h"
  9. #define USBH_VIDEO_FORMAT_UNCOMPRESSED 0
  10. #define USBH_VIDEO_FORMAT_MJPEG 1
  11. struct usbh_video_resolution {
  12. uint16_t wWidth;
  13. uint16_t wHeight;
  14. };
  15. struct usbh_video_format {
  16. struct usbh_video_resolution frame[12];
  17. uint8_t format_type;
  18. uint8_t num_of_frames;
  19. };
  20. struct usbh_videoframe {
  21. uint8_t *frame_buf;
  22. uint32_t frame_bufsize;
  23. uint32_t frame_format;
  24. uint32_t frame_size;
  25. };
  26. struct usbh_videostreaming {
  27. struct usbh_videoframe *frame;
  28. uint32_t frame_format;
  29. uint32_t bufoffset;
  30. uint16_t width;
  31. uint16_t height;
  32. };
  33. struct usbh_video {
  34. struct usbh_hubport *hport;
  35. struct usb_endpoint_descriptor *isoin; /* ISO IN endpoint */
  36. struct usb_endpoint_descriptor *isoout; /* ISO OUT endpoint */
  37. uint8_t ctrl_intf; /* interface number */
  38. uint8_t data_intf; /* interface number */
  39. uint8_t minor;
  40. struct video_probe_and_commit_controls probe;
  41. struct video_probe_and_commit_controls commit;
  42. uint16_t isoin_mps;
  43. uint16_t isoout_mps;
  44. bool is_opened;
  45. uint8_t current_format;
  46. uint16_t bcdVDC;
  47. uint8_t num_of_intf_altsettings;
  48. uint8_t num_of_formats;
  49. struct usbh_video_format format[3];
  50. void *user_data;
  51. };
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. 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);
  56. 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);
  57. int usbh_video_open(struct usbh_video *video_class,
  58. uint8_t format_type,
  59. uint16_t wWidth,
  60. uint16_t wHeight,
  61. uint8_t altsetting);
  62. int usbh_video_close(struct usbh_video *video_class);
  63. void usbh_video_list_info(struct usbh_video *video_class);
  64. void usbh_video_run(struct usbh_video *video_class);
  65. void usbh_video_stop(struct usbh_video *video_class);
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69. #endif /* USBH_VIDEO_H */