Files
CherryUSB/class/video/usbh_video.h

87 lines
2.2 KiB
C
Raw Permalink Normal View History

2022-09-23 22:02:03 +08:00
/*
* Copyright (c) 2022, sakumisu
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef USBH_VIDEO_H
#define USBH_VIDEO_H
#include "usb_video.h"
#define USBH_VIDEO_FORMAT_UNCOMPRESSED 0
#define USBH_VIDEO_FORMAT_MJPEG 1
struct usbh_video_resolution {
uint16_t wWidth;
uint16_t wHeight;
uint32_t dwDefaultFrameInterval;
2022-09-23 22:02:03 +08:00
};
struct usbh_video_format {
2023-03-22 14:57:47 +08:00
struct usbh_video_resolution frame[12];
2022-09-23 22:02:03 +08:00
uint8_t format_type;
uint8_t num_of_frames;
};
2024-04-07 23:30:51 +08:00
struct usbh_videoframe {
uint8_t *frame_buf;
uint32_t frame_bufsize;
uint32_t frame_format;
uint32_t frame_size;
};
2022-09-23 22:02:03 +08:00
struct usbh_videostreaming {
2024-04-07 23:30:51 +08:00
struct usbh_videoframe *frame;
uint32_t frame_format;
2022-09-23 22:02:03 +08:00
uint32_t bufoffset;
2023-08-25 21:36:27 +08:00
uint16_t width;
2024-04-07 23:30:51 +08:00
uint16_t height;
2022-09-23 22:02:03 +08:00
};
struct usbh_video {
struct usbh_hubport *hport;
struct usb_endpoint_descriptor *isoin; /* ISO IN endpoint */
struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */
2022-09-23 22:02:03 +08:00
uint8_t ctrl_intf; /* interface number */
uint8_t data_intf; /* interface number */
uint8_t minor;
struct video_probe_and_commit_controls probe;
struct video_probe_and_commit_controls commit;
uint16_t isoin_mps;
bool is_opened;
2022-12-31 14:10:27 +08:00
uint8_t current_format;
bool is_bulk;
2022-09-23 22:02:03 +08:00
uint16_t bcdVDC;
2022-09-24 17:15:40 +08:00
uint8_t num_of_intf_altsettings;
2022-09-23 22:02:03 +08:00
uint8_t num_of_formats;
struct usbh_video_format format[3];
void *user_data;
2022-09-23 22:02:03 +08:00
};
#ifdef __cplusplus
extern "C" {
#endif
2023-11-13 19:50:04 +08:00
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);
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);
2022-09-23 22:02:03 +08:00
2022-12-31 14:10:27 +08:00
int usbh_video_open(struct usbh_video *video_class,
uint8_t format_type,
uint16_t wWidth,
uint16_t wHeight,
uint8_t altsetting);
2022-09-23 22:02:03 +08:00
int usbh_video_close(struct usbh_video *video_class);
void usbh_video_list_info(struct usbh_video *video_class);
2022-11-26 23:52:58 +08:00
void usbh_video_run(struct usbh_video *video_class);
void usbh_video_stop(struct usbh_video *video_class);
2022-09-23 22:02:03 +08:00
#ifdef __cplusplus
}
#endif
#endif /* USBH_VIDEO_H */