aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig8
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile3
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h1
-rw-r--r--drivers/media/dvb/dvb-usb/dw2102.c425
-rw-r--r--drivers/media/dvb/dvb-usb/dw2102.h9
-rw-r--r--drivers/media/dvb/frontends/Kconfig14
-rw-r--r--drivers/media/dvb/frontends/Makefile1
-rw-r--r--drivers/media/dvb/frontends/drx397xD.c1504
-rw-r--r--drivers/media/dvb/frontends/drx397xD.h130
-rw-r--r--drivers/media/dvb/frontends/drx397xD_fw.h40
-rw-r--r--drivers/media/dvb/frontends/z0194a.h97
-rw-r--r--drivers/media/radio/dsbr100.c1
-rw-r--r--drivers/media/radio/miropcm20-radio.c1
-rw-r--r--drivers/media/radio/radio-aimslab.c1
-rw-r--r--drivers/media/radio/radio-aztech.c1
-rw-r--r--drivers/media/radio/radio-cadet.c1
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c1
-rw-r--r--drivers/media/radio/radio-gemtek.c1
-rw-r--r--drivers/media/radio/radio-maestro.c1
-rw-r--r--drivers/media/radio/radio-maxiradio.c1
-rw-r--r--drivers/media/radio/radio-rtrack2.c1
-rw-r--r--drivers/media/radio/radio-sf16fmi.c1
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c1
-rw-r--r--drivers/media/radio/radio-si470x.c1
-rw-r--r--drivers/media/radio/radio-terratec.c1
-rw-r--r--drivers/media/radio/radio-trust.c1
-rw-r--r--drivers/media/radio/radio-typhoon.c1
-rw-r--r--drivers/media/radio/radio-zoltrix.c1
-rw-r--r--drivers/media/video/Kconfig8
-rw-r--r--drivers/media/video/Makefile2
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c9
-rw-r--r--drivers/media/video/bt8xx/bttv-risc.c1
-rw-r--r--drivers/media/video/bt8xx/bttv-vbi.c1
-rw-r--r--drivers/media/video/bw-qcam.c1
-rw-r--r--drivers/media/video/c-qcam.c1
-rw-r--r--drivers/media/video/cafe_ccic.c3
-rw-r--r--drivers/media/video/compat_ioctl32.c2
-rw-r--r--drivers/media/video/cpia.h1
-rw-r--r--drivers/media/video/cpia2/cpia2_v4l.c1
-rw-r--r--drivers/media/video/cs5345.c2
-rw-r--r--drivers/media/video/cx18/cx18-driver.h1
-rw-r--r--drivers/media/video/cx18/cx18-firmware.c54
-rw-r--r--drivers/media/video/cx18/cx18-streams.c2
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c3
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c3
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c1
-rw-r--r--drivers/media/video/cx88/cx88-core.c3
-rw-r--r--drivers/media/video/cx88/cx88-video.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c3
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c3
-rw-r--r--drivers/media/video/gspca/conex.c5
-rw-r--r--drivers/media/video/gspca/etoms.c5
-rw-r--r--drivers/media/video/gspca/gspca.c15
-rw-r--r--drivers/media/video/gspca/mars.c5
-rw-r--r--drivers/media/video/gspca/ov519.c5
-rw-r--r--drivers/media/video/gspca/pac207.c10
-rw-r--r--drivers/media/video/gspca/pac7311.c5
-rw-r--r--drivers/media/video/gspca/sonixb.c5
-rw-r--r--drivers/media/video/gspca/sonixj.c251
-rw-r--r--drivers/media/video/gspca/spca500.c5
-rw-r--r--drivers/media/video/gspca/spca501.c5
-rw-r--r--drivers/media/video/gspca/spca505.c5
-rw-r--r--drivers/media/video/gspca/spca506.c5
-rw-r--r--drivers/media/video/gspca/spca508.c5
-rw-r--r--drivers/media/video/gspca/spca561.c5
-rw-r--r--drivers/media/video/gspca/stk014.c5
-rw-r--r--drivers/media/video/gspca/sunplus.c5
-rw-r--r--drivers/media/video/gspca/t613.c22
-rw-r--r--drivers/media/video/gspca/tv8532.c5
-rw-r--r--drivers/media/video/gspca/vc032x.c5
-rw-r--r--drivers/media/video/gspca/zc3xx.c362
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h1
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c2
-rw-r--r--drivers/media/video/meye.c3
-rw-r--r--drivers/media/video/msp3400-driver.c1
-rw-r--r--drivers/media/video/mt9m001.c2
-rw-r--r--drivers/media/video/ov511.c2
-rw-r--r--drivers/media/video/ov511.h1
-rw-r--r--drivers/media/video/pms.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c1
-rw-r--r--drivers/media/video/pwc/pwc-if.c2
-rw-r--r--drivers/media/video/pwc/pwc.h1
-rw-r--r--drivers/media/video/s2255drv.c3
-rw-r--r--drivers/media/video/saa5246a.c1
-rw-r--r--drivers/media/video/saa5249.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c2
-rw-r--r--drivers/media/video/saa7134/saa7134.h1
-rw-r--r--drivers/media/video/se401.h1
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c1
-rw-r--r--drivers/media/video/sn9c102/sn9c102.h1
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c60
-rw-r--r--drivers/media/video/soc_camera.c11
-rw-r--r--drivers/media/video/stk-webcam.c3
-rw-r--r--drivers/media/video/stradis.c1
-rw-r--r--drivers/media/video/stv680.c3
-rw-r--r--drivers/media/video/tda7432.c1
-rw-r--r--drivers/media/video/tuner-core.c1
-rw-r--r--drivers/media/video/usbvideo/usbvideo.c2
-rw-r--r--drivers/media/video/usbvideo/usbvideo.h1
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c75
-rw-r--r--drivers/media/video/uvc/uvc_driver.c2
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c1
-rw-r--r--drivers/media/video/v4l1-compat.c1
-rw-r--r--drivers/media/video/v4l2-dev.c421
-rw-r--r--drivers/media/video/v4l2-ioctl.c1865
-rw-r--r--drivers/media/video/videobuf-dma-contig.c8
-rw-r--r--drivers/media/video/videodev.c2262
-rw-r--r--drivers/media/video/vivi.c1
-rw-r--r--drivers/media/video/w9966.c1
-rw-r--r--drivers/media/video/w9968cf.c3
-rw-r--r--drivers/media/video/zc0301/zc0301.h1
-rw-r--r--drivers/media/video/zoran_driver.c1
-rw-r--r--drivers/media/video/zr364xx.c1
114 files changed, 5028 insertions, 2823 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index a577c0f89f67..3c663c65ef66 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -246,6 +246,14 @@ config DVB_USB_AF9005_REMOTE
246 Say Y here to support the default remote control decoding for the 246 Say Y here to support the default remote control decoding for the
247 Afatech AF9005 based receiver. 247 Afatech AF9005 based receiver.
248 248
249config DVB_USB_DW2102
250 tristate "DvbWorld 2102 DVB-S USB2.0 receiver"
251 depends on DVB_USB
252 select DVB_STV0299 if !DVB_FE_CUSTOMISE
253 select DVB_PLL if !DVB_FE_CUSTOMISE
254 help
255 Say Y here to support the DvbWorld 2102 DVB-S USB2.0 receiver.
256
249config DVB_USB_ANYSEE 257config DVB_USB_ANYSEE
250 tristate "Anysee DVB-T/C USB2.0 support" 258 tristate "Anysee DVB-T/C USB2.0 support"
251 depends on DVB_USB 259 depends on DVB_USB
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 44c11e45e564..e206f1ea0027 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -64,6 +64,9 @@ obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o
64dvb-usb-anysee-objs = anysee.o 64dvb-usb-anysee-objs = anysee.o
65obj-$(CONFIG_DVB_USB_ANYSEE) += dvb-usb-anysee.o 65obj-$(CONFIG_DVB_USB_ANYSEE) += dvb-usb-anysee.o
66 66
67dvb-usb-dw2102-objs = dw2102.o
68obj-$(CONFIG_DVB_USB_DW2102) += dvb-usb-dw2102.o
69
67EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 70EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
68# due to tuner-xc3028 71# due to tuner-xc3028
69EXTRA_CFLAGS += -Idrivers/media/common/tuners 72EXTRA_CFLAGS += -Idrivers/media/common/tuners
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index e5238b31e946..029b437caf9a 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -204,5 +204,6 @@
204#define USB_PID_ASUS_U3000 0x171f 204#define USB_PID_ASUS_U3000 0x171f
205#define USB_PID_ASUS_U3100 0x173f 205#define USB_PID_ASUS_U3100 0x173f
206#define USB_PID_YUAN_EC372S 0x1edc 206#define USB_PID_YUAN_EC372S 0x1edc
207#define USB_PID_DW2102 0x2102
207 208
208#endif 209#endif
diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
new file mode 100644
index 000000000000..a4d898b44e55
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -0,0 +1,425 @@
1/* DVB USB framework compliant Linux driver for the DVBWorld DVB-S 2102 Card
2*
3* Copyright (C) 2008 Igor M. Liplianin (liplianin@me.by)
4*
5* This program is free software; you can redistribute it and/or modify it
6* under the terms of the GNU General Public License as published by the
7* Free Software Foundation, version 2.
8*
9* see Documentation/dvb/README.dvb-usb for more information
10*/
11#include <linux/version.h>
12#include "dw2102.h"
13#include "stv0299.h"
14#include "z0194a.h"
15
16#ifndef USB_PID_DW2102
17#define USB_PID_DW2102 0x2102
18#endif
19
20#define DW2102_READ_MSG 0
21#define DW2102_WRITE_MSG 1
22
23#define REG_1F_SYMBOLRATE_BYTE0 0x1f
24#define REG_20_SYMBOLRATE_BYTE1 0x20
25#define REG_21_SYMBOLRATE_BYTE2 0x21
26
27#define DW2102_VOLTAGE_CTRL (0x1800)
28#define DW2102_RC_QUERY (0x1a00)
29
30struct dw2102_state {
31 u32 last_key_pressed;
32};
33struct dw2102_rc_keys {
34 u32 keycode;
35 u32 event;
36};
37
38DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
39
40static int dw2102_op_rw(struct usb_device *dev, u8 request, u16 value,
41 u8 *data, u16 len, int flags)
42{
43 int ret;
44 u8 u8buf[len];
45
46 unsigned int pipe = (flags == DW2102_READ_MSG) ?
47 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
48 u8 request_type = (flags == DW2102_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
49
50 if (flags == DW2102_WRITE_MSG)
51 memcpy(u8buf, data, len);
52 ret = usb_control_msg(dev, pipe, request,
53 request_type | USB_TYPE_VENDOR, value, 0 , u8buf, len, 2000);
54
55 if (flags == DW2102_READ_MSG)
56 memcpy(data, u8buf, len);
57 return ret;
58}
59
60/* I2C */
61
62static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
63 int num)
64{
65struct dvb_usb_device *d = i2c_get_adapdata(adap);
66 int i = 0, ret = 0;
67 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
68 u8 request;
69 u16 value;
70
71 if (!d)
72 return -ENODEV;
73 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
74 return -EAGAIN;
75
76 switch (num) {
77 case 2:
78 /* read stv0299 register */
79 request = 0xb5;
80 value = msg[0].buf[0];/* register */
81 for (i = 0; i < msg[1].len; i++) {
82 value = value + i;
83 ret = dw2102_op_rw(d->udev, 0xb5,
84 value, buf6, 2, DW2102_READ_MSG);
85 msg[1].buf[i] = buf6[0];
86
87 }
88 break;
89 case 1:
90 switch (msg[0].addr) {
91 case 0x68:
92 /* write to stv0299 register */
93 buf6[0] = 0x2a;
94 buf6[1] = msg[0].buf[0];
95 buf6[2] = msg[0].buf[1];
96 ret = dw2102_op_rw(d->udev, 0xb2,
97 0, buf6, 3, DW2102_WRITE_MSG);
98 break;
99 case 0x60:
100 if (msg[0].flags == 0) {
101 /* write to tuner pll */
102 buf6[0] = 0x2c;
103 buf6[1] = 5;
104 buf6[2] = 0xc0;
105 buf6[3] = msg[0].buf[0];
106 buf6[4] = msg[0].buf[1];
107 buf6[5] = msg[0].buf[2];
108 buf6[6] = msg[0].buf[3];
109 ret = dw2102_op_rw(d->udev, 0xb2,
110 0, buf6, 7, DW2102_WRITE_MSG);
111 } else {
112 /* write to tuner pll */
113 ret = dw2102_op_rw(d->udev, 0xb5,
114 0, buf6, 1, DW2102_READ_MSG);
115 msg[0].buf[0] = buf6[0];
116 }
117 break;
118 case (DW2102_RC_QUERY):
119 ret = dw2102_op_rw(d->udev, 0xb8,
120 0, buf6, 2, DW2102_READ_MSG);
121 msg[0].buf[0] = buf6[0];
122 msg[0].buf[1] = buf6[1];
123 break;
124 case (DW2102_VOLTAGE_CTRL):
125 buf6[0] = 0x30;
126 buf6[1] = msg[0].buf[0];
127 ret = dw2102_op_rw(d->udev, 0xb2,
128 0, buf6, 2, DW2102_WRITE_MSG);
129 break;
130 }
131
132 break;
133 }
134
135 mutex_unlock(&d->i2c_mutex);
136 return num;
137}
138
139static u32 dw2102_i2c_func(struct i2c_adapter *adapter)
140{
141 return I2C_FUNC_I2C;
142}
143
144static struct i2c_algorithm dw2102_i2c_algo = {
145 .master_xfer = dw2102_i2c_transfer,
146 .functionality = dw2102_i2c_func,
147};
148
149static int dw2102_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
150{
151 static u8 command_13v[1] = {0x00};
152 static u8 command_18v[1] = {0x01};
153 struct i2c_msg msg[] = {
154 {.addr = DW2102_VOLTAGE_CTRL, .flags = 0,
155 .buf = command_13v, .len = 1},
156 };
157
158 struct dvb_usb_adapter *udev_adap =
159 (struct dvb_usb_adapter *)(fe->dvb->priv);
160 if (voltage == SEC_VOLTAGE_18)
161 msg[0].buf = command_18v;
162 i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1);
163 return 0;
164}
165
166static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
167{
168 d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
169 &d->dev->i2c_adap);
170 if (d->fe != NULL) {
171 d->fe->ops.set_voltage = dw2102_set_voltage;
172 info("Attached stv0299!\n");
173 return 0;
174 }
175 return -EIO;
176}
177
178static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
179{
180 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
181 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
182 return 0;
183}
184
185static struct dvb_usb_rc_key dw2102_rc_keys[] = {
186 { 0xf8, 0x0a, KEY_Q }, /*power*/
187 { 0xf8, 0x0c, KEY_M }, /*mute*/
188 { 0xf8, 0x11, KEY_1 },
189 { 0xf8, 0x12, KEY_2 },
190 { 0xf8, 0x13, KEY_3 },
191 { 0xf8, 0x14, KEY_4 },
192 { 0xf8, 0x15, KEY_5 },
193 { 0xf8, 0x16, KEY_6 },
194 { 0xf8, 0x17, KEY_7 },
195 { 0xf8, 0x18, KEY_8 },
196 { 0xf8, 0x19, KEY_9 },
197 { 0xf8, 0x10, KEY_0 },
198 { 0xf8, 0x1c, KEY_PAGEUP }, /*ch+*/
199 { 0xf8, 0x0f, KEY_PAGEDOWN }, /*ch-*/
200 { 0xf8, 0x1a, KEY_O }, /*vol+*/
201 { 0xf8, 0x0e, KEY_Z }, /*vol-*/
202 { 0xf8, 0x04, KEY_R }, /*rec*/
203 { 0xf8, 0x09, KEY_D }, /*fav*/
204 { 0xf8, 0x08, KEY_BACKSPACE }, /*rewind*/
205 { 0xf8, 0x07, KEY_A }, /*fast*/
206 { 0xf8, 0x0b, KEY_P }, /*pause*/
207 { 0xf8, 0x02, KEY_ESC }, /*cancel*/
208 { 0xf8, 0x03, KEY_G }, /*tab*/
209 { 0xf8, 0x00, KEY_UP }, /*up*/
210 { 0xf8, 0x1f, KEY_ENTER }, /*ok*/
211 { 0xf8, 0x01, KEY_DOWN }, /*down*/
212 { 0xf8, 0x05, KEY_C }, /*cap*/
213 { 0xf8, 0x06, KEY_S }, /*stop*/
214 { 0xf8, 0x40, KEY_F }, /*full*/
215 { 0xf8, 0x1e, KEY_W }, /*tvmode*/
216 { 0xf8, 0x1b, KEY_B }, /*recall*/
217
218};
219
220
221
222static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
223{
224 struct dw2102_state *st = d->priv;
225 u8 key[2];
226 struct i2c_msg msg[] = {
227 {.addr = DW2102_RC_QUERY, .flags = I2C_M_RD, .buf = key,
228 .len = 2},
229 };
230 int i;
231
232 *state = REMOTE_NO_KEY_PRESSED;
233 if (dw2102_i2c_transfer(&d->i2c_adap, msg, 1) == 1) {
234 for (i = 0; i < ARRAY_SIZE(dw2102_rc_keys); i++) {
235 if (dw2102_rc_keys[i].data == msg[0].buf[0]) {
236 *state = REMOTE_KEY_PRESSED;
237 *event = dw2102_rc_keys[i].event;
238 st->last_key_pressed =
239 dw2102_rc_keys[i].event;
240 break;
241 }
242 st->last_key_pressed = 0;
243 }
244 }
245 /* info("key: %x %x\n",key[0],key[1]); */
246 return 0;
247}
248
249static struct usb_device_id dw2102_table[] = {
250 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
251 {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
252 { }
253};
254
255MODULE_DEVICE_TABLE(usb, dw2102_table);
256
257static int dw2102_load_firmware(struct usb_device *dev,
258 const struct firmware *frmwr)
259{
260 u8 *b, *p;
261 int ret = 0, i;
262 u8 reset;
263 u8 reset16 [] = {0, 0, 0, 0, 0, 0, 0};
264 const struct firmware *fw;
265 const char *filename = "dvb-usb-dw2101.fw";
266 switch (dev->descriptor.idProduct) {
267 case 0x2101:
268 ret = request_firmware(&fw, filename, &dev->dev);
269 if (ret != 0) {
270 err("did not find the firmware file. (%s) "
271 "Please see linux/Documentation/dvb/ for more details "
272 "on firmware-problems.", filename);
273 return ret;
274 }
275 break;
276 case USB_PID_DW2102:
277 fw = frmwr;
278 break;
279 }
280 info("start downloading DW2102 firmware");
281 p = kmalloc(fw->size, GFP_KERNEL);
282 reset = 1;
283 /*stop the CPU*/
284 dw2102_op_rw(dev, 0xa0, 0x7f92, &reset, 1, DW2102_WRITE_MSG);
285 dw2102_op_rw(dev, 0xa0, 0xe600, &reset, 1, DW2102_WRITE_MSG);
286
287 if (p != NULL) {
288 memcpy(p, fw->data, fw->size);
289 for (i = 0; i < fw->size; i += 0x40) {
290 b = (u8 *) p + i;
291 if (dw2102_op_rw
292 (dev, 0xa0, i, b , 0x40,
293 DW2102_WRITE_MSG) != 0x40
294 ) {
295 err("error while transferring firmware");
296 ret = -EINVAL;
297 break;
298 }
299 }
300 /* restart the CPU */
301 reset = 0;
302 if (ret || dw2102_op_rw
303 (dev, 0xa0, 0x7f92, &reset, 1,
304 DW2102_WRITE_MSG) != 1) {
305 err("could not restart the USB controller CPU.");
306 ret = -EINVAL;
307 }
308 if (ret || dw2102_op_rw
309 (dev, 0xa0, 0xe600, &reset, 1,
310 DW2102_WRITE_MSG) != 1) {
311 err("could not restart the USB controller CPU.");
312 ret = -EINVAL;
313 }
314 /* init registers */
315 switch (dev->descriptor.idProduct) {
316 case USB_PID_DW2102:
317 dw2102_op_rw
318 (dev, 0xbf, 0x0040, &reset, 0,
319 DW2102_WRITE_MSG);
320 dw2102_op_rw
321 (dev, 0xb9, 0x0000, &reset16[0], 2,
322 DW2102_READ_MSG);
323 break;
324 case 0x2101:
325 dw2102_op_rw
326 (dev, 0xbc, 0x0030, &reset16[0], 2,
327 DW2102_READ_MSG);
328 dw2102_op_rw
329 (dev, 0xba, 0x0000, &reset16[0], 7,
330 DW2102_READ_MSG);
331 dw2102_op_rw
332 (dev, 0xba, 0x0000, &reset16[0], 7,
333 DW2102_READ_MSG);
334 dw2102_op_rw
335 (dev, 0xb9, 0x0000, &reset16[0], 2,
336 DW2102_READ_MSG);
337 break;
338 }
339 kfree(p);
340 }
341 return ret;
342}
343
344static struct dvb_usb_device_properties dw2102_properties = {
345 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
346 .usb_ctrl = DEVICE_SPECIFIC,
347 .firmware = "dvb-usb-dw2102.fw",
348 .size_of_priv = sizeof(struct dw2102_state),
349 .no_reconnect = 1,
350
351 .i2c_algo = &dw2102_i2c_algo,
352 .rc_key_map = dw2102_rc_keys,
353 .rc_key_map_size = ARRAY_SIZE(dw2102_rc_keys),
354 .rc_interval = 150,
355 .rc_query = dw2102_rc_query,
356
357 .generic_bulk_ctrl_endpoint = 0x81,
358 /* parameter for the MPEG2-data transfer */
359 .num_adapters = 1,
360 .download_firmware = dw2102_load_firmware,
361 .adapter = {
362 {
363 .frontend_attach = dw2102_frontend_attach,
364 .streaming_ctrl = NULL,
365 .tuner_attach = dw2102_tuner_attach,
366 .stream = {
367 .type = USB_BULK,
368 .count = 8,
369 .endpoint = 0x82,
370 .u = {
371 .bulk = {
372 .buffersize = 4096,
373 }
374 }
375 },
376 }
377 },
378 .num_device_descs = 2,
379 .devices = {
380 {"DVBWorld DVB-S 2102 USB2.0",
381 {&dw2102_table[0], NULL},
382 {NULL},
383 },
384 {"DVBWorld DVB-S 2101 USB2.0",
385 {&dw2102_table[1], NULL},
386 {NULL},
387 },
388 }
389};
390
391static int dw2102_probe(struct usb_interface *intf,
392 const struct usb_device_id *id)
393{
394 return dvb_usb_device_init(intf, &dw2102_properties,
395 THIS_MODULE, NULL, adapter_nr);
396}
397
398static struct usb_driver dw2102_driver = {
399 .name = "dw2102",
400 .probe = dw2102_probe,
401 .disconnect = dvb_usb_device_exit,
402 .id_table = dw2102_table,
403};
404
405static int __init dw2102_module_init(void)
406{
407 int ret = usb_register(&dw2102_driver);
408 if (ret)
409 err("usb_register failed. Error number %d", ret);
410
411 return ret;
412}
413
414static void __exit dw2102_module_exit(void)
415{
416 usb_deregister(&dw2102_driver);
417}
418
419module_init(dw2102_module_init);
420module_exit(dw2102_module_exit);
421
422MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
423MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101 2102 USB2.0 device");
424MODULE_VERSION("0.1");
425MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dw2102.h b/drivers/media/dvb/dvb-usb/dw2102.h
new file mode 100644
index 000000000000..cb5873752e46
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dw2102.h
@@ -0,0 +1,9 @@
1#ifndef _DW2102_H_
2#define _DW2102_H_
3
4#define DVB_USB_LOG_PREFIX "dw2102"
5#include <dvb-usb.h>
6
7extern int dvb_usb_dw2102_debug;
8#define deb_xfer(args...) dprintk(dvb_usb_dw2102_debug, 0x02, args)
9#endif
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index c20553c4da1f..fa7f0c563770 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -135,6 +135,20 @@ config DVB_CX22702
135 help 135 help
136 A DVB-T tuner module. Say Y when you want to support this frontend. 136 A DVB-T tuner module. Say Y when you want to support this frontend.
137 137
138config DVB_DRX397XD
139 tristate "Micronas DRX3975D/DRX3977D based"
140 depends on DVB_CORE && I2C && HOTPLUG
141 default m if DVB_FE_CUSTOMISE
142 select FW_LOADER
143 help
144 A DVB-T tuner module. Say Y when you want to support this frontend.
145
146 TODO:
147 This driver needs external firmware. Please use the command
148 "<kerneldir>/Documentation/dvb/get_dvb_firmware drx397xD" to
149 download/extract them, and then copy them to /usr/lib/hotplug/firmware
150 or /lib/firmware (depending on configuration of firmware hotplug).
151
138config DVB_L64781 152config DVB_L64781
139 tristate "LSI L64781" 153 tristate "LSI L64781"
140 depends on DVB_CORE && I2C 154 depends on DVB_CORE && I2C
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
index a89dc0fc4c6f..028da55611c0 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_DVB_NXT6000) += nxt6000.o
25obj-$(CONFIG_DVB_MT352) += mt352.o 25obj-$(CONFIG_DVB_MT352) += mt352.o
26obj-$(CONFIG_DVB_ZL10353) += zl10353.o 26obj-$(CONFIG_DVB_ZL10353) += zl10353.o
27obj-$(CONFIG_DVB_CX22702) += cx22702.o 27obj-$(CONFIG_DVB_CX22702) += cx22702.o
28obj-$(CONFIG_DVB_DRX397XD) += drx397xD.o
28obj-$(CONFIG_DVB_TDA10021) += tda10021.o 29obj-$(CONFIG_DVB_TDA10021) += tda10021.o
29obj-$(CONFIG_DVB_TDA10023) += tda10023.o 30obj-$(CONFIG_DVB_TDA10023) += tda10023.o
30obj-$(CONFIG_DVB_STV0297) += stv0297.o 31obj-$(CONFIG_DVB_STV0297) += stv0297.o
diff --git a/drivers/media/dvb/frontends/drx397xD.c b/drivers/media/dvb/frontends/drx397xD.c
new file mode 100644
index 000000000000..3cbed874a6f8
--- /dev/null
+++ b/drivers/media/dvb/frontends/drx397xD.c
@@ -0,0 +1,1504 @@
1/*
2 * Driver for Micronas drx397xD demodulator
3 *
4 * Copyright (C) 2007 Henk Vergonet <Henk.Vergonet@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#define DEBUG /* uncomment if you want debugging output */
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/moduleparam.h>
24#include <linux/init.h>
25#include <linux/device.h>
26#include <linux/delay.h>
27#include <linux/string.h>
28#include <linux/firmware.h>
29#include <asm/div64.h>
30
31#include "dvb_frontend.h"
32#include "drx397xD.h"
33
34static const char mod_name[] = "drx397xD";
35
36#define MAX_CLOCK_DRIFT 200 /* maximal 200 PPM allowed */
37
38#define F_SET_0D0h 1
39#define F_SET_0D4h 2
40
41typedef enum fw_ix {
42#define _FW_ENTRY(a, b) b
43#include "drx397xD_fw.h"
44} fw_ix_t;
45
46/* chip specifics */
47struct drx397xD_state {
48 struct i2c_adapter *i2c;
49 struct dvb_frontend frontend;
50 struct drx397xD_config config;
51 fw_ix_t chip_rev;
52 int flags;
53 u32 bandwidth_parm; /* internal bandwidth conversions */
54 u32 f_osc; /* w90: actual osc frequency [Hz] */
55};
56
57/*******************************************************************************
58 * Firmware
59 ******************************************************************************/
60
61static const char *blob_name[] = {
62#define _BLOB_ENTRY(a, b) a
63#include "drx397xD_fw.h"
64};
65
66typedef enum blob_ix {
67#define _BLOB_ENTRY(a, b) b
68#include "drx397xD_fw.h"
69} blob_ix_t;
70
71static struct {
72 const char *name;
73 const struct firmware *file;
74 rwlock_t lock;
75 int refcnt;
76 const u8 *data[ARRAY_SIZE(blob_name)];
77} fw[] = {
78#define _FW_ENTRY(a, b) { \
79 .name = a, \
80 .file = 0, \
81 .lock = RW_LOCK_UNLOCKED, \
82 .refcnt = 0, \
83 .data = { } }
84#include "drx397xD_fw.h"
85};
86
87/* use only with writer lock aquired */
88static void _drx_release_fw(struct drx397xD_state *s, fw_ix_t ix)
89{
90 memset(&fw[ix].data[0], 0, sizeof(fw[0].data));
91 if (fw[ix].file)
92 release_firmware(fw[ix].file);
93}
94
95static void drx_release_fw(struct drx397xD_state *s)
96{
97 fw_ix_t ix = s->chip_rev;
98
99 pr_debug("%s\n", __FUNCTION__);
100
101 write_lock(&fw[ix].lock);
102 if (fw[ix].refcnt) {
103 fw[ix].refcnt--;
104 if (fw[ix].refcnt == 0)
105 _drx_release_fw(s, ix);
106 }
107 write_unlock(&fw[ix].lock);
108}
109
110static int drx_load_fw(struct drx397xD_state *s, fw_ix_t ix)
111{
112 const u8 *data;
113 size_t size, len;
114 int i = 0, j, rc = -EINVAL;
115
116 pr_debug("%s\n", __FUNCTION__);
117
118 if (ix < 0 || ix >= ARRAY_SIZE(fw))
119 return -EINVAL;
120 s->chip_rev = ix;
121
122 write_lock(&fw[ix].lock);
123 if (fw[ix].file) {
124 rc = 0;
125 goto exit_ok;
126 }
127 memset(&fw[ix].data[0], 0, sizeof(fw[0].data));
128
129 if (request_firmware(&fw[ix].file, fw[ix].name, &s->i2c->dev) != 0) {
130 printk(KERN_ERR "%s: Firmware \"%s\" not available\n",
131 mod_name, fw[ix].name);
132 rc = -ENOENT;
133 goto exit_err;
134 }
135
136 if (!fw[ix].file->data || fw[ix].file->size < 10)
137 goto exit_corrupt;
138
139 data = fw[ix].file->data;
140 size = fw[ix].file->size;
141
142 if (data[i++] != 2) /* check firmware version */
143 goto exit_corrupt;
144
145 do {
146 switch (data[i++]) {
147 case 0x00: /* bytecode */
148 if (i >= size)
149 break;
150 i += data[i];
151 case 0x01: /* reset */
152 case 0x02: /* sleep */
153 i++;
154 break;
155 case 0xfe: /* name */
156 len = strnlen(&data[i], size - i);
157 if (i + len + 1 >= size)
158 goto exit_corrupt;
159 if (data[i + len + 1] != 0)
160 goto exit_corrupt;
161 for (j = 0; j < ARRAY_SIZE(blob_name); j++) {
162 if (strcmp(blob_name[j], &data[i]) == 0) {
163 fw[ix].data[j] = &data[i + len + 1];
164 pr_debug("Loading %s\n", blob_name[j]);
165 }
166 }
167 i += len + 1;
168 break;
169 case 0xff: /* file terminator */
170 if (i == size) {
171 rc = 0;
172 goto exit_ok;
173 }
174 default:
175 goto exit_corrupt;
176 }
177 } while (i < size);
178 exit_corrupt:
179 printk(KERN_ERR "%s: Firmware is corrupt\n", mod_name);
180 exit_err:
181 _drx_release_fw(s, ix);
182 fw[ix].refcnt--;
183 exit_ok:
184 fw[ix].refcnt++;
185 write_unlock(&fw[ix].lock);
186 return rc;
187}
188
189/*******************************************************************************
190 * i2c bus IO
191 ******************************************************************************/
192
193static int write_fw(struct drx397xD_state *s, blob_ix_t ix)
194{
195 struct i2c_msg msg = {.addr = s->config.demod_address,.flags = 0 };
196 const u8 *data;
197 int len, rc = 0, i = 0;
198
199 if (ix < 0 || ix >= ARRAY_SIZE(blob_name)) {
200 pr_debug("%s drx_fw_ix_t out of range\n", __FUNCTION__);
201 return -EINVAL;
202 }
203 pr_debug("%s %s\n", __FUNCTION__, blob_name[ix]);
204
205 read_lock(&fw[s->chip_rev].lock);
206 data = fw[s->chip_rev].data[ix];
207 if (!data) {
208 rc = -EINVAL;
209 goto exit_rc;
210 }
211
212 for (;;) {
213 switch (data[i++]) {
214 case 0: /* bytecode */
215 len = data[i++];
216 msg.len = len;
217 msg.buf = (__u8 *) &data[i];
218 if (i2c_transfer(s->i2c, &msg, 1) != 1) {
219 rc = -EIO;
220 goto exit_rc;
221 }
222 i += len;
223 break;
224 case 1: /* reset */
225 case 2: /* sleep */
226 i++;
227 break;
228 default:
229 goto exit_rc;
230 }
231 }
232 exit_rc:
233 read_unlock(&fw[s->chip_rev].lock);
234 return 0;
235}
236
237/* Function is not endian safe, use the RD16 wrapper below */
238static int _read16(struct drx397xD_state *s, u32 i2c_adr)
239{
240 int rc;
241 u8 a[4];
242 u16 v;
243 struct i2c_msg msg[2] = {
244 {
245 .addr = s->config.demod_address,
246 .flags = 0,
247 .buf = a,
248 .len = sizeof(a)
249 }
250 , {
251 .addr = s->config.demod_address,
252 .flags = I2C_M_RD,
253 .buf = (u8 *) & v,
254 .len = sizeof(v)
255 }
256 };
257
258 *(u32 *) a = i2c_adr;
259
260 rc = i2c_transfer(s->i2c, msg, 2);
261 if (rc != 2)
262 return -EIO;
263
264 return le16_to_cpu(v);
265}
266
267/* Function is not endian safe, use the WR16.. wrappers below */
268static int _write16(struct drx397xD_state *s, u32 i2c_adr, u16 val)
269{
270 u8 a[6];
271 int rc;
272 struct i2c_msg msg = {
273 .addr = s->config.demod_address,
274 .flags = 0,
275 .buf = a,
276 .len = sizeof(a)
277 };
278
279 *(u32 *) a = i2c_adr;
280 *(u16 *) & a[4] = val;
281
282 rc = i2c_transfer(s->i2c, &msg, 1);
283 if (rc != 1)
284 return -EIO;
285 return 0;
286}
287
288#define WR16(ss,adr, val) \
289 _write16(ss, I2C_ADR_C0(adr), cpu_to_le16(val))
290#define WR16_E0(ss,adr, val) \
291 _write16(ss, I2C_ADR_E0(adr), cpu_to_le16(val))
292#define RD16(ss,adr) \
293 _read16(ss, I2C_ADR_C0(adr))
294
295#define EXIT_RC( cmd ) if ( (rc = (cmd)) < 0) goto exit_rc
296
297/*******************************************************************************
298 * Tuner callback
299 ******************************************************************************/
300
301static int PLL_Set(struct drx397xD_state *s,
302 struct dvb_frontend_parameters *fep, int *df_tuner)
303{
304 struct dvb_frontend *fe = &s->frontend;
305 u32 f_tuner, f = fep->frequency;
306 int rc;
307
308 pr_debug("%s\n", __FUNCTION__);
309
310 if ((f > s->frontend.ops.tuner_ops.info.frequency_max) ||
311 (f < s->frontend.ops.tuner_ops.info.frequency_min))
312 return -EINVAL;
313
314 *df_tuner = 0;
315 if (!s->frontend.ops.tuner_ops.set_params ||
316 !s->frontend.ops.tuner_ops.get_frequency)
317 return -ENOSYS;
318
319 rc = s->frontend.ops.tuner_ops.set_params(fe, fep);
320 if (rc < 0)
321 return rc;
322
323 rc = s->frontend.ops.tuner_ops.get_frequency(fe, &f_tuner);
324 if (rc < 0)
325 return rc;
326
327 *df_tuner = f_tuner - f;
328 pr_debug("%s requested %d [Hz] tuner %d [Hz]\n", __FUNCTION__, f,
329 f_tuner);
330
331 return 0;
332}
333
334/*******************************************************************************
335 * Demodulator helper functions
336 ******************************************************************************/
337
338static int SC_WaitForReady(struct drx397xD_state *s)
339{
340 int cnt = 1000;
341 int rc;
342
343 pr_debug("%s\n", __FUNCTION__);
344
345 while (cnt--) {
346 rc = RD16(s, 0x820043);
347 if (rc == 0)
348 return 0;
349 }
350 return -1;
351}
352
353static int SC_SendCommand(struct drx397xD_state *s, int cmd)
354{
355 int rc;
356
357 pr_debug("%s\n", __FUNCTION__);
358
359 WR16(s, 0x820043, cmd);
360 SC_WaitForReady(s);
361 rc = RD16(s, 0x820042);
362 if ((rc & 0xffff) == 0xffff)
363 return -1;
364 return 0;
365}
366
367static int HI_Command(struct drx397xD_state *s, u16 cmd)
368{
369 int rc, cnt = 1000;
370
371 pr_debug("%s\n", __FUNCTION__);
372
373 rc = WR16(s, 0x420032, cmd);
374 if (rc < 0)
375 return rc;
376
377 do {
378 rc = RD16(s, 0x420032);
379 if (rc == 0) {
380 rc = RD16(s, 0x420031);
381 return rc;
382 }
383 if (rc < 0)
384 return rc;
385 } while (--cnt);
386 return rc;
387}
388
389static int HI_CfgCommand(struct drx397xD_state *s)
390{
391
392 pr_debug("%s\n", __FUNCTION__);
393
394 WR16(s, 0x420033, 0x3973);
395 WR16(s, 0x420034, s->config.w50); // code 4, log 4
396 WR16(s, 0x420035, s->config.w52); // code 15, log 9
397 WR16(s, 0x420036, s->config.demod_address << 1);
398 WR16(s, 0x420037, s->config.w56); // code (set_i2c ?? initX 1 ), log 1
399// WR16(s, 0x420033, 0x3973);
400 if ((s->config.w56 & 8) == 0)
401 return HI_Command(s, 3);
402 return WR16(s, 0x420032, 0x3);
403}
404
405static const u8 fastIncrDecLUT_15273[] = {
406 0x0e, 0x0f, 0x0f, 0x10, 0x11, 0x12, 0x12, 0x13, 0x14,
407 0x15, 0x16, 0x17, 0x18, 0x1a, 0x1b, 0x1c, 0x1d, 0x1f
408};
409
410static const u8 slowIncrDecLUT_15272[] = {
411 3, 4, 4, 5, 6
412};
413
414static int SetCfgIfAgc(struct drx397xD_state *s, struct drx397xD_CfgIfAgc *agc)
415{
416 u16 w06 = agc->w06;
417 u16 w08 = agc->w08;
418 u16 w0A = agc->w0A;
419 u16 w0C = agc->w0C;
420 int quot, rem, i, rc = -EINVAL;
421
422 pr_debug("%s\n", __FUNCTION__);
423
424 if (agc->w04 > 0x3ff)
425 goto exit_rc;
426
427 if (agc->d00 == 1) {
428 EXIT_RC(RD16(s, 0x0c20010));
429 rc &= ~0x10;
430 EXIT_RC(WR16(s, 0x0c20010, rc));
431 return WR16(s, 0x0c20030, agc->w04 & 0x7ff);
432 }
433
434 if (agc->d00 != 0)
435 goto exit_rc;
436 if (w0A < w08)
437 goto exit_rc;
438 if (w0A > 0x3ff)
439 goto exit_rc;
440 if (w0C > 0x3ff)
441 goto exit_rc;
442 if (w06 > 0x3ff)
443 goto exit_rc;
444
445 EXIT_RC(RD16(s, 0x0c20010));
446 rc |= 0x10;
447 EXIT_RC(WR16(s, 0x0c20010, rc));
448
449 EXIT_RC(WR16(s, 0x0c20025, (w06 >> 1) & 0x1ff));
450 EXIT_RC(WR16(s, 0x0c20031, (w0A - w08) >> 1));
451 EXIT_RC(WR16(s, 0x0c20032, ((w0A + w08) >> 1) - 0x1ff));
452
453 quot = w0C / 113;
454 rem = w0C % 113;
455 if (quot <= 8) {
456 quot = 8 - quot;
457 } else {
458 quot = 0;
459 rem += 113;
460 }
461
462 EXIT_RC(WR16(s, 0x0c20024, quot));
463
464 i = fastIncrDecLUT_15273[rem / 8];
465 EXIT_RC(WR16(s, 0x0c2002d, i));
466 EXIT_RC(WR16(s, 0x0c2002e, i));
467
468 i = slowIncrDecLUT_15272[rem / 28];
469 EXIT_RC(WR16(s, 0x0c2002b, i));
470 rc = WR16(s, 0x0c2002c, i);
471 exit_rc:
472 return rc;
473}
474
475static int SetCfgRfAgc(struct drx397xD_state *s, struct drx397xD_CfgRfAgc *agc)
476{
477 u16 w04 = agc->w04;
478 u16 w06 = agc->w06;
479 int rc = -1;
480
481 pr_debug("%s %d 0x%x 0x%x\n", __FUNCTION__, agc->d00, w04, w06);
482
483 if (w04 > 0x3ff)
484 goto exit_rc;
485
486 switch (agc->d00) {
487 case 1:
488 if (w04 == 0x3ff)
489 w04 = 0x400;
490
491 EXIT_RC(WR16(s, 0x0c20036, w04));
492 s->config.w9C &= ~2;
493 EXIT_RC(WR16(s, 0x0c20015, s->config.w9C));
494 EXIT_RC(RD16(s, 0x0c20010));
495 rc &= 0xbfdf;
496 EXIT_RC(WR16(s, 0x0c20010, rc));
497 EXIT_RC(RD16(s, 0x0c20013));
498 rc &= ~2;
499 break;
500 case 0:
501 // loc_8000659
502 s->config.w9C &= ~2;
503 EXIT_RC(WR16(s, 0x0c20015, s->config.w9C));
504 EXIT_RC(RD16(s, 0x0c20010));
505 rc &= 0xbfdf;
506 rc |= 0x4000;
507 EXIT_RC(WR16(s, 0x0c20010, rc));
508 EXIT_RC(WR16(s, 0x0c20051, (w06 >> 4) & 0x3f));
509 EXIT_RC(RD16(s, 0x0c20013));
510 rc &= ~2;
511 break;
512 default:
513 s->config.w9C |= 2;
514 EXIT_RC(WR16(s, 0x0c20015, s->config.w9C));
515 EXIT_RC(RD16(s, 0x0c20010));
516 rc &= 0xbfdf;
517 EXIT_RC(WR16(s, 0x0c20010, rc));
518
519 EXIT_RC(WR16(s, 0x0c20036, 0));
520
521 EXIT_RC(RD16(s, 0x0c20013));
522 rc |= 2;
523 }
524 rc = WR16(s, 0x0c20013, rc);
525 exit_rc:
526 return rc;
527}
528
529static int GetLockStatus(struct drx397xD_state *s, int *lockstat)
530{
531 int rc;
532
533 *lockstat = 0;
534
535 rc = RD16(s, 0x082004b);
536 if (rc < 0)
537 return rc;
538
539 if (s->config.d60 != 2)
540 return 0;
541
542 if ((rc & 7) == 7)
543 *lockstat |= 1;
544 if ((rc & 3) == 3)
545 *lockstat |= 2;
546 if (rc & 1)
547 *lockstat |= 4;
548 return 0;
549}
550
551static int CorrectSysClockDeviation(struct drx397xD_state *s)
552{
553 int rc = -EINVAL;
554 int lockstat;
555 u32 clk, clk_limit;
556
557 pr_debug("%s\n", __FUNCTION__);
558
559 if (s->config.d5C == 0) {
560 EXIT_RC(WR16(s, 0x08200e8, 0x010));
561 EXIT_RC(WR16(s, 0x08200e9, 0x113));
562 s->config.d5C = 1;
563 return rc;
564 }
565 if (s->config.d5C != 1)
566 goto exit_rc;
567
568 rc = RD16(s, 0x0820048);
569
570 rc = GetLockStatus(s, &lockstat);
571 if (rc < 0)
572 goto exit_rc;
573 if ((lockstat & 1) == 0)
574 goto exit_rc;
575
576 EXIT_RC(WR16(s, 0x0420033, 0x200));
577 EXIT_RC(WR16(s, 0x0420034, 0xc5));
578 EXIT_RC(WR16(s, 0x0420035, 0x10));
579 EXIT_RC(WR16(s, 0x0420036, 0x1));
580 EXIT_RC(WR16(s, 0x0420037, 0xa));
581 EXIT_RC(HI_Command(s, 6));
582 EXIT_RC(RD16(s, 0x0420040));
583 clk = rc;
584 EXIT_RC(RD16(s, 0x0420041));
585 clk |= rc << 16;
586
587 if (clk <= 0x26ffff)
588 goto exit_rc;
589 if (clk > 0x610000)
590 goto exit_rc;
591
592 if (!s->bandwidth_parm)
593 return -EINVAL;
594
595 /* round & convert to Hz */
596 clk = ((u64) (clk + 0x800000) * s->bandwidth_parm + (1 << 20)) >> 21;
597 clk_limit = s->config.f_osc * MAX_CLOCK_DRIFT / 1000;
598
599 if (clk - s->config.f_osc * 1000 + clk_limit <= 2 * clk_limit) {
600 s->f_osc = clk;
601 pr_debug("%s: osc %d %d [Hz]\n", __FUNCTION__,
602 s->config.f_osc * 1000, clk - s->config.f_osc * 1000);
603 }
604 rc = WR16(s, 0x08200e8, 0);
605 exit_rc:
606 return rc;
607}
608
609static int ConfigureMPEGOutput(struct drx397xD_state *s, int type)
610{
611 int rc, si, bp;
612
613 pr_debug("%s\n", __FUNCTION__);
614
615 si = s->config.wA0;
616 if (s->config.w98 == 0) {
617 si |= 1;
618 bp = 0;
619 } else {
620 si &= ~1;
621 bp = 0x200;
622 }
623 if (s->config.w9A == 0) {
624 si |= 0x80;
625 } else {
626 si &= ~0x80;
627 }
628
629 EXIT_RC(WR16(s, 0x2150045, 0));
630 EXIT_RC(WR16(s, 0x2150010, si));
631 EXIT_RC(WR16(s, 0x2150011, bp));
632 rc = WR16(s, 0x2150012, (type == 0 ? 0xfff : 0));
633 exit_rc:
634 return rc;
635}
636
637static int drx_tune(struct drx397xD_state *s,
638 struct dvb_frontend_parameters *fep)
639{
640 u16 v22 = 0;
641 u16 v1C = 0;
642 u16 v1A = 0;
643 u16 v18 = 0;
644 u32 edi = 0, ebx = 0, ebp = 0, edx = 0;
645 u16 v20 = 0, v1E = 0, v16 = 0, v14 = 0, v12 = 0, v10 = 0, v0E = 0;
646
647 int rc, df_tuner;
648 int a, b, c, d;
649 pr_debug("%s %d\n", __FUNCTION__, s->config.d60);
650
651 if (s->config.d60 != 2)
652 goto set_tuner;
653 rc = CorrectSysClockDeviation(s);
654 if (rc < 0)
655 goto set_tuner;
656
657 s->config.d60 = 1;
658 rc = ConfigureMPEGOutput(s, 0);
659 if (rc < 0)
660 goto set_tuner;
661 set_tuner:
662
663 rc = PLL_Set(s, fep, &df_tuner);
664 if (rc < 0) {
665 printk(KERN_ERR "Error in pll_set\n");
666 goto exit_rc;
667 }
668 msleep(200);
669
670 a = rc = RD16(s, 0x2150016);
671 if (rc < 0)
672 goto exit_rc;
673 b = rc = RD16(s, 0x2150010);
674 if (rc < 0)
675 goto exit_rc;
676 c = rc = RD16(s, 0x2150034);
677 if (rc < 0)
678 goto exit_rc;
679 d = rc = RD16(s, 0x2150035);
680 if (rc < 0)
681 goto exit_rc;
682 rc = WR16(s, 0x2150014, c);
683 rc = WR16(s, 0x2150015, d);
684 rc = WR16(s, 0x2150010, 0);
685 rc = WR16(s, 0x2150000, 2);
686 rc = WR16(s, 0x2150036, 0x0fff);
687 rc = WR16(s, 0x2150016, a);
688
689 rc = WR16(s, 0x2150010, 2);
690 rc = WR16(s, 0x2150007, 0);
691 rc = WR16(s, 0x2150000, 1);
692 rc = WR16(s, 0x2110000, 0);
693 rc = WR16(s, 0x0800000, 0);
694 rc = WR16(s, 0x2800000, 0);
695 rc = WR16(s, 0x2110010, 0x664);
696
697 rc = write_fw(s, DRXD_ResetECRAM);
698 rc = WR16(s, 0x2110000, 1);
699
700 rc = write_fw(s, DRXD_InitSC);
701 if (rc < 0)
702 goto exit_rc;
703
704 rc = SetCfgIfAgc(s, &s->config.ifagc);
705 if (rc < 0)
706 goto exit_rc;
707
708 rc = SetCfgRfAgc(s, &s->config.rfagc);
709 if (rc < 0)
710 goto exit_rc;
711
712 if (fep->u.ofdm.transmission_mode != TRANSMISSION_MODE_2K)
713 v22 = 1;
714 switch (fep->u.ofdm.transmission_mode) {
715 case TRANSMISSION_MODE_8K:
716 edi = 1;
717 if (s->chip_rev == DRXD_FW_B1)
718 break;
719
720 rc = WR16(s, 0x2010010, 0);
721 if (rc < 0)
722 break;
723 v1C = 0x63;
724 v1A = 0x53;
725 v18 = 0x43;
726 break;
727 default:
728 edi = 0;
729 if (s->chip_rev == DRXD_FW_B1)
730 break;
731
732 rc = WR16(s, 0x2010010, 1);
733 if (rc < 0)
734 break;
735
736 v1C = 0x61;
737 v1A = 0x47;
738 v18 = 0x41;
739 }
740
741 switch (fep->u.ofdm.guard_interval) {
742 case GUARD_INTERVAL_1_4:
743 edi |= 0x0c;
744 break;
745 case GUARD_INTERVAL_1_8:
746 edi |= 0x08;
747 break;
748 case GUARD_INTERVAL_1_16:
749 edi |= 0x04;
750 break;
751 case GUARD_INTERVAL_1_32:
752 break;
753 default:
754 v22 |= 2;
755 }
756
757 ebx = 0;
758 ebp = 0;
759 v20 = 0;
760 v1E = 0;
761 v16 = 0;
762 v14 = 0;
763 v12 = 0;
764 v10 = 0;
765 v0E = 0;
766
767 switch (fep->u.ofdm.hierarchy_information) {
768 case HIERARCHY_1:
769 edi |= 0x40;
770 if (s->chip_rev == DRXD_FW_B1)
771 break;
772 rc = WR16(s, 0x1c10047, 1);
773 if (rc < 0)
774 goto exit_rc;
775 rc = WR16(s, 0x2010012, 1);
776 if (rc < 0)
777 goto exit_rc;
778 ebx = 0x19f;
779 ebp = 0x1fb;
780 v20 = 0x0c0;
781 v1E = 0x195;
782 v16 = 0x1d6;
783 v14 = 0x1ef;
784 v12 = 4;
785 v10 = 5;
786 v0E = 5;
787 break;
788 case HIERARCHY_2:
789 edi |= 0x80;
790 if (s->chip_rev == DRXD_FW_B1)
791 break;
792 rc = WR16(s, 0x1c10047, 2);
793 if (rc < 0)
794 goto exit_rc;
795 rc = WR16(s, 0x2010012, 2);
796 if (rc < 0)
797 goto exit_rc;
798 ebx = 0x08f;
799 ebp = 0x12f;
800 v20 = 0x0c0;
801 v1E = 0x11e;
802 v16 = 0x1d6;
803 v14 = 0x15e;
804 v12 = 4;
805 v10 = 5;
806 v0E = 5;
807 break;
808 case HIERARCHY_4:
809 edi |= 0xc0;
810 if (s->chip_rev == DRXD_FW_B1)
811 break;
812 rc = WR16(s, 0x1c10047, 3);
813 if (rc < 0)
814 goto exit_rc;
815 rc = WR16(s, 0x2010012, 3);
816 if (rc < 0)
817 goto exit_rc;
818 ebx = 0x14d;
819 ebp = 0x197;
820 v20 = 0x0c0;
821 v1E = 0x1ce;
822 v16 = 0x1d6;
823 v14 = 0x11a;
824 v12 = 4;
825 v10 = 6;
826 v0E = 5;
827 break;
828 default:
829 v22 |= 8;
830 if (s->chip_rev == DRXD_FW_B1)
831 break;
832 rc = WR16(s, 0x1c10047, 0);
833 if (rc < 0)
834 goto exit_rc;
835 rc = WR16(s, 0x2010012, 0);
836 if (rc < 0)
837 goto exit_rc;
838 // QPSK QAM16 QAM64
839 ebx = 0x19f; // 62
840 ebp = 0x1fb; // 15
841 v20 = 0x16a; // 62
842 v1E = 0x195; // 62
843 v16 = 0x1bb; // 15
844 v14 = 0x1ef; // 15
845 v12 = 5; // 16
846 v10 = 5; // 16
847 v0E = 5; // 16
848 }
849
850 switch (fep->u.ofdm.constellation) {
851 default:
852 v22 |= 4;
853 case QPSK:
854 if (s->chip_rev == DRXD_FW_B1)
855 break;
856
857 rc = WR16(s, 0x1c10046, 0);
858 if (rc < 0)
859 goto exit_rc;
860 rc = WR16(s, 0x2010011, 0);
861 if (rc < 0)
862 goto exit_rc;
863 rc = WR16(s, 0x201001a, 0x10);
864 if (rc < 0)
865 goto exit_rc;
866 rc = WR16(s, 0x201001b, 0);
867 if (rc < 0)
868 goto exit_rc;
869 rc = WR16(s, 0x201001c, 0);
870 if (rc < 0)
871 goto exit_rc;
872 rc = WR16(s, 0x1c10062, v20);
873 if (rc < 0)
874 goto exit_rc;
875 rc = WR16(s, 0x1c1002a, v1C);
876 if (rc < 0)
877 goto exit_rc;
878 rc = WR16(s, 0x1c10015, v16);
879 if (rc < 0)
880 goto exit_rc;
881 rc = WR16(s, 0x1c10016, v12);
882 if (rc < 0)
883 goto exit_rc;
884 break;
885 case QAM_16:
886 edi |= 0x10;
887 if (s->chip_rev == DRXD_FW_B1)
888 break;
889
890 rc = WR16(s, 0x1c10046, 1);
891 if (rc < 0)
892 goto exit_rc;
893 rc = WR16(s, 0x2010011, 1);
894 if (rc < 0)
895 goto exit_rc;
896 rc = WR16(s, 0x201001a, 0x10);
897 if (rc < 0)
898 goto exit_rc;
899 rc = WR16(s, 0x201001b, 4);
900 if (rc < 0)
901 goto exit_rc;
902 rc = WR16(s, 0x201001c, 0);
903 if (rc < 0)
904 goto exit_rc;
905 rc = WR16(s, 0x1c10062, v1E);
906 if (rc < 0)
907 goto exit_rc;
908 rc = WR16(s, 0x1c1002a, v1A);
909 if (rc < 0)
910 goto exit_rc;
911 rc = WR16(s, 0x1c10015, v14);
912 if (rc < 0)
913 goto exit_rc;
914 rc = WR16(s, 0x1c10016, v10);
915 if (rc < 0)
916 goto exit_rc;
917 break;
918 case QAM_64:
919 edi |= 0x20;
920 rc = WR16(s, 0x1c10046, 2);
921 if (rc < 0)
922 goto exit_rc;
923 rc = WR16(s, 0x2010011, 2);
924 if (rc < 0)
925 goto exit_rc;
926 rc = WR16(s, 0x201001a, 0x20);
927 if (rc < 0)
928 goto exit_rc;
929 rc = WR16(s, 0x201001b, 8);
930 if (rc < 0)
931 goto exit_rc;
932 rc = WR16(s, 0x201001c, 2);
933 if (rc < 0)
934 goto exit_rc;
935 rc = WR16(s, 0x1c10062, ebx);
936 if (rc < 0)
937 goto exit_rc;
938 rc = WR16(s, 0x1c1002a, v18);
939 if (rc < 0)
940 goto exit_rc;
941 rc = WR16(s, 0x1c10015, ebp);
942 if (rc < 0)
943 goto exit_rc;
944 rc = WR16(s, 0x1c10016, v0E);
945 if (rc < 0)
946 goto exit_rc;
947 break;
948 }
949
950 if (s->config.s20d24 == 1) {
951 rc = WR16(s, 0x2010013, 0);
952 } else {
953 rc = WR16(s, 0x2010013, 1);
954 edi |= 0x1000;
955 }
956
957 switch (fep->u.ofdm.code_rate_HP) {
958 default:
959 v22 |= 0x10;
960 case FEC_1_2:
961 if (s->chip_rev == DRXD_FW_B1)
962 break;
963 rc = WR16(s, 0x2090011, 0);
964 break;
965 case FEC_2_3:
966 edi |= 0x200;
967 if (s->chip_rev == DRXD_FW_B1)
968 break;
969 rc = WR16(s, 0x2090011, 1);
970 break;
971 case FEC_3_4:
972 edi |= 0x400;
973 if (s->chip_rev == DRXD_FW_B1)
974 break;
975 rc = WR16(s, 0x2090011, 2);
976 break;
977 case FEC_5_6: /* 5 */
978 edi |= 0x600;
979 if (s->chip_rev == DRXD_FW_B1)
980 break;
981 rc = WR16(s, 0x2090011, 3);
982 break;
983 case FEC_7_8: /* 7 */
984 edi |= 0x800;
985 if (s->chip_rev == DRXD_FW_B1)
986 break;
987 rc = WR16(s, 0x2090011, 4);
988 break;
989 };
990 if (rc < 0)
991 goto exit_rc;
992
993 switch (fep->u.ofdm.bandwidth) {
994 default:
995 rc = -EINVAL;
996 goto exit_rc;
997 case BANDWIDTH_8_MHZ: /* 0 */
998 case BANDWIDTH_AUTO:
999 rc = WR16(s, 0x0c2003f, 0x32);
1000 s->bandwidth_parm = ebx = 0x8b8249; // 9142857
1001 edx = 0;
1002 break;
1003 case BANDWIDTH_7_MHZ:
1004 rc = WR16(s, 0x0c2003f, 0x3b);
1005 s->bandwidth_parm = ebx = 0x7a1200; // 8000000
1006 edx = 0x4807;
1007 break;
1008 case BANDWIDTH_6_MHZ:
1009 rc = WR16(s, 0x0c2003f, 0x47);
1010 s->bandwidth_parm = ebx = 0x68a1b6; // 6857142
1011 edx = 0x0f07;
1012 break;
1013 };
1014
1015 if (rc < 0)
1016 goto exit_rc;
1017
1018 rc = WR16(s, 0x08200ec, edx);
1019 if (rc < 0)
1020 goto exit_rc;
1021
1022 rc = RD16(s, 0x0820050);
1023 if (rc < 0)
1024 goto exit_rc;
1025 rc = WR16(s, 0x0820050, rc);
1026
1027 {
1028 /* Configure bandwidth specific factor */
1029 ebx = div64_u64(((u64) (s->f_osc) << 21) + (ebx >> 1),
1030 (u64)ebx) - 0x800000;
1031 EXIT_RC(WR16(s, 0x0c50010, ebx & 0xffff));
1032 EXIT_RC(WR16(s, 0x0c50011, ebx >> 16));
1033
1034 /* drx397xD oscillator calibration */
1035 ebx = div64_u64(((u64) (s->config.f_if + df_tuner) << 28) +
1036 (s->f_osc >> 1), (u64)s->f_osc);
1037 }
1038 ebx &= 0xfffffff;
1039 if (fep->inversion == INVERSION_ON)
1040 ebx = 0x10000000 - ebx;
1041
1042 EXIT_RC(WR16(s, 0x0c30010, ebx & 0xffff));
1043 EXIT_RC(WR16(s, 0x0c30011, ebx >> 16));
1044
1045 EXIT_RC(WR16(s, 0x0800000, 1));
1046 EXIT_RC(RD16(s, 0x0800000));
1047
1048
1049 EXIT_RC(SC_WaitForReady(s));
1050 EXIT_RC(WR16(s, 0x0820042, 0));
1051 EXIT_RC(WR16(s, 0x0820041, v22));
1052 EXIT_RC(WR16(s, 0x0820040, edi));
1053 EXIT_RC(SC_SendCommand(s, 3));
1054
1055 rc = RD16(s, 0x0800000);
1056
1057 SC_WaitForReady(s);
1058 WR16(s, 0x0820042, 0);
1059 WR16(s, 0x0820041, 1);
1060 WR16(s, 0x0820040, 1);
1061 SC_SendCommand(s, 1);
1062
1063// rc = WR16(s, 0x2150000, 1);
1064// if (rc < 0) goto exit_rc;
1065
1066 rc = WR16(s, 0x2150000, 2);
1067 rc = WR16(s, 0x2150016, a);
1068 rc = WR16(s, 0x2150010, 4);
1069 rc = WR16(s, 0x2150036, 0);
1070 rc = WR16(s, 0x2150000, 1);
1071 s->config.d60 = 2;
1072 exit_rc:
1073 return rc;
1074}
1075
1076/*******************************************************************************
1077 * DVB interface
1078 ******************************************************************************/
1079
1080static int drx397x_init(struct dvb_frontend *fe)
1081{
1082 struct drx397xD_state *s = fe->demodulator_priv;
1083 int rc;
1084
1085 pr_debug("%s\n", __FUNCTION__);
1086
1087 s->config.rfagc.d00 = 2; /* 0x7c */
1088 s->config.rfagc.w04 = 0;
1089 s->config.rfagc.w06 = 0x3ff;
1090
1091 s->config.ifagc.d00 = 0; /* 0x68 */
1092 s->config.ifagc.w04 = 0;
1093 s->config.ifagc.w06 = 140;
1094 s->config.ifagc.w08 = 0;
1095 s->config.ifagc.w0A = 0x3ff;
1096 s->config.ifagc.w0C = 0x388;
1097
1098 /* for signal strenght calculations */
1099 s->config.ss76 = 820;
1100 s->config.ss78 = 2200;
1101 s->config.ss7A = 150;
1102
1103 /* HI_CfgCommand */
1104 s->config.w50 = 4;
1105 s->config.w52 = 9; // 0xf;
1106
1107 s->config.f_if = 42800000; /* d14: intermediate frequency [Hz] */
1108 s->config.f_osc = 48000; /* s66 : oscillator frequency [kHz] */
1109 s->config.w92 = 12000; // 20000;
1110
1111 s->config.w9C = 0x000e;
1112 s->config.w9E = 0x0000;
1113
1114 /* ConfigureMPEGOutput params */
1115 s->config.wA0 = 4;
1116 s->config.w98 = 1; // 0;
1117 s->config.w9A = 1;
1118
1119 /* get chip revision */
1120 rc = RD16(s, 0x2410019);
1121 if (rc < 0)
1122 return -ENODEV;
1123
1124 if (rc == 0) {
1125 printk(KERN_INFO "%s: chip revision A2\n", mod_name);
1126 rc = drx_load_fw(s, DRXD_FW_A2);
1127 } else {
1128
1129 rc = (rc >> 12) - 3;
1130 switch (rc) {
1131 case 1:
1132 s->flags |= F_SET_0D4h;
1133 case 0:
1134 case 4:
1135 s->flags |= F_SET_0D0h;
1136 break;
1137 case 2:
1138 case 5:
1139 break;
1140 case 3:
1141 s->flags |= F_SET_0D4h;
1142 break;
1143 default:
1144 return -ENODEV;
1145 };
1146 printk(KERN_INFO "%s: chip revision B1.%d\n", mod_name, rc);
1147 rc = drx_load_fw(s, DRXD_FW_B1);
1148 }
1149 if (rc < 0)
1150 goto error;
1151
1152 rc = WR16(s, 0x0420033, 0x3973);
1153 if (rc < 0)
1154 goto error;
1155
1156 rc = HI_Command(s, 2);
1157
1158 msleep(1);
1159
1160 if (s->chip_rev == DRXD_FW_A2) {
1161 rc = WR16(s, 0x043012d, 0x47F);
1162 if (rc < 0)
1163 goto error;
1164 }
1165 rc = WR16_E0(s, 0x0400000, 0);
1166 if (rc < 0)
1167 goto error;
1168
1169 if (s->config.w92 > 20000 || s->config.w92 % 4000) {
1170 printk(KERN_ERR "%s: invalid osc frequency\n", mod_name);
1171 rc = -1;
1172 goto error;
1173 }
1174
1175 rc = WR16(s, 0x2410010, 1);
1176 if (rc < 0)
1177 goto error;
1178 rc = WR16(s, 0x2410011, 0x15);
1179 if (rc < 0)
1180 goto error;
1181 rc = WR16(s, 0x2410012, s->config.w92 / 4000);
1182 if (rc < 0)
1183 goto error;
1184#ifdef ORIG_FW
1185 rc = WR16(s, 0x2410015, 2);
1186 if (rc < 0)
1187 goto error;
1188#endif
1189 rc = WR16(s, 0x2410017, 0x3973);
1190 if (rc < 0)
1191 goto error;
1192
1193 s->f_osc = s->config.f_osc * 1000; /* initial estimator */
1194
1195 s->config.w56 = 1;
1196
1197 rc = HI_CfgCommand(s);
1198 if (rc < 0)
1199 goto error;
1200
1201 rc = write_fw(s, DRXD_InitAtomicRead);
1202 if (rc < 0)
1203 goto error;
1204
1205 if (s->chip_rev == DRXD_FW_A2) {
1206 rc = WR16(s, 0x2150013, 0);
1207 if (rc < 0)
1208 goto error;
1209 }
1210
1211 rc = WR16_E0(s, 0x0400002, 0);
1212 if (rc < 0)
1213 goto error;
1214 rc = WR16(s, 0x0400002, 0);
1215 if (rc < 0)
1216 goto error;
1217
1218 if (s->chip_rev == DRXD_FW_A2) {
1219 rc = write_fw(s, DRXD_ResetCEFR);
1220 if (rc < 0)
1221 goto error;
1222 }
1223 rc = write_fw(s, DRXD_microcode);
1224 if (rc < 0)
1225 goto error;
1226
1227 s->config.w9C = 0x0e;
1228 if (s->flags & F_SET_0D0h) {
1229 s->config.w9C = 0;
1230 rc = RD16(s, 0x0c20010);
1231 if (rc < 0)
1232 goto write_DRXD_InitFE_1;
1233
1234 rc &= ~0x1000;
1235 rc = WR16(s, 0x0c20010, rc);
1236 if (rc < 0)
1237 goto write_DRXD_InitFE_1;
1238
1239 rc = RD16(s, 0x0c20011);
1240 if (rc < 0)
1241 goto write_DRXD_InitFE_1;
1242
1243 rc &= ~0x8;
1244 rc = WR16(s, 0x0c20011, rc);
1245 if (rc < 0)
1246 goto write_DRXD_InitFE_1;
1247
1248 rc = WR16(s, 0x0c20012, 1);
1249 }
1250
1251 write_DRXD_InitFE_1:
1252
1253 rc = write_fw(s, DRXD_InitFE_1);
1254 if (rc < 0)
1255 goto error;
1256
1257 rc = 1;
1258 if (s->chip_rev == DRXD_FW_B1) {
1259 if (s->flags & F_SET_0D0h)
1260 rc = 0;
1261 } else {
1262 if (s->flags & F_SET_0D0h)
1263 rc = 4;
1264 }
1265
1266 rc = WR16(s, 0x0C20012, rc);
1267 if (rc < 0)
1268 goto error;
1269
1270 rc = WR16(s, 0x0C20013, s->config.w9E);
1271 if (rc < 0)
1272 goto error;
1273 rc = WR16(s, 0x0C20015, s->config.w9C);
1274 if (rc < 0)
1275 goto error;
1276
1277 rc = write_fw(s, DRXD_InitFE_2);
1278 if (rc < 0)
1279 goto error;
1280 rc = write_fw(s, DRXD_InitFT);
1281 if (rc < 0)
1282 goto error;
1283 rc = write_fw(s, DRXD_InitCP);
1284 if (rc < 0)
1285 goto error;
1286 rc = write_fw(s, DRXD_InitCE);
1287 if (rc < 0)
1288 goto error;
1289 rc = write_fw(s, DRXD_InitEQ);
1290 if (rc < 0)
1291 goto error;
1292 rc = write_fw(s, DRXD_InitEC);
1293 if (rc < 0)
1294 goto error;
1295 rc = write_fw(s, DRXD_InitSC);
1296 if (rc < 0)
1297 goto error;
1298
1299 rc = SetCfgIfAgc(s, &s->config.ifagc);
1300 if (rc < 0)
1301 goto error;
1302
1303 rc = SetCfgRfAgc(s, &s->config.rfagc);
1304 if (rc < 0)
1305 goto error;
1306
1307 rc = ConfigureMPEGOutput(s, 1);
1308 rc = WR16(s, 0x08201fe, 0x0017);
1309 rc = WR16(s, 0x08201ff, 0x0101);
1310
1311 s->config.d5C = 0;
1312 s->config.d60 = 1;
1313 s->config.d48 = 1;
1314 error:
1315 return rc;
1316}
1317
1318static int drx397x_get_frontend(struct dvb_frontend *fe,
1319 struct dvb_frontend_parameters *params)
1320{
1321 return 0;
1322}
1323
1324static int drx397x_set_frontend(struct dvb_frontend *fe,
1325 struct dvb_frontend_parameters *params)
1326{
1327 struct drx397xD_state *s = fe->demodulator_priv;
1328
1329 s->config.s20d24 = 1; // 0;
1330 return drx_tune(s, params);
1331}
1332
1333static int drx397x_get_tune_settings(struct dvb_frontend *fe,
1334 struct dvb_frontend_tune_settings
1335 *fe_tune_settings)
1336{
1337 fe_tune_settings->min_delay_ms = 10000;
1338 fe_tune_settings->step_size = 0;
1339 fe_tune_settings->max_drift = 0;
1340 return 0;
1341}
1342
1343static int drx397x_read_status(struct dvb_frontend *fe, fe_status_t * status)
1344{
1345 struct drx397xD_state *s = fe->demodulator_priv;
1346 int lockstat;
1347
1348 GetLockStatus(s, &lockstat);
1349 /* TODO */
1350// if (lockstat & 1)
1351// CorrectSysClockDeviation(s);
1352
1353 *status = 0;
1354 if (lockstat & 2) {
1355 CorrectSysClockDeviation(s);
1356 ConfigureMPEGOutput(s, 1);
1357 *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI;
1358 }
1359 if (lockstat & 4) {
1360 *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL;
1361 }
1362
1363 return 0;
1364}
1365
1366static int drx397x_read_ber(struct dvb_frontend *fe, unsigned int *ber)
1367{
1368 *ber = 0;
1369 return 0;
1370}
1371
1372static int drx397x_read_snr(struct dvb_frontend *fe, u16 * snr)
1373{
1374 *snr = 0;
1375 return 0;
1376}
1377
1378static int drx397x_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
1379{
1380 struct drx397xD_state *s = fe->demodulator_priv;
1381 int rc;
1382
1383 if (s->config.ifagc.d00 == 2) {
1384 *strength = 0xffff;
1385 return 0;
1386 }
1387 rc = RD16(s, 0x0c20035);
1388 if (rc < 0) {
1389 *strength = 0;
1390 return 0;
1391 }
1392 rc &= 0x3ff;
1393 /* Signal strength is calculated using the following formula:
1394 *
1395 * a = 2200 * 150 / (2200 + 150);
1396 * a = a * 3300 / (a + 820);
1397 * b = 2200 * 3300 / (2200 + 820);
1398 * c = (((b-a) * rc) >> 10 + a) << 4;
1399 * strength = ~c & 0xffff;
1400 *
1401 * The following does the same but with less rounding errors:
1402 */
1403 *strength = ~(7720 + (rc * 30744 >> 10));
1404 return 0;
1405}
1406
1407static int drx397x_read_ucblocks(struct dvb_frontend *fe,
1408 unsigned int *ucblocks)
1409{
1410 *ucblocks = 0;
1411 return 0;
1412}
1413
1414static int drx397x_sleep(struct dvb_frontend *fe)
1415{
1416 return 0;
1417}
1418
1419static void drx397x_release(struct dvb_frontend *fe)
1420{
1421 struct drx397xD_state *s = fe->demodulator_priv;
1422 printk(KERN_INFO "%s: release demodulator\n", mod_name);
1423 if (s) {
1424 drx_release_fw(s);
1425 kfree(s);
1426 }
1427
1428}
1429
1430static struct dvb_frontend_ops drx397x_ops = {
1431
1432 .info = {
1433 .name = "Micronas DRX397xD DVB-T Frontend",
1434 .type = FE_OFDM,
1435 .frequency_min = 47125000,
1436 .frequency_max = 855250000,
1437 .frequency_stepsize = 166667,
1438 .frequency_tolerance = 0,
1439 .caps = /* 0x0C01B2EAE */
1440 FE_CAN_FEC_1_2 | // = 0x2,
1441 FE_CAN_FEC_2_3 | // = 0x4,
1442 FE_CAN_FEC_3_4 | // = 0x8,
1443 FE_CAN_FEC_5_6 | // = 0x20,
1444 FE_CAN_FEC_7_8 | // = 0x80,
1445 FE_CAN_FEC_AUTO | // = 0x200,
1446 FE_CAN_QPSK | // = 0x400,
1447 FE_CAN_QAM_16 | // = 0x800,
1448 FE_CAN_QAM_64 | // = 0x2000,
1449 FE_CAN_QAM_AUTO | // = 0x10000,
1450 FE_CAN_TRANSMISSION_MODE_AUTO | // = 0x20000,
1451 FE_CAN_GUARD_INTERVAL_AUTO | // = 0x80000,
1452 FE_CAN_HIERARCHY_AUTO | // = 0x100000,
1453 FE_CAN_RECOVER | // = 0x40000000,
1454 FE_CAN_MUTE_TS // = 0x80000000
1455 },
1456
1457 .release = drx397x_release,
1458 .init = drx397x_init,
1459 .sleep = drx397x_sleep,
1460
1461 .set_frontend = drx397x_set_frontend,
1462 .get_tune_settings = drx397x_get_tune_settings,
1463 .get_frontend = drx397x_get_frontend,
1464
1465 .read_status = drx397x_read_status,
1466 .read_snr = drx397x_read_snr,
1467 .read_signal_strength = drx397x_read_signal_strength,
1468 .read_ber = drx397x_read_ber,
1469 .read_ucblocks = drx397x_read_ucblocks,
1470};
1471
1472struct dvb_frontend *drx397xD_attach(const struct drx397xD_config *config,
1473 struct i2c_adapter *i2c)
1474{
1475 struct drx397xD_state *s = NULL;
1476
1477 /* allocate memory for the internal state */
1478 s = kzalloc(sizeof(struct drx397xD_state), GFP_KERNEL);
1479 if (s == NULL)
1480 goto error;
1481
1482 /* setup the state */
1483 s->i2c = i2c;
1484 memcpy(&s->config, config, sizeof(struct drx397xD_config));
1485
1486 /* check if the demod is there */
1487 if (RD16(s, 0x2410019) < 0)
1488 goto error;
1489
1490 /* create dvb_frontend */
1491 memcpy(&s->frontend.ops, &drx397x_ops, sizeof(struct dvb_frontend_ops));
1492 s->frontend.demodulator_priv = s;
1493
1494 return &s->frontend;
1495 error:
1496 kfree(s);
1497 return NULL;
1498}
1499
1500MODULE_DESCRIPTION("Micronas DRX397xD DVB-T Frontend");
1501MODULE_AUTHOR("Henk Vergonet");
1502MODULE_LICENSE("GPL");
1503
1504EXPORT_SYMBOL(drx397xD_attach);
diff --git a/drivers/media/dvb/frontends/drx397xD.h b/drivers/media/dvb/frontends/drx397xD.h
new file mode 100644
index 000000000000..ddc7a07971b7
--- /dev/null
+++ b/drivers/media/dvb/frontends/drx397xD.h
@@ -0,0 +1,130 @@
1/*
2 * Driver for Micronas DVB-T drx397xD demodulator
3 *
4 * Copyright (C) 2007 Henk vergonet <Henk.Vergonet@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */
21
22#ifndef _DRX397XD_H_INCLUDED
23#define _DRX397XD_H_INCLUDED
24
25#include <linux/dvb/frontend.h>
26
27#define DRX_F_STEPSIZE 166667
28#define DRX_F_OFFSET 36000000
29
30#define I2C_ADR_C0(x) \
31( (u32)cpu_to_le32( \
32 (u32)( \
33 (((u32)(x) & (u32)0x000000ffUL) ) | \
34 (((u32)(x) & (u32)0x0000ff00UL) << 16) | \
35 (((u32)(x) & (u32)0x0fff0000UL) >> 8) | \
36 ( (u32)0x00c00000UL) \
37 )) \
38)
39
40#define I2C_ADR_E0(x) \
41( (u32)cpu_to_le32( \
42 (u32)( \
43 (((u32)(x) & (u32)0x000000ffUL) ) | \
44 (((u32)(x) & (u32)0x0000ff00UL) << 16) | \
45 (((u32)(x) & (u32)0x0fff0000UL) >> 8) | \
46 ( (u32)0x00e00000UL) \
47 )) \
48)
49
50struct drx397xD_CfgRfAgc /* 0x7c */
51{
52 int d00; /* 2 */
53 u16 w04;
54 u16 w06;
55};
56
57struct drx397xD_CfgIfAgc /* 0x68 */
58{
59 int d00; /* 0 */
60 u16 w04; /* 0 */
61 u16 w06;
62 u16 w08;
63 u16 w0A;
64 u16 w0C;
65};
66
67struct drx397xD_s20 {
68 int d04;
69 u32 d18;
70 u32 d1C;
71 u32 d20;
72 u32 d14;
73 u32 d24;
74 u32 d0C;
75 u32 d08;
76};
77
78struct drx397xD_config
79{
80 /* demodulator's I2C address */
81 u8 demod_address; /* 0x0f */
82
83 struct drx397xD_CfgIfAgc ifagc; /* 0x68 */
84 struct drx397xD_CfgRfAgc rfagc; /* 0x7c */
85 u32 s20d24;
86
87 /* HI_CfgCommand parameters */
88 u16 w50, w52, /* w54, */ w56;
89
90 int d5C;
91 int d60;
92 int d48;
93 int d28;
94
95 u32 f_if; /* d14: intermediate frequency [Hz] */
96 /* 36000000 on Cinergy 2400i DT */
97 /* 42800000 on Pinnacle Hybrid PRO 330e */
98
99 u16 f_osc; /* s66: 48000 oscillator frequency [kHz] */
100
101 u16 w92; /* 20000 */
102
103 u16 wA0;
104 u16 w98;
105 u16 w9A;
106
107 u16 w9C; /* 0xe0 */
108 u16 w9E; /* 0x00 */
109
110 /* used for signal strength calculations in
111 drx397x_read_signal_strength
112 */
113 u16 ss78; // 2200
114 u16 ss7A; // 150
115 u16 ss76; // 820
116};
117
118#if defined(CONFIG_DVB_DRX397XD) || (defined(CONFIG_DVB_DRX397XD_MODULE) && defined(MODULE))
119extern struct dvb_frontend* drx397xD_attach(const struct drx397xD_config *config,
120 struct i2c_adapter *i2c);
121#else
122static inline struct dvb_frontend* drx397xD_attach(const struct drx397xD_config *config,
123 struct i2c_adapter *i2c)
124{
125 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
126 return NULL;
127}
128#endif /* CONFIG_DVB_DRX397XD */
129
130#endif /* _DRX397XD_H_INCLUDED */
diff --git a/drivers/media/dvb/frontends/drx397xD_fw.h b/drivers/media/dvb/frontends/drx397xD_fw.h
new file mode 100644
index 000000000000..01de02a81cd4
--- /dev/null
+++ b/drivers/media/dvb/frontends/drx397xD_fw.h
@@ -0,0 +1,40 @@
1/*
2 * Firmware definitions for Micronas drx397xD
3 *
4 * Copyright (C) 2007 Henk Vergonet <Henk.Vergonet@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifdef _FW_ENTRY
21 _FW_ENTRY("drx397xD.A2.fw", DRXD_FW_A2 = 0 ),
22 _FW_ENTRY("drx397xD.B1.fw", DRXD_FW_B1 ),
23#undef _FW_ENTRY
24#endif /* _FW_ENTRY */
25
26#ifdef _BLOB_ENTRY
27 _BLOB_ENTRY("InitAtomicRead", DRXD_InitAtomicRead = 0 ),
28 _BLOB_ENTRY("InitCE", DRXD_InitCE ),
29 _BLOB_ENTRY("InitCP", DRXD_InitCP ),
30 _BLOB_ENTRY("InitEC", DRXD_InitEC ),
31 _BLOB_ENTRY("InitEQ", DRXD_InitEQ ),
32 _BLOB_ENTRY("InitFE_1", DRXD_InitFE_1 ),
33 _BLOB_ENTRY("InitFE_2", DRXD_InitFE_2 ),
34 _BLOB_ENTRY("InitFT", DRXD_InitFT ),
35 _BLOB_ENTRY("InitSC", DRXD_InitSC ),
36 _BLOB_ENTRY("ResetCEFR", DRXD_ResetCEFR ),
37 _BLOB_ENTRY("ResetECRAM", DRXD_ResetECRAM ),
38 _BLOB_ENTRY("microcode", DRXD_microcode ),
39#undef _BLOB_ENTRY
40#endif /* _BLOB_ENTRY */
diff --git a/drivers/media/dvb/frontends/z0194a.h b/drivers/media/dvb/frontends/z0194a.h
new file mode 100644
index 000000000000..d2876d2e1769
--- /dev/null
+++ b/drivers/media/dvb/frontends/z0194a.h
@@ -0,0 +1,97 @@
1/* z0194a.h Sharp z0194a tuner support
2*
3* Copyright (C) 2008 Igor M. Liplianin (liplianin@me.by)
4*
5* This program is free software; you can redistribute it and/or modify it
6* under the terms of the GNU General Public License as published by the
7* Free Software Foundation, version 2.
8*
9* see Documentation/dvb/README.dvb-usb for more information
10*/
11
12#ifndef Z0194A
13#define Z0194A
14
15static int sharp_z0194a__set_symbol_rate(struct dvb_frontend *fe,
16 u32 srate, u32 ratio)
17{
18 u8 aclk = 0;
19 u8 bclk = 0;
20
21 if (srate < 1500000) {
22 aclk = 0xb7; bclk = 0x47; }
23 else if (srate < 3000000) {
24 aclk = 0xb7; bclk = 0x4b; }
25 else if (srate < 7000000) {
26 aclk = 0xb7; bclk = 0x4f; }
27 else if (srate < 14000000) {
28 aclk = 0xb7; bclk = 0x53; }
29 else if (srate < 30000000) {
30 aclk = 0xb6; bclk = 0x53; }
31 else if (srate < 45000000) {
32 aclk = 0xb4; bclk = 0x51; }
33
34 stv0299_writereg(fe, 0x13, aclk);
35 stv0299_writereg(fe, 0x14, bclk);
36 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
37 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
38 stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
39
40 return 0;
41}
42
43static u8 sharp_z0194a__inittab[] = {
44 0x01, 0x15,
45 0x02, 0x00,
46 0x03, 0x00,
47 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
48 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
49 0x06, 0x40, /* DAC not used, set to high impendance mode */
50 0x07, 0x00, /* DAC LSB */
51 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
52 0x09, 0x00, /* FIFO */
53 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
54 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
55 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
56 0x10, 0x3f, /* AGC2 0x3d */
57 0x11, 0x84,
58 0x12, 0xb9,
59 0x15, 0xc9, /* lock detector threshold */
60 0x16, 0x00,
61 0x17, 0x00,
62 0x18, 0x00,
63 0x19, 0x00,
64 0x1a, 0x00,
65 0x1f, 0x50,
66 0x20, 0x00,
67 0x21, 0x00,
68 0x22, 0x00,
69 0x23, 0x00,
70 0x28, 0x00, /* out imp: normal out type: parallel FEC mode:0 */
71 0x29, 0x1e, /* 1/2 threshold */
72 0x2a, 0x14, /* 2/3 threshold */
73 0x2b, 0x0f, /* 3/4 threshold */
74 0x2c, 0x09, /* 5/6 threshold */
75 0x2d, 0x05, /* 7/8 threshold */
76 0x2e, 0x01,
77 0x31, 0x1f, /* test all FECs */
78 0x32, 0x19, /* viterbi and synchro search */
79 0x33, 0xfc, /* rs control */
80 0x34, 0x93, /* error control */
81 0x0f, 0x52,
82 0xff, 0xff
83};
84
85static struct stv0299_config sharp_z0194a_config = {
86 .demod_address = 0x68,
87 .inittab = sharp_z0194a__inittab,
88 .mclk = 88000000UL,
89 .invert = 1,
90 .skip_reinit = 0,
91 .lock_output = STV0299_LOCKOUTPUT_1,
92 .volt13_op0_op1 = STV0299_VOLT13_OP1,
93 .min_delay_ms = 100,
94 .set_symbol_rate = sharp_z0194a__set_symbol_rate,
95};
96
97#endif
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c
index 4e3f83e4e48f..97c6853ad1d3 100644
--- a/drivers/media/radio/dsbr100.c
+++ b/drivers/media/radio/dsbr100.c
@@ -85,6 +85,7 @@
85#include <linux/input.h> 85#include <linux/input.h>
86#include <linux/videodev2.h> 86#include <linux/videodev2.h>
87#include <media/v4l2-common.h> 87#include <media/v4l2-common.h>
88#include <media/v4l2-ioctl.h>
88#include <linux/usb.h> 89#include <linux/usb.h>
89 90
90/* 91/*
diff --git a/drivers/media/radio/miropcm20-radio.c b/drivers/media/radio/miropcm20-radio.c
index 09fe6f1cdf14..4a332fe8b64b 100644
--- a/drivers/media/radio/miropcm20-radio.c
+++ b/drivers/media/radio/miropcm20-radio.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/videodev.h> 24#include <linux/videodev.h>
25#include <media/v4l2-common.h> 25#include <media/v4l2-common.h>
26#include <media/v4l2-ioctl.h>
26#include "oss/aci.h" 27#include "oss/aci.h"
27#include "miropcm20-rds-core.h" 28#include "miropcm20-rds-core.h"
28 29
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 1ec18ed1a733..ec8d64704dd0 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -36,6 +36,7 @@
36#include <asm/uaccess.h> /* copy to/from user */ 36#include <asm/uaccess.h> /* copy to/from user */
37#include <linux/videodev2.h> /* kernel radio structs */ 37#include <linux/videodev2.h> /* kernel radio structs */
38#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
39#include <media/v4l2-ioctl.h>
39 40
40#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 41#include <linux/version.h> /* for KERNEL_VERSION MACRO */
41#define RADIO_VERSION KERNEL_VERSION(0,0,2) 42#define RADIO_VERSION KERNEL_VERSION(0,0,2)
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 46cdb549eac7..639164a974a1 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -33,6 +33,7 @@
33#include <asm/uaccess.h> /* copy to/from user */ 33#include <asm/uaccess.h> /* copy to/from user */
34#include <linux/videodev2.h> /* kernel radio structs */ 34#include <linux/videodev2.h> /* kernel radio structs */
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-ioctl.h>
36 37
37#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 38#include <linux/version.h> /* for KERNEL_VERSION MACRO */
38#define RADIO_VERSION KERNEL_VERSION(0,0,2) 39#define RADIO_VERSION KERNEL_VERSION(0,0,2)
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index b14db53ea456..484ea87d7fba 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -39,6 +39,7 @@
39#include <asm/uaccess.h> /* copy to/from user */ 39#include <asm/uaccess.h> /* copy to/from user */
40#include <linux/videodev2.h> /* V4L2 API defs */ 40#include <linux/videodev2.h> /* V4L2 API defs */
41#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
42#include <media/v4l2-ioctl.h>
42#include <linux/param.h> 43#include <linux/param.h>
43#include <linux/pnp.h> 44#include <linux/pnp.h>
44 45
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index de49be971480..2b834b95f3e7 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -46,6 +46,7 @@
46#include <linux/pci.h> 46#include <linux/pci.h>
47#include <linux/videodev2.h> 47#include <linux/videodev2.h>
48#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
49#include <media/v4l2-ioctl.h>
49#include <linux/errno.h> 50#include <linux/errno.h>
50 51
51#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 52#include <linux/version.h> /* for KERNEL_VERSION MACRO */
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 81f6aeb1cd11..4740bacc2f88 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -23,6 +23,7 @@
23#include <asm/io.h> /* outb, outb_p */ 23#include <asm/io.h> /* outb, outb_p */
24#include <asm/uaccess.h> /* copy to/from user */ 24#include <asm/uaccess.h> /* copy to/from user */
25#include <linux/videodev2.h> /* kernel radio structs */ 25#include <linux/videodev2.h> /* kernel radio structs */
26#include <media/v4l2-ioctl.h>
26#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
27#include <linux/spinlock.h> 28#include <linux/spinlock.h>
28 29
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index bddd3c409aa9..040a73fac694 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -27,6 +27,7 @@
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/videodev2.h> 28#include <linux/videodev2.h>
29#include <media/v4l2-common.h> 29#include <media/v4l2-common.h>
30#include <media/v4l2-ioctl.h>
30 31
31#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 32#include <linux/version.h> /* for KERNEL_VERSION MACRO */
32#define RADIO_VERSION KERNEL_VERSION(0,0,6) 33#define RADIO_VERSION KERNEL_VERSION(0,0,6)
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 0133ecf3e040..9e824a7d5cc4 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -44,6 +44,7 @@
44#include <linux/pci.h> 44#include <linux/pci.h>
45#include <linux/videodev2.h> 45#include <linux/videodev2.h>
46#include <media/v4l2-common.h> 46#include <media/v4l2-common.h>
47#include <media/v4l2-ioctl.h>
47 48
48#define DRIVER_VERSION "0.77" 49#define DRIVER_VERSION "0.77"
49 50
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index 070802103dc3..c3fb270f211b 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -17,6 +17,7 @@
17#include <asm/uaccess.h> /* copy to/from user */ 17#include <asm/uaccess.h> /* copy to/from user */
18#include <linux/videodev2.h> /* kernel radio structs */ 18#include <linux/videodev2.h> /* kernel radio structs */
19#include <media/v4l2-common.h> 19#include <media/v4l2-common.h>
20#include <media/v4l2-ioctl.h>
20#include <linux/spinlock.h> 21#include <linux/spinlock.h>
21 22
22#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 23#include <linux/version.h> /* for KERNEL_VERSION MACRO */
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 66e052fd3909..bb8b1c9107b1 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -24,6 +24,7 @@
24#include <linux/delay.h> /* udelay */ 24#include <linux/delay.h> /* udelay */
25#include <linux/videodev2.h> /* kernel radio structs */ 25#include <linux/videodev2.h> /* kernel radio structs */
26#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
27#include <media/v4l2-ioctl.h>
27#include <linux/isapnp.h> 28#include <linux/isapnp.h>
28#include <asm/io.h> /* outb, outb_p */ 29#include <asm/io.h> /* outb, outb_p */
29#include <asm/uaccess.h> /* copy to/from user */ 30#include <asm/uaccess.h> /* copy to/from user */
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index b0ccf7cb5952..9fa025b704cb 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -22,6 +22,7 @@
22#include <asm/uaccess.h> /* copy to/from user */ 22#include <asm/uaccess.h> /* copy to/from user */
23#include <linux/videodev2.h> /* kernel radio structs */ 23#include <linux/videodev2.h> /* kernel radio structs */
24#include <media/v4l2-common.h> 24#include <media/v4l2-common.h>
25#include <media/v4l2-ioctl.h>
25#include <linux/mutex.h> 26#include <linux/mutex.h>
26 27
27static struct mutex lock; 28static struct mutex lock;
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c
index dc93a882b385..333612180176 100644
--- a/drivers/media/radio/radio-si470x.c
+++ b/drivers/media/radio/radio-si470x.c
@@ -133,6 +133,7 @@
133#include <linux/videodev2.h> 133#include <linux/videodev2.h>
134#include <linux/mutex.h> 134#include <linux/mutex.h>
135#include <media/v4l2-common.h> 135#include <media/v4l2-common.h>
136#include <media/v4l2-ioctl.h>
136#include <media/rds.h> 137#include <media/rds.h>
137#include <asm/unaligned.h> 138#include <asm/unaligned.h>
138 139
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index acc32080e9bd..a9914dbcf493 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -32,6 +32,7 @@
32#include <asm/uaccess.h> /* copy to/from user */ 32#include <asm/uaccess.h> /* copy to/from user */
33#include <linux/videodev2.h> /* kernel radio structs */ 33#include <linux/videodev2.h> /* kernel radio structs */
34#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
35#include <media/v4l2-ioctl.h>
35#include <linux/spinlock.h> 36#include <linux/spinlock.h>
36 37
37#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 38#include <linux/version.h> /* for KERNEL_VERSION MACRO */
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c
index 4ebdfbadeb9c..560c49481a2d 100644
--- a/drivers/media/radio/radio-trust.c
+++ b/drivers/media/radio/radio-trust.c
@@ -23,6 +23,7 @@
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <linux/videodev2.h> 24#include <linux/videodev2.h>
25#include <media/v4l2-common.h> 25#include <media/v4l2-common.h>
26#include <media/v4l2-ioctl.h>
26 27
27#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 28#include <linux/version.h> /* for KERNEL_VERSION MACRO */
28#define RADIO_VERSION KERNEL_VERSION(0,0,2) 29#define RADIO_VERSION KERNEL_VERSION(0,0,2)
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index 18f2abd7e255..023d6f3c751c 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -40,6 +40,7 @@
40#include <asm/uaccess.h> /* copy to/from user */ 40#include <asm/uaccess.h> /* copy to/from user */
41#include <linux/videodev2.h> /* kernel radio structs */ 41#include <linux/videodev2.h> /* kernel radio structs */
42#include <media/v4l2-common.h> 42#include <media/v4l2-common.h>
43#include <media/v4l2-ioctl.h>
43 44
44#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 45#include <linux/version.h> /* for KERNEL_VERSION MACRO */
45#define RADIO_VERSION KERNEL_VERSION(0,1,1) 46#define RADIO_VERSION KERNEL_VERSION(0,1,1)
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index 43773c56c62f..cf0355bb6ef7 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -37,6 +37,7 @@
37#include <asm/uaccess.h> /* copy to/from user */ 37#include <asm/uaccess.h> /* copy to/from user */
38#include <linux/videodev2.h> /* kernel radio structs */ 38#include <linux/videodev2.h> /* kernel radio structs */
39#include <media/v4l2-common.h> 39#include <media/v4l2-common.h>
40#include <media/v4l2-ioctl.h>
40 41
41#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 42#include <linux/version.h> /* for KERNEL_VERSION MACRO */
42#define RADIO_VERSION KERNEL_VERSION(0,0,2) 43#define RADIO_VERSION KERNEL_VERSION(0,0,2)
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index f606d2951fde..2a747db6dc3e 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -806,13 +806,7 @@ menuconfig V4L_USB_DRIVERS
806 806
807if V4L_USB_DRIVERS && USB 807if V4L_USB_DRIVERS && USB
808 808
809config USB_VIDEO_CLASS 809source "drivers/media/video/uvc/Kconfig"
810 tristate "USB Video Class (UVC)"
811 ---help---
812 Support for the USB Video Class (UVC). Currently only video
813 input devices, such as webcams, are supported.
814
815 For more information see: <http://linux-uvc.berlios.de/>
816 810
817source "drivers/media/video/gspca/Kconfig" 811source "drivers/media/video/gspca/Kconfig"
818 812
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 45d5db5abb1e..9de1e4885246 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -10,6 +10,8 @@ msp3400-objs := msp3400-driver.o msp3400-kthreads.o
10 10
11stkwebcam-objs := stk-webcam.o stk-sensor.o 11stkwebcam-objs := stk-webcam.o stk-sensor.o
12 12
13videodev-objs := v4l2-dev.o v4l2-ioctl.o
14
13obj-$(CONFIG_VIDEO_DEV) += videodev.o compat_ioctl32.o v4l2-int-device.o 15obj-$(CONFIG_VIDEO_DEV) += videodev.o compat_ioctl32.o v4l2-int-device.o
14 16
15obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o 17obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 0ea559a7fe59..33c72055447d 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -45,6 +45,7 @@
45#include <linux/kdev_t.h> 45#include <linux/kdev_t.h>
46#include "bttvp.h" 46#include "bttvp.h"
47#include <media/v4l2-common.h> 47#include <media/v4l2-common.h>
48#include <media/v4l2-ioctl.h>
48#include <media/tvaudio.h> 49#include <media/tvaudio.h>
49#include <media/msp3400.h> 50#include <media/msp3400.h>
50 51
@@ -163,8 +164,8 @@ MODULE_LICENSE("GPL");
163static ssize_t show_card(struct device *cd, 164static ssize_t show_card(struct device *cd,
164 struct device_attribute *attr, char *buf) 165 struct device_attribute *attr, char *buf)
165{ 166{
166 struct video_device *vfd = container_of(cd, struct video_device, class_dev); 167 struct video_device *vfd = container_of(cd, struct video_device, dev);
167 struct bttv *btv = dev_get_drvdata(vfd->dev); 168 struct bttv *btv = dev_get_drvdata(vfd->parent);
168 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); 169 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
169} 170}
170static DEVICE_ATTR(card, S_IRUGO, show_card, NULL); 171static DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
@@ -4185,7 +4186,7 @@ static struct video_device *vdev_init(struct bttv *btv,
4185 return NULL; 4186 return NULL;
4186 *vfd = *template; 4187 *vfd = *template;
4187 vfd->minor = -1; 4188 vfd->minor = -1;
4188 vfd->dev = &btv->c.pci->dev; 4189 vfd->parent = &btv->c.pci->dev;
4189 vfd->release = video_device_release; 4190 vfd->release = video_device_release;
4190 vfd->type = type; 4191 vfd->type = type;
4191 vfd->debug = bttv_debug; 4192 vfd->debug = bttv_debug;
@@ -4244,7 +4245,7 @@ static int __devinit bttv_register_video(struct bttv *btv)
4244 goto err; 4245 goto err;
4245 printk(KERN_INFO "bttv%d: registered device video%d\n", 4246 printk(KERN_INFO "bttv%d: registered device video%d\n",
4246 btv->c.nr,btv->video_dev->minor & 0x1f); 4247 btv->c.nr,btv->video_dev->minor & 0x1f);
4247 if (device_create_file(&btv->video_dev->class_dev, 4248 if (device_create_file(&btv->video_dev->dev,
4248 &dev_attr_card)<0) { 4249 &dev_attr_card)<0) {
4249 printk(KERN_ERR "bttv%d: device_create_file 'card' " 4250 printk(KERN_ERR "bttv%d: device_create_file 'card' "
4250 "failed\n", btv->c.nr); 4251 "failed\n", btv->c.nr);
diff --git a/drivers/media/video/bt8xx/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c
index 0af586876e72..649682aac1ac 100644
--- a/drivers/media/video/bt8xx/bttv-risc.c
+++ b/drivers/media/video/bt8xx/bttv-risc.c
@@ -31,6 +31,7 @@
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <asm/page.h> 32#include <asm/page.h>
33#include <asm/pgtable.h> 33#include <asm/pgtable.h>
34#include <media/v4l2-ioctl.h>
34 35
35#include "bttvp.h" 36#include "bttvp.h"
36 37
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c
index 68f28e5fa040..6819e21a3773 100644
--- a/drivers/media/video/bt8xx/bttv-vbi.c
+++ b/drivers/media/video/bt8xx/bttv-vbi.c
@@ -29,6 +29,7 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/kdev_t.h> 31#include <linux/kdev_t.h>
32#include <media/v4l2-ioctl.h>
32#include <asm/io.h> 33#include <asm/io.h>
33#include "bttvp.h" 34#include "bttvp.h"
34 35
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index b364adaae78d..e367862313e1 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -74,6 +74,7 @@ OTHER DEALINGS IN THE SOFTWARE.
74#include <linux/sched.h> 74#include <linux/sched.h>
75#include <linux/videodev.h> 75#include <linux/videodev.h>
76#include <media/v4l2-common.h> 76#include <media/v4l2-common.h>
77#include <media/v4l2-ioctl.h>
77#include <linux/mutex.h> 78#include <linux/mutex.h>
78#include <asm/uaccess.h> 79#include <asm/uaccess.h>
79 80
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index fe1e67bb1ca8..8d690410c84f 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -35,6 +35,7 @@
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/videodev.h> 36#include <linux/videodev.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-ioctl.h>
38#include <linux/mutex.h> 39#include <linux/mutex.h>
39#include <linux/jiffies.h> 40#include <linux/jiffies.h>
40 41
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index d99453faaab7..302c57f151c2 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -25,6 +25,7 @@
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/v4l2-ioctl.h>
28#include <media/v4l2-chip-ident.h> 29#include <media/v4l2-chip-ident.h>
29#include <linux/device.h> 30#include <linux/device.h>
30#include <linux/wait.h> 31#include <linux/wait.h>
@@ -2157,7 +2158,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
2157 cam->v4ldev = cafe_v4l_template; 2158 cam->v4ldev = cafe_v4l_template;
2158 cam->v4ldev.debug = 0; 2159 cam->v4ldev.debug = 0;
2159// cam->v4ldev.debug = V4L2_DEBUG_IOCTL_ARG; 2160// cam->v4ldev.debug = V4L2_DEBUG_IOCTL_ARG;
2160 cam->v4ldev.dev = &pdev->dev; 2161 cam->v4ldev.parent = &pdev->dev;
2161 ret = video_register_device(&cam->v4ldev, VFL_TYPE_GRABBER, -1); 2162 ret = video_register_device(&cam->v4ldev, VFL_TYPE_GRABBER, -1);
2162 if (ret) 2163 if (ret)
2163 goto out_smbus; 2164 goto out_smbus;
diff --git a/drivers/media/video/compat_ioctl32.c b/drivers/media/video/compat_ioctl32.c
index 54de0cd482e9..bd5d9de5a008 100644
--- a/drivers/media/video/compat_ioctl32.c
+++ b/drivers/media/video/compat_ioctl32.c
@@ -17,7 +17,7 @@
17#include <linux/videodev2.h> 17#include <linux/videodev2.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/smp_lock.h> 19#include <linux/smp_lock.h>
20#include <media/v4l2-common.h> 20#include <media/v4l2-ioctl.h>
21 21
22#ifdef CONFIG_COMPAT 22#ifdef CONFIG_COMPAT
23 23
diff --git a/drivers/media/video/cpia.h b/drivers/media/video/cpia.h
index 5096058bf579..8f0cfee4b8a1 100644
--- a/drivers/media/video/cpia.h
+++ b/drivers/media/video/cpia.h
@@ -46,6 +46,7 @@
46#include <asm/uaccess.h> 46#include <asm/uaccess.h>
47#include <linux/videodev.h> 47#include <linux/videodev.h>
48#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
49#include <media/v4l2-ioctl.h>
49#include <linux/list.h> 50#include <linux/list.h>
50#include <linux/mutex.h> 51#include <linux/mutex.h>
51 52
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index 7ce2789fa976..8817c3841463 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -37,6 +37,7 @@
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <media/v4l2-ioctl.h>
40 41
41#include "cpia2.h" 42#include "cpia2.h"
42#include "cpia2dev.h" 43#include "cpia2dev.h"
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c
index 1c3fa3a7470a..61d14d26686f 100644
--- a/drivers/media/video/cs5345.c
+++ b/drivers/media/video/cs5345.c
@@ -111,7 +111,7 @@ static int cs5345_command(struct i2c_client *client, unsigned cmd, void *arg)
111 if (cmd == VIDIOC_DBG_G_REGISTER) 111 if (cmd == VIDIOC_DBG_G_REGISTER)
112 reg->val = cs5345_read(client, reg->reg & 0x1f); 112 reg->val = cs5345_read(client, reg->reg & 0x1f);
113 else 113 else
114 cs5345_write(client, reg->reg & 0x1f, reg->val & 0x1f); 114 cs5345_write(client, reg->reg & 0x1f, reg->val & 0xff);
115 break; 115 break;
116 } 116 }
117#endif 117#endif
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index 45e31b04730e..4801bc7fb5b2 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -46,6 +46,7 @@
46#include <linux/dvb/video.h> 46#include <linux/dvb/video.h>
47#include <linux/dvb/audio.h> 47#include <linux/dvb/audio.h>
48#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
49#include <media/v4l2-ioctl.h>
49#include <media/tuner.h> 50#include <media/tuner.h>
50#include "cx18-mailbox.h" 51#include "cx18-mailbox.h"
51#include "cx18-av-core.h" 52#include "cx18-av-core.h"
diff --git a/drivers/media/video/cx18/cx18-firmware.c b/drivers/media/video/cx18/cx18-firmware.c
index 2d630d9f7496..78fadd2ada5d 100644
--- a/drivers/media/video/cx18/cx18-firmware.c
+++ b/drivers/media/video/cx18/cx18-firmware.c
@@ -86,10 +86,6 @@
86 86
87#define CX18_DSP0_INTERRUPT_MASK 0xd0004C 87#define CX18_DSP0_INTERRUPT_MASK 0xd0004C
88 88
89/* Encoder/decoder firmware sizes */
90#define CX18_FW_CPU_SIZE (158332)
91#define CX18_FW_APU_SIZE (141200)
92
93#define APU_ROM_SYNC1 0x6D676553 /* "mgeS" */ 89#define APU_ROM_SYNC1 0x6D676553 /* "mgeS" */
94#define APU_ROM_SYNC2 0x72646548 /* "rdeH" */ 90#define APU_ROM_SYNC2 0x72646548 /* "rdeH" */
95 91
@@ -100,35 +96,22 @@ struct cx18_apu_rom_seghdr {
100 u32 size; 96 u32 size;
101}; 97};
102 98
103static int load_cpu_fw_direct(const char *fn, u8 __iomem *mem, struct cx18 *cx, long size) 99static int load_cpu_fw_direct(const char *fn, u8 __iomem *mem, struct cx18 *cx)
104{ 100{
105 const struct firmware *fw = NULL; 101 const struct firmware *fw = NULL;
106 int retries = 3;
107 int i, j; 102 int i, j;
103 unsigned size;
108 u32 __iomem *dst = (u32 __iomem *)mem; 104 u32 __iomem *dst = (u32 __iomem *)mem;
109 const u32 *src; 105 const u32 *src;
110 106
111retry: 107 if (request_firmware(&fw, fn, &cx->dev->dev)) {
112 if (!retries || request_firmware(&fw, fn, &cx->dev->dev)) { 108 CX18_ERR("Unable to open firmware %s\n", fn);
113 CX18_ERR("Unable to open firmware %s (must be %ld bytes)\n",
114 fn, size);
115 CX18_ERR("Did you put the firmware in the hotplug firmware directory?\n"); 109 CX18_ERR("Did you put the firmware in the hotplug firmware directory?\n");
116 return -ENOMEM; 110 return -ENOMEM;
117 } 111 }
118 112
119 src = (const u32 *)fw->data; 113 src = (const u32 *)fw->data;
120 114
121 if (fw->size != size) {
122 /* Due to race conditions in firmware loading (esp. with
123 udev <0.95) the wrong file was sometimes loaded. So we check
124 filesizes to see if at least the right-sized file was
125 loaded. If not, then we retry. */
126 CX18_INFO("retry: file loaded was not %s (expected size %ld, got %zd)\n",
127 fn, size, fw->size);
128 release_firmware(fw);
129 retries--;
130 goto retry;
131 }
132 for (i = 0; i < fw->size; i += 4096) { 115 for (i = 0; i < fw->size; i += 4096) {
133 setup_page(i); 116 setup_page(i);
134 for (j = i; j < fw->size && j < i + 4096; j += 4) { 117 for (j = i; j < fw->size && j < i + 4096; j += 4) {
@@ -145,15 +128,16 @@ retry:
145 } 128 }
146 if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags)) 129 if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags))
147 CX18_INFO("loaded %s firmware (%zd bytes)\n", fn, fw->size); 130 CX18_INFO("loaded %s firmware (%zd bytes)\n", fn, fw->size);
131 size = fw->size;
148 release_firmware(fw); 132 release_firmware(fw);
149 return size; 133 return size;
150} 134}
151 135
152static int load_apu_fw_direct(const char *fn, u8 __iomem *dst, struct cx18 *cx, long size) 136static int load_apu_fw_direct(const char *fn, u8 __iomem *dst, struct cx18 *cx)
153{ 137{
154 const struct firmware *fw = NULL; 138 const struct firmware *fw = NULL;
155 int retries = 3;
156 int i, j; 139 int i, j;
140 unsigned size;
157 const u32 *src; 141 const u32 *src;
158 struct cx18_apu_rom_seghdr seghdr; 142 struct cx18_apu_rom_seghdr seghdr;
159 const u8 *vers; 143 const u8 *vers;
@@ -161,10 +145,8 @@ static int load_apu_fw_direct(const char *fn, u8 __iomem *dst, struct cx18 *cx,
161 u32 apu_version = 0; 145 u32 apu_version = 0;
162 int sz; 146 int sz;
163 147
164retry: 148 if (request_firmware(&fw, fn, &cx->dev->dev)) {
165 if (!retries || request_firmware(&fw, fn, &cx->dev->dev)) { 149 CX18_ERR("unable to open firmware %s\n", fn);
166 CX18_ERR("unable to open firmware %s (must be %ld bytes)\n",
167 fn, size);
168 CX18_ERR("did you put the firmware in the hotplug firmware directory?\n"); 150 CX18_ERR("did you put the firmware in the hotplug firmware directory?\n");
169 return -ENOMEM; 151 return -ENOMEM;
170 } 152 }
@@ -173,19 +155,8 @@ retry:
173 vers = fw->data + sizeof(seghdr); 155 vers = fw->data + sizeof(seghdr);
174 sz = fw->size; 156 sz = fw->size;
175 157
176 if (fw->size != size) {
177 /* Due to race conditions in firmware loading (esp. with
178 udev <0.95) the wrong file was sometimes loaded. So we check
179 filesizes to see if at least the right-sized file was
180 loaded. If not, then we retry. */
181 CX18_INFO("retry: file loaded was not %s (expected size %ld, got %zd)\n",
182 fn, size, fw->size);
183 release_firmware(fw);
184 retries--;
185 goto retry;
186 }
187 apu_version = (vers[0] << 24) | (vers[4] << 16) | vers[32]; 158 apu_version = (vers[0] << 24) | (vers[4] << 16) | vers[32];
188 while (offset + sizeof(seghdr) < size) { 159 while (offset + sizeof(seghdr) < fw->size) {
189 /* TODO: byteswapping */ 160 /* TODO: byteswapping */
190 memcpy(&seghdr, src + offset / 4, sizeof(seghdr)); 161 memcpy(&seghdr, src + offset / 4, sizeof(seghdr));
191 offset += sizeof(seghdr); 162 offset += sizeof(seghdr);
@@ -215,6 +186,7 @@ retry:
215 if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags)) 186 if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags))
216 CX18_INFO("loaded %s firmware V%08x (%zd bytes)\n", 187 CX18_INFO("loaded %s firmware V%08x (%zd bytes)\n",
217 fn, apu_version, fw->size); 188 fn, apu_version, fw->size);
189 size = fw->size;
218 release_firmware(fw); 190 release_firmware(fw);
219 /* Clear bit0 for APU to start from 0 */ 191 /* Clear bit0 for APU to start from 0 */
220 write_reg(read_reg(0xc72030) & ~1, 0xc72030); 192 write_reg(read_reg(0xc72030) & ~1, 0xc72030);
@@ -340,7 +312,7 @@ int cx18_firmware_init(struct cx18 *cx)
340 /* Only if the processor is not running */ 312 /* Only if the processor is not running */
341 if (read_reg(CX18_PROC_SOFT_RESET) & 8) { 313 if (read_reg(CX18_PROC_SOFT_RESET) & 8) {
342 int sz = load_apu_fw_direct("v4l-cx23418-apu.fw", 314 int sz = load_apu_fw_direct("v4l-cx23418-apu.fw",
343 cx->enc_mem, cx, CX18_FW_APU_SIZE); 315 cx->enc_mem, cx);
344 316
345 write_enc(0xE51FF004, 0); 317 write_enc(0xE51FF004, 0);
346 write_enc(0xa00000, 4); /* todo: not hardcoded */ 318 write_enc(0xa00000, 4); /* todo: not hardcoded */
@@ -348,7 +320,7 @@ int cx18_firmware_init(struct cx18 *cx)
348 cx18_msleep_timeout(500, 0); 320 cx18_msleep_timeout(500, 0);
349 321
350 sz = sz <= 0 ? sz : load_cpu_fw_direct("v4l-cx23418-cpu.fw", 322 sz = sz <= 0 ? sz : load_cpu_fw_direct("v4l-cx23418-cpu.fw",
351 cx->enc_mem, cx, CX18_FW_CPU_SIZE); 323 cx->enc_mem, cx);
352 324
353 if (sz > 0) { 325 if (sz > 0) {
354 int retries = 0; 326 int retries = 0;
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index 1728b1d832a9..210a2416b320 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -194,7 +194,7 @@ static int cx18_prep_dev(struct cx18 *cx, int type)
194 cx->num); 194 cx->num);
195 195
196 s->v4l2dev->minor = minor; 196 s->v4l2dev->minor = minor;
197 s->v4l2dev->dev = &cx->dev->dev; 197 s->v4l2dev->parent = &cx->dev->dev;
198 s->v4l2dev->fops = cx18_stream_info[type].fops; 198 s->v4l2dev->fops = cx18_stream_info[type].fops;
199 s->v4l2dev->release = video_device_release; 199 s->v4l2dev->release = video_device_release;
200 s->v4l2dev->tvnorms = V4L2_STD_ALL; 200 s->v4l2dev->tvnorms = V4L2_STD_ALL;
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index e7ef093265af..4d0dcb06c19d 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -32,6 +32,7 @@
32#include <linux/device.h> 32#include <linux/device.h>
33#include <linux/firmware.h> 33#include <linux/firmware.h>
34#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
35#include <media/v4l2-ioctl.h>
35#include <media/cx2341x.h> 36#include <media/cx2341x.h>
36 37
37#include "cx23885.h" 38#include "cx23885.h"
@@ -1766,7 +1767,7 @@ static struct video_device *cx23885_video_dev_alloc(
1766 vfd->minor = -1; 1767 vfd->minor = -1;
1767 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, 1768 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name,
1768 type, cx23885_boards[tsport->dev->board].name); 1769 type, cx23885_boards[tsport->dev->board].name);
1769 vfd->dev = &pci->dev; 1770 vfd->parent = &pci->dev;
1770 vfd->release = video_device_release; 1771 vfd->release = video_device_release;
1771 return vfd; 1772 return vfd;
1772} 1773}
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index 043fc4e5c586..245712e45f69 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -33,6 +33,7 @@
33 33
34#include "cx23885.h" 34#include "cx23885.h"
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-ioctl.h>
36 37
37#ifdef CONFIG_VIDEO_V4L1_COMPAT 38#ifdef CONFIG_VIDEO_V4L1_COMPAT
38/* Include V4L1 specific functions. Should be removed soon */ 39/* Include V4L1 specific functions. Should be removed soon */
@@ -326,7 +327,7 @@ struct video_device *cx23885_vdev_init(struct cx23885_dev *dev,
326 return NULL; 327 return NULL;
327 *vfd = *template; 328 *vfd = *template;
328 vfd->minor = -1; 329 vfd->minor = -1;
329 vfd->dev = &pci->dev; 330 vfd->parent = &pci->dev;
330 vfd->release = video_device_release; 331 vfd->release = video_device_release;
331 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", 332 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
332 dev->name, type, cx23885_boards[dev->board].name); 333 dev->name, type, cx23885_boards[dev->board].name);
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index bfdca5847764..4d1a461f329f 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -33,6 +33,7 @@
33#include <linux/device.h> 33#include <linux/device.h>
34#include <linux/firmware.h> 34#include <linux/firmware.h>
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-ioctl.h>
36#include <media/cx2341x.h> 37#include <media/cx2341x.h>
37 38
38#include "cx88.h" 39#include "cx88.h"
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 60eeda3057e9..d656fec59010 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -40,6 +40,7 @@
40 40
41#include "cx88.h" 41#include "cx88.h"
42#include <media/v4l2-common.h> 42#include <media/v4l2-common.h>
43#include <media/v4l2-ioctl.h>
43 44
44MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); 45MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
45MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 46MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
@@ -1006,7 +1007,7 @@ struct video_device *cx88_vdev_init(struct cx88_core *core,
1006 return NULL; 1007 return NULL;
1007 *vfd = *template; 1008 *vfd = *template;
1008 vfd->minor = -1; 1009 vfd->minor = -1;
1009 vfd->dev = &pci->dev; 1010 vfd->parent = &pci->dev;
1010 vfd->release = video_device_release; 1011 vfd->release = video_device_release;
1011 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", 1012 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
1012 core->name, type, core->board.name); 1013 core->name, type, core->board.name);
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 0fed5cd2ccea..d08c11eb8a75 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -39,6 +39,7 @@
39 39
40#include "cx88.h" 40#include "cx88.h"
41#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
42#include <media/v4l2-ioctl.h>
42 43
43#ifdef CONFIG_VIDEO_V4L1_COMPAT 44#ifdef CONFIG_VIDEO_V4L1_COMPAT
44/* Include V4L1 specific functions. Should be removed soon */ 45/* Include V4L1 specific functions. Should be removed soon */
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 2d9f14d2a00b..67c62eaa5b6d 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -38,6 +38,7 @@
38 38
39#include "em28xx.h" 39#include "em28xx.h"
40#include <media/v4l2-common.h> 40#include <media/v4l2-common.h>
41#include <media/v4l2-ioctl.h>
41#include <media/msp3400.h> 42#include <media/msp3400.h>
42#include <media/tuner.h> 43#include <media/tuner.h>
43 44
@@ -1892,7 +1893,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
1892 return NULL; 1893 return NULL;
1893 *vfd = *template; 1894 *vfd = *template;
1894 vfd->minor = -1; 1895 vfd->minor = -1;
1895 vfd->dev = &dev->udev->dev; 1896 vfd->parent = &dev->udev->dev;
1896 vfd->release = video_device_release; 1897 vfd->release = video_device_release;
1897 vfd->type = type; 1898 vfd->type = type;
1898 vfd->debug = video_debug; 1899 vfd->debug = video_debug;
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index 15d037ae25c5..8cd5f37425ea 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -34,6 +34,7 @@
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
36#include <linux/page-flags.h> 36#include <linux/page-flags.h>
37#include <media/v4l2-ioctl.h>
37#include <asm/byteorder.h> 38#include <asm/byteorder.h>
38#include <asm/page.h> 39#include <asm/page.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
@@ -985,7 +986,7 @@ static DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
985 986
986static int et61x251_create_sysfs(struct et61x251_device* cam) 987static int et61x251_create_sysfs(struct et61x251_device* cam)
987{ 988{
988 struct device *classdev = &(cam->v4ldev->class_dev); 989 struct device *classdev = &(cam->v4ldev->dev);
989 int err = 0; 990 int err = 0;
990 991
991 if ((err = device_create_file(classdev, &dev_attr_reg))) 992 if ((err = device_create_file(classdev, &dev_attr_reg)))
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index 013d593b0c67..18c1dec2f769 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -25,9 +25,6 @@
25#define CONEX_CAM 1 /* special JPEG header */ 25#define CONEX_CAM 1 /* special JPEG header */
26#include "jpeg.h" 26#include "jpeg.h"
27 27
28#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
29static const char version[] = "2.1.7";
30
31MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
32MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver"); 29MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver");
33MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
@@ -1038,7 +1035,7 @@ static int __init sd_mod_init(void)
1038{ 1035{
1039 if (usb_register(&sd_driver) < 0) 1036 if (usb_register(&sd_driver) < 0)
1040 return -1; 1037 return -1;
1041 PDEBUG(D_PROBE, "v%s registered", version); 1038 PDEBUG(D_PROBE, "registered");
1042 return 0; 1039 return 0;
1043} 1040}
1044static void __exit sd_mod_exit(void) 1041static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c
index 8ab4ea7201a9..6f2f1d24b7eb 100644
--- a/drivers/media/video/gspca/etoms.c
+++ b/drivers/media/video/gspca/etoms.c
@@ -22,9 +22,6 @@
22 22
23#include "gspca.h" 23#include "gspca.h"
24 24
25#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
26static const char version[] = "2.1.7";
27
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 25MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
29MODULE_DESCRIPTION("Etoms USB Camera Driver"); 26MODULE_DESCRIPTION("Etoms USB Camera Driver");
30MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
@@ -942,7 +939,7 @@ static int __init sd_mod_init(void)
942{ 939{
943 if (usb_register(&sd_driver) < 0) 940 if (usb_register(&sd_driver) < 0)
944 return -1; 941 return -1;
945 PDEBUG(D_PROBE, "v%s registered", version); 942 PDEBUG(D_PROBE, "registered");
946 return 0; 943 return 0;
947} 944}
948 945
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 16e367cec760..0f09784631ad 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -32,6 +32,7 @@
32#include <asm/page.h> 32#include <asm/page.h>
33#include <linux/uaccess.h> 33#include <linux/uaccess.h>
34#include <linux/jiffies.h> 34#include <linux/jiffies.h>
35#include <media/v4l2-ioctl.h>
35 36
36#include "gspca.h" 37#include "gspca.h"
37 38
@@ -42,8 +43,7 @@ MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
42MODULE_DESCRIPTION("GSPCA USB Camera Driver"); 43MODULE_DESCRIPTION("GSPCA USB Camera Driver");
43MODULE_LICENSE("GPL"); 44MODULE_LICENSE("GPL");
44 45
45#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7) 46#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 2, 0)
46static const char version[] = "2.1.7";
47 47
48static int video_nr = -1; 48static int video_nr = -1;
49 49
@@ -209,6 +209,8 @@ struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
209 &frame->v4l2_buf.timestamp); 209 &frame->v4l2_buf.timestamp);
210 frame->v4l2_buf.sequence = ++gspca_dev->sequence; 210 frame->v4l2_buf.sequence = ++gspca_dev->sequence;
211 } else if (gspca_dev->last_packet_type == DISCARD_PACKET) { 211 } else if (gspca_dev->last_packet_type == DISCARD_PACKET) {
212 if (packet_type == LAST_PACKET)
213 gspca_dev->last_packet_type = packet_type;
212 return frame; 214 return frame;
213 } 215 }
214 216
@@ -399,7 +401,7 @@ static struct usb_host_endpoint *alt_isoc(struct usb_host_interface *alt,
399 * This routine may be called many times when the bandwidth is too small 401 * This routine may be called many times when the bandwidth is too small
400 * (the bandwidth is checked on urb submit). 402 * (the bandwidth is checked on urb submit).
401 */ 403 */
402struct usb_host_endpoint *get_isoc_ep(struct gspca_dev *gspca_dev) 404static struct usb_host_endpoint *get_isoc_ep(struct gspca_dev *gspca_dev)
403{ 405{
404 struct usb_interface *intf; 406 struct usb_interface *intf;
405 struct usb_host_endpoint *ep; 407 struct usb_host_endpoint *ep;
@@ -1740,7 +1742,7 @@ int gspca_dev_probe(struct usb_interface *intf,
1740 1742
1741 /* init video stuff */ 1743 /* init video stuff */
1742 memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template); 1744 memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template);
1743 gspca_dev->vdev.dev = &dev->dev; 1745 gspca_dev->vdev.parent = &dev->dev;
1744 memcpy(&gspca_dev->fops, &dev_fops, sizeof gspca_dev->fops); 1746 memcpy(&gspca_dev->fops, &dev_fops, sizeof gspca_dev->fops);
1745 gspca_dev->vdev.fops = &gspca_dev->fops; 1747 gspca_dev->vdev.fops = &gspca_dev->fops;
1746 gspca_dev->fops.owner = module; /* module protection */ 1748 gspca_dev->fops.owner = module; /* module protection */
@@ -1885,7 +1887,10 @@ EXPORT_SYMBOL(gspca_auto_gain_n_exposure);
1885/* -- module insert / remove -- */ 1887/* -- module insert / remove -- */
1886static int __init gspca_init(void) 1888static int __init gspca_init(void)
1887{ 1889{
1888 info("main v%s registered", version); 1890 info("main v%d.%d.%d registered",
1891 (DRIVER_VERSION_NUMBER >> 16) & 0xff,
1892 (DRIVER_VERSION_NUMBER >> 8) & 0xff,
1893 DRIVER_VERSION_NUMBER & 0xff);
1889 return 0; 1894 return 0;
1890} 1895}
1891static void __exit gspca_exit(void) 1896static void __exit gspca_exit(void)
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c
index 88c2b02f380a..a4706162f415 100644
--- a/drivers/media/video/gspca/mars.c
+++ b/drivers/media/video/gspca/mars.c
@@ -24,9 +24,6 @@
24#include "gspca.h" 24#include "gspca.h"
25#include "jpeg.h" 25#include "jpeg.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/Mars USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/Mars USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -451,7 +448,7 @@ static int __init sd_mod_init(void)
451{ 448{
452 if (usb_register(&sd_driver) < 0) 449 if (usb_register(&sd_driver) < 0)
453 return -1; 450 return -1;
454 PDEBUG(D_PROBE, "v%s registered", version); 451 PDEBUG(D_PROBE, "registered");
455 return 0; 452 return 0;
456} 453}
457static void __exit sd_mod_exit(void) 454static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c
index 08d99c3b78e2..f15bec7080c9 100644
--- a/drivers/media/video/gspca/ov519.c
+++ b/drivers/media/video/gspca/ov519.c
@@ -24,9 +24,6 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); 27MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
31MODULE_DESCRIPTION("OV519 USB Camera Driver"); 28MODULE_DESCRIPTION("OV519 USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -2169,7 +2166,7 @@ static int __init sd_mod_init(void)
2169{ 2166{
2170 if (usb_register(&sd_driver) < 0) 2167 if (usb_register(&sd_driver) < 0)
2171 return -1; 2168 return -1;
2172 PDEBUG(D_PROBE, "v%s registered", version); 2169 PDEBUG(D_PROBE, "registered");
2173 return 0; 2170 return 0;
2174} 2171}
2175static void __exit sd_mod_exit(void) 2172static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c
index fa7abc411090..f790746370d7 100644
--- a/drivers/media/video/gspca/pac207.c
+++ b/drivers/media/video/gspca/pac207.c
@@ -27,9 +27,6 @@
27 27
28#include "gspca.h" 28#include "gspca.h"
29 29
30#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
31static const char version[] = "2.1.7";
32
33MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>"); 30MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>");
34MODULE_DESCRIPTION("Pixart PAC207"); 31MODULE_DESCRIPTION("Pixart PAC207");
35MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
@@ -208,7 +205,7 @@ static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index,
208} 205}
209 206
210 207
211int pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value) 208static int pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value)
212{ 209{
213 struct usb_device *udev = gspca_dev->dev; 210 struct usb_device *udev = gspca_dev->dev;
214 int err; 211 int err;
@@ -223,8 +220,7 @@ int pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value)
223 return err; 220 return err;
224} 221}
225 222
226 223static int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index)
227int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index)
228{ 224{
229 struct usb_device *udev = gspca_dev->dev; 225 struct usb_device *udev = gspca_dev->dev;
230 int res; 226 int res;
@@ -609,7 +605,7 @@ static int __init sd_mod_init(void)
609{ 605{
610 if (usb_register(&sd_driver) < 0) 606 if (usb_register(&sd_driver) < 0)
611 return -1; 607 return -1;
612 PDEBUG(D_PROBE, "v%s registered", version); 608 PDEBUG(D_PROBE, "registered");
613 return 0; 609 return 0;
614} 610}
615static void __exit sd_mod_exit(void) 611static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index 5c052e31be4a..2267ae7cb87f 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -23,9 +23,6 @@
23 23
24#include "gspca.h" 24#include "gspca.h"
25 25
26#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
27static const char version[] = "2.1.7";
28
29MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li"); 26MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li");
30MODULE_DESCRIPTION("Pixart PAC7311"); 27MODULE_DESCRIPTION("Pixart PAC7311");
31MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
@@ -747,7 +744,7 @@ static int __init sd_mod_init(void)
747{ 744{
748 if (usb_register(&sd_driver) < 0) 745 if (usb_register(&sd_driver) < 0)
749 return -1; 746 return -1;
750 PDEBUG(D_PROBE, "v%s registered", version); 747 PDEBUG(D_PROBE, "registered");
751 return 0; 748 return 0;
752} 749}
753static void __exit sd_mod_exit(void) 750static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index dbeebe8625c5..f6bef896d3a5 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -24,9 +24,6 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 8)
28static const char version[] = "2.1.8";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SN9C102 USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/SN9C102 USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -1464,7 +1461,7 @@ static int __init sd_mod_init(void)
1464{ 1461{
1465 if (usb_register(&sd_driver) < 0) 1462 if (usb_register(&sd_driver) < 0)
1466 return -1; 1463 return -1;
1467 PDEBUG(D_PROBE, "v%s registered", version); 1464 PDEBUG(D_PROBE, "registered");
1468 return 0; 1465 return 0;
1469} 1466}
1470static void __exit sd_mod_exit(void) 1467static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 3e68b9926956..35b1a3ee4c3f 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -24,9 +24,6 @@
24#include "gspca.h" 24#include "gspca.h"
25#include "jpeg.h" 25#include "jpeg.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -361,6 +358,7 @@ static const __u8 mo4000_sensor_init[][8] = {
361}; 358};
362static const __u8 ov7660_sensor_init[][8] = { 359static const __u8 ov7660_sensor_init[][8] = {
363 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ 360 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
361/* (delay 20ms) */
364 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, 362 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
365 /* Outformat ?? rawRGB */ 363 /* Outformat ?? rawRGB */
366 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ 364 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
@@ -539,13 +537,31 @@ static void reg_r(struct gspca_dev *gspca_dev,
539 value, 0, 537 value, 0,
540 gspca_dev->usb_buf, len, 538 gspca_dev->usb_buf, len,
541 500); 539 500);
540 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
542} 541}
543 542
543static void reg_w1(struct gspca_dev *gspca_dev,
544 __u16 value,
545 __u8 data)
546{
547 PDEBUG(D_USBO, "reg_w1 [%02x] = %02x", value, data);
548 gspca_dev->usb_buf[0] = data;
549 usb_control_msg(gspca_dev->dev,
550 usb_sndctrlpipe(gspca_dev->dev, 0),
551 0x08,
552 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
553 value,
554 0,
555 gspca_dev->usb_buf, 1,
556 500);
557}
544static void reg_w(struct gspca_dev *gspca_dev, 558static void reg_w(struct gspca_dev *gspca_dev,
545 __u16 value, 559 __u16 value,
546 const __u8 *buffer, 560 const __u8 *buffer,
547 int len) 561 int len)
548{ 562{
563 PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..",
564 value, buffer[0], buffer[1]);
549 if (len <= sizeof gspca_dev->usb_buf) { 565 if (len <= sizeof gspca_dev->usb_buf) {
550 memcpy(gspca_dev->usb_buf, buffer, len); 566 memcpy(gspca_dev->usb_buf, buffer, len);
551 usb_control_msg(gspca_dev->dev, 567 usb_control_msg(gspca_dev->dev,
@@ -571,31 +587,42 @@ static void reg_w(struct gspca_dev *gspca_dev,
571 } 587 }
572} 588}
573 589
574/* I2C write 2 bytes */ 590/* I2C write 1 byte */
575static void i2c_w2(struct gspca_dev *gspca_dev, 591static void i2c_w1(struct gspca_dev *gspca_dev, __u8 reg, __u8 val)
576 const __u8 *buffer)
577{ 592{
578 struct sd *sd = (struct sd *) gspca_dev; 593 struct sd *sd = (struct sd *) gspca_dev;
579 __u8 mode[8];
580 594
581 /* is i2c ready */ 595 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
582 mode[0] = 0x81 | (2 << 4); 596 gspca_dev->usb_buf[0] = 0x81 | (2 << 4); /* = a1 */
583 mode[1] = sd->i2c_base; 597 gspca_dev->usb_buf[1] = sd->i2c_base;
584 mode[2] = buffer[0]; 598 gspca_dev->usb_buf[2] = reg;
585 mode[3] = buffer[1]; 599 gspca_dev->usb_buf[3] = val;
586 mode[4] = 0; 600 gspca_dev->usb_buf[4] = 0;
587 mode[5] = 0; 601 gspca_dev->usb_buf[5] = 0;
588 mode[6] = 0; 602 gspca_dev->usb_buf[6] = 0;
589 mode[7] = 0x10; 603 gspca_dev->usb_buf[7] = 0x10;
590 reg_w(gspca_dev, 0x08, mode, 8); 604 usb_control_msg(gspca_dev->dev,
605 usb_sndctrlpipe(gspca_dev->dev, 0),
606 0x08,
607 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
608 0x08, /* value = i2c */
609 0,
610 gspca_dev->usb_buf, 8,
611 500);
591} 612}
592 613
593/* I2C write 8 bytes */ 614/* I2C write 8 bytes */
594static void i2c_w8(struct gspca_dev *gspca_dev, 615static void i2c_w8(struct gspca_dev *gspca_dev,
595 const __u8 *buffer) 616 const __u8 *buffer)
596{ 617{
597 reg_w(gspca_dev, 0x08, buffer, 8); 618 memcpy(gspca_dev->usb_buf, buffer, 8);
598 msleep(1); 619 usb_control_msg(gspca_dev->dev,
620 usb_sndctrlpipe(gspca_dev->dev, 0),
621 0x08,
622 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
623 0x08, 0, /* value, index */
624 gspca_dev->usb_buf, 8,
625 500);
599} 626}
600 627
601/* read 5 bytes in gspca_dev->usb_buf */ 628/* read 5 bytes in gspca_dev->usb_buf */
@@ -613,24 +640,21 @@ static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg)
613 mode[6] = 0; 640 mode[6] = 0;
614 mode[7] = 0x10; 641 mode[7] = 0x10;
615 i2c_w8(gspca_dev, mode); 642 i2c_w8(gspca_dev, mode);
643 msleep(2);
616 mode[0] = 0x81 | (5 << 4) | 0x02; 644 mode[0] = 0x81 | (5 << 4) | 0x02;
617 mode[2] = 0; 645 mode[2] = 0;
618 i2c_w8(gspca_dev, mode); 646 i2c_w8(gspca_dev, mode);
647 msleep(2);
619 reg_r(gspca_dev, 0x0a, 5); 648 reg_r(gspca_dev, 0x0a, 5);
620} 649}
621 650
622static int probesensor(struct gspca_dev *gspca_dev) 651static int probesensor(struct gspca_dev *gspca_dev)
623{ 652{
624 struct sd *sd = (struct sd *) gspca_dev; 653 struct sd *sd = (struct sd *) gspca_dev;
625 __u8 reg02;
626 static const __u8 datasend[] = { 2, 0 };
627 /* reg val1 val2 val3 val4 */
628 654
629 i2c_w2(gspca_dev, datasend); 655 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
630/* should write 0xa1 0x11 0x02 0x00 0x00 0x00 0x00 the 0x10 is add by i2cw */
631 msleep(10); 656 msleep(10);
632 reg02 = 0x66; 657 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
633 reg_w(gspca_dev, 0x02, &reg02, 1); /* Gpio on */
634 msleep(10); 658 msleep(10);
635 i2c_r5(gspca_dev, 0); /* read sensor id */ 659 i2c_r5(gspca_dev, 0); /* read sensor id */
636 if (gspca_dev->usb_buf[0] == 0x02 660 if (gspca_dev->usb_buf[0] == 0x02
@@ -642,7 +666,7 @@ static int probesensor(struct gspca_dev *gspca_dev)
642 sd->sensor = SENSOR_HV7131R; 666 sd->sensor = SENSOR_HV7131R;
643 return SENSOR_HV7131R; 667 return SENSOR_HV7131R;
644 } 668 }
645 PDEBUG(D_PROBE, "Find Sensor %d %d %d", 669 PDEBUG(D_PROBE, "Find Sensor 0x%02x 0x%02x 0x%02x",
646 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1], 670 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
647 gspca_dev->usb_buf[2]); 671 gspca_dev->usb_buf[2]);
648 PDEBUG(D_PROBE, "Sensor sn9c102P Not found"); 672 PDEBUG(D_PROBE, "Sensor sn9c102P Not found");
@@ -653,8 +677,6 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
653 const __u8 *sn9c1xx) 677 const __u8 *sn9c1xx)
654{ 678{
655 struct sd *sd = (struct sd *) gspca_dev; 679 struct sd *sd = (struct sd *) gspca_dev;
656 __u8 data;
657 __u8 regF1;
658 const __u8 *reg9a; 680 const __u8 *reg9a;
659 static const __u8 reg9a_def[] = 681 static const __u8 reg9a_def[] =
660 {0x08, 0x40, 0x20, 0x10, 0x00, 0x04}; 682 {0x08, 0x40, 0x20, 0x10, 0x00, 0x04};
@@ -663,15 +685,13 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
663 static const __u8 reg9a_sn9c325[] = 685 static const __u8 reg9a_sn9c325[] =
664 {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20}; 686 {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20};
665 687
666 688 reg_w1(gspca_dev, 0xf1, 0x00);
667 regF1 = 0x00; 689 reg_w1(gspca_dev, 0x01, sn9c1xx[0]); /*fixme:jfm was [1] en v1*/
668 reg_w(gspca_dev, 0xf1, &regF1, 1);
669 reg_w(gspca_dev, 0x01, &sn9c1xx[0], 1); /*fixme:jfm was [1] en v1*/
670 690
671 /* configure gpio */ 691 /* configure gpio */
672 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2); 692 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
673 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); 693 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
674 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm was 3 */ 694 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
675 switch (sd->bridge) { 695 switch (sd->bridge) {
676 case BRIDGE_SN9C325: 696 case BRIDGE_SN9C325:
677 reg9a = reg9a_sn9c325; 697 reg9a = reg9a_sn9c325;
@@ -685,35 +705,25 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
685 } 705 }
686 reg_w(gspca_dev, 0x9a, reg9a, 6); 706 reg_w(gspca_dev, 0x9a, reg9a, 6);
687 707
688 data = 0x60; /*fixme:jfm 60 00 00 (3) */ 708 reg_w1(gspca_dev, 0xd4, 0x60); /*fixme:jfm 60 00 00 (3) ? */
689 reg_w(gspca_dev, 0xd4, &data, 1);
690 709
691 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); 710 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
692 711
693 switch (sd->bridge) { 712 switch (sd->bridge) {
694 case BRIDGE_SN9C120: /* from win trace */ 713 case BRIDGE_SN9C120: /* from win trace */
695 data = 0x61; 714 reg_w1(gspca_dev, 0x01, 0x61);
696 reg_w(gspca_dev, 0x01, &data, 1); 715 reg_w1(gspca_dev, 0x17, 0x20);
697 data = 0x20; 716 reg_w1(gspca_dev, 0x01, 0x60);
698 reg_w(gspca_dev, 0x17, &data, 1);
699 data = 0x60;
700 reg_w(gspca_dev, 0x01, &data, 1);
701 break; 717 break;
702 case BRIDGE_SN9C325: 718 case BRIDGE_SN9C325:
703 data = 0x43; 719 reg_w1(gspca_dev, 0x01, 0x43);
704 reg_w(gspca_dev, 0x01, &data, 1); 720 reg_w1(gspca_dev, 0x17, 0xae);
705 data = 0xae; 721 reg_w1(gspca_dev, 0x01, 0x42);
706 reg_w(gspca_dev, 0x17, &data, 1);
707 data = 0x42;
708 reg_w(gspca_dev, 0x01, &data, 1);
709 break; 722 break;
710 default: 723 default:
711 data = 0x43; 724 reg_w1(gspca_dev, 0x01, 0x43);
712 reg_w(gspca_dev, 0x01, &data, 1); 725 reg_w1(gspca_dev, 0x17, 0x61);
713 data = 0x61; 726 reg_w1(gspca_dev, 0x01, 0x42);
714 reg_w(gspca_dev, 0x17, &data, 1);
715 data = 0x42;
716 reg_w(gspca_dev, 0x01, &data, 1);
717 } 727 }
718 728
719 if (sd->sensor == SENSOR_HV7131R) { 729 if (sd->sensor == SENSOR_HV7131R) {
@@ -770,6 +780,9 @@ static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
770{ 780{
771 int i = 0; 781 int i = 0;
772 782
783 i2c_w8(gspca_dev, ov7660_sensor_init[i]); /* reset SCCB */
784 i++;
785 msleep(20);
773 while (ov7660_sensor_init[i][0]) { 786 while (ov7660_sensor_init[i][0]) {
774 i2c_w8(gspca_dev, ov7660_sensor_init[i]); 787 i2c_w8(gspca_dev, ov7660_sensor_init[i]);
775 i++; 788 i++;
@@ -782,13 +795,11 @@ static int sd_config(struct gspca_dev *gspca_dev,
782{ 795{
783 struct sd *sd = (struct sd *) gspca_dev; 796 struct sd *sd = (struct sd *) gspca_dev;
784 struct cam *cam; 797 struct cam *cam;
785 __u16 vendor;
786 __u16 product; 798 __u16 product;
787 799
788 vendor = id->idVendor;
789 product = id->idProduct; 800 product = id->idProduct;
790 sd->sensor = -1; 801 sd->sensor = -1;
791 switch (vendor) { 802 switch (id->idVendor) {
792 case 0x0458: /* Genius */ 803 case 0x0458: /* Genius */
793/* switch (product) { 804/* switch (product) {
794 case 0x7025: */ 805 case 0x7025: */
@@ -960,7 +971,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
960 } 971 }
961 if (sd->sensor < 0) { 972 if (sd->sensor < 0) {
962 PDEBUG(D_ERR, "Invalid vendor/product %04x:%04x", 973 PDEBUG(D_ERR, "Invalid vendor/product %04x:%04x",
963 vendor, product); 974 id->idVendor, product);
964 return -EINVAL; 975 return -EINVAL;
965 } 976 }
966 977
@@ -983,34 +994,26 @@ static int sd_open(struct gspca_dev *gspca_dev)
983{ 994{
984 struct sd *sd = (struct sd *) gspca_dev; 995 struct sd *sd = (struct sd *) gspca_dev;
985/* const __u8 *sn9c1xx; */ 996/* const __u8 *sn9c1xx; */
986 __u8 regF1;
987 __u8 regGpio[] = { 0x29, 0x74 }; 997 __u8 regGpio[] = { 0x29, 0x74 };
998 __u8 regF1;
988 999
989 /* setup a selector by bridge */ 1000 /* setup a selector by bridge */
990 regF1 = 0x01; 1001 reg_w1(gspca_dev, 0xf1, 0x01);
991 reg_w(gspca_dev, 0xf1, &regF1, 1);
992 reg_r(gspca_dev, 0x00, 1); /* -> regF1 = 0x00 */ 1002 reg_r(gspca_dev, 0x00, 1); /* -> regF1 = 0x00 */
993 regF1 = gspca_dev->usb_buf[0]; 1003 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
994 reg_w(gspca_dev, 0xf1, &regF1, 1);
995 reg_r(gspca_dev, 0x00, 1); 1004 reg_r(gspca_dev, 0x00, 1);
996 regF1 = gspca_dev->usb_buf[0]; 1005 regF1 = gspca_dev->usb_buf[0];
997 switch (sd->bridge) { 1006 switch (sd->bridge) {
998 case BRIDGE_SN9C102P: 1007 case BRIDGE_SN9C102P:
999 if (regF1 != 0x11) 1008 if (regF1 != 0x11)
1000 return -ENODEV; 1009 return -ENODEV;
1001 reg_w(gspca_dev, 0x02, &regGpio[1], 1); 1010 reg_w1(gspca_dev, 0x02, regGpio[1]);
1002 break; 1011 break;
1003 case BRIDGE_SN9C105: 1012 case BRIDGE_SN9C105:
1004 if (regF1 != 0x11) 1013 if (regF1 != 0x11)
1005 return -ENODEV; 1014 return -ENODEV;
1006 reg_w(gspca_dev, 0x02, regGpio, 2); 1015 reg_w(gspca_dev, 0x02, regGpio, 2);
1007 break; 1016 break;
1008 case BRIDGE_SN9C110:
1009 if (regF1 != 0x12)
1010 return -ENODEV;
1011 regGpio[1] = 0x62;
1012 reg_w(gspca_dev, 0x02, &regGpio[1], 1);
1013 break;
1014 case BRIDGE_SN9C120: 1017 case BRIDGE_SN9C120:
1015 if (regF1 != 0x12) 1018 if (regF1 != 0x12)
1016 return -ENODEV; 1019 return -ENODEV;
@@ -1018,16 +1021,15 @@ static int sd_open(struct gspca_dev *gspca_dev)
1018 reg_w(gspca_dev, 0x02, regGpio, 2); 1021 reg_w(gspca_dev, 0x02, regGpio, 2);
1019 break; 1022 break;
1020 default: 1023 default:
1024/* case BRIDGE_SN9C110: */
1021/* case BRIDGE_SN9C325: */ 1025/* case BRIDGE_SN9C325: */
1022 if (regF1 != 0x12) 1026 if (regF1 != 0x12)
1023 return -ENODEV; 1027 return -ENODEV;
1024 regGpio[1] = 0x62; 1028 reg_w1(gspca_dev, 0x02, 0x62);
1025 reg_w(gspca_dev, 0x02, &regGpio[1], 1);
1026 break; 1029 break;
1027 } 1030 }
1028 1031
1029 regF1 = 0x01; 1032 reg_w1(gspca_dev, 0xf1, 0x01);
1030 reg_w(gspca_dev, 0xf1, &regF1, 1);
1031 1033
1032 return 0; 1034 return 0;
1033} 1035}
@@ -1123,7 +1125,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
1123 } 1125 }
1124 1126
1125 k2 = sd->brightness >> 10; 1127 k2 = sd->brightness >> 10;
1126 reg_w(gspca_dev, 0x96, &k2, 1); 1128 reg_w1(gspca_dev, 0x96, k2);
1127} 1129}
1128 1130
1129static void setcontrast(struct gspca_dev *gspca_dev) 1131static void setcontrast(struct gspca_dev *gspca_dev)
@@ -1152,7 +1154,7 @@ static void setcolors(struct gspca_dev *gspca_dev)
1152 data = (colour + 32) & 0x7f; /* blue */ 1154 data = (colour + 32) & 0x7f; /* blue */
1153 else 1155 else
1154 data = (-colour + 32) & 0x7f; /* red */ 1156 data = (-colour + 32) & 0x7f; /* red */
1155 reg_w(gspca_dev, 0x05, &data, 1); 1157 reg_w1(gspca_dev, 0x05, data);
1156} 1158}
1157 1159
1158/* -- start the camera -- */ 1160/* -- start the camera -- */
@@ -1165,7 +1167,6 @@ static void sd_start(struct gspca_dev *gspca_dev)
1165 __u8 reg17; 1167 __u8 reg17;
1166 const __u8 *sn9c1xx; 1168 const __u8 *sn9c1xx;
1167 int mode; 1169 int mode;
1168 static const __u8 DC29[] = { 0x6a, 0x50, 0x00, 0x00, 0x50, 0x3c };
1169 static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; 1170 static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1170 static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; 1171 static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1171 static const __u8 CA_sn9c120[] = 1172 static const __u8 CA_sn9c120[] =
@@ -1179,21 +1180,20 @@ static void sd_start(struct gspca_dev *gspca_dev)
1179 1180
1180/*fixme:jfm this sequence should appear at end of sd_start */ 1181/*fixme:jfm this sequence should appear at end of sd_start */
1181/* with 1182/* with
1182 data = 0x44; 1183 reg_w1(gspca_dev, 0x01, 0x44); */
1183 reg_w(gspca_dev, 0x01, &data, 1); */ 1184 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
1184 reg_w(gspca_dev, 0x15, &sn9c1xx[0x15], 1); 1185 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
1185 reg_w(gspca_dev, 0x16, &sn9c1xx[0x16], 1); 1186 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
1186 reg_w(gspca_dev, 0x12, &sn9c1xx[0x12], 1); 1187 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
1187 reg_w(gspca_dev, 0x13, &sn9c1xx[0x13], 1); 1188 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1188 reg_w(gspca_dev, 0x18, &sn9c1xx[0x18], 1); 1189 reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */
1189 reg_w(gspca_dev, 0xd2, &DC29[0], 1); 1190 reg_w1(gspca_dev, 0xd3, 0x50);
1190 reg_w(gspca_dev, 0xd3, &DC29[1], 1); 1191 reg_w1(gspca_dev, 0xc6, 0x00);
1191 reg_w(gspca_dev, 0xc6, &DC29[2], 1); 1192 reg_w1(gspca_dev, 0xc7, 0x00);
1192 reg_w(gspca_dev, 0xc7, &DC29[3], 1); 1193 reg_w1(gspca_dev, 0xc8, 0x50);
1193 reg_w(gspca_dev, 0xc8, &DC29[4], 1); 1194 reg_w1(gspca_dev, 0xc9, 0x3c);
1194 reg_w(gspca_dev, 0xc9, &DC29[5], 1);
1195/*fixme:jfm end of ending sequence */ 1195/*fixme:jfm end of ending sequence */
1196 reg_w(gspca_dev, 0x18, &sn9c1xx[0x18], 1); 1196 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1197 switch (sd->bridge) { 1197 switch (sd->bridge) {
1198 case BRIDGE_SN9C325: 1198 case BRIDGE_SN9C325:
1199 data = 0xae; 1199 data = 0xae;
@@ -1205,11 +1205,11 @@ static void sd_start(struct gspca_dev *gspca_dev)
1205 data = 0x60; 1205 data = 0x60;
1206 break; 1206 break;
1207 } 1207 }
1208 reg_w(gspca_dev, 0x17, &data, 1); 1208 reg_w1(gspca_dev, 0x17, data);
1209 reg_w(gspca_dev, 0x05, &sn9c1xx[5], 1); 1209 reg_w1(gspca_dev, 0x05, sn9c1xx[5]);
1210 reg_w(gspca_dev, 0x07, &sn9c1xx[7], 1); 1210 reg_w1(gspca_dev, 0x07, sn9c1xx[7]);
1211 reg_w(gspca_dev, 0x06, &sn9c1xx[6], 1); 1211 reg_w1(gspca_dev, 0x06, sn9c1xx[6]);
1212 reg_w(gspca_dev, 0x14, &sn9c1xx[0x14], 1); 1212 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
1213 switch (sd->bridge) { 1213 switch (sd->bridge) {
1214 case BRIDGE_SN9C325: 1214 case BRIDGE_SN9C325:
1215 reg_w(gspca_dev, 0x20, regsn20_sn9c325, 1215 reg_w(gspca_dev, 0x20, regsn20_sn9c325,
@@ -1217,10 +1217,8 @@ static void sd_start(struct gspca_dev *gspca_dev)
1217 for (i = 0; i < 8; i++) 1217 for (i = 0; i < 8; i++)
1218 reg_w(gspca_dev, 0x84, reg84_sn9c325, 1218 reg_w(gspca_dev, 0x84, reg84_sn9c325,
1219 sizeof reg84_sn9c325); 1219 sizeof reg84_sn9c325);
1220 data = 0x0a; 1220 reg_w1(gspca_dev, 0x9a, 0x0a);
1221 reg_w(gspca_dev, 0x9a, &data, 1); 1221 reg_w1(gspca_dev, 0x99, 0x60);
1222 data = 0x60;
1223 reg_w(gspca_dev, 0x99, &data, 1);
1224 break; 1222 break;
1225 case BRIDGE_SN9C120: 1223 case BRIDGE_SN9C120:
1226 reg_w(gspca_dev, 0x20, regsn20_sn9c120, 1224 reg_w(gspca_dev, 0x20, regsn20_sn9c120,
@@ -1233,39 +1231,30 @@ static void sd_start(struct gspca_dev *gspca_dev)
1233 sizeof reg84_sn9c120_2); 1231 sizeof reg84_sn9c120_2);
1234 reg_w(gspca_dev, 0x84, reg84_sn9c120_3, 1232 reg_w(gspca_dev, 0x84, reg84_sn9c120_3,
1235 sizeof reg84_sn9c120_3); 1233 sizeof reg84_sn9c120_3);
1236 data = 0x05; 1234 reg_w1(gspca_dev, 0x9a, 0x05);
1237 reg_w(gspca_dev, 0x9a, &data, 1); 1235 reg_w1(gspca_dev, 0x99, 0x5b);
1238 data = 0x5b;
1239 reg_w(gspca_dev, 0x99, &data, 1);
1240 break; 1236 break;
1241 default: 1237 default:
1242 reg_w(gspca_dev, 0x20, regsn20, sizeof regsn20); 1238 reg_w(gspca_dev, 0x20, regsn20, sizeof regsn20);
1243 for (i = 0; i < 8; i++) 1239 for (i = 0; i < 8; i++)
1244 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 1240 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1245 data = 0x08; 1241 reg_w1(gspca_dev, 0x9a, 0x08);
1246 reg_w(gspca_dev, 0x9a, &data, 1); 1242 reg_w1(gspca_dev, 0x99, 0x59);
1247 data = 0x59;
1248 reg_w(gspca_dev, 0x99, &data, 1);
1249 break; 1243 break;
1250 } 1244 }
1251 1245
1252 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 1246 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
1253 reg1 = 0x02; 1247 if (mode)
1248 reg1 = 0x46; /* 320 clk 48Mhz */
1249 else
1250 reg1 = 0x06; /* 640 clk 24Mz */
1254 reg17 = 0x61; 1251 reg17 = 0x61;
1255 switch (sd->sensor) { 1252 switch (sd->sensor) {
1256 case SENSOR_HV7131R: 1253 case SENSOR_HV7131R:
1257 hv7131R_InitSensor(gspca_dev); 1254 hv7131R_InitSensor(gspca_dev);
1258 if (mode)
1259 reg1 = 0x46; /* 320 clk 48Mhz */
1260 else
1261 reg1 = 0x06; /* 640 clk 24Mz */
1262 break; 1255 break;
1263 case SENSOR_MI0360: 1256 case SENSOR_MI0360:
1264 mi0360_InitSensor(gspca_dev); 1257 mi0360_InitSensor(gspca_dev);
1265 if (mode)
1266 reg1 = 0x46; /* 320 clk 48Mhz */
1267 else
1268 reg1 = 0x06; /* 640 clk 24Mz */
1269 break; 1258 break;
1270 case SENSOR_MO4000: 1259 case SENSOR_MO4000:
1271 mo4000_InitSensor(gspca_dev); 1260 mo4000_InitSensor(gspca_dev);
@@ -1274,13 +1263,13 @@ static void sd_start(struct gspca_dev *gspca_dev)
1274 reg1 = 0x06; /* clk 24Mz */ 1263 reg1 = 0x06; /* clk 24Mz */
1275 } else { 1264 } else {
1276 reg17 = 0x22; /* 640 MCKSIZE */ 1265 reg17 = 0x22; /* 640 MCKSIZE */
1277 reg1 = 0x06; /* 640 clk 24Mz */ 1266/* reg1 = 0x06; * 640 clk 24Mz (done) */
1278 } 1267 }
1279 break; 1268 break;
1280 case SENSOR_OV7648: 1269 case SENSOR_OV7648:
1270 ov7648_InitSensor(gspca_dev);
1281 reg17 = 0xa2; 1271 reg17 = 0xa2;
1282 reg1 = 0x44; 1272 reg1 = 0x44;
1283 ov7648_InitSensor(gspca_dev);
1284/* if (mode) 1273/* if (mode)
1285 ; * 320x2... 1274 ; * 320x2...
1286 else 1275 else
@@ -1292,7 +1281,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
1292 if (mode) { 1281 if (mode) {
1293/* reg17 = 0x21; * 320 */ 1282/* reg17 = 0x21; * 320 */
1294/* reg1 = 0x44; */ 1283/* reg1 = 0x44; */
1295 reg1 = 0x46; 1284/* reg1 = 0x46; (done) */
1296 } else { 1285 } else {
1297 reg17 = 0xa2; /* 640 */ 1286 reg17 = 0xa2; /* 640 */
1298 reg1 = 0x40; 1287 reg1 = 0x40;
@@ -1321,16 +1310,16 @@ static void sd_start(struct gspca_dev *gspca_dev)
1321 1310
1322 /* here change size mode 0 -> VGA; 1 -> CIF */ 1311 /* here change size mode 0 -> VGA; 1 -> CIF */
1323 data = 0x40 | sn9c1xx[0x18] | (mode << 4); 1312 data = 0x40 | sn9c1xx[0x18] | (mode << 4);
1324 reg_w(gspca_dev, 0x18, &data, 1); 1313 reg_w1(gspca_dev, 0x18, data);
1325 1314
1326 reg_w(gspca_dev, 0x100, qtable4, 0x40); 1315 reg_w(gspca_dev, 0x100, qtable4, 0x40);
1327 reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40); 1316 reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40);
1328 1317
1329 data = sn9c1xx[0x18] | (mode << 4); 1318 data = sn9c1xx[0x18] | (mode << 4);
1330 reg_w(gspca_dev, 0x18, &data, 1); 1319 reg_w1(gspca_dev, 0x18, data);
1331 1320
1332 reg_w(gspca_dev, 0x17, &reg17, 1); 1321 reg_w1(gspca_dev, 0x17, reg17);
1333 reg_w(gspca_dev, 0x01, &reg1, 1); 1322 reg_w1(gspca_dev, 0x01, reg1);
1334 setbrightness(gspca_dev); 1323 setbrightness(gspca_dev);
1335 setcontrast(gspca_dev); 1324 setcontrast(gspca_dev);
1336} 1325}
@@ -1342,7 +1331,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1342 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; 1331 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
1343 static const __u8 stopmi0360[] = 1332 static const __u8 stopmi0360[] =
1344 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 }; 1333 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
1345 __u8 regF1;
1346 __u8 data; 1334 __u8 data;
1347 const __u8 *sn9c1xx; 1335 const __u8 *sn9c1xx;
1348 1336
@@ -1366,12 +1354,11 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1366 break; 1354 break;
1367 } 1355 }
1368 sn9c1xx = sn_tb[(int) sd->sensor]; 1356 sn9c1xx = sn_tb[(int) sd->sensor];
1369 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 1); 1357 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1370 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 1); 1358 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
1371 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 1); 1359 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1372 reg_w(gspca_dev, 0x01, &data, 1); 1360 reg_w1(gspca_dev, 0x01, data);
1373 regF1 = 0x01; 1361 reg_w1(gspca_dev, 0xf1, 0x01);
1374 reg_w(gspca_dev, 0xf1, &regF1, 1);
1375} 1362}
1376 1363
1377static void sd_stop0(struct gspca_dev *gspca_dev) 1364static void sd_stop0(struct gspca_dev *gspca_dev)
@@ -1658,7 +1645,7 @@ static int __init sd_mod_init(void)
1658{ 1645{
1659 if (usb_register(&sd_driver) < 0) 1646 if (usb_register(&sd_driver) < 0)
1660 return -1; 1647 return -1;
1661 info("v%s registered", version); 1648 info("registered");
1662 return 0; 1649 return 0;
1663} 1650}
1664static void __exit sd_mod_exit(void) 1651static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c
index 156206118795..8c83823745f0 100644
--- a/drivers/media/video/gspca/spca500.c
+++ b/drivers/media/video/gspca/spca500.c
@@ -24,9 +24,6 @@
24#include "gspca.h" 24#include "gspca.h"
25#include "jpeg.h" 25#include "jpeg.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SPCA500 USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/SPCA500 USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -1203,7 +1200,7 @@ static int __init sd_mod_init(void)
1203{ 1200{
1204 if (usb_register(&sd_driver) < 0) 1201 if (usb_register(&sd_driver) < 0)
1205 return -1; 1202 return -1;
1206 PDEBUG(D_PROBE, "v%s registered", version); 1203 PDEBUG(D_PROBE, "registered");
1207 return 0; 1204 return 0;
1208} 1205}
1209static void __exit sd_mod_exit(void) 1206static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c
index 50e929de0203..6537acee89dd 100644
--- a/drivers/media/video/gspca/spca501.c
+++ b/drivers/media/video/gspca/spca501.c
@@ -23,9 +23,6 @@
23 23
24#include "gspca.h" 24#include "gspca.h"
25 25
26#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
27static const char version[] = "2.1.7";
28
29MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 26MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
30MODULE_DESCRIPTION("GSPCA/SPCA501 USB Camera Driver"); 27MODULE_DESCRIPTION("GSPCA/SPCA501 USB Camera Driver");
31MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
@@ -2216,7 +2213,7 @@ static int __init sd_mod_init(void)
2216{ 2213{
2217 if (usb_register(&sd_driver) < 0) 2214 if (usb_register(&sd_driver) < 0)
2218 return -1; 2215 return -1;
2219 PDEBUG(D_PROBE, "v%s registered", version); 2216 PDEBUG(D_PROBE, "registered");
2220 return 0; 2217 return 0;
2221} 2218}
2222static void __exit sd_mod_exit(void) 2219static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c
index ddea6e140aa8..1bb23d03f048 100644
--- a/drivers/media/video/gspca/spca505.c
+++ b/drivers/media/video/gspca/spca505.c
@@ -23,9 +23,6 @@
23 23
24#include "gspca.h" 24#include "gspca.h"
25 25
26#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
27static const char version[] = "2.1.7";
28
29MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 26MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
30MODULE_DESCRIPTION("GSPCA/SPCA505 USB Camera Driver"); 27MODULE_DESCRIPTION("GSPCA/SPCA505 USB Camera Driver");
31MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
@@ -938,7 +935,7 @@ static int __init sd_mod_init(void)
938{ 935{
939 if (usb_register(&sd_driver) < 0) 936 if (usb_register(&sd_driver) < 0)
940 return -1; 937 return -1;
941 PDEBUG(D_PROBE, "v%s registered", version); 938 PDEBUG(D_PROBE, "registered");
942 return 0; 939 return 0;
943} 940}
944static void __exit sd_mod_exit(void) 941static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c
index 143203c1fd9f..40e8541b2b89 100644
--- a/drivers/media/video/gspca/spca506.c
+++ b/drivers/media/video/gspca/spca506.c
@@ -25,9 +25,6 @@
25 25
26#include "gspca.h" 26#include "gspca.h"
27 27
28#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
29static const char version[] = "2.1.7";
30
31MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
32MODULE_DESCRIPTION("GSPCA/SPCA506 USB Camera Driver"); 29MODULE_DESCRIPTION("GSPCA/SPCA506 USB Camera Driver");
33MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
@@ -834,7 +831,7 @@ static int __init sd_mod_init(void)
834{ 831{
835 if (usb_register(&sd_driver) < 0) 832 if (usb_register(&sd_driver) < 0)
836 return -1; 833 return -1;
837 PDEBUG(D_PROBE, "v%s registered", version); 834 PDEBUG(D_PROBE, "registered");
838 return 0; 835 return 0;
839} 836}
840static void __exit sd_mod_exit(void) 837static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c
index d8cd93866a4a..362f645d08c6 100644
--- a/drivers/media/video/gspca/spca508.c
+++ b/drivers/media/video/gspca/spca508.c
@@ -22,9 +22,6 @@
22 22
23#include "gspca.h" 23#include "gspca.h"
24 24
25#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
26static const char version[] = "2.1.7";
27
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 25MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
29MODULE_DESCRIPTION("GSPCA/SPCA508 USB Camera Driver"); 26MODULE_DESCRIPTION("GSPCA/SPCA508 USB Camera Driver");
30MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
@@ -1778,7 +1775,7 @@ static int __init sd_mod_init(void)
1778{ 1775{
1779 if (usb_register(&sd_driver) < 0) 1776 if (usb_register(&sd_driver) < 0)
1780 return -1; 1777 return -1;
1781 PDEBUG(D_PROBE, "v%s registered", version); 1778 PDEBUG(D_PROBE, "registered");
1782 return 0; 1779 return 0;
1783} 1780}
1784static void __exit sd_mod_exit(void) 1781static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index b659bd0f788d..85c37f396aaf 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -24,9 +24,6 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SPCA561 USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/SPCA561 USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -1039,7 +1036,7 @@ static int __init sd_mod_init(void)
1039{ 1036{
1040 if (usb_register(&sd_driver) < 0) 1037 if (usb_register(&sd_driver) < 0)
1041 return -1; 1038 return -1;
1042 PDEBUG(D_PROBE, "v%s registered", version); 1039 PDEBUG(D_PROBE, "registered");
1043 return 0; 1040 return 0;
1044} 1041}
1045static void __exit sd_mod_exit(void) 1042static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c
index c78ee0d3e59b..90efde17b08b 100644
--- a/drivers/media/video/gspca/stk014.c
+++ b/drivers/media/video/gspca/stk014.c
@@ -23,9 +23,6 @@
23#include "gspca.h" 23#include "gspca.h"
24#include "jpeg.h" 24#include "jpeg.h"
25 25
26#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
27static const char version[] = "2.1.7";
28
29MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); 26MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
30MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver"); 27MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver");
31MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
@@ -576,7 +573,7 @@ static int __init sd_mod_init(void)
576{ 573{
577 if (usb_register(&sd_driver) < 0) 574 if (usb_register(&sd_driver) < 0)
578 return -1; 575 return -1;
579 info("v%s registered", version); 576 info("registered");
580 return 0; 577 return 0;
581} 578}
582static void __exit sd_mod_exit(void) 579static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index abd7bef9b3d1..53e20275f26d 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -24,9 +24,6 @@
24#include "gspca.h" 24#include "gspca.h"
25#include "jpeg.h" 25#include "jpeg.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 8)
28static const char version[] = "2.1.8";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SPCA5xx USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/SPCA5xx USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -1664,7 +1661,7 @@ static int __init sd_mod_init(void)
1664{ 1661{
1665 if (usb_register(&sd_driver) < 0) 1662 if (usb_register(&sd_driver) < 0)
1666 return -1; 1663 return -1;
1667 PDEBUG(D_PROBE, "v%s registered", version); 1664 PDEBUG(D_PROBE, "registered");
1668 return 0; 1665 return 0;
1669} 1666}
1670static void __exit sd_mod_exit(void) 1667static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c
index 00f47e463a05..fc1c62e5a2fd 100644
--- a/drivers/media/video/gspca/t613.c
+++ b/drivers/media/video/gspca/t613.c
@@ -1,12 +1,4 @@
1/* 1/*
2 *Notes: * t613 + tas5130A
3 * * Focus to light do not balance well as in win.
4 * Quality in win is not good, but its kinda better.
5 * * Fix some "extraneous bytes", most of apps will show the image anyway
6 * * Gamma table, is there, but its really doing something?
7 * * 7~8 Fps, its ok, max on win its 10.
8 * Costantino Leandro
9 *
10 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr> 2 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
11 * 3 *
12 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -22,16 +14,22 @@
22 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 *Notes: * t613 + tas5130A
19 * * Focus to light do not balance well as in win.
20 * Quality in win is not good, but its kinda better.
21 * * Fix some "extraneous bytes", most of apps will show the image anyway
22 * * Gamma table, is there, but its really doing something?
23 * * 7~8 Fps, its ok, max on win its 10.
24 * Costantino Leandro
25 */ 25 */
26 26
27#define MODULE_NAME "t613" 27#define MODULE_NAME "t613"
28
28#include "gspca.h" 29#include "gspca.h"
29#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
30static const char version[] = "2.1.7";
31 30
32#define MAX_GAMMA 0x10 /* 0 to 15 */ 31#define MAX_GAMMA 0x10 /* 0 to 15 */
33 32
34/* From LUVCVIEW */
35#define V4L2_CID_EFFECTS (V4L2_CID_PRIVATE_BASE + 3) 33#define V4L2_CID_EFFECTS (V4L2_CID_PRIVATE_BASE + 3)
36 34
37MODULE_AUTHOR("Leandro Costantino <le_costantino@pixartargentina.com.ar>"); 35MODULE_AUTHOR("Leandro Costantino <le_costantino@pixartargentina.com.ar>");
@@ -1025,7 +1023,7 @@ static int __init sd_mod_init(void)
1025{ 1023{
1026 if (usb_register(&sd_driver) < 0) 1024 if (usb_register(&sd_driver) < 0)
1027 return -1; 1025 return -1;
1028 PDEBUG(D_PROBE, "v%s registered", version); 1026 PDEBUG(D_PROBE, "registered");
1029 return 0; 1027 return 0;
1030} 1028}
1031static void __exit sd_mod_exit(void) 1029static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/tv8532.c b/drivers/media/video/gspca/tv8532.c
index 0b793899095f..cb2d9da2a224 100644
--- a/drivers/media/video/gspca/tv8532.c
+++ b/drivers/media/video/gspca/tv8532.c
@@ -22,9 +22,6 @@
22 22
23#include "gspca.h" 23#include "gspca.h"
24 24
25#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
26static const char version[] = "2.1.7";
27
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 25MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
29MODULE_DESCRIPTION("TV8532 USB Camera Driver"); 26MODULE_DESCRIPTION("TV8532 USB Camera Driver");
30MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
@@ -656,7 +653,7 @@ static int __init sd_mod_init(void)
656{ 653{
657 if (usb_register(&sd_driver) < 0) 654 if (usb_register(&sd_driver) < 0)
658 return -1; 655 return -1;
659 PDEBUG(D_PROBE, "v%s registered", version); 656 PDEBUG(D_PROBE, "registered");
660 return 0; 657 return 0;
661} 658}
662 659
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index fcf2c9e32573..e306ac420298 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -24,9 +24,6 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/VC032X USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/VC032X USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -1805,7 +1802,7 @@ static int __init sd_mod_init(void)
1805{ 1802{
1806 if (usb_register(&sd_driver) < 0) 1803 if (usb_register(&sd_driver) < 0)
1807 return -1; 1804 return -1;
1808 PDEBUG(D_PROBE, "v%s registered", version); 1805 PDEBUG(D_PROBE, "registered");
1809 return 0; 1806 return 0;
1810} 1807}
1811static void __exit sd_mod_exit(void) 1808static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index b761b11c5c6a..f8d6f1780a45 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -24,9 +24,6 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>, " 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>, "
31 "Serge A. Suchkov <Serge.A.S@tochka.ru>"); 28 "Serge A. Suchkov <Serge.A.S@tochka.ru>");
32MODULE_DESCRIPTION("GSPCA ZC03xx/VC3xx USB Camera Driver"); 29MODULE_DESCRIPTION("GSPCA ZC03xx/VC3xx USB Camera Driver");
@@ -49,7 +46,7 @@ struct sd {
49 __u8 sharpness; 46 __u8 sharpness;
50 47
51 char qindex; 48 char qindex;
52 char sensor; /* Type of image sensor chip */ 49 signed char sensor; /* Type of image sensor chip */
53/* !! values used in different tables */ 50/* !! values used in different tables */
54#define SENSOR_CS2102 0 51#define SENSOR_CS2102 0
55#define SENSOR_CS2102K 1 52#define SENSOR_CS2102K 1
@@ -2205,10 +2202,10 @@ static const struct usb_action hdcs2020xb_InitialScale[] = {
2205}; 2202};
2206static const struct usb_action hdcs2020b_50HZ[] = { 2203static const struct usb_action hdcs2020b_50HZ[] = {
2207 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ 2204 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
2208 {0xaa, 0x13, 0x0018}, /* 00,13,18,aa */ 2205 {0xaa, 0x13, 0x0018}, /* 00,13,18,aa */
2209 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ 2206 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */
2210 {0xaa, 0x0e, 0x0005}, /* 00,0e,05,aa */ 2207 {0xaa, 0x0e, 0x0005}, /* 00,0e,05,aa */
2211 {0xaa, 0x19, 0x001f}, /* 00,19,1f,aa */ 2208 {0xaa, 0x19, 0x001f}, /* 00,19,1f,aa */
2212 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */ 2209 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
2213 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */ 2210 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */
2214 {0xa0, 0x76, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,76,cc */ 2211 {0xa0, 0x76, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,76,cc */
@@ -2226,10 +2223,10 @@ static const struct usb_action hdcs2020b_50HZ[] = {
2226}; 2223};
2227static const struct usb_action hdcs2020b_60HZ[] = { 2224static const struct usb_action hdcs2020b_60HZ[] = {
2228 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ 2225 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
2229 {0xaa, 0x13, 0x0031}, /* 00,13,31,aa */ 2226 {0xaa, 0x13, 0x0031}, /* 00,13,31,aa */
2230 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ 2227 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */
2231 {0xaa, 0x0e, 0x0004}, /* 00,0e,04,aa */ 2228 {0xaa, 0x0e, 0x0004}, /* 00,0e,04,aa */
2232 {0xaa, 0x19, 0x00cd}, /* 00,19,cd,aa */ 2229 {0xaa, 0x19, 0x00cd}, /* 00,19,cd,aa */
2233 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */ 2230 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
2234 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */ 2231 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */
2235 {0xa0, 0x62, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,62,cc */ 2232 {0xa0, 0x62, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,62,cc */
@@ -2247,10 +2244,10 @@ static const struct usb_action hdcs2020b_60HZ[] = {
2247}; 2244};
2248static const struct usb_action hdcs2020b_NoFliker[] = { 2245static const struct usb_action hdcs2020b_NoFliker[] = {
2249 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ 2246 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
2250 {0xaa, 0x13, 0x0010}, /* 00,13,10,aa */ 2247 {0xaa, 0x13, 0x0010}, /* 00,13,10,aa */
2251 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ 2248 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */
2252 {0xaa, 0x0e, 0x0004}, /* 00,0e,04,aa */ 2249 {0xaa, 0x0e, 0x0004}, /* 00,0e,04,aa */
2253 {0xaa, 0x19, 0x0000}, /* 00,19,00,aa */ 2250 {0xaa, 0x19, 0x0000}, /* 00,19,00,aa */
2254 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */ 2251 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
2255 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */ 2252 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */
2256 {0xa0, 0x70, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,70,cc */ 2253 {0xa0, 0x70, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,70,cc */
@@ -4102,27 +4099,27 @@ static const struct usb_action pas106b_Initial_com[] = {
4102 4099
4103static const struct usb_action pas106b_Initial[] = { /* 176x144 */ 4100static const struct usb_action pas106b_Initial[] = { /* 176x144 */
4104/* JPEG control */ 4101/* JPEG control */
4105 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4102 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4106/* Sream and Sensor specific */ 4103/* Sream and Sensor specific */
4107 {0xa0, 0x0f, ZC3XX_R010_CMOSSENSORSELECT}, /* CMOSSensorSelect */ 4104 {0xa0, 0x0f, ZC3XX_R010_CMOSSENSORSELECT},
4108/* Picture size */ 4105/* Picture size */
4109 {0xa0, 0x00, ZC3XX_R003_FRAMEWIDTHHIGH}, /* FrameWidthHigh 00 */ 4106 {0xa0, 0x00, ZC3XX_R003_FRAMEWIDTHHIGH},
4110 {0xa0, 0xb0, ZC3XX_R004_FRAMEWIDTHLOW}, /* FrameWidthLow B0 */ 4107 {0xa0, 0xb0, ZC3XX_R004_FRAMEWIDTHLOW},
4111 {0xa0, 0x00, ZC3XX_R005_FRAMEHEIGHTHIGH}, /* FrameHeightHigh 00 */ 4108 {0xa0, 0x00, ZC3XX_R005_FRAMEHEIGHTHIGH},
4112 {0xa0, 0x90, ZC3XX_R006_FRAMEHEIGHTLOW}, /* FrameHightLow 90 */ 4109 {0xa0, 0x90, ZC3XX_R006_FRAMEHEIGHTLOW},
4113/* System */ 4110/* System */
4114 {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING}, /* SystemOperating */ 4111 {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING},
4115/* Sream and Sensor specific */ 4112/* Sream and Sensor specific */
4116 {0xa0, 0x03, ZC3XX_R012_VIDEOCONTROLFUNC}, /* VideoControlFunction */ 4113 {0xa0, 0x03, ZC3XX_R012_VIDEOCONTROLFUNC},
4117 {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC}, /* VideoControlFunction */ 4114 {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC},
4118/* Sensor Interface */ 4115/* Sensor Interface */
4119 {0xa0, 0x08, ZC3XX_R08D_COMPABILITYMODE}, /* Compatibily Mode */ 4116 {0xa0, 0x08, ZC3XX_R08D_COMPABILITYMODE},
4120/* Window inside sensor array */ 4117/* Window inside sensor array */
4121 {0xa0, 0x03, ZC3XX_R09A_WINXSTARTLOW}, /* WinXStartLow */ 4118 {0xa0, 0x03, ZC3XX_R09A_WINXSTARTLOW},
4122 {0xa0, 0x00, ZC3XX_R11A_FIRSTYLOW}, /* FirstYLow */ 4119 {0xa0, 0x00, ZC3XX_R11A_FIRSTYLOW},
4123 {0xa0, 0x03, ZC3XX_R11C_FIRSTXLOW}, /* FirstxLow */ 4120 {0xa0, 0x03, ZC3XX_R11C_FIRSTXLOW},
4124 {0xa0, 0x28, ZC3XX_R09C_WINHEIGHTLOW}, /* WinHeightLow */ 4121 {0xa0, 0x28, ZC3XX_R09C_WINHEIGHTLOW},
4125 {0xa0, 0x68, ZC3XX_R09E_WINWIDTHLOW}, /* WinWidthLow */ 4122 {0xa0, 0x68, ZC3XX_R09E_WINWIDTHLOW},
4126/* Init the sensor */ 4123/* Init the sensor */
4127 {0xaa, 0x02, 0x0004}, 4124 {0xaa, 0x02, 0x0004},
4128 {0xaa, 0x08, 0x0000}, 4125 {0xaa, 0x08, 0x0000},
@@ -4135,40 +4132,40 @@ static const struct usb_action pas106b_Initial[] = { /* 176x144 */
4135 {0xaa, 0x14, 0x0081}, 4132 {0xaa, 0x14, 0x0081},
4136 4133
4137/* Other registors */ 4134/* Other registors */
4138 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, /* SensorCorrection */ 4135 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION},
4139/* Frame retreiving */ 4136/* Frame retreiving */
4140 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* AutoAdjustFPS */ 4137 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},
4141/* Gains */ 4138/* Gains */
4142 {0xa0, 0xa0, ZC3XX_R1A8_DIGITALGAIN}, /* DigitalGain */ 4139 {0xa0, 0xa0, ZC3XX_R1A8_DIGITALGAIN},
4143/* Unknown */ 4140/* Unknown */
4144 {0xa0, 0x00, 0x01ad}, 4141 {0xa0, 0x00, 0x01ad},
4145/* Sharpness */ 4142/* Sharpness */
4146 {0xa0, 0x03, ZC3XX_R1C5_SHARPNESSMODE}, /* SharpnessMode */ 4143 {0xa0, 0x03, ZC3XX_R1C5_SHARPNESSMODE},
4147 {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05}, /* Sharpness05 */ 4144 {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05},
4148/* Other registors */ 4145/* Other registors */
4149 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE}, /* OperationMode */ 4146 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE},
4150/* Auto exposure and white balance */ 4147/* Auto exposure and white balance */
4151 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS}, /* AWBStatus */ 4148 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS},
4152/*Dead pixels */ 4149/*Dead pixels */
4153 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE}, /* DeadPixelsMode */ 4150 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
4154/* EEPROM */ 4151/* EEPROM */
4155 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS}, /* EEPROMAccess */ 4152 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
4156/* JPEG control */ 4153/* JPEG control */
4157 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4154 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4158 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00}, /* sharpness+ */ 4155 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00},
4159 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05}, /* sharpness- */ 4156 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05},
4160/* Other registers */ 4157/* Other registers */
4161 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE}, /* OperationMode */ 4158 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE},
4162/* Auto exposure and white balance */ 4159/* Auto exposure and white balance */
4163 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS}, /* AWBStatus */ 4160 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS},
4164/*Dead pixels */ 4161/*Dead pixels */
4165 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE}, /* DeadPixelsMode */ 4162 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
4166/* EEPROM */ 4163/* EEPROM */
4167 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS}, /* EEPROMAccess */ 4164 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
4168/* JPEG control */ 4165/* JPEG control */
4169 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4166 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4170 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00}, /* sharpness+ */ 4167 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00},
4171 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05}, /* sharpness- */ 4168 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05},
4172 4169
4173 {0xa0, 0x58, ZC3XX_R10A_RGB00}, /* matrix */ 4170 {0xa0, 0x58, ZC3XX_R10A_RGB00}, /* matrix */
4174 {0xa0, 0xf4, ZC3XX_R10B_RGB01}, 4171 {0xa0, 0xf4, ZC3XX_R10B_RGB01},
@@ -4180,67 +4177,67 @@ static const struct usb_action pas106b_Initial[] = { /* 176x144 */
4180 {0xa0, 0xf4, ZC3XX_R111_RGB21}, 4177 {0xa0, 0xf4, ZC3XX_R111_RGB21},
4181 {0xa0, 0x58, ZC3XX_R112_RGB22}, 4178 {0xa0, 0x58, ZC3XX_R112_RGB22},
4182/* Auto correction */ 4179/* Auto correction */
4183 {0xa0, 0x03, ZC3XX_R181_WINXSTART}, /* WinXstart */ 4180 {0xa0, 0x03, ZC3XX_R181_WINXSTART},
4184 {0xa0, 0x08, ZC3XX_R182_WINXWIDTH}, /* WinXWidth */ 4181 {0xa0, 0x08, ZC3XX_R182_WINXWIDTH},
4185 {0xa0, 0x16, ZC3XX_R183_WINXCENTER}, /* WinXCenter */ 4182 {0xa0, 0x16, ZC3XX_R183_WINXCENTER},
4186 {0xa0, 0x03, ZC3XX_R184_WINYSTART}, /* WinYStart */ 4183 {0xa0, 0x03, ZC3XX_R184_WINYSTART},
4187 {0xa0, 0x05, ZC3XX_R185_WINYWIDTH}, /* WinYWidth */ 4184 {0xa0, 0x05, ZC3XX_R185_WINYWIDTH},
4188 {0xa0, 0x14, ZC3XX_R186_WINYCENTER}, /* WinYCenter */ 4185 {0xa0, 0x14, ZC3XX_R186_WINYCENTER},
4189 {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4186 {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE},
4190 4187
4191/* Auto exposure and white balance */ 4188/* Auto exposure and white balance */
4192 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* ExposureLimitHigh */ 4189 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},
4193 {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID}, /* ExposureLimitMid */ 4190 {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID},
4194 {0xa0, 0xb1, ZC3XX_R192_EXPOSURELIMITLOW}, /* ExposureLimitLow */ 4191 {0xa0, 0xb1, ZC3XX_R192_EXPOSURELIMITLOW},
4195 {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH}, /* AntiFlickerHigh */ 4192 {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},
4196 {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID}, /* AntiFlickerLow */ 4193 {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},
4197 {0xa0, 0x87, ZC3XX_R197_ANTIFLICKERLOW}, /* AntiFlickerLow */ 4194 {0xa0, 0x87, ZC3XX_R197_ANTIFLICKERLOW},
4198 {0xa0, 0x0c, ZC3XX_R18C_AEFREEZE}, /* AEBFreeze */ 4195 {0xa0, 0x0c, ZC3XX_R18C_AEFREEZE},
4199 {0xa0, 0x18, ZC3XX_R18F_AEUNFREEZE}, /* AEBUnfreeze */ 4196 {0xa0, 0x18, ZC3XX_R18F_AEUNFREEZE},
4200/* sensor on */ 4197/* sensor on */
4201 {0xaa, 0x07, 0x00b1}, 4198 {0xaa, 0x07, 0x00b1},
4202 {0xaa, 0x05, 0x0003}, 4199 {0xaa, 0x05, 0x0003},
4203 {0xaa, 0x04, 0x0001}, 4200 {0xaa, 0x04, 0x0001},
4204 {0xaa, 0x03, 0x003b}, 4201 {0xaa, 0x03, 0x003b},
4205/* Gains */ 4202/* Gains */
4206 {0xa0, 0x20, ZC3XX_R1A9_DIGITALLIMITDIFF}, /* DigitalLimitDiff */ 4203 {0xa0, 0x20, ZC3XX_R1A9_DIGITALLIMITDIFF},
4207 {0xa0, 0x26, ZC3XX_R1AA_DIGITALGAINSTEP}, /* DigitalGainStep */ 4204 {0xa0, 0x26, ZC3XX_R1AA_DIGITALGAINSTEP},
4208 {0xa0, 0xa0, ZC3XX_R11D_GLOBALGAIN}, /* GlobalGain */ 4205 {0xa0, 0xa0, ZC3XX_R11D_GLOBALGAIN},
4209 {0xa0, 0x60, ZC3XX_R11D_GLOBALGAIN}, /* GlobalGain */ 4206 {0xa0, 0x60, ZC3XX_R11D_GLOBALGAIN},
4210/* Auto correction */ 4207/* Auto correction */
4211 {0xa0, 0x40, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4208 {0xa0, 0x40, ZC3XX_R180_AUTOCORRECTENABLE},
4212 {0xa1, 0x01, 0x0180}, /* AutoCorrectEnable */ 4209 {0xa1, 0x01, 0x0180}, /* AutoCorrectEnable */
4213 {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4210 {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE},
4214/* Gains */ 4211/* Gains */
4215 {0xa0, 0x40, ZC3XX_R116_RGAIN}, /* RGain */ 4212 {0xa0, 0x40, ZC3XX_R116_RGAIN},
4216 {0xa0, 0x40, ZC3XX_R117_GGAIN}, /* GGain */ 4213 {0xa0, 0x40, ZC3XX_R117_GGAIN},
4217 {0xa0, 0x40, ZC3XX_R118_BGAIN}, /* BGain */ 4214 {0xa0, 0x40, ZC3XX_R118_BGAIN},
4218 {} 4215 {}
4219}; 4216};
4220 4217
4221static const struct usb_action pas106b_InitialScale[] = { /* 352x288 */ 4218static const struct usb_action pas106b_InitialScale[] = { /* 352x288 */
4222/* JPEG control */ 4219/* JPEG control */
4223 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4220 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4224/* Sream and Sensor specific */ 4221/* Sream and Sensor specific */
4225 {0xa0, 0x0f, ZC3XX_R010_CMOSSENSORSELECT}, /* CMOSSensorSelect */ 4222 {0xa0, 0x0f, ZC3XX_R010_CMOSSENSORSELECT},
4226/* Picture size */ 4223/* Picture size */
4227 {0xa0, 0x01, ZC3XX_R003_FRAMEWIDTHHIGH}, /* FrameWidthHigh */ 4224 {0xa0, 0x01, ZC3XX_R003_FRAMEWIDTHHIGH},
4228 {0xa0, 0x60, ZC3XX_R004_FRAMEWIDTHLOW}, /* FrameWidthLow */ 4225 {0xa0, 0x60, ZC3XX_R004_FRAMEWIDTHLOW},
4229 {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH}, /* FrameHeightHigh */ 4226 {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH},
4230 {0xa0, 0x20, ZC3XX_R006_FRAMEHEIGHTLOW}, /* FrameHightLow */ 4227 {0xa0, 0x20, ZC3XX_R006_FRAMEHEIGHTLOW},
4231/* System */ 4228/* System */
4232 {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING}, /* SystemOperating */ 4229 {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING},
4233/* Sream and Sensor specific */ 4230/* Sream and Sensor specific */
4234 {0xa0, 0x03, ZC3XX_R012_VIDEOCONTROLFUNC}, /* VideoControlFunction */ 4231 {0xa0, 0x03, ZC3XX_R012_VIDEOCONTROLFUNC},
4235 {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC}, /* VideoControlFunction */ 4232 {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC},
4236/* Sensor Interface */ 4233/* Sensor Interface */
4237 {0xa0, 0x08, ZC3XX_R08D_COMPABILITYMODE}, /* Compatibily Mode */ 4234 {0xa0, 0x08, ZC3XX_R08D_COMPABILITYMODE},
4238/* Window inside sensor array */ 4235/* Window inside sensor array */
4239 {0xa0, 0x03, ZC3XX_R09A_WINXSTARTLOW}, /* WinXStartLow */ 4236 {0xa0, 0x03, ZC3XX_R09A_WINXSTARTLOW},
4240 {0xa0, 0x00, ZC3XX_R11A_FIRSTYLOW}, /* FirstYLow */ 4237 {0xa0, 0x00, ZC3XX_R11A_FIRSTYLOW},
4241 {0xa0, 0x03, ZC3XX_R11C_FIRSTXLOW}, /* FirstxLow */ 4238 {0xa0, 0x03, ZC3XX_R11C_FIRSTXLOW},
4242 {0xa0, 0x28, ZC3XX_R09C_WINHEIGHTLOW}, /* WinHeightLow */ 4239 {0xa0, 0x28, ZC3XX_R09C_WINHEIGHTLOW},
4243 {0xa0, 0x68, ZC3XX_R09E_WINWIDTHLOW}, /* WinWidthLow */ 4240 {0xa0, 0x68, ZC3XX_R09E_WINWIDTHLOW},
4244/* Init the sensor */ 4241/* Init the sensor */
4245 {0xaa, 0x02, 0x0004}, 4242 {0xaa, 0x02, 0x0004},
4246 {0xaa, 0x08, 0x0000}, 4243 {0xaa, 0x08, 0x0000},
@@ -4253,41 +4250,41 @@ static const struct usb_action pas106b_InitialScale[] = { /* 352x288 */
4253 {0xaa, 0x14, 0x0081}, 4250 {0xaa, 0x14, 0x0081},
4254 4251
4255/* Other registors */ 4252/* Other registors */
4256 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, /* SensorCorrection */ 4253 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION},
4257/* Frame retreiving */ 4254/* Frame retreiving */
4258 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* AutoAdjustFPS */ 4255 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},
4259/* Gains */ 4256/* Gains */
4260 {0xa0, 0xa0, ZC3XX_R1A8_DIGITALGAIN}, /* DigitalGain */ 4257 {0xa0, 0xa0, ZC3XX_R1A8_DIGITALGAIN},
4261/* Unknown */ 4258/* Unknown */
4262 {0xa0, 0x00, 0x01ad}, 4259 {0xa0, 0x00, 0x01ad},
4263/* Sharpness */ 4260/* Sharpness */
4264 {0xa0, 0x03, ZC3XX_R1C5_SHARPNESSMODE}, /* SharpnessMode */ 4261 {0xa0, 0x03, ZC3XX_R1C5_SHARPNESSMODE},
4265 {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05}, /* Sharpness05 */ 4262 {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05},
4266/* Other registors */ 4263/* Other registors */
4267 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE}, /* OperationMode */ 4264 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE},
4268/* Auto exposure and white balance */ 4265/* Auto exposure and white balance */
4269 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS}, /* AWBStatus */ 4266 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS},
4270 {0xa0, 0x80, ZC3XX_R18D_YTARGET}, /* ????????? */ 4267 {0xa0, 0x80, ZC3XX_R18D_YTARGET},
4271/*Dead pixels */ 4268/*Dead pixels */
4272 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE}, /* DeadPixelsMode */ 4269 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
4273/* EEPROM */ 4270/* EEPROM */
4274 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS}, /* EEPROMAccess */ 4271 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
4275/* JPEG control */ 4272/* JPEG control */
4276 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4273 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4277 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00}, /* sharpness+ */ 4274 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00},
4278 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05}, /* sharpness- */ 4275 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05},
4279/* Other registers */ 4276/* Other registers */
4280 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE}, /* OperationMode */ 4277 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE},
4281/* Auto exposure and white balance */ 4278/* Auto exposure and white balance */
4282 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS}, /* AWBStatus */ 4279 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS},
4283/*Dead pixels */ 4280/*Dead pixels */
4284 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE}, /* DeadPixelsMode */ 4281 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
4285/* EEPROM */ 4282/* EEPROM */
4286 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS}, /* EEPROMAccess */ 4283 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
4287/* JPEG control */ 4284/* JPEG control */
4288 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4285 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4289 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00}, /* sharpness+ */ 4286 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00},
4290 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05}, /* sharpness- */ 4287 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05},
4291 4288
4292 {0xa0, 0x58, ZC3XX_R10A_RGB00}, /* matrix */ 4289 {0xa0, 0x58, ZC3XX_R10A_RGB00}, /* matrix */
4293 {0xa0, 0xf4, ZC3XX_R10B_RGB01}, 4290 {0xa0, 0xf4, ZC3XX_R10B_RGB01},
@@ -4299,43 +4296,43 @@ static const struct usb_action pas106b_InitialScale[] = { /* 352x288 */
4299 {0xa0, 0xf4, ZC3XX_R111_RGB21}, 4296 {0xa0, 0xf4, ZC3XX_R111_RGB21},
4300 {0xa0, 0x58, ZC3XX_R112_RGB22}, 4297 {0xa0, 0x58, ZC3XX_R112_RGB22},
4301/* Auto correction */ 4298/* Auto correction */
4302 {0xa0, 0x03, ZC3XX_R181_WINXSTART}, /* WinXstart */ 4299 {0xa0, 0x03, ZC3XX_R181_WINXSTART},
4303 {0xa0, 0x08, ZC3XX_R182_WINXWIDTH}, /* WinXWidth */ 4300 {0xa0, 0x08, ZC3XX_R182_WINXWIDTH},
4304 {0xa0, 0x16, ZC3XX_R183_WINXCENTER}, /* WinXCenter */ 4301 {0xa0, 0x16, ZC3XX_R183_WINXCENTER},
4305 {0xa0, 0x03, ZC3XX_R184_WINYSTART}, /* WinYStart */ 4302 {0xa0, 0x03, ZC3XX_R184_WINYSTART},
4306 {0xa0, 0x05, ZC3XX_R185_WINYWIDTH}, /* WinYWidth */ 4303 {0xa0, 0x05, ZC3XX_R185_WINYWIDTH},
4307 {0xa0, 0x14, ZC3XX_R186_WINYCENTER}, /* WinYCenter */ 4304 {0xa0, 0x14, ZC3XX_R186_WINYCENTER},
4308 {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4305 {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE},
4309 4306
4310/* Auto exposure and white balance */ 4307/* Auto exposure and white balance */
4311 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* ExposureLimitHigh 0 */ 4308 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},
4312 {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID}, /* ExposureLimitMid */ 4309 {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID},
4313 {0xa0, 0xb1, ZC3XX_R192_EXPOSURELIMITLOW}, /* ExposureLimitLow 0xb1 */ 4310 {0xa0, 0xb1, ZC3XX_R192_EXPOSURELIMITLOW},
4314 4311
4315 {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH}, /* AntiFlickerHigh 0x00 */ 4312 {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},
4316 {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID}, /* AntiFlickerLow 0x00 */ 4313 {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},
4317 {0xa0, 0x87, ZC3XX_R197_ANTIFLICKERLOW}, /* AntiFlickerLow 0x87 */ 4314 {0xa0, 0x87, ZC3XX_R197_ANTIFLICKERLOW},
4318 4315
4319 {0xa0, 0x10, ZC3XX_R18C_AEFREEZE}, /* AEBFreeze 0x10 0x0c */ 4316 {0xa0, 0x10, ZC3XX_R18C_AEFREEZE},
4320 {0xa0, 0x20, ZC3XX_R18F_AEUNFREEZE}, /* AEBUnfreeze 0x30 0x18 */ 4317 {0xa0, 0x20, ZC3XX_R18F_AEUNFREEZE},
4321/* sensor on */ 4318/* sensor on */
4322 {0xaa, 0x07, 0x00b1}, 4319 {0xaa, 0x07, 0x00b1},
4323 {0xaa, 0x05, 0x0003}, 4320 {0xaa, 0x05, 0x0003},
4324 {0xaa, 0x04, 0x0001}, 4321 {0xaa, 0x04, 0x0001},
4325 {0xaa, 0x03, 0x003b}, 4322 {0xaa, 0x03, 0x003b},
4326/* Gains */ 4323/* Gains */
4327 {0xa0, 0x20, ZC3XX_R1A9_DIGITALLIMITDIFF}, /* DigitalLimitDiff */ 4324 {0xa0, 0x20, ZC3XX_R1A9_DIGITALLIMITDIFF},
4328 {0xa0, 0x26, ZC3XX_R1AA_DIGITALGAINSTEP}, /* DigitalGainStep */ 4325 {0xa0, 0x26, ZC3XX_R1AA_DIGITALGAINSTEP},
4329 {0xa0, 0xa0, ZC3XX_R11D_GLOBALGAIN}, /* GlobalGain */ 4326 {0xa0, 0xa0, ZC3XX_R11D_GLOBALGAIN},
4330 {0xa0, 0x60, ZC3XX_R11D_GLOBALGAIN}, /* GlobalGain */ 4327 {0xa0, 0x60, ZC3XX_R11D_GLOBALGAIN},
4331/* Auto correction */ 4328/* Auto correction */
4332 {0xa0, 0x40, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4329 {0xa0, 0x40, ZC3XX_R180_AUTOCORRECTENABLE},
4333 {0xa1, 0x01, 0x0180}, /* AutoCorrectEnable */ 4330 {0xa1, 0x01, 0x0180}, /* AutoCorrectEnable */
4334 {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4331 {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE},
4335/* Gains */ 4332/* Gains */
4336 {0xa0, 0x40, ZC3XX_R116_RGAIN}, /* RGain */ 4333 {0xa0, 0x40, ZC3XX_R116_RGAIN},
4337 {0xa0, 0x40, ZC3XX_R117_GGAIN}, /* GGain */ 4334 {0xa0, 0x40, ZC3XX_R117_GGAIN},
4338 {0xa0, 0x40, ZC3XX_R118_BGAIN}, /* BGain */ 4335 {0xa0, 0x40, ZC3XX_R118_BGAIN},
4339 4336
4340 {0xa0, 0x00, 0x0007}, /* AutoCorrectEnable */ 4337 {0xa0, 0x00, 0x0007}, /* AutoCorrectEnable */
4341 {0xa0, 0xff, ZC3XX_R018_FRAMELOST}, /* Frame adjust */ 4338 {0xa0, 0xff, ZC3XX_R018_FRAMELOST}, /* Frame adjust */
@@ -4459,8 +4456,8 @@ static const struct usb_action pb03303x_Initial[] = {
4459 {0xa0, 0x50, ZC3XX_R112_RGB22}, 4456 {0xa0, 0x50, ZC3XX_R112_RGB22},
4460 4457
4461 {0xa1, 0x01, 0x0008}, 4458 {0xa1, 0x01, 0x0008},
4462 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* clock ? */ 4459 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4463 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00}, /* sharpness+ */ 4460 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00},
4464 {0xa1, 0x01, 0x01c8}, 4461 {0xa1, 0x01, 0x01c8},
4465 {0xa1, 0x01, 0x01c9}, 4462 {0xa1, 0x01, 0x01c9},
4466 {0xa1, 0x01, 0x01ca}, 4463 {0xa1, 0x01, 0x01ca},
@@ -5984,7 +5981,7 @@ static const struct usb_action tas5130c_vf0250_Initial[] = {
5984 {0xaa, 0x1b, 0x0000}, /* 00,1b,00,aa, */ 5981 {0xaa, 0x1b, 0x0000}, /* 00,1b,00,aa, */
5985 {0xaa, 0x13, 0x0002}, /* 00,13,02,aa, */ 5982 {0xaa, 0x13, 0x0002}, /* 00,13,02,aa, */
5986 {0xaa, 0x15, 0x0004}, /* 00,15,04,aa */ 5983 {0xaa, 0x15, 0x0004}, /* 00,15,04,aa */
5987 {0xaa, 0x01, 0x0000}, 5984/*?? {0xaa, 0x01, 0x0000}, */
5988 {0xaa, 0x01, 0x0000}, 5985 {0xaa, 0x01, 0x0000},
5989 {0xaa, 0x1a, 0x0000}, /* 00,1a,00,aa, */ 5986 {0xaa, 0x1a, 0x0000}, /* 00,1a,00,aa, */
5990 {0xaa, 0x1c, 0x0017}, /* 00,1c,17,aa, */ 5987 {0xaa, 0x1c, 0x0017}, /* 00,1c,17,aa, */
@@ -6000,8 +5997,8 @@ static const struct usb_action tas5130c_vf0250_Initial[] = {
6000 {0xaa, 0x0f, 0x00a0}, /* 00,0f,a0,aa, */ 5997 {0xaa, 0x0f, 0x00a0}, /* 00,0f,a0,aa, */
6001 {0xaa, 0x10, 0x0000}, /* 00,10,00,aa, */ 5998 {0xaa, 0x10, 0x0000}, /* 00,10,00,aa, */
6002 {0xaa, 0x11, 0x00a0}, /* 00,11,a0,aa, */ 5999 {0xaa, 0x11, 0x00a0}, /* 00,11,a0,aa, */
6003 {0xa0, 0x00, 0x0039}, 6000/*?? {0xa0, 0x00, 0x0039},
6004 {0xa1, 0x01, 0x0037}, 6001 {0xa1, 0x01, 0x0037}, */
6005 {0xaa, 0x16, 0x0001}, /* 00,16,01,aa, */ 6002 {0xaa, 0x16, 0x0001}, /* 00,16,01,aa, */
6006 {0xaa, 0x17, 0x00e8}, /* 00,17,e6,aa, (e6 -> e8) */ 6003 {0xaa, 0x17, 0x00e8}, /* 00,17,e6,aa, (e6 -> e8) */
6007 {0xaa, 0x18, 0x0002}, /* 00,18,02,aa, */ 6004 {0xaa, 0x18, 0x0002}, /* 00,18,02,aa, */
@@ -6272,7 +6269,7 @@ static void reg_w(struct usb_device *dev,
6272 __u8 value, 6269 __u8 value,
6273 __u16 index) 6270 __u16 index)
6274{ 6271{
6275 PDEBUG(D_USBO, "reg w %02x -> [%04x]", value, index); 6272 PDEBUG(D_USBO, "reg w [%04x] = %02x", index, value);
6276 reg_w_i(dev, value, index); 6273 reg_w_i(dev, value, index);
6277} 6274}
6278 6275
@@ -6280,17 +6277,17 @@ static __u16 i2c_read(struct gspca_dev *gspca_dev,
6280 __u8 reg) 6277 __u8 reg)
6281{ 6278{
6282 __u8 retbyte; 6279 __u8 retbyte;
6283 __u8 retval[2]; 6280 __u16 retval;
6284 6281
6285 reg_w_i(gspca_dev->dev, reg, 0x92); 6282 reg_w_i(gspca_dev->dev, reg, 0x92);
6286 reg_w_i(gspca_dev->dev, 0x02, 0x90); /* <- read command */ 6283 reg_w_i(gspca_dev->dev, 0x02, 0x90); /* <- read command */
6287 msleep(25); 6284 msleep(25);
6288 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */ 6285 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */
6289 retval[0] = reg_r_i(gspca_dev, 0x0095); /* read Lowbyte */ 6286 retval = reg_r_i(gspca_dev, 0x0095); /* read Lowbyte */
6290 retval[1] = reg_r_i(gspca_dev, 0x0096); /* read Hightbyte */ 6287 retval |= reg_r_i(gspca_dev, 0x0096) << 8; /* read Hightbyte */
6291 PDEBUG(D_USBO, "i2c r [%02x] -> (%02x) %02x%02x", 6288 PDEBUG(D_USBO, "i2c r [%02x] -> %04x (%02x)",
6292 reg, retbyte, retval[1], retval[0]); 6289 reg, retval, retbyte);
6293 return (retval[1] << 8) | retval[0]; 6290 return retval;
6294} 6291}
6295 6292
6296static __u8 i2c_write(struct gspca_dev *gspca_dev, 6293static __u8 i2c_write(struct gspca_dev *gspca_dev,
@@ -6306,7 +6303,7 @@ static __u8 i2c_write(struct gspca_dev *gspca_dev,
6306 reg_w_i(gspca_dev->dev, 0x01, 0x90); /* <- write command */ 6303 reg_w_i(gspca_dev->dev, 0x01, 0x90); /* <- write command */
6307 msleep(5); 6304 msleep(5);
6308 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */ 6305 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */
6309 PDEBUG(D_USBO, "i2c w [%02x] %02x%02x (%02x)", 6306 PDEBUG(D_USBO, "i2c w [%02x] = %02x%02x (%02x)",
6310 reg, valH, valL, retbyte); 6307 reg, valH, valL, retbyte);
6311 return retbyte; 6308 return retbyte;
6312} 6309}
@@ -6349,6 +6346,8 @@ static void setmatrix(struct gspca_dev *gspca_dev)
6349 {0x58, 0xf4, 0xf4, 0xf4, 0x58, 0xf4, 0xf4, 0xf4, 0x58}; 6346 {0x58, 0xf4, 0xf4, 0xf4, 0x58, 0xf4, 0xf4, 0xf4, 0x58};
6350 static const __u8 po2030_matrix[9] = 6347 static const __u8 po2030_matrix[9] =
6351 {0x60, 0xf0, 0xf0, 0xf0, 0x60, 0xf0, 0xf0, 0xf0, 0x60}; 6348 {0x60, 0xf0, 0xf0, 0xf0, 0x60, 0xf0, 0xf0, 0xf0, 0x60};
6349 static const __u8 vf0250_matrix[9] =
6350 {0x7b, 0xea, 0xea, 0xea, 0x7b, 0xea, 0xea, 0xea, 0x7b};
6352 6351
6353 switch (sd->sensor) { 6352 switch (sd->sensor) {
6354 case SENSOR_GC0305: 6353 case SENSOR_GC0305:
@@ -6363,8 +6362,9 @@ static void setmatrix(struct gspca_dev *gspca_dev)
6363 case SENSOR_PO2030: 6362 case SENSOR_PO2030:
6364 matrix = po2030_matrix; 6363 matrix = po2030_matrix;
6365 break; 6364 break;
6366 case SENSOR_TAS5130C_VF0250: /* no matrix? */ 6365 case SENSOR_TAS5130C_VF0250:
6367 return; 6366 matrix = vf0250_matrix;
6367 break;
6368 default: /* matrix already loaded */ 6368 default: /* matrix already loaded */
6369 return; 6369 return;
6370 } 6370 }
@@ -6744,7 +6744,7 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
6744 return 0x04; /* CS2102 */ 6744 return 0x04; /* CS2102 */
6745 6745
6746 start_2wr_probe(dev, 0x06); /* OmniVision */ 6746 start_2wr_probe(dev, 0x06); /* OmniVision */
6747 reg_w(dev, 0x08, 0x8d); 6747 reg_w(dev, 0x08, 0x008d);
6748 i2c_write(gspca_dev, 0x11, 0xaa, 0x00); 6748 i2c_write(gspca_dev, 0x11, 0xaa, 0x00);
6749 retbyte = i2c_read(gspca_dev, 0x11); 6749 retbyte = i2c_read(gspca_dev, 0x11);
6750 if (retbyte != 0) { 6750 if (retbyte != 0) {
@@ -6778,7 +6778,7 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
6778 return 0x0c; /* ICM105A */ 6778 return 0x0c; /* ICM105A */
6779 6779
6780 start_2wr_probe(dev, 0x0e); /* PAS202BCB */ 6780 start_2wr_probe(dev, 0x0e); /* PAS202BCB */
6781 reg_w(dev, 0x08, 0x8d); 6781 reg_w(dev, 0x08, 0x008d);
6782 i2c_write(gspca_dev, 0x03, 0xaa, 0x00); 6782 i2c_write(gspca_dev, 0x03, 0xaa, 0x00);
6783 msleep(500); 6783 msleep(500);
6784 retbyte = i2c_read(gspca_dev, 0x03); 6784 retbyte = i2c_read(gspca_dev, 0x03);
@@ -6830,7 +6830,6 @@ static const struct sensor_by_chipset_revision chipset_revision_sensor[] = {
6830 {0x8001, 0x13}, 6830 {0x8001, 0x13},
6831 {0x8000, 0x14}, /* CS2102K */ 6831 {0x8000, 0x14}, /* CS2102K */
6832 {0x8400, 0x15}, /* TAS5130K */ 6832 {0x8400, 0x15}, /* TAS5130K */
6833 {0, 0}
6834}; 6833};
6835 6834
6836static int vga_3wr_probe(struct gspca_dev *gspca_dev) 6835static int vga_3wr_probe(struct gspca_dev *gspca_dev)
@@ -6843,7 +6842,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6843 6842
6844/*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/ 6843/*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/
6845 reg_w(dev, 0x02, 0x0010); 6844 reg_w(dev, 0x02, 0x0010);
6846 reg_r(gspca_dev, 0x10); 6845 reg_r(gspca_dev, 0x0010);
6847 reg_w(dev, 0x01, 0x0000); 6846 reg_w(dev, 0x01, 0x0000);
6848 reg_w(dev, 0x00, 0x0010); 6847 reg_w(dev, 0x00, 0x0010);
6849 reg_w(dev, 0x01, 0x0001); 6848 reg_w(dev, 0x01, 0x0001);
@@ -6869,17 +6868,15 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6869 PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", checkword); 6868 PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", checkword);
6870 reg_r(gspca_dev, 0x0010); 6869 reg_r(gspca_dev, 0x0010);
6871 /* this is tested only once anyway */ 6870 /* this is tested only once anyway */
6872 i = 0; 6871 for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) {
6873 while (chipset_revision_sensor[i].revision) {
6874 if (chipset_revision_sensor[i].revision == checkword) { 6872 if (chipset_revision_sensor[i].revision == checkword) {
6875 sd->chip_revision = checkword; 6873 sd->chip_revision = checkword;
6876 send_unknown(dev, SENSOR_PB0330); 6874 send_unknown(dev, SENSOR_PB0330);
6877 return chipset_revision_sensor[i].internal_sensor_id; 6875 return chipset_revision_sensor[i].internal_sensor_id;
6878 } 6876 }
6879 i++;
6880 } 6877 }
6881 6878
6882 reg_w(dev, 0x01, 0x0000); 6879 reg_w(dev, 0x01, 0x0000); /* check ?? */
6883 reg_w(dev, 0x01, 0x0001); 6880 reg_w(dev, 0x01, 0x0001);
6884 reg_w(dev, 0xdd, 0x008b); 6881 reg_w(dev, 0xdd, 0x008b);
6885 reg_w(dev, 0x0a, 0x0010); 6882 reg_w(dev, 0x0a, 0x0010);
@@ -6901,8 +6898,11 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6901 retbyte = i2c_read(gspca_dev, 0x00); 6898 retbyte = i2c_read(gspca_dev, 0x00);
6902 if (retbyte != 0) { 6899 if (retbyte != 0) {
6903 PDEBUG(D_PROBE, "probe 3wr vga type %02x", retbyte); 6900 PDEBUG(D_PROBE, "probe 3wr vga type %02x", retbyte);
6904 send_unknown(dev, SENSOR_GC0305); 6901 if (retbyte == 0x11) /* VF0250 */
6905 return retbyte; /* 0x29 = gc0305 - should continue? */ 6902 return 0x0250;
6903 if (retbyte == 0x29) /* gc0305 */
6904 send_unknown(dev, SENSOR_GC0305);
6905 return retbyte;
6906 } 6906 }
6907 6907
6908 reg_w(dev, 0x01, 0x0000); /* check OmniVision */ 6908 reg_w(dev, 0x01, 0x0000); /* check OmniVision */
@@ -6918,18 +6918,18 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6918 return 0x06; /* OmniVision confirm ? */ 6918 return 0x06; /* OmniVision confirm ? */
6919 } 6919 }
6920 6920
6921 reg_w(dev, 0x01, 0x00); 6921 reg_w(dev, 0x01, 0x0000);
6922 reg_w(dev, 0x00, 0x02); 6922 reg_w(dev, 0x00, 0x0002);
6923 reg_w(dev, 0x01, 0x10); 6923 reg_w(dev, 0x01, 0x0010);
6924 reg_w(dev, 0x01, 0x01); 6924 reg_w(dev, 0x01, 0x0001);
6925 reg_w(dev, 0xee, 0x8b); 6925 reg_w(dev, 0xee, 0x008b);
6926 reg_w(dev, 0x03, 0x12); 6926 reg_w(dev, 0x03, 0x0012);
6927/* msleep(150); */ 6927/* msleep(150); */
6928 reg_w(dev, 0x01, 0x12); 6928 reg_w(dev, 0x01, 0x0012);
6929 reg_w(dev, 0x05, 0x12); 6929 reg_w(dev, 0x05, 0x0012);
6930 retbyte = i2c_read(gspca_dev, 0x00); /* ID 0 */ 6930 retbyte = i2c_read(gspca_dev, 0x0000); /* ID 0 */
6931 checkword = retbyte << 8; 6931 checkword = retbyte << 8;
6932 retbyte = i2c_read(gspca_dev, 0x01); /* ID 1 */ 6932 retbyte = i2c_read(gspca_dev, 0x0001); /* ID 1 */
6933 checkword |= retbyte; 6933 checkword |= retbyte;
6934 PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", checkword); 6934 PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", checkword);
6935 if (checkword == 0x2030) { 6935 if (checkword == 0x2030) {
@@ -6939,14 +6939,14 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6939 return checkword; 6939 return checkword;
6940 } 6940 }
6941 6941
6942 reg_w(dev, 0x01, 0x00); 6942 reg_w(dev, 0x01, 0x0000);
6943 reg_w(dev, 0x0a, 0x10); 6943 reg_w(dev, 0x0a, 0x0010);
6944 reg_w(dev, 0xd3, 0x8b); 6944 reg_w(dev, 0xd3, 0x008b);
6945 reg_w(dev, 0x01, 0x01); 6945 reg_w(dev, 0x01, 0x0001);
6946 reg_w(dev, 0x03, 0x12); 6946 reg_w(dev, 0x03, 0x0012);
6947 reg_w(dev, 0x01, 0x12); 6947 reg_w(dev, 0x01, 0x0012);
6948 reg_w(dev, 0x05, 0x01); 6948 reg_w(dev, 0x05, 0x0001);
6949 reg_w(dev, 0xd3, 0x8b); 6949 reg_w(dev, 0xd3, 0x008b);
6950 retbyte = i2c_read(gspca_dev, 0x01); 6950 retbyte = i2c_read(gspca_dev, 0x01);
6951 if (retbyte != 0) { 6951 if (retbyte != 0) {
6952 PDEBUG(D_PROBE, "probe 3wr vga type 0a ?"); 6952 PDEBUG(D_PROBE, "probe 3wr vga type 0a ?");
@@ -6962,7 +6962,9 @@ static int zcxx_probeSensor(struct gspca_dev *gspca_dev)
6962 6962
6963 switch (sd->sensor) { 6963 switch (sd->sensor) {
6964 case SENSOR_MC501CB: 6964 case SENSOR_MC501CB:
6965 return -1; /* don't probe */
6965 case SENSOR_TAS5130C_VF0250: 6966 case SENSOR_TAS5130C_VF0250:
6967 /* may probe but with write in reg 0x0010 */
6966 return -1; /* don't probe */ 6968 return -1; /* don't probe */
6967 } 6969 }
6968 sensor = vga_2wr_probe(gspca_dev); 6970 sensor = vga_2wr_probe(gspca_dev);
@@ -7010,6 +7012,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
7010 7012
7011 /* define some sensors from the vendor/product */ 7013 /* define some sensors from the vendor/product */
7012 sd->sharpness = 2; 7014 sd->sharpness = 2;
7015 sd->sensor = -1;
7013 switch (id->idVendor) { 7016 switch (id->idVendor) {
7014 case 0x041e: /* Creative */ 7017 case 0x041e: /* Creative */
7015 switch (id->idProduct) { 7018 switch (id->idProduct) {
@@ -7119,6 +7122,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
7119 PDEBUG(D_PROBE, "Find Sensor GC0305"); 7122 PDEBUG(D_PROBE, "Find Sensor GC0305");
7120 sd->sensor = SENSOR_GC0305; 7123 sd->sensor = SENSOR_GC0305;
7121 break; 7124 break;
7125 case 0x0250:
7126 PDEBUG(D_PROBE, "Sensor Tas5130 (VF0250)");
7127 sd->sensor = SENSOR_TAS5130C_VF0250;
7128 break;
7122 case 0x2030: 7129 case 0x2030:
7123 PDEBUG(D_PROBE, "Find Sensor PO2030"); 7130 PDEBUG(D_PROBE, "Find Sensor PO2030");
7124 sd->sensor = SENSOR_PO2030; 7131 sd->sensor = SENSOR_PO2030;
@@ -7235,6 +7242,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
7235 case SENSOR_GC0305: 7242 case SENSOR_GC0305:
7236 case SENSOR_OV7620: 7243 case SENSOR_OV7620:
7237 case SENSOR_PO2030: 7244 case SENSOR_PO2030:
7245 case SENSOR_TAS5130C_VF0250:
7238 msleep(100); /* ?? */ 7246 msleep(100); /* ?? */
7239 reg_r(gspca_dev, 0x0002); /* --> 0x40 */ 7247 reg_r(gspca_dev, 0x0002); /* --> 0x40 */
7240 reg_w(dev, 0x09, 0x01ad); /* (from win traces) */ 7248 reg_w(dev, 0x09, 0x01ad); /* (from win traces) */
@@ -7605,7 +7613,7 @@ static int __init sd_mod_init(void)
7605{ 7613{
7606 if (usb_register(&sd_driver) < 0) 7614 if (usb_register(&sd_driver) < 0)
7607 return -1; 7615 return -1;
7608 PDEBUG(D_PROBE, "v%s registered", version); 7616 PDEBUG(D_PROBE, "registered");
7609 return 0; 7617 return 0;
7610} 7618}
7611 7619
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index a08bb3331cfb..ab287b48fc2b 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -60,6 +60,7 @@
60#include <linux/dvb/video.h> 60#include <linux/dvb/video.h>
61#include <linux/dvb/audio.h> 61#include <linux/dvb/audio.h>
62#include <media/v4l2-common.h> 62#include <media/v4l2-common.h>
63#include <media/v4l2-ioctl.h>
63#include <media/tuner.h> 64#include <media/tuner.h>
64#include <media/cx2341x.h> 65#include <media/cx2341x.h>
65 66
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index f8883b487f4a..b883c4e08fbd 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -217,7 +217,7 @@ static int ivtv_prep_dev(struct ivtv *itv, int type)
217 itv->num, s->name); 217 itv->num, s->name);
218 218
219 s->v4l2dev->minor = minor; 219 s->v4l2dev->minor = minor;
220 s->v4l2dev->dev = &itv->dev->dev; 220 s->v4l2dev->parent = &itv->dev->dev;
221 s->v4l2dev->fops = ivtv_stream_info[type].fops; 221 s->v4l2dev->fops = ivtv_stream_info[type].fops;
222 s->v4l2dev->release = video_device_release; 222 s->v4l2dev->release = video_device_release;
223 s->v4l2dev->tvnorms = V4L2_STD_ALL; 223 s->v4l2dev->tvnorms = V4L2_STD_ALL;
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 2fb5854cf6f0..a1fb9874fdcf 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -31,6 +31,7 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/videodev.h> 32#include <linux/videodev.h>
33#include <media/v4l2-common.h> 33#include <media/v4l2-common.h>
34#include <media/v4l2-ioctl.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <asm/io.h> 36#include <asm/io.h>
36#include <linux/delay.h> 37#include <linux/delay.h>
@@ -1801,7 +1802,7 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1801 } 1802 }
1802 1803
1803 memcpy(meye.video_dev, &meye_template, sizeof(meye_template)); 1804 memcpy(meye.video_dev, &meye_template, sizeof(meye_template));
1804 meye.video_dev->dev = &meye.mchip_dev->dev; 1805 meye.video_dev->parent = &meye.mchip_dev->dev;
1805 1806
1806 if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) { 1807 if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) {
1807 printk(KERN_ERR "meye: unable to power on the camera\n"); 1808 printk(KERN_ERR "meye: unable to power on the camera\n");
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index 5691e019d195..780531b587a4 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -54,6 +54,7 @@
54#include <linux/videodev.h> 54#include <linux/videodev.h>
55#include <linux/videodev2.h> 55#include <linux/videodev2.h>
56#include <media/v4l2-common.h> 56#include <media/v4l2-common.h>
57#include <media/v4l2-ioctl.h>
57#include <media/v4l2-i2c-drv-legacy.h> 58#include <media/v4l2-i2c-drv-legacy.h>
58#include <media/tvaudio.h> 59#include <media/tvaudio.h>
59#include <media/msp3400.h> 60#include <media/msp3400.h>
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c
index ee43499544c1..554d2295484e 100644
--- a/drivers/media/video/mt9m001.c
+++ b/drivers/media/video/mt9m001.c
@@ -120,7 +120,7 @@ static int mt9m001_init(struct soc_camera_device *icd)
120 int ret; 120 int ret;
121 121
122 /* Disable chip, synchronous option update */ 122 /* Disable chip, synchronous option update */
123 dev_dbg(icd->vdev->dev, "%s\n", __func__); 123 dev_dbg(icd->vdev->parent, "%s\n", __func__);
124 124
125 ret = reg_write(icd, MT9M001_RESET, 1); 125 ret = reg_write(icd, MT9M001_RESET, 1);
126 if (ret >= 0) 126 if (ret >= 0)
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index eafb0c7736e6..b72e5660bc19 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -5833,7 +5833,7 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
5833 goto error; 5833 goto error;
5834 5834
5835 memcpy(ov->vdev, &vdev_template, sizeof(*ov->vdev)); 5835 memcpy(ov->vdev, &vdev_template, sizeof(*ov->vdev));
5836 ov->vdev->dev = &intf->dev; 5836 ov->vdev->parent = &intf->dev;
5837 video_set_drvdata(ov->vdev, ov); 5837 video_set_drvdata(ov->vdev, ov);
5838 5838
5839 for (i = 0; i < OV511_MAX_UNIT_VIDEO; i++) { 5839 for (i = 0; i < OV511_MAX_UNIT_VIDEO; i++) {
diff --git a/drivers/media/video/ov511.h b/drivers/media/video/ov511.h
index 1010e51189b7..baded1262ca9 100644
--- a/drivers/media/video/ov511.h
+++ b/drivers/media/video/ov511.h
@@ -4,6 +4,7 @@
4#include <asm/uaccess.h> 4#include <asm/uaccess.h>
5#include <linux/videodev.h> 5#include <linux/videodev.h>
6#include <media/v4l2-common.h> 6#include <media/v4l2-common.h>
7#include <media/v4l2-ioctl.h>
7#include <linux/usb.h> 8#include <linux/usb.h>
8#include <linux/mutex.h> 9#include <linux/mutex.h>
9 10
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 51b1461d8fb6..260c1d3f9692 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -30,6 +30,7 @@
30#include <asm/io.h> 30#include <asm/io.h>
31#include <linux/videodev.h> 31#include <linux/videodev.h>
32#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
33#include <media/v4l2-ioctl.h>
33#include <linux/mutex.h> 34#include <linux/mutex.h>
34 35
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 0d72dc470fef..bd6169fbdcca 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -30,6 +30,7 @@
30#include <linux/videodev2.h> 30#include <linux/videodev2.h>
31#include <media/v4l2-dev.h> 31#include <media/v4l2-dev.h>
32#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
33#include <media/v4l2-ioctl.h>
33 34
34struct pvr2_v4l2_dev; 35struct pvr2_v4l2_dev;
35struct pvr2_v4l2_fh; 36struct pvr2_v4l2_fh;
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 423fa7c2d0c9..b4de82115e5b 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -1767,7 +1767,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1767 return -ENOMEM; 1767 return -ENOMEM;
1768 } 1768 }
1769 memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); 1769 memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template));
1770 pdev->vdev->dev = &(udev->dev); 1770 pdev->vdev->parent = &(udev->dev);
1771 strcpy(pdev->vdev->name, name); 1771 strcpy(pdev->vdev->name, name);
1772 pdev->vdev->owner = THIS_MODULE; 1772 pdev->vdev->owner = THIS_MODULE;
1773 video_set_drvdata(pdev->vdev, pdev); 1773 video_set_drvdata(pdev->vdev, pdev);
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 8e8e5b27e77e..835db149a3b1 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -35,6 +35,7 @@
35#include <asm/errno.h> 35#include <asm/errno.h>
36#include <linux/videodev.h> 36#include <linux/videodev.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-ioctl.h>
38 39
39#include "pwc-uncompress.h" 40#include "pwc-uncompress.h"
40#include <media/pwc-ioctl.h> 41#include <media/pwc-ioctl.h>
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 04eb2c3fabd8..eb81915935b1 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -49,6 +49,7 @@
49#include <linux/version.h> 49#include <linux/version.h>
50#include <media/videobuf-vmalloc.h> 50#include <media/videobuf-vmalloc.h>
51#include <media/v4l2-common.h> 51#include <media/v4l2-common.h>
52#include <media/v4l2-ioctl.h>
52#include <linux/vmalloc.h> 53#include <linux/vmalloc.h>
53#include <linux/usb.h> 54#include <linux/usb.h>
54 55
@@ -1706,7 +1707,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1706 /* register 4 video devices */ 1707 /* register 4 video devices */
1707 dev->vdev[i] = video_device_alloc(); 1708 dev->vdev[i] = video_device_alloc();
1708 memcpy(dev->vdev[i], &template, sizeof(struct video_device)); 1709 memcpy(dev->vdev[i], &template, sizeof(struct video_device));
1709 dev->vdev[i]->dev = &dev->interface->dev; 1710 dev->vdev[i]->parent = &dev->interface->dev;
1710 if (video_nr == -1) 1711 if (video_nr == -1)
1711 ret = video_register_device(dev->vdev[i], 1712 ret = video_register_device(dev->vdev[i],
1712 VFL_TYPE_GRABBER, 1713 VFL_TYPE_GRABBER,
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index 03e772130b55..8d69632a6658 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -46,6 +46,7 @@
46#include <linux/videotext.h> 46#include <linux/videotext.h>
47#include <linux/videodev.h> 47#include <linux/videodev.h>
48#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
49#include <media/v4l2-ioctl.h>
49#include <linux/mutex.h> 50#include <linux/mutex.h>
50 51
51#include "saa5246a.h" 52#include "saa5246a.h"
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index fde99d9ee71f..812cfe3fd3f3 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -57,6 +57,7 @@
57#include <linux/videotext.h> 57#include <linux/videotext.h>
58#include <linux/videodev.h> 58#include <linux/videodev.h>
59#include <media/v4l2-common.h> 59#include <media/v4l2-common.h>
60#include <media/v4l2-ioctl.h>
60#include <linux/mutex.h> 61#include <linux/mutex.h>
61 62
62 63
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index cfee84ee7a88..f3e7a598e4b5 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -798,7 +798,7 @@ static struct video_device *vdev_init(struct saa7134_dev *dev,
798 return NULL; 798 return NULL;
799 *vfd = *template; 799 *vfd = *template;
800 vfd->minor = -1; 800 vfd->minor = -1;
801 vfd->dev = &dev->pci->dev; 801 vfd->parent = &dev->pci->dev;
802 vfd->release = video_device_release; 802 vfd->release = video_device_release;
803 vfd->debug = video_debug; 803 vfd->debug = video_debug;
804 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", 804 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 2a5ab957542d..3854cc29752d 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -465,7 +465,7 @@ static int empress_init(struct saa7134_dev *dev)
465 if (NULL == dev->empress_dev) 465 if (NULL == dev->empress_dev)
466 return -ENOMEM; 466 return -ENOMEM;
467 *(dev->empress_dev) = saa7134_empress_template; 467 *(dev->empress_dev) = saa7134_empress_template;
468 dev->empress_dev->dev = &dev->pci->dev; 468 dev->empress_dev->parent = &dev->pci->dev;
469 dev->empress_dev->release = video_device_release; 469 dev->empress_dev->release = video_device_release;
470 snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name), 470 snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name),
471 "%s empress (%s)", dev->name, 471 "%s empress (%s)", dev->name,
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 6927cbea8624..ade4e19799e9 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -34,6 +34,7 @@
34#include <asm/io.h> 34#include <asm/io.h>
35 35
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h>
37#include <media/tuner.h> 38#include <media/tuner.h>
38#include <media/ir-common.h> 39#include <media/ir-common.h>
39#include <media/ir-kbd-i2c.h> 40#include <media/ir-kbd-i2c.h>
diff --git a/drivers/media/video/se401.h b/drivers/media/video/se401.h
index 835ef872e803..2ce685db5d8b 100644
--- a/drivers/media/video/se401.h
+++ b/drivers/media/video/se401.h
@@ -5,6 +5,7 @@
5#include <asm/uaccess.h> 5#include <asm/uaccess.h>
6#include <linux/videodev.h> 6#include <linux/videodev.h>
7#include <media/v4l2-common.h> 7#include <media/v4l2-common.h>
8#include <media/v4l2-ioctl.h>
8#include <linux/mutex.h> 9#include <linux/mutex.h>
9 10
10#define se401_DEBUG /* Turn on debug messages */ 11#define se401_DEBUG /* Turn on debug messages */
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index 012005e1a77b..f7ca3cb9340a 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -91,6 +91,7 @@ struct sh_mobile_ceu_dev {
91 void __iomem *base; 91 void __iomem *base;
92 unsigned long video_limit; 92 unsigned long video_limit;
93 93
94 /* lock used to protect videobuf */
94 spinlock_t lock; 95 spinlock_t lock;
95 struct list_head capture; 96 struct list_head capture;
96 struct videobuf_buffer *active; 97 struct videobuf_buffer *active;
diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h
index 0c8d87d8d18d..cbfc44433b99 100644
--- a/drivers/media/video/sn9c102/sn9c102.h
+++ b/drivers/media/video/sn9c102/sn9c102.h
@@ -25,6 +25,7 @@
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/v4l2-ioctl.h>
28#include <linux/device.h> 29#include <linux/device.h>
29#include <linux/list.h> 30#include <linux/list.h>
30#include <linux/spinlock.h> 31#include <linux/spinlock.h>
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 7f9c7bcf3c85..475b78191151 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -1038,8 +1038,7 @@ static ssize_t sn9c102_show_reg(struct device* cd,
1038 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1038 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1039 return -ERESTARTSYS; 1039 return -ERESTARTSYS;
1040 1040
1041 cam = video_get_drvdata(container_of(cd, struct video_device, 1041 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1042 class_dev));
1043 if (!cam) { 1042 if (!cam) {
1044 mutex_unlock(&sn9c102_sysfs_lock); 1043 mutex_unlock(&sn9c102_sysfs_lock);
1045 return -ENODEV; 1044 return -ENODEV;
@@ -1064,8 +1063,7 @@ sn9c102_store_reg(struct device* cd, struct device_attribute *attr,
1064 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1063 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1065 return -ERESTARTSYS; 1064 return -ERESTARTSYS;
1066 1065
1067 cam = video_get_drvdata(container_of(cd, struct video_device, 1066 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1068 class_dev));
1069 if (!cam) { 1067 if (!cam) {
1070 mutex_unlock(&sn9c102_sysfs_lock); 1068 mutex_unlock(&sn9c102_sysfs_lock);
1071 return -ENODEV; 1069 return -ENODEV;
@@ -1098,8 +1096,7 @@ static ssize_t sn9c102_show_val(struct device* cd,
1098 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1096 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1099 return -ERESTARTSYS; 1097 return -ERESTARTSYS;
1100 1098
1101 cam = video_get_drvdata(container_of(cd, struct video_device, 1099 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1102 class_dev));
1103 if (!cam) { 1100 if (!cam) {
1104 mutex_unlock(&sn9c102_sysfs_lock); 1101 mutex_unlock(&sn9c102_sysfs_lock);
1105 return -ENODEV; 1102 return -ENODEV;
@@ -1132,8 +1129,7 @@ sn9c102_store_val(struct device* cd, struct device_attribute *attr,
1132 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1129 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1133 return -ERESTARTSYS; 1130 return -ERESTARTSYS;
1134 1131
1135 cam = video_get_drvdata(container_of(cd, struct video_device, 1132 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1136 class_dev));
1137 if (!cam) { 1133 if (!cam) {
1138 mutex_unlock(&sn9c102_sysfs_lock); 1134 mutex_unlock(&sn9c102_sysfs_lock);
1139 return -ENODEV; 1135 return -ENODEV;
@@ -1170,8 +1166,7 @@ static ssize_t sn9c102_show_i2c_reg(struct device* cd,
1170 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1166 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1171 return -ERESTARTSYS; 1167 return -ERESTARTSYS;
1172 1168
1173 cam = video_get_drvdata(container_of(cd, struct video_device, 1169 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1174 class_dev));
1175 if (!cam) { 1170 if (!cam) {
1176 mutex_unlock(&sn9c102_sysfs_lock); 1171 mutex_unlock(&sn9c102_sysfs_lock);
1177 return -ENODEV; 1172 return -ENODEV;
@@ -1198,8 +1193,7 @@ sn9c102_store_i2c_reg(struct device* cd, struct device_attribute *attr,
1198 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1193 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1199 return -ERESTARTSYS; 1194 return -ERESTARTSYS;
1200 1195
1201 cam = video_get_drvdata(container_of(cd, struct video_device, 1196 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1202 class_dev));
1203 if (!cam) { 1197 if (!cam) {
1204 mutex_unlock(&sn9c102_sysfs_lock); 1198 mutex_unlock(&sn9c102_sysfs_lock);
1205 return -ENODEV; 1199 return -ENODEV;
@@ -1232,8 +1226,7 @@ static ssize_t sn9c102_show_i2c_val(struct device* cd,
1232 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1226 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1233 return -ERESTARTSYS; 1227 return -ERESTARTSYS;
1234 1228
1235 cam = video_get_drvdata(container_of(cd, struct video_device, 1229 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1236 class_dev));
1237 if (!cam) { 1230 if (!cam) {
1238 mutex_unlock(&sn9c102_sysfs_lock); 1231 mutex_unlock(&sn9c102_sysfs_lock);
1239 return -ENODEV; 1232 return -ENODEV;
@@ -1271,8 +1264,7 @@ sn9c102_store_i2c_val(struct device* cd, struct device_attribute *attr,
1271 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1264 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1272 return -ERESTARTSYS; 1265 return -ERESTARTSYS;
1273 1266
1274 cam = video_get_drvdata(container_of(cd, struct video_device, 1267 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1275 class_dev));
1276 if (!cam) { 1268 if (!cam) {
1277 mutex_unlock(&sn9c102_sysfs_lock); 1269 mutex_unlock(&sn9c102_sysfs_lock);
1278 return -ENODEV; 1270 return -ENODEV;
@@ -1318,8 +1310,7 @@ sn9c102_store_green(struct device* cd, struct device_attribute *attr,
1318 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1310 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1319 return -ERESTARTSYS; 1311 return -ERESTARTSYS;
1320 1312
1321 cam = video_get_drvdata(container_of(cd, struct video_device, 1313 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1322 class_dev));
1323 if (!cam) { 1314 if (!cam) {
1324 mutex_unlock(&sn9c102_sysfs_lock); 1315 mutex_unlock(&sn9c102_sysfs_lock);
1325 return -ENODEV; 1316 return -ENODEV;
@@ -1400,8 +1391,7 @@ static ssize_t sn9c102_show_frame_header(struct device* cd,
1400 struct sn9c102_device* cam; 1391 struct sn9c102_device* cam;
1401 ssize_t count; 1392 ssize_t count;
1402 1393
1403 cam = video_get_drvdata(container_of(cd, struct video_device, 1394 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1404 class_dev));
1405 if (!cam) 1395 if (!cam)
1406 return -ENODEV; 1396 return -ENODEV;
1407 1397
@@ -1428,49 +1418,49 @@ static DEVICE_ATTR(frame_header, S_IRUGO, sn9c102_show_frame_header, NULL);
1428 1418
1429static int sn9c102_create_sysfs(struct sn9c102_device* cam) 1419static int sn9c102_create_sysfs(struct sn9c102_device* cam)
1430{ 1420{
1431 struct device *classdev = &(cam->v4ldev->class_dev); 1421 struct device *dev = &(cam->v4ldev->dev);
1432 int err = 0; 1422 int err = 0;
1433 1423
1434 if ((err = device_create_file(classdev, &dev_attr_reg))) 1424 if ((err = device_create_file(dev, &dev_attr_reg)))
1435 goto err_out; 1425 goto err_out;
1436 if ((err = device_create_file(classdev, &dev_attr_val))) 1426 if ((err = device_create_file(dev, &dev_attr_val)))
1437 goto err_reg; 1427 goto err_reg;
1438 if ((err = device_create_file(classdev, &dev_attr_frame_header))) 1428 if ((err = device_create_file(dev, &dev_attr_frame_header)))
1439 goto err_val; 1429 goto err_val;
1440 1430
1441 if (cam->sensor.sysfs_ops) { 1431 if (cam->sensor.sysfs_ops) {
1442 if ((err = device_create_file(classdev, &dev_attr_i2c_reg))) 1432 if ((err = device_create_file(dev, &dev_attr_i2c_reg)))
1443 goto err_frame_header; 1433 goto err_frame_header;
1444 if ((err = device_create_file(classdev, &dev_attr_i2c_val))) 1434 if ((err = device_create_file(dev, &dev_attr_i2c_val)))
1445 goto err_i2c_reg; 1435 goto err_i2c_reg;
1446 } 1436 }
1447 1437
1448 if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) { 1438 if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) {
1449 if ((err = device_create_file(classdev, &dev_attr_green))) 1439 if ((err = device_create_file(dev, &dev_attr_green)))
1450 goto err_i2c_val; 1440 goto err_i2c_val;
1451 } else { 1441 } else {
1452 if ((err = device_create_file(classdev, &dev_attr_blue))) 1442 if ((err = device_create_file(dev, &dev_attr_blue)))
1453 goto err_i2c_val; 1443 goto err_i2c_val;
1454 if ((err = device_create_file(classdev, &dev_attr_red))) 1444 if ((err = device_create_file(dev, &dev_attr_red)))
1455 goto err_blue; 1445 goto err_blue;
1456 } 1446 }
1457 1447
1458 return 0; 1448 return 0;
1459 1449
1460err_blue: 1450err_blue:
1461 device_remove_file(classdev, &dev_attr_blue); 1451 device_remove_file(dev, &dev_attr_blue);
1462err_i2c_val: 1452err_i2c_val:
1463 if (cam->sensor.sysfs_ops) 1453 if (cam->sensor.sysfs_ops)
1464 device_remove_file(classdev, &dev_attr_i2c_val); 1454 device_remove_file(dev, &dev_attr_i2c_val);
1465err_i2c_reg: 1455err_i2c_reg:
1466 if (cam->sensor.sysfs_ops) 1456 if (cam->sensor.sysfs_ops)
1467 device_remove_file(classdev, &dev_attr_i2c_reg); 1457 device_remove_file(dev, &dev_attr_i2c_reg);
1468err_frame_header: 1458err_frame_header:
1469 device_remove_file(classdev, &dev_attr_frame_header); 1459 device_remove_file(dev, &dev_attr_frame_header);
1470err_val: 1460err_val:
1471 device_remove_file(classdev, &dev_attr_val); 1461 device_remove_file(dev, &dev_attr_val);
1472err_reg: 1462err_reg:
1473 device_remove_file(classdev, &dev_attr_reg); 1463 device_remove_file(dev, &dev_attr_reg);
1474err_out: 1464err_out:
1475 return err; 1465 return err;
1476} 1466}
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index e39b98f1eca4..b01749088472 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -25,6 +25,7 @@
25#include <linux/vmalloc.h> 25#include <linux/vmalloc.h>
26 26
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/v4l2-ioctl.h>
28#include <media/v4l2-dev.h> 29#include <media/v4l2-dev.h>
29#include <media/videobuf-core.h> 30#include <media/videobuf-core.h>
30#include <media/soc_camera.h> 31#include <media/soc_camera.h>
@@ -193,7 +194,7 @@ static int soc_camera_open(struct inode *inode, struct file *file)
193 mutex_lock(&video_lock); 194 mutex_lock(&video_lock);
194 195
195 vdev = video_devdata(file); 196 vdev = video_devdata(file);
196 icd = container_of(vdev->dev, struct soc_camera_device, dev); 197 icd = container_of(vdev->parent, struct soc_camera_device, dev);
197 ici = to_soc_camera_host(icd->dev.parent); 198 ici = to_soc_camera_host(icd->dev.parent);
198 199
199 if (!try_module_get(icd->ops->owner)) { 200 if (!try_module_get(icd->ops->owner)) {
@@ -258,7 +259,7 @@ static int soc_camera_close(struct inode *inode, struct file *file)
258 259
259 vfree(icf); 260 vfree(icf);
260 261
261 dev_dbg(vdev->dev, "camera device close\n"); 262 dev_dbg(vdev->parent, "camera device close\n");
262 263
263 return 0; 264 return 0;
264} 265}
@@ -271,7 +272,7 @@ static ssize_t soc_camera_read(struct file *file, char __user *buf,
271 struct video_device *vdev = icd->vdev; 272 struct video_device *vdev = icd->vdev;
272 int err = -EINVAL; 273 int err = -EINVAL;
273 274
274 dev_err(vdev->dev, "camera device read not implemented\n"); 275 dev_err(vdev->parent, "camera device read not implemented\n");
275 276
276 return err; 277 return err;
277} 278}
@@ -877,7 +878,7 @@ int soc_camera_video_start(struct soc_camera_device *icd)
877 878
878 strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name)); 879 strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
879 /* Maybe better &ici->dev */ 880 /* Maybe better &ici->dev */
880 vdev->dev = &icd->dev; 881 vdev->parent = &icd->dev;
881 vdev->type = VID_TYPE_CAPTURE; 882 vdev->type = VID_TYPE_CAPTURE;
882 vdev->current_norm = V4L2_STD_UNKNOWN; 883 vdev->current_norm = V4L2_STD_UNKNOWN;
883 vdev->fops = &soc_camera_fops; 884 vdev->fops = &soc_camera_fops;
@@ -915,7 +916,7 @@ int soc_camera_video_start(struct soc_camera_device *icd)
915 916
916 err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor); 917 err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor);
917 if (err < 0) { 918 if (err < 0) {
918 dev_err(vdev->dev, "video_register_device failed\n"); 919 dev_err(vdev->parent, "video_register_device failed\n");
919 goto evidregd; 920 goto evidregd;
920 } 921 }
921 icd->vdev = vdev; 922 icd->vdev = vdev;
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index f308c38d744f..20028aeb842b 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -34,6 +34,7 @@
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/videodev2.h> 35#include <linux/videodev2.h>
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h>
37 38
38#include "stk-webcam.h" 39#include "stk-webcam.h"
39 40
@@ -1369,7 +1370,7 @@ static int stk_register_video_device(struct stk_camera *dev)
1369 1370
1370 dev->vdev = stk_v4l_data; 1371 dev->vdev = stk_v4l_data;
1371 dev->vdev.debug = debug; 1372 dev->vdev.debug = debug;
1372 dev->vdev.dev = &dev->interface->dev; 1373 dev->vdev.parent = &dev->interface->dev;
1373 dev->vdev.priv = dev; 1374 dev->vdev.priv = dev;
1374 err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1); 1375 err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1);
1375 if (err) 1376 if (err)
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index c109511f21ea..6ace8923b797 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -43,6 +43,7 @@
43#include <linux/vmalloc.h> 43#include <linux/vmalloc.h>
44#include <linux/videodev.h> 44#include <linux/videodev.h>
45#include <media/v4l2-common.h> 45#include <media/v4l2-common.h>
46#include <media/v4l2-ioctl.h>
46 47
47#include "saa7146.h" 48#include "saa7146.h"
48#include "saa7146reg.h" 49#include "saa7146reg.h"
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index d7f130bedb5f..da94d3fd8fac 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -66,6 +66,7 @@
66#include <linux/errno.h> 66#include <linux/errno.h>
67#include <linux/videodev.h> 67#include <linux/videodev.h>
68#include <media/v4l2-common.h> 68#include <media/v4l2-common.h>
69#include <media/v4l2-ioctl.h>
69#include <linux/usb.h> 70#include <linux/usb.h>
70#include <linux/mutex.h> 71#include <linux/mutex.h>
71 72
@@ -1454,7 +1455,7 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
1454 goto error; 1455 goto error;
1455 } 1456 }
1456 memcpy(stv680->vdev, &stv680_template, sizeof(stv680_template)); 1457 memcpy(stv680->vdev, &stv680_template, sizeof(stv680_template));
1457 stv680->vdev->dev = &intf->dev; 1458 stv680->vdev->parent = &intf->dev;
1458 video_set_drvdata(stv680->vdev, stv680); 1459 video_set_drvdata(stv680->vdev, stv680);
1459 1460
1460 memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name)); 1461 memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name));
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index ae75c187da79..2fda40c0f255 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -48,6 +48,7 @@
48#include <linux/i2c.h> 48#include <linux/i2c.h>
49 49
50#include <media/v4l2-common.h> 50#include <media/v4l2-common.h>
51#include <media/v4l2-ioctl.h>
51#include <media/i2c-addr.h> 52#include <media/i2c-addr.h>
52 53
53#ifndef VIDEO_AUDIO_BALANCE 54#ifndef VIDEO_AUDIO_BALANCE
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 93d879dc510f..d806a3556eed 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -19,6 +19,7 @@
19#include <media/tuner.h> 19#include <media/tuner.h>
20#include <media/tuner-types.h> 20#include <media/tuner-types.h>
21#include <media/v4l2-common.h> 21#include <media/v4l2-common.h>
22#include <media/v4l2-ioctl.h>
22#include <media/v4l2-i2c-drv-legacy.h> 23#include <media/v4l2-i2c-drv-legacy.h>
23#include "mt20xx.h" 24#include "mt20xx.h"
24#include "tda8290.h" 25#include "tda8290.h"
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index 4128ee20b64e..7e6ab2910c13 100644
--- a/drivers/media/video/usbvideo/usbvideo.c
+++ b/drivers/media/video/usbvideo/usbvideo.c
@@ -1040,7 +1040,7 @@ int usbvideo_RegisterVideoDevice(struct uvd *uvd)
1040 err("%s: uvd->dev == NULL", __func__); 1040 err("%s: uvd->dev == NULL", __func__);
1041 return -EINVAL; 1041 return -EINVAL;
1042 } 1042 }
1043 uvd->vdev.dev = &uvd->dev->dev; 1043 uvd->vdev.parent = &uvd->dev->dev;
1044 if (video_register_device(&uvd->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { 1044 if (video_register_device(&uvd->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
1045 err("%s: video_register_device failed", __func__); 1045 err("%s: video_register_device failed", __func__);
1046 return -EPIPE; 1046 return -EPIPE;
diff --git a/drivers/media/video/usbvideo/usbvideo.h b/drivers/media/video/usbvideo/usbvideo.h
index 051775d4c726..c66985beb8c9 100644
--- a/drivers/media/video/usbvideo/usbvideo.h
+++ b/drivers/media/video/usbvideo/usbvideo.h
@@ -18,6 +18,7 @@
18 18
19#include <linux/videodev.h> 19#include <linux/videodev.h>
20#include <media/v4l2-common.h> 20#include <media/v4l2-common.h>
21#include <media/v4l2-ioctl.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
22#include <linux/mutex.h> 23#include <linux/mutex.h>
23 24
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index cd6c41d67899..56cd685d35ea 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -65,6 +65,7 @@
65 65
66#include <media/saa7115.h> 66#include <media/saa7115.h>
67#include <media/v4l2-common.h> 67#include <media/v4l2-common.h>
68#include <media/v4l2-ioctl.h>
68#include <media/tuner.h> 69#include <media/tuner.h>
69#include <media/audiochip.h> 70#include <media/audiochip.h>
70 71
@@ -184,7 +185,7 @@ MODULE_ALIAS(DRIVER_ALIAS);
184static inline struct usb_usbvision *cd_to_usbvision(struct device *cd) 185static inline struct usb_usbvision *cd_to_usbvision(struct device *cd)
185{ 186{
186 struct video_device *vdev = 187 struct video_device *vdev =
187 container_of(cd, struct video_device, class_dev); 188 container_of(cd, struct video_device, dev);
188 return video_get_drvdata(vdev); 189 return video_get_drvdata(vdev);
189} 190}
190 191
@@ -199,7 +200,7 @@ static ssize_t show_model(struct device *cd,
199 struct device_attribute *attr, char *buf) 200 struct device_attribute *attr, char *buf)
200{ 201{
201 struct video_device *vdev = 202 struct video_device *vdev =
202 container_of(cd, struct video_device, class_dev); 203 container_of(cd, struct video_device, dev);
203 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 204 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
204 return sprintf(buf, "%s\n", 205 return sprintf(buf, "%s\n",
205 usbvision_device_data[usbvision->DevModel].ModelString); 206 usbvision_device_data[usbvision->DevModel].ModelString);
@@ -210,7 +211,7 @@ static ssize_t show_hue(struct device *cd,
210 struct device_attribute *attr, char *buf) 211 struct device_attribute *attr, char *buf)
211{ 212{
212 struct video_device *vdev = 213 struct video_device *vdev =
213 container_of(cd, struct video_device, class_dev); 214 container_of(cd, struct video_device, dev);
214 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 215 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
215 struct v4l2_control ctrl; 216 struct v4l2_control ctrl;
216 ctrl.id = V4L2_CID_HUE; 217 ctrl.id = V4L2_CID_HUE;
@@ -225,7 +226,7 @@ static ssize_t show_contrast(struct device *cd,
225 struct device_attribute *attr, char *buf) 226 struct device_attribute *attr, char *buf)
226{ 227{
227 struct video_device *vdev = 228 struct video_device *vdev =
228 container_of(cd, struct video_device, class_dev); 229 container_of(cd, struct video_device, dev);
229 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 230 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
230 struct v4l2_control ctrl; 231 struct v4l2_control ctrl;
231 ctrl.id = V4L2_CID_CONTRAST; 232 ctrl.id = V4L2_CID_CONTRAST;
@@ -240,7 +241,7 @@ static ssize_t show_brightness(struct device *cd,
240 struct device_attribute *attr, char *buf) 241 struct device_attribute *attr, char *buf)
241{ 242{
242 struct video_device *vdev = 243 struct video_device *vdev =
243 container_of(cd, struct video_device, class_dev); 244 container_of(cd, struct video_device, dev);
244 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 245 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
245 struct v4l2_control ctrl; 246 struct v4l2_control ctrl;
246 ctrl.id = V4L2_CID_BRIGHTNESS; 247 ctrl.id = V4L2_CID_BRIGHTNESS;
@@ -255,7 +256,7 @@ static ssize_t show_saturation(struct device *cd,
255 struct device_attribute *attr, char *buf) 256 struct device_attribute *attr, char *buf)
256{ 257{
257 struct video_device *vdev = 258 struct video_device *vdev =
258 container_of(cd, struct video_device, class_dev); 259 container_of(cd, struct video_device, dev);
259 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 260 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
260 struct v4l2_control ctrl; 261 struct v4l2_control ctrl;
261 ctrl.id = V4L2_CID_SATURATION; 262 ctrl.id = V4L2_CID_SATURATION;
@@ -270,7 +271,7 @@ static ssize_t show_streaming(struct device *cd,
270 struct device_attribute *attr, char *buf) 271 struct device_attribute *attr, char *buf)
271{ 272{
272 struct video_device *vdev = 273 struct video_device *vdev =
273 container_of(cd, struct video_device, class_dev); 274 container_of(cd, struct video_device, dev);
274 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 275 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
275 return sprintf(buf, "%s\n", 276 return sprintf(buf, "%s\n",
276 YES_NO(usbvision->streaming==Stream_On?1:0)); 277 YES_NO(usbvision->streaming==Stream_On?1:0));
@@ -281,7 +282,7 @@ static ssize_t show_compression(struct device *cd,
281 struct device_attribute *attr, char *buf) 282 struct device_attribute *attr, char *buf)
282{ 283{
283 struct video_device *vdev = 284 struct video_device *vdev =
284 container_of(cd, struct video_device, class_dev); 285 container_of(cd, struct video_device, dev);
285 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 286 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
286 return sprintf(buf, "%s\n", 287 return sprintf(buf, "%s\n",
287 YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS)); 288 YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS));
@@ -292,7 +293,7 @@ static ssize_t show_device_bridge(struct device *cd,
292 struct device_attribute *attr, char *buf) 293 struct device_attribute *attr, char *buf)
293{ 294{
294 struct video_device *vdev = 295 struct video_device *vdev =
295 container_of(cd, struct video_device, class_dev); 296 container_of(cd, struct video_device, dev);
296 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 297 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
297 return sprintf(buf, "%d\n", usbvision->bridgeType); 298 return sprintf(buf, "%d\n", usbvision->bridgeType);
298} 299}
@@ -304,40 +305,31 @@ static void usbvision_create_sysfs(struct video_device *vdev)
304 if (!vdev) 305 if (!vdev)
305 return; 306 return;
306 do { 307 do {
307 res = device_create_file(&vdev->class_dev, 308 res = device_create_file(&vdev->dev, &dev_attr_version);
308 &dev_attr_version);
309 if (res<0) 309 if (res<0)
310 break; 310 break;
311 res = device_create_file(&vdev->class_dev, 311 res = device_create_file(&vdev->dev, &dev_attr_model);
312 &dev_attr_model);
313 if (res<0) 312 if (res<0)
314 break; 313 break;
315 res = device_create_file(&vdev->class_dev, 314 res = device_create_file(&vdev->dev, &dev_attr_hue);
316 &dev_attr_hue);
317 if (res<0) 315 if (res<0)
318 break; 316 break;
319 res = device_create_file(&vdev->class_dev, 317 res = device_create_file(&vdev->dev, &dev_attr_contrast);
320 &dev_attr_contrast);
321 if (res<0) 318 if (res<0)
322 break; 319 break;
323 res = device_create_file(&vdev->class_dev, 320 res = device_create_file(&vdev->dev, &dev_attr_brightness);
324 &dev_attr_brightness);
325 if (res<0) 321 if (res<0)
326 break; 322 break;
327 res = device_create_file(&vdev->class_dev, 323 res = device_create_file(&vdev->dev, &dev_attr_saturation);
328 &dev_attr_saturation);
329 if (res<0) 324 if (res<0)
330 break; 325 break;
331 res = device_create_file(&vdev->class_dev, 326 res = device_create_file(&vdev->dev, &dev_attr_streaming);
332 &dev_attr_streaming);
333 if (res<0) 327 if (res<0)
334 break; 328 break;
335 res = device_create_file(&vdev->class_dev, 329 res = device_create_file(&vdev->dev, &dev_attr_compression);
336 &dev_attr_compression);
337 if (res<0) 330 if (res<0)
338 break; 331 break;
339 res = device_create_file(&vdev->class_dev, 332 res = device_create_file(&vdev->dev, &dev_attr_bridge);
340 &dev_attr_bridge);
341 if (res>=0) 333 if (res>=0)
342 return; 334 return;
343 } while (0); 335 } while (0);
@@ -348,24 +340,15 @@ static void usbvision_create_sysfs(struct video_device *vdev)
348static void usbvision_remove_sysfs(struct video_device *vdev) 340static void usbvision_remove_sysfs(struct video_device *vdev)
349{ 341{
350 if (vdev) { 342 if (vdev) {
351 device_remove_file(&vdev->class_dev, 343 device_remove_file(&vdev->dev, &dev_attr_version);
352 &dev_attr_version); 344 device_remove_file(&vdev->dev, &dev_attr_model);
353 device_remove_file(&vdev->class_dev, 345 device_remove_file(&vdev->dev, &dev_attr_hue);
354 &dev_attr_model); 346 device_remove_file(&vdev->dev, &dev_attr_contrast);
355 device_remove_file(&vdev->class_dev, 347 device_remove_file(&vdev->dev, &dev_attr_brightness);
356 &dev_attr_hue); 348 device_remove_file(&vdev->dev, &dev_attr_saturation);
357 device_remove_file(&vdev->class_dev, 349 device_remove_file(&vdev->dev, &dev_attr_streaming);
358 &dev_attr_contrast); 350 device_remove_file(&vdev->dev, &dev_attr_compression);
359 device_remove_file(&vdev->class_dev, 351 device_remove_file(&vdev->dev, &dev_attr_bridge);
360 &dev_attr_brightness);
361 device_remove_file(&vdev->class_dev,
362 &dev_attr_saturation);
363 device_remove_file(&vdev->class_dev,
364 &dev_attr_streaming);
365 device_remove_file(&vdev->class_dev,
366 &dev_attr_compression);
367 device_remove_file(&vdev->class_dev,
368 &dev_attr_bridge);
369 } 352 }
370} 353}
371 354
@@ -1506,7 +1489,7 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision,
1506 } 1489 }
1507 *vdev = *vdev_template; 1490 *vdev = *vdev_template;
1508// vdev->minor = -1; 1491// vdev->minor = -1;
1509 vdev->dev = &usb_dev->dev; 1492 vdev->parent = &usb_dev->dev;
1510 snprintf(vdev->name, sizeof(vdev->name), "%s", name); 1493 snprintf(vdev->name, sizeof(vdev->name), "%s", name);
1511 video_set_drvdata(vdev, usbvision); 1494 video_set_drvdata(vdev, usbvision);
1512 return vdev; 1495 return vdev;
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index f2b2983fe062..79d6821c4741 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -1458,7 +1458,7 @@ static int uvc_register_video(struct uvc_device *dev)
1458 * unregistered before the reference is released, so we don't need to 1458 * unregistered before the reference is released, so we don't need to
1459 * get another one. 1459 * get another one.
1460 */ 1460 */
1461 vdev->dev = &dev->intf->dev; 1461 vdev->parent = &dev->intf->dev;
1462 vdev->type = 0; 1462 vdev->type = 0;
1463 vdev->type2 = 0; 1463 vdev->type2 = 0;
1464 vdev->minor = -1; 1464 vdev->minor = -1;
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index b5a11eb8f9fa..d7bd71be40a9 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -23,6 +23,7 @@
23#include <asm/atomic.h> 23#include <asm/atomic.h>
24 24
25#include <media/v4l2-common.h> 25#include <media/v4l2-common.h>
26#include <media/v4l2-ioctl.h>
26 27
27#include "uvcvideo.h" 28#include "uvcvideo.h"
28 29
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index a0f6c60279ec..79937d1031fc 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -30,6 +30,7 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/videodev.h> 31#include <linux/videodev.h>
32#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
33#include <media/v4l2-ioctl.h>
33 34
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <asm/system.h> 36#include <asm/system.h>
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
new file mode 100644
index 000000000000..88eeee1d8baf
--- /dev/null
+++ b/drivers/media/video/v4l2-dev.c
@@ -0,0 +1,421 @@
1/*
2 * Video capture interface for Linux version 2
3 *
4 * A generic video device interface for the LINUX operating system
5 * using a set of device structures/vectors for low level operations.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * Authors: Alan Cox, <alan@redhat.com> (version 1)
13 * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2)
14 *
15 * Fixes: 20000516 Claudio Matsuoka <claudio@conectiva.com>
16 * - Added procfs support
17 */
18
19#include <linux/module.h>
20#include <linux/types.h>
21#include <linux/kernel.h>
22#include <linux/mm.h>
23#include <linux/string.h>
24#include <linux/errno.h>
25#include <linux/init.h>
26#include <linux/kmod.h>
27#include <linux/slab.h>
28#include <linux/smp_lock.h>
29#include <asm/uaccess.h>
30#include <asm/system.h>
31
32#include <media/v4l2-common.h>
33
34#define VIDEO_NUM_DEVICES 256
35#define VIDEO_NAME "video4linux"
36
37/*
38 * sysfs stuff
39 */
40
41static ssize_t show_index(struct device *cd,
42 struct device_attribute *attr, char *buf)
43{
44 struct video_device *vfd = container_of(cd, struct video_device, dev);
45 return sprintf(buf, "%i\n", vfd->index);
46}
47
48static ssize_t show_name(struct device *cd,
49 struct device_attribute *attr, char *buf)
50{
51 struct video_device *vfd = container_of(cd, struct video_device, dev);
52 return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
53}
54
55static struct device_attribute video_device_attrs[] = {
56 __ATTR(name, S_IRUGO, show_name, NULL),
57 __ATTR(index, S_IRUGO, show_index, NULL),
58 __ATTR_NULL
59};
60
61struct video_device *video_device_alloc(void)
62{
63 struct video_device *vfd;
64
65 vfd = kzalloc(sizeof(*vfd), GFP_KERNEL);
66 return vfd;
67}
68EXPORT_SYMBOL(video_device_alloc);
69
70void video_device_release(struct video_device *vfd)
71{
72 kfree(vfd);
73}
74EXPORT_SYMBOL(video_device_release);
75
76static void video_release(struct device *cd)
77{
78 struct video_device *vfd = container_of(cd, struct video_device, dev);
79
80#if 1
81 /* needed until all drivers are fixed */
82 if (!vfd->release)
83 return;
84#endif
85 vfd->release(vfd);
86}
87
88static struct class video_class = {
89 .name = VIDEO_NAME,
90 .dev_attrs = video_device_attrs,
91 .dev_release = video_release,
92};
93
94/*
95 * Active devices
96 */
97
98static struct video_device *video_device[VIDEO_NUM_DEVICES];
99static DEFINE_MUTEX(videodev_lock);
100
101struct video_device *video_devdata(struct file *file)
102{
103 return video_device[iminor(file->f_path.dentry->d_inode)];
104}
105EXPORT_SYMBOL(video_devdata);
106
107/*
108 * Open a video device - FIXME: Obsoleted
109 */
110static int video_open(struct inode *inode, struct file *file)
111{
112 unsigned int minor = iminor(inode);
113 int err = 0;
114 struct video_device *vfl;
115 const struct file_operations *old_fops;
116
117 if (minor >= VIDEO_NUM_DEVICES)
118 return -ENODEV;
119 lock_kernel();
120 mutex_lock(&videodev_lock);
121 vfl = video_device[minor];
122 if (vfl == NULL) {
123 mutex_unlock(&videodev_lock);
124 request_module("char-major-%d-%d", VIDEO_MAJOR, minor);
125 mutex_lock(&videodev_lock);
126 vfl = video_device[minor];
127 if (vfl == NULL) {
128 mutex_unlock(&videodev_lock);
129 unlock_kernel();
130 return -ENODEV;
131 }
132 }
133 old_fops = file->f_op;
134 file->f_op = fops_get(vfl->fops);
135 if (file->f_op->open)
136 err = file->f_op->open(inode, file);
137 if (err) {
138 fops_put(file->f_op);
139 file->f_op = fops_get(old_fops);
140 }
141 fops_put(old_fops);
142 mutex_unlock(&videodev_lock);
143 unlock_kernel();
144 return err;
145}
146
147/*
148 * open/release helper functions -- handle exclusive opens
149 * Should be removed soon
150 */
151int video_exclusive_open(struct inode *inode, struct file *file)
152{
153 struct video_device *vfl = video_devdata(file);
154 int retval = 0;
155
156 mutex_lock(&vfl->lock);
157 if (vfl->users)
158 retval = -EBUSY;
159 else
160 vfl->users++;
161 mutex_unlock(&vfl->lock);
162 return retval;
163}
164EXPORT_SYMBOL(video_exclusive_open);
165
166int video_exclusive_release(struct inode *inode, struct file *file)
167{
168 struct video_device *vfl = video_devdata(file);
169
170 vfl->users--;
171 return 0;
172}
173EXPORT_SYMBOL(video_exclusive_release);
174
175/**
176 * get_index - assign stream number based on parent device
177 * @vdev: video_device to assign index number to, vdev->dev should be assigned
178 * @num: -1 if auto assign, requested number otherwise
179 *
180 *
181 * returns -ENFILE if num is already in use, a free index number if
182 * successful.
183 */
184static int get_index(struct video_device *vdev, int num)
185{
186 u32 used = 0;
187 const int max_index = sizeof(used) * 8 - 1;
188 int i;
189
190 /* Currently a single v4l driver instance cannot create more than
191 32 devices.
192 Increase to u64 or an array of u32 if more are needed. */
193 if (num > max_index) {
194 printk(KERN_ERR "videodev: %s num is too large\n", __func__);
195 return -EINVAL;
196 }
197
198 for (i = 0; i < VIDEO_NUM_DEVICES; i++) {
199 if (video_device[i] != NULL &&
200 video_device[i] != vdev &&
201 video_device[i]->parent == vdev->parent) {
202 used |= 1 << video_device[i]->index;
203 }
204 }
205
206 if (num >= 0) {
207 if (used & (1 << num))
208 return -ENFILE;
209 return num;
210 }
211
212 i = ffz(used);
213 return i > max_index ? -ENFILE : i;
214}
215
216static const struct file_operations video_fops;
217
218int video_register_device(struct video_device *vfd, int type, int nr)
219{
220 return video_register_device_index(vfd, type, nr, -1);
221}
222EXPORT_SYMBOL(video_register_device);
223
224/**
225 * video_register_device - register video4linux devices
226 * @vfd: video device structure we want to register
227 * @type: type of device to register
228 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ...
229 * -1 == first free)
230 *
231 * The registration code assigns minor numbers based on the type
232 * requested. -ENFILE is returned in all the device slots for this
233 * category are full. If not then the minor field is set and the
234 * driver initialize function is called (if non %NULL).
235 *
236 * Zero is returned on success.
237 *
238 * Valid types are
239 *
240 * %VFL_TYPE_GRABBER - A frame grabber
241 *
242 * %VFL_TYPE_VTX - A teletext device
243 *
244 * %VFL_TYPE_VBI - Vertical blank data (undecoded)
245 *
246 * %VFL_TYPE_RADIO - A radio card
247 */
248
249int video_register_device_index(struct video_device *vfd, int type, int nr,
250 int index)
251{
252 int i = 0;
253 int base;
254 int end;
255 int ret;
256 char *name_base;
257
258 switch (type) {
259 case VFL_TYPE_GRABBER:
260 base = MINOR_VFL_TYPE_GRABBER_MIN;
261 end = MINOR_VFL_TYPE_GRABBER_MAX+1;
262 name_base = "video";
263 break;
264 case VFL_TYPE_VTX:
265 base = MINOR_VFL_TYPE_VTX_MIN;
266 end = MINOR_VFL_TYPE_VTX_MAX+1;
267 name_base = "vtx";
268 break;
269 case VFL_TYPE_VBI:
270 base = MINOR_VFL_TYPE_VBI_MIN;
271 end = MINOR_VFL_TYPE_VBI_MAX+1;
272 name_base = "vbi";
273 break;
274 case VFL_TYPE_RADIO:
275 base = MINOR_VFL_TYPE_RADIO_MIN;
276 end = MINOR_VFL_TYPE_RADIO_MAX+1;
277 name_base = "radio";
278 break;
279 default:
280 printk(KERN_ERR "%s called with unknown type: %d\n",
281 __func__, type);
282 return -1;
283 }
284
285 /* pick a minor number */
286 mutex_lock(&videodev_lock);
287 if (nr >= 0 && nr < end-base) {
288 /* use the one the driver asked for */
289 i = base + nr;
290 if (NULL != video_device[i]) {
291 mutex_unlock(&videodev_lock);
292 return -ENFILE;
293 }
294 } else {
295 /* use first free */
296 for (i = base; i < end; i++)
297 if (NULL == video_device[i])
298 break;
299 if (i == end) {
300 mutex_unlock(&videodev_lock);
301 return -ENFILE;
302 }
303 }
304 video_device[i] = vfd;
305 vfd->minor = i;
306
307 ret = get_index(vfd, index);
308 vfd->index = ret;
309
310 mutex_unlock(&videodev_lock);
311
312 if (ret < 0) {
313 printk(KERN_ERR "%s: get_index failed\n", __func__);
314 goto fail_minor;
315 }
316
317 mutex_init(&vfd->lock);
318
319 /* sysfs class */
320 memset(&vfd->dev, 0x00, sizeof(vfd->dev));
321 vfd->dev.class = &video_class;
322 vfd->dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
323 if (vfd->parent)
324 vfd->dev.parent = vfd->parent;
325 sprintf(vfd->dev.bus_id, "%s%d", name_base, i - base);
326 ret = device_register(&vfd->dev);
327 if (ret < 0) {
328 printk(KERN_ERR "%s: device_register failed\n", __func__);
329 goto fail_minor;
330 }
331
332#if 1
333 /* needed until all drivers are fixed */
334 if (!vfd->release)
335 printk(KERN_WARNING "videodev: \"%s\" has no release callback. "
336 "Please fix your driver for proper sysfs support, see "
337 "http://lwn.net/Articles/36850/\n", vfd->name);
338#endif
339 return 0;
340
341fail_minor:
342 mutex_lock(&videodev_lock);
343 video_device[vfd->minor] = NULL;
344 vfd->minor = -1;
345 mutex_unlock(&videodev_lock);
346 return ret;
347}
348EXPORT_SYMBOL(video_register_device_index);
349
350/**
351 * video_unregister_device - unregister a video4linux device
352 * @vfd: the device to unregister
353 *
354 * This unregisters the passed device and deassigns the minor
355 * number. Future open calls will be met with errors.
356 */
357
358void video_unregister_device(struct video_device *vfd)
359{
360 mutex_lock(&videodev_lock);
361 if (video_device[vfd->minor] != vfd)
362 panic("videodev: bad unregister");
363
364 video_device[vfd->minor] = NULL;
365 device_unregister(&vfd->dev);
366 mutex_unlock(&videodev_lock);
367}
368EXPORT_SYMBOL(video_unregister_device);
369
370/*
371 * Video fs operations
372 */
373static const struct file_operations video_fops = {
374 .owner = THIS_MODULE,
375 .llseek = no_llseek,
376 .open = video_open,
377};
378
379/*
380 * Initialise video for linux
381 */
382
383static int __init videodev_init(void)
384{
385 int ret;
386
387 printk(KERN_INFO "Linux video capture interface: v2.00\n");
388 if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, &video_fops)) {
389 printk(KERN_WARNING "video_dev: unable to get major %d\n", VIDEO_MAJOR);
390 return -EIO;
391 }
392
393 ret = class_register(&video_class);
394 if (ret < 0) {
395 unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME);
396 printk(KERN_WARNING "video_dev: class_register failed\n");
397 return -EIO;
398 }
399
400 return 0;
401}
402
403static void __exit videodev_exit(void)
404{
405 class_unregister(&video_class);
406 unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME);
407}
408
409module_init(videodev_init)
410module_exit(videodev_exit)
411
412MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>");
413MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2");
414MODULE_LICENSE("GPL");
415
416
417/*
418 * Local variables:
419 * c-basic-offset: 8
420 * End:
421 */
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
new file mode 100644
index 000000000000..56a4fdee9160
--- /dev/null
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -0,0 +1,1865 @@
1/*
2 * Video capture interface for Linux version 2
3 *
4 * A generic framework to process V4L2 ioctl commands.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * Authors: Alan Cox, <alan@redhat.com> (version 1)
12 * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2)
13 */
14
15#include <linux/module.h>
16#include <linux/types.h>
17#include <linux/kernel.h>
18
19#define __OLD_VIDIOC_ /* To allow fixing old calls */
20#include <linux/videodev2.h>
21
22#ifdef CONFIG_VIDEO_V4L1
23#include <linux/videodev.h>
24#endif
25#include <media/v4l2-common.h>
26#include <media/v4l2-ioctl.h>
27#include <linux/video_decoder.h>
28
29#define dbgarg(cmd, fmt, arg...) \
30 do { \
31 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \
32 printk(KERN_DEBUG "%s: ", vfd->name); \
33 v4l_printk_ioctl(cmd); \
34 printk(" " fmt, ## arg); \
35 } \
36 } while (0)
37
38#define dbgarg2(fmt, arg...) \
39 do { \
40 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \
41 printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\
42 } while (0)
43
44struct std_descr {
45 v4l2_std_id std;
46 const char *descr;
47};
48
49static const struct std_descr standards[] = {
50 { V4L2_STD_NTSC, "NTSC" },
51 { V4L2_STD_NTSC_M, "NTSC-M" },
52 { V4L2_STD_NTSC_M_JP, "NTSC-M-JP" },
53 { V4L2_STD_NTSC_M_KR, "NTSC-M-KR" },
54 { V4L2_STD_NTSC_443, "NTSC-443" },
55 { V4L2_STD_PAL, "PAL" },
56 { V4L2_STD_PAL_BG, "PAL-BG" },
57 { V4L2_STD_PAL_B, "PAL-B" },
58 { V4L2_STD_PAL_B1, "PAL-B1" },
59 { V4L2_STD_PAL_G, "PAL-G" },
60 { V4L2_STD_PAL_H, "PAL-H" },
61 { V4L2_STD_PAL_I, "PAL-I" },
62 { V4L2_STD_PAL_DK, "PAL-DK" },
63 { V4L2_STD_PAL_D, "PAL-D" },
64 { V4L2_STD_PAL_D1, "PAL-D1" },
65 { V4L2_STD_PAL_K, "PAL-K" },
66 { V4L2_STD_PAL_M, "PAL-M" },
67 { V4L2_STD_PAL_N, "PAL-N" },
68 { V4L2_STD_PAL_Nc, "PAL-Nc" },
69 { V4L2_STD_PAL_60, "PAL-60" },
70 { V4L2_STD_SECAM, "SECAM" },
71 { V4L2_STD_SECAM_B, "SECAM-B" },
72 { V4L2_STD_SECAM_G, "SECAM-G" },
73 { V4L2_STD_SECAM_H, "SECAM-H" },
74 { V4L2_STD_SECAM_DK, "SECAM-DK" },
75 { V4L2_STD_SECAM_D, "SECAM-D" },
76 { V4L2_STD_SECAM_K, "SECAM-K" },
77 { V4L2_STD_SECAM_K1, "SECAM-K1" },
78 { V4L2_STD_SECAM_L, "SECAM-L" },
79 { V4L2_STD_SECAM_LC, "SECAM-Lc" },
80 { 0, "Unknown" }
81};
82
83/* video4linux standard ID conversion to standard name
84 */
85const char *v4l2_norm_to_name(v4l2_std_id id)
86{
87 u32 myid = id;
88 int i;
89
90 /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
91 64 bit comparations. So, on that architecture, with some gcc
92 variants, compilation fails. Currently, the max value is 30bit wide.
93 */
94 BUG_ON(myid != id);
95
96 for (i = 0; standards[i].std; i++)
97 if (myid == standards[i].std)
98 break;
99 return standards[i].descr;
100}
101EXPORT_SYMBOL(v4l2_norm_to_name);
102
103/* Fill in the fields of a v4l2_standard structure according to the
104 'id' and 'transmission' parameters. Returns negative on error. */
105int v4l2_video_std_construct(struct v4l2_standard *vs,
106 int id, const char *name)
107{
108 u32 index = vs->index;
109
110 memset(vs, 0, sizeof(struct v4l2_standard));
111 vs->index = index;
112 vs->id = id;
113 if (id & V4L2_STD_525_60) {
114 vs->frameperiod.numerator = 1001;
115 vs->frameperiod.denominator = 30000;
116 vs->framelines = 525;
117 } else {
118 vs->frameperiod.numerator = 1;
119 vs->frameperiod.denominator = 25;
120 vs->framelines = 625;
121 }
122 strlcpy(vs->name, name, sizeof(vs->name));
123 return 0;
124}
125EXPORT_SYMBOL(v4l2_video_std_construct);
126
127/* ----------------------------------------------------------------- */
128/* some arrays for pretty-printing debug messages of enum types */
129
130const char *v4l2_field_names[] = {
131 [V4L2_FIELD_ANY] = "any",
132 [V4L2_FIELD_NONE] = "none",
133 [V4L2_FIELD_TOP] = "top",
134 [V4L2_FIELD_BOTTOM] = "bottom",
135 [V4L2_FIELD_INTERLACED] = "interlaced",
136 [V4L2_FIELD_SEQ_TB] = "seq-tb",
137 [V4L2_FIELD_SEQ_BT] = "seq-bt",
138 [V4L2_FIELD_ALTERNATE] = "alternate",
139 [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
140 [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
141};
142EXPORT_SYMBOL(v4l2_field_names);
143
144const char *v4l2_type_names[] = {
145 [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "vid-cap",
146 [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "vid-overlay",
147 [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "vid-out",
148 [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
149 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
150 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap",
151 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
152 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "vid-out-overlay",
153};
154EXPORT_SYMBOL(v4l2_type_names);
155
156static const char *v4l2_memory_names[] = {
157 [V4L2_MEMORY_MMAP] = "mmap",
158 [V4L2_MEMORY_USERPTR] = "userptr",
159 [V4L2_MEMORY_OVERLAY] = "overlay",
160};
161
162#define prt_names(a, arr) ((((a) >= 0) && ((a) < ARRAY_SIZE(arr))) ? \
163 arr[a] : "unknown")
164
165/* ------------------------------------------------------------------ */
166/* debug help functions */
167
168#ifdef CONFIG_VIDEO_V4L1_COMPAT
169static const char *v4l1_ioctls[] = {
170 [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP",
171 [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN",
172 [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN",
173 [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER",
174 [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER",
175 [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT",
176 [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT",
177 [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE",
178 [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN",
179 [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN",
180 [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF",
181 [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF",
182 [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY",
183 [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ",
184 [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ",
185 [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO",
186 [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO",
187 [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC",
188 [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE",
189 [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF",
190 [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT",
191 [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE",
192 [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE",
193 [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE",
194 [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE",
195 [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO",
196 [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE",
197 [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT",
198 [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT"
199};
200#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
201#endif
202
203static const char *v4l2_ioctls[] = {
204 [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP",
205 [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED",
206 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
207 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
208 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
209 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
210 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
211 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
212 [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF",
213 [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY",
214 [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF",
215 [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF",
216 [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON",
217 [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF",
218 [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM",
219 [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM",
220 [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD",
221 [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD",
222 [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD",
223 [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT",
224 [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL",
225 [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL",
226 [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER",
227 [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER",
228 [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO",
229 [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO",
230 [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL",
231 [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU",
232 [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT",
233 [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT",
234 [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT",
235 [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT",
236 [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT",
237 [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT",
238 [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT",
239 [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR",
240 [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR",
241 [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY",
242 [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY",
243 [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP",
244 [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP",
245 [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP",
246 [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP",
247 [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP",
248 [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD",
249 [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT",
250 [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO",
251 [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT",
252 [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY",
253 [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY",
254 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
255 [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS",
256 [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS",
257 [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS",
258 [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS",
259#if 1
260 [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES",
261 [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS",
262 [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX",
263 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
264 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",
265
266 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
267 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
268
269 [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT",
270 [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK",
271#endif
272};
273#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
274
275static const char *v4l2_int_ioctls[] = {
276#ifdef CONFIG_VIDEO_V4L1_COMPAT
277 [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES",
278 [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS",
279 [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM",
280 [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT",
281 [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT",
282 [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT",
283 [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE",
284 [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO",
285 [_IOC_NR(DECODER_INIT)] = "DECODER_INIT",
286 [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS",
287 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
288#endif
289 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
290
291 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
292 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
293 [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG",
294
295 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
296 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
297 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
298 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE",
299 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
300 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
301 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
302 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
303 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
304 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
305 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
306 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING",
307 [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ",
308 [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT",
309 [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT",
310 [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT",
311};
312#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
313
314/* Common ioctl debug function. This function can be used by
315 external ioctl messages as well as internal V4L ioctl */
316void v4l_printk_ioctl(unsigned int cmd)
317{
318 char *dir, *type;
319
320 switch (_IOC_TYPE(cmd)) {
321 case 'd':
322 if (_IOC_NR(cmd) >= V4L2_INT_IOCTLS) {
323 type = "v4l2_int";
324 break;
325 }
326 printk("%s", v4l2_int_ioctls[_IOC_NR(cmd)]);
327 return;
328#ifdef CONFIG_VIDEO_V4L1_COMPAT
329 case 'v':
330 if (_IOC_NR(cmd) >= V4L1_IOCTLS) {
331 type = "v4l1";
332 break;
333 }
334 printk("%s", v4l1_ioctls[_IOC_NR(cmd)]);
335 return;
336#endif
337 case 'V':
338 if (_IOC_NR(cmd) >= V4L2_IOCTLS) {
339 type = "v4l2";
340 break;
341 }
342 printk("%s", v4l2_ioctls[_IOC_NR(cmd)]);
343 return;
344 default:
345 type = "unknown";
346 }
347
348 switch (_IOC_DIR(cmd)) {
349 case _IOC_NONE: dir = "--"; break;
350 case _IOC_READ: dir = "r-"; break;
351 case _IOC_WRITE: dir = "-w"; break;
352 case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
353 default: dir = "*ERR*"; break;
354 }
355 printk("%s ioctl '%c', dir=%s, #%d (0x%08x)",
356 type, _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd);
357}
358EXPORT_SYMBOL(v4l_printk_ioctl);
359
360/*
361 * helper function -- handles userspace copying for ioctl arguments
362 */
363
364#ifdef __OLD_VIDIOC_
365static unsigned int
366video_fix_command(unsigned int cmd)
367{
368 switch (cmd) {
369 case VIDIOC_OVERLAY_OLD:
370 cmd = VIDIOC_OVERLAY;
371 break;
372 case VIDIOC_S_PARM_OLD:
373 cmd = VIDIOC_S_PARM;
374 break;
375 case VIDIOC_S_CTRL_OLD:
376 cmd = VIDIOC_S_CTRL;
377 break;
378 case VIDIOC_G_AUDIO_OLD:
379 cmd = VIDIOC_G_AUDIO;
380 break;
381 case VIDIOC_G_AUDOUT_OLD:
382 cmd = VIDIOC_G_AUDOUT;
383 break;
384 case VIDIOC_CROPCAP_OLD:
385 cmd = VIDIOC_CROPCAP;
386 break;
387 }
388 return cmd;
389}
390#endif
391
392/*
393 * Obsolete usercopy function - Should be removed soon
394 */
395int
396video_usercopy(struct inode *inode, struct file *file,
397 unsigned int cmd, unsigned long arg,
398 int (*func)(struct inode *inode, struct file *file,
399 unsigned int cmd, void *arg))
400{
401 char sbuf[128];
402 void *mbuf = NULL;
403 void *parg = NULL;
404 int err = -EINVAL;
405 int is_ext_ctrl;
406 size_t ctrls_size = 0;
407 void __user *user_ptr = NULL;
408
409#ifdef __OLD_VIDIOC_
410 cmd = video_fix_command(cmd);
411#endif
412 is_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||
413 cmd == VIDIOC_TRY_EXT_CTRLS);
414
415 /* Copy arguments into temp kernel buffer */
416 switch (_IOC_DIR(cmd)) {
417 case _IOC_NONE:
418 parg = NULL;
419 break;
420 case _IOC_READ:
421 case _IOC_WRITE:
422 case (_IOC_WRITE | _IOC_READ):
423 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
424 parg = sbuf;
425 } else {
426 /* too big to allocate from stack */
427 mbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
428 if (NULL == mbuf)
429 return -ENOMEM;
430 parg = mbuf;
431 }
432
433 err = -EFAULT;
434 if (_IOC_DIR(cmd) & _IOC_WRITE)
435 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
436 goto out;
437 break;
438 }
439 if (is_ext_ctrl) {
440 struct v4l2_ext_controls *p = parg;
441
442 /* In case of an error, tell the caller that it wasn't
443 a specific control that caused it. */
444 p->error_idx = p->count;
445 user_ptr = (void __user *)p->controls;
446 if (p->count) {
447 ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
448 /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
449 mbuf = kmalloc(ctrls_size, GFP_KERNEL);
450 err = -ENOMEM;
451 if (NULL == mbuf)
452 goto out_ext_ctrl;
453 err = -EFAULT;
454 if (copy_from_user(mbuf, user_ptr, ctrls_size))
455 goto out_ext_ctrl;
456 p->controls = mbuf;
457 }
458 }
459
460 /* call driver */
461 err = func(inode, file, cmd, parg);
462 if (err == -ENOIOCTLCMD)
463 err = -EINVAL;
464 if (is_ext_ctrl) {
465 struct v4l2_ext_controls *p = parg;
466
467 p->controls = (void *)user_ptr;
468 if (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))
469 err = -EFAULT;
470 goto out_ext_ctrl;
471 }
472 if (err < 0)
473 goto out;
474
475out_ext_ctrl:
476 /* Copy results into user buffer */
477 switch (_IOC_DIR(cmd)) {
478 case _IOC_READ:
479 case (_IOC_WRITE | _IOC_READ):
480 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
481 err = -EFAULT;
482 break;
483 }
484
485out:
486 kfree(mbuf);
487 return err;
488}
489EXPORT_SYMBOL(video_usercopy);
490
491static void dbgbuf(unsigned int cmd, struct video_device *vfd,
492 struct v4l2_buffer *p)
493{
494 struct v4l2_timecode *tc = &p->timecode;
495
496 dbgarg(cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, "
497 "bytesused=%d, flags=0x%08d, "
498 "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx, length=%d\n",
499 p->timestamp.tv_sec / 3600,
500 (int)(p->timestamp.tv_sec / 60) % 60,
501 (int)(p->timestamp.tv_sec % 60),
502 p->timestamp.tv_usec,
503 p->index,
504 prt_names(p->type, v4l2_type_names),
505 p->bytesused, p->flags,
506 p->field, p->sequence,
507 prt_names(p->memory, v4l2_memory_names),
508 p->m.userptr, p->length);
509 dbgarg2("timecode=%02d:%02d:%02d type=%d, "
510 "flags=0x%08d, frames=%d, userbits=0x%08x\n",
511 tc->hours, tc->minutes, tc->seconds,
512 tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits);
513}
514
515static inline void dbgrect(struct video_device *vfd, char *s,
516 struct v4l2_rect *r)
517{
518 dbgarg2("%sRect start at %dx%d, size=%dx%d\n", s, r->left, r->top,
519 r->width, r->height);
520};
521
522static inline void v4l_print_pix_fmt(struct video_device *vfd,
523 struct v4l2_pix_format *fmt)
524{
525 dbgarg2("width=%d, height=%d, format=%c%c%c%c, field=%s, "
526 "bytesperline=%d sizeimage=%d, colorspace=%d\n",
527 fmt->width, fmt->height,
528 (fmt->pixelformat & 0xff),
529 (fmt->pixelformat >> 8) & 0xff,
530 (fmt->pixelformat >> 16) & 0xff,
531 (fmt->pixelformat >> 24) & 0xff,
532 prt_names(fmt->field, v4l2_field_names),
533 fmt->bytesperline, fmt->sizeimage, fmt->colorspace);
534};
535
536static inline void v4l_print_ext_ctrls(unsigned int cmd,
537 struct video_device *vfd, struct v4l2_ext_controls *c, int show_vals)
538{
539 __u32 i;
540
541 if (!(vfd->debug & V4L2_DEBUG_IOCTL_ARG))
542 return;
543 dbgarg(cmd, "");
544 printk(KERN_CONT "class=0x%x", c->ctrl_class);
545 for (i = 0; i < c->count; i++) {
546 if (show_vals)
547 printk(KERN_CONT " id/val=0x%x/0x%x",
548 c->controls[i].id, c->controls[i].value);
549 else
550 printk(KERN_CONT " id=0x%x", c->controls[i].id);
551 }
552 printk(KERN_CONT "\n");
553};
554
555static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv)
556{
557 __u32 i;
558
559 /* zero the reserved fields */
560 c->reserved[0] = c->reserved[1] = 0;
561 for (i = 0; i < c->count; i++) {
562 c->controls[i].reserved2[0] = 0;
563 c->controls[i].reserved2[1] = 0;
564 }
565 /* V4L2_CID_PRIVATE_BASE cannot be used as control class
566 when using extended controls.
567 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL
568 is it allowed for backwards compatibility.
569 */
570 if (!allow_priv && c->ctrl_class == V4L2_CID_PRIVATE_BASE)
571 return 0;
572 /* Check that all controls are from the same control class. */
573 for (i = 0; i < c->count; i++) {
574 if (V4L2_CTRL_ID2CLASS(c->controls[i].id) != c->ctrl_class) {
575 c->error_idx = i;
576 return 0;
577 }
578 }
579 return 1;
580}
581
582static int check_fmt(struct video_device *vfd, enum v4l2_buf_type type)
583{
584 switch (type) {
585 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
586 if (vfd->vidioc_try_fmt_vid_cap)
587 return 0;
588 break;
589 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
590 if (vfd->vidioc_try_fmt_vid_overlay)
591 return 0;
592 break;
593 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
594 if (vfd->vidioc_try_fmt_vid_out)
595 return 0;
596 break;
597 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
598 if (vfd->vidioc_try_fmt_vid_out_overlay)
599 return 0;
600 break;
601 case V4L2_BUF_TYPE_VBI_CAPTURE:
602 if (vfd->vidioc_try_fmt_vbi_cap)
603 return 0;
604 break;
605 case V4L2_BUF_TYPE_VBI_OUTPUT:
606 if (vfd->vidioc_try_fmt_vbi_out)
607 return 0;
608 break;
609 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
610 if (vfd->vidioc_try_fmt_sliced_vbi_cap)
611 return 0;
612 break;
613 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
614 if (vfd->vidioc_try_fmt_sliced_vbi_out)
615 return 0;
616 break;
617 case V4L2_BUF_TYPE_PRIVATE:
618 if (vfd->vidioc_try_fmt_type_private)
619 return 0;
620 break;
621 }
622 return -EINVAL;
623}
624
625static int __video_do_ioctl(struct inode *inode, struct file *file,
626 unsigned int cmd, void *arg)
627{
628 struct video_device *vfd = video_devdata(file);
629 void *fh = file->private_data;
630 int ret = -EINVAL;
631
632 if ((vfd->debug & V4L2_DEBUG_IOCTL) &&
633 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
634 v4l_print_ioctl(vfd->name, cmd);
635 printk(KERN_CONT "\n");
636 }
637
638#ifdef CONFIG_VIDEO_V4L1_COMPAT
639 /***********************************************************
640 Handles calls to the obsoleted V4L1 API
641 Due to the nature of VIDIOCGMBUF, each driver that supports
642 V4L1 should implement its own handler for this ioctl.
643 ***********************************************************/
644
645 /* --- streaming capture ------------------------------------- */
646 if (cmd == VIDIOCGMBUF) {
647 struct video_mbuf *p = arg;
648
649 memset(p, 0, sizeof(*p));
650
651 if (!vfd->vidiocgmbuf)
652 return ret;
653 ret = vfd->vidiocgmbuf(file, fh, p);
654 if (!ret)
655 dbgarg(cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
656 p->size, p->frames,
657 (unsigned long)p->offsets);
658 return ret;
659 }
660
661 /********************************************************
662 All other V4L1 calls are handled by v4l1_compat module.
663 Those calls will be translated into V4L2 calls, and
664 __video_do_ioctl will be called again, with one or more
665 V4L2 ioctls.
666 ********************************************************/
667 if (_IOC_TYPE(cmd) == 'v')
668 return v4l_compat_translate_ioctl(inode, file, cmd, arg,
669 __video_do_ioctl);
670#endif
671
672 switch (cmd) {
673 /* --- capabilities ------------------------------------------ */
674 case VIDIOC_QUERYCAP:
675 {
676 struct v4l2_capability *cap = (struct v4l2_capability *)arg;
677 memset(cap, 0, sizeof(*cap));
678
679 if (!vfd->vidioc_querycap)
680 break;
681
682 ret = vfd->vidioc_querycap(file, fh, cap);
683 if (!ret)
684 dbgarg(cmd, "driver=%s, card=%s, bus=%s, "
685 "version=0x%08x, "
686 "capabilities=0x%08x\n",
687 cap->driver, cap->card, cap->bus_info,
688 cap->version,
689 cap->capabilities);
690 break;
691 }
692
693 /* --- priority ------------------------------------------ */
694 case VIDIOC_G_PRIORITY:
695 {
696 enum v4l2_priority *p = arg;
697
698 if (!vfd->vidioc_g_priority)
699 break;
700 ret = vfd->vidioc_g_priority(file, fh, p);
701 if (!ret)
702 dbgarg(cmd, "priority is %d\n", *p);
703 break;
704 }
705 case VIDIOC_S_PRIORITY:
706 {
707 enum v4l2_priority *p = arg;
708
709 if (!vfd->vidioc_s_priority)
710 break;
711 dbgarg(cmd, "setting priority to %d\n", *p);
712 ret = vfd->vidioc_s_priority(file, fh, *p);
713 break;
714 }
715
716 /* --- capture ioctls ---------------------------------------- */
717 case VIDIOC_ENUM_FMT:
718 {
719 struct v4l2_fmtdesc *f = arg;
720 enum v4l2_buf_type type;
721 unsigned int index;
722
723 index = f->index;
724 type = f->type;
725 memset(f, 0, sizeof(*f));
726 f->index = index;
727 f->type = type;
728
729 switch (type) {
730 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
731 if (vfd->vidioc_enum_fmt_vid_cap)
732 ret = vfd->vidioc_enum_fmt_vid_cap(file, fh, f);
733 break;
734 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
735 if (vfd->vidioc_enum_fmt_vid_overlay)
736 ret = vfd->vidioc_enum_fmt_vid_overlay(file,
737 fh, f);
738 break;
739#if 1
740 /* V4L2_BUF_TYPE_VBI_CAPTURE should not support VIDIOC_ENUM_FMT
741 * according to the spec. The bttv and saa7134 drivers support
742 * it though, so just warn that this is deprecated and will be
743 * removed in the near future. */
744 case V4L2_BUF_TYPE_VBI_CAPTURE:
745 if (vfd->vidioc_enum_fmt_vbi_cap) {
746 printk(KERN_WARNING "vidioc_enum_fmt_vbi_cap will be removed in 2.6.28!\n");
747 ret = vfd->vidioc_enum_fmt_vbi_cap(file, fh, f);
748 }
749 break;
750#endif
751 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
752 if (vfd->vidioc_enum_fmt_vid_out)
753 ret = vfd->vidioc_enum_fmt_vid_out(file, fh, f);
754 break;
755 case V4L2_BUF_TYPE_PRIVATE:
756 if (vfd->vidioc_enum_fmt_type_private)
757 ret = vfd->vidioc_enum_fmt_type_private(file,
758 fh, f);
759 break;
760 default:
761 break;
762 }
763 if (!ret)
764 dbgarg(cmd, "index=%d, type=%d, flags=%d, "
765 "pixelformat=%c%c%c%c, description='%s'\n",
766 f->index, f->type, f->flags,
767 (f->pixelformat & 0xff),
768 (f->pixelformat >> 8) & 0xff,
769 (f->pixelformat >> 16) & 0xff,
770 (f->pixelformat >> 24) & 0xff,
771 f->description);
772 break;
773 }
774 case VIDIOC_G_FMT:
775 {
776 struct v4l2_format *f = (struct v4l2_format *)arg;
777
778 memset(f->fmt.raw_data, 0, sizeof(f->fmt.raw_data));
779
780 /* FIXME: Should be one dump per type */
781 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names));
782
783 switch (f->type) {
784 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
785 if (vfd->vidioc_g_fmt_vid_cap)
786 ret = vfd->vidioc_g_fmt_vid_cap(file, fh, f);
787 if (!ret)
788 v4l_print_pix_fmt(vfd, &f->fmt.pix);
789 break;
790 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
791 if (vfd->vidioc_g_fmt_vid_overlay)
792 ret = vfd->vidioc_g_fmt_vid_overlay(file,
793 fh, f);
794 break;
795 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
796 if (vfd->vidioc_g_fmt_vid_out)
797 ret = vfd->vidioc_g_fmt_vid_out(file, fh, f);
798 if (!ret)
799 v4l_print_pix_fmt(vfd, &f->fmt.pix);
800 break;
801 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
802 if (vfd->vidioc_g_fmt_vid_out_overlay)
803 ret = vfd->vidioc_g_fmt_vid_out_overlay(file,
804 fh, f);
805 break;
806 case V4L2_BUF_TYPE_VBI_CAPTURE:
807 if (vfd->vidioc_g_fmt_vbi_cap)
808 ret = vfd->vidioc_g_fmt_vbi_cap(file, fh, f);
809 break;
810 case V4L2_BUF_TYPE_VBI_OUTPUT:
811 if (vfd->vidioc_g_fmt_vbi_out)
812 ret = vfd->vidioc_g_fmt_vbi_out(file, fh, f);
813 break;
814 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
815 if (vfd->vidioc_g_fmt_sliced_vbi_cap)
816 ret = vfd->vidioc_g_fmt_sliced_vbi_cap(file,
817 fh, f);
818 break;
819 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
820 if (vfd->vidioc_g_fmt_sliced_vbi_out)
821 ret = vfd->vidioc_g_fmt_sliced_vbi_out(file,
822 fh, f);
823 break;
824 case V4L2_BUF_TYPE_PRIVATE:
825 if (vfd->vidioc_g_fmt_type_private)
826 ret = vfd->vidioc_g_fmt_type_private(file,
827 fh, f);
828 break;
829 }
830
831 break;
832 }
833 case VIDIOC_S_FMT:
834 {
835 struct v4l2_format *f = (struct v4l2_format *)arg;
836
837 /* FIXME: Should be one dump per type */
838 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names));
839
840 switch (f->type) {
841 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
842 v4l_print_pix_fmt(vfd, &f->fmt.pix);
843 if (vfd->vidioc_s_fmt_vid_cap)
844 ret = vfd->vidioc_s_fmt_vid_cap(file, fh, f);
845 break;
846 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
847 if (vfd->vidioc_s_fmt_vid_overlay)
848 ret = vfd->vidioc_s_fmt_vid_overlay(file,
849 fh, f);
850 break;
851 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
852 v4l_print_pix_fmt(vfd, &f->fmt.pix);
853 if (vfd->vidioc_s_fmt_vid_out)
854 ret = vfd->vidioc_s_fmt_vid_out(file, fh, f);
855 break;
856 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
857 if (vfd->vidioc_s_fmt_vid_out_overlay)
858 ret = vfd->vidioc_s_fmt_vid_out_overlay(file,
859 fh, f);
860 break;
861 case V4L2_BUF_TYPE_VBI_CAPTURE:
862 if (vfd->vidioc_s_fmt_vbi_cap)
863 ret = vfd->vidioc_s_fmt_vbi_cap(file, fh, f);
864 break;
865 case V4L2_BUF_TYPE_VBI_OUTPUT:
866 if (vfd->vidioc_s_fmt_vbi_out)
867 ret = vfd->vidioc_s_fmt_vbi_out(file, fh, f);
868 break;
869 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
870 if (vfd->vidioc_s_fmt_sliced_vbi_cap)
871 ret = vfd->vidioc_s_fmt_sliced_vbi_cap(file,
872 fh, f);
873 break;
874 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
875 if (vfd->vidioc_s_fmt_sliced_vbi_out)
876 ret = vfd->vidioc_s_fmt_sliced_vbi_out(file,
877 fh, f);
878 break;
879 case V4L2_BUF_TYPE_PRIVATE:
880 if (vfd->vidioc_s_fmt_type_private)
881 ret = vfd->vidioc_s_fmt_type_private(file,
882 fh, f);
883 break;
884 }
885 break;
886 }
887 case VIDIOC_TRY_FMT:
888 {
889 struct v4l2_format *f = (struct v4l2_format *)arg;
890
891 /* FIXME: Should be one dump per type */
892 dbgarg(cmd, "type=%s\n", prt_names(f->type,
893 v4l2_type_names));
894 switch (f->type) {
895 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
896 if (vfd->vidioc_try_fmt_vid_cap)
897 ret = vfd->vidioc_try_fmt_vid_cap(file, fh, f);
898 if (!ret)
899 v4l_print_pix_fmt(vfd, &f->fmt.pix);
900 break;
901 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
902 if (vfd->vidioc_try_fmt_vid_overlay)
903 ret = vfd->vidioc_try_fmt_vid_overlay(file,
904 fh, f);
905 break;
906 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
907 if (vfd->vidioc_try_fmt_vid_out)
908 ret = vfd->vidioc_try_fmt_vid_out(file, fh, f);
909 if (!ret)
910 v4l_print_pix_fmt(vfd, &f->fmt.pix);
911 break;
912 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
913 if (vfd->vidioc_try_fmt_vid_out_overlay)
914 ret = vfd->vidioc_try_fmt_vid_out_overlay(file,
915 fh, f);
916 break;
917 case V4L2_BUF_TYPE_VBI_CAPTURE:
918 if (vfd->vidioc_try_fmt_vbi_cap)
919 ret = vfd->vidioc_try_fmt_vbi_cap(file, fh, f);
920 break;
921 case V4L2_BUF_TYPE_VBI_OUTPUT:
922 if (vfd->vidioc_try_fmt_vbi_out)
923 ret = vfd->vidioc_try_fmt_vbi_out(file, fh, f);
924 break;
925 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
926 if (vfd->vidioc_try_fmt_sliced_vbi_cap)
927 ret = vfd->vidioc_try_fmt_sliced_vbi_cap(file,
928 fh, f);
929 break;
930 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
931 if (vfd->vidioc_try_fmt_sliced_vbi_out)
932 ret = vfd->vidioc_try_fmt_sliced_vbi_out(file,
933 fh, f);
934 break;
935 case V4L2_BUF_TYPE_PRIVATE:
936 if (vfd->vidioc_try_fmt_type_private)
937 ret = vfd->vidioc_try_fmt_type_private(file,
938 fh, f);
939 break;
940 }
941
942 break;
943 }
944 /* FIXME: Those buf reqs could be handled here,
945 with some changes on videobuf to allow its header to be included at
946 videodev2.h or being merged at videodev2.
947 */
948 case VIDIOC_REQBUFS:
949 {
950 struct v4l2_requestbuffers *p = arg;
951
952 if (!vfd->vidioc_reqbufs)
953 break;
954 ret = check_fmt(vfd, p->type);
955 if (ret)
956 break;
957
958 ret = vfd->vidioc_reqbufs(file, fh, p);
959 dbgarg(cmd, "count=%d, type=%s, memory=%s\n",
960 p->count,
961 prt_names(p->type, v4l2_type_names),
962 prt_names(p->memory, v4l2_memory_names));
963 break;
964 }
965 case VIDIOC_QUERYBUF:
966 {
967 struct v4l2_buffer *p = arg;
968
969 if (!vfd->vidioc_querybuf)
970 break;
971 ret = check_fmt(vfd, p->type);
972 if (ret)
973 break;
974
975 ret = vfd->vidioc_querybuf(file, fh, p);
976 if (!ret)
977 dbgbuf(cmd, vfd, p);
978 break;
979 }
980 case VIDIOC_QBUF:
981 {
982 struct v4l2_buffer *p = arg;
983
984 if (!vfd->vidioc_qbuf)
985 break;
986 ret = check_fmt(vfd, p->type);
987 if (ret)
988 break;
989
990 ret = vfd->vidioc_qbuf(file, fh, p);
991 if (!ret)
992 dbgbuf(cmd, vfd, p);
993 break;
994 }
995 case VIDIOC_DQBUF:
996 {
997 struct v4l2_buffer *p = arg;
998
999 if (!vfd->vidioc_dqbuf)
1000 break;
1001 ret = check_fmt(vfd, p->type);
1002 if (ret)
1003 break;
1004
1005 ret = vfd->vidioc_dqbuf(file, fh, p);
1006 if (!ret)
1007 dbgbuf(cmd, vfd, p);
1008 break;
1009 }
1010 case VIDIOC_OVERLAY:
1011 {
1012 int *i = arg;
1013
1014 if (!vfd->vidioc_overlay)
1015 break;
1016 dbgarg(cmd, "value=%d\n", *i);
1017 ret = vfd->vidioc_overlay(file, fh, *i);
1018 break;
1019 }
1020 case VIDIOC_G_FBUF:
1021 {
1022 struct v4l2_framebuffer *p = arg;
1023
1024 if (!vfd->vidioc_g_fbuf)
1025 break;
1026 ret = vfd->vidioc_g_fbuf(file, fh, arg);
1027 if (!ret) {
1028 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
1029 p->capability, p->flags,
1030 (unsigned long)p->base);
1031 v4l_print_pix_fmt(vfd, &p->fmt);
1032 }
1033 break;
1034 }
1035 case VIDIOC_S_FBUF:
1036 {
1037 struct v4l2_framebuffer *p = arg;
1038
1039 if (!vfd->vidioc_s_fbuf)
1040 break;
1041 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
1042 p->capability, p->flags, (unsigned long)p->base);
1043 v4l_print_pix_fmt(vfd, &p->fmt);
1044 ret = vfd->vidioc_s_fbuf(file, fh, arg);
1045 break;
1046 }
1047 case VIDIOC_STREAMON:
1048 {
1049 enum v4l2_buf_type i = *(int *)arg;
1050
1051 if (!vfd->vidioc_streamon)
1052 break;
1053 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
1054 ret = vfd->vidioc_streamon(file, fh, i);
1055 break;
1056 }
1057 case VIDIOC_STREAMOFF:
1058 {
1059 enum v4l2_buf_type i = *(int *)arg;
1060
1061 if (!vfd->vidioc_streamoff)
1062 break;
1063 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
1064 ret = vfd->vidioc_streamoff(file, fh, i);
1065 break;
1066 }
1067 /* ---------- tv norms ---------- */
1068 case VIDIOC_ENUMSTD:
1069 {
1070 struct v4l2_standard *p = arg;
1071 v4l2_std_id id = vfd->tvnorms, curr_id = 0;
1072 unsigned int index = p->index, i, j = 0;
1073 const char *descr = "";
1074
1075 /* Return norm array in a canonical way */
1076 for (i = 0; i <= index && id; i++) {
1077 /* last std value in the standards array is 0, so this
1078 while always ends there since (id & 0) == 0. */
1079 while ((id & standards[j].std) != standards[j].std)
1080 j++;
1081 curr_id = standards[j].std;
1082 descr = standards[j].descr;
1083 j++;
1084 if (curr_id == 0)
1085 break;
1086 if (curr_id != V4L2_STD_PAL &&
1087 curr_id != V4L2_STD_SECAM &&
1088 curr_id != V4L2_STD_NTSC)
1089 id &= ~curr_id;
1090 }
1091 if (i <= index)
1092 return -EINVAL;
1093
1094 v4l2_video_std_construct(p, curr_id, descr);
1095 p->index = index;
1096
1097 dbgarg(cmd, "index=%d, id=0x%Lx, name=%s, fps=%d/%d, "
1098 "framelines=%d\n", p->index,
1099 (unsigned long long)p->id, p->name,
1100 p->frameperiod.numerator,
1101 p->frameperiod.denominator,
1102 p->framelines);
1103
1104 ret = 0;
1105 break;
1106 }
1107 case VIDIOC_G_STD:
1108 {
1109 v4l2_std_id *id = arg;
1110
1111 ret = 0;
1112 /* Calls the specific handler */
1113 if (vfd->vidioc_g_std)
1114 ret = vfd->vidioc_g_std(file, fh, id);
1115 else
1116 *id = vfd->current_norm;
1117
1118 if (!ret)
1119 dbgarg(cmd, "std=0x%08Lx\n", (long long unsigned)*id);
1120 break;
1121 }
1122 case VIDIOC_S_STD:
1123 {
1124 v4l2_std_id *id = arg, norm;
1125
1126 dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id);
1127
1128 norm = (*id) & vfd->tvnorms;
1129 if (vfd->tvnorms && !norm) /* Check if std is supported */
1130 break;
1131
1132 /* Calls the specific handler */
1133 if (vfd->vidioc_s_std)
1134 ret = vfd->vidioc_s_std(file, fh, &norm);
1135 else
1136 ret = -EINVAL;
1137
1138 /* Updates standard information */
1139 if (ret >= 0)
1140 vfd->current_norm = norm;
1141 break;
1142 }
1143 case VIDIOC_QUERYSTD:
1144 {
1145 v4l2_std_id *p = arg;
1146
1147 if (!vfd->vidioc_querystd)
1148 break;
1149 ret = vfd->vidioc_querystd(file, fh, arg);
1150 if (!ret)
1151 dbgarg(cmd, "detected std=%08Lx\n",
1152 (unsigned long long)*p);
1153 break;
1154 }
1155 /* ------ input switching ---------- */
1156 /* FIXME: Inputs can be handled inside videodev2 */
1157 case VIDIOC_ENUMINPUT:
1158 {
1159 struct v4l2_input *p = arg;
1160 int i = p->index;
1161
1162 if (!vfd->vidioc_enum_input)
1163 break;
1164 memset(p, 0, sizeof(*p));
1165 p->index = i;
1166
1167 ret = vfd->vidioc_enum_input(file, fh, p);
1168 if (!ret)
1169 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1170 "audioset=%d, "
1171 "tuner=%d, std=%08Lx, status=%d\n",
1172 p->index, p->name, p->type, p->audioset,
1173 p->tuner,
1174 (unsigned long long)p->std,
1175 p->status);
1176 break;
1177 }
1178 case VIDIOC_G_INPUT:
1179 {
1180 unsigned int *i = arg;
1181
1182 if (!vfd->vidioc_g_input)
1183 break;
1184 ret = vfd->vidioc_g_input(file, fh, i);
1185 if (!ret)
1186 dbgarg(cmd, "value=%d\n", *i);
1187 break;
1188 }
1189 case VIDIOC_S_INPUT:
1190 {
1191 unsigned int *i = arg;
1192
1193 if (!vfd->vidioc_s_input)
1194 break;
1195 dbgarg(cmd, "value=%d\n", *i);
1196 ret = vfd->vidioc_s_input(file, fh, *i);
1197 break;
1198 }
1199
1200 /* ------ output switching ---------- */
1201 case VIDIOC_ENUMOUTPUT:
1202 {
1203 struct v4l2_output *p = arg;
1204 int i = p->index;
1205
1206 if (!vfd->vidioc_enum_output)
1207 break;
1208 memset(p, 0, sizeof(*p));
1209 p->index = i;
1210
1211 ret = vfd->vidioc_enum_output(file, fh, p);
1212 if (!ret)
1213 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1214 "audioset=0x%x, "
1215 "modulator=%d, std=0x%08Lx\n",
1216 p->index, p->name, p->type, p->audioset,
1217 p->modulator, (unsigned long long)p->std);
1218 break;
1219 }
1220 case VIDIOC_G_OUTPUT:
1221 {
1222 unsigned int *i = arg;
1223
1224 if (!vfd->vidioc_g_output)
1225 break;
1226 ret = vfd->vidioc_g_output(file, fh, i);
1227 if (!ret)
1228 dbgarg(cmd, "value=%d\n", *i);
1229 break;
1230 }
1231 case VIDIOC_S_OUTPUT:
1232 {
1233 unsigned int *i = arg;
1234
1235 if (!vfd->vidioc_s_output)
1236 break;
1237 dbgarg(cmd, "value=%d\n", *i);
1238 ret = vfd->vidioc_s_output(file, fh, *i);
1239 break;
1240 }
1241
1242 /* --- controls ---------------------------------------------- */
1243 case VIDIOC_QUERYCTRL:
1244 {
1245 struct v4l2_queryctrl *p = arg;
1246
1247 if (!vfd->vidioc_queryctrl)
1248 break;
1249 ret = vfd->vidioc_queryctrl(file, fh, p);
1250 if (!ret)
1251 dbgarg(cmd, "id=0x%x, type=%d, name=%s, min/max=%d/%d, "
1252 "step=%d, default=%d, flags=0x%08x\n",
1253 p->id, p->type, p->name,
1254 p->minimum, p->maximum,
1255 p->step, p->default_value, p->flags);
1256 else
1257 dbgarg(cmd, "id=0x%x\n", p->id);
1258 break;
1259 }
1260 case VIDIOC_G_CTRL:
1261 {
1262 struct v4l2_control *p = arg;
1263
1264 if (vfd->vidioc_g_ctrl)
1265 ret = vfd->vidioc_g_ctrl(file, fh, p);
1266 else if (vfd->vidioc_g_ext_ctrls) {
1267 struct v4l2_ext_controls ctrls;
1268 struct v4l2_ext_control ctrl;
1269
1270 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);
1271 ctrls.count = 1;
1272 ctrls.controls = &ctrl;
1273 ctrl.id = p->id;
1274 ctrl.value = p->value;
1275 if (check_ext_ctrls(&ctrls, 1)) {
1276 ret = vfd->vidioc_g_ext_ctrls(file, fh, &ctrls);
1277 if (ret == 0)
1278 p->value = ctrl.value;
1279 }
1280 } else
1281 break;
1282 if (!ret)
1283 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
1284 else
1285 dbgarg(cmd, "id=0x%x\n", p->id);
1286 break;
1287 }
1288 case VIDIOC_S_CTRL:
1289 {
1290 struct v4l2_control *p = arg;
1291 struct v4l2_ext_controls ctrls;
1292 struct v4l2_ext_control ctrl;
1293
1294 if (!vfd->vidioc_s_ctrl && !vfd->vidioc_s_ext_ctrls)
1295 break;
1296
1297 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
1298
1299 if (vfd->vidioc_s_ctrl) {
1300 ret = vfd->vidioc_s_ctrl(file, fh, p);
1301 break;
1302 }
1303 if (!vfd->vidioc_s_ext_ctrls)
1304 break;
1305
1306 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);
1307 ctrls.count = 1;
1308 ctrls.controls = &ctrl;
1309 ctrl.id = p->id;
1310 ctrl.value = p->value;
1311 if (check_ext_ctrls(&ctrls, 1))
1312 ret = vfd->vidioc_s_ext_ctrls(file, fh, &ctrls);
1313 break;
1314 }
1315 case VIDIOC_G_EXT_CTRLS:
1316 {
1317 struct v4l2_ext_controls *p = arg;
1318
1319 p->error_idx = p->count;
1320 if (!vfd->vidioc_g_ext_ctrls)
1321 break;
1322 if (check_ext_ctrls(p, 0))
1323 ret = vfd->vidioc_g_ext_ctrls(file, fh, p);
1324 v4l_print_ext_ctrls(cmd, vfd, p, !ret);
1325 break;
1326 }
1327 case VIDIOC_S_EXT_CTRLS:
1328 {
1329 struct v4l2_ext_controls *p = arg;
1330
1331 p->error_idx = p->count;
1332 if (!vfd->vidioc_s_ext_ctrls)
1333 break;
1334 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1335 if (check_ext_ctrls(p, 0))
1336 ret = vfd->vidioc_s_ext_ctrls(file, fh, p);
1337 break;
1338 }
1339 case VIDIOC_TRY_EXT_CTRLS:
1340 {
1341 struct v4l2_ext_controls *p = arg;
1342
1343 p->error_idx = p->count;
1344 if (!vfd->vidioc_try_ext_ctrls)
1345 break;
1346 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1347 if (check_ext_ctrls(p, 0))
1348 ret = vfd->vidioc_try_ext_ctrls(file, fh, p);
1349 break;
1350 }
1351 case VIDIOC_QUERYMENU:
1352 {
1353 struct v4l2_querymenu *p = arg;
1354
1355 if (!vfd->vidioc_querymenu)
1356 break;
1357 ret = vfd->vidioc_querymenu(file, fh, p);
1358 if (!ret)
1359 dbgarg(cmd, "id=0x%x, index=%d, name=%s\n",
1360 p->id, p->index, p->name);
1361 else
1362 dbgarg(cmd, "id=0x%x, index=%d\n",
1363 p->id, p->index);
1364 break;
1365 }
1366 /* --- audio ---------------------------------------------- */
1367 case VIDIOC_ENUMAUDIO:
1368 {
1369 struct v4l2_audio *p = arg;
1370
1371 if (!vfd->vidioc_enumaudio)
1372 break;
1373 ret = vfd->vidioc_enumaudio(file, fh, p);
1374 if (!ret)
1375 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1376 "mode=0x%x\n", p->index, p->name,
1377 p->capability, p->mode);
1378 else
1379 dbgarg(cmd, "index=%d\n", p->index);
1380 break;
1381 }
1382 case VIDIOC_G_AUDIO:
1383 {
1384 struct v4l2_audio *p = arg;
1385 __u32 index = p->index;
1386
1387 if (!vfd->vidioc_g_audio)
1388 break;
1389
1390 memset(p, 0, sizeof(*p));
1391 p->index = index;
1392 ret = vfd->vidioc_g_audio(file, fh, p);
1393 if (!ret)
1394 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1395 "mode=0x%x\n", p->index,
1396 p->name, p->capability, p->mode);
1397 else
1398 dbgarg(cmd, "index=%d\n", p->index);
1399 break;
1400 }
1401 case VIDIOC_S_AUDIO:
1402 {
1403 struct v4l2_audio *p = arg;
1404
1405 if (!vfd->vidioc_s_audio)
1406 break;
1407 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1408 "mode=0x%x\n", p->index, p->name,
1409 p->capability, p->mode);
1410 ret = vfd->vidioc_s_audio(file, fh, p);
1411 break;
1412 }
1413 case VIDIOC_ENUMAUDOUT:
1414 {
1415 struct v4l2_audioout *p = arg;
1416
1417 if (!vfd->vidioc_enumaudout)
1418 break;
1419 dbgarg(cmd, "Enum for index=%d\n", p->index);
1420 ret = vfd->vidioc_enumaudout(file, fh, p);
1421 if (!ret)
1422 dbgarg2("index=%d, name=%s, capability=%d, "
1423 "mode=%d\n", p->index, p->name,
1424 p->capability, p->mode);
1425 break;
1426 }
1427 case VIDIOC_G_AUDOUT:
1428 {
1429 struct v4l2_audioout *p = arg;
1430
1431 if (!vfd->vidioc_g_audout)
1432 break;
1433 dbgarg(cmd, "Enum for index=%d\n", p->index);
1434 ret = vfd->vidioc_g_audout(file, fh, p);
1435 if (!ret)
1436 dbgarg2("index=%d, name=%s, capability=%d, "
1437 "mode=%d\n", p->index, p->name,
1438 p->capability, p->mode);
1439 break;
1440 }
1441 case VIDIOC_S_AUDOUT:
1442 {
1443 struct v4l2_audioout *p = arg;
1444
1445 if (!vfd->vidioc_s_audout)
1446 break;
1447 dbgarg(cmd, "index=%d, name=%s, capability=%d, "
1448 "mode=%d\n", p->index, p->name,
1449 p->capability, p->mode);
1450
1451 ret = vfd->vidioc_s_audout(file, fh, p);
1452 break;
1453 }
1454 case VIDIOC_G_MODULATOR:
1455 {
1456 struct v4l2_modulator *p = arg;
1457
1458 if (!vfd->vidioc_g_modulator)
1459 break;
1460 ret = vfd->vidioc_g_modulator(file, fh, p);
1461 if (!ret)
1462 dbgarg(cmd, "index=%d, name=%s, "
1463 "capability=%d, rangelow=%d,"
1464 " rangehigh=%d, txsubchans=%d\n",
1465 p->index, p->name, p->capability,
1466 p->rangelow, p->rangehigh,
1467 p->txsubchans);
1468 break;
1469 }
1470 case VIDIOC_S_MODULATOR:
1471 {
1472 struct v4l2_modulator *p = arg;
1473
1474 if (!vfd->vidioc_s_modulator)
1475 break;
1476 dbgarg(cmd, "index=%d, name=%s, capability=%d, "
1477 "rangelow=%d, rangehigh=%d, txsubchans=%d\n",
1478 p->index, p->name, p->capability, p->rangelow,
1479 p->rangehigh, p->txsubchans);
1480 ret = vfd->vidioc_s_modulator(file, fh, p);
1481 break;
1482 }
1483 case VIDIOC_G_CROP:
1484 {
1485 struct v4l2_crop *p = arg;
1486
1487 if (!vfd->vidioc_g_crop)
1488 break;
1489 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1490 ret = vfd->vidioc_g_crop(file, fh, p);
1491 if (!ret)
1492 dbgrect(vfd, "", &p->c);
1493 break;
1494 }
1495 case VIDIOC_S_CROP:
1496 {
1497 struct v4l2_crop *p = arg;
1498
1499 if (!vfd->vidioc_s_crop)
1500 break;
1501 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1502 dbgrect(vfd, "", &p->c);
1503 ret = vfd->vidioc_s_crop(file, fh, p);
1504 break;
1505 }
1506 case VIDIOC_CROPCAP:
1507 {
1508 struct v4l2_cropcap *p = arg;
1509
1510 /*FIXME: Should also show v4l2_fract pixelaspect */
1511 if (!vfd->vidioc_cropcap)
1512 break;
1513 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1514 ret = vfd->vidioc_cropcap(file, fh, p);
1515 if (!ret) {
1516 dbgrect(vfd, "bounds ", &p->bounds);
1517 dbgrect(vfd, "defrect ", &p->defrect);
1518 }
1519 break;
1520 }
1521 case VIDIOC_G_JPEGCOMP:
1522 {
1523 struct v4l2_jpegcompression *p = arg;
1524
1525 if (!vfd->vidioc_g_jpegcomp)
1526 break;
1527 ret = vfd->vidioc_g_jpegcomp(file, fh, p);
1528 if (!ret)
1529 dbgarg(cmd, "quality=%d, APPn=%d, "
1530 "APP_len=%d, COM_len=%d, "
1531 "jpeg_markers=%d\n",
1532 p->quality, p->APPn, p->APP_len,
1533 p->COM_len, p->jpeg_markers);
1534 break;
1535 }
1536 case VIDIOC_S_JPEGCOMP:
1537 {
1538 struct v4l2_jpegcompression *p = arg;
1539
1540 if (!vfd->vidioc_g_jpegcomp)
1541 break;
1542 dbgarg(cmd, "quality=%d, APPn=%d, APP_len=%d, "
1543 "COM_len=%d, jpeg_markers=%d\n",
1544 p->quality, p->APPn, p->APP_len,
1545 p->COM_len, p->jpeg_markers);
1546 ret = vfd->vidioc_s_jpegcomp(file, fh, p);
1547 break;
1548 }
1549 case VIDIOC_G_ENC_INDEX:
1550 {
1551 struct v4l2_enc_idx *p = arg;
1552
1553 if (!vfd->vidioc_g_enc_index)
1554 break;
1555 ret = vfd->vidioc_g_enc_index(file, fh, p);
1556 if (!ret)
1557 dbgarg(cmd, "entries=%d, entries_cap=%d\n",
1558 p->entries, p->entries_cap);
1559 break;
1560 }
1561 case VIDIOC_ENCODER_CMD:
1562 {
1563 struct v4l2_encoder_cmd *p = arg;
1564
1565 if (!vfd->vidioc_encoder_cmd)
1566 break;
1567 memset(&p->raw, 0, sizeof(p->raw));
1568 ret = vfd->vidioc_encoder_cmd(file, fh, p);
1569 if (!ret)
1570 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1571 break;
1572 }
1573 case VIDIOC_TRY_ENCODER_CMD:
1574 {
1575 struct v4l2_encoder_cmd *p = arg;
1576
1577 if (!vfd->vidioc_try_encoder_cmd)
1578 break;
1579 memset(&p->raw, 0, sizeof(p->raw));
1580 ret = vfd->vidioc_try_encoder_cmd(file, fh, p);
1581 if (!ret)
1582 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1583 break;
1584 }
1585 case VIDIOC_G_PARM:
1586 {
1587 struct v4l2_streamparm *p = arg;
1588 __u32 type = p->type;
1589
1590 memset(p, 0, sizeof(*p));
1591 p->type = type;
1592
1593 if (vfd->vidioc_g_parm) {
1594 ret = vfd->vidioc_g_parm(file, fh, p);
1595 } else {
1596 struct v4l2_standard s;
1597
1598 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1599 return -EINVAL;
1600
1601 v4l2_video_std_construct(&s, vfd->current_norm,
1602 v4l2_norm_to_name(vfd->current_norm));
1603
1604 p->parm.capture.timeperframe = s.frameperiod;
1605 ret = 0;
1606 }
1607
1608 dbgarg(cmd, "type=%d\n", p->type);
1609 break;
1610 }
1611 case VIDIOC_S_PARM:
1612 {
1613 struct v4l2_streamparm *p = arg;
1614
1615 if (!vfd->vidioc_s_parm)
1616 break;
1617 dbgarg(cmd, "type=%d\n", p->type);
1618 ret = vfd->vidioc_s_parm(file, fh, p);
1619 break;
1620 }
1621 case VIDIOC_G_TUNER:
1622 {
1623 struct v4l2_tuner *p = arg;
1624 __u32 index = p->index;
1625
1626 if (!vfd->vidioc_g_tuner)
1627 break;
1628
1629 memset(p, 0, sizeof(*p));
1630 p->index = index;
1631
1632 ret = vfd->vidioc_g_tuner(file, fh, p);
1633 if (!ret)
1634 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1635 "capability=0x%x, rangelow=%d, "
1636 "rangehigh=%d, signal=%d, afc=%d, "
1637 "rxsubchans=0x%x, audmode=%d\n",
1638 p->index, p->name, p->type,
1639 p->capability, p->rangelow,
1640 p->rangehigh, p->signal, p->afc,
1641 p->rxsubchans, p->audmode);
1642 break;
1643 }
1644 case VIDIOC_S_TUNER:
1645 {
1646 struct v4l2_tuner *p = arg;
1647
1648 if (!vfd->vidioc_s_tuner)
1649 break;
1650 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1651 "capability=0x%x, rangelow=%d, "
1652 "rangehigh=%d, signal=%d, afc=%d, "
1653 "rxsubchans=0x%x, audmode=%d\n",
1654 p->index, p->name, p->type,
1655 p->capability, p->rangelow,
1656 p->rangehigh, p->signal, p->afc,
1657 p->rxsubchans, p->audmode);
1658 ret = vfd->vidioc_s_tuner(file, fh, p);
1659 break;
1660 }
1661 case VIDIOC_G_FREQUENCY:
1662 {
1663 struct v4l2_frequency *p = arg;
1664
1665 if (!vfd->vidioc_g_frequency)
1666 break;
1667
1668 memset(p->reserved, 0, sizeof(p->reserved));
1669
1670 ret = vfd->vidioc_g_frequency(file, fh, p);
1671 if (!ret)
1672 dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n",
1673 p->tuner, p->type, p->frequency);
1674 break;
1675 }
1676 case VIDIOC_S_FREQUENCY:
1677 {
1678 struct v4l2_frequency *p = arg;
1679
1680 if (!vfd->vidioc_s_frequency)
1681 break;
1682 dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n",
1683 p->tuner, p->type, p->frequency);
1684 ret = vfd->vidioc_s_frequency(file, fh, p);
1685 break;
1686 }
1687 case VIDIOC_G_SLICED_VBI_CAP:
1688 {
1689 struct v4l2_sliced_vbi_cap *p = arg;
1690 __u32 type = p->type;
1691
1692 if (!vfd->vidioc_g_sliced_vbi_cap)
1693 break;
1694 memset(p, 0, sizeof(*p));
1695 p->type = type;
1696 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1697 ret = vfd->vidioc_g_sliced_vbi_cap(file, fh, p);
1698 if (!ret)
1699 dbgarg2("service_set=%d\n", p->service_set);
1700 break;
1701 }
1702 case VIDIOC_LOG_STATUS:
1703 {
1704 if (!vfd->vidioc_log_status)
1705 break;
1706 ret = vfd->vidioc_log_status(file, fh);
1707 break;
1708 }
1709#ifdef CONFIG_VIDEO_ADV_DEBUG
1710 case VIDIOC_DBG_G_REGISTER:
1711 {
1712 struct v4l2_register *p = arg;
1713
1714 if (!capable(CAP_SYS_ADMIN))
1715 ret = -EPERM;
1716 else if (vfd->vidioc_g_register)
1717 ret = vfd->vidioc_g_register(file, fh, p);
1718 break;
1719 }
1720 case VIDIOC_DBG_S_REGISTER:
1721 {
1722 struct v4l2_register *p = arg;
1723
1724 if (!capable(CAP_SYS_ADMIN))
1725 ret = -EPERM;
1726 else if (vfd->vidioc_s_register)
1727 ret = vfd->vidioc_s_register(file, fh, p);
1728 break;
1729 }
1730#endif
1731 case VIDIOC_G_CHIP_IDENT:
1732 {
1733 struct v4l2_chip_ident *p = arg;
1734
1735 if (!vfd->vidioc_g_chip_ident)
1736 break;
1737 ret = vfd->vidioc_g_chip_ident(file, fh, p);
1738 if (!ret)
1739 dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision);
1740 break;
1741 }
1742 default:
1743 {
1744 if (!vfd->vidioc_default)
1745 break;
1746 ret = vfd->vidioc_default(file, fh, cmd, arg);
1747 break;
1748 }
1749 case VIDIOC_S_HW_FREQ_SEEK:
1750 {
1751 struct v4l2_hw_freq_seek *p = arg;
1752
1753 if (!vfd->vidioc_s_hw_freq_seek)
1754 break;
1755 dbgarg(cmd,
1756 "tuner=%d, type=%d, seek_upward=%d, wrap_around=%d\n",
1757 p->tuner, p->type, p->seek_upward, p->wrap_around);
1758 ret = vfd->vidioc_s_hw_freq_seek(file, fh, p);
1759 break;
1760 }
1761 } /* switch */
1762
1763 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) {
1764 if (ret < 0) {
1765 v4l_print_ioctl(vfd->name, cmd);
1766 printk(KERN_CONT " error %d\n", ret);
1767 }
1768 }
1769
1770 return ret;
1771}
1772
1773int video_ioctl2(struct inode *inode, struct file *file,
1774 unsigned int cmd, unsigned long arg)
1775{
1776 char sbuf[128];
1777 void *mbuf = NULL;
1778 void *parg = NULL;
1779 int err = -EINVAL;
1780 int is_ext_ctrl;
1781 size_t ctrls_size = 0;
1782 void __user *user_ptr = NULL;
1783
1784#ifdef __OLD_VIDIOC_
1785 cmd = video_fix_command(cmd);
1786#endif
1787 is_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||
1788 cmd == VIDIOC_TRY_EXT_CTRLS);
1789
1790 /* Copy arguments into temp kernel buffer */
1791 switch (_IOC_DIR(cmd)) {
1792 case _IOC_NONE:
1793 parg = NULL;
1794 break;
1795 case _IOC_READ:
1796 case _IOC_WRITE:
1797 case (_IOC_WRITE | _IOC_READ):
1798 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
1799 parg = sbuf;
1800 } else {
1801 /* too big to allocate from stack */
1802 mbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
1803 if (NULL == mbuf)
1804 return -ENOMEM;
1805 parg = mbuf;
1806 }
1807
1808 err = -EFAULT;
1809 if (_IOC_DIR(cmd) & _IOC_WRITE)
1810 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
1811 goto out;
1812 break;
1813 }
1814
1815 if (is_ext_ctrl) {
1816 struct v4l2_ext_controls *p = parg;
1817
1818 /* In case of an error, tell the caller that it wasn't
1819 a specific control that caused it. */
1820 p->error_idx = p->count;
1821 user_ptr = (void __user *)p->controls;
1822 if (p->count) {
1823 ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
1824 /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
1825 mbuf = kmalloc(ctrls_size, GFP_KERNEL);
1826 err = -ENOMEM;
1827 if (NULL == mbuf)
1828 goto out_ext_ctrl;
1829 err = -EFAULT;
1830 if (copy_from_user(mbuf, user_ptr, ctrls_size))
1831 goto out_ext_ctrl;
1832 p->controls = mbuf;
1833 }
1834 }
1835
1836 /* Handles IOCTL */
1837 err = __video_do_ioctl(inode, file, cmd, parg);
1838 if (err == -ENOIOCTLCMD)
1839 err = -EINVAL;
1840 if (is_ext_ctrl) {
1841 struct v4l2_ext_controls *p = parg;
1842
1843 p->controls = (void *)user_ptr;
1844 if (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))
1845 err = -EFAULT;
1846 goto out_ext_ctrl;
1847 }
1848 if (err < 0)
1849 goto out;
1850
1851out_ext_ctrl:
1852 /* Copy results into user buffer */
1853 switch (_IOC_DIR(cmd)) {
1854 case _IOC_READ:
1855 case (_IOC_WRITE | _IOC_READ):
1856 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
1857 err = -EFAULT;
1858 break;
1859 }
1860
1861out:
1862 kfree(mbuf);
1863 return err;
1864}
1865EXPORT_SYMBOL(video_ioctl2);
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c
index 03f20acb668c..31944b11e6ea 100644
--- a/drivers/media/video/videobuf-dma-contig.c
+++ b/drivers/media/video/videobuf-dma-contig.c
@@ -28,10 +28,10 @@ struct videobuf_dma_contig_memory {
28}; 28};
29 29
30#define MAGIC_DC_MEM 0x0733ac61 30#define MAGIC_DC_MEM 0x0733ac61
31#define MAGIC_CHECK(is, should) \ 31#define MAGIC_CHECK(is, should) \
32 if (unlikely((is) != (should))) { \ 32 if (unlikely((is) != (should))) { \
33 pr_err("magic mismatch: %x expected %x\n", is, should); \ 33 pr_err("magic mismatch: %x expected %x\n", (is), (should)); \
34 BUG(); \ 34 BUG(); \
35 } 35 }
36 36
37static void 37static void
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 6616e6570557..e69de29bb2d1 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -1,2262 +0,0 @@
1/*
2 * Video capture interface for Linux version 2
3 *
4 * A generic video device interface for the LINUX operating system
5 * using a set of device structures/vectors for low level operations.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * Authors: Alan Cox, <alan@redhat.com> (version 1)
13 * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2)
14 *
15 * Fixes: 20000516 Claudio Matsuoka <claudio@conectiva.com>
16 * - Added procfs support
17 */
18
19#define dbgarg(cmd, fmt, arg...) \
20 do { \
21 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \
22 printk(KERN_DEBUG "%s: ", vfd->name); \
23 v4l_printk_ioctl(cmd); \
24 printk(" " fmt, ## arg); \
25 } \
26 } while (0)
27
28#define dbgarg2(fmt, arg...) \
29 do { \
30 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \
31 printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\
32 } while (0)
33
34#include <linux/module.h>
35#include <linux/types.h>
36#include <linux/kernel.h>
37#include <linux/mm.h>
38#include <linux/string.h>
39#include <linux/errno.h>
40#include <linux/init.h>
41#include <linux/kmod.h>
42#include <linux/slab.h>
43#include <linux/smp_lock.h>
44#include <asm/uaccess.h>
45#include <asm/system.h>
46
47#define __OLD_VIDIOC_ /* To allow fixing old calls*/
48#include <linux/videodev2.h>
49
50#ifdef CONFIG_VIDEO_V4L1
51#include <linux/videodev.h>
52#endif
53#include <media/v4l2-common.h>
54#include <linux/video_decoder.h>
55
56#define VIDEO_NUM_DEVICES 256
57#define VIDEO_NAME "video4linux"
58
59struct std_descr {
60 v4l2_std_id std;
61 const char *descr;
62};
63
64static const struct std_descr standards[] = {
65 { V4L2_STD_NTSC, "NTSC" },
66 { V4L2_STD_NTSC_M, "NTSC-M" },
67 { V4L2_STD_NTSC_M_JP, "NTSC-M-JP" },
68 { V4L2_STD_NTSC_M_KR, "NTSC-M-KR" },
69 { V4L2_STD_NTSC_443, "NTSC-443" },
70 { V4L2_STD_PAL, "PAL" },
71 { V4L2_STD_PAL_BG, "PAL-BG" },
72 { V4L2_STD_PAL_B, "PAL-B" },
73 { V4L2_STD_PAL_B1, "PAL-B1" },
74 { V4L2_STD_PAL_G, "PAL-G" },
75 { V4L2_STD_PAL_H, "PAL-H" },
76 { V4L2_STD_PAL_I, "PAL-I" },
77 { V4L2_STD_PAL_DK, "PAL-DK" },
78 { V4L2_STD_PAL_D, "PAL-D" },
79 { V4L2_STD_PAL_D1, "PAL-D1" },
80 { V4L2_STD_PAL_K, "PAL-K" },
81 { V4L2_STD_PAL_M, "PAL-M" },
82 { V4L2_STD_PAL_N, "PAL-N" },
83 { V4L2_STD_PAL_Nc, "PAL-Nc" },
84 { V4L2_STD_PAL_60, "PAL-60" },
85 { V4L2_STD_SECAM, "SECAM" },
86 { V4L2_STD_SECAM_B, "SECAM-B" },
87 { V4L2_STD_SECAM_G, "SECAM-G" },
88 { V4L2_STD_SECAM_H, "SECAM-H" },
89 { V4L2_STD_SECAM_DK, "SECAM-DK" },
90 { V4L2_STD_SECAM_D, "SECAM-D" },
91 { V4L2_STD_SECAM_K, "SECAM-K" },
92 { V4L2_STD_SECAM_K1, "SECAM-K1" },
93 { V4L2_STD_SECAM_L, "SECAM-L" },
94 { V4L2_STD_SECAM_LC, "SECAM-Lc" },
95 { 0, "Unknown" }
96};
97
98/* video4linux standard ID conversion to standard name
99 */
100const char *v4l2_norm_to_name(v4l2_std_id id)
101{
102 u32 myid = id;
103 int i;
104
105 /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
106 64 bit comparations. So, on that architecture, with some gcc
107 variants, compilation fails. Currently, the max value is 30bit wide.
108 */
109 BUG_ON(myid != id);
110
111 for (i = 0; standards[i].std; i++)
112 if (myid == standards[i].std)
113 break;
114 return standards[i].descr;
115}
116EXPORT_SYMBOL(v4l2_norm_to_name);
117
118/* Fill in the fields of a v4l2_standard structure according to the
119 'id' and 'transmission' parameters. Returns negative on error. */
120int v4l2_video_std_construct(struct v4l2_standard *vs,
121 int id, const char *name)
122{
123 u32 index = vs->index;
124
125 memset(vs, 0, sizeof(struct v4l2_standard));
126 vs->index = index;
127 vs->id = id;
128 if (id & V4L2_STD_525_60) {
129 vs->frameperiod.numerator = 1001;
130 vs->frameperiod.denominator = 30000;
131 vs->framelines = 525;
132 } else {
133 vs->frameperiod.numerator = 1;
134 vs->frameperiod.denominator = 25;
135 vs->framelines = 625;
136 }
137 strlcpy(vs->name, name, sizeof(vs->name));
138 return 0;
139}
140EXPORT_SYMBOL(v4l2_video_std_construct);
141
142/* ----------------------------------------------------------------- */
143/* some arrays for pretty-printing debug messages of enum types */
144
145const char *v4l2_field_names[] = {
146 [V4L2_FIELD_ANY] = "any",
147 [V4L2_FIELD_NONE] = "none",
148 [V4L2_FIELD_TOP] = "top",
149 [V4L2_FIELD_BOTTOM] = "bottom",
150 [V4L2_FIELD_INTERLACED] = "interlaced",
151 [V4L2_FIELD_SEQ_TB] = "seq-tb",
152 [V4L2_FIELD_SEQ_BT] = "seq-bt",
153 [V4L2_FIELD_ALTERNATE] = "alternate",
154 [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
155 [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
156};
157EXPORT_SYMBOL(v4l2_field_names);
158
159const char *v4l2_type_names[] = {
160 [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "vid-cap",
161 [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "vid-overlay",
162 [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "vid-out",
163 [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
164 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
165 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap",
166 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
167 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "vid-out-overlay",
168};
169EXPORT_SYMBOL(v4l2_type_names);
170
171static const char *v4l2_memory_names[] = {
172 [V4L2_MEMORY_MMAP] = "mmap",
173 [V4L2_MEMORY_USERPTR] = "userptr",
174 [V4L2_MEMORY_OVERLAY] = "overlay",
175};
176
177#define prt_names(a, arr) ((((a) >= 0) && ((a) < ARRAY_SIZE(arr))) ? \
178 arr[a] : "unknown")
179
180/* ------------------------------------------------------------------ */
181/* debug help functions */
182
183#ifdef CONFIG_VIDEO_V4L1_COMPAT
184static const char *v4l1_ioctls[] = {
185 [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP",
186 [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN",
187 [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN",
188 [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER",
189 [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER",
190 [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT",
191 [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT",
192 [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE",
193 [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN",
194 [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN",
195 [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF",
196 [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF",
197 [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY",
198 [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ",
199 [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ",
200 [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO",
201 [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO",
202 [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC",
203 [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE",
204 [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF",
205 [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT",
206 [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE",
207 [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE",
208 [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE",
209 [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE",
210 [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO",
211 [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE",
212 [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT",
213 [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT"
214};
215#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
216#endif
217
218static const char *v4l2_ioctls[] = {
219 [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP",
220 [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED",
221 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
222 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
223 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
224 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
225 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
226 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
227 [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF",
228 [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY",
229 [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF",
230 [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF",
231 [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON",
232 [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF",
233 [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM",
234 [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM",
235 [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD",
236 [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD",
237 [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD",
238 [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT",
239 [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL",
240 [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL",
241 [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER",
242 [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER",
243 [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO",
244 [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO",
245 [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL",
246 [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU",
247 [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT",
248 [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT",
249 [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT",
250 [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT",
251 [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT",
252 [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT",
253 [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT",
254 [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR",
255 [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR",
256 [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY",
257 [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY",
258 [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP",
259 [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP",
260 [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP",
261 [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP",
262 [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP",
263 [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD",
264 [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT",
265 [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO",
266 [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT",
267 [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY",
268 [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY",
269 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
270 [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS",
271 [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS",
272 [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS",
273 [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS",
274#if 1
275 [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES",
276 [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS",
277 [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX",
278 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
279 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",
280
281 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
282 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
283
284 [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT",
285 [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK",
286#endif
287};
288#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
289
290static const char *v4l2_int_ioctls[] = {
291#ifdef CONFIG_VIDEO_V4L1_COMPAT
292 [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES",
293 [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS",
294 [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM",
295 [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT",
296 [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT",
297 [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT",
298 [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE",
299 [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO",
300 [_IOC_NR(DECODER_INIT)] = "DECODER_INIT",
301 [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS",
302 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
303#endif
304 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
305
306 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
307 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
308 [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG",
309
310 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
311 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
312 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
313 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE",
314 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
315 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
316 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
317 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
318 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
319 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
320 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
321 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING",
322 [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ",
323 [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT",
324 [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT",
325 [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT",
326};
327#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
328
329/* Common ioctl debug function. This function can be used by
330 external ioctl messages as well as internal V4L ioctl */
331void v4l_printk_ioctl(unsigned int cmd)
332{
333 char *dir, *type;
334
335 switch (_IOC_TYPE(cmd)) {
336 case 'd':
337 if (_IOC_NR(cmd) >= V4L2_INT_IOCTLS) {
338 type = "v4l2_int";
339 break;
340 }
341 printk("%s", v4l2_int_ioctls[_IOC_NR(cmd)]);
342 return;
343#ifdef CONFIG_VIDEO_V4L1_COMPAT
344 case 'v':
345 if (_IOC_NR(cmd) >= V4L1_IOCTLS) {
346 type = "v4l1";
347 break;
348 }
349 printk("%s", v4l1_ioctls[_IOC_NR(cmd)]);
350 return;
351#endif
352 case 'V':
353 if (_IOC_NR(cmd) >= V4L2_IOCTLS) {
354 type = "v4l2";
355 break;
356 }
357 printk("%s", v4l2_ioctls[_IOC_NR(cmd)]);
358 return;
359 default:
360 type = "unknown";
361 }
362
363 switch (_IOC_DIR(cmd)) {
364 case _IOC_NONE: dir = "--"; break;
365 case _IOC_READ: dir = "r-"; break;
366 case _IOC_WRITE: dir = "-w"; break;
367 case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
368 default: dir = "*ERR*"; break;
369 }
370 printk("%s ioctl '%c', dir=%s, #%d (0x%08x)",
371 type, _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd);
372}
373EXPORT_SYMBOL(v4l_printk_ioctl);
374
375/*
376 * sysfs stuff
377 */
378
379static ssize_t show_index(struct device *cd,
380 struct device_attribute *attr, char *buf)
381{
382 struct video_device *vfd = container_of(cd, struct video_device,
383 class_dev);
384 return sprintf(buf, "%i\n", vfd->index);
385}
386
387static ssize_t show_name(struct device *cd,
388 struct device_attribute *attr, char *buf)
389{
390 struct video_device *vfd = container_of(cd, struct video_device,
391 class_dev);
392 return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
393}
394
395static struct device_attribute video_device_attrs[] = {
396 __ATTR(name, S_IRUGO, show_name, NULL),
397 __ATTR(index, S_IRUGO, show_index, NULL),
398 __ATTR_NULL
399};
400
401struct video_device *video_device_alloc(void)
402{
403 struct video_device *vfd;
404
405 vfd = kzalloc(sizeof(*vfd),GFP_KERNEL);
406 return vfd;
407}
408EXPORT_SYMBOL(video_device_alloc);
409
410void video_device_release(struct video_device *vfd)
411{
412 kfree(vfd);
413}
414EXPORT_SYMBOL(video_device_release);
415
416static void video_release(struct device *cd)
417{
418 struct video_device *vfd = container_of(cd, struct video_device,
419 class_dev);
420
421#if 1
422 /* needed until all drivers are fixed */
423 if (!vfd->release)
424 return;
425#endif
426 vfd->release(vfd);
427}
428
429static struct class video_class = {
430 .name = VIDEO_NAME,
431 .dev_attrs = video_device_attrs,
432 .dev_release = video_release,
433};
434
435/*
436 * Active devices
437 */
438
439static struct video_device *video_device[VIDEO_NUM_DEVICES];
440static DEFINE_MUTEX(videodev_lock);
441
442struct video_device* video_devdata(struct file *file)
443{
444 return video_device[iminor(file->f_path.dentry->d_inode)];
445}
446EXPORT_SYMBOL(video_devdata);
447
448/*
449 * Open a video device - FIXME: Obsoleted
450 */
451static int video_open(struct inode *inode, struct file *file)
452{
453 unsigned int minor = iminor(inode);
454 int err = 0;
455 struct video_device *vfl;
456 const struct file_operations *old_fops;
457
458 if(minor>=VIDEO_NUM_DEVICES)
459 return -ENODEV;
460 lock_kernel();
461 mutex_lock(&videodev_lock);
462 vfl=video_device[minor];
463 if(vfl==NULL) {
464 mutex_unlock(&videodev_lock);
465 request_module("char-major-%d-%d", VIDEO_MAJOR, minor);
466 mutex_lock(&videodev_lock);
467 vfl=video_device[minor];
468 if (vfl==NULL) {
469 mutex_unlock(&videodev_lock);
470 unlock_kernel();
471 return -ENODEV;
472 }
473 }
474 old_fops = file->f_op;
475 file->f_op = fops_get(vfl->fops);
476 if(file->f_op->open)
477 err = file->f_op->open(inode,file);
478 if (err) {
479 fops_put(file->f_op);
480 file->f_op = fops_get(old_fops);
481 }
482 fops_put(old_fops);
483 mutex_unlock(&videodev_lock);
484 unlock_kernel();
485 return err;
486}
487
488/*
489 * helper function -- handles userspace copying for ioctl arguments
490 */
491
492#ifdef __OLD_VIDIOC_
493static unsigned int
494video_fix_command(unsigned int cmd)
495{
496 switch (cmd) {
497 case VIDIOC_OVERLAY_OLD:
498 cmd = VIDIOC_OVERLAY;
499 break;
500 case VIDIOC_S_PARM_OLD:
501 cmd = VIDIOC_S_PARM;
502 break;
503 case VIDIOC_S_CTRL_OLD:
504 cmd = VIDIOC_S_CTRL;
505 break;
506 case VIDIOC_G_AUDIO_OLD:
507 cmd = VIDIOC_G_AUDIO;
508 break;
509 case VIDIOC_G_AUDOUT_OLD:
510 cmd = VIDIOC_G_AUDOUT;
511 break;
512 case VIDIOC_CROPCAP_OLD:
513 cmd = VIDIOC_CROPCAP;
514 break;
515 }
516 return cmd;
517}
518#endif
519
520/*
521 * Obsolete usercopy function - Should be removed soon
522 */
523int
524video_usercopy(struct inode *inode, struct file *file,
525 unsigned int cmd, unsigned long arg,
526 int (*func)(struct inode *inode, struct file *file,
527 unsigned int cmd, void *arg))
528{
529 char sbuf[128];
530 void *mbuf = NULL;
531 void *parg = NULL;
532 int err = -EINVAL;
533 int is_ext_ctrl;
534 size_t ctrls_size = 0;
535 void __user *user_ptr = NULL;
536
537#ifdef __OLD_VIDIOC_
538 cmd = video_fix_command(cmd);
539#endif
540 is_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||
541 cmd == VIDIOC_TRY_EXT_CTRLS);
542
543 /* Copy arguments into temp kernel buffer */
544 switch (_IOC_DIR(cmd)) {
545 case _IOC_NONE:
546 parg = NULL;
547 break;
548 case _IOC_READ:
549 case _IOC_WRITE:
550 case (_IOC_WRITE | _IOC_READ):
551 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
552 parg = sbuf;
553 } else {
554 /* too big to allocate from stack */
555 mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
556 if (NULL == mbuf)
557 return -ENOMEM;
558 parg = mbuf;
559 }
560
561 err = -EFAULT;
562 if (_IOC_DIR(cmd) & _IOC_WRITE)
563 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
564 goto out;
565 break;
566 }
567 if (is_ext_ctrl) {
568 struct v4l2_ext_controls *p = parg;
569
570 /* In case of an error, tell the caller that it wasn't
571 a specific control that caused it. */
572 p->error_idx = p->count;
573 user_ptr = (void __user *)p->controls;
574 if (p->count) {
575 ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
576 /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
577 mbuf = kmalloc(ctrls_size, GFP_KERNEL);
578 err = -ENOMEM;
579 if (NULL == mbuf)
580 goto out_ext_ctrl;
581 err = -EFAULT;
582 if (copy_from_user(mbuf, user_ptr, ctrls_size))
583 goto out_ext_ctrl;
584 p->controls = mbuf;
585 }
586 }
587
588 /* call driver */
589 err = func(inode, file, cmd, parg);
590 if (err == -ENOIOCTLCMD)
591 err = -EINVAL;
592 if (is_ext_ctrl) {
593 struct v4l2_ext_controls *p = parg;
594
595 p->controls = (void *)user_ptr;
596 if (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))
597 err = -EFAULT;
598 goto out_ext_ctrl;
599 }
600 if (err < 0)
601 goto out;
602
603out_ext_ctrl:
604 /* Copy results into user buffer */
605 switch (_IOC_DIR(cmd))
606 {
607 case _IOC_READ:
608 case (_IOC_WRITE | _IOC_READ):
609 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
610 err = -EFAULT;
611 break;
612 }
613
614out:
615 kfree(mbuf);
616 return err;
617}
618EXPORT_SYMBOL(video_usercopy);
619
620/*
621 * open/release helper functions -- handle exclusive opens
622 * Should be removed soon
623 */
624int video_exclusive_open(struct inode *inode, struct file *file)
625{
626 struct video_device *vfl = video_devdata(file);
627 int retval = 0;
628
629 mutex_lock(&vfl->lock);
630 if (vfl->users) {
631 retval = -EBUSY;
632 } else {
633 vfl->users++;
634 }
635 mutex_unlock(&vfl->lock);
636 return retval;
637}
638EXPORT_SYMBOL(video_exclusive_open);
639
640int video_exclusive_release(struct inode *inode, struct file *file)
641{
642 struct video_device *vfl = video_devdata(file);
643
644 vfl->users--;
645 return 0;
646}
647EXPORT_SYMBOL(video_exclusive_release);
648
649static void dbgbuf(unsigned int cmd, struct video_device *vfd,
650 struct v4l2_buffer *p)
651{
652 struct v4l2_timecode *tc=&p->timecode;
653
654 dbgarg (cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, "
655 "bytesused=%d, flags=0x%08d, "
656 "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx, length=%d\n",
657 (p->timestamp.tv_sec/3600),
658 (int)(p->timestamp.tv_sec/60)%60,
659 (int)(p->timestamp.tv_sec%60),
660 p->timestamp.tv_usec,
661 p->index,
662 prt_names(p->type, v4l2_type_names),
663 p->bytesused, p->flags,
664 p->field, p->sequence,
665 prt_names(p->memory, v4l2_memory_names),
666 p->m.userptr, p->length);
667 dbgarg2("timecode=%02d:%02d:%02d type=%d, "
668 "flags=0x%08d, frames=%d, userbits=0x%08x\n",
669 tc->hours,tc->minutes,tc->seconds,
670 tc->type, tc->flags, tc->frames, *(__u32 *) tc->userbits);
671}
672
673static inline void dbgrect(struct video_device *vfd, char *s,
674 struct v4l2_rect *r)
675{
676 dbgarg2("%sRect start at %dx%d, size=%dx%d\n", s, r->left, r->top,
677 r->width, r->height);
678};
679
680static inline void v4l_print_pix_fmt (struct video_device *vfd,
681 struct v4l2_pix_format *fmt)
682{
683 dbgarg2 ("width=%d, height=%d, format=%c%c%c%c, field=%s, "
684 "bytesperline=%d sizeimage=%d, colorspace=%d\n",
685 fmt->width,fmt->height,
686 (fmt->pixelformat & 0xff),
687 (fmt->pixelformat >> 8) & 0xff,
688 (fmt->pixelformat >> 16) & 0xff,
689 (fmt->pixelformat >> 24) & 0xff,
690 prt_names(fmt->field, v4l2_field_names),
691 fmt->bytesperline, fmt->sizeimage, fmt->colorspace);
692};
693
694static inline void v4l_print_ext_ctrls(unsigned int cmd,
695 struct video_device *vfd, struct v4l2_ext_controls *c, int show_vals)
696{
697 __u32 i;
698
699 if (!(vfd->debug & V4L2_DEBUG_IOCTL_ARG))
700 return;
701 dbgarg(cmd, "");
702 printk(KERN_CONT "class=0x%x", c->ctrl_class);
703 for (i = 0; i < c->count; i++) {
704 if (show_vals)
705 printk(KERN_CONT " id/val=0x%x/0x%x",
706 c->controls[i].id, c->controls[i].value);
707 else
708 printk(KERN_CONT " id=0x%x", c->controls[i].id);
709 }
710 printk(KERN_CONT "\n");
711};
712
713static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv)
714{
715 __u32 i;
716
717 /* zero the reserved fields */
718 c->reserved[0] = c->reserved[1] = 0;
719 for (i = 0; i < c->count; i++) {
720 c->controls[i].reserved2[0] = 0;
721 c->controls[i].reserved2[1] = 0;
722 }
723 /* V4L2_CID_PRIVATE_BASE cannot be used as control class
724 when using extended controls.
725 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL
726 is it allowed for backwards compatibility.
727 */
728 if (!allow_priv && c->ctrl_class == V4L2_CID_PRIVATE_BASE)
729 return 0;
730 /* Check that all controls are from the same control class. */
731 for (i = 0; i < c->count; i++) {
732 if (V4L2_CTRL_ID2CLASS(c->controls[i].id) != c->ctrl_class) {
733 c->error_idx = i;
734 return 0;
735 }
736 }
737 return 1;
738}
739
740static int check_fmt (struct video_device *vfd, enum v4l2_buf_type type)
741{
742 switch (type) {
743 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
744 if (vfd->vidioc_try_fmt_vid_cap)
745 return (0);
746 break;
747 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
748 if (vfd->vidioc_try_fmt_vid_overlay)
749 return (0);
750 break;
751 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
752 if (vfd->vidioc_try_fmt_vid_out)
753 return (0);
754 break;
755 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
756 if (vfd->vidioc_try_fmt_vid_out_overlay)
757 return (0);
758 break;
759 case V4L2_BUF_TYPE_VBI_CAPTURE:
760 if (vfd->vidioc_try_fmt_vbi_cap)
761 return (0);
762 break;
763 case V4L2_BUF_TYPE_VBI_OUTPUT:
764 if (vfd->vidioc_try_fmt_vbi_out)
765 return (0);
766 break;
767 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
768 if (vfd->vidioc_try_fmt_sliced_vbi_cap)
769 return (0);
770 break;
771 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
772 if (vfd->vidioc_try_fmt_sliced_vbi_out)
773 return (0);
774 break;
775 case V4L2_BUF_TYPE_PRIVATE:
776 if (vfd->vidioc_try_fmt_type_private)
777 return (0);
778 break;
779 }
780 return (-EINVAL);
781}
782
783static int __video_do_ioctl(struct inode *inode, struct file *file,
784 unsigned int cmd, void *arg)
785{
786 struct video_device *vfd = video_devdata(file);
787 void *fh = file->private_data;
788 int ret = -EINVAL;
789
790 if ( (vfd->debug & V4L2_DEBUG_IOCTL) &&
791 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
792 v4l_print_ioctl(vfd->name, cmd);
793 printk("\n");
794 }
795
796#ifdef CONFIG_VIDEO_V4L1_COMPAT
797 /***********************************************************
798 Handles calls to the obsoleted V4L1 API
799 Due to the nature of VIDIOCGMBUF, each driver that supports
800 V4L1 should implement its own handler for this ioctl.
801 ***********************************************************/
802
803 /* --- streaming capture ------------------------------------- */
804 if (cmd == VIDIOCGMBUF) {
805 struct video_mbuf *p=arg;
806
807 memset(p, 0, sizeof(*p));
808
809 if (!vfd->vidiocgmbuf)
810 return ret;
811 ret=vfd->vidiocgmbuf(file, fh, p);
812 if (!ret)
813 dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
814 p->size, p->frames,
815 (unsigned long)p->offsets);
816 return ret;
817 }
818
819 /********************************************************
820 All other V4L1 calls are handled by v4l1_compat module.
821 Those calls will be translated into V4L2 calls, and
822 __video_do_ioctl will be called again, with one or more
823 V4L2 ioctls.
824 ********************************************************/
825 if (_IOC_TYPE(cmd)=='v')
826 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
827 __video_do_ioctl);
828#endif
829
830 switch(cmd) {
831 /* --- capabilities ------------------------------------------ */
832 case VIDIOC_QUERYCAP:
833 {
834 struct v4l2_capability *cap = (struct v4l2_capability*)arg;
835 memset(cap, 0, sizeof(*cap));
836
837 if (!vfd->vidioc_querycap)
838 break;
839
840 ret=vfd->vidioc_querycap(file, fh, cap);
841 if (!ret)
842 dbgarg (cmd, "driver=%s, card=%s, bus=%s, "
843 "version=0x%08x, "
844 "capabilities=0x%08x\n",
845 cap->driver,cap->card,cap->bus_info,
846 cap->version,
847 cap->capabilities);
848 break;
849 }
850
851 /* --- priority ------------------------------------------ */
852 case VIDIOC_G_PRIORITY:
853 {
854 enum v4l2_priority *p=arg;
855
856 if (!vfd->vidioc_g_priority)
857 break;
858 ret=vfd->vidioc_g_priority(file, fh, p);
859 if (!ret)
860 dbgarg(cmd, "priority is %d\n", *p);
861 break;
862 }
863 case VIDIOC_S_PRIORITY:
864 {
865 enum v4l2_priority *p=arg;
866
867 if (!vfd->vidioc_s_priority)
868 break;
869 dbgarg(cmd, "setting priority to %d\n", *p);
870 ret=vfd->vidioc_s_priority(file, fh, *p);
871 break;
872 }
873
874 /* --- capture ioctls ---------------------------------------- */
875 case VIDIOC_ENUM_FMT:
876 {
877 struct v4l2_fmtdesc *f = arg;
878 enum v4l2_buf_type type;
879 unsigned int index;
880
881 index = f->index;
882 type = f->type;
883 memset(f,0,sizeof(*f));
884 f->index = index;
885 f->type = type;
886
887 switch (type) {
888 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
889 if (vfd->vidioc_enum_fmt_vid_cap)
890 ret = vfd->vidioc_enum_fmt_vid_cap(file, fh, f);
891 break;
892 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
893 if (vfd->vidioc_enum_fmt_vid_overlay)
894 ret = vfd->vidioc_enum_fmt_vid_overlay(file,
895 fh, f);
896 break;
897#if 1
898 /* V4L2_BUF_TYPE_VBI_CAPTURE should not support VIDIOC_ENUM_FMT
899 * according to the spec. The bttv and saa7134 drivers support
900 * it though, so just warn that this is deprecated and will be
901 * removed in the near future. */
902 case V4L2_BUF_TYPE_VBI_CAPTURE:
903 if (vfd->vidioc_enum_fmt_vbi_cap) {
904 printk(KERN_WARNING "vidioc_enum_fmt_vbi_cap will be removed in 2.6.28!\n");
905 ret = vfd->vidioc_enum_fmt_vbi_cap(file, fh, f);
906 }
907 break;
908#endif
909 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
910 if (vfd->vidioc_enum_fmt_vid_out)
911 ret = vfd->vidioc_enum_fmt_vid_out(file, fh, f);
912 break;
913 case V4L2_BUF_TYPE_PRIVATE:
914 if (vfd->vidioc_enum_fmt_type_private)
915 ret = vfd->vidioc_enum_fmt_type_private(file,
916 fh, f);
917 break;
918 default:
919 break;
920 }
921 if (!ret)
922 dbgarg (cmd, "index=%d, type=%d, flags=%d, "
923 "pixelformat=%c%c%c%c, description='%s'\n",
924 f->index, f->type, f->flags,
925 (f->pixelformat & 0xff),
926 (f->pixelformat >> 8) & 0xff,
927 (f->pixelformat >> 16) & 0xff,
928 (f->pixelformat >> 24) & 0xff,
929 f->description);
930 break;
931 }
932 case VIDIOC_G_FMT:
933 {
934 struct v4l2_format *f = (struct v4l2_format *)arg;
935
936 memset(f->fmt.raw_data, 0, sizeof(f->fmt.raw_data));
937
938 /* FIXME: Should be one dump per type */
939 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names));
940
941 switch (f->type) {
942 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
943 if (vfd->vidioc_g_fmt_vid_cap)
944 ret = vfd->vidioc_g_fmt_vid_cap(file, fh, f);
945 if (!ret)
946 v4l_print_pix_fmt(vfd, &f->fmt.pix);
947 break;
948 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
949 if (vfd->vidioc_g_fmt_vid_overlay)
950 ret = vfd->vidioc_g_fmt_vid_overlay(file,
951 fh, f);
952 break;
953 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
954 if (vfd->vidioc_g_fmt_vid_out)
955 ret = vfd->vidioc_g_fmt_vid_out(file, fh, f);
956 if (!ret)
957 v4l_print_pix_fmt(vfd, &f->fmt.pix);
958 break;
959 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
960 if (vfd->vidioc_g_fmt_vid_out_overlay)
961 ret = vfd->vidioc_g_fmt_vid_out_overlay(file,
962 fh, f);
963 break;
964 case V4L2_BUF_TYPE_VBI_CAPTURE:
965 if (vfd->vidioc_g_fmt_vbi_cap)
966 ret = vfd->vidioc_g_fmt_vbi_cap(file, fh, f);
967 break;
968 case V4L2_BUF_TYPE_VBI_OUTPUT:
969 if (vfd->vidioc_g_fmt_vbi_out)
970 ret = vfd->vidioc_g_fmt_vbi_out(file, fh, f);
971 break;
972 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
973 if (vfd->vidioc_g_fmt_sliced_vbi_cap)
974 ret = vfd->vidioc_g_fmt_sliced_vbi_cap(file,
975 fh, f);
976 break;
977 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
978 if (vfd->vidioc_g_fmt_sliced_vbi_out)
979 ret = vfd->vidioc_g_fmt_sliced_vbi_out(file,
980 fh, f);
981 break;
982 case V4L2_BUF_TYPE_PRIVATE:
983 if (vfd->vidioc_g_fmt_type_private)
984 ret = vfd->vidioc_g_fmt_type_private(file,
985 fh, f);
986 break;
987 }
988
989 break;
990 }
991 case VIDIOC_S_FMT:
992 {
993 struct v4l2_format *f = (struct v4l2_format *)arg;
994
995 /* FIXME: Should be one dump per type */
996 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names));
997
998 switch (f->type) {
999 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1000 v4l_print_pix_fmt(vfd, &f->fmt.pix);
1001 if (vfd->vidioc_s_fmt_vid_cap)
1002 ret = vfd->vidioc_s_fmt_vid_cap(file, fh, f);
1003 break;
1004 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
1005 if (vfd->vidioc_s_fmt_vid_overlay)
1006 ret = vfd->vidioc_s_fmt_vid_overlay(file,
1007 fh, f);
1008 break;
1009 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1010 v4l_print_pix_fmt(vfd, &f->fmt.pix);
1011 if (vfd->vidioc_s_fmt_vid_out)
1012 ret = vfd->vidioc_s_fmt_vid_out(file, fh, f);
1013 break;
1014 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
1015 if (vfd->vidioc_s_fmt_vid_out_overlay)
1016 ret = vfd->vidioc_s_fmt_vid_out_overlay(file,
1017 fh, f);
1018 break;
1019 case V4L2_BUF_TYPE_VBI_CAPTURE:
1020 if (vfd->vidioc_s_fmt_vbi_cap)
1021 ret = vfd->vidioc_s_fmt_vbi_cap(file, fh, f);
1022 break;
1023 case V4L2_BUF_TYPE_VBI_OUTPUT:
1024 if (vfd->vidioc_s_fmt_vbi_out)
1025 ret = vfd->vidioc_s_fmt_vbi_out(file, fh, f);
1026 break;
1027 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
1028 if (vfd->vidioc_s_fmt_sliced_vbi_cap)
1029 ret = vfd->vidioc_s_fmt_sliced_vbi_cap(file,
1030 fh, f);
1031 break;
1032 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
1033 if (vfd->vidioc_s_fmt_sliced_vbi_out)
1034 ret = vfd->vidioc_s_fmt_sliced_vbi_out(file,
1035 fh, f);
1036 break;
1037 case V4L2_BUF_TYPE_PRIVATE:
1038 if (vfd->vidioc_s_fmt_type_private)
1039 ret = vfd->vidioc_s_fmt_type_private(file,
1040 fh, f);
1041 break;
1042 }
1043 break;
1044 }
1045 case VIDIOC_TRY_FMT:
1046 {
1047 struct v4l2_format *f = (struct v4l2_format *)arg;
1048
1049 /* FIXME: Should be one dump per type */
1050 dbgarg (cmd, "type=%s\n", prt_names(f->type,
1051 v4l2_type_names));
1052 switch (f->type) {
1053 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1054 if (vfd->vidioc_try_fmt_vid_cap)
1055 ret = vfd->vidioc_try_fmt_vid_cap(file, fh, f);
1056 if (!ret)
1057 v4l_print_pix_fmt(vfd, &f->fmt.pix);
1058 break;
1059 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
1060 if (vfd->vidioc_try_fmt_vid_overlay)
1061 ret = vfd->vidioc_try_fmt_vid_overlay(file,
1062 fh, f);
1063 break;
1064 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1065 if (vfd->vidioc_try_fmt_vid_out)
1066 ret = vfd->vidioc_try_fmt_vid_out(file, fh, f);
1067 if (!ret)
1068 v4l_print_pix_fmt(vfd, &f->fmt.pix);
1069 break;
1070 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
1071 if (vfd->vidioc_try_fmt_vid_out_overlay)
1072 ret = vfd->vidioc_try_fmt_vid_out_overlay(file,
1073 fh, f);
1074 break;
1075 case V4L2_BUF_TYPE_VBI_CAPTURE:
1076 if (vfd->vidioc_try_fmt_vbi_cap)
1077 ret = vfd->vidioc_try_fmt_vbi_cap(file, fh, f);
1078 break;
1079 case V4L2_BUF_TYPE_VBI_OUTPUT:
1080 if (vfd->vidioc_try_fmt_vbi_out)
1081 ret = vfd->vidioc_try_fmt_vbi_out(file, fh, f);
1082 break;
1083 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
1084 if (vfd->vidioc_try_fmt_sliced_vbi_cap)
1085 ret = vfd->vidioc_try_fmt_sliced_vbi_cap(file,
1086 fh, f);
1087 break;
1088 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
1089 if (vfd->vidioc_try_fmt_sliced_vbi_out)
1090 ret = vfd->vidioc_try_fmt_sliced_vbi_out(file,
1091 fh, f);
1092 break;
1093 case V4L2_BUF_TYPE_PRIVATE:
1094 if (vfd->vidioc_try_fmt_type_private)
1095 ret = vfd->vidioc_try_fmt_type_private(file,
1096 fh, f);
1097 break;
1098 }
1099
1100 break;
1101 }
1102 /* FIXME: Those buf reqs could be handled here,
1103 with some changes on videobuf to allow its header to be included at
1104 videodev2.h or being merged at videodev2.
1105 */
1106 case VIDIOC_REQBUFS:
1107 {
1108 struct v4l2_requestbuffers *p=arg;
1109
1110 if (!vfd->vidioc_reqbufs)
1111 break;
1112 ret = check_fmt (vfd, p->type);
1113 if (ret)
1114 break;
1115
1116 ret=vfd->vidioc_reqbufs(file, fh, p);
1117 dbgarg (cmd, "count=%d, type=%s, memory=%s\n",
1118 p->count,
1119 prt_names(p->type, v4l2_type_names),
1120 prt_names(p->memory, v4l2_memory_names));
1121 break;
1122 }
1123 case VIDIOC_QUERYBUF:
1124 {
1125 struct v4l2_buffer *p=arg;
1126
1127 if (!vfd->vidioc_querybuf)
1128 break;
1129 ret = check_fmt (vfd, p->type);
1130 if (ret)
1131 break;
1132
1133 ret=vfd->vidioc_querybuf(file, fh, p);
1134 if (!ret)
1135 dbgbuf(cmd,vfd,p);
1136 break;
1137 }
1138 case VIDIOC_QBUF:
1139 {
1140 struct v4l2_buffer *p=arg;
1141
1142 if (!vfd->vidioc_qbuf)
1143 break;
1144 ret = check_fmt (vfd, p->type);
1145 if (ret)
1146 break;
1147
1148 ret=vfd->vidioc_qbuf(file, fh, p);
1149 if (!ret)
1150 dbgbuf(cmd,vfd,p);
1151 break;
1152 }
1153 case VIDIOC_DQBUF:
1154 {
1155 struct v4l2_buffer *p=arg;
1156 if (!vfd->vidioc_dqbuf)
1157 break;
1158 ret = check_fmt (vfd, p->type);
1159 if (ret)
1160 break;
1161
1162 ret=vfd->vidioc_dqbuf(file, fh, p);
1163 if (!ret)
1164 dbgbuf(cmd,vfd,p);
1165 break;
1166 }
1167 case VIDIOC_OVERLAY:
1168 {
1169 int *i = arg;
1170
1171 if (!vfd->vidioc_overlay)
1172 break;
1173 dbgarg (cmd, "value=%d\n",*i);
1174 ret=vfd->vidioc_overlay(file, fh, *i);
1175 break;
1176 }
1177 case VIDIOC_G_FBUF:
1178 {
1179 struct v4l2_framebuffer *p = arg;
1180
1181 if (!vfd->vidioc_g_fbuf)
1182 break;
1183 ret = vfd->vidioc_g_fbuf(file, fh, arg);
1184 if (!ret) {
1185 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
1186 p->capability, p->flags,
1187 (unsigned long)p->base);
1188 v4l_print_pix_fmt(vfd, &p->fmt);
1189 }
1190 break;
1191 }
1192 case VIDIOC_S_FBUF:
1193 {
1194 struct v4l2_framebuffer *p = arg;
1195
1196 if (!vfd->vidioc_s_fbuf)
1197 break;
1198 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
1199 p->capability, p->flags, (unsigned long)p->base);
1200 v4l_print_pix_fmt(vfd, &p->fmt);
1201 ret = vfd->vidioc_s_fbuf(file, fh, arg);
1202 break;
1203 }
1204 case VIDIOC_STREAMON:
1205 {
1206 enum v4l2_buf_type i = *(int *)arg;
1207 if (!vfd->vidioc_streamon)
1208 break;
1209 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
1210 ret=vfd->vidioc_streamon(file, fh,i);
1211 break;
1212 }
1213 case VIDIOC_STREAMOFF:
1214 {
1215 enum v4l2_buf_type i = *(int *)arg;
1216
1217 if (!vfd->vidioc_streamoff)
1218 break;
1219 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
1220 ret=vfd->vidioc_streamoff(file, fh, i);
1221 break;
1222 }
1223 /* ---------- tv norms ---------- */
1224 case VIDIOC_ENUMSTD:
1225 {
1226 struct v4l2_standard *p = arg;
1227 v4l2_std_id id = vfd->tvnorms, curr_id = 0;
1228 unsigned int index = p->index, i, j = 0;
1229 const char *descr = "";
1230
1231 /* Return norm array in a canonical way */
1232 for (i = 0; i <= index && id; i++) {
1233 /* last std value in the standards array is 0, so this
1234 while always ends there since (id & 0) == 0. */
1235 while ((id & standards[j].std) != standards[j].std)
1236 j++;
1237 curr_id = standards[j].std;
1238 descr = standards[j].descr;
1239 j++;
1240 if (curr_id == 0)
1241 break;
1242 if (curr_id != V4L2_STD_PAL &&
1243 curr_id != V4L2_STD_SECAM &&
1244 curr_id != V4L2_STD_NTSC)
1245 id &= ~curr_id;
1246 }
1247 if (i <= index)
1248 return -EINVAL;
1249
1250 v4l2_video_std_construct(p, curr_id, descr);
1251 p->index = index;
1252
1253 dbgarg(cmd, "index=%d, id=0x%Lx, name=%s, fps=%d/%d, "
1254 "framelines=%d\n", p->index,
1255 (unsigned long long)p->id, p->name,
1256 p->frameperiod.numerator,
1257 p->frameperiod.denominator,
1258 p->framelines);
1259
1260 ret = 0;
1261 break;
1262 }
1263 case VIDIOC_G_STD:
1264 {
1265 v4l2_std_id *id = arg;
1266
1267 ret = 0;
1268 /* Calls the specific handler */
1269 if (vfd->vidioc_g_std)
1270 ret = vfd->vidioc_g_std(file, fh, id);
1271 else
1272 *id = vfd->current_norm;
1273
1274 if (!ret)
1275 dbgarg(cmd, "std=0x%08Lx\n", (long long unsigned)*id);
1276 break;
1277 }
1278 case VIDIOC_S_STD:
1279 {
1280 v4l2_std_id *id = arg,norm;
1281
1282 dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id);
1283
1284 norm = (*id) & vfd->tvnorms;
1285 if ( vfd->tvnorms && !norm) /* Check if std is supported */
1286 break;
1287
1288 /* Calls the specific handler */
1289 if (vfd->vidioc_s_std)
1290 ret=vfd->vidioc_s_std(file, fh, &norm);
1291 else
1292 ret=-EINVAL;
1293
1294 /* Updates standard information */
1295 if (ret>=0)
1296 vfd->current_norm=norm;
1297
1298 break;
1299 }
1300 case VIDIOC_QUERYSTD:
1301 {
1302 v4l2_std_id *p=arg;
1303
1304 if (!vfd->vidioc_querystd)
1305 break;
1306 ret=vfd->vidioc_querystd(file, fh, arg);
1307 if (!ret)
1308 dbgarg (cmd, "detected std=%08Lx\n",
1309 (unsigned long long)*p);
1310 break;
1311 }
1312 /* ------ input switching ---------- */
1313 /* FIXME: Inputs can be handled inside videodev2 */
1314 case VIDIOC_ENUMINPUT:
1315 {
1316 struct v4l2_input *p=arg;
1317 int i=p->index;
1318
1319 if (!vfd->vidioc_enum_input)
1320 break;
1321 memset(p, 0, sizeof(*p));
1322 p->index=i;
1323
1324 ret=vfd->vidioc_enum_input(file, fh, p);
1325 if (!ret)
1326 dbgarg (cmd, "index=%d, name=%s, type=%d, "
1327 "audioset=%d, "
1328 "tuner=%d, std=%08Lx, status=%d\n",
1329 p->index,p->name,p->type,p->audioset,
1330 p->tuner,
1331 (unsigned long long)p->std,
1332 p->status);
1333 break;
1334 }
1335 case VIDIOC_G_INPUT:
1336 {
1337 unsigned int *i = arg;
1338
1339 if (!vfd->vidioc_g_input)
1340 break;
1341 ret=vfd->vidioc_g_input(file, fh, i);
1342 if (!ret)
1343 dbgarg (cmd, "value=%d\n",*i);
1344 break;
1345 }
1346 case VIDIOC_S_INPUT:
1347 {
1348 unsigned int *i = arg;
1349
1350 if (!vfd->vidioc_s_input)
1351 break;
1352 dbgarg (cmd, "value=%d\n",*i);
1353 ret=vfd->vidioc_s_input(file, fh, *i);
1354 break;
1355 }
1356
1357 /* ------ output switching ---------- */
1358 case VIDIOC_ENUMOUTPUT:
1359 {
1360 struct v4l2_output *p = arg;
1361 int i = p->index;
1362
1363 if (!vfd->vidioc_enum_output)
1364 break;
1365 memset(p, 0, sizeof(*p));
1366 p->index = i;
1367
1368 ret = vfd->vidioc_enum_output(file, fh, p);
1369 if (!ret)
1370 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1371 "audioset=0x%x, "
1372 "modulator=%d, std=0x%08Lx\n",
1373 p->index, p->name, p->type, p->audioset,
1374 p->modulator, (unsigned long long)p->std);
1375 break;
1376 }
1377 case VIDIOC_G_OUTPUT:
1378 {
1379 unsigned int *i = arg;
1380
1381 if (!vfd->vidioc_g_output)
1382 break;
1383 ret=vfd->vidioc_g_output(file, fh, i);
1384 if (!ret)
1385 dbgarg (cmd, "value=%d\n",*i);
1386 break;
1387 }
1388 case VIDIOC_S_OUTPUT:
1389 {
1390 unsigned int *i = arg;
1391
1392 if (!vfd->vidioc_s_output)
1393 break;
1394 dbgarg (cmd, "value=%d\n",*i);
1395 ret=vfd->vidioc_s_output(file, fh, *i);
1396 break;
1397 }
1398
1399 /* --- controls ---------------------------------------------- */
1400 case VIDIOC_QUERYCTRL:
1401 {
1402 struct v4l2_queryctrl *p = arg;
1403
1404 if (!vfd->vidioc_queryctrl)
1405 break;
1406 ret = vfd->vidioc_queryctrl(file, fh, p);
1407 if (!ret)
1408 dbgarg(cmd, "id=0x%x, type=%d, name=%s, min/max=%d/%d, "
1409 "step=%d, default=%d, flags=0x%08x\n",
1410 p->id, p->type, p->name,
1411 p->minimum, p->maximum,
1412 p->step, p->default_value, p->flags);
1413 else
1414 dbgarg(cmd, "id=0x%x\n", p->id);
1415 break;
1416 }
1417 case VIDIOC_G_CTRL:
1418 {
1419 struct v4l2_control *p = arg;
1420
1421 if (vfd->vidioc_g_ctrl)
1422 ret = vfd->vidioc_g_ctrl(file, fh, p);
1423 else if (vfd->vidioc_g_ext_ctrls) {
1424 struct v4l2_ext_controls ctrls;
1425 struct v4l2_ext_control ctrl;
1426
1427 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);
1428 ctrls.count = 1;
1429 ctrls.controls = &ctrl;
1430 ctrl.id = p->id;
1431 ctrl.value = p->value;
1432 if (check_ext_ctrls(&ctrls, 1)) {
1433 ret = vfd->vidioc_g_ext_ctrls(file, fh, &ctrls);
1434 if (ret == 0)
1435 p->value = ctrl.value;
1436 }
1437 } else
1438 break;
1439 if (!ret)
1440 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
1441 else
1442 dbgarg(cmd, "id=0x%x\n", p->id);
1443 break;
1444 }
1445 case VIDIOC_S_CTRL:
1446 {
1447 struct v4l2_control *p = arg;
1448 struct v4l2_ext_controls ctrls;
1449 struct v4l2_ext_control ctrl;
1450
1451 if (!vfd->vidioc_s_ctrl && !vfd->vidioc_s_ext_ctrls)
1452 break;
1453
1454 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
1455
1456 if (vfd->vidioc_s_ctrl) {
1457 ret = vfd->vidioc_s_ctrl(file, fh, p);
1458 break;
1459 }
1460 if (!vfd->vidioc_s_ext_ctrls)
1461 break;
1462
1463 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);
1464 ctrls.count = 1;
1465 ctrls.controls = &ctrl;
1466 ctrl.id = p->id;
1467 ctrl.value = p->value;
1468 if (check_ext_ctrls(&ctrls, 1))
1469 ret = vfd->vidioc_s_ext_ctrls(file, fh, &ctrls);
1470 break;
1471 }
1472 case VIDIOC_G_EXT_CTRLS:
1473 {
1474 struct v4l2_ext_controls *p = arg;
1475
1476 p->error_idx = p->count;
1477 if (!vfd->vidioc_g_ext_ctrls)
1478 break;
1479 if (check_ext_ctrls(p, 0))
1480 ret = vfd->vidioc_g_ext_ctrls(file, fh, p);
1481 v4l_print_ext_ctrls(cmd, vfd, p, !ret);
1482 break;
1483 }
1484 case VIDIOC_S_EXT_CTRLS:
1485 {
1486 struct v4l2_ext_controls *p = arg;
1487
1488 p->error_idx = p->count;
1489 if (!vfd->vidioc_s_ext_ctrls)
1490 break;
1491 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1492 if (check_ext_ctrls(p, 0))
1493 ret = vfd->vidioc_s_ext_ctrls(file, fh, p);
1494 break;
1495 }
1496 case VIDIOC_TRY_EXT_CTRLS:
1497 {
1498 struct v4l2_ext_controls *p = arg;
1499
1500 p->error_idx = p->count;
1501 if (!vfd->vidioc_try_ext_ctrls)
1502 break;
1503 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1504 if (check_ext_ctrls(p, 0))
1505 ret = vfd->vidioc_try_ext_ctrls(file, fh, p);
1506 break;
1507 }
1508 case VIDIOC_QUERYMENU:
1509 {
1510 struct v4l2_querymenu *p = arg;
1511
1512 if (!vfd->vidioc_querymenu)
1513 break;
1514 ret = vfd->vidioc_querymenu(file, fh, p);
1515 if (!ret)
1516 dbgarg(cmd, "id=0x%x, index=%d, name=%s\n",
1517 p->id, p->index, p->name);
1518 else
1519 dbgarg(cmd, "id=0x%x, index=%d\n",
1520 p->id, p->index);
1521 break;
1522 }
1523 /* --- audio ---------------------------------------------- */
1524 case VIDIOC_ENUMAUDIO:
1525 {
1526 struct v4l2_audio *p = arg;
1527
1528 if (!vfd->vidioc_enumaudio)
1529 break;
1530 ret = vfd->vidioc_enumaudio(file, fh, p);
1531 if (!ret)
1532 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1533 "mode=0x%x\n", p->index, p->name,
1534 p->capability, p->mode);
1535 else
1536 dbgarg(cmd, "index=%d\n", p->index);
1537 break;
1538 }
1539 case VIDIOC_G_AUDIO:
1540 {
1541 struct v4l2_audio *p = arg;
1542 __u32 index = p->index;
1543
1544 if (!vfd->vidioc_g_audio)
1545 break;
1546
1547 memset(p, 0, sizeof(*p));
1548 p->index = index;
1549 ret = vfd->vidioc_g_audio(file, fh, p);
1550 if (!ret)
1551 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1552 "mode=0x%x\n", p->index,
1553 p->name, p->capability, p->mode);
1554 else
1555 dbgarg(cmd, "index=%d\n", p->index);
1556 break;
1557 }
1558 case VIDIOC_S_AUDIO:
1559 {
1560 struct v4l2_audio *p = arg;
1561
1562 if (!vfd->vidioc_s_audio)
1563 break;
1564 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1565 "mode=0x%x\n", p->index, p->name,
1566 p->capability, p->mode);
1567 ret = vfd->vidioc_s_audio(file, fh, p);
1568 break;
1569 }
1570 case VIDIOC_ENUMAUDOUT:
1571 {
1572 struct v4l2_audioout *p=arg;
1573
1574 if (!vfd->vidioc_enumaudout)
1575 break;
1576 dbgarg(cmd, "Enum for index=%d\n", p->index);
1577 ret=vfd->vidioc_enumaudout(file, fh, p);
1578 if (!ret)
1579 dbgarg2("index=%d, name=%s, capability=%d, "
1580 "mode=%d\n", p->index, p->name,
1581 p->capability,p->mode);
1582 break;
1583 }
1584 case VIDIOC_G_AUDOUT:
1585 {
1586 struct v4l2_audioout *p=arg;
1587
1588 if (!vfd->vidioc_g_audout)
1589 break;
1590 dbgarg(cmd, "Enum for index=%d\n", p->index);
1591 ret=vfd->vidioc_g_audout(file, fh, p);
1592 if (!ret)
1593 dbgarg2("index=%d, name=%s, capability=%d, "
1594 "mode=%d\n", p->index, p->name,
1595 p->capability,p->mode);
1596 break;
1597 }
1598 case VIDIOC_S_AUDOUT:
1599 {
1600 struct v4l2_audioout *p=arg;
1601
1602 if (!vfd->vidioc_s_audout)
1603 break;
1604 dbgarg(cmd, "index=%d, name=%s, capability=%d, "
1605 "mode=%d\n", p->index, p->name,
1606 p->capability,p->mode);
1607
1608 ret=vfd->vidioc_s_audout(file, fh, p);
1609 break;
1610 }
1611 case VIDIOC_G_MODULATOR:
1612 {
1613 struct v4l2_modulator *p=arg;
1614 if (!vfd->vidioc_g_modulator)
1615 break;
1616 ret=vfd->vidioc_g_modulator(file, fh, p);
1617 if (!ret)
1618 dbgarg(cmd, "index=%d, name=%s, "
1619 "capability=%d, rangelow=%d,"
1620 " rangehigh=%d, txsubchans=%d\n",
1621 p->index, p->name,p->capability,
1622 p->rangelow, p->rangehigh,
1623 p->txsubchans);
1624 break;
1625 }
1626 case VIDIOC_S_MODULATOR:
1627 {
1628 struct v4l2_modulator *p=arg;
1629 if (!vfd->vidioc_s_modulator)
1630 break;
1631 dbgarg(cmd, "index=%d, name=%s, capability=%d, "
1632 "rangelow=%d, rangehigh=%d, txsubchans=%d\n",
1633 p->index, p->name,p->capability,p->rangelow,
1634 p->rangehigh,p->txsubchans);
1635 ret=vfd->vidioc_s_modulator(file, fh, p);
1636 break;
1637 }
1638 case VIDIOC_G_CROP:
1639 {
1640 struct v4l2_crop *p=arg;
1641 if (!vfd->vidioc_g_crop)
1642 break;
1643 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1644 ret=vfd->vidioc_g_crop(file, fh, p);
1645 if (!ret) {
1646 dbgrect(vfd, "", &p->c);
1647 }
1648 break;
1649 }
1650 case VIDIOC_S_CROP:
1651 {
1652 struct v4l2_crop *p=arg;
1653 if (!vfd->vidioc_s_crop)
1654 break;
1655 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1656 dbgrect(vfd, "", &p->c);
1657 ret=vfd->vidioc_s_crop(file, fh, p);
1658 break;
1659 }
1660 case VIDIOC_CROPCAP:
1661 {
1662 struct v4l2_cropcap *p = arg;
1663
1664 /*FIXME: Should also show v4l2_fract pixelaspect */
1665 if (!vfd->vidioc_cropcap)
1666 break;
1667 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1668 ret = vfd->vidioc_cropcap(file, fh, p);
1669 if (!ret) {
1670 dbgrect(vfd, "bounds ", &p->bounds);
1671 dbgrect(vfd, "defrect ", &p->defrect);
1672 }
1673 break;
1674 }
1675 case VIDIOC_G_JPEGCOMP:
1676 {
1677 struct v4l2_jpegcompression *p=arg;
1678 if (!vfd->vidioc_g_jpegcomp)
1679 break;
1680 ret=vfd->vidioc_g_jpegcomp(file, fh, p);
1681 if (!ret)
1682 dbgarg (cmd, "quality=%d, APPn=%d, "
1683 "APP_len=%d, COM_len=%d, "
1684 "jpeg_markers=%d\n",
1685 p->quality,p->APPn,p->APP_len,
1686 p->COM_len,p->jpeg_markers);
1687 break;
1688 }
1689 case VIDIOC_S_JPEGCOMP:
1690 {
1691 struct v4l2_jpegcompression *p=arg;
1692 if (!vfd->vidioc_g_jpegcomp)
1693 break;
1694 dbgarg (cmd, "quality=%d, APPn=%d, APP_len=%d, "
1695 "COM_len=%d, jpeg_markers=%d\n",
1696 p->quality,p->APPn,p->APP_len,
1697 p->COM_len,p->jpeg_markers);
1698 ret=vfd->vidioc_s_jpegcomp(file, fh, p);
1699 break;
1700 }
1701 case VIDIOC_G_ENC_INDEX:
1702 {
1703 struct v4l2_enc_idx *p=arg;
1704
1705 if (!vfd->vidioc_g_enc_index)
1706 break;
1707 ret=vfd->vidioc_g_enc_index(file, fh, p);
1708 if (!ret)
1709 dbgarg (cmd, "entries=%d, entries_cap=%d\n",
1710 p->entries,p->entries_cap);
1711 break;
1712 }
1713 case VIDIOC_ENCODER_CMD:
1714 {
1715 struct v4l2_encoder_cmd *p = arg;
1716
1717 if (!vfd->vidioc_encoder_cmd)
1718 break;
1719 memset(&p->raw, 0, sizeof(p->raw));
1720 ret = vfd->vidioc_encoder_cmd(file, fh, p);
1721 if (!ret)
1722 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1723 break;
1724 }
1725 case VIDIOC_TRY_ENCODER_CMD:
1726 {
1727 struct v4l2_encoder_cmd *p = arg;
1728
1729 if (!vfd->vidioc_try_encoder_cmd)
1730 break;
1731 memset(&p->raw, 0, sizeof(p->raw));
1732 ret = vfd->vidioc_try_encoder_cmd(file, fh, p);
1733 if (!ret)
1734 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1735 break;
1736 }
1737 case VIDIOC_G_PARM:
1738 {
1739 struct v4l2_streamparm *p=arg;
1740 __u32 type=p->type;
1741
1742 memset(p,0,sizeof(*p));
1743 p->type=type;
1744
1745 if (vfd->vidioc_g_parm) {
1746 ret=vfd->vidioc_g_parm(file, fh, p);
1747 } else {
1748 struct v4l2_standard s;
1749
1750 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1751 return -EINVAL;
1752
1753 v4l2_video_std_construct(&s, vfd->current_norm,
1754 v4l2_norm_to_name(vfd->current_norm));
1755
1756 p->parm.capture.timeperframe = s.frameperiod;
1757 ret=0;
1758 }
1759
1760 dbgarg (cmd, "type=%d\n", p->type);
1761 break;
1762 }
1763 case VIDIOC_S_PARM:
1764 {
1765 struct v4l2_streamparm *p=arg;
1766 if (!vfd->vidioc_s_parm)
1767 break;
1768 dbgarg (cmd, "type=%d\n", p->type);
1769 ret=vfd->vidioc_s_parm(file, fh, p);
1770 break;
1771 }
1772 case VIDIOC_G_TUNER:
1773 {
1774 struct v4l2_tuner *p = arg;
1775 __u32 index = p->index;
1776
1777 if (!vfd->vidioc_g_tuner)
1778 break;
1779
1780 memset(p, 0, sizeof(*p));
1781 p->index = index;
1782
1783 ret = vfd->vidioc_g_tuner(file, fh, p);
1784 if (!ret)
1785 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1786 "capability=0x%x, rangelow=%d, "
1787 "rangehigh=%d, signal=%d, afc=%d, "
1788 "rxsubchans=0x%x, audmode=%d\n",
1789 p->index, p->name, p->type,
1790 p->capability, p->rangelow,
1791 p->rangehigh, p->signal, p->afc,
1792 p->rxsubchans, p->audmode);
1793 break;
1794 }
1795 case VIDIOC_S_TUNER:
1796 {
1797 struct v4l2_tuner *p = arg;
1798
1799 if (!vfd->vidioc_s_tuner)
1800 break;
1801 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1802 "capability=0x%x, rangelow=%d, "
1803 "rangehigh=%d, signal=%d, afc=%d, "
1804 "rxsubchans=0x%x, audmode=%d\n",
1805 p->index, p->name, p->type,
1806 p->capability, p->rangelow,
1807 p->rangehigh, p->signal, p->afc,
1808 p->rxsubchans, p->audmode);
1809 ret = vfd->vidioc_s_tuner(file, fh, p);
1810 break;
1811 }
1812 case VIDIOC_G_FREQUENCY:
1813 {
1814 struct v4l2_frequency *p = arg;
1815
1816 if (!vfd->vidioc_g_frequency)
1817 break;
1818
1819 memset(p->reserved, 0, sizeof(p->reserved));
1820
1821 ret = vfd->vidioc_g_frequency(file, fh, p);
1822 if (!ret)
1823 dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n",
1824 p->tuner, p->type, p->frequency);
1825 break;
1826 }
1827 case VIDIOC_S_FREQUENCY:
1828 {
1829 struct v4l2_frequency *p=arg;
1830 if (!vfd->vidioc_s_frequency)
1831 break;
1832 dbgarg (cmd, "tuner=%d, type=%d, frequency=%d\n",
1833 p->tuner,p->type,p->frequency);
1834 ret=vfd->vidioc_s_frequency(file, fh, p);
1835 break;
1836 }
1837 case VIDIOC_G_SLICED_VBI_CAP:
1838 {
1839 struct v4l2_sliced_vbi_cap *p = arg;
1840 __u32 type = p->type;
1841
1842 if (!vfd->vidioc_g_sliced_vbi_cap)
1843 break;
1844 memset(p, 0, sizeof(*p));
1845 p->type = type;
1846 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1847 ret = vfd->vidioc_g_sliced_vbi_cap(file, fh, p);
1848 if (!ret)
1849 dbgarg2("service_set=%d\n", p->service_set);
1850 break;
1851 }
1852 case VIDIOC_LOG_STATUS:
1853 {
1854 if (!vfd->vidioc_log_status)
1855 break;
1856 ret=vfd->vidioc_log_status(file, fh);
1857 break;
1858 }
1859#ifdef CONFIG_VIDEO_ADV_DEBUG
1860 case VIDIOC_DBG_G_REGISTER:
1861 {
1862 struct v4l2_register *p=arg;
1863 if (!capable(CAP_SYS_ADMIN))
1864 ret=-EPERM;
1865 else if (vfd->vidioc_g_register)
1866 ret=vfd->vidioc_g_register(file, fh, p);
1867 break;
1868 }
1869 case VIDIOC_DBG_S_REGISTER:
1870 {
1871 struct v4l2_register *p=arg;
1872 if (!capable(CAP_SYS_ADMIN))
1873 ret=-EPERM;
1874 else if (vfd->vidioc_s_register)
1875 ret=vfd->vidioc_s_register(file, fh, p);
1876 break;
1877 }
1878#endif
1879 case VIDIOC_G_CHIP_IDENT:
1880 {
1881 struct v4l2_chip_ident *p=arg;
1882 if (!vfd->vidioc_g_chip_ident)
1883 break;
1884 ret=vfd->vidioc_g_chip_ident(file, fh, p);
1885 if (!ret)
1886 dbgarg (cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision);
1887 break;
1888 }
1889 default:
1890 {
1891 if (!vfd->vidioc_default)
1892 break;
1893 ret = vfd->vidioc_default(file, fh, cmd, arg);
1894 break;
1895 }
1896 case VIDIOC_S_HW_FREQ_SEEK:
1897 {
1898 struct v4l2_hw_freq_seek *p = arg;
1899 if (!vfd->vidioc_s_hw_freq_seek)
1900 break;
1901 dbgarg(cmd,
1902 "tuner=%d, type=%d, seek_upward=%d, wrap_around=%d\n",
1903 p->tuner, p->type, p->seek_upward, p->wrap_around);
1904 ret = vfd->vidioc_s_hw_freq_seek(file, fh, p);
1905 break;
1906 }
1907 } /* switch */
1908
1909 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) {
1910 if (ret < 0) {
1911 v4l_print_ioctl(vfd->name, cmd);
1912 printk(KERN_CONT " error %d\n", ret);
1913 }
1914 }
1915
1916 return ret;
1917}
1918
1919int video_ioctl2 (struct inode *inode, struct file *file,
1920 unsigned int cmd, unsigned long arg)
1921{
1922 char sbuf[128];
1923 void *mbuf = NULL;
1924 void *parg = NULL;
1925 int err = -EINVAL;
1926 int is_ext_ctrl;
1927 size_t ctrls_size = 0;
1928 void __user *user_ptr = NULL;
1929
1930#ifdef __OLD_VIDIOC_
1931 cmd = video_fix_command(cmd);
1932#endif
1933 is_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||
1934 cmd == VIDIOC_TRY_EXT_CTRLS);
1935
1936 /* Copy arguments into temp kernel buffer */
1937 switch (_IOC_DIR(cmd)) {
1938 case _IOC_NONE:
1939 parg = NULL;
1940 break;
1941 case _IOC_READ:
1942 case _IOC_WRITE:
1943 case (_IOC_WRITE | _IOC_READ):
1944 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
1945 parg = sbuf;
1946 } else {
1947 /* too big to allocate from stack */
1948 mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
1949 if (NULL == mbuf)
1950 return -ENOMEM;
1951 parg = mbuf;
1952 }
1953
1954 err = -EFAULT;
1955 if (_IOC_DIR(cmd) & _IOC_WRITE)
1956 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
1957 goto out;
1958 break;
1959 }
1960
1961 if (is_ext_ctrl) {
1962 struct v4l2_ext_controls *p = parg;
1963
1964 /* In case of an error, tell the caller that it wasn't
1965 a specific control that caused it. */
1966 p->error_idx = p->count;
1967 user_ptr = (void __user *)p->controls;
1968 if (p->count) {
1969 ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
1970 /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
1971 mbuf = kmalloc(ctrls_size, GFP_KERNEL);
1972 err = -ENOMEM;
1973 if (NULL == mbuf)
1974 goto out_ext_ctrl;
1975 err = -EFAULT;
1976 if (copy_from_user(mbuf, user_ptr, ctrls_size))
1977 goto out_ext_ctrl;
1978 p->controls = mbuf;
1979 }
1980 }
1981
1982 /* Handles IOCTL */
1983 err = __video_do_ioctl(inode, file, cmd, parg);
1984 if (err == -ENOIOCTLCMD)
1985 err = -EINVAL;
1986 if (is_ext_ctrl) {
1987 struct v4l2_ext_controls *p = parg;
1988
1989 p->controls = (void *)user_ptr;
1990 if (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))
1991 err = -EFAULT;
1992 goto out_ext_ctrl;
1993 }
1994 if (err < 0)
1995 goto out;
1996
1997out_ext_ctrl:
1998 /* Copy results into user buffer */
1999 switch (_IOC_DIR(cmd))
2000 {
2001 case _IOC_READ:
2002 case (_IOC_WRITE | _IOC_READ):
2003 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
2004 err = -EFAULT;
2005 break;
2006 }
2007
2008out:
2009 kfree(mbuf);
2010 return err;
2011}
2012EXPORT_SYMBOL(video_ioctl2);
2013
2014/**
2015 * get_index - assign stream number based on parent device
2016 * @vdev: video_device to assign index number to, vdev->dev should be assigned
2017 * @num: -1 if auto assign, requested number otherwise
2018 *
2019 *
2020 * returns -ENFILE if num is already in use, a free index number if
2021 * successful.
2022 */
2023static int get_index(struct video_device *vdev, int num)
2024{
2025 u32 used = 0;
2026 const int max_index = sizeof(used) * 8 - 1;
2027 int i;
2028
2029 /* Currently a single v4l driver instance cannot create more than
2030 32 devices.
2031 Increase to u64 or an array of u32 if more are needed. */
2032 if (num > max_index) {
2033 printk(KERN_ERR "videodev: %s num is too large\n", __func__);
2034 return -EINVAL;
2035 }
2036
2037 for (i = 0; i < VIDEO_NUM_DEVICES; i++) {
2038 if (video_device[i] != NULL &&
2039 video_device[i] != vdev &&
2040 video_device[i]->dev == vdev->dev) {
2041 used |= 1 << video_device[i]->index;
2042 }
2043 }
2044
2045 if (num >= 0) {
2046 if (used & (1 << num))
2047 return -ENFILE;
2048 return num;
2049 }
2050
2051 i = ffz(used);
2052 return i > max_index ? -ENFILE : i;
2053}
2054
2055static const struct file_operations video_fops;
2056
2057int video_register_device(struct video_device *vfd, int type, int nr)
2058{
2059 return video_register_device_index(vfd, type, nr, -1);
2060}
2061EXPORT_SYMBOL(video_register_device);
2062
2063/**
2064 * video_register_device - register video4linux devices
2065 * @vfd: video device structure we want to register
2066 * @type: type of device to register
2067 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ...
2068 * -1 == first free)
2069 *
2070 * The registration code assigns minor numbers based on the type
2071 * requested. -ENFILE is returned in all the device slots for this
2072 * category are full. If not then the minor field is set and the
2073 * driver initialize function is called (if non %NULL).
2074 *
2075 * Zero is returned on success.
2076 *
2077 * Valid types are
2078 *
2079 * %VFL_TYPE_GRABBER - A frame grabber
2080 *
2081 * %VFL_TYPE_VTX - A teletext device
2082 *
2083 * %VFL_TYPE_VBI - Vertical blank data (undecoded)
2084 *
2085 * %VFL_TYPE_RADIO - A radio card
2086 */
2087
2088int video_register_device_index(struct video_device *vfd, int type, int nr,
2089 int index)
2090{
2091 int i=0;
2092 int base;
2093 int end;
2094 int ret;
2095 char *name_base;
2096
2097 switch(type)
2098 {
2099 case VFL_TYPE_GRABBER:
2100 base=MINOR_VFL_TYPE_GRABBER_MIN;
2101 end=MINOR_VFL_TYPE_GRABBER_MAX+1;
2102 name_base = "video";
2103 break;
2104 case VFL_TYPE_VTX:
2105 base=MINOR_VFL_TYPE_VTX_MIN;
2106 end=MINOR_VFL_TYPE_VTX_MAX+1;
2107 name_base = "vtx";
2108 break;
2109 case VFL_TYPE_VBI:
2110 base=MINOR_VFL_TYPE_VBI_MIN;
2111 end=MINOR_VFL_TYPE_VBI_MAX+1;
2112 name_base = "vbi";
2113 break;
2114 case VFL_TYPE_RADIO:
2115 base=MINOR_VFL_TYPE_RADIO_MIN;
2116 end=MINOR_VFL_TYPE_RADIO_MAX+1;
2117 name_base = "radio";
2118 break;
2119 default:
2120 printk(KERN_ERR "%s called with unknown type: %d\n",
2121 __func__, type);
2122 return -1;
2123 }
2124
2125 /* pick a minor number */
2126 mutex_lock(&videodev_lock);
2127 if (nr >= 0 && nr < end-base) {
2128 /* use the one the driver asked for */
2129 i = base+nr;
2130 if (NULL != video_device[i]) {
2131 mutex_unlock(&videodev_lock);
2132 return -ENFILE;
2133 }
2134 } else {
2135 /* use first free */
2136 for(i=base;i<end;i++)
2137 if (NULL == video_device[i])
2138 break;
2139 if (i == end) {
2140 mutex_unlock(&videodev_lock);
2141 return -ENFILE;
2142 }
2143 }
2144 video_device[i]=vfd;
2145 vfd->minor=i;
2146
2147 ret = get_index(vfd, index);
2148 vfd->index = ret;
2149
2150 mutex_unlock(&videodev_lock);
2151
2152 if (ret < 0) {
2153 printk(KERN_ERR "%s: get_index failed\n", __func__);
2154 goto fail_minor;
2155 }
2156
2157 mutex_init(&vfd->lock);
2158
2159 /* sysfs class */
2160 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
2161 vfd->class_dev.class = &video_class;
2162 vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
2163 if (vfd->dev)
2164 vfd->class_dev.parent = vfd->dev;
2165 sprintf(vfd->class_dev.bus_id, "%s%d", name_base, i - base);
2166 ret = device_register(&vfd->class_dev);
2167 if (ret < 0) {
2168 printk(KERN_ERR "%s: device_register failed\n", __func__);
2169 goto fail_minor;
2170 }
2171
2172#if 1
2173 /* needed until all drivers are fixed */
2174 if (!vfd->release)
2175 printk(KERN_WARNING "videodev: \"%s\" has no release callback. "
2176 "Please fix your driver for proper sysfs support, see "
2177 "http://lwn.net/Articles/36850/\n", vfd->name);
2178#endif
2179 return 0;
2180
2181fail_minor:
2182 mutex_lock(&videodev_lock);
2183 video_device[vfd->minor] = NULL;
2184 vfd->minor = -1;
2185 mutex_unlock(&videodev_lock);
2186 return ret;
2187}
2188EXPORT_SYMBOL(video_register_device_index);
2189
2190/**
2191 * video_unregister_device - unregister a video4linux device
2192 * @vfd: the device to unregister
2193 *
2194 * This unregisters the passed device and deassigns the minor
2195 * number. Future open calls will be met with errors.
2196 */
2197
2198void video_unregister_device(struct video_device *vfd)
2199{
2200 mutex_lock(&videodev_lock);
2201 if(video_device[vfd->minor]!=vfd)
2202 panic("videodev: bad unregister");
2203
2204 video_device[vfd->minor]=NULL;
2205 device_unregister(&vfd->class_dev);
2206 mutex_unlock(&videodev_lock);
2207}
2208EXPORT_SYMBOL(video_unregister_device);
2209
2210/*
2211 * Video fs operations
2212 */
2213static const struct file_operations video_fops=
2214{
2215 .owner = THIS_MODULE,
2216 .llseek = no_llseek,
2217 .open = video_open,
2218};
2219
2220/*
2221 * Initialise video for linux
2222 */
2223
2224static int __init videodev_init(void)
2225{
2226 int ret;
2227
2228 printk(KERN_INFO "Linux video capture interface: v2.00\n");
2229 if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, &video_fops)) {
2230 printk(KERN_WARNING "video_dev: unable to get major %d\n", VIDEO_MAJOR);
2231 return -EIO;
2232 }
2233
2234 ret = class_register(&video_class);
2235 if (ret < 0) {
2236 unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME);
2237 printk(KERN_WARNING "video_dev: class_register failed\n");
2238 return -EIO;
2239 }
2240
2241 return 0;
2242}
2243
2244static void __exit videodev_exit(void)
2245{
2246 class_unregister(&video_class);
2247 unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME);
2248}
2249
2250module_init(videodev_init)
2251module_exit(videodev_exit)
2252
2253MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>");
2254MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2");
2255MODULE_LICENSE("GPL");
2256
2257
2258/*
2259 * Local variables:
2260 * c-basic-offset: 8
2261 * End:
2262 */
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 059b01c11dc1..e4b3a006c71e 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -35,6 +35,7 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <media/videobuf-vmalloc.h> 36#include <media/videobuf-vmalloc.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-ioctl.h>
38#include <linux/kthread.h> 39#include <linux/kthread.h>
39#include <linux/highmem.h> 40#include <linux/highmem.h>
40#include <linux/freezer.h> 41#include <linux/freezer.h>
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index 33f702698a56..a63e11f8399b 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -59,6 +59,7 @@
59#include <linux/delay.h> 59#include <linux/delay.h>
60#include <linux/videodev.h> 60#include <linux/videodev.h>
61#include <media/v4l2-common.h> 61#include <media/v4l2-common.h>
62#include <media/v4l2-ioctl.h>
62#include <linux/parport.h> 63#include <linux/parport.h>
63 64
64/*#define DEBUG*/ /* Undef me for production */ 65/*#define DEBUG*/ /* Undef me for production */
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index 840522442d07..56bbeec542c5 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -42,6 +42,7 @@
42#include <asm/page.h> 42#include <asm/page.h>
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44#include <linux/page-flags.h> 44#include <linux/page-flags.h>
45#include <media/v4l2-ioctl.h>
45 46
46#include "w9968cf.h" 47#include "w9968cf.h"
47#include "w9968cf_decoder.h" 48#include "w9968cf_decoder.h"
@@ -3555,7 +3556,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3555 cam->v4ldev->minor = video_nr[dev_nr]; 3556 cam->v4ldev->minor = video_nr[dev_nr];
3556 cam->v4ldev->release = video_device_release; 3557 cam->v4ldev->release = video_device_release;
3557 video_set_drvdata(cam->v4ldev, cam); 3558 video_set_drvdata(cam->v4ldev, cam);
3558 cam->v4ldev->dev = &cam->dev; 3559 cam->v4ldev->parent = &cam->dev;
3559 3560
3560 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 3561 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
3561 video_nr[dev_nr]); 3562 video_nr[dev_nr]);
diff --git a/drivers/media/video/zc0301/zc0301.h b/drivers/media/video/zc0301/zc0301.h
index 7bbab541a309..b1b5cceb4baa 100644
--- a/drivers/media/video/zc0301/zc0301.h
+++ b/drivers/media/video/zc0301/zc0301.h
@@ -25,6 +25,7 @@
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/v4l2-ioctl.h>
28#include <linux/device.h> 29#include <linux/device.h>
29#include <linux/list.h> 30#include <linux/list.h>
30#include <linux/spinlock.h> 31#include <linux/spinlock.h>
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index c0675921fe20..e1e1b19a0aed 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -71,6 +71,7 @@
71 71
72#include <linux/videodev.h> 72#include <linux/videodev.h>
73#include <media/v4l2-common.h> 73#include <media/v4l2-common.h>
74#include <media/v4l2-ioctl.h>
74#include "videocodec.h" 75#include "videocodec.h"
75 76
76#include <asm/byteorder.h> 77#include <asm/byteorder.h>
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index 485df2e36132..ea5265c22983 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -35,6 +35,7 @@
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/highmem.h> 36#include <linux/highmem.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-ioctl.h>
38 39
39 40
40/* Version Information */ 41/* Version Information */