21#include <linux/ioctl.h>
22#include <linux/types.h>
23#include <linux/usb/ch9.h>
25#define UVC_EVENT_FIRST (V4L2_EVENT_PRIVATE_START + 0)
26#define UVC_EVENT_CONNECT (V4L2_EVENT_PRIVATE_START + 0)
27#define UVC_EVENT_DISCONNECT (V4L2_EVENT_PRIVATE_START + 1)
28#define UVC_EVENT_STREAMON (V4L2_EVENT_PRIVATE_START + 2)
29#define UVC_EVENT_STREAMOFF (V4L2_EVENT_PRIVATE_START + 3)
30#define UVC_EVENT_SETUP (V4L2_EVENT_PRIVATE_START + 4)
31#define UVC_EVENT_DATA (V4L2_EVENT_PRIVATE_START + 5)
32#define UVC_EVENT_LAST (V4L2_EVENT_PRIVATE_START + 5)
35#define UVC_MAX_REQUEST_SIZE 512
46 struct usb_ctrlrequest
req;
51#define UVCIOC_SEND_RESPONSE _IOW('U', 1, struct uvc_request_data)
53#define UVC_INTF_CONTROL 0
54#define UVC_INTF_STREAMING 1
63#include <linux/usb/gadget.h>
64#include <linux/videodev2.h>
65#include <linux/version.h>
66#include <media/v4l2-fh.h>
70#define UVC_TRACE_PROBE (1 << 0)
71#define UVC_TRACE_DESCR (1 << 1)
72#define UVC_TRACE_CONTROL (1 << 2)
73#define UVC_TRACE_FORMAT (1 << 3)
74#define UVC_TRACE_CAPTURE (1 << 4)
75#define UVC_TRACE_CALLS (1 << 5)
76#define UVC_TRACE_IOCTL (1 << 6)
77#define UVC_TRACE_FRAME (1 << 7)
78#define UVC_TRACE_SUSPEND (1 << 8)
79#define UVC_TRACE_STATUS (1 << 9)
81#define UVC_WARN_MINMAX 0
82#define UVC_WARN_PROBE_DEF 1
84extern unsigned int uvc_gadget_trace_param;
86#define uvc_trace(flag, msg...) \
88 if (uvc_gadget_trace_param & flag) \
89 printk(KERN_DEBUG "uvcvideo: " msg); \
92#define uvc_warn_once(dev, warn, msg...) \
94 if (!test_and_set_bit(warn, &dev->warnings)) \
95 printk(KERN_INFO "uvcvideo: " msg); \
98#define uvc_printk(level, msg...) \
99 printk(level "uvcvideo: " msg)
105#define DRIVER_VERSION "0.1.0"
106#define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 0)
108#define DMA_ADDR_INVALID (~(dma_addr_t)0)
110#define UVC_NUM_REQUESTS 4
111#define UVC_MAX_EVENTS 4
126 unsigned int imagesize;
129 unsigned int req_size;
130 struct usb_request *req[UVC_NUM_REQUESTS];
131 __u8 *req_buffer[UVC_NUM_REQUESTS];
132 struct list_head req_free;
135 void (*encode) (
struct usb_request *req,
struct uvc_video *video,
136 struct uvc_buffer *buf);
140 __u32 max_payload_size;
142 struct uvc_video_queue queue;
148 UVC_STATE_DISCONNECTED,
155 struct video_device *vdev;
156 enum uvc_state state;
157 struct usb_function func;
158 struct uvc_video video;
162 const struct uvc_descriptor_header *
const *control;
163 const struct uvc_descriptor_header *
const *fs_streaming;
164 const struct uvc_descriptor_header *
const *hs_streaming;
167 unsigned int control_intf;
168 struct usb_ep *control_ep;
169 struct usb_request *control_req;
172 unsigned int streaming_intf;
175 unsigned int event_length;
176 unsigned int event_setup_out : 1;
179static inline struct uvc_device *to_uvc(
struct usb_function *f)
181 return container_of(f,
struct uvc_device, func);
184struct uvc_file_handle
187 struct uvc_video *device;
190#define to_uvc_file_handle(handle) \
191 container_of(handle, struct uvc_file_handle, vfh)
197extern void uvc_endpoint_stream(
struct uvc_device *dev);
199extern void uvc_function_connect(
struct uvc_device *uvc);
200extern void uvc_function_disconnect(
struct uvc_device *uvc);
struct usb_ctrlrequest req
enum usb_device_speed speed
struct uvc_request_data data
__u8 data[UVC_MAX_REQUEST_SIZE - sizeof(__s32)]
#define UVC_MAX_REQUEST_SIZE