4 #include <linux/module.h>
5 #include <linux/version.h>
6 #include <linux/kernel.h>
8 #include <linux/videodev2.h>
9 #include <media/v4l2-common.h>
10 #include <linux/mutex.h>
12 /* values in 2.6.27 */
13 #ifndef V4L2_PIX_FMT_SPCA501
14 #define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1')
16 #ifndef V4L2_PIX_FMT_SPCA561
17 #define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1')
20 /* values in 2.6.26 */
21 #ifndef V4L2_CID_POWER_LINE_FREQUENCY
22 #define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24)
24 #ifndef V4L2_CID_WHITE_BALANCE_TEMPERATURE
25 #define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE + 26)
27 #ifndef V4L2_CID_SHARPNESS
28 #define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27)
31 #ifdef CONFIG_VIDEO_ADV_DEBUG
32 /* GSPCA our debug messages */
33 extern int gspca_debug;
34 #define PDEBUG(level, fmt, args...) \
36 if (gspca_debug & (level)) \
37 printk(KERN_INFO MODULE_NAME ": " fmt "\n", ## args); \
49 #define PDEBUG(level, fmt, args...)
52 #define err(fmt, args...) \
54 printk(KERN_ERR MODULE_NAME ": " fmt "\n", ## args); \
57 #define info(fmt, args...) \
59 printk(KERN_INFO MODULE_NAME ": " fmt "\n", ## args); \
62 #define warn(fmt, args...) \
64 printk(KERN_WARNING MODULE_NAME ": " fmt "\n", ## args); \
67 #define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */
69 #define MAX_NURBS 16 /* max number of URBs */
70 #define ISO_MAX_PKT 32 /* max number of packets in an ISOC transfer */
71 #define ISO_MAX_SIZE 0x8000 /* max size of one URB buffer (32 Kb) */
73 /* device information - set at probe time */
78 short mode; /* subdriver value */
79 short reserved; /* subdriver value */
83 struct cam_mode *cam_mode; /* size nmodes */
91 /* subdriver operations */
92 typedef int (*cam_op) (struct gspca_dev *);
93 typedef void (*cam_v_op) (struct gspca_dev *);
94 typedef int (*cam_cf_op) (struct gspca_dev *, const struct usb_device_id *);
95 typedef int (*cam_jpg_op) (struct gspca_dev *,
96 struct v4l2_jpegcompression *);
97 typedef int (*cam_qmnu_op) (struct gspca_dev *,
98 struct v4l2_querymenu *);
99 typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev,
100 struct gspca_frame *frame,
105 struct v4l2_queryctrl qctrl;
106 int (*set)(struct gspca_dev *, __s32);
107 int (*get)(struct gspca_dev *, __s32 *);
110 /* subdriver description */
113 char *name; /* sub-driver name */
118 cam_cf_op config; /* called on probe */
119 cam_op open; /* called on open */
120 cam_v_op start; /* called on stream on */
121 cam_v_op stopN; /* called on stream off - main alt */
122 cam_v_op stop0; /* called on stream off - alt 0 */
123 cam_v_op close; /* called on close */
124 cam_v_op dq_callback; /* called when a frame has been dequeued */
126 cam_jpg_op get_jcomp;
127 cam_jpg_op set_jcomp;
128 cam_qmnu_op querymenu;
131 /* packet types when moving from iso buf to frame buf */
132 #define DISCARD_PACKET 0
133 #define FIRST_PACKET 1
134 #define INTER_PACKET 2
135 #define LAST_PACKET 3
138 __u8 *data; /* frame buffer */
139 __u8 *data_end; /* end of frame while filling */
141 struct v4l2_buffer v4l2_buf;
145 struct video_device vdev; /* !! must be the first item */
146 struct file_operations fops;
147 struct usb_device *dev;
148 struct file *capt_file; /* file doing video capture */
150 struct cam cam; /* device information */
151 const struct sd_desc *sd_desc; /* subdriver description */
153 struct urb *urb[MAX_NURBS];
155 __u8 *frbuf; /* buffer for nframes */
156 struct gspca_frame frame[GSPCA_MAX_FRAMES];
157 __u32 frsz; /* frame size */
158 char nframes; /* number of frames */
159 char fr_i; /* frame being filled */
160 char fr_q; /* next frame to queue */
161 char fr_o; /* next frame to dequeue */
162 signed char fr_queue[GSPCA_MAX_FRAMES]; /* frame queue */
163 char last_packet_type;
165 __u8 iface; /* USB interface number */
166 __u8 alt; /* USB alternate setting */
167 __u8 curr_mode; /* current camera mode */
168 __u32 pixfmt; /* current mode parameters */
172 atomic_t nevent; /* number of frames done */
173 wait_queue_head_t wq; /* wait queue */
174 struct mutex usb_lock; /* usb exchange protection */
175 struct mutex read_lock; /* read protection */
176 struct mutex queue_lock; /* ISOC queue protection */
177 __u32 sequence; /* frame sequence number */
179 char users; /* number of opens */
180 char present; /* device connected */
181 char nbufread; /* number of buffers for read() */
182 char nurbs; /* number of allocated URBs */
183 char memory; /* memory type (V4L2_MEMORY_xxx) */
184 __u8 urb_in; /* URB pointers - used when !mmap */
186 __u8 nbalt; /* number of USB alternate settings */
189 int gspca_dev_probe(struct usb_interface *intf,
190 const struct usb_device_id *id,
191 const struct sd_desc *sd_desc,
193 struct module *module);
194 void gspca_disconnect(struct usb_interface *intf);
195 struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
197 struct gspca_frame *frame,
200 #endif /* GSPCAV2_H */