aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/gspca.h
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-04-12 08:58:09 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:14:28 -0400
commit63eb9546dcb5e9dc39ab88a603dede8fdd18e717 (patch)
treec61a8365a0428a58f643df35b29220f1c5e63f46 /drivers/media/video/gspca/gspca.h
parent8b53b39d6228cda41b7ddfc9d094a072afca6655 (diff)
V4L/DVB (8152): Initial release of gspca with only one driver.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/gspca/gspca.h')
-rw-r--r--drivers/media/video/gspca/gspca.h178
1 files changed, 178 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
new file mode 100644
index 000000000000..1394ab13f1f4
--- /dev/null
+++ b/drivers/media/video/gspca/gspca.h
@@ -0,0 +1,178 @@
1#ifndef GSPCAV2_H
2#define GSPCAV2_H
3
4#include <linux/module.h>
5#include <linux/version.h>
6#include <linux/kernel.h>
7#include <linux/usb.h>
8#include <linux/videodev2.h>
9#include <media/v4l2-common.h>
10#include <linux/mutex.h>
11
12#ifdef GSPCA_DEBUG
13/* GSPCA our debug messages */
14extern int gspca_debug;
15#define PDEBUG(level, fmt, args...) \
16 do {\
17 if (gspca_debug & (level)) \
18 printk(KERN_INFO MODULE_NAME ": " fmt "\n", ## args); \
19 } while (0)
20#define D_ERR 0x01
21#define D_PROBE 0x02
22#define D_CONF 0x04
23#define D_STREAM 0x08
24#define D_FRAM 0x10
25#define D_PACK 0x20
26#define D_USBI 0x40
27#define D_USBO 0x80
28#else
29#define PDEBUG(level, fmt, args...)
30#endif
31#undef err
32#define err(fmt, args...) \
33 do {\
34 printk(KERN_ERR MODULE_NAME ": " fmt "\n", ## args); \
35 } while (0)
36#undef info
37#define info(fmt, args...) \
38 do {\
39 printk(KERN_INFO MODULE_NAME ": " fmt "\n", ## args); \
40 } while (0)
41#undef warn
42#define warn(fmt, args...) \
43 do {\
44 printk(KERN_WARNING MODULE_NAME ": " fmt "\n", ## args); \
45 } while (0)
46
47#define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */
48/* ISOC transfers */
49#define NURBS 4 /* number of URBs */
50#define ISO_MAX_PKT 32 /* max number of packets in an ISOC transfer */
51#define ISO_MAX_SIZE 0x10000 /* max size of one URB buffer (64 Kb) */
52
53/* device information - set at probe time */
54struct cam_mode {
55 __u32 pixfmt;
56 short width;
57 short height;
58 short mode; /* subdriver value */
59 short reserved; /* subdriver value */
60};
61struct cam {
62 char *dev_name;
63 struct cam_mode *cam_mode; /* size nmodes */
64 char nmodes;
65 __u8 epaddr;
66};
67
68struct gspca_dev;
69struct gspca_frame;
70
71/* subdriver operations */
72typedef int (*cam_op) (struct gspca_dev *);
73typedef void (*cam_v_op) (struct gspca_dev *);
74typedef int (*cam_cf_op) (struct gspca_dev *, const struct usb_device_id *);
75typedef int (*cam_jpg_op) (struct gspca_dev *,
76 struct v4l2_jpegcompression *);
77typedef int (*cam_qmnu_op) (struct gspca_dev *,
78 struct v4l2_querymenu *);
79typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev,
80 struct gspca_frame *frame,
81 unsigned char *data,
82 int len);
83
84struct ctrl {
85 struct v4l2_queryctrl qctrl;
86 int (*set)(struct gspca_dev *, __s32);
87 int (*get)(struct gspca_dev *, __s32 *);
88};
89
90/* subdriver description */
91struct sd_desc {
92/* information */
93 char *name; /* sub-driver name */
94/* controls */
95 struct ctrl *ctrls;
96 int nctrls;
97/* operations */
98 cam_cf_op config; /* called on probe */
99 cam_op open; /* called on open */
100 cam_v_op start; /* called on stream on */
101 cam_v_op stopN; /* called on stream off - main alt */
102 cam_v_op stop0; /* called on stream off - alt 0 */
103 cam_v_op close; /* called on close */
104 cam_pkt_op pkt_scan;
105 cam_jpg_op get_jcomp;
106 cam_jpg_op set_jcomp;
107 cam_qmnu_op querymenu;
108};
109
110struct gspca_pktbuf {
111 char *data;
112 struct urb *urb;
113};
114
115/* packet types when moving from iso buf to frame buf */
116#define DISCARD_PACKET 0
117#define FIRST_PACKET 1
118#define INTER_PACKET 2
119#define LAST_PACKET 3
120
121struct gspca_frame {
122 unsigned char *data; /* frame buffer */
123 unsigned char *data_end; /* current end of frame while filling */
124 int vma_use_count;
125 struct v4l2_buffer v4l2_buf;
126};
127
128struct gspca_dev {
129 struct video_device vdev; /* !! must be the first item */
130 struct usb_device *dev;
131
132 struct cam cam; /* device information */
133 const struct sd_desc *sd_desc; /* subdriver description */
134
135 struct gspca_pktbuf pktbuf[NURBS];
136
137 __u8 *frbuf; /* buffer for nframes */
138 struct gspca_frame frame[GSPCA_MAX_FRAMES];
139 unsigned int frsz; /* frame size */
140 char nframes; /* number of frames */
141 char fr_i; /* frame being filled */
142 char fr_q; /* next frame to queue */
143 char fr_o; /* next frame to dequeue */
144 signed char fr_queue[GSPCA_MAX_FRAMES]; /* frame queue */
145 char last_packet_type;
146
147 __u8 iface; /* USB interface number */
148 __u8 alt; /* USB alternate setting */
149 char curr_mode; /* current camera mode */
150 __u32 pixfmt; /* current mode parameters */
151 short width;
152 short height;
153
154 atomic_t nevent; /* number of frames done */
155 wait_queue_head_t wq; /* wait queue */
156 struct mutex usb_lock; /* usb exchange protection */
157 struct mutex read_lock; /* read protection */
158 struct mutex queue_lock; /* ISOC queue protection */
159 __u32 sequence; /* frame sequence number */
160 signed char streaming;
161 char users; /* # open */
162 char present; /* device connected */
163 char nbufread; /* number of buffers for read() */
164};
165
166int gspca_dev_probe(struct usb_interface *intf,
167 const struct usb_device_id *id,
168 const struct sd_desc *sd_desc,
169 int dev_size);
170int gspca_dev_init(struct gspca_dev *gspca_dev,
171 struct usb_interface *intf);
172void gspca_disconnect(struct usb_interface *intf);
173struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
174 int packet_type,
175 struct gspca_frame *frame,
176 unsigned char *data,
177 int len);
178#endif /* GSPCAV2_H */