This source file includes following definitions.
- to_gspca_buffer
1
2 #ifndef GSPCAV2_H
3 #define GSPCAV2_H
4
5 #include <linux/module.h>
6 #include <linux/kernel.h>
7 #include <linux/usb.h>
8 #include <linux/videodev2.h>
9 #include <media/v4l2-common.h>
10 #include <media/v4l2-ctrls.h>
11 #include <media/v4l2-device.h>
12 #include <media/videobuf2-v4l2.h>
13 #include <media/videobuf2-vmalloc.h>
14 #include <linux/mutex.h>
15
16
17
18
19
20 #define D_PROBE 1
21 #define D_CONF 2
22 #define D_STREAM 3
23 #define D_FRAM 4
24 #define D_PACK 5
25 #define D_USBI 6
26 #define D_USBO 7
27
28 extern int gspca_debug;
29
30
31 #define gspca_dbg(gspca_dev, level, fmt, ...) \
32 v4l2_dbg(level, gspca_debug, &(gspca_dev)->v4l2_dev, \
33 fmt, ##__VA_ARGS__)
34
35 #define gspca_err(gspca_dev, fmt, ...) \
36 v4l2_err(&(gspca_dev)->v4l2_dev, fmt, ##__VA_ARGS__)
37
38 #define GSPCA_MAX_FRAMES 16
39
40 #define MAX_NURBS 4
41
42
43
44 struct framerates {
45 const u8 *rates;
46 int nrates;
47 };
48
49
50 struct cam {
51 const struct v4l2_pix_format *cam_mode;
52 const struct framerates *mode_framerates;
53
54 u32 bulk_size;
55 u32 input_flags;
56 u8 nmodes;
57 u8 no_urb_create;
58 u8 bulk_nurbs;
59
60
61
62 u8 bulk;
63 u8 npkt;
64
65 u8 needs_full_bandwidth;
66
67
68 };
69
70 struct gspca_dev;
71 struct gspca_frame;
72
73
74 typedef int (*cam_op) (struct gspca_dev *);
75 typedef void (*cam_v_op) (struct gspca_dev *);
76 typedef int (*cam_cf_op) (struct gspca_dev *, const struct usb_device_id *);
77 typedef int (*cam_get_jpg_op) (struct gspca_dev *,
78 struct v4l2_jpegcompression *);
79 typedef int (*cam_set_jpg_op) (struct gspca_dev *,
80 const struct v4l2_jpegcompression *);
81 typedef int (*cam_get_reg_op) (struct gspca_dev *,
82 struct v4l2_dbg_register *);
83 typedef int (*cam_set_reg_op) (struct gspca_dev *,
84 const struct v4l2_dbg_register *);
85 typedef int (*cam_chip_info_op) (struct gspca_dev *,
86 struct v4l2_dbg_chip_info *);
87 typedef void (*cam_streamparm_op) (struct gspca_dev *,
88 struct v4l2_streamparm *);
89 typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev,
90 u8 *data,
91 int len);
92 typedef int (*cam_int_pkt_op) (struct gspca_dev *gspca_dev,
93 u8 *data,
94 int len);
95 typedef void (*cam_format_op) (struct gspca_dev *gspca_dev,
96 struct v4l2_format *fmt);
97 typedef int (*cam_frmsize_op) (struct gspca_dev *gspca_dev,
98 struct v4l2_frmsizeenum *fsize);
99
100
101 struct sd_desc {
102
103 const char *name;
104
105 cam_cf_op config;
106 cam_op init;
107 cam_op init_controls;
108 cam_op start;
109 cam_pkt_op pkt_scan;
110
111 cam_op isoc_init;
112 cam_op isoc_nego;
113 cam_v_op stopN;
114 cam_v_op stop0;
115 cam_v_op dq_callback;
116 cam_get_jpg_op get_jcomp;
117 cam_set_jpg_op set_jcomp;
118 cam_streamparm_op get_streamparm;
119 cam_streamparm_op set_streamparm;
120 cam_format_op try_fmt;
121 cam_frmsize_op enum_framesizes;
122 #ifdef CONFIG_VIDEO_ADV_DEBUG
123 cam_set_reg_op set_register;
124 cam_get_reg_op get_register;
125 cam_chip_info_op get_chip_info;
126 #endif
127 #if IS_ENABLED(CONFIG_INPUT)
128 cam_int_pkt_op int_pkt_scan;
129
130
131 u8 other_input;
132 #endif
133 };
134
135
136 enum gspca_packet_type {
137 DISCARD_PACKET,
138 FIRST_PACKET,
139 INTER_PACKET,
140 LAST_PACKET
141 };
142
143 struct gspca_buffer {
144 struct vb2_v4l2_buffer vb;
145 struct list_head list;
146 };
147
148 static inline struct gspca_buffer *to_gspca_buffer(struct vb2_buffer *vb2)
149 {
150 return container_of(vb2, struct gspca_buffer, vb.vb2_buf);
151 }
152
153 struct gspca_dev {
154 struct video_device vdev;
155 struct module *module;
156 struct v4l2_device v4l2_dev;
157 struct usb_device *dev;
158
159 #if IS_ENABLED(CONFIG_INPUT)
160 struct input_dev *input_dev;
161 char phys[64];
162 #endif
163
164 struct cam cam;
165 const struct sd_desc *sd_desc;
166 struct v4l2_ctrl_handler ctrl_handler;
167
168
169
170 struct {
171 struct v4l2_ctrl *autogain;
172 struct v4l2_ctrl *exposure;
173 struct v4l2_ctrl *gain;
174 int exp_too_low_cnt, exp_too_high_cnt;
175 };
176
177 #define USB_BUF_SZ 64
178 __u8 *usb_buf;
179 struct urb *urb[MAX_NURBS];
180 #if IS_ENABLED(CONFIG_INPUT)
181 struct urb *int_urb;
182 #endif
183
184 u8 *image;
185 u32 image_len;
186 __u8 last_packet_type;
187 __s8 empty_packet;
188 bool streaming;
189
190 __u8 curr_mode;
191 struct v4l2_pix_format pixfmt;
192 __u32 sequence;
193
194 struct vb2_queue queue;
195
196 spinlock_t qlock;
197 struct list_head buf_list;
198
199 wait_queue_head_t wq;
200 struct mutex usb_lock;
201 int usb_err;
202 u16 pkt_size;
203 #ifdef CONFIG_PM
204 char frozen;
205 #endif
206 bool present;
207 char memory;
208 __u8 iface;
209 __u8 alt;
210 int xfer_ep;
211 u8 audio;
212
213
214
215
216 };
217
218 int gspca_dev_probe(struct usb_interface *intf,
219 const struct usb_device_id *id,
220 const struct sd_desc *sd_desc,
221 int dev_size,
222 struct module *module);
223 int gspca_dev_probe2(struct usb_interface *intf,
224 const struct usb_device_id *id,
225 const struct sd_desc *sd_desc,
226 int dev_size,
227 struct module *module);
228 void gspca_disconnect(struct usb_interface *intf);
229 void gspca_frame_add(struct gspca_dev *gspca_dev,
230 enum gspca_packet_type packet_type,
231 const u8 *data,
232 int len);
233 #ifdef CONFIG_PM
234 int gspca_suspend(struct usb_interface *intf, pm_message_t message);
235 int gspca_resume(struct usb_interface *intf);
236 #endif
237 int gspca_expo_autogain(struct gspca_dev *gspca_dev, int avg_lum,
238 int desired_avg_lum, int deadzone, int gain_knee, int exposure_knee);
239 int gspca_coarse_grained_expo_autogain(struct gspca_dev *gspca_dev,
240 int avg_lum, int desired_avg_lum, int deadzone);
241
242 #endif