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_videostreaming { 26 uint32_t bufoffset; 27 uint32_t buflen; 28 uint16_t width; 29 uint16_t heigth; 30 void (*video_one_frame_callback)(struct usbh_videostreaming *stream); 31 }; 32 33 struct usbh_video { 34 struct usbh_hubport *hport; 35 36 uint8_t ctrl_intf; /* interface number */ 37 uint8_t data_intf; /* interface number */ 38 uint8_t minor; 39 usbh_pipe_t isoin; /* ISO IN endpoint */ 40 usbh_pipe_t isoout; /* ISO OUT endpoint */ 41 struct video_probe_and_commit_controls probe; 42 struct video_probe_and_commit_controls commit; 43 uint16_t isoin_mps; 44 uint16_t isoout_mps; 45 bool is_opened; 46 uint8_t current_format; 47 uint16_t bcdVDC; 48 uint8_t num_of_intf_altsettings; 49 uint8_t num_of_formats; 50 struct usbh_video_format format[3]; 51 }; 52 53 #ifdef __cplusplus 54 extern "C" { 55 #endif 56 57 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); 58 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); 59 60 int usbh_video_open(struct usbh_video *video_class, 61 uint8_t format_type, 62 uint16_t wWidth, 63 uint16_t wHeight, 64 uint8_t altsetting); 65 int usbh_video_close(struct usbh_video *video_class); 66 67 void usbh_video_list_info(struct usbh_video *video_class); 68 69 void usbh_video_run(struct usbh_video *video_class); 70 void usbh_video_stop(struct usbh_video *video_class); 71 72 #ifdef __cplusplus 73 } 74 #endif 75 76 #endif /* USBH_VIDEO_H */ 77