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