]> Pileus Git - ~andy/linux/blob - drivers/media/video/gspca/gspca.h
V4L/DVB (8671): gspca: Remove the unused field 'dev_name' of the device structure.
[~andy/linux] / drivers / media / video / gspca / gspca.h
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 /* compilation option */
13 #define GSPCA_DEBUG 1
14
15 #ifdef GSPCA_DEBUG
16 /* GSPCA our debug messages */
17 extern int gspca_debug;
18 #define PDEBUG(level, fmt, args...) \
19         do {\
20                 if (gspca_debug & (level)) \
21                         printk(KERN_INFO MODULE_NAME ": " fmt "\n", ## args); \
22         } while (0)
23 #define D_ERR  0x01
24 #define D_PROBE 0x02
25 #define D_CONF 0x04
26 #define D_STREAM 0x08
27 #define D_FRAM 0x10
28 #define D_PACK 0x20
29 #define D_USBI 0x40
30 #define D_USBO 0x80
31 #define D_V4L2 0x0100
32 #else
33 #define PDEBUG(level, fmt, args...)
34 #endif
35 #undef err
36 #define err(fmt, args...) \
37         do {\
38                 printk(KERN_ERR MODULE_NAME ": " fmt "\n", ## args); \
39         } while (0)
40 #undef info
41 #define info(fmt, args...) \
42         do {\
43                 printk(KERN_INFO MODULE_NAME ": " fmt "\n", ## args); \
44         } while (0)
45 #undef warn
46 #define warn(fmt, args...) \
47         do {\
48                 printk(KERN_WARNING MODULE_NAME ": " fmt "\n", ## args); \
49         } while (0)
50
51 #define GSPCA_MAX_FRAMES 16     /* maximum number of video frame buffers */
52 /* ISOC transfers */
53 #define MAX_NURBS 16            /* max number of URBs */
54 #define ISO_MAX_PKT 32          /* max number of packets in an ISOC transfer */
55 #define ISO_MAX_SIZE 0x8000     /* max size of one URB buffer (32 Kb) */
56
57 /* device information - set at probe time */
58 struct cam {
59         struct v4l2_pix_format *cam_mode;       /* size nmodes */
60         char nmodes;
61         __u8 epaddr;
62 };
63
64 struct gspca_dev;
65 struct gspca_frame;
66
67 /* subdriver operations */
68 typedef int (*cam_op) (struct gspca_dev *);
69 typedef void (*cam_v_op) (struct gspca_dev *);
70 typedef int (*cam_cf_op) (struct gspca_dev *, const struct usb_device_id *);
71 typedef int (*cam_jpg_op) (struct gspca_dev *,
72                                 struct v4l2_jpegcompression *);
73 typedef int (*cam_qmnu_op) (struct gspca_dev *,
74                         struct v4l2_querymenu *);
75 typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev,
76                                 struct gspca_frame *frame,
77                                 __u8 *data,
78                                 int len);
79
80 struct ctrl {
81         struct v4l2_queryctrl qctrl;
82         int (*set)(struct gspca_dev *, __s32);
83         int (*get)(struct gspca_dev *, __s32 *);
84 };
85
86 /* subdriver description */
87 struct sd_desc {
88 /* information */
89         const char *name;       /* sub-driver name */
90 /* controls */
91         const struct ctrl *ctrls;
92         int nctrls;
93 /* operations */
94         cam_cf_op config;       /* called on probe */
95         cam_op open;            /* called on open */
96         cam_v_op start;         /* called on stream on */
97         cam_v_op stopN;         /* called on stream off - main alt */
98         cam_v_op stop0;         /* called on stream off - alt 0 */
99         cam_v_op close;         /* called on close */
100         cam_pkt_op pkt_scan;
101 /* optional operations */
102         cam_v_op dq_callback;   /* called when a frame has been dequeued */
103         cam_jpg_op get_jcomp;
104         cam_jpg_op set_jcomp;
105         cam_qmnu_op querymenu;
106 };
107
108 /* packet types when moving from iso buf to frame buf */
109 #define DISCARD_PACKET  0
110 #define FIRST_PACKET    1
111 #define INTER_PACKET    2
112 #define LAST_PACKET     3
113
114 struct gspca_frame {
115         __u8 *data;                     /* frame buffer */
116         __u8 *data_end;                 /* end of frame while filling */
117         int vma_use_count;
118         struct v4l2_buffer v4l2_buf;
119 };
120
121 struct gspca_dev {
122         struct video_device vdev;       /* !! must be the first item */
123         struct file_operations fops;
124         struct usb_device *dev;
125         struct file *capt_file;         /* file doing video capture */
126
127         struct cam cam;                         /* device information */
128         const struct sd_desc *sd_desc;          /* subdriver description */
129
130         __u8 usb_buf[8];                        /* buffer for USB exchanges */
131         struct urb *urb[MAX_NURBS];
132
133         __u8 *frbuf;                            /* buffer for nframes */
134         struct gspca_frame frame[GSPCA_MAX_FRAMES];
135         __u32 frsz;                             /* frame size */
136         char nframes;                           /* number of frames */
137         char fr_i;                              /* frame being filled */
138         char fr_q;                              /* next frame to queue */
139         char fr_o;                              /* next frame to dequeue */
140         signed char fr_queue[GSPCA_MAX_FRAMES]; /* frame queue */
141         char last_packet_type;
142
143         __u8 iface;                     /* USB interface number */
144         __u8 alt;                       /* USB alternate setting */
145         __u8 curr_mode;                 /* current camera mode */
146         __u32 pixfmt;                   /* current mode parameters */
147         __u16 width;
148         __u16 height;
149
150         atomic_t nevent;                /* number of frames done */
151         wait_queue_head_t wq;           /* wait queue */
152         struct mutex usb_lock;          /* usb exchange protection */
153         struct mutex read_lock;         /* read protection */
154         struct mutex queue_lock;        /* ISOC queue protection */
155         __u32 sequence;                 /* frame sequence number */
156         char streaming;
157         char users;                     /* number of opens */
158         char present;                   /* device connected */
159         char nbufread;                  /* number of buffers for read() */
160         char nurbs;                     /* number of allocated URBs */
161         char memory;                    /* memory type (V4L2_MEMORY_xxx) */
162         __u8 nbalt;                     /* number of USB alternate settings */
163 };
164
165 int gspca_dev_probe(struct usb_interface *intf,
166                 const struct usb_device_id *id,
167                 const struct sd_desc *sd_desc,
168                 int dev_size,
169                 struct module *module);
170 void gspca_disconnect(struct usb_interface *intf);
171 struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
172                                     int packet_type,
173                                     struct gspca_frame *frame,
174                                     const __u8 *data,
175                                     int len);
176 int gspca_auto_gain_n_exposure(struct gspca_dev *gspca_dev, int avg_lum,
177         int desired_avg_lum, int deadzone, int gain_knee, int exposure_knee);
178 #endif /* GSPCAV2_H */