aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/Kconfig28
-rw-r--r--drivers/media/video/adv7170.c10
-rw-r--r--drivers/media/video/adv7175.c6
-rw-r--r--drivers/media/video/arv.c54
-rw-r--r--drivers/media/video/bt819.c10
-rw-r--r--drivers/media/video/bt856.c4
-rw-r--r--drivers/media/video/bw-qcam.c106
-rw-r--r--drivers/media/video/c-qcam.c66
-rw-r--r--drivers/media/video/cpia.c656
-rw-r--r--drivers/media/video/cpia.h52
-rw-r--r--drivers/media/video/cpia_pp.c106
-rw-r--r--drivers/media/video/cpia_usb.c40
-rw-r--r--drivers/media/video/cs8420.h2
-rw-r--r--drivers/media/video/dabusb.c18
-rw-r--r--drivers/media/video/dabusb.h4
-rw-r--r--drivers/media/video/dsbr100.c44
-rw-r--r--drivers/media/video/et61x251/et61x251.h8
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c210
-rw-r--r--drivers/media/video/et61x251/et61x251_sensor.h20
-rw-r--r--drivers/media/video/et61x251/et61x251_tas5130d1b.c10
-rw-r--r--drivers/media/video/ov511.c92
-rw-r--r--drivers/media/video/ov511.h8
-rw-r--r--drivers/media/video/ovcamchip/Makefile2
-rw-r--r--drivers/media/video/ovcamchip/ovcamchip_core.c6
-rw-r--r--drivers/media/video/ovcamchip/ovcamchip_priv.h2
-rw-r--r--drivers/media/video/planb.c128
-rw-r--r--drivers/media/video/planb.h6
-rw-r--r--drivers/media/video/pms.c136
-rw-r--r--drivers/media/video/pwc/Makefile2
-rw-r--r--drivers/media/video/pwc/philips.txt66
-rw-r--r--drivers/media/video/pwc/pwc-ctrl.c374
-rw-r--r--drivers/media/video/pwc/pwc-if.c302
-rw-r--r--drivers/media/video/pwc/pwc-ioctl.h40
-rw-r--r--drivers/media/video/pwc/pwc-kiara.c288
-rw-r--r--drivers/media/video/pwc/pwc-misc.c26
-rw-r--r--drivers/media/video/pwc/pwc-nala.h2
-rw-r--r--drivers/media/video/pwc/pwc-timon.c288
-rw-r--r--drivers/media/video/pwc/pwc-uncompress.c6
-rw-r--r--drivers/media/video/pwc/pwc-uncompress.h2
-rw-r--r--drivers/media/video/pwc/pwc.h4
-rw-r--r--drivers/media/video/saa5249.c112
-rw-r--r--drivers/media/video/saa7110.c4
-rw-r--r--drivers/media/video/saa7111.c4
-rw-r--r--drivers/media/video/saa7114.c12
-rw-r--r--drivers/media/video/saa7121.h6
-rw-r--r--drivers/media/video/saa7146.h10
-rw-r--r--drivers/media/video/saa7146reg.h4
-rw-r--r--drivers/media/video/saa7185.c4
-rw-r--r--drivers/media/video/saa7196.h4
-rw-r--r--drivers/media/video/se401.c216
-rw-r--r--drivers/media/video/se401.h6
-rw-r--r--drivers/media/video/sn9c102/Makefile6
-rw-r--r--drivers/media/video/sn9c102/sn9c102.h8
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c264
-rw-r--r--drivers/media/video/sn9c102/sn9c102_hv7131d.c16
-rw-r--r--drivers/media/video/sn9c102/sn9c102_mi0343.c106
-rw-r--r--drivers/media/video/sn9c102/sn9c102_ov7630.c14
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas106b.c16
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas202bca.c6
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas202bcb.c18
-rw-r--r--drivers/media/video/sn9c102/sn9c102_sensor.h70
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5110c1b.c12
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5130d1b.c12
-rw-r--r--drivers/media/video/stradis.c10
-rw-r--r--drivers/media/video/stv680.c48
-rw-r--r--drivers/media/video/stv680.h142
-rw-r--r--drivers/media/video/tda9840.c2
-rw-r--r--drivers/media/video/tea6415c.c2
-rw-r--r--drivers/media/video/tea6420.c2
-rw-r--r--drivers/media/video/tuner-3036.c50
-rw-r--r--drivers/media/video/usbvideo/ibmcam.c10
-rw-r--r--drivers/media/video/usbvideo/konicawc.c48
-rw-r--r--drivers/media/video/usbvideo/ultracam.c2
-rw-r--r--drivers/media/video/usbvideo/usbvideo.c42
-rw-r--r--drivers/media/video/usbvideo/usbvideo.h10
-rw-r--r--drivers/media/video/usbvideo/vicam.c28
-rw-r--r--drivers/media/video/videocodec.h52
-rw-r--r--drivers/media/video/vino.c4
-rw-r--r--drivers/media/video/vpx3220.c20
-rw-r--r--drivers/media/video/w9966.c102
-rw-r--r--drivers/media/video/w9968cf.c930
-rw-r--r--drivers/media/video/w9968cf.h12
-rw-r--r--drivers/media/video/w9968cf_decoder.h8
-rw-r--r--drivers/media/video/w9968cf_vpp.h2
-rw-r--r--drivers/media/video/zc0301/zc0301.h6
-rw-r--r--drivers/media/video/zc0301/zc0301_core.c148
-rw-r--r--drivers/media/video/zc0301/zc0301_pas202bcb.c12
-rw-r--r--drivers/media/video/zc0301/zc0301_sensor.h4
-rw-r--r--drivers/media/video/zoran.h2
-rw-r--r--drivers/media/video/zoran_card.c2
-rw-r--r--drivers/media/video/zoran_card.h2
-rw-r--r--drivers/media/video/zoran_device.c16
-rw-r--r--drivers/media/video/zoran_device.h2
-rw-r--r--drivers/media/video/zoran_driver.c16
-rw-r--r--drivers/media/video/zoran_procfs.c2
-rw-r--r--drivers/media/video/zoran_procfs.h2
-rw-r--r--drivers/media/video/zr36016.c22
-rw-r--r--drivers/media/video/zr36050.c16
-rw-r--r--drivers/media/video/zr36057.h10
-rw-r--r--drivers/media/video/zr36060.c20
-rw-r--r--drivers/media/video/zr36120.c46
-rw-r--r--drivers/media/video/zr36120.h6
102 files changed, 3012 insertions, 3012 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 1f8a46b5916e..f31a19890b15 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -370,7 +370,7 @@ config VIDEO_SAA7127
370# 370#
371 371
372menu "V4L USB devices" 372menu "V4L USB devices"
373 depends on USB && VIDEO_DEV 373 depends on USB && VIDEO_DEV
374 374
375source "drivers/media/video/em28xx/Kconfig" 375source "drivers/media/video/em28xx/Kconfig"
376 376
@@ -528,17 +528,17 @@ config USB_W9968CF
528 ---help--- 528 ---help---
529 Say Y here if you want support for cameras based on OV681 or 529 Say Y here if you want support for cameras based on OV681 or
530 Winbond W9967CF/W9968CF JPEG USB Dual Mode Camera Chips. 530 Winbond W9967CF/W9968CF JPEG USB Dual Mode Camera Chips.
531 531
532 This driver has an optional plugin, which is distributed as a 532 This driver has an optional plugin, which is distributed as a
533 separate module only (released under GPL). It allows to use higher 533 separate module only (released under GPL). It allows to use higher
534 resolutions and framerates, but cannot be included in the official 534 resolutions and framerates, but cannot be included in the official
535 Linux kernel for performance purposes. 535 Linux kernel for performance purposes.
536 536
537 See <file:Documentation/usb/w9968cf.txt> for more informations. 537 See <file:Documentation/usb/w9968cf.txt> for more informations.
538 538
539 This driver uses the Video For Linux and the I2C APIs. It needs the 539 This driver uses the Video For Linux and the I2C APIs. It needs the
540 OmniVision Camera Chip support as well. You must say Y or M to 540 OmniVision Camera Chip support as well. You must say Y or M to
541 "Video For Linux", "I2C Support" and "OmniVision Camera Chip 541 "Video For Linux", "I2C Support" and "OmniVision Camera Chip
542 support" to use this driver. 542 support" to use this driver.
543 543
544 To compile this driver as a module, choose M here: the 544 To compile this driver as a module, choose M here: the
@@ -564,20 +564,20 @@ config USB_PWC
564 depends on USB && VIDEO_DEV 564 depends on USB && VIDEO_DEV
565 ---help--- 565 ---help---
566 Say Y or M here if you want to use one of these Philips & OEM 566 Say Y or M here if you want to use one of these Philips & OEM
567 webcams: 567 webcams:
568 * Philips PCA645, PCA646 568 * Philips PCA645, PCA646
569 * Philips PCVC675, PCVC680, PCVC690 569 * Philips PCVC675, PCVC680, PCVC690
570 * Philips PCVC720/40, PCVC730, PCVC740, PCVC750 570 * Philips PCVC720/40, PCVC730, PCVC740, PCVC750
571 * Askey VC010 571 * Askey VC010
572 * Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro' 572 * Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro'
573 and 'Orbit'/'Sphere' 573 and 'Orbit'/'Sphere'
574 * Samsung MPC-C10, MPC-C30 574 * Samsung MPC-C10, MPC-C30
575 * Creative Webcam 5, Pro Ex 575 * Creative Webcam 5, Pro Ex
576 * SOTEC Afina Eye 576 * SOTEC Afina Eye
577 * Visionite VCS-UC300, VCS-UM100 577 * Visionite VCS-UC300, VCS-UM100
578 578
579 The PCA635, PCVC665 and PCVC720/20 are not supported by this driver 579 The PCA635, PCVC665 and PCVC720/20 are not supported by this driver
580 and never will be, but the 665 and 720/20 are supported by other 580 and never will be, but the 665 and 720/20 are supported by other
581 drivers. 581 drivers.
582 582
583 See <file:Documentation/usb/philips.txt> for more information and 583 See <file:Documentation/usb/philips.txt> for more information and
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 671e36db224d..48709582a186 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * adv7170 - adv7170, adv7171 video encoder driver version 0.0.1 2 * adv7170 - adv7170, adv7171 video encoder driver version 0.0.1
3 * 3 *
4 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com> 4 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
5 * 5 *
6 * Based on adv7176 driver by: 6 * Based on adv7176 driver by:
7 * 7 *
8 * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 8 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
9 * Copyright (C) 1999 Wolfgang Scherr <scherr@net4you.net> 9 * Copyright (C) 1999 Wolfgang Scherr <scherr@net4you.net>
@@ -173,7 +173,7 @@ adv7170_write_block (struct i2c_client *client,
173static const unsigned char init_NTSC[] = { 173static const unsigned char init_NTSC[] = {
174 0x00, 0x10, // MR0 174 0x00, 0x10, // MR0
175 0x01, 0x20, // MR1 175 0x01, 0x20, // MR1
176 0x02, 0x0e, // MR2 RTC control: bits 2 and 1 176 0x02, 0x0e, // MR2 RTC control: bits 2 and 1
177 0x03, 0x80, // MR3 177 0x03, 0x80, // MR3
178 0x04, 0x30, // MR4 178 0x04, 0x30, // MR4
179 0x05, 0x00, // Reserved 179 0x05, 0x00, // Reserved
@@ -196,7 +196,7 @@ static const unsigned char init_NTSC[] = {
196 0x16, 0x00, // CGMS_WSS_0 196 0x16, 0x00, // CGMS_WSS_0
197 0x17, 0x00, // CGMS_WSS_1 197 0x17, 0x00, // CGMS_WSS_1
198 0x18, 0x00, // CGMS_WSS_2 198 0x18, 0x00, // CGMS_WSS_2
199 0x19, 0x00, // Teletext Ctl 199 0x19, 0x00, // Teletext Ctl
200}; 200};
201 201
202static const unsigned char init_PAL[] = { 202static const unsigned char init_PAL[] = {
@@ -381,7 +381,7 @@ static unsigned short normal_i2c[] =
381}; 381};
382 382
383static unsigned short ignore = I2C_CLIENT_END; 383static unsigned short ignore = I2C_CLIENT_END;
384 384
385static struct i2c_client_address_data addr_data = { 385static struct i2c_client_address_data addr_data = {
386 .normal_i2c = normal_i2c, 386 .normal_i2c = normal_i2c,
387 .probe = &ignore, 387 .probe = &ignore,
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index 085e8863cacb..68e7d7aff5e6 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * adv7175 - adv7175a video encoder driver version 0.0.3 2 * adv7175 - adv7175a video encoder driver version 0.0.3
3 * 3 *
4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -233,7 +233,7 @@ adv7175_command (struct i2c_client *client,
233 sizeof(init_common)); 233 sizeof(init_common));
234 adv7175_write(client, 0x07, TR0MODE | TR0RST); 234 adv7175_write(client, 0x07, TR0MODE | TR0RST);
235 adv7175_write(client, 0x07, TR0MODE); 235 adv7175_write(client, 0x07, TR0MODE);
236 break; 236 break;
237 237
238 case ENCODER_GET_CAPABILITIES: 238 case ENCODER_GET_CAPABILITIES:
239 { 239 {
@@ -399,7 +399,7 @@ static unsigned short normal_i2c[] =
399}; 399};
400 400
401static unsigned short ignore = I2C_CLIENT_END; 401static unsigned short ignore = I2C_CLIENT_END;
402 402
403static struct i2c_client_address_data addr_data = { 403static struct i2c_client_address_data addr_data = {
404 .normal_i2c = normal_i2c, 404 .normal_i2c = normal_i2c,
405 .probe = &ignore, 405 .probe = &ignore,
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index c586f64b6b7f..dbe025170599 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -161,39 +161,39 @@ void iic(int n, unsigned long addr, unsigned long data1, unsigned long data2,
161{ 161{
162 int i; 162 int i;
163 163
164 /* Slave Address */ 164 /* Slave Address */
165 ar_outl(addr, PLDI2CDATA); 165 ar_outl(addr, PLDI2CDATA);
166 wait_for_vsync(); 166 wait_for_vsync();
167 167
168 /* Start */ 168 /* Start */
169 ar_outl(1, PLDI2CCND); 169 ar_outl(1, PLDI2CCND);
170 wait_acknowledge(); 170 wait_acknowledge();
171 171
172 /* Transfer data 1 */ 172 /* Transfer data 1 */
173 ar_outl(data1, PLDI2CDATA); 173 ar_outl(data1, PLDI2CDATA);
174 wait_for_vsync(); 174 wait_for_vsync();
175 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); 175 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
176 wait_acknowledge(); 176 wait_acknowledge();
177 177
178 /* Transfer data 2 */ 178 /* Transfer data 2 */
179 ar_outl(data2, PLDI2CDATA); 179 ar_outl(data2, PLDI2CDATA);
180 wait_for_vsync(); 180 wait_for_vsync();
181 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); 181 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
182 wait_acknowledge(); 182 wait_acknowledge();
183 183
184 if (n == 3) { 184 if (n == 3) {
185 /* Transfer data 3 */ 185 /* Transfer data 3 */
186 ar_outl(data3, PLDI2CDATA); 186 ar_outl(data3, PLDI2CDATA);
187 wait_for_vsync(); 187 wait_for_vsync();
188 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); 188 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
189 wait_acknowledge(); 189 wait_acknowledge();
190 } 190 }
191 191
192 /* Stop */ 192 /* Stop */
193 for (i = 0; i < 100; i++) 193 for (i = 0; i < 100; i++)
194 cpu_relax(); 194 cpu_relax();
195 ar_outl(2, PLDI2CCND); 195 ar_outl(2, PLDI2CCND);
196 ar_outl(2, PLDI2CCND); 196 ar_outl(2, PLDI2CCND);
197 197
198 while (ar_inl(PLDI2CSTS) & PLDI2CSTS_BB) 198 while (ar_inl(PLDI2CSTS) & PLDI2CSTS_BB)
199 cpu_relax(); 199 cpu_relax();
@@ -204,24 +204,24 @@ void init_iic(void)
204{ 204{
205 DEBUG(1, "init_iic:\n"); 205 DEBUG(1, "init_iic:\n");
206 206
207 /* 207 /*
208 * ICU Setting (iic) 208 * ICU Setting (iic)
209 */ 209 */
210 /* I2C Setting */ 210 /* I2C Setting */
211 ar_outl(0x0, PLDI2CCR); /* I2CCR Disable */ 211 ar_outl(0x0, PLDI2CCR); /* I2CCR Disable */
212 ar_outl(0x0300, PLDI2CMOD); /* I2CMOD ACK/8b-data/7b-addr/auto */ 212 ar_outl(0x0300, PLDI2CMOD); /* I2CMOD ACK/8b-data/7b-addr/auto */
213 ar_outl(0x1, PLDI2CACK); /* I2CACK ACK */ 213 ar_outl(0x1, PLDI2CACK); /* I2CACK ACK */
214 214
215 /* I2C CLK */ 215 /* I2C CLK */
216 /* 50MH-100k */ 216 /* 50MH-100k */
217 if (freq == 75) { 217 if (freq == 75) {
218 ar_outl(369, PLDI2CFREQ); /* BCLK = 75MHz */ 218 ar_outl(369, PLDI2CFREQ); /* BCLK = 75MHz */
219 } else if (freq == 50) { 219 } else if (freq == 50) {
220 ar_outl(244, PLDI2CFREQ); /* BCLK = 50MHz */ 220 ar_outl(244, PLDI2CFREQ); /* BCLK = 50MHz */
221 } else { 221 } else {
222 ar_outl(244, PLDI2CFREQ); /* default: BCLK = 50MHz */ 222 ar_outl(244, PLDI2CFREQ); /* default: BCLK = 50MHz */
223 } 223 }
224 ar_outl(0x1, PLDI2CCR); /* I2CCR Enable */ 224 ar_outl(0x1, PLDI2CCR); /* I2CCR Enable */
225} 225}
226 226
227/************************************************************************** 227/**************************************************************************
@@ -253,7 +253,7 @@ static inline void wait_for_vertical_sync(int exp_line)
253 253
254 /* 254 /*
255 * check HCOUNT because we cannot check vertical sync. 255 * check HCOUNT because we cannot check vertical sync.
256 */ 256 */
257 for (; tmout >= 0; tmout--) { 257 for (; tmout >= 0; tmout--) {
258 l = ar_inl(ARVHCOUNT); 258 l = ar_inl(ARVHCOUNT);
259 if (l == exp_line) 259 if (l == exp_line)
@@ -562,8 +562,8 @@ static void ar_interrupt(int irq, void *dev, struct pt_regs *regs)
562 /* operations for interlace mode */ 562 /* operations for interlace mode */
563 if ( line_count < (AR_HEIGHT_VGA/2) ) /* even line */ 563 if ( line_count < (AR_HEIGHT_VGA/2) ) /* even line */
564 line_number = (line_count << 1); 564 line_number = (line_count << 1);
565 else /* odd line */ 565 else /* odd line */
566 line_number = 566 line_number =
567 (((line_count - (AR_HEIGHT_VGA/2)) << 1) + 1); 567 (((line_count - (AR_HEIGHT_VGA/2)) << 1) + 1);
568 } else { 568 } else {
569 line_number = line_count; 569 line_number = line_count;
@@ -651,7 +651,7 @@ static int ar_initialize(struct video_device *dev)
651 cr |= ARVCR1_NORMAL; 651 cr |= ARVCR1_NORMAL;
652 ar_outl(cr, ARVCR1); 652 ar_outl(cr, ARVCR1);
653 653
654 /* 654 /*
655 * Initialize IIC so that CPU can communicate with AR LSI, 655 * Initialize IIC so that CPU can communicate with AR LSI,
656 * and send boot commands to AR LSI. 656 * and send boot commands to AR LSI.
657 */ 657 */
@@ -846,7 +846,7 @@ static int __init ar_init(void)
846 * so register video device as a frame grabber type. 846 * so register video device as a frame grabber type.
847 * device is named "video[0-64]". 847 * device is named "video[0-64]".
848 * video_register_device() initializes h/w using ar_initialize(). 848 * video_register_device() initializes h/w using ar_initialize().
849 */ 849 */
850 if (video_register_device(ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) { 850 if (video_register_device(ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) {
851 /* return -1, -ENFILE(full) or others */ 851 /* return -1, -ENFILE(full) or others */
852 printk("arv: register video (Colour AR) failed.\n"); 852 printk("arv: register video (Colour AR) failed.\n");
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index d8a18a6a5bee..e7b38fdd5e3c 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * bt819 - BT819A VideoStream Decoder (Rockwell Part) 2 * bt819 - BT819A VideoStream Decoder (Rockwell Part)
3 * 3 *
4 * Copyright (C) 1999 Mike Bernson <mike@mlb.org> 4 * Copyright (C) 1999 Mike Bernson <mike@mlb.org>
@@ -6,7 +6,7 @@
6 * 6 *
7 * Modifications for LML33/DC10plus unified driver 7 * Modifications for LML33/DC10plus unified driver
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net> 10 * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net>
11 * - moved over to linux>=2.4.x i2c protocol (9/9/2002) 11 * - moved over to linux>=2.4.x i2c protocol (9/9/2002)
12 * 12 *
@@ -206,9 +206,9 @@ bt819_init (struct i2c_client *client)
206 Bug in the bt819 stepping on my board? 206 Bug in the bt819 stepping on my board?
207 */ 207 */
208 0x14, 0x00, /* 0x14 Vertial Scaling lsb */ 208 0x14, 0x00, /* 0x14 Vertial Scaling lsb */
209 0x16, 0x07, /* 0x16 Video Timing Polarity 209 0x16, 0x07, /* 0x16 Video Timing Polarity
210 ACTIVE=active low 210 ACTIVE=active low
211 FIELD: high=odd, 211 FIELD: high=odd,
212 vreset=active high, 212 vreset=active high,
213 hreset=active high */ 213 hreset=active high */
214 0x18, 0x68, /* 0x18 AGC Delay */ 214 0x18, 0x68, /* 0x18 AGC Delay */
@@ -497,7 +497,7 @@ static unsigned short normal_i2c[] = {
497}; 497};
498 498
499static unsigned short ignore = I2C_CLIENT_END; 499static unsigned short ignore = I2C_CLIENT_END;
500 500
501static struct i2c_client_address_data addr_data = { 501static struct i2c_client_address_data addr_data = {
502 .normal_i2c = normal_i2c, 502 .normal_i2c = normal_i2c,
503 .probe = &ignore, 503 .probe = &ignore,
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index 4d47a0a0e974..af3b61d4fa7d 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * bt856 - BT856A Digital Video Encoder (Rockwell Part) 2 * bt856 - BT856A Digital Video Encoder (Rockwell Part)
3 * 3 *
4 * Copyright (C) 1999 Mike Bernson <mike@mlb.org> 4 * Copyright (C) 1999 Mike Bernson <mike@mlb.org>
@@ -285,7 +285,7 @@ bt856_command (struct i2c_client *client,
285static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; 285static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END };
286 286
287static unsigned short ignore = I2C_CLIENT_END; 287static unsigned short ignore = I2C_CLIENT_END;
288 288
289static struct i2c_client_address_data addr_data = { 289static struct i2c_client_address_data addr_data = {
290 .normal_i2c = normal_i2c, 290 .normal_i2c = normal_i2c,
291 .probe = &ignore, 291 .probe = &ignore,
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index d97b7d8ac33d..cf61c590f4ad 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -150,7 +150,7 @@ static int qc_calibrate(struct qcam_device *q)
150static struct qcam_device *qcam_init(struct parport *port) 150static struct qcam_device *qcam_init(struct parport *port)
151{ 151{
152 struct qcam_device *q; 152 struct qcam_device *q;
153 153
154 q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL); 154 q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL);
155 if(q==NULL) 155 if(q==NULL)
156 return NULL; 156 return NULL;
@@ -158,16 +158,16 @@ static struct qcam_device *qcam_init(struct parport *port)
158 q->pport = port; 158 q->pport = port;
159 q->pdev = parport_register_device(port, "bw-qcam", NULL, NULL, 159 q->pdev = parport_register_device(port, "bw-qcam", NULL, NULL,
160 NULL, 0, NULL); 160 NULL, 0, NULL);
161 if (q->pdev == NULL) 161 if (q->pdev == NULL)
162 { 162 {
163 printk(KERN_ERR "bw-qcam: couldn't register for %s.\n", 163 printk(KERN_ERR "bw-qcam: couldn't register for %s.\n",
164 port->name); 164 port->name);
165 kfree(q); 165 kfree(q);
166 return NULL; 166 return NULL;
167 } 167 }
168 168
169 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template)); 169 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
170 170
171 mutex_init(&q->lock); 171 mutex_init(&q->lock);
172 172
173 q->port_mode = (QC_ANY | QC_NOTSET); 173 q->port_mode = (QC_ANY | QC_NOTSET);
@@ -236,12 +236,12 @@ static int qc_waithand(struct qcam_device *q, int val)
236 while (!((status = read_lpstatus(q)) & 8)) 236 while (!((status = read_lpstatus(q)) & 8))
237 { 237 {
238 /* 1000 is enough spins on the I/O for all normal 238 /* 1000 is enough spins on the I/O for all normal
239 cases, at that point we start to poll slowly 239 cases, at that point we start to poll slowly
240 until the camera wakes up. However, we are 240 until the camera wakes up. However, we are
241 busy blocked until the camera responds, so 241 busy blocked until the camera responds, so
242 setting it lower is much better for interactive 242 setting it lower is much better for interactive
243 response. */ 243 response. */
244 244
245 if(runs++>maxpoll) 245 if(runs++>maxpoll)
246 { 246 {
247 msleep_interruptible(5); 247 msleep_interruptible(5);
@@ -255,12 +255,12 @@ static int qc_waithand(struct qcam_device *q, int val)
255 while (((status = read_lpstatus(q)) & 8)) 255 while (((status = read_lpstatus(q)) & 8))
256 { 256 {
257 /* 1000 is enough spins on the I/O for all normal 257 /* 1000 is enough spins on the I/O for all normal
258 cases, at that point we start to poll slowly 258 cases, at that point we start to poll slowly
259 until the camera wakes up. However, we are 259 until the camera wakes up. However, we are
260 busy blocked until the camera responds, so 260 busy blocked until the camera responds, so
261 setting it lower is much better for interactive 261 setting it lower is much better for interactive
262 response. */ 262 response. */
263 263
264 if(runs++>maxpoll) 264 if(runs++>maxpoll)
265 { 265 {
266 msleep_interruptible(5); 266 msleep_interruptible(5);
@@ -282,17 +282,17 @@ static unsigned int qc_waithand2(struct qcam_device *q, int val)
282{ 282{
283 unsigned int status; 283 unsigned int status;
284 int runs=0; 284 int runs=0;
285 285
286 do 286 do
287 { 287 {
288 status = read_lpdata(q); 288 status = read_lpdata(q);
289 /* 1000 is enough spins on the I/O for all normal 289 /* 1000 is enough spins on the I/O for all normal
290 cases, at that point we start to poll slowly 290 cases, at that point we start to poll slowly
291 until the camera wakes up. However, we are 291 until the camera wakes up. However, we are
292 busy blocked until the camera responds, so 292 busy blocked until the camera responds, so
293 setting it lower is much better for interactive 293 setting it lower is much better for interactive
294 response. */ 294 response. */
295 295
296 if(runs++>maxpoll) 296 if(runs++>maxpoll)
297 { 297 {
298 msleep_interruptible(5); 298 msleep_interruptible(5);
@@ -321,7 +321,7 @@ static int qc_detect(struct qcam_device *q)
321 321
322 lastreg = reg = read_lpstatus(q) & 0xf0; 322 lastreg = reg = read_lpstatus(q) & 0xf0;
323 323
324 for (i = 0; i < 500; i++) 324 for (i = 0; i < 500; i++)
325 { 325 {
326 reg = read_lpstatus(q) & 0xf0; 326 reg = read_lpstatus(q) & 0xf0;
327 if (reg != lastreg) 327 if (reg != lastreg)
@@ -357,7 +357,7 @@ static int qc_detect(struct qcam_device *q)
357 357
358static void qc_reset(struct qcam_device *q) 358static void qc_reset(struct qcam_device *q)
359{ 359{
360 switch (q->port_mode & QC_FORCE_MASK) 360 switch (q->port_mode & QC_FORCE_MASK)
361 { 361 {
362 case QC_FORCE_UNIDIR: 362 case QC_FORCE_UNIDIR:
363 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR; 363 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
@@ -370,7 +370,7 @@ static void qc_reset(struct qcam_device *q)
370 case QC_ANY: 370 case QC_ANY:
371 write_lpcontrol(q, 0x20); 371 write_lpcontrol(q, 0x20);
372 write_lpdata(q, 0x75); 372 write_lpdata(q, 0x75);
373 373
374 if (read_lpdata(q) != 0x75) { 374 if (read_lpdata(q) != 0x75) {
375 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR; 375 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR;
376 } else { 376 } else {
@@ -398,8 +398,8 @@ static void qc_reset(struct qcam_device *q)
398static int qc_setscanmode(struct qcam_device *q) 398static int qc_setscanmode(struct qcam_device *q)
399{ 399{
400 int old_mode = q->mode; 400 int old_mode = q->mode;
401 401
402 switch (q->transfer_scale) 402 switch (q->transfer_scale)
403 { 403 {
404 case 1: 404 case 1:
405 q->mode = 0; 405 q->mode = 0;
@@ -412,7 +412,7 @@ static int qc_setscanmode(struct qcam_device *q)
412 break; 412 break;
413 } 413 }
414 414
415 switch (q->bpp) 415 switch (q->bpp)
416 { 416 {
417 case 4: 417 case 4:
418 break; 418 break;
@@ -421,7 +421,7 @@ static int qc_setscanmode(struct qcam_device *q)
421 break; 421 break;
422 } 422 }
423 423
424 switch (q->port_mode & QC_MODE_MASK) 424 switch (q->port_mode & QC_MODE_MASK)
425 { 425 {
426 case QC_BIDIR: 426 case QC_BIDIR:
427 q->mode += 1; 427 q->mode += 1;
@@ -430,10 +430,10 @@ static int qc_setscanmode(struct qcam_device *q)
430 case QC_UNIDIR: 430 case QC_UNIDIR:
431 break; 431 break;
432 } 432 }
433 433
434 if (q->mode != old_mode) 434 if (q->mode != old_mode)
435 q->status |= QC_PARAM_CHANGE; 435 q->status |= QC_PARAM_CHANGE;
436 436
437 return 0; 437 return 0;
438} 438}
439 439
@@ -451,7 +451,7 @@ static void qc_set(struct qcam_device *q)
451 /* Set the brightness. Yes, this is repetitive, but it works. 451 /* Set the brightness. Yes, this is repetitive, but it works.
452 * Shorter versions seem to fail subtly. Feel free to try :-). */ 452 * Shorter versions seem to fail subtly. Feel free to try :-). */
453 /* I think the problem was in qc_command, not here -- bls */ 453 /* I think the problem was in qc_command, not here -- bls */
454 454
455 qc_command(q, 0xb); 455 qc_command(q, 0xb);
456 qc_command(q, q->brightness); 456 qc_command(q, q->brightness);
457 457
@@ -502,13 +502,13 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
502 unsigned int hi2, lo2; 502 unsigned int hi2, lo2;
503 static int state = 0; 503 static int state = 0;
504 504
505 if (buffer == NULL) 505 if (buffer == NULL)
506 { 506 {
507 state = 0; 507 state = 0;
508 return 0; 508 return 0;
509 } 509 }
510 510
511 switch (q->port_mode & QC_MODE_MASK) 511 switch (q->port_mode & QC_MODE_MASK)
512 { 512 {
513 case QC_BIDIR: /* Bi-directional Port */ 513 case QC_BIDIR: /* Bi-directional Port */
514 write_lpcontrol(q, 0x26); 514 write_lpcontrol(q, 0x26);
@@ -517,7 +517,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
517 write_lpcontrol(q, 0x2e); 517 write_lpcontrol(q, 0x2e);
518 lo2 = (qc_waithand2(q, 0) >> 1); 518 lo2 = (qc_waithand2(q, 0) >> 1);
519 hi2 = (read_lpstatus(q) >> 3) & 0x1f; 519 hi2 = (read_lpstatus(q) >> 3) & 0x1f;
520 switch (q->bpp) 520 switch (q->bpp)
521 { 521 {
522 case 4: 522 case 4:
523 buffer[0] = lo & 0xf; 523 buffer[0] = lo & 0xf;
@@ -544,7 +544,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
544 write_lpcontrol(q, 0xe); 544 write_lpcontrol(q, 0xe);
545 hi = (qc_waithand(q, 0) & 0xf0) >> 4; 545 hi = (qc_waithand(q, 0) & 0xf0) >> 4;
546 546
547 switch (q->bpp) 547 switch (q->bpp)
548 { 548 {
549 case 4: 549 case 4:
550 buffer[0] = lo; 550 buffer[0] = lo;
@@ -552,7 +552,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
552 ret = 2; 552 ret = 2;
553 break; 553 break;
554 case 6: 554 case 6:
555 switch (state) 555 switch (state)
556 { 556 {
557 case 0: 557 case 0:
558 buffer[0] = (lo << 2) | ((hi & 0xc) >> 2); 558 buffer[0] = (lo << 2) | ((hi & 0xc) >> 2);
@@ -604,13 +604,13 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
604 int shift=8-q->bpp; 604 int shift=8-q->bpp;
605 char invert; 605 char invert;
606 606
607 if (q->mode == -1) 607 if (q->mode == -1)
608 return -ENXIO; 608 return -ENXIO;
609 609
610 qc_command(q, 0x7); 610 qc_command(q, 0x7);
611 qc_command(q, q->mode); 611 qc_command(q, q->mode);
612 612
613 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) 613 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
614 { 614 {
615 write_lpcontrol(q, 0x2e); /* turn port around */ 615 write_lpcontrol(q, 0x2e); /* turn port around */
616 write_lpcontrol(q, 0x26); 616 write_lpcontrol(q, 0x26);
@@ -618,7 +618,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
618 write_lpcontrol(q, 0x2e); 618 write_lpcontrol(q, 0x2e);
619 (void) qc_waithand(q, 0); 619 (void) qc_waithand(q, 0);
620 } 620 }
621 621
622 /* strange -- should be 15:63 below, but 4bpp is odd */ 622 /* strange -- should be 15:63 below, but 4bpp is odd */
623 invert = (q->bpp == 4) ? 16 : 63; 623 invert = (q->bpp == 4) ? 16 : 63;
624 624
@@ -629,15 +629,15 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
629 q->transfer_scale; 629 q->transfer_scale;
630 transperline = (transperline + divisor - 1) / divisor; 630 transperline = (transperline + divisor - 1) / divisor;
631 631
632 for (i = 0, yield = yieldlines; i < linestotrans; i++) 632 for (i = 0, yield = yieldlines; i < linestotrans; i++)
633 { 633 {
634 for (pixels_read = j = 0; j < transperline; j++) 634 for (pixels_read = j = 0; j < transperline; j++)
635 { 635 {
636 bytes = qc_readbytes(q, buffer); 636 bytes = qc_readbytes(q, buffer);
637 for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++) 637 for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++)
638 { 638 {
639 int o; 639 int o;
640 if (buffer[k] == 0 && invert == 16) 640 if (buffer[k] == 0 && invert == 16)
641 { 641 {
642 /* 4bpp is odd (again) -- inverter is 16, not 15, but output 642 /* 4bpp is odd (again) -- inverter is 16, not 15, but output
643 must be 0-15 -- bls */ 643 must be 0-15 -- bls */
@@ -653,7 +653,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
653 pixels_read += bytes; 653 pixels_read += bytes;
654 } 654 }
655 (void) qc_readbytes(q, NULL); /* reset state machine */ 655 (void) qc_readbytes(q, NULL); /* reset state machine */
656 656
657 /* Grabbing an entire frame from the quickcam is a lengthy 657 /* Grabbing an entire frame from the quickcam is a lengthy
658 process. We don't (usually) want to busy-block the 658 process. We don't (usually) want to busy-block the
659 processor for the entire frame. yieldlines is a module 659 processor for the entire frame. yieldlines is a module
@@ -666,7 +666,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
666 } 666 }
667 } 667 }
668 668
669 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) 669 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
670 { 670 {
671 write_lpcontrol(q, 2); 671 write_lpcontrol(q, 2);
672 write_lpcontrol(q, 6); 672 write_lpcontrol(q, 6);
@@ -687,7 +687,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
687{ 687{
688 struct video_device *dev = video_devdata(file); 688 struct video_device *dev = video_devdata(file);
689 struct qcam_device *qcam=(struct qcam_device *)dev; 689 struct qcam_device *qcam=(struct qcam_device *)dev;
690 690
691 switch(cmd) 691 switch(cmd)
692 { 692 {
693 case VIDIOCGCAP: 693 case VIDIOCGCAP:
@@ -762,7 +762,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
762 return -EINVAL; 762 return -EINVAL;
763 if(p->depth!=4 && p->depth!=6) 763 if(p->depth!=4 && p->depth!=6)
764 return -EINVAL; 764 return -EINVAL;
765 765
766 /* 766 /*
767 * Now load the camera. 767 * Now load the camera.
768 */ 768 */
@@ -790,11 +790,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
790 return -EINVAL; 790 return -EINVAL;
791 if(vw->width<80||vw->width>320) 791 if(vw->width<80||vw->width>320)
792 return -EINVAL; 792 return -EINVAL;
793 793
794 qcam->width = 320; 794 qcam->width = 320;
795 qcam->height = 240; 795 qcam->height = 240;
796 qcam->transfer_scale = 4; 796 qcam->transfer_scale = 4;
797 797
798 if(vw->width>=160 && vw->height>=120) 798 if(vw->width>=160 && vw->height>=120)
799 { 799 {
800 qcam->transfer_scale = 2; 800 qcam->transfer_scale = 2;
@@ -808,11 +808,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
808 mutex_lock(&qcam->lock); 808 mutex_lock(&qcam->lock);
809 qc_setscanmode(qcam); 809 qc_setscanmode(qcam);
810 mutex_unlock(&qcam->lock); 810 mutex_unlock(&qcam->lock);
811 811
812 /* We must update the camera before we grab. We could 812 /* We must update the camera before we grab. We could
813 just have changed the grab size */ 813 just have changed the grab size */
814 qcam->status |= QC_PARAM_CHANGE; 814 qcam->status |= QC_PARAM_CHANGE;
815 815
816 /* Ok we figured out what to use from our wide choice */ 816 /* Ok we figured out what to use from our wide choice */
817 return 0; 817 return 0;
818 } 818 }
@@ -853,9 +853,9 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
853 struct qcam_device *qcam=(struct qcam_device *)v; 853 struct qcam_device *qcam=(struct qcam_device *)v;
854 int len; 854 int len;
855 parport_claim_or_block(qcam->pdev); 855 parport_claim_or_block(qcam->pdev);
856 856
857 mutex_lock(&qcam->lock); 857 mutex_lock(&qcam->lock);
858 858
859 qc_reset(qcam); 859 qc_reset(qcam);
860 860
861 /* Update the camera parameters if we need to */ 861 /* Update the camera parameters if we need to */
@@ -863,13 +863,13 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
863 qc_set(qcam); 863 qc_set(qcam);
864 864
865 len=qc_capture(qcam, buf,count); 865 len=qc_capture(qcam, buf,count);
866 866
867 mutex_unlock(&qcam->lock); 867 mutex_unlock(&qcam->lock);
868 868
869 parport_release(qcam->pdev); 869 parport_release(qcam->pdev);
870 return len; 870 return len;
871} 871}
872 872
873static struct file_operations qcam_fops = { 873static struct file_operations qcam_fops = {
874 .owner = THIS_MODULE, 874 .owner = THIS_MODULE,
875 .open = video_exclusive_open, 875 .open = video_exclusive_open,
@@ -905,11 +905,11 @@ static int init_bwqcam(struct parport *port)
905 qcam=qcam_init(port); 905 qcam=qcam_init(port);
906 if(qcam==NULL) 906 if(qcam==NULL)
907 return -ENODEV; 907 return -ENODEV;
908 908
909 parport_claim_or_block(qcam->pdev); 909 parport_claim_or_block(qcam->pdev);
910 910
911 qc_reset(qcam); 911 qc_reset(qcam);
912 912
913 if(qc_detect(qcam)==0) 913 if(qc_detect(qcam)==0)
914 { 914 {
915 parport_release(qcam->pdev); 915 parport_release(qcam->pdev);
@@ -920,9 +920,9 @@ static int init_bwqcam(struct parport *port)
920 qc_calibrate(qcam); 920 qc_calibrate(qcam);
921 921
922 parport_release(qcam->pdev); 922 parport_release(qcam->pdev);
923 923
924 printk(KERN_INFO "Connectix Quickcam on %s\n", qcam->pport->name); 924 printk(KERN_INFO "Connectix Quickcam on %s\n", qcam->pport->name);
925 925
926 if(video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1) 926 if(video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1)
927 { 927 {
928 parport_unregister_device(qcam->pdev); 928 parport_unregister_device(qcam->pdev);
@@ -1013,7 +1013,7 @@ static int __init init_bw_qcams(void)
1013 printk("Connectix Quickcam max-poll was above 5000. Using 5000.\n"); 1013 printk("Connectix Quickcam max-poll was above 5000. Using 5000.\n");
1014 maxpoll = 5000; 1014 maxpoll = 5000;
1015 } 1015 }
1016 1016
1017 if (yieldlines < 1) { 1017 if (yieldlines < 1) {
1018 printk("Connectix Quickcam yieldlines was less than 1. Using 1.\n"); 1018 printk("Connectix Quickcam yieldlines was less than 1. Using 1.\n");
1019 yieldlines = 1; 1019 yieldlines = 1;
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 8211fd8d7cbf..22a7386bbea6 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -16,7 +16,7 @@
16 * 16 *
17 * The parport parameter controls which parports will be scanned. 17 * The parport parameter controls which parports will be scanned.
18 * Scanning all parports causes some printers to print a garbage page. 18 * Scanning all parports causes some printers to print a garbage page.
19 * -- March 14, 1999 Billy Donahue <billy@escape.com> 19 * -- March 14, 1999 Billy Donahue <billy@escape.com>
20 * 20 *
21 * Fixed data format to BGR, added force_rgb parameter. Added missing 21 * Fixed data format to BGR, added force_rgb parameter. Added missing
22 * parport_unregister_driver() on module removal. 22 * parport_unregister_driver() on module removal.
@@ -88,7 +88,7 @@ static inline unsigned int qcam_ready2(struct qcam_device *qcam)
88 return (parport_read_data(qcam->pport) & 0x1)?1:0; 88 return (parport_read_data(qcam->pport) & 0x1)?1:0;
89} 89}
90 90
91static unsigned int qcam_await_ready1(struct qcam_device *qcam, 91static unsigned int qcam_await_ready1(struct qcam_device *qcam,
92 int value) 92 int value)
93{ 93{
94 unsigned long oldjiffies = jiffies; 94 unsigned long oldjiffies = jiffies;
@@ -98,7 +98,7 @@ static unsigned int qcam_await_ready1(struct qcam_device *qcam,
98 if (qcam_ready1(qcam) == value) 98 if (qcam_ready1(qcam) == value)
99 return 0; 99 return 0;
100 100
101 /* If the camera didn't respond within 1/25 second, poll slowly 101 /* If the camera didn't respond within 1/25 second, poll slowly
102 for a while. */ 102 for a while. */
103 for (i = 0; i < 50; i++) 103 for (i = 0; i < 50; i++)
104 { 104 {
@@ -123,7 +123,7 @@ static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value)
123 if (qcam_ready2(qcam) == value) 123 if (qcam_ready2(qcam) == value)
124 return 0; 124 return 0;
125 125
126 /* If the camera didn't respond within 1/25 second, poll slowly 126 /* If the camera didn't respond within 1/25 second, poll slowly
127 for a while. */ 127 for a while. */
128 for (i = 0; i < 50; i++) 128 for (i = 0; i < 50; i++)
129 { 129 {
@@ -157,12 +157,12 @@ static int qcam_write_data(struct qcam_device *qcam, unsigned int data)
157 unsigned int idata; 157 unsigned int idata;
158 parport_write_data(qcam->pport, data); 158 parport_write_data(qcam->pport, data);
159 idata = qcam_read_data(qcam); 159 idata = qcam_read_data(qcam);
160 if (data != idata) 160 if (data != idata)
161 { 161 {
162 printk(KERN_WARNING "cqcam: sent %x but received %x\n", data, 162 printk(KERN_WARNING "cqcam: sent %x but received %x\n", data,
163 idata); 163 idata);
164 return 1; 164 return 1;
165 } 165 }
166 return 0; 166 return 0;
167} 167}
168 168
@@ -193,12 +193,12 @@ static int qc_detect(struct qcam_device *qcam)
193 no device was found". Fix this one day. */ 193 no device was found". Fix this one day. */
194 if (qcam->pport->probe_info[0].class == PARPORT_CLASS_MEDIA 194 if (qcam->pport->probe_info[0].class == PARPORT_CLASS_MEDIA
195 && qcam->pport->probe_info[0].model 195 && qcam->pport->probe_info[0].model
196 && !strcmp(qcam->pdev->port->probe_info[0].model, 196 && !strcmp(qcam->pdev->port->probe_info[0].model,
197 "Color QuickCam 2.0")) { 197 "Color QuickCam 2.0")) {
198 printk(KERN_DEBUG "QuickCam: Found by IEEE1284 probe.\n"); 198 printk(KERN_DEBUG "QuickCam: Found by IEEE1284 probe.\n");
199 return 1; 199 return 1;
200 } 200 }
201 201
202 if (probe < 2) 202 if (probe < 2)
203 return 0; 203 return 0;
204 204
@@ -206,11 +206,11 @@ static int qc_detect(struct qcam_device *qcam)
206 206
207 /* look for a heartbeat */ 207 /* look for a heartbeat */
208 ostat = stat = parport_read_status(qcam->pport); 208 ostat = stat = parport_read_status(qcam->pport);
209 for (i=0; i<250; i++) 209 for (i=0; i<250; i++)
210 { 210 {
211 mdelay(1); 211 mdelay(1);
212 stat = parport_read_status(qcam->pport); 212 stat = parport_read_status(qcam->pport);
213 if (ostat != stat) 213 if (ostat != stat)
214 { 214 {
215 if (++count >= 3) return 1; 215 if (++count >= 3) return 1;
216 ostat = stat; 216 ostat = stat;
@@ -226,11 +226,11 @@ static int qc_detect(struct qcam_device *qcam)
226 count = 0; 226 count = 0;
227 227
228 ostat = stat = parport_read_status(qcam->pport); 228 ostat = stat = parport_read_status(qcam->pport);
229 for (i=0; i<250; i++) 229 for (i=0; i<250; i++)
230 { 230 {
231 mdelay(1); 231 mdelay(1);
232 stat = parport_read_status(qcam->pport); 232 stat = parport_read_status(qcam->pport);
233 if (ostat != stat) 233 if (ostat != stat)
234 { 234 {
235 if (++count >= 3) return 1; 235 if (++count >= 3) return 1;
236 ostat = stat; 236 ostat = stat;
@@ -247,7 +247,7 @@ static void qc_reset(struct qcam_device *qcam)
247 parport_write_control(qcam->pport, 0x8); 247 parport_write_control(qcam->pport, 0x8);
248 mdelay(1); 248 mdelay(1);
249 parport_write_control(qcam->pport, 0xc); 249 parport_write_control(qcam->pport, 0xc);
250 mdelay(1); 250 mdelay(1);
251} 251}
252 252
253/* Reset the QuickCam and program for brightness, contrast, 253/* Reset the QuickCam and program for brightness, contrast,
@@ -258,7 +258,7 @@ static void qc_setup(struct qcam_device *q)
258 qc_reset(q); 258 qc_reset(q);
259 259
260 /* Set the brightness. */ 260 /* Set the brightness. */
261 qcam_set(q, 11, q->brightness); 261 qcam_set(q, 11, q->brightness);
262 262
263 /* Set the height and width. These refer to the actual 263 /* Set the height and width. These refer to the actual
264 CCD area *before* applying the selected decimation. */ 264 CCD area *before* applying the selected decimation. */
@@ -272,12 +272,12 @@ static void qc_setup(struct qcam_device *q)
272 /* Set contrast and white balance. */ 272 /* Set contrast and white balance. */
273 qcam_set(q, 0x19, q->contrast); 273 qcam_set(q, 0x19, q->contrast);
274 qcam_set(q, 0x1f, q->whitebal); 274 qcam_set(q, 0x1f, q->whitebal);
275 275
276 /* Set the speed. */ 276 /* Set the speed. */
277 qcam_set(q, 45, 2); 277 qcam_set(q, 45, 2);
278} 278}
279 279
280/* Read some bytes from the camera and put them in the buffer. 280/* Read some bytes from the camera and put them in the buffer.
281 nbytes should be a multiple of 3, because bidirectional mode gives 281 nbytes should be a multiple of 3, because bidirectional mode gives
282 us three bytes at a time. */ 282 us three bytes at a time. */
283 283
@@ -383,7 +383,7 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le
383 383
384 if (qcam_set(q, 7, (q->mode | (is_bi_dir?1:0)) + 1)) 384 if (qcam_set(q, 7, (q->mode | (is_bi_dir?1:0)) + 1))
385 return -EIO; 385 return -EIO;
386 386
387 lines = q->height; 387 lines = q->height;
388 pixelsperline = q->width; 388 pixelsperline = q->width;
389 bitsperxfer = (is_bi_dir) ? 24 : 8; 389 bitsperxfer = (is_bi_dir) ? 24 : 8;
@@ -499,7 +499,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
499{ 499{
500 struct video_device *dev = video_devdata(file); 500 struct video_device *dev = video_devdata(file);
501 struct qcam_device *qcam=(struct qcam_device *)dev; 501 struct qcam_device *qcam=(struct qcam_device *)dev;
502 502
503 switch(cmd) 503 switch(cmd)
504 { 504 {
505 case VIDIOCGCAP: 505 case VIDIOCGCAP:
@@ -574,7 +574,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
574 */ 574 */
575 if (p->depth != 24 || p->palette != VIDEO_PALETTE_RGB24) 575 if (p->depth != 24 || p->palette != VIDEO_PALETTE_RGB24)
576 return -EINVAL; 576 return -EINVAL;
577 577
578 /* 578 /*
579 * Now load the camera. 579 * Now load the camera.
580 */ 580 */
@@ -584,7 +584,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
584 584
585 mutex_lock(&qcam->lock); 585 mutex_lock(&qcam->lock);
586 parport_claim_or_block(qcam->pdev); 586 parport_claim_or_block(qcam->pdev);
587 qc_setup(qcam); 587 qc_setup(qcam);
588 parport_release(qcam->pdev); 588 parport_release(qcam->pdev);
589 mutex_unlock(&qcam->lock); 589 mutex_unlock(&qcam->lock);
590 return 0; 590 return 0;
@@ -601,11 +601,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
601 return -EINVAL; 601 return -EINVAL;
602 if(vw->width<80||vw->width>320) 602 if(vw->width<80||vw->width>320)
603 return -EINVAL; 603 return -EINVAL;
604 604
605 qcam->width = 80; 605 qcam->width = 80;
606 qcam->height = 60; 606 qcam->height = 60;
607 qcam->mode = QC_DECIMATION_4; 607 qcam->mode = QC_DECIMATION_4;
608 608
609 if(vw->width>=160 && vw->height>=120) 609 if(vw->width>=160 && vw->height>=120)
610 { 610 {
611 qcam->width = 160; 611 qcam->width = 160;
@@ -627,7 +627,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
627 qcam->mode = QC_BILLIONS | QC_DECIMATION_1; 627 qcam->mode = QC_BILLIONS | QC_DECIMATION_1;
628 } 628 }
629#endif 629#endif
630 /* Ok we figured out what to use from our 630 /* Ok we figured out what to use from our
631 wide choice */ 631 wide choice */
632 mutex_lock(&qcam->lock); 632 mutex_lock(&qcam->lock);
633 parport_claim_or_block(qcam->pdev); 633 parport_claim_or_block(qcam->pdev);
@@ -676,7 +676,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
676 mutex_lock(&qcam->lock); 676 mutex_lock(&qcam->lock);
677 parport_claim_or_block(qcam->pdev); 677 parport_claim_or_block(qcam->pdev);
678 /* Probably should have a semaphore against multiple users */ 678 /* Probably should have a semaphore against multiple users */
679 len = qc_capture(qcam, buf,count); 679 len = qc_capture(qcam, buf,count);
680 parport_release(qcam->pdev); 680 parport_release(qcam->pdev);
681 mutex_unlock(&qcam->lock); 681 mutex_unlock(&qcam->lock);
682 return len; 682 return len;
@@ -707,7 +707,7 @@ static struct video_device qcam_template=
707static struct qcam_device *qcam_init(struct parport *port) 707static struct qcam_device *qcam_init(struct parport *port)
708{ 708{
709 struct qcam_device *q; 709 struct qcam_device *q;
710 710
711 q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL); 711 q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL);
712 if(q==NULL) 712 if(q==NULL)
713 return NULL; 713 return NULL;
@@ -718,14 +718,14 @@ static struct qcam_device *qcam_init(struct parport *port)
718 718
719 q->bidirectional = (q->pport->modes & PARPORT_MODE_TRISTATE)?1:0; 719 q->bidirectional = (q->pport->modes & PARPORT_MODE_TRISTATE)?1:0;
720 720
721 if (q->pdev == NULL) 721 if (q->pdev == NULL)
722 { 722 {
723 printk(KERN_ERR "c-qcam: couldn't register for %s.\n", 723 printk(KERN_ERR "c-qcam: couldn't register for %s.\n",
724 port->name); 724 port->name);
725 kfree(q); 725 kfree(q);
726 return NULL; 726 return NULL;
727 } 727 }
728 728
729 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template)); 729 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
730 730
731 mutex_init(&q->lock); 731 mutex_init(&q->lock);
@@ -766,11 +766,11 @@ static int init_cqcam(struct parport *port)
766 qcam = qcam_init(port); 766 qcam = qcam_init(port);
767 if (qcam==NULL) 767 if (qcam==NULL)
768 return -ENODEV; 768 return -ENODEV;
769 769
770 parport_claim_or_block(qcam->pdev); 770 parport_claim_or_block(qcam->pdev);
771 771
772 qc_reset(qcam); 772 qc_reset(qcam);
773 773
774 if (probe && qc_detect(qcam)==0) 774 if (probe && qc_detect(qcam)==0)
775 { 775 {
776 parport_release(qcam->pdev); 776 parport_release(qcam->pdev);
@@ -782,7 +782,7 @@ static int init_cqcam(struct parport *port)
782 qc_setup(qcam); 782 qc_setup(qcam);
783 783
784 parport_release(qcam->pdev); 784 parport_release(qcam->pdev);
785 785
786 if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1) 786 if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1)
787 { 787 {
788 printk(KERN_ERR "Unable to register Colour QuickCam on %s\n", 788 printk(KERN_ERR "Unable to register Colour QuickCam on %s\n",
@@ -792,9 +792,9 @@ static int init_cqcam(struct parport *port)
792 return -ENODEV; 792 return -ENODEV;
793 } 793 }
794 794
795 printk(KERN_INFO "video%d: Colour QuickCam found on %s\n", 795 printk(KERN_INFO "video%d: Colour QuickCam found on %s\n",
796 qcam->vdev.minor, qcam->pport->name); 796 qcam->vdev.minor, qcam->pport->name);
797 797
798 qcams[num_cams++] = qcam; 798 qcams[num_cams++] = qcam;
799 799
800 return 0; 800 return 0;
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 3cebfa91ca14..2227c5640c12 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ 26/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
27/* #define _CPIA_DEBUG_ 1 */ 27/* #define _CPIA_DEBUG_ 1 */
28 28
29#include <linux/config.h> 29#include <linux/config.h>
30 30
@@ -67,11 +67,11 @@ MODULE_SUPPORTED_DEVICE("video");
67static unsigned short colorspace_conv = 0; 67static unsigned short colorspace_conv = 0;
68module_param(colorspace_conv, ushort, 0444); 68module_param(colorspace_conv, ushort, 0444);
69MODULE_PARM_DESC(colorspace_conv, 69MODULE_PARM_DESC(colorspace_conv,
70 "\n<n> Colorspace conversion:" 70 "\n<n> Colorspace conversion:"
71 "\n0 = disable" 71 "\n0 = disable"
72 "\n1 = enable" 72 "\n1 = enable"
73 "\nDefault value is 0" 73 "\nDefault value is 0"
74 "\n"); 74 "\n");
75 75
76#define ABOUT "V4L-Driver for Vision CPiA based cameras" 76#define ABOUT "V4L-Driver for Vision CPiA based cameras"
77 77
@@ -189,8 +189,8 @@ enum {
189#define TC 94 189#define TC 94
190#define EXP_ACC_DARK 50 190#define EXP_ACC_DARK 50
191#define EXP_ACC_LIGHT 90 191#define EXP_ACC_LIGHT 90
192#define HIGH_COMP_102 160 192#define HIGH_COMP_102 160
193#define MAX_COMP 239 193#define MAX_COMP 239
194#define DARK_TIME 3 194#define DARK_TIME 3
195#define LIGHT_TIME 3 195#define LIGHT_TIME 3
196 196
@@ -208,7 +208,7 @@ static u8 flicker_jumps[2][2][4] =
208static void reset_camera_struct(struct cam_data *cam); 208static void reset_camera_struct(struct cam_data *cam);
209static int find_over_exposure(int brightness); 209static int find_over_exposure(int brightness);
210static void set_flicker(struct cam_params *params, volatile u32 *command_flags, 210static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
211 int on); 211 int on);
212 212
213 213
214/********************************************************************** 214/**********************************************************************
@@ -262,7 +262,7 @@ static void rvfree(void *mem, unsigned long size)
262static struct proc_dir_entry *cpia_proc_root=NULL; 262static struct proc_dir_entry *cpia_proc_root=NULL;
263 263
264static int cpia_read_proc(char *page, char **start, off_t off, 264static int cpia_read_proc(char *page, char **start, off_t off,
265 int count, int *eof, void *data) 265 int count, int *eof, void *data)
266{ 266{
267 char *out = page; 267 char *out = page;
268 int len, tmp; 268 int len, tmp;
@@ -276,58 +276,58 @@ static int cpia_read_proc(char *page, char **start, off_t off,
276 out += sprintf(out, "V4L Driver version: %d.%d.%d\n", 276 out += sprintf(out, "V4L Driver version: %d.%d.%d\n",
277 CPIA_MAJ_VER, CPIA_MIN_VER, CPIA_PATCH_VER); 277 CPIA_MAJ_VER, CPIA_MIN_VER, CPIA_PATCH_VER);
278 out += sprintf(out, "CPIA Version: %d.%02d (%d.%d)\n", 278 out += sprintf(out, "CPIA Version: %d.%02d (%d.%d)\n",
279 cam->params.version.firmwareVersion, 279 cam->params.version.firmwareVersion,
280 cam->params.version.firmwareRevision, 280 cam->params.version.firmwareRevision,
281 cam->params.version.vcVersion, 281 cam->params.version.vcVersion,
282 cam->params.version.vcRevision); 282 cam->params.version.vcRevision);
283 out += sprintf(out, "CPIA PnP-ID: %04x:%04x:%04x\n", 283 out += sprintf(out, "CPIA PnP-ID: %04x:%04x:%04x\n",
284 cam->params.pnpID.vendor, cam->params.pnpID.product, 284 cam->params.pnpID.vendor, cam->params.pnpID.product,
285 cam->params.pnpID.deviceRevision); 285 cam->params.pnpID.deviceRevision);
286 out += sprintf(out, "VP-Version: %d.%d %04x\n", 286 out += sprintf(out, "VP-Version: %d.%d %04x\n",
287 cam->params.vpVersion.vpVersion, 287 cam->params.vpVersion.vpVersion,
288 cam->params.vpVersion.vpRevision, 288 cam->params.vpVersion.vpRevision,
289 cam->params.vpVersion.cameraHeadID); 289 cam->params.vpVersion.cameraHeadID);
290 290
291 out += sprintf(out, "system_state: %#04x\n", 291 out += sprintf(out, "system_state: %#04x\n",
292 cam->params.status.systemState); 292 cam->params.status.systemState);
293 out += sprintf(out, "grab_state: %#04x\n", 293 out += sprintf(out, "grab_state: %#04x\n",
294 cam->params.status.grabState); 294 cam->params.status.grabState);
295 out += sprintf(out, "stream_state: %#04x\n", 295 out += sprintf(out, "stream_state: %#04x\n",
296 cam->params.status.streamState); 296 cam->params.status.streamState);
297 out += sprintf(out, "fatal_error: %#04x\n", 297 out += sprintf(out, "fatal_error: %#04x\n",
298 cam->params.status.fatalError); 298 cam->params.status.fatalError);
299 out += sprintf(out, "cmd_error: %#04x\n", 299 out += sprintf(out, "cmd_error: %#04x\n",
300 cam->params.status.cmdError); 300 cam->params.status.cmdError);
301 out += sprintf(out, "debug_flags: %#04x\n", 301 out += sprintf(out, "debug_flags: %#04x\n",
302 cam->params.status.debugFlags); 302 cam->params.status.debugFlags);
303 out += sprintf(out, "vp_status: %#04x\n", 303 out += sprintf(out, "vp_status: %#04x\n",
304 cam->params.status.vpStatus); 304 cam->params.status.vpStatus);
305 out += sprintf(out, "error_code: %#04x\n", 305 out += sprintf(out, "error_code: %#04x\n",
306 cam->params.status.errorCode); 306 cam->params.status.errorCode);
307 /* QX3 specific entries */ 307 /* QX3 specific entries */
308 if (cam->params.qx3.qx3_detected) { 308 if (cam->params.qx3.qx3_detected) {
309 out += sprintf(out, "button: %4d\n", 309 out += sprintf(out, "button: %4d\n",
310 cam->params.qx3.button); 310 cam->params.qx3.button);
311 out += sprintf(out, "cradled: %4d\n", 311 out += sprintf(out, "cradled: %4d\n",
312 cam->params.qx3.cradled); 312 cam->params.qx3.cradled);
313 } 313 }
314 out += sprintf(out, "video_size: %s\n", 314 out += sprintf(out, "video_size: %s\n",
315 cam->params.format.videoSize == VIDEOSIZE_CIF ? 315 cam->params.format.videoSize == VIDEOSIZE_CIF ?
316 "CIF " : "QCIF"); 316 "CIF " : "QCIF");
317 out += sprintf(out, "roi: (%3d, %3d) to (%3d, %3d)\n", 317 out += sprintf(out, "roi: (%3d, %3d) to (%3d, %3d)\n",
318 cam->params.roi.colStart*8, 318 cam->params.roi.colStart*8,
319 cam->params.roi.rowStart*4, 319 cam->params.roi.rowStart*4,
320 cam->params.roi.colEnd*8, 320 cam->params.roi.colEnd*8,
321 cam->params.roi.rowEnd*4); 321 cam->params.roi.rowEnd*4);
322 out += sprintf(out, "actual_fps: %3d\n", cam->fps); 322 out += sprintf(out, "actual_fps: %3d\n", cam->fps);
323 out += sprintf(out, "transfer_rate: %4dkB/s\n", 323 out += sprintf(out, "transfer_rate: %4dkB/s\n",
324 cam->transfer_rate); 324 cam->transfer_rate);
325 325
326 out += sprintf(out, "\nread-write\n"); 326 out += sprintf(out, "\nread-write\n");
327 out += sprintf(out, "----------------------- current min" 327 out += sprintf(out, "----------------------- current min"
328 " max default comment\n"); 328 " max default comment\n");
329 out += sprintf(out, "brightness: %8d %8d %8d %8d\n", 329 out += sprintf(out, "brightness: %8d %8d %8d %8d\n",
330 cam->params.colourParams.brightness, 0, 100, 50); 330 cam->params.colourParams.brightness, 0, 100, 50);
331 if (cam->params.version.firmwareVersion == 1 && 331 if (cam->params.version.firmwareVersion == 1 &&
332 cam->params.version.firmwareRevision == 2) 332 cam->params.version.firmwareRevision == 2)
333 /* 1-02 firmware limits contrast to 80 */ 333 /* 1-02 firmware limits contrast to 80 */
@@ -336,26 +336,26 @@ static int cpia_read_proc(char *page, char **start, off_t off,
336 tmp = 96; 336 tmp = 96;
337 337
338 out += sprintf(out, "contrast: %8d %8d %8d %8d" 338 out += sprintf(out, "contrast: %8d %8d %8d %8d"
339 " steps of 8\n", 339 " steps of 8\n",
340 cam->params.colourParams.contrast, 0, tmp, 48); 340 cam->params.colourParams.contrast, 0, tmp, 48);
341 out += sprintf(out, "saturation: %8d %8d %8d %8d\n", 341 out += sprintf(out, "saturation: %8d %8d %8d %8d\n",
342 cam->params.colourParams.saturation, 0, 100, 50); 342 cam->params.colourParams.saturation, 0, 100, 50);
343 tmp = (25000+5000*cam->params.sensorFps.baserate)/ 343 tmp = (25000+5000*cam->params.sensorFps.baserate)/
344 (1<<cam->params.sensorFps.divisor); 344 (1<<cam->params.sensorFps.divisor);
345 out += sprintf(out, "sensor_fps: %4d.%03d %8d %8d %8d\n", 345 out += sprintf(out, "sensor_fps: %4d.%03d %8d %8d %8d\n",
346 tmp/1000, tmp%1000, 3, 30, 15); 346 tmp/1000, tmp%1000, 3, 30, 15);
347 out += sprintf(out, "stream_start_line: %8d %8d %8d %8d\n", 347 out += sprintf(out, "stream_start_line: %8d %8d %8d %8d\n",
348 2*cam->params.streamStartLine, 0, 348 2*cam->params.streamStartLine, 0,
349 cam->params.format.videoSize == VIDEOSIZE_CIF ? 288:144, 349 cam->params.format.videoSize == VIDEOSIZE_CIF ? 288:144,
350 cam->params.format.videoSize == VIDEOSIZE_CIF ? 240:120); 350 cam->params.format.videoSize == VIDEOSIZE_CIF ? 240:120);
351 out += sprintf(out, "sub_sample: %8s %8s %8s %8s\n", 351 out += sprintf(out, "sub_sample: %8s %8s %8s %8s\n",
352 cam->params.format.subSample == SUBSAMPLE_420 ? 352 cam->params.format.subSample == SUBSAMPLE_420 ?
353 "420" : "422", "420", "422", "422"); 353 "420" : "422", "420", "422", "422");
354 out += sprintf(out, "yuv_order: %8s %8s %8s %8s\n", 354 out += sprintf(out, "yuv_order: %8s %8s %8s %8s\n",
355 cam->params.format.yuvOrder == YUVORDER_YUYV ? 355 cam->params.format.yuvOrder == YUVORDER_YUYV ?
356 "YUYV" : "UYVY", "YUYV" , "UYVY", "YUYV"); 356 "YUYV" : "UYVY", "YUYV" , "UYVY", "YUYV");
357 out += sprintf(out, "ecp_timing: %8s %8s %8s %8s\n", 357 out += sprintf(out, "ecp_timing: %8s %8s %8s %8s\n",
358 cam->params.ecpTiming ? "slow" : "normal", "slow", 358 cam->params.ecpTiming ? "slow" : "normal", "slow",
359 "normal", "normal"); 359 "normal", "normal");
360 360
361 if (cam->params.colourBalance.balanceMode == 2) { 361 if (cam->params.colourBalance.balanceMode == 2) {
@@ -366,11 +366,11 @@ static int cpia_read_proc(char *page, char **start, off_t off,
366 out += sprintf(out, "color_balance_mode: %8s %8s %8s" 366 out += sprintf(out, "color_balance_mode: %8s %8s %8s"
367 " %8s\n", tmpstr, "manual", "auto", "auto"); 367 " %8s\n", tmpstr, "manual", "auto", "auto");
368 out += sprintf(out, "red_gain: %8d %8d %8d %8d\n", 368 out += sprintf(out, "red_gain: %8d %8d %8d %8d\n",
369 cam->params.colourBalance.redGain, 0, 212, 32); 369 cam->params.colourBalance.redGain, 0, 212, 32);
370 out += sprintf(out, "green_gain: %8d %8d %8d %8d\n", 370 out += sprintf(out, "green_gain: %8d %8d %8d %8d\n",
371 cam->params.colourBalance.greenGain, 0, 212, 6); 371 cam->params.colourBalance.greenGain, 0, 212, 6);
372 out += sprintf(out, "blue_gain: %8d %8d %8d %8d\n", 372 out += sprintf(out, "blue_gain: %8d %8d %8d %8d\n",
373 cam->params.colourBalance.blueGain, 0, 212, 92); 373 cam->params.colourBalance.blueGain, 0, 212, 92);
374 374
375 if (cam->params.version.firmwareVersion == 1 && 375 if (cam->params.version.firmwareVersion == 1 &&
376 cam->params.version.firmwareRevision == 2) 376 cam->params.version.firmwareRevision == 2)
@@ -381,11 +381,11 @@ static int cpia_read_proc(char *page, char **start, off_t off,
381 381
382 if (cam->params.exposure.gainMode == 0) 382 if (cam->params.exposure.gainMode == 0)
383 out += sprintf(out, "max_gain: unknown %28s" 383 out += sprintf(out, "max_gain: unknown %28s"
384 " powers of 2\n", tmpstr); 384 " powers of 2\n", tmpstr);
385 else 385 else
386 out += sprintf(out, "max_gain: %8d %28s" 386 out += sprintf(out, "max_gain: %8d %28s"
387 " 1,2,4 or 8 \n", 387 " 1,2,4 or 8 \n",
388 1<<(cam->params.exposure.gainMode-1), tmpstr); 388 1<<(cam->params.exposure.gainMode-1), tmpstr);
389 389
390 switch(cam->params.exposure.expMode) { 390 switch(cam->params.exposure.expMode) {
391 case 1: 391 case 1:
@@ -402,10 +402,10 @@ static int cpia_read_proc(char *page, char **start, off_t off,
402 out += sprintf(out, "exposure_mode: %8s %8s %8s" 402 out += sprintf(out, "exposure_mode: %8s %8s %8s"
403 " %8s\n", tmpstr, "manual", "auto", "auto"); 403 " %8s\n", tmpstr, "manual", "auto", "auto");
404 out += sprintf(out, "centre_weight: %8s %8s %8s %8s\n", 404 out += sprintf(out, "centre_weight: %8s %8s %8s %8s\n",
405 (2-cam->params.exposure.centreWeight) ? "on" : "off", 405 (2-cam->params.exposure.centreWeight) ? "on" : "off",
406 "off", "on", "on"); 406 "off", "on", "on");
407 out += sprintf(out, "gain: %8d %8d max_gain %8d 1,2,4,8 possible\n", 407 out += sprintf(out, "gain: %8d %8d max_gain %8d 1,2,4,8 possible\n",
408 1<<cam->params.exposure.gain, 1, 1); 408 1<<cam->params.exposure.gain, 1, 1);
409 if (cam->params.version.firmwareVersion == 1 && 409 if (cam->params.version.firmwareVersion == 1 &&
410 cam->params.version.firmwareRevision == 2) 410 cam->params.version.firmwareRevision == 2)
411 /* 1-02 firmware limits fineExp/2 to 127 */ 411 /* 1-02 firmware limits fineExp/2 to 127 */
@@ -414,7 +414,7 @@ static int cpia_read_proc(char *page, char **start, off_t off,
414 tmp = 510; 414 tmp = 510;
415 415
416 out += sprintf(out, "fine_exp: %8d %8d %8d %8d\n", 416 out += sprintf(out, "fine_exp: %8d %8d %8d %8d\n",
417 cam->params.exposure.fineExp*2, 0, tmp, 0); 417 cam->params.exposure.fineExp*2, 0, tmp, 0);
418 if (cam->params.version.firmwareVersion == 1 && 418 if (cam->params.version.firmwareVersion == 1 &&
419 cam->params.version.firmwareRevision == 2) 419 cam->params.version.firmwareRevision == 2)
420 /* 1-02 firmware limits coarseExpHi to 0 */ 420 /* 1-02 firmware limits coarseExpHi to 0 */
@@ -426,46 +426,46 @@ static int cpia_read_proc(char *page, char **start, off_t off,
426 " %8d\n", cam->params.exposure.coarseExpLo+ 426 " %8d\n", cam->params.exposure.coarseExpLo+
427 256*cam->params.exposure.coarseExpHi, 0, tmp, 185); 427 256*cam->params.exposure.coarseExpHi, 0, tmp, 185);
428 out += sprintf(out, "red_comp: %8d %8d %8d %8d\n", 428 out += sprintf(out, "red_comp: %8d %8d %8d %8d\n",
429 cam->params.exposure.redComp, COMP_RED, 255, COMP_RED); 429 cam->params.exposure.redComp, COMP_RED, 255, COMP_RED);
430 out += sprintf(out, "green1_comp: %8d %8d %8d %8d\n", 430 out += sprintf(out, "green1_comp: %8d %8d %8d %8d\n",
431 cam->params.exposure.green1Comp, COMP_GREEN1, 255, 431 cam->params.exposure.green1Comp, COMP_GREEN1, 255,
432 COMP_GREEN1); 432 COMP_GREEN1);
433 out += sprintf(out, "green2_comp: %8d %8d %8d %8d\n", 433 out += sprintf(out, "green2_comp: %8d %8d %8d %8d\n",
434 cam->params.exposure.green2Comp, COMP_GREEN2, 255, 434 cam->params.exposure.green2Comp, COMP_GREEN2, 255,
435 COMP_GREEN2); 435 COMP_GREEN2);
436 out += sprintf(out, "blue_comp: %8d %8d %8d %8d\n", 436 out += sprintf(out, "blue_comp: %8d %8d %8d %8d\n",
437 cam->params.exposure.blueComp, COMP_BLUE, 255, COMP_BLUE); 437 cam->params.exposure.blueComp, COMP_BLUE, 255, COMP_BLUE);
438 438
439 out += sprintf(out, "apcor_gain1: %#8x %#8x %#8x %#8x\n", 439 out += sprintf(out, "apcor_gain1: %#8x %#8x %#8x %#8x\n",
440 cam->params.apcor.gain1, 0, 0xff, 0x1c); 440 cam->params.apcor.gain1, 0, 0xff, 0x1c);
441 out += sprintf(out, "apcor_gain2: %#8x %#8x %#8x %#8x\n", 441 out += sprintf(out, "apcor_gain2: %#8x %#8x %#8x %#8x\n",
442 cam->params.apcor.gain2, 0, 0xff, 0x1a); 442 cam->params.apcor.gain2, 0, 0xff, 0x1a);
443 out += sprintf(out, "apcor_gain4: %#8x %#8x %#8x %#8x\n", 443 out += sprintf(out, "apcor_gain4: %#8x %#8x %#8x %#8x\n",
444 cam->params.apcor.gain4, 0, 0xff, 0x2d); 444 cam->params.apcor.gain4, 0, 0xff, 0x2d);
445 out += sprintf(out, "apcor_gain8: %#8x %#8x %#8x %#8x\n", 445 out += sprintf(out, "apcor_gain8: %#8x %#8x %#8x %#8x\n",
446 cam->params.apcor.gain8, 0, 0xff, 0x2a); 446 cam->params.apcor.gain8, 0, 0xff, 0x2a);
447 out += sprintf(out, "vl_offset_gain1: %8d %8d %8d %8d\n", 447 out += sprintf(out, "vl_offset_gain1: %8d %8d %8d %8d\n",
448 cam->params.vlOffset.gain1, 0, 255, 24); 448 cam->params.vlOffset.gain1, 0, 255, 24);
449 out += sprintf(out, "vl_offset_gain2: %8d %8d %8d %8d\n", 449 out += sprintf(out, "vl_offset_gain2: %8d %8d %8d %8d\n",
450 cam->params.vlOffset.gain2, 0, 255, 28); 450 cam->params.vlOffset.gain2, 0, 255, 28);
451 out += sprintf(out, "vl_offset_gain4: %8d %8d %8d %8d\n", 451 out += sprintf(out, "vl_offset_gain4: %8d %8d %8d %8d\n",
452 cam->params.vlOffset.gain4, 0, 255, 30); 452 cam->params.vlOffset.gain4, 0, 255, 30);
453 out += sprintf(out, "vl_offset_gain8: %8d %8d %8d %8d\n", 453 out += sprintf(out, "vl_offset_gain8: %8d %8d %8d %8d\n",
454 cam->params.vlOffset.gain8, 0, 255, 30); 454 cam->params.vlOffset.gain8, 0, 255, 30);
455 out += sprintf(out, "flicker_control: %8s %8s %8s %8s\n", 455 out += sprintf(out, "flicker_control: %8s %8s %8s %8s\n",
456 cam->params.flickerControl.flickerMode ? "on" : "off", 456 cam->params.flickerControl.flickerMode ? "on" : "off",
457 "off", "on", "off"); 457 "off", "on", "off");
458 out += sprintf(out, "mains_frequency: %8d %8d %8d %8d" 458 out += sprintf(out, "mains_frequency: %8d %8d %8d %8d"
459 " only 50/60\n", 459 " only 50/60\n",
460 cam->mainsFreq ? 60 : 50, 50, 60, 50); 460 cam->mainsFreq ? 60 : 50, 50, 60, 50);
461 if(cam->params.flickerControl.allowableOverExposure < 0) 461 if(cam->params.flickerControl.allowableOverExposure < 0)
462 out += sprintf(out, "allowable_overexposure: %4dauto auto %8d auto\n", 462 out += sprintf(out, "allowable_overexposure: %4dauto auto %8d auto\n",
463 -cam->params.flickerControl.allowableOverExposure, 463 -cam->params.flickerControl.allowableOverExposure,
464 255); 464 255);
465 else 465 else
466 out += sprintf(out, "allowable_overexposure: %8d auto %8d auto\n", 466 out += sprintf(out, "allowable_overexposure: %8d auto %8d auto\n",
467 cam->params.flickerControl.allowableOverExposure, 467 cam->params.flickerControl.allowableOverExposure,
468 255); 468 255);
469 out += sprintf(out, "compression_mode: "); 469 out += sprintf(out, "compression_mode: ");
470 switch(cam->params.compression.mode) { 470 switch(cam->params.compression.mode) {
471 case CPIA_COMPRESSION_NONE: 471 case CPIA_COMPRESSION_NONE:
@@ -483,52 +483,52 @@ static int cpia_read_proc(char *page, char **start, off_t off,
483 } 483 }
484 out += sprintf(out, " none,auto,manual auto\n"); 484 out += sprintf(out, " none,auto,manual auto\n");
485 out += sprintf(out, "decimation_enable: %8s %8s %8s %8s\n", 485 out += sprintf(out, "decimation_enable: %8s %8s %8s %8s\n",
486 cam->params.compression.decimation == 486 cam->params.compression.decimation ==
487 DECIMATION_ENAB ? "on":"off", "off", "on", 487 DECIMATION_ENAB ? "on":"off", "off", "on",
488 "off"); 488 "off");
489 out += sprintf(out, "compression_target: %9s %9s %9s %9s\n", 489 out += sprintf(out, "compression_target: %9s %9s %9s %9s\n",
490 cam->params.compressionTarget.frTargeting == 490 cam->params.compressionTarget.frTargeting ==
491 CPIA_COMPRESSION_TARGET_FRAMERATE ? 491 CPIA_COMPRESSION_TARGET_FRAMERATE ?
492 "framerate":"quality", 492 "framerate":"quality",
493 "framerate", "quality", "quality"); 493 "framerate", "quality", "quality");
494 out += sprintf(out, "target_framerate: %8d %8d %8d %8d\n", 494 out += sprintf(out, "target_framerate: %8d %8d %8d %8d\n",
495 cam->params.compressionTarget.targetFR, 1, 30, 15); 495 cam->params.compressionTarget.targetFR, 1, 30, 15);
496 out += sprintf(out, "target_quality: %8d %8d %8d %8d\n", 496 out += sprintf(out, "target_quality: %8d %8d %8d %8d\n",
497 cam->params.compressionTarget.targetQ, 1, 64, 5); 497 cam->params.compressionTarget.targetQ, 1, 64, 5);
498 out += sprintf(out, "y_threshold: %8d %8d %8d %8d\n", 498 out += sprintf(out, "y_threshold: %8d %8d %8d %8d\n",
499 cam->params.yuvThreshold.yThreshold, 0, 31, 6); 499 cam->params.yuvThreshold.yThreshold, 0, 31, 6);
500 out += sprintf(out, "uv_threshold: %8d %8d %8d %8d\n", 500 out += sprintf(out, "uv_threshold: %8d %8d %8d %8d\n",
501 cam->params.yuvThreshold.uvThreshold, 0, 31, 6); 501 cam->params.yuvThreshold.uvThreshold, 0, 31, 6);
502 out += sprintf(out, "hysteresis: %8d %8d %8d %8d\n", 502 out += sprintf(out, "hysteresis: %8d %8d %8d %8d\n",
503 cam->params.compressionParams.hysteresis, 0, 255, 3); 503 cam->params.compressionParams.hysteresis, 0, 255, 3);
504 out += sprintf(out, "threshold_max: %8d %8d %8d %8d\n", 504 out += sprintf(out, "threshold_max: %8d %8d %8d %8d\n",
505 cam->params.compressionParams.threshMax, 0, 255, 11); 505 cam->params.compressionParams.threshMax, 0, 255, 11);
506 out += sprintf(out, "small_step: %8d %8d %8d %8d\n", 506 out += sprintf(out, "small_step: %8d %8d %8d %8d\n",
507 cam->params.compressionParams.smallStep, 0, 255, 1); 507 cam->params.compressionParams.smallStep, 0, 255, 1);
508 out += sprintf(out, "large_step: %8d %8d %8d %8d\n", 508 out += sprintf(out, "large_step: %8d %8d %8d %8d\n",
509 cam->params.compressionParams.largeStep, 0, 255, 3); 509 cam->params.compressionParams.largeStep, 0, 255, 3);
510 out += sprintf(out, "decimation_hysteresis: %8d %8d %8d %8d\n", 510 out += sprintf(out, "decimation_hysteresis: %8d %8d %8d %8d\n",
511 cam->params.compressionParams.decimationHysteresis, 511 cam->params.compressionParams.decimationHysteresis,
512 0, 255, 2); 512 0, 255, 2);
513 out += sprintf(out, "fr_diff_step_thresh: %8d %8d %8d %8d\n", 513 out += sprintf(out, "fr_diff_step_thresh: %8d %8d %8d %8d\n",
514 cam->params.compressionParams.frDiffStepThresh, 514 cam->params.compressionParams.frDiffStepThresh,
515 0, 255, 5); 515 0, 255, 5);
516 out += sprintf(out, "q_diff_step_thresh: %8d %8d %8d %8d\n", 516 out += sprintf(out, "q_diff_step_thresh: %8d %8d %8d %8d\n",
517 cam->params.compressionParams.qDiffStepThresh, 517 cam->params.compressionParams.qDiffStepThresh,
518 0, 255, 3); 518 0, 255, 3);
519 out += sprintf(out, "decimation_thresh_mod: %8d %8d %8d %8d\n", 519 out += sprintf(out, "decimation_thresh_mod: %8d %8d %8d %8d\n",
520 cam->params.compressionParams.decimationThreshMod, 520 cam->params.compressionParams.decimationThreshMod,
521 0, 255, 2); 521 0, 255, 2);
522 /* QX3 specific entries */ 522 /* QX3 specific entries */
523 if (cam->params.qx3.qx3_detected) { 523 if (cam->params.qx3.qx3_detected) {
524 out += sprintf(out, "toplight: %8s %8s %8s %8s\n", 524 out += sprintf(out, "toplight: %8s %8s %8s %8s\n",
525 cam->params.qx3.toplight ? "on" : "off", 525 cam->params.qx3.toplight ? "on" : "off",
526 "off", "on", "off"); 526 "off", "on", "off");
527 out += sprintf(out, "bottomlight: %8s %8s %8s %8s\n", 527 out += sprintf(out, "bottomlight: %8s %8s %8s %8s\n",
528 cam->params.qx3.bottomlight ? "on" : "off", 528 cam->params.qx3.bottomlight ? "on" : "off",
529 "off", "on", "off"); 529 "off", "on", "off");
530 } 530 }
531 531
532 len = out - page; 532 len = out - page;
533 len -= off; 533 len -= off;
534 if (len < count) { 534 if (len < count) {
@@ -543,7 +543,7 @@ static int cpia_read_proc(char *page, char **start, off_t off,
543 543
544 544
545static int match(char *checkstr, char **buffer, unsigned long *count, 545static int match(char *checkstr, char **buffer, unsigned long *count,
546 int *find_colon, int *err) 546 int *find_colon, int *err)
547{ 547{
548 int ret, colon_found = 1; 548 int ret, colon_found = 1;
549 int len = strlen(checkstr); 549 int len = strlen(checkstr);
@@ -583,7 +583,7 @@ static unsigned long int value(char **buffer, unsigned long *count, int *err)
583} 583}
584 584
585static int cpia_write_proc(struct file *file, const char __user *buf, 585static int cpia_write_proc(struct file *file, const char __user *buf,
586 unsigned long count, void *data) 586 unsigned long count, void *data)
587{ 587{
588 struct cam_data *cam = data; 588 struct cam_data *cam = data;
589 struct cam_params new_params; 589 struct cam_params new_params;
@@ -619,12 +619,12 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
619 retval = -EINVAL; 619 retval = -EINVAL;
620 goto out; 620 goto out;
621 } 621 }
622 622
623 buffer = page; 623 buffer = page;
624 624
625 if (mutex_lock_interruptible(&cam->param_lock)) 625 if (mutex_lock_interruptible(&cam->param_lock))
626 return -ERESTARTSYS; 626 return -ERESTARTSYS;
627 627
628 /* 628 /*
629 * Skip over leading whitespace 629 * Skip over leading whitespace
630 */ 630 */
@@ -632,15 +632,15 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
632 --count; 632 --count;
633 ++buffer; 633 ++buffer;
634 } 634 }
635 635
636 memcpy(&new_params, &cam->params, sizeof(struct cam_params)); 636 memcpy(&new_params, &cam->params, sizeof(struct cam_params));
637 new_mains = cam->mainsFreq; 637 new_mains = cam->mainsFreq;
638 638
639#define MATCH(x) (match(x, &buffer, &count, &find_colon, &retval)) 639#define MATCH(x) (match(x, &buffer, &count, &find_colon, &retval))
640#define VALUE (value(&buffer,&count, &retval)) 640#define VALUE (value(&buffer,&count, &retval))
641#define FIRMWARE_VERSION(x,y) (new_params.version.firmwareVersion == (x) && \ 641#define FIRMWARE_VERSION(x,y) (new_params.version.firmwareVersion == (x) && \
642 new_params.version.firmwareRevision == (y)) 642 new_params.version.firmwareRevision == (y))
643 643
644 retval = 0; 644 retval = 0;
645 while (count && !retval) { 645 while (count && !retval) {
646 find_colon = 1; 646 find_colon = 1;
@@ -656,7 +656,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
656 } 656 }
657 command_flags |= COMMAND_SETCOLOURPARAMS; 657 command_flags |= COMMAND_SETCOLOURPARAMS;
658 if(new_params.flickerControl.allowableOverExposure < 0) 658 if(new_params.flickerControl.allowableOverExposure < 0)
659 new_params.flickerControl.allowableOverExposure = 659 new_params.flickerControl.allowableOverExposure =
660 -find_over_exposure(new_params.colourParams.brightness); 660 -find_over_exposure(new_params.colourParams.brightness);
661 if(new_params.flickerControl.flickerMode != 0) 661 if(new_params.flickerControl.flickerMode != 0)
662 command_flags |= COMMAND_SETFLICKERCTRL; 662 command_flags |= COMMAND_SETFLICKERCTRL;
@@ -721,7 +721,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
721 /* Either base rate would work here */ 721 /* Either base rate would work here */
722 new_params.sensorFps.baserate = 1; 722 new_params.sensorFps.baserate = 1;
723 } 723 }
724 new_params.flickerControl.coarseJump = 724 new_params.flickerControl.coarseJump =
725 flicker_jumps[new_mains] 725 flicker_jumps[new_mains]
726 [new_params.sensorFps.baserate] 726 [new_params.sensorFps.baserate]
727 [new_params.sensorFps.divisor]; 727 [new_params.sensorFps.divisor];
@@ -1085,7 +1085,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1085 } else if (MATCH("mains_frequency")) { 1085 } else if (MATCH("mains_frequency")) {
1086 if (!retval && MATCH("50")) { 1086 if (!retval && MATCH("50")) {
1087 new_mains = 0; 1087 new_mains = 0;
1088 new_params.flickerControl.coarseJump = 1088 new_params.flickerControl.coarseJump =
1089 flicker_jumps[new_mains] 1089 flicker_jumps[new_mains]
1090 [new_params.sensorFps.baserate] 1090 [new_params.sensorFps.baserate]
1091 [new_params.sensorFps.divisor]; 1091 [new_params.sensorFps.divisor];
@@ -1093,7 +1093,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1093 command_flags |= COMMAND_SETFLICKERCTRL; 1093 command_flags |= COMMAND_SETFLICKERCTRL;
1094 } else if (!retval && MATCH("60")) { 1094 } else if (!retval && MATCH("60")) {
1095 new_mains = 1; 1095 new_mains = 1;
1096 new_params.flickerControl.coarseJump = 1096 new_params.flickerControl.coarseJump =
1097 flicker_jumps[new_mains] 1097 flicker_jumps[new_mains]
1098 [new_params.sensorFps.baserate] 1098 [new_params.sensorFps.baserate]
1099 [new_params.sensorFps.divisor]; 1099 [new_params.sensorFps.divisor];
@@ -1103,7 +1103,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1103 retval = -EINVAL; 1103 retval = -EINVAL;
1104 } else if (MATCH("allowable_overexposure")) { 1104 } else if (MATCH("allowable_overexposure")) {
1105 if (!retval && MATCH("auto")) { 1105 if (!retval && MATCH("auto")) {
1106 new_params.flickerControl.allowableOverExposure = 1106 new_params.flickerControl.allowableOverExposure =
1107 -find_over_exposure(new_params.colourParams.brightness); 1107 -find_over_exposure(new_params.colourParams.brightness);
1108 if(new_params.flickerControl.flickerMode != 0) 1108 if(new_params.flickerControl.flickerMode != 0)
1109 command_flags |= COMMAND_SETFLICKERCTRL; 1109 command_flags |= COMMAND_SETFLICKERCTRL;
@@ -1146,10 +1146,10 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1146 command_flags |= COMMAND_SETCOMPRESSION; 1146 command_flags |= COMMAND_SETCOMPRESSION;
1147 } else if (MATCH("compression_target")) { 1147 } else if (MATCH("compression_target")) {
1148 if (!retval && MATCH("quality")) 1148 if (!retval && MATCH("quality"))
1149 new_params.compressionTarget.frTargeting = 1149 new_params.compressionTarget.frTargeting =
1150 CPIA_COMPRESSION_TARGET_QUALITY; 1150 CPIA_COMPRESSION_TARGET_QUALITY;
1151 else if (!retval && MATCH("framerate")) 1151 else if (!retval && MATCH("framerate"))
1152 new_params.compressionTarget.frTargeting = 1152 new_params.compressionTarget.frTargeting =
1153 CPIA_COMPRESSION_TARGET_FRAMERATE; 1153 CPIA_COMPRESSION_TARGET_FRAMERATE;
1154 else 1154 else
1155 retval = -EINVAL; 1155 retval = -EINVAL;
@@ -1173,7 +1173,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1173 if (!retval) { 1173 if (!retval) {
1174 if(val > 0 && val <= 64) 1174 if(val > 0 && val <= 64)
1175 new_params.compressionTarget.targetQ = val; 1175 new_params.compressionTarget.targetQ = val;
1176 else 1176 else
1177 retval = -EINVAL; 1177 retval = -EINVAL;
1178 } 1178 }
1179 command_flags |= COMMAND_SETCOMPRESSIONTARGET; 1179 command_flags |= COMMAND_SETCOMPRESSIONTARGET;
@@ -1288,19 +1288,19 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1288 } 1288 }
1289 command_flags |= COMMAND_SETCOMPRESSIONPARAMS; 1289 command_flags |= COMMAND_SETCOMPRESSIONPARAMS;
1290 } else if (MATCH("toplight")) { 1290 } else if (MATCH("toplight")) {
1291 if (!retval && MATCH("on")) 1291 if (!retval && MATCH("on"))
1292 new_params.qx3.toplight = 1; 1292 new_params.qx3.toplight = 1;
1293 else if (!retval && MATCH("off")) 1293 else if (!retval && MATCH("off"))
1294 new_params.qx3.toplight = 0; 1294 new_params.qx3.toplight = 0;
1295 else 1295 else
1296 retval = -EINVAL; 1296 retval = -EINVAL;
1297 command_flags |= COMMAND_SETLIGHTS; 1297 command_flags |= COMMAND_SETLIGHTS;
1298 } else if (MATCH("bottomlight")) { 1298 } else if (MATCH("bottomlight")) {
1299 if (!retval && MATCH("on")) 1299 if (!retval && MATCH("on"))
1300 new_params.qx3.bottomlight = 1; 1300 new_params.qx3.bottomlight = 1;
1301 else if (!retval && MATCH("off")) 1301 else if (!retval && MATCH("off"))
1302 new_params.qx3.bottomlight = 0; 1302 new_params.qx3.bottomlight = 0;
1303 else 1303 else
1304 retval = -EINVAL; 1304 retval = -EINVAL;
1305 command_flags |= COMMAND_SETLIGHTS; 1305 command_flags |= COMMAND_SETLIGHTS;
1306 } else { 1306 } else {
@@ -1326,7 +1326,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1326 } 1326 }
1327 } 1327 }
1328 } 1328 }
1329#undef MATCH 1329#undef MATCH
1330#undef VALUE 1330#undef VALUE
1331#undef FIRMWARE_VERSION 1331#undef FIRMWARE_VERSION
1332 if (!retval) { 1332 if (!retval) {
@@ -1349,24 +1349,24 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1349 retval = size; 1349 retval = size;
1350 } else 1350 } else
1351 DBG("error: %d\n", retval); 1351 DBG("error: %d\n", retval);
1352 1352
1353 mutex_unlock(&cam->param_lock); 1353 mutex_unlock(&cam->param_lock);
1354 1354
1355out: 1355out:
1356 free_page((unsigned long)page); 1356 free_page((unsigned long)page);
1357 return retval; 1357 return retval;
1358} 1358}
1359 1359
1360static void create_proc_cpia_cam(struct cam_data *cam) 1360static void create_proc_cpia_cam(struct cam_data *cam)
1361{ 1361{
1362 char name[7]; 1362 char name[7];
1363 struct proc_dir_entry *ent; 1363 struct proc_dir_entry *ent;
1364 1364
1365 if (!cpia_proc_root || !cam) 1365 if (!cpia_proc_root || !cam)
1366 return; 1366 return;
1367 1367
1368 sprintf(name, "video%d", cam->vdev.minor); 1368 sprintf(name, "video%d", cam->vdev.minor);
1369 1369
1370 ent = create_proc_entry(name, S_IFREG|S_IRUGO|S_IWUSR, cpia_proc_root); 1370 ent = create_proc_entry(name, S_IFREG|S_IRUGO|S_IWUSR, cpia_proc_root);
1371 if (!ent) 1371 if (!ent)
1372 return; 1372 return;
@@ -1374,9 +1374,9 @@ static void create_proc_cpia_cam(struct cam_data *cam)
1374 ent->data = cam; 1374 ent->data = cam;
1375 ent->read_proc = cpia_read_proc; 1375 ent->read_proc = cpia_read_proc;
1376 ent->write_proc = cpia_write_proc; 1376 ent->write_proc = cpia_write_proc;
1377 /* 1377 /*
1378 size of the proc entry is 3736 bytes for the standard webcam; 1378 size of the proc entry is 3736 bytes for the standard webcam;
1379 the extra features of the QX3 microscope add 189 bytes. 1379 the extra features of the QX3 microscope add 189 bytes.
1380 (we have not yet probed the camera to see which type it is). 1380 (we have not yet probed the camera to see which type it is).
1381 */ 1381 */
1382 ent->size = 3736 + 189; 1382 ent->size = 3736 + 189;
@@ -1386,10 +1386,10 @@ static void create_proc_cpia_cam(struct cam_data *cam)
1386static void destroy_proc_cpia_cam(struct cam_data *cam) 1386static void destroy_proc_cpia_cam(struct cam_data *cam)
1387{ 1387{
1388 char name[7]; 1388 char name[7];
1389 1389
1390 if (!cam || !cam->proc_entry) 1390 if (!cam || !cam->proc_entry)
1391 return; 1391 return;
1392 1392
1393 sprintf(name, "video%d", cam->vdev.minor); 1393 sprintf(name, "video%d", cam->vdev.minor);
1394 remove_proc_entry(name, cpia_proc_root); 1394 remove_proc_entry(name, cpia_proc_root);
1395 cam->proc_entry = NULL; 1395 cam->proc_entry = NULL;
@@ -1596,13 +1596,13 @@ static void set_vw_size(struct cam_data *cam)
1596 cam->vc.width = cam->vw.width; 1596 cam->vc.width = cam->vw.width;
1597 if(cam->vc.height == 0) 1597 if(cam->vc.height == 0)
1598 cam->vc.height = cam->vw.height; 1598 cam->vc.height = cam->vw.height;
1599 1599
1600 cam->params.roi.colStart += cam->vc.x >> 3; 1600 cam->params.roi.colStart += cam->vc.x >> 3;
1601 cam->params.roi.colEnd = cam->params.roi.colStart + 1601 cam->params.roi.colEnd = cam->params.roi.colStart +
1602 (cam->vc.width >> 3); 1602 (cam->vc.width >> 3);
1603 cam->params.roi.rowStart += cam->vc.y >> 2; 1603 cam->params.roi.rowStart += cam->vc.y >> 2;
1604 cam->params.roi.rowEnd = cam->params.roi.rowStart + 1604 cam->params.roi.rowEnd = cam->params.roi.rowStart +
1605 (cam->vc.height >> 2); 1605 (cam->vc.height >> 2);
1606 1606
1607 return; 1607 return;
1608} 1608}
@@ -1624,7 +1624,7 @@ static int allocate_frame_buf(struct cam_data *cam)
1624static int free_frame_buf(struct cam_data *cam) 1624static int free_frame_buf(struct cam_data *cam)
1625{ 1625{
1626 int i; 1626 int i;
1627 1627
1628 rvfree(cam->frame_buf, FRAME_NUM*CPIA_MAX_FRAME_SIZE); 1628 rvfree(cam->frame_buf, FRAME_NUM*CPIA_MAX_FRAME_SIZE);
1629 cam->frame_buf = NULL; 1629 cam->frame_buf = NULL;
1630 for (i=0; i < FRAME_NUM; i++) 1630 for (i=0; i < FRAME_NUM; i++)
@@ -1667,7 +1667,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
1667 mutex_lock(&cam->param_lock); 1667 mutex_lock(&cam->param_lock);
1668 datasize=8; 1668 datasize=8;
1669 break; 1669 break;
1670 case CPIA_COMMAND_ReadMCPorts: 1670 case CPIA_COMMAND_ReadMCPorts:
1671 case CPIA_COMMAND_ReadVCRegs: 1671 case CPIA_COMMAND_ReadVCRegs:
1672 datasize = 4; 1672 datasize = 4;
1673 break; 1673 break;
@@ -1746,10 +1746,10 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
1746 mutex_unlock(&cam->param_lock); 1746 mutex_unlock(&cam->param_lock);
1747 break; 1747 break;
1748 1748
1749 case CPIA_COMMAND_ReadMCPorts: 1749 case CPIA_COMMAND_ReadMCPorts:
1750 if (!cam->params.qx3.qx3_detected) 1750 if (!cam->params.qx3.qx3_detected)
1751 break; 1751 break;
1752 /* test button press */ 1752 /* test button press */
1753 cam->params.qx3.button = ((data[1] & 0x02) == 0); 1753 cam->params.qx3.button = ((data[1] & 0x02) == 0);
1754 if (cam->params.qx3.button) { 1754 if (cam->params.qx3.button) {
1755 /* button pressed - unlock the latch */ 1755 /* button pressed - unlock the latch */
@@ -1770,9 +1770,9 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
1770 1770
1771/* send a command to the camera with an additional data transaction */ 1771/* send a command to the camera with an additional data transaction */
1772static int do_command_extended(struct cam_data *cam, u16 command, 1772static int do_command_extended(struct cam_data *cam, u16 command,
1773 u8 a, u8 b, u8 c, u8 d, 1773 u8 a, u8 b, u8 c, u8 d,
1774 u8 e, u8 f, u8 g, u8 h, 1774 u8 e, u8 f, u8 g, u8 h,
1775 u8 i, u8 j, u8 k, u8 l) 1775 u8 i, u8 j, u8 k, u8 l)
1776{ 1776{
1777 int retval; 1777 int retval;
1778 u8 cmd[8], data[8]; 1778 u8 cmd[8], data[8];
@@ -1809,10 +1809,10 @@ static int do_command_extended(struct cam_data *cam, u16 command,
1809#define LIMIT(x) ((((x)>0xffffff)?0xff0000:(((x)<=0xffff)?0:(x)&0xff0000))>>16) 1809#define LIMIT(x) ((((x)>0xffffff)?0xff0000:(((x)<=0xffff)?0:(x)&0xff0000))>>16)
1810 1810
1811static int convert420(unsigned char *yuv, unsigned char *rgb, int out_fmt, 1811static int convert420(unsigned char *yuv, unsigned char *rgb, int out_fmt,
1812 int linesize, int mmap_kludge) 1812 int linesize, int mmap_kludge)
1813{ 1813{
1814 int y, u, v, r, g, b, y1; 1814 int y, u, v, r, g, b, y1;
1815 1815
1816 /* Odd lines use the same u and v as the previous line. 1816 /* Odd lines use the same u and v as the previous line.
1817 * Because of compression, it is necessary to get this 1817 * Because of compression, it is necessary to get this
1818 * information from the decoded image. */ 1818 * information from the decoded image. */
@@ -1925,7 +1925,7 @@ static int convert420(unsigned char *yuv, unsigned char *rgb, int out_fmt,
1925 1925
1926 1926
1927static int yuvconvert(unsigned char *yuv, unsigned char *rgb, int out_fmt, 1927static int yuvconvert(unsigned char *yuv, unsigned char *rgb, int out_fmt,
1928 int in_uyvy, int mmap_kludge) 1928 int in_uyvy, int mmap_kludge)
1929{ 1929{
1930 int y, u, v, r, g, b, y1; 1930 int y, u, v, r, g, b, y1;
1931 1931
@@ -2078,21 +2078,21 @@ static int parse_picture(struct cam_data *cam, int size)
2078 mutex_unlock(&cam->param_lock); 2078 mutex_unlock(&cam->param_lock);
2079 return -1; 2079 return -1;
2080 } 2080 }
2081 2081
2082 if (ibuf[17] != SUBSAMPLE_420 && ibuf[17] != SUBSAMPLE_422) { 2082 if (ibuf[17] != SUBSAMPLE_420 && ibuf[17] != SUBSAMPLE_422) {
2083 LOG("illegal subtype %d\n",ibuf[17]); 2083 LOG("illegal subtype %d\n",ibuf[17]);
2084 mutex_unlock(&cam->param_lock); 2084 mutex_unlock(&cam->param_lock);
2085 return -1; 2085 return -1;
2086 } 2086 }
2087 subsample_422 = ibuf[17] == SUBSAMPLE_422; 2087 subsample_422 = ibuf[17] == SUBSAMPLE_422;
2088 2088
2089 if (ibuf[18] != YUVORDER_YUYV && ibuf[18] != YUVORDER_UYVY) { 2089 if (ibuf[18] != YUVORDER_YUYV && ibuf[18] != YUVORDER_UYVY) {
2090 LOG("illegal yuvorder %d\n",ibuf[18]); 2090 LOG("illegal yuvorder %d\n",ibuf[18]);
2091 mutex_unlock(&cam->param_lock); 2091 mutex_unlock(&cam->param_lock);
2092 return -1; 2092 return -1;
2093 } 2093 }
2094 in_uyvy = ibuf[18] == YUVORDER_UYVY; 2094 in_uyvy = ibuf[18] == YUVORDER_UYVY;
2095 2095
2096 if ((ibuf[24] != cam->params.roi.colStart) || 2096 if ((ibuf[24] != cam->params.roi.colStart) ||
2097 (ibuf[25] != cam->params.roi.colEnd) || 2097 (ibuf[25] != cam->params.roi.colEnd) ||
2098 (ibuf[26] != cam->params.roi.rowStart) || 2098 (ibuf[26] != cam->params.roi.rowStart) ||
@@ -2104,20 +2104,20 @@ static int parse_picture(struct cam_data *cam, int size)
2104 cols = 8*(ibuf[25] - ibuf[24]); 2104 cols = 8*(ibuf[25] - ibuf[24]);
2105 rows = 4*(ibuf[27] - ibuf[26]); 2105 rows = 4*(ibuf[27] - ibuf[26]);
2106 2106
2107 2107
2108 if ((ibuf[28] != NOT_COMPRESSED) && (ibuf[28] != COMPRESSED)) { 2108 if ((ibuf[28] != NOT_COMPRESSED) && (ibuf[28] != COMPRESSED)) {
2109 LOG("illegal compression %d\n",ibuf[28]); 2109 LOG("illegal compression %d\n",ibuf[28]);
2110 mutex_unlock(&cam->param_lock); 2110 mutex_unlock(&cam->param_lock);
2111 return -1; 2111 return -1;
2112 } 2112 }
2113 compressed = (ibuf[28] == COMPRESSED); 2113 compressed = (ibuf[28] == COMPRESSED);
2114 2114
2115 if (ibuf[29] != NO_DECIMATION && ibuf[29] != DECIMATION_ENAB) { 2115 if (ibuf[29] != NO_DECIMATION && ibuf[29] != DECIMATION_ENAB) {
2116 LOG("illegal decimation %d\n",ibuf[29]); 2116 LOG("illegal decimation %d\n",ibuf[29]);
2117 mutex_unlock(&cam->param_lock); 2117 mutex_unlock(&cam->param_lock);
2118 return -1; 2118 return -1;
2119 } 2119 }
2120 decimation = (ibuf[29] == DECIMATION_ENAB); 2120 decimation = (ibuf[29] == DECIMATION_ENAB);
2121 2121
2122 cam->params.yuvThreshold.yThreshold = ibuf[30]; 2122 cam->params.yuvThreshold.yThreshold = ibuf[30];
2123 cam->params.yuvThreshold.uvThreshold = ibuf[31]; 2123 cam->params.yuvThreshold.uvThreshold = ibuf[31];
@@ -2131,7 +2131,7 @@ static int parse_picture(struct cam_data *cam, int size)
2131 cam->params.status.errorCode = ibuf[39]; 2131 cam->params.status.errorCode = ibuf[39];
2132 cam->fps = ibuf[41]; 2132 cam->fps = ibuf[41];
2133 mutex_unlock(&cam->param_lock); 2133 mutex_unlock(&cam->param_lock);
2134 2134
2135 linesize = skipcount(cols, out_fmt); 2135 linesize = skipcount(cols, out_fmt);
2136 ibuf += FRAME_HEADER_SIZE; 2136 ibuf += FRAME_HEADER_SIZE;
2137 size -= FRAME_HEADER_SIZE; 2137 size -= FRAME_HEADER_SIZE;
@@ -2150,14 +2150,14 @@ static int parse_picture(struct cam_data *cam, int size)
2150 if (!compressed || (compressed && !(*ibuf & 1))) { 2150 if (!compressed || (compressed && !(*ibuf & 1))) {
2151 if(subsample_422 || even_line) { 2151 if(subsample_422 || even_line) {
2152 obuf += yuvconvert(ibuf, obuf, out_fmt, 2152 obuf += yuvconvert(ibuf, obuf, out_fmt,
2153 in_uyvy, cam->mmap_kludge); 2153 in_uyvy, cam->mmap_kludge);
2154 ibuf += 4; 2154 ibuf += 4;
2155 ll -= 4; 2155 ll -= 4;
2156 } else { 2156 } else {
2157 /* SUBSAMPLE_420 on an odd line */ 2157 /* SUBSAMPLE_420 on an odd line */
2158 obuf += convert420(ibuf, obuf, 2158 obuf += convert420(ibuf, obuf,
2159 out_fmt, linesize, 2159 out_fmt, linesize,
2160 cam->mmap_kludge); 2160 cam->mmap_kludge);
2161 ibuf += 2; 2161 ibuf += 2;
2162 ll -= 2; 2162 ll -= 2;
2163 } 2163 }
@@ -2183,7 +2183,7 @@ static int parse_picture(struct cam_data *cam, int size)
2183 2183
2184 if ((size > 3) && (ibuf[0] == EOI) && (ibuf[1] == EOI) && 2184 if ((size > 3) && (ibuf[0] == EOI) && (ibuf[1] == EOI) &&
2185 (ibuf[2] == EOI) && (ibuf[3] == EOI)) { 2185 (ibuf[2] == EOI) && (ibuf[3] == EOI)) {
2186 size -= 4; 2186 size -= 4;
2187 break; 2187 break;
2188 } 2188 }
2189 2189
@@ -2204,7 +2204,7 @@ static int parse_picture(struct cam_data *cam, int size)
2204 return -1; 2204 return -1;
2205 } 2205 }
2206 } 2206 }
2207 2207
2208 if(decimation) { 2208 if(decimation) {
2209 /* interpolate odd rows */ 2209 /* interpolate odd rows */
2210 int i, j; 2210 int i, j;
@@ -2233,7 +2233,7 @@ static int parse_picture(struct cam_data *cam, int size)
2233static inline int init_stream_cap(struct cam_data *cam) 2233static inline int init_stream_cap(struct cam_data *cam)
2234{ 2234{
2235 return do_command(cam, CPIA_COMMAND_InitStreamCap, 2235 return do_command(cam, CPIA_COMMAND_InitStreamCap,
2236 0, cam->params.streamStartLine, 0, 0); 2236 0, cam->params.streamStartLine, 0, 0);
2237} 2237}
2238 2238
2239 2239
@@ -2254,7 +2254,7 @@ static int find_over_exposure(int brightness)
2254 int MaxAllowableOverExposure, OverExposure; 2254 int MaxAllowableOverExposure, OverExposure;
2255 2255
2256 MaxAllowableOverExposure = FLICKER_MAX_EXPOSURE - brightness - 2256 MaxAllowableOverExposure = FLICKER_MAX_EXPOSURE - brightness -
2257 FLICKER_BRIGHTNESS_CONSTANT; 2257 FLICKER_BRIGHTNESS_CONSTANT;
2258 2258
2259 if (MaxAllowableOverExposure < FLICKER_ALLOWABLE_OVER_EXPOSURE) { 2259 if (MaxAllowableOverExposure < FLICKER_ALLOWABLE_OVER_EXPOSURE) {
2260 OverExposure = MaxAllowableOverExposure; 2260 OverExposure = MaxAllowableOverExposure;
@@ -2280,62 +2280,62 @@ static void dispatch_commands(struct cam_data *cam)
2280 DEB_BYTE(cam->cmd_queue>>8); 2280 DEB_BYTE(cam->cmd_queue>>8);
2281 if (cam->cmd_queue & COMMAND_SETFORMAT) { 2281 if (cam->cmd_queue & COMMAND_SETFORMAT) {
2282 do_command(cam, CPIA_COMMAND_SetFormat, 2282 do_command(cam, CPIA_COMMAND_SetFormat,
2283 cam->params.format.videoSize, 2283 cam->params.format.videoSize,
2284 cam->params.format.subSample, 2284 cam->params.format.subSample,
2285 cam->params.format.yuvOrder, 0); 2285 cam->params.format.yuvOrder, 0);
2286 do_command(cam, CPIA_COMMAND_SetROI, 2286 do_command(cam, CPIA_COMMAND_SetROI,
2287 cam->params.roi.colStart, cam->params.roi.colEnd, 2287 cam->params.roi.colStart, cam->params.roi.colEnd,
2288 cam->params.roi.rowStart, cam->params.roi.rowEnd); 2288 cam->params.roi.rowStart, cam->params.roi.rowEnd);
2289 cam->first_frame = 1; 2289 cam->first_frame = 1;
2290 } 2290 }
2291 2291
2292 if (cam->cmd_queue & COMMAND_SETCOLOURPARAMS) 2292 if (cam->cmd_queue & COMMAND_SETCOLOURPARAMS)
2293 do_command(cam, CPIA_COMMAND_SetColourParams, 2293 do_command(cam, CPIA_COMMAND_SetColourParams,
2294 cam->params.colourParams.brightness, 2294 cam->params.colourParams.brightness,
2295 cam->params.colourParams.contrast, 2295 cam->params.colourParams.contrast,
2296 cam->params.colourParams.saturation, 0); 2296 cam->params.colourParams.saturation, 0);
2297 2297
2298 if (cam->cmd_queue & COMMAND_SETAPCOR) 2298 if (cam->cmd_queue & COMMAND_SETAPCOR)
2299 do_command(cam, CPIA_COMMAND_SetApcor, 2299 do_command(cam, CPIA_COMMAND_SetApcor,
2300 cam->params.apcor.gain1, 2300 cam->params.apcor.gain1,
2301 cam->params.apcor.gain2, 2301 cam->params.apcor.gain2,
2302 cam->params.apcor.gain4, 2302 cam->params.apcor.gain4,
2303 cam->params.apcor.gain8); 2303 cam->params.apcor.gain8);
2304 2304
2305 if (cam->cmd_queue & COMMAND_SETVLOFFSET) 2305 if (cam->cmd_queue & COMMAND_SETVLOFFSET)
2306 do_command(cam, CPIA_COMMAND_SetVLOffset, 2306 do_command(cam, CPIA_COMMAND_SetVLOffset,
2307 cam->params.vlOffset.gain1, 2307 cam->params.vlOffset.gain1,
2308 cam->params.vlOffset.gain2, 2308 cam->params.vlOffset.gain2,
2309 cam->params.vlOffset.gain4, 2309 cam->params.vlOffset.gain4,
2310 cam->params.vlOffset.gain8); 2310 cam->params.vlOffset.gain8);
2311 2311
2312 if (cam->cmd_queue & COMMAND_SETEXPOSURE) { 2312 if (cam->cmd_queue & COMMAND_SETEXPOSURE) {
2313 do_command_extended(cam, CPIA_COMMAND_SetExposure, 2313 do_command_extended(cam, CPIA_COMMAND_SetExposure,
2314 cam->params.exposure.gainMode, 2314 cam->params.exposure.gainMode,
2315 1, 2315 1,
2316 cam->params.exposure.compMode, 2316 cam->params.exposure.compMode,
2317 cam->params.exposure.centreWeight, 2317 cam->params.exposure.centreWeight,
2318 cam->params.exposure.gain, 2318 cam->params.exposure.gain,
2319 cam->params.exposure.fineExp, 2319 cam->params.exposure.fineExp,
2320 cam->params.exposure.coarseExpLo, 2320 cam->params.exposure.coarseExpLo,
2321 cam->params.exposure.coarseExpHi, 2321 cam->params.exposure.coarseExpHi,
2322 cam->params.exposure.redComp, 2322 cam->params.exposure.redComp,
2323 cam->params.exposure.green1Comp, 2323 cam->params.exposure.green1Comp,
2324 cam->params.exposure.green2Comp, 2324 cam->params.exposure.green2Comp,
2325 cam->params.exposure.blueComp); 2325 cam->params.exposure.blueComp);
2326 if(cam->params.exposure.expMode != 1) { 2326 if(cam->params.exposure.expMode != 1) {
2327 do_command_extended(cam, CPIA_COMMAND_SetExposure, 2327 do_command_extended(cam, CPIA_COMMAND_SetExposure,
2328 0, 2328 0,
2329 cam->params.exposure.expMode, 2329 cam->params.exposure.expMode,
2330 0, 0, 2330 0, 0,
2331 cam->params.exposure.gain, 2331 cam->params.exposure.gain,
2332 cam->params.exposure.fineExp, 2332 cam->params.exposure.fineExp,
2333 cam->params.exposure.coarseExpLo, 2333 cam->params.exposure.coarseExpLo,
2334 cam->params.exposure.coarseExpHi, 2334 cam->params.exposure.coarseExpHi,
2335 0, 0, 0, 0); 2335 0, 0, 0, 0);
2336 } 2336 }
2337 } 2337 }
2338 2338
2339 if (cam->cmd_queue & COMMAND_SETCOLOURBALANCE) { 2339 if (cam->cmd_queue & COMMAND_SETCOLOURBALANCE) {
2340 if (cam->params.colourBalance.balanceMode == 1) { 2340 if (cam->params.colourBalance.balanceMode == 1) {
2341 do_command(cam, CPIA_COMMAND_SetColourBalance, 2341 do_command(cam, CPIA_COMMAND_SetColourBalance,
@@ -2358,47 +2358,47 @@ static void dispatch_commands(struct cam_data *cam)
2358 2358
2359 if (cam->cmd_queue & COMMAND_SETCOMPRESSIONTARGET) 2359 if (cam->cmd_queue & COMMAND_SETCOMPRESSIONTARGET)
2360 do_command(cam, CPIA_COMMAND_SetCompressionTarget, 2360 do_command(cam, CPIA_COMMAND_SetCompressionTarget,
2361 cam->params.compressionTarget.frTargeting, 2361 cam->params.compressionTarget.frTargeting,
2362 cam->params.compressionTarget.targetFR, 2362 cam->params.compressionTarget.targetFR,
2363 cam->params.compressionTarget.targetQ, 0); 2363 cam->params.compressionTarget.targetQ, 0);
2364 2364
2365 if (cam->cmd_queue & COMMAND_SETYUVTHRESH) 2365 if (cam->cmd_queue & COMMAND_SETYUVTHRESH)
2366 do_command(cam, CPIA_COMMAND_SetYUVThresh, 2366 do_command(cam, CPIA_COMMAND_SetYUVThresh,
2367 cam->params.yuvThreshold.yThreshold, 2367 cam->params.yuvThreshold.yThreshold,
2368 cam->params.yuvThreshold.uvThreshold, 0, 0); 2368 cam->params.yuvThreshold.uvThreshold, 0, 0);
2369 2369
2370 if (cam->cmd_queue & COMMAND_SETCOMPRESSIONPARAMS) 2370 if (cam->cmd_queue & COMMAND_SETCOMPRESSIONPARAMS)
2371 do_command_extended(cam, CPIA_COMMAND_SetCompressionParams, 2371 do_command_extended(cam, CPIA_COMMAND_SetCompressionParams,
2372 0, 0, 0, 0, 2372 0, 0, 0, 0,
2373 cam->params.compressionParams.hysteresis, 2373 cam->params.compressionParams.hysteresis,
2374 cam->params.compressionParams.threshMax, 2374 cam->params.compressionParams.threshMax,
2375 cam->params.compressionParams.smallStep, 2375 cam->params.compressionParams.smallStep,
2376 cam->params.compressionParams.largeStep, 2376 cam->params.compressionParams.largeStep,
2377 cam->params.compressionParams.decimationHysteresis, 2377 cam->params.compressionParams.decimationHysteresis,
2378 cam->params.compressionParams.frDiffStepThresh, 2378 cam->params.compressionParams.frDiffStepThresh,
2379 cam->params.compressionParams.qDiffStepThresh, 2379 cam->params.compressionParams.qDiffStepThresh,
2380 cam->params.compressionParams.decimationThreshMod); 2380 cam->params.compressionParams.decimationThreshMod);
2381 2381
2382 if (cam->cmd_queue & COMMAND_SETCOMPRESSION) 2382 if (cam->cmd_queue & COMMAND_SETCOMPRESSION)
2383 do_command(cam, CPIA_COMMAND_SetCompression, 2383 do_command(cam, CPIA_COMMAND_SetCompression,
2384 cam->params.compression.mode, 2384 cam->params.compression.mode,
2385 cam->params.compression.decimation, 0, 0); 2385 cam->params.compression.decimation, 0, 0);
2386 2386
2387 if (cam->cmd_queue & COMMAND_SETSENSORFPS) 2387 if (cam->cmd_queue & COMMAND_SETSENSORFPS)
2388 do_command(cam, CPIA_COMMAND_SetSensorFPS, 2388 do_command(cam, CPIA_COMMAND_SetSensorFPS,
2389 cam->params.sensorFps.divisor, 2389 cam->params.sensorFps.divisor,
2390 cam->params.sensorFps.baserate, 0, 0); 2390 cam->params.sensorFps.baserate, 0, 0);
2391 2391
2392 if (cam->cmd_queue & COMMAND_SETFLICKERCTRL) 2392 if (cam->cmd_queue & COMMAND_SETFLICKERCTRL)
2393 do_command(cam, CPIA_COMMAND_SetFlickerCtrl, 2393 do_command(cam, CPIA_COMMAND_SetFlickerCtrl,
2394 cam->params.flickerControl.flickerMode, 2394 cam->params.flickerControl.flickerMode,
2395 cam->params.flickerControl.coarseJump, 2395 cam->params.flickerControl.coarseJump,
2396 abs(cam->params.flickerControl.allowableOverExposure), 2396 abs(cam->params.flickerControl.allowableOverExposure),
2397 0); 2397 0);
2398 2398
2399 if (cam->cmd_queue & COMMAND_SETECPTIMING) 2399 if (cam->cmd_queue & COMMAND_SETECPTIMING)
2400 do_command(cam, CPIA_COMMAND_SetECPTiming, 2400 do_command(cam, CPIA_COMMAND_SetECPTiming,
2401 cam->params.ecpTiming, 0, 0, 0); 2401 cam->params.ecpTiming, 0, 0, 0);
2402 2402
2403 if (cam->cmd_queue & COMMAND_PAUSE) 2403 if (cam->cmd_queue & COMMAND_PAUSE)
2404 do_command(cam, CPIA_COMMAND_EndStreamCap, 0, 0, 0, 0); 2404 do_command(cam, CPIA_COMMAND_EndStreamCap, 0, 0, 0, 0);
@@ -2409,9 +2409,9 @@ static void dispatch_commands(struct cam_data *cam)
2409 if (cam->cmd_queue & COMMAND_SETLIGHTS && cam->params.qx3.qx3_detected) 2409 if (cam->cmd_queue & COMMAND_SETLIGHTS && cam->params.qx3.qx3_detected)
2410 { 2410 {
2411 int p1 = (cam->params.qx3.bottomlight == 0) << 1; 2411 int p1 = (cam->params.qx3.bottomlight == 0) << 1;
2412 int p2 = (cam->params.qx3.toplight == 0) << 3; 2412 int p2 = (cam->params.qx3.toplight == 0) << 3;
2413 do_command(cam, CPIA_COMMAND_WriteVCReg, 0x90, 0x8F, 0x50, 0); 2413 do_command(cam, CPIA_COMMAND_WriteVCReg, 0x90, 0x8F, 0x50, 0);
2414 do_command(cam, CPIA_COMMAND_WriteMCPort, 2, 0, (p1|p2|0xE0), 0); 2414 do_command(cam, CPIA_COMMAND_WriteMCPort, 2, 0, (p1|p2|0xE0), 0);
2415 } 2415 }
2416 2416
2417 cam->cmd_queue = COMMAND_NONE; 2417 cam->cmd_queue = COMMAND_NONE;
@@ -2422,11 +2422,11 @@ static void dispatch_commands(struct cam_data *cam)
2422 2422
2423 2423
2424static void set_flicker(struct cam_params *params, volatile u32 *command_flags, 2424static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
2425 int on) 2425 int on)
2426{ 2426{
2427 /* Everything in here is from the Windows driver */ 2427 /* Everything in here is from the Windows driver */
2428#define FIRMWARE_VERSION(x,y) (params->version.firmwareVersion == (x) && \ 2428#define FIRMWARE_VERSION(x,y) (params->version.firmwareVersion == (x) && \
2429 params->version.firmwareRevision == (y)) 2429 params->version.firmwareRevision == (y))
2430/* define for compgain calculation */ 2430/* define for compgain calculation */
2431#if 0 2431#if 0
2432#define COMPGAIN(base, curexp, newexp) \ 2432#define COMPGAIN(base, curexp, newexp) \
@@ -2441,7 +2441,7 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
2441 (u16)(((u32)(curexp * (u8)(curcomp + 128)) / (u8)(basecomp - 128))) 2441 (u16)(((u32)(curexp * (u8)(curcomp + 128)) / (u8)(basecomp - 128)))
2442#endif 2442#endif
2443 2443
2444 2444
2445 int currentexp = params->exposure.coarseExpLo + 2445 int currentexp = params->exposure.coarseExpLo +
2446 params->exposure.coarseExpHi*256; 2446 params->exposure.coarseExpHi*256;
2447 int startexp; 2447 int startexp;
@@ -2482,7 +2482,7 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
2482 } 2482 }
2483 if(FIRMWARE_VERSION(1,2)) 2483 if(FIRMWARE_VERSION(1,2))
2484 params->exposure.compMode = 0; 2484 params->exposure.compMode = 0;
2485 else 2485 else
2486 params->exposure.compMode = 1; 2486 params->exposure.compMode = 1;
2487 2487
2488 params->apcor.gain1 = 0x18; 2488 params->apcor.gain1 = 0x18;
@@ -2533,14 +2533,14 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
2533} 2533}
2534 2534
2535#define FIRMWARE_VERSION(x,y) (cam->params.version.firmwareVersion == (x) && \ 2535#define FIRMWARE_VERSION(x,y) (cam->params.version.firmwareVersion == (x) && \
2536 cam->params.version.firmwareRevision == (y)) 2536 cam->params.version.firmwareRevision == (y))
2537/* monitor the exposure and adjust the sensor frame rate if needed */ 2537/* monitor the exposure and adjust the sensor frame rate if needed */
2538static void monitor_exposure(struct cam_data *cam) 2538static void monitor_exposure(struct cam_data *cam)
2539{ 2539{
2540 u8 exp_acc, bcomp, gain, coarseL, cmd[8], data[8]; 2540 u8 exp_acc, bcomp, gain, coarseL, cmd[8], data[8];
2541 int retval, light_exp, dark_exp, very_dark_exp; 2541 int retval, light_exp, dark_exp, very_dark_exp;
2542 int old_exposure, new_exposure, framerate; 2542 int old_exposure, new_exposure, framerate;
2543 2543
2544 /* get necessary stats and register settings from camera */ 2544 /* get necessary stats and register settings from camera */
2545 /* do_command can't handle this, so do it ourselves */ 2545 /* do_command can't handle this, so do it ourselves */
2546 cmd[0] = CPIA_COMMAND_ReadVPRegs>>8; 2546 cmd[0] = CPIA_COMMAND_ReadVPRegs>>8;
@@ -2564,17 +2564,17 @@ static void monitor_exposure(struct cam_data *cam)
2564 2564
2565 mutex_lock(&cam->param_lock); 2565 mutex_lock(&cam->param_lock);
2566 light_exp = cam->params.colourParams.brightness + 2566 light_exp = cam->params.colourParams.brightness +
2567 TC - 50 + EXP_ACC_LIGHT; 2567 TC - 50 + EXP_ACC_LIGHT;
2568 if(light_exp > 255) 2568 if(light_exp > 255)
2569 light_exp = 255; 2569 light_exp = 255;
2570 dark_exp = cam->params.colourParams.brightness + 2570 dark_exp = cam->params.colourParams.brightness +
2571 TC - 50 - EXP_ACC_DARK; 2571 TC - 50 - EXP_ACC_DARK;
2572 if(dark_exp < 0) 2572 if(dark_exp < 0)
2573 dark_exp = 0; 2573 dark_exp = 0;
2574 very_dark_exp = dark_exp/2; 2574 very_dark_exp = dark_exp/2;
2575 2575
2576 old_exposure = cam->params.exposure.coarseExpHi * 256 + 2576 old_exposure = cam->params.exposure.coarseExpHi * 256 +
2577 cam->params.exposure.coarseExpLo; 2577 cam->params.exposure.coarseExpLo;
2578 2578
2579 if(!cam->params.flickerControl.disabled) { 2579 if(!cam->params.flickerControl.disabled) {
2580 /* Flicker control on */ 2580 /* Flicker control on */
@@ -2667,11 +2667,11 @@ static void monitor_exposure(struct cam_data *cam)
2667 cam->exposure_status = EXPOSURE_NORMAL; 2667 cam->exposure_status = EXPOSURE_NORMAL;
2668 } 2668 }
2669 } 2669 }
2670 2670
2671 framerate = cam->fps; 2671 framerate = cam->fps;
2672 if(framerate > 30 || framerate < 1) 2672 if(framerate > 30 || framerate < 1)
2673 framerate = 1; 2673 framerate = 1;
2674 2674
2675 if(!cam->params.flickerControl.disabled) { 2675 if(!cam->params.flickerControl.disabled) {
2676 /* Flicker control on */ 2676 /* Flicker control on */
2677 if((cam->exposure_status == EXPOSURE_VERY_DARK || 2677 if((cam->exposure_status == EXPOSURE_VERY_DARK ||
@@ -2683,10 +2683,10 @@ static void monitor_exposure(struct cam_data *cam)
2683 ++cam->params.sensorFps.divisor; 2683 ++cam->params.sensorFps.divisor;
2684 cam->cmd_queue |= COMMAND_SETSENSORFPS; 2684 cam->cmd_queue |= COMMAND_SETSENSORFPS;
2685 2685
2686 cam->params.flickerControl.coarseJump = 2686 cam->params.flickerControl.coarseJump =
2687 flicker_jumps[cam->mainsFreq] 2687 flicker_jumps[cam->mainsFreq]
2688 [cam->params.sensorFps.baserate] 2688 [cam->params.sensorFps.baserate]
2689 [cam->params.sensorFps.divisor]; 2689 [cam->params.sensorFps.divisor];
2690 cam->cmd_queue |= COMMAND_SETFLICKERCTRL; 2690 cam->cmd_queue |= COMMAND_SETFLICKERCTRL;
2691 2691
2692 new_exposure = cam->params.flickerControl.coarseJump-1; 2692 new_exposure = cam->params.flickerControl.coarseJump-1;
@@ -2704,15 +2704,15 @@ static void monitor_exposure(struct cam_data *cam)
2704 cam->params.sensorFps.divisor > 0) { 2704 cam->params.sensorFps.divisor > 0) {
2705 2705
2706 /* light for too long */ 2706 /* light for too long */
2707 int max_exp = FIRMWARE_VERSION(1,2) ? MAX_EXP_102 : MAX_EXP ; 2707 int max_exp = FIRMWARE_VERSION(1,2) ? MAX_EXP_102 : MAX_EXP ;
2708 2708
2709 --cam->params.sensorFps.divisor; 2709 --cam->params.sensorFps.divisor;
2710 cam->cmd_queue |= COMMAND_SETSENSORFPS; 2710 cam->cmd_queue |= COMMAND_SETSENSORFPS;
2711 2711
2712 cam->params.flickerControl.coarseJump = 2712 cam->params.flickerControl.coarseJump =
2713 flicker_jumps[cam->mainsFreq] 2713 flicker_jumps[cam->mainsFreq]
2714 [cam->params.sensorFps.baserate] 2714 [cam->params.sensorFps.baserate]
2715 [cam->params.sensorFps.divisor]; 2715 [cam->params.sensorFps.divisor];
2716 cam->cmd_queue |= COMMAND_SETFLICKERCTRL; 2716 cam->cmd_queue |= COMMAND_SETFLICKERCTRL;
2717 2717
2718 new_exposure = cam->params.flickerControl.coarseJump-1; 2718 new_exposure = cam->params.flickerControl.coarseJump-1;
@@ -2772,7 +2772,7 @@ static void monitor_exposure(struct cam_data *cam)
2772 2772
2773 It also adjust the colour balance when an exposure step is detected - as 2773 It also adjust the colour balance when an exposure step is detected - as
2774 long as flicker is running 2774 long as flicker is running
2775*/ 2775*/
2776static void restart_flicker(struct cam_data *cam) 2776static void restart_flicker(struct cam_data *cam)
2777{ 2777{
2778 int cam_exposure, old_exp; 2778 int cam_exposure, old_exp;
@@ -2786,22 +2786,22 @@ static void restart_flicker(struct cam_data *cam)
2786 } 2786 }
2787 cam_exposure = cam->raw_image[39]*2; 2787 cam_exposure = cam->raw_image[39]*2;
2788 old_exp = cam->params.exposure.coarseExpLo + 2788 old_exp = cam->params.exposure.coarseExpLo +
2789 cam->params.exposure.coarseExpHi*256; 2789 cam->params.exposure.coarseExpHi*256;
2790 /* 2790 /*
2791 see how far away camera exposure is from a valid 2791 see how far away camera exposure is from a valid
2792 flicker exposure value 2792 flicker exposure value
2793 */ 2793 */
2794 cam_exposure %= cam->params.flickerControl.coarseJump; 2794 cam_exposure %= cam->params.flickerControl.coarseJump;
2795 if(!cam->params.flickerControl.disabled && 2795 if(!cam->params.flickerControl.disabled &&
2796 cam_exposure <= cam->params.flickerControl.coarseJump - 3) { 2796 cam_exposure <= cam->params.flickerControl.coarseJump - 3) {
2797 /* Flicker control auto-disabled */ 2797 /* Flicker control auto-disabled */
2798 cam->params.flickerControl.disabled = 1; 2798 cam->params.flickerControl.disabled = 1;
2799 } 2799 }
2800 2800
2801 if(cam->params.flickerControl.disabled && 2801 if(cam->params.flickerControl.disabled &&
2802 cam->params.flickerControl.flickerMode && 2802 cam->params.flickerControl.flickerMode &&
2803 old_exp > cam->params.flickerControl.coarseJump + 2803 old_exp > cam->params.flickerControl.coarseJump +
2804 ROUND_UP_EXP_FOR_FLICKER) { 2804 ROUND_UP_EXP_FOR_FLICKER) {
2805 /* exposure is now high enough to switch 2805 /* exposure is now high enough to switch
2806 flicker control back on */ 2806 flicker control back on */
2807 set_flicker(&cam->params, &cam->cmd_queue, 1); 2807 set_flicker(&cam->params, &cam->cmd_queue, 1);
@@ -2818,7 +2818,7 @@ static int clear_stall(struct cam_data *cam)
2818{ 2818{
2819 /* FIXME: Does this actually work? */ 2819 /* FIXME: Does this actually work? */
2820 LOG("Clearing stall\n"); 2820 LOG("Clearing stall\n");
2821 2821
2822 cam->ops->streamRead(cam->lowlevel_data, cam->raw_image, 0); 2822 cam->ops->streamRead(cam->lowlevel_data, cam->raw_image, 0);
2823 do_command(cam, CPIA_COMMAND_GetCameraStatus,0,0,0,0); 2823 do_command(cam, CPIA_COMMAND_GetCameraStatus,0,0,0,0);
2824 return cam->params.status.streamState != STREAM_PAUSED; 2824 return cam->params.status.streamState != STREAM_PAUSED;
@@ -2878,7 +2878,7 @@ static int fetch_frame(void *data)
2878 return -EINTR; 2878 return -EINTR;
2879 2879
2880 do_command(cam, CPIA_COMMAND_GetCameraStatus, 2880 do_command(cam, CPIA_COMMAND_GetCameraStatus,
2881 0, 0, 0, 0); 2881 0, 0, 0, 0);
2882 } 2882 }
2883 if(cam->params.status.streamState != STREAM_READY) { 2883 if(cam->params.status.streamState != STREAM_READY) {
2884 continue; 2884 continue;
@@ -2903,18 +2903,18 @@ static int fetch_frame(void *data)
2903 2903
2904 /* Switch flicker control back on if it got turned off */ 2904 /* Switch flicker control back on if it got turned off */
2905 restart_flicker(cam); 2905 restart_flicker(cam);
2906 2906
2907 /* If AEC is enabled, monitor the exposure and 2907 /* If AEC is enabled, monitor the exposure and
2908 adjust the sensor frame rate if needed */ 2908 adjust the sensor frame rate if needed */
2909 if(cam->params.exposure.expMode == 2) 2909 if(cam->params.exposure.expMode == 2)
2910 monitor_exposure(cam); 2910 monitor_exposure(cam);
2911 2911
2912 /* camera idle now so dispatch queued commands */ 2912 /* camera idle now so dispatch queued commands */
2913 dispatch_commands(cam); 2913 dispatch_commands(cam);
2914 2914
2915 /* Update our knowledge of the camera state */ 2915 /* Update our knowledge of the camera state */
2916 do_command(cam, CPIA_COMMAND_GetColourBalance, 0, 0, 0, 0); 2916 do_command(cam, CPIA_COMMAND_GetColourBalance, 0, 0, 0, 0);
2917 do_command(cam, CPIA_COMMAND_GetExposure, 0, 0, 0, 0); 2917 do_command(cam, CPIA_COMMAND_GetExposure, 0, 0, 0, 0);
2918 do_command(cam, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0); 2918 do_command(cam, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0);
2919 2919
2920 /* decompress and convert image to by copying it from 2920 /* decompress and convert image to by copying it from
@@ -2933,7 +2933,7 @@ static int fetch_frame(void *data)
2933 uncompressed. */ 2933 uncompressed. */
2934 cam->first_frame = 1; 2934 cam->first_frame = 1;
2935 do_command(cam, CPIA_COMMAND_SetGrabMode, 2935 do_command(cam, CPIA_COMMAND_SetGrabMode,
2936 CPIA_GRAB_SINGLE, 0, 0, 0); 2936 CPIA_GRAB_SINGLE, 0, 0, 0);
2937 /* FIXME: Trial & error - need up to 70ms for 2937 /* FIXME: Trial & error - need up to 70ms for
2938 the grab mode change to complete ? */ 2938 the grab mode change to complete ? */
2939 msleep_interruptible(70); 2939 msleep_interruptible(70);
@@ -2957,12 +2957,12 @@ static int fetch_frame(void *data)
2957 if (cam->first_frame) { 2957 if (cam->first_frame) {
2958 cam->first_frame = 0; 2958 cam->first_frame = 0;
2959 do_command(cam, CPIA_COMMAND_SetCompression, 2959 do_command(cam, CPIA_COMMAND_SetCompression,
2960 cam->params.compression.mode, 2960 cam->params.compression.mode,
2961 cam->params.compression.decimation, 0, 0); 2961 cam->params.compression.decimation, 0, 0);
2962 2962
2963 /* Switch from single-grab to continuous grab */ 2963 /* Switch from single-grab to continuous grab */
2964 do_command(cam, CPIA_COMMAND_SetGrabMode, 2964 do_command(cam, CPIA_COMMAND_SetGrabMode,
2965 CPIA_GRAB_CONTINUOUS, 0, 0, 0); 2965 CPIA_GRAB_CONTINUOUS, 0, 0, 0);
2966 } 2966 }
2967 return 0; 2967 return 0;
2968 } 2968 }
@@ -2977,12 +2977,12 @@ static int capture_frame(struct cam_data *cam, struct video_mmap *vm)
2977 if ((err = allocate_frame_buf(cam))) 2977 if ((err = allocate_frame_buf(cam)))
2978 return err; 2978 return err;
2979 } 2979 }
2980 2980
2981 cam->curframe = vm->frame; 2981 cam->curframe = vm->frame;
2982 cam->frame[cam->curframe].state = FRAME_READY; 2982 cam->frame[cam->curframe].state = FRAME_READY;
2983 return fetch_frame(cam); 2983 return fetch_frame(cam);
2984} 2984}
2985 2985
2986static int goto_high_power(struct cam_data *cam) 2986static int goto_high_power(struct cam_data *cam)
2987{ 2987{
2988 if (do_command(cam, CPIA_COMMAND_GotoHiPower, 0, 0, 0, 0)) 2988 if (do_command(cam, CPIA_COMMAND_GotoHiPower, 0, 0, 0, 0))
@@ -3039,22 +3039,22 @@ static void save_camera_state(struct cam_data *cam)
3039static int set_camera_state(struct cam_data *cam) 3039static int set_camera_state(struct cam_data *cam)
3040{ 3040{
3041 cam->cmd_queue = COMMAND_SETCOMPRESSION | 3041 cam->cmd_queue = COMMAND_SETCOMPRESSION |
3042 COMMAND_SETCOMPRESSIONTARGET | 3042 COMMAND_SETCOMPRESSIONTARGET |
3043 COMMAND_SETCOLOURPARAMS | 3043 COMMAND_SETCOLOURPARAMS |
3044 COMMAND_SETFORMAT | 3044 COMMAND_SETFORMAT |
3045 COMMAND_SETYUVTHRESH | 3045 COMMAND_SETYUVTHRESH |
3046 COMMAND_SETECPTIMING | 3046 COMMAND_SETECPTIMING |
3047 COMMAND_SETCOMPRESSIONPARAMS | 3047 COMMAND_SETCOMPRESSIONPARAMS |
3048 COMMAND_SETEXPOSURE | 3048 COMMAND_SETEXPOSURE |
3049 COMMAND_SETCOLOURBALANCE | 3049 COMMAND_SETCOLOURBALANCE |
3050 COMMAND_SETSENSORFPS | 3050 COMMAND_SETSENSORFPS |
3051 COMMAND_SETAPCOR | 3051 COMMAND_SETAPCOR |
3052 COMMAND_SETFLICKERCTRL | 3052 COMMAND_SETFLICKERCTRL |
3053 COMMAND_SETVLOFFSET; 3053 COMMAND_SETVLOFFSET;
3054 3054
3055 do_command(cam, CPIA_COMMAND_SetGrabMode, CPIA_GRAB_SINGLE,0,0,0); 3055 do_command(cam, CPIA_COMMAND_SetGrabMode, CPIA_GRAB_SINGLE,0,0,0);
3056 dispatch_commands(cam); 3056 dispatch_commands(cam);
3057 3057
3058 /* Wait 6 frames for the sensor to get all settings and 3058 /* Wait 6 frames for the sensor to get all settings and
3059 AEC/ACB to settle */ 3059 AEC/ACB to settle */
3060 msleep_interruptible(6*(cam->params.sensorFps.baserate ? 33 : 40) * 3060 msleep_interruptible(6*(cam->params.sensorFps.baserate ? 33 : 40) *
@@ -3062,7 +3062,7 @@ static int set_camera_state(struct cam_data *cam)
3062 3062
3063 if(signal_pending(current)) 3063 if(signal_pending(current))
3064 return -EINTR; 3064 return -EINTR;
3065 3065
3066 save_camera_state(cam); 3066 save_camera_state(cam);
3067 3067
3068 return 0; 3068 return 0;
@@ -3094,9 +3094,9 @@ static int reset_camera(struct cam_data *cam)
3094 if (goto_low_power(cam)) 3094 if (goto_low_power(cam))
3095 return -ENODEV; 3095 return -ENODEV;
3096 } 3096 }
3097 3097
3098 /* procedure described in developer's guide p3-28 */ 3098 /* procedure described in developer's guide p3-28 */
3099 3099
3100 /* Check the firmware version. */ 3100 /* Check the firmware version. */
3101 cam->params.version.firmwareVersion = 0; 3101 cam->params.version.firmwareVersion = 0;
3102 get_version_information(cam); 3102 get_version_information(cam);
@@ -3113,14 +3113,14 @@ static int reset_camera(struct cam_data *cam)
3113 cam->params.qx3.qx3_detected = (cam->params.pnpID.vendor == 0x0813 && 3113 cam->params.qx3.qx3_detected = (cam->params.pnpID.vendor == 0x0813 &&
3114 cam->params.pnpID.product == 0x0001); 3114 cam->params.pnpID.product == 0x0001);
3115 3115
3116 /* The fatal error checking should be done after 3116 /* The fatal error checking should be done after
3117 * the camera powers up (developer's guide p 3-38) */ 3117 * the camera powers up (developer's guide p 3-38) */
3118 3118
3119 /* Set streamState before transition to high power to avoid bug 3119 /* Set streamState before transition to high power to avoid bug
3120 * in firmware 1-02 */ 3120 * in firmware 1-02 */
3121 do_command(cam, CPIA_COMMAND_ModifyCameraStatus, STREAMSTATE, 0, 3121 do_command(cam, CPIA_COMMAND_ModifyCameraStatus, STREAMSTATE, 0,
3122 STREAM_NOT_READY, 0); 3122 STREAM_NOT_READY, 0);
3123 3123
3124 /* GotoHiPower */ 3124 /* GotoHiPower */
3125 err = goto_high_power(cam); 3125 err = goto_high_power(cam);
3126 if (err) 3126 if (err)
@@ -3142,16 +3142,16 @@ static int reset_camera(struct cam_data *cam)
3142 /* Firmware 1-02 may do this for parallel port cameras, 3142 /* Firmware 1-02 may do this for parallel port cameras,
3143 * just clear the flags (developer's guide p 3-38) */ 3143 * just clear the flags (developer's guide p 3-38) */
3144 do_command(cam, CPIA_COMMAND_ModifyCameraStatus, 3144 do_command(cam, CPIA_COMMAND_ModifyCameraStatus,
3145 FATALERROR, ~(COM_FLAG|CPIA_FLAG), 0, 0); 3145 FATALERROR, ~(COM_FLAG|CPIA_FLAG), 0, 0);
3146 } 3146 }
3147 } 3147 }
3148 3148
3149 /* Check the camera status again */ 3149 /* Check the camera status again */
3150 if (cam->params.status.fatalError) { 3150 if (cam->params.status.fatalError) {
3151 if (cam->params.status.fatalError) 3151 if (cam->params.status.fatalError)
3152 return -EIO; 3152 return -EIO;
3153 } 3153 }
3154 3154
3155 /* VPVersion can't be retrieved before the camera is in HiPower, 3155 /* VPVersion can't be retrieved before the camera is in HiPower,
3156 * so get it here instead of in get_version_information. */ 3156 * so get it here instead of in get_version_information. */
3157 do_command(cam, CPIA_COMMAND_GetVPVersion, 0, 0, 0, 0); 3157 do_command(cam, CPIA_COMMAND_GetVPVersion, 0, 0, 0, 0);
@@ -3193,24 +3193,24 @@ static int cpia_open(struct inode *inode, struct file *file)
3193 if (!cam->raw_image) 3193 if (!cam->raw_image)
3194 goto oops; 3194 goto oops;
3195 } 3195 }
3196 3196
3197 if (!cam->decompressed_frame.data) { 3197 if (!cam->decompressed_frame.data) {
3198 cam->decompressed_frame.data = rvmalloc(CPIA_MAX_FRAME_SIZE); 3198 cam->decompressed_frame.data = rvmalloc(CPIA_MAX_FRAME_SIZE);
3199 if (!cam->decompressed_frame.data) 3199 if (!cam->decompressed_frame.data)
3200 goto oops; 3200 goto oops;
3201 } 3201 }
3202 3202
3203 /* open cpia */ 3203 /* open cpia */
3204 err = -ENODEV; 3204 err = -ENODEV;
3205 if (cam->ops->open(cam->lowlevel_data)) 3205 if (cam->ops->open(cam->lowlevel_data))
3206 goto oops; 3206 goto oops;
3207 3207
3208 /* reset the camera */ 3208 /* reset the camera */
3209 if ((err = reset_camera(cam)) != 0) { 3209 if ((err = reset_camera(cam)) != 0) {
3210 cam->ops->close(cam->lowlevel_data); 3210 cam->ops->close(cam->lowlevel_data);
3211 goto oops; 3211 goto oops;
3212 } 3212 }
3213 3213
3214 err = -EINTR; 3214 err = -EINTR;
3215 if(signal_pending(current)) 3215 if(signal_pending(current))
3216 goto oops; 3216 goto oops;
@@ -3224,7 +3224,7 @@ static int cpia_open(struct inode *inode, struct file *file)
3224 3224
3225 /* init it to something */ 3225 /* init it to something */
3226 cam->mmap_kludge = 0; 3226 cam->mmap_kludge = 0;
3227 3227
3228 ++cam->open_count; 3228 ++cam->open_count;
3229 file->private_data = dev; 3229 file->private_data = dev;
3230 mutex_unlock(&cam->busy_lock); 3230 mutex_unlock(&cam->busy_lock);
@@ -3250,10 +3250,10 @@ static int cpia_close(struct inode *inode, struct file *file)
3250 struct cam_data *cam = dev->priv; 3250 struct cam_data *cam = dev->priv;
3251 3251
3252 if (cam->ops) { 3252 if (cam->ops) {
3253 /* Return ownership of /proc/cpia/videoX to root */ 3253 /* Return ownership of /proc/cpia/videoX to root */
3254 if(cam->proc_entry) 3254 if(cam->proc_entry)
3255 cam->proc_entry->uid = 0; 3255 cam->proc_entry->uid = 0;
3256 3256
3257 /* save camera state for later open (developers guide ch 3.5.3) */ 3257 /* save camera state for later open (developers guide ch 3.5.3) */
3258 save_camera_state(cam); 3258 save_camera_state(cam);
3259 3259
@@ -3342,7 +3342,7 @@ static ssize_t cpia_read(struct file *file, char __user *buf,
3342 return -EFAULT; 3342 return -EFAULT;
3343 } 3343 }
3344 if (copy_to_user(buf, cam->decompressed_frame.data, 3344 if (copy_to_user(buf, cam->decompressed_frame.data,
3345 cam->decompressed_frame.count)) { 3345 cam->decompressed_frame.count)) {
3346 DBG("copy_to_user failed\n"); 3346 DBG("copy_to_user failed\n");
3347 mutex_unlock(&cam->busy_lock); 3347 mutex_unlock(&cam->busy_lock);
3348 return -EFAULT; 3348 return -EFAULT;
@@ -3361,7 +3361,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3361 3361
3362 if (!cam || !cam->ops) 3362 if (!cam || !cam->ops)
3363 return -ENODEV; 3363 return -ENODEV;
3364 3364
3365 /* make this _really_ smp-safe */ 3365 /* make this _really_ smp-safe */
3366 if (mutex_lock_interruptible(&cam->busy_lock)) 3366 if (mutex_lock_interruptible(&cam->busy_lock))
3367 return -EINTR; 3367 return -EINTR;
@@ -3405,7 +3405,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3405 v->norm = 0; 3405 v->norm = 0;
3406 break; 3406 break;
3407 } 3407 }
3408 3408
3409 case VIDIOCSCHAN: 3409 case VIDIOCSCHAN:
3410 { 3410 {
3411 struct video_channel *v = arg; 3411 struct video_channel *v = arg;
@@ -3424,7 +3424,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3424 *pic = cam->vp; 3424 *pic = cam->vp;
3425 break; 3425 break;
3426 } 3426 }
3427 3427
3428 case VIDIOCSPICT: 3428 case VIDIOCSPICT:
3429 { 3429 {
3430 struct video_picture *vp = arg; 3430 struct video_picture *vp = arg;
@@ -3458,11 +3458,11 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3458 3458
3459 /* Adjust flicker control if necessary */ 3459 /* Adjust flicker control if necessary */
3460 if(cam->params.flickerControl.allowableOverExposure < 0) 3460 if(cam->params.flickerControl.allowableOverExposure < 0)
3461 cam->params.flickerControl.allowableOverExposure = 3461 cam->params.flickerControl.allowableOverExposure =
3462 -find_over_exposure(cam->params.colourParams.brightness); 3462 -find_over_exposure(cam->params.colourParams.brightness);
3463 if(cam->params.flickerControl.flickerMode != 0) 3463 if(cam->params.flickerControl.flickerMode != 0)
3464 cam->cmd_queue |= COMMAND_SETFLICKERCTRL; 3464 cam->cmd_queue |= COMMAND_SETFLICKERCTRL;
3465 3465
3466 3466
3467 /* queue command to update camera */ 3467 /* queue command to update camera */
3468 cam->cmd_queue |= COMMAND_SETCOLOURPARAMS; 3468 cam->cmd_queue |= COMMAND_SETCOLOURPARAMS;
@@ -3482,7 +3482,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3482 *vw = cam->vw; 3482 *vw = cam->vw;
3483 break; 3483 break;
3484 } 3484 }
3485 3485
3486 case VIDIOCSWIN: 3486 case VIDIOCSWIN:
3487 { 3487 {
3488 /* copy_from_user, check validity, copy to internal structure */ 3488 /* copy_from_user, check validity, copy to internal structure */
@@ -3514,7 +3514,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3514 3514
3515 /* video size is changing, reset the subcapture area */ 3515 /* video size is changing, reset the subcapture area */
3516 memset(&cam->vc, 0, sizeof(cam->vc)); 3516 memset(&cam->vc, 0, sizeof(cam->vc));
3517 3517
3518 set_vw_size(cam); 3518 set_vw_size(cam);
3519 DBG("%d / %d\n", cam->vw.width, cam->vw.height); 3519 DBG("%d / %d\n", cam->vw.width, cam->vw.height);
3520 cam->cmd_queue |= COMMAND_SETFORMAT; 3520 cam->cmd_queue |= COMMAND_SETFORMAT;
@@ -3547,7 +3547,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3547 vm->offsets[i] = CPIA_MAX_FRAME_SIZE * i; 3547 vm->offsets[i] = CPIA_MAX_FRAME_SIZE * i;
3548 break; 3548 break;
3549 } 3549 }
3550 3550
3551 case VIDIOCMCAPTURE: 3551 case VIDIOCMCAPTURE:
3552 { 3552 {
3553 struct video_mmap *vm = arg; 3553 struct video_mmap *vm = arg;
@@ -3597,7 +3597,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3597 3597
3598 /* video size is changing, reset the subcapture area */ 3598 /* video size is changing, reset the subcapture area */
3599 memset(&cam->vc, 0, sizeof(cam->vc)); 3599 memset(&cam->vc, 0, sizeof(cam->vc));
3600 3600
3601 set_vw_size(cam); 3601 set_vw_size(cam);
3602 cam->cmd_queue |= COMMAND_SETFORMAT; 3602 cam->cmd_queue |= COMMAND_SETFORMAT;
3603 dispatch_commands(cam); 3603 dispatch_commands(cam);
@@ -3608,7 +3608,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3608 3608
3609 break; 3609 break;
3610 } 3610 }
3611 3611
3612 case VIDIOCSYNC: 3612 case VIDIOCSYNC:
3613 { 3613 {
3614 int *frame = arg; 3614 int *frame = arg;
@@ -3649,7 +3649,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3649 *vc = cam->vc; 3649 *vc = cam->vc;
3650 3650
3651 break; 3651 break;
3652 } 3652 }
3653 3653
3654 case VIDIOCSCAPTURE: 3654 case VIDIOCSCAPTURE:
3655 { 3655 {
@@ -3665,7 +3665,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3665 retval = -EINVAL; 3665 retval = -EINVAL;
3666 break; 3666 break;
3667 } 3667 }
3668 3668
3669 /* Clip to the resolution we can set for the ROI 3669 /* Clip to the resolution we can set for the ROI
3670 (every 8 columns and 4 rows) */ 3670 (every 8 columns and 4 rows) */
3671 vc->x = vc->x & ~(__u32)7; 3671 vc->x = vc->x & ~(__u32)7;
@@ -3681,14 +3681,14 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3681 } 3681 }
3682 3682
3683 DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height); 3683 DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height);
3684 3684
3685 mutex_lock(&cam->param_lock); 3685 mutex_lock(&cam->param_lock);
3686 3686
3687 cam->vc.x = vc->x; 3687 cam->vc.x = vc->x;
3688 cam->vc.y = vc->y; 3688 cam->vc.y = vc->y;
3689 cam->vc.width = vc->width; 3689 cam->vc.width = vc->width;
3690 cam->vc.height = vc->height; 3690 cam->vc.height = vc->height;
3691 3691
3692 set_vw_size(cam); 3692 set_vw_size(cam);
3693 cam->cmd_queue |= COMMAND_SETFORMAT; 3693 cam->cmd_queue |= COMMAND_SETFORMAT;
3694 3694
@@ -3699,7 +3699,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3699 dispatch_commands(cam); 3699 dispatch_commands(cam);
3700 break; 3700 break;
3701 } 3701 }
3702 3702
3703 case VIDIOCGUNIT: 3703 case VIDIOCGUNIT:
3704 { 3704 {
3705 struct video_unit *vu = arg; 3705 struct video_unit *vu = arg;
@@ -3715,7 +3715,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3715 break; 3715 break;
3716 } 3716 }
3717 3717
3718 3718
3719 /* pointless to implement overlay with this camera */ 3719 /* pointless to implement overlay with this camera */
3720 case VIDIOCCAPTURE: 3720 case VIDIOCCAPTURE:
3721 case VIDIOCGFBUF: 3721 case VIDIOCGFBUF:
@@ -3738,7 +3738,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3738 3738
3739 mutex_unlock(&cam->busy_lock); 3739 mutex_unlock(&cam->busy_lock);
3740 return retval; 3740 return retval;
3741} 3741}
3742 3742
3743static int cpia_ioctl(struct inode *inode, struct file *file, 3743static int cpia_ioctl(struct inode *inode, struct file *file,
3744 unsigned int cmd, unsigned long arg) 3744 unsigned int cmd, unsigned long arg)
@@ -3759,7 +3759,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
3759 3759
3760 if (!cam || !cam->ops) 3760 if (!cam || !cam->ops)
3761 return -ENODEV; 3761 return -ENODEV;
3762 3762
3763 DBG("cpia_mmap: %ld\n", size); 3763 DBG("cpia_mmap: %ld\n", size);
3764 3764
3765 if (size > FRAME_NUM*CPIA_MAX_FRAME_SIZE) 3765 if (size > FRAME_NUM*CPIA_MAX_FRAME_SIZE)
@@ -3767,7 +3767,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
3767 3767
3768 if (!cam || !cam->ops) 3768 if (!cam || !cam->ops)
3769 return -ENODEV; 3769 return -ENODEV;
3770 3770
3771 /* make this _really_ smp-safe */ 3771 /* make this _really_ smp-safe */
3772 if (mutex_lock_interruptible(&cam->busy_lock)) 3772 if (mutex_lock_interruptible(&cam->busy_lock))
3773 return -EINTR; 3773 return -EINTR;
@@ -3851,11 +3851,11 @@ static void reset_camera_struct(struct cam_data *cam)
3851 cam->params.flickerControl.flickerMode = 0; 3851 cam->params.flickerControl.flickerMode = 0;
3852 cam->params.flickerControl.disabled = 1; 3852 cam->params.flickerControl.disabled = 1;
3853 3853
3854 cam->params.flickerControl.coarseJump = 3854 cam->params.flickerControl.coarseJump =
3855 flicker_jumps[cam->mainsFreq] 3855 flicker_jumps[cam->mainsFreq]
3856 [cam->params.sensorFps.baserate] 3856 [cam->params.sensorFps.baserate]
3857 [cam->params.sensorFps.divisor]; 3857 [cam->params.sensorFps.divisor];
3858 cam->params.flickerControl.allowableOverExposure = 3858 cam->params.flickerControl.allowableOverExposure =
3859 -find_over_exposure(cam->params.colourParams.brightness); 3859 -find_over_exposure(cam->params.colourParams.brightness);
3860 cam->params.vlOffset.gain1 = 20; 3860 cam->params.vlOffset.gain1 = 20;
3861 cam->params.vlOffset.gain2 = 24; 3861 cam->params.vlOffset.gain2 = 24;
@@ -3870,21 +3870,21 @@ static void reset_camera_struct(struct cam_data *cam)
3870 cam->params.compressionParams.qDiffStepThresh = 3; 3870 cam->params.compressionParams.qDiffStepThresh = 3;
3871 cam->params.compressionParams.decimationThreshMod = 2; 3871 cam->params.compressionParams.decimationThreshMod = 2;
3872 /* End of default values from Software Developer's Guide */ 3872 /* End of default values from Software Developer's Guide */
3873 3873
3874 cam->transfer_rate = 0; 3874 cam->transfer_rate = 0;
3875 cam->exposure_status = EXPOSURE_NORMAL; 3875 cam->exposure_status = EXPOSURE_NORMAL;
3876 3876
3877 /* Set Sensor FPS to 15fps. This seems better than 30fps 3877 /* Set Sensor FPS to 15fps. This seems better than 30fps
3878 * for indoor lighting. */ 3878 * for indoor lighting. */
3879 cam->params.sensorFps.divisor = 1; 3879 cam->params.sensorFps.divisor = 1;
3880 cam->params.sensorFps.baserate = 1; 3880 cam->params.sensorFps.baserate = 1;
3881 3881
3882 cam->params.yuvThreshold.yThreshold = 6; /* From windows driver */ 3882 cam->params.yuvThreshold.yThreshold = 6; /* From windows driver */
3883 cam->params.yuvThreshold.uvThreshold = 6; /* From windows driver */ 3883 cam->params.yuvThreshold.uvThreshold = 6; /* From windows driver */
3884 3884
3885 cam->params.format.subSample = SUBSAMPLE_422; 3885 cam->params.format.subSample = SUBSAMPLE_422;
3886 cam->params.format.yuvOrder = YUVORDER_YUYV; 3886 cam->params.format.yuvOrder = YUVORDER_YUYV;
3887 3887
3888 cam->params.compression.mode = CPIA_COMPRESSION_AUTO; 3888 cam->params.compression.mode = CPIA_COMPRESSION_AUTO;
3889 cam->params.compressionTarget.frTargeting = 3889 cam->params.compressionTarget.frTargeting =
3890 CPIA_COMPRESSION_TARGET_QUALITY; 3890 CPIA_COMPRESSION_TARGET_QUALITY;
@@ -3898,7 +3898,7 @@ static void reset_camera_struct(struct cam_data *cam)
3898 cam->params.qx3.cradled = 0; 3898 cam->params.qx3.cradled = 0;
3899 3899
3900 cam->video_size = VIDEOSIZE_CIF; 3900 cam->video_size = VIDEOSIZE_CIF;
3901 3901
3902 cam->vp.colour = 32768; /* 50% */ 3902 cam->vp.colour = 32768; /* 50% */
3903 cam->vp.hue = 32768; /* 50% */ 3903 cam->vp.hue = 32768; /* 50% */
3904 cam->vp.brightness = 32768; /* 50% */ 3904 cam->vp.brightness = 32768; /* 50% */
@@ -3911,7 +3911,7 @@ static void reset_camera_struct(struct cam_data *cam)
3911 cam->vc.y = 0; 3911 cam->vc.y = 0;
3912 cam->vc.width = 0; 3912 cam->vc.width = 0;
3913 cam->vc.height = 0; 3913 cam->vc.height = 0;
3914 3914
3915 cam->vw.x = 0; 3915 cam->vw.x = 0;
3916 cam->vw.y = 0; 3916 cam->vw.y = 0;
3917 set_vw_size(cam); 3917 set_vw_size(cam);
@@ -3928,7 +3928,7 @@ static void reset_camera_struct(struct cam_data *cam)
3928 3928
3929/* initialize cam_data structure */ 3929/* initialize cam_data structure */
3930static void init_camera_struct(struct cam_data *cam, 3930static void init_camera_struct(struct cam_data *cam,
3931 struct cpia_camera_ops *ops ) 3931 struct cpia_camera_ops *ops )
3932{ 3932{
3933 int i; 3933 int i;
3934 3934
@@ -3945,7 +3945,7 @@ static void init_camera_struct(struct cam_data *cam,
3945 3945
3946 memcpy(&cam->vdev, &cpia_template, sizeof(cpia_template)); 3946 memcpy(&cam->vdev, &cpia_template, sizeof(cpia_template));
3947 cam->vdev.priv = cam; 3947 cam->vdev.priv = cam;
3948 3948
3949 cam->curframe = 0; 3949 cam->curframe = 0;
3950 for (i = 0; i < FRAME_NUM; i++) { 3950 for (i = 0; i < FRAME_NUM; i++) {
3951 cam->frame[i].width = 0; 3951 cam->frame[i].width = 0;
@@ -3961,15 +3961,15 @@ static void init_camera_struct(struct cam_data *cam,
3961 3961
3962struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowlevel) 3962struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowlevel)
3963{ 3963{
3964 struct cam_data *camera; 3964 struct cam_data *camera;
3965 3965
3966 if ((camera = kmalloc(sizeof(struct cam_data), GFP_KERNEL)) == NULL) 3966 if ((camera = kmalloc(sizeof(struct cam_data), GFP_KERNEL)) == NULL)
3967 return NULL; 3967 return NULL;
3968 3968
3969 3969
3970 init_camera_struct( camera, ops ); 3970 init_camera_struct( camera, ops );
3971 camera->lowlevel_data = lowlevel; 3971 camera->lowlevel_data = lowlevel;
3972 3972
3973 /* register v4l device */ 3973 /* register v4l device */
3974 if (video_register_device(&camera->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { 3974 if (video_register_device(&camera->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
3975 kfree(camera); 3975 kfree(camera);
@@ -3982,7 +3982,7 @@ struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowleve
3982 /* open cpia */ 3982 /* open cpia */
3983 if (camera->ops->open(camera->lowlevel_data)) 3983 if (camera->ops->open(camera->lowlevel_data))
3984 return camera; 3984 return camera;
3985 3985
3986 /* reset the camera */ 3986 /* reset the camera */
3987 if (reset_camera(camera) != 0) { 3987 if (reset_camera(camera) != 0) {
3988 camera->ops->close(camera->lowlevel_data); 3988 camera->ops->close(camera->lowlevel_data);
@@ -4022,11 +4022,11 @@ void cpia_unregister_camera(struct cam_data *cam)
4022 DBG("camera open -- setting ops to NULL\n"); 4022 DBG("camera open -- setting ops to NULL\n");
4023 cam->ops = NULL; 4023 cam->ops = NULL;
4024 } 4024 }
4025 4025
4026#ifdef CONFIG_PROC_FS 4026#ifdef CONFIG_PROC_FS
4027 DBG("destroying /proc/cpia/video%d\n", cam->vdev.minor); 4027 DBG("destroying /proc/cpia/video%d\n", cam->vdev.minor);
4028 destroy_proc_cpia_cam(cam); 4028 destroy_proc_cpia_cam(cam);
4029#endif 4029#endif
4030 if (!cam->open_count) { 4030 if (!cam->open_count) {
4031 DBG("freeing camera\n"); 4031 DBG("freeing camera\n");
4032 kfree(cam); 4032 kfree(cam);
diff --git a/drivers/media/video/cpia.h b/drivers/media/video/cpia.h
index de6678200a57..dde27a6a4a09 100644
--- a/drivers/media/video/cpia.h
+++ b/drivers/media/video/cpia.h
@@ -52,10 +52,10 @@
52struct cpia_camera_ops 52struct cpia_camera_ops
53{ 53{
54 /* open sets privdata to point to structure for this camera. 54 /* open sets privdata to point to structure for this camera.
55 * Returns negative value on error, otherwise 0. 55 * Returns negative value on error, otherwise 0.
56 */ 56 */
57 int (*open)(void *privdata); 57 int (*open)(void *privdata);
58 58
59 /* Registers callback function cb to be called with cbdata 59 /* Registers callback function cb to be called with cbdata
60 * when an image is ready. If cb is NULL, only single image grabs 60 * when an image is ready. If cb is NULL, only single image grabs
61 * should be used. cb should immediately call streamRead to read 61 * should be used. cb should immediately call streamRead to read
@@ -63,8 +63,8 @@ struct cpia_camera_ops
63 * otherwise 0. 63 * otherwise 0.
64 */ 64 */
65 int (*registerCallback)(void *privdata, void (*cb)(void *cbdata), 65 int (*registerCallback)(void *privdata, void (*cb)(void *cbdata),
66 void *cbdata); 66 void *cbdata);
67 67
68 /* transferCmd sends commands to the camera. command MUST point to 68 /* transferCmd sends commands to the camera. command MUST point to
69 * an 8 byte buffer in kernel space. data can be NULL if no extra 69 * an 8 byte buffer in kernel space. data can be NULL if no extra
70 * data is needed. The size of the data is given by the last 2 70 * data is needed. The size of the data is given by the last 2
@@ -77,30 +77,30 @@ struct cpia_camera_ops
77 * Returns negative value on error, otherwise 0. 77 * Returns negative value on error, otherwise 0.
78 */ 78 */
79 int (*streamStart)(void *privdata); 79 int (*streamStart)(void *privdata);
80 80
81 /* streamStop terminates stream capture mode. 81 /* streamStop terminates stream capture mode.
82 * Returns negative value on error, otherwise 0. 82 * Returns negative value on error, otherwise 0.
83 */ 83 */
84 int (*streamStop)(void *privdata); 84 int (*streamStop)(void *privdata);
85 85
86 /* streamRead reads a frame from the camera. buffer points to a 86 /* streamRead reads a frame from the camera. buffer points to a
87 * buffer large enough to hold a complete frame in kernel space. 87 * buffer large enough to hold a complete frame in kernel space.
88 * noblock indicates if this should be a non blocking read. 88 * noblock indicates if this should be a non blocking read.
89 * Returns the number of bytes read, or negative value on error. 89 * Returns the number of bytes read, or negative value on error.
90 */ 90 */
91 int (*streamRead)(void *privdata, u8 *buffer, int noblock); 91 int (*streamRead)(void *privdata, u8 *buffer, int noblock);
92 92
93 /* close disables the device until open() is called again. 93 /* close disables the device until open() is called again.
94 * Returns negative value on error, otherwise 0. 94 * Returns negative value on error, otherwise 0.
95 */ 95 */
96 int (*close)(void *privdata); 96 int (*close)(void *privdata);
97 97
98 /* If wait_for_stream_ready is non-zero, wait until the streamState 98 /* If wait_for_stream_ready is non-zero, wait until the streamState
99 * is STREAM_READY before calling streamRead. 99 * is STREAM_READY before calling streamRead.
100 */ 100 */
101 int wait_for_stream_ready; 101 int wait_for_stream_ready;
102 102
103 /* 103 /*
104 * Used to maintain lowlevel module usage counts 104 * Used to maintain lowlevel module usage counts
105 */ 105 */
106 struct module *owner; 106 struct module *owner;
@@ -215,14 +215,14 @@ struct cam_params {
215 u8 videoSize; /* CIF/QCIF */ 215 u8 videoSize; /* CIF/QCIF */
216 u8 subSample; 216 u8 subSample;
217 u8 yuvOrder; 217 u8 yuvOrder;
218 } format; 218 } format;
219 struct { /* Intel QX3 specific data */ 219 struct { /* Intel QX3 specific data */
220 u8 qx3_detected; /* a QX3 is present */ 220 u8 qx3_detected; /* a QX3 is present */
221 u8 toplight; /* top light lit , R/W */ 221 u8 toplight; /* top light lit , R/W */
222 u8 bottomlight; /* bottom light lit, R/W */ 222 u8 bottomlight; /* bottom light lit, R/W */
223 u8 button; /* snapshot button pressed (R/O) */ 223 u8 button; /* snapshot button pressed (R/O) */
224 u8 cradled; /* microscope is in cradle (R/O) */ 224 u8 cradled; /* microscope is in cradle (R/O) */
225 } qx3; 225 } qx3;
226 struct { 226 struct {
227 u8 colStart; /* skip first 8*colStart pixels */ 227 u8 colStart; /* skip first 8*colStart pixels */
228 u8 colEnd; /* finish at 8*colEnd pixels */ 228 u8 colEnd; /* finish at 8*colEnd pixels */
@@ -247,13 +247,13 @@ enum v4l_camstates {
247struct cam_data { 247struct cam_data {
248 struct list_head cam_data_list; 248 struct list_head cam_data_list;
249 249
250 struct mutex busy_lock; /* guard against SMP multithreading */ 250 struct mutex busy_lock; /* guard against SMP multithreading */
251 struct cpia_camera_ops *ops; /* lowlevel driver operations */ 251 struct cpia_camera_ops *ops; /* lowlevel driver operations */
252 void *lowlevel_data; /* private data for lowlevel driver */ 252 void *lowlevel_data; /* private data for lowlevel driver */
253 u8 *raw_image; /* buffer for raw image data */ 253 u8 *raw_image; /* buffer for raw image data */
254 struct cpia_frame decompressed_frame; 254 struct cpia_frame decompressed_frame;
255 /* buffer to hold decompressed frame */ 255 /* buffer to hold decompressed frame */
256 int image_size; /* sizeof last decompressed image */ 256 int image_size; /* sizeof last decompressed image */
257 int open_count; /* # of process that have camera open */ 257 int open_count; /* # of process that have camera open */
258 258
259 /* camera status */ 259 /* camera status */
@@ -265,7 +265,7 @@ struct cam_data {
265 struct mutex param_lock; /* params lock for this camera */ 265 struct mutex param_lock; /* params lock for this camera */
266 struct cam_params params; /* camera settings */ 266 struct cam_params params; /* camera settings */
267 struct proc_dir_entry *proc_entry; /* /proc/cpia/videoX */ 267 struct proc_dir_entry *proc_entry; /* /proc/cpia/videoX */
268 268
269 /* v4l */ 269 /* v4l */
270 int video_size; /* VIDEO_SIZE_ */ 270 int video_size; /* VIDEO_SIZE_ */
271 volatile enum v4l_camstates camstate; /* v4l layer status */ 271 volatile enum v4l_camstates camstate; /* v4l layer status */
@@ -277,7 +277,7 @@ struct cam_data {
277 /* mmap interface */ 277 /* mmap interface */
278 int curframe; /* the current frame to grab into */ 278 int curframe; /* the current frame to grab into */
279 u8 *frame_buf; /* frame buffer data */ 279 u8 *frame_buf; /* frame buffer data */
280 struct cpia_frame frame[FRAME_NUM]; 280 struct cpia_frame frame[FRAME_NUM];
281 /* FRAME_NUM-buffering, so we need a array */ 281 /* FRAME_NUM-buffering, so we need a array */
282 282
283 int first_frame; 283 int first_frame;
@@ -424,7 +424,7 @@ void cpia_unregister_camera(struct cam_data *cam);
424#define DEB_BYTE(p)\ 424#define DEB_BYTE(p)\
425 DBG("%1d %1d %1d %1d %1d %1d %1d %1d \n",\ 425 DBG("%1d %1d %1d %1d %1d %1d %1d %1d \n",\
426 (p)&0x80?1:0, (p)&0x40?1:0, (p)&0x20?1:0, (p)&0x10?1:0,\ 426 (p)&0x80?1:0, (p)&0x40?1:0, (p)&0x20?1:0, (p)&0x10?1:0,\
427 (p)&0x08?1:0, (p)&0x04?1:0, (p)&0x02?1:0, (p)&0x01?1:0); 427 (p)&0x08?1:0, (p)&0x04?1:0, (p)&0x02?1:0, (p)&0x01?1:0);
428 428
429#endif /* __KERNEL__ */ 429#endif /* __KERNEL__ */
430 430
diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c
index 74cff626e044..3021f21aae36 100644
--- a/drivers/media/video/cpia_pp.c
+++ b/drivers/media/video/cpia_pp.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ 25/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
26/* #define _CPIA_DEBUG_ 1 */ 26/* #define _CPIA_DEBUG_ 1 */
27 27
28#include <linux/config.h> 28#include <linux/config.h>
29 29
@@ -45,7 +45,7 @@
45 45
46static int cpia_pp_open(void *privdata); 46static int cpia_pp_open(void *privdata);
47static int cpia_pp_registerCallback(void *privdata, void (*cb) (void *cbdata), 47static int cpia_pp_registerCallback(void *privdata, void (*cb) (void *cbdata),
48 void *cbdata); 48 void *cbdata);
49static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data); 49static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data);
50static int cpia_pp_streamStart(void *privdata); 50static int cpia_pp_streamStart(void *privdata);
51static int cpia_pp_streamStop(void *privdata); 51static int cpia_pp_streamStop(void *privdata);
@@ -93,7 +93,7 @@ struct pp_cam_entry {
93 int stream_irq; 93 int stream_irq;
94}; 94};
95 95
96static struct cpia_camera_ops cpia_pp_ops = 96static struct cpia_camera_ops cpia_pp_ops =
97{ 97{
98 cpia_pp_open, 98 cpia_pp_open,
99 cpia_pp_registerCallback, 99 cpia_pp_registerCallback,
@@ -123,7 +123,7 @@ static void cpia_parport_disable_irq( struct parport *port ) {
123} 123}
124 124
125/* Special CPiA PPC modes: These are invoked by using the 1284 Extensibility 125/* Special CPiA PPC modes: These are invoked by using the 1284 Extensibility
126 * Link Flag during negotiation */ 126 * Link Flag during negotiation */
127#define UPLOAD_FLAG 0x08 127#define UPLOAD_FLAG 0x08
128#define NIBBLE_TRANSFER 0x01 128#define NIBBLE_TRANSFER 0x01
129#define ECP_TRANSFER 0x03 129#define ECP_TRANSFER 0x03
@@ -139,17 +139,17 @@ static void cpia_parport_disable_irq( struct parport *port ) {
139/* CPiA nonstandard "Nibble" mode (no nDataAvail signal after each byte). */ 139/* CPiA nonstandard "Nibble" mode (no nDataAvail signal after each byte). */
140/* The standard kernel parport_ieee1284_read_nibble() fails with the CPiA... */ 140/* The standard kernel parport_ieee1284_read_nibble() fails with the CPiA... */
141 141
142static size_t cpia_read_nibble (struct parport *port, 142static size_t cpia_read_nibble (struct parport *port,
143 void *buffer, size_t len, 143 void *buffer, size_t len,
144 int flags) 144 int flags)
145{ 145{
146 /* adapted verbatim, with one change, from 146 /* adapted verbatim, with one change, from
147 parport_ieee1284_read_nibble() in drivers/parport/ieee1284-ops.c */ 147 parport_ieee1284_read_nibble() in drivers/parport/ieee1284-ops.c */
148 148
149 unsigned char *buf = buffer; 149 unsigned char *buf = buffer;
150 int i; 150 int i;
151 unsigned char byte = 0; 151 unsigned char byte = 0;
152 152
153 len *= 2; /* in nibbles */ 153 len *= 2; /* in nibbles */
154 for (i=0; i < len; i++) { 154 for (i=0; i < len; i++) {
155 unsigned char nibble; 155 unsigned char nibble;
@@ -158,12 +158,12 @@ static size_t cpia_read_nibble (struct parport *port,
158 * after every second nibble to signal that more 158 * after every second nibble to signal that more
159 * data is available. (the total number of Bytes that 159 * data is available. (the total number of Bytes that
160 * should be sent is known; if too few are received, an error 160 * should be sent is known; if too few are received, an error
161 * will be recorded after a timeout). 161 * will be recorded after a timeout).
162 * This is incompatible with parport_ieee1284_read_nibble(), 162 * This is incompatible with parport_ieee1284_read_nibble(),
163 * which expects to find nFault LO after every second nibble. 163 * which expects to find nFault LO after every second nibble.
164 */ 164 */
165 165
166 /* Solution: modify cpia_read_nibble to only check for 166 /* Solution: modify cpia_read_nibble to only check for
167 * nDataAvail before the first nibble is sent. 167 * nDataAvail before the first nibble is sent.
168 */ 168 */
169 169
@@ -216,7 +216,7 @@ static size_t cpia_read_nibble (struct parport *port,
216 /* Second nibble */ 216 /* Second nibble */
217 byte |= nibble << 4; 217 byte |= nibble << 4;
218 *buf++ = byte; 218 *buf++ = byte;
219 } else 219 } else
220 byte = nibble; 220 byte = nibble;
221 } 221 }
222 222
@@ -238,18 +238,18 @@ static size_t cpia_read_nibble (struct parport *port,
238} 238}
239 239
240/* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1) 240/* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1)
241 * (See CPiA Data sheet p. 31) 241 * (See CPiA Data sheet p. 31)
242 * 242 *
243 * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a 243 * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a
244 * nonstandard variant of nibble mode which allows the same (mediocre) 244 * nonstandard variant of nibble mode which allows the same (mediocre)
245 * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable 245 * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable
246 * parallel ports, but works also for non-TRISTATE-capable ports. 246 * parallel ports, but works also for non-TRISTATE-capable ports.
247 * (Standard nibble mode only send 4 bits per cycle) 247 * (Standard nibble mode only send 4 bits per cycle)
248 * 248 *
249 */ 249 */
250 250
251static size_t cpia_read_nibble_stream(struct parport *port, 251static size_t cpia_read_nibble_stream(struct parport *port,
252 void *buffer, size_t len, 252 void *buffer, size_t len,
253 int flags) 253 int flags)
254{ 254{
255 int i; 255 int i;
@@ -260,7 +260,7 @@ static size_t cpia_read_nibble_stream(struct parport *port,
260 unsigned char nibble[2], byte = 0; 260 unsigned char nibble[2], byte = 0;
261 int j; 261 int j;
262 262
263 /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */ 263 /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */
264 if (endseen > 3 ) 264 if (endseen > 3 )
265 break; 265 break;
266 266
@@ -268,7 +268,7 @@ static size_t cpia_read_nibble_stream(struct parport *port,
268 parport_frob_control (port, 268 parport_frob_control (port,
269 PARPORT_CONTROL_AUTOFD, 269 PARPORT_CONTROL_AUTOFD,
270 PARPORT_CONTROL_AUTOFD); 270 PARPORT_CONTROL_AUTOFD);
271 271
272 /* Event 9: nAck goes low. */ 272 /* Event 9: nAck goes low. */
273 port->ieee1284.phase = IEEE1284_PH_REV_DATA; 273 port->ieee1284.phase = IEEE1284_PH_REV_DATA;
274 if (parport_wait_peripheral (port, 274 if (parport_wait_peripheral (port,
@@ -282,7 +282,7 @@ static size_t cpia_read_nibble_stream(struct parport *port,
282 282
283 /* Read lower nibble */ 283 /* Read lower nibble */
284 nibble[0] = parport_read_status (port) >>3; 284 nibble[0] = parport_read_status (port) >>3;
285 285
286 /* Event 10: Set nAutoFd high. */ 286 /* Event 10: Set nAutoFd high. */
287 parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0); 287 parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0);
288 288
@@ -295,10 +295,10 @@ static size_t cpia_read_nibble_stream(struct parport *port,
295 port->name); 295 port->name);
296 break; 296 break;
297 } 297 }
298 298
299 /* Read upper nibble */ 299 /* Read upper nibble */
300 nibble[1] = parport_read_status (port) >>3; 300 nibble[1] = parport_read_status (port) >>3;
301 301
302 /* reassemble the byte */ 302 /* reassemble the byte */
303 for (j = 0; j < 2 ; j++ ) { 303 for (j = 0; j < 2 ; j++ ) {
304 nibble[j] &= ~8; 304 nibble[j] &= ~8;
@@ -335,8 +335,8 @@ static void EndTransferMode(struct pp_cam_entry *cam)
335static int ForwardSetup(struct pp_cam_entry *cam) 335static int ForwardSetup(struct pp_cam_entry *cam)
336{ 336{
337 int retry; 337 int retry;
338 338
339 /* The CPiA uses ECP protocol for Downloads from the Host to the camera. 339 /* The CPiA uses ECP protocol for Downloads from the Host to the camera.
340 * This will be software-emulated if ECP hardware is not present 340 * This will be software-emulated if ECP hardware is not present
341 */ 341 */
342 342
@@ -375,9 +375,9 @@ static int ReverseSetup(struct pp_cam_entry *cam, int extensibility)
375 upload_mode = mode; 375 upload_mode = mode;
376 if(extensibility) mode = UPLOAD_FLAG|transfer_mode|IEEE1284_EXT_LINK; 376 if(extensibility) mode = UPLOAD_FLAG|transfer_mode|IEEE1284_EXT_LINK;
377 377
378 /* the usual camera maximum response time is 10ms, but after 378 /* the usual camera maximum response time is 10ms, but after
379 * receiving some commands, it needs up to 40ms. */ 379 * receiving some commands, it needs up to 40ms. */
380 380
381 for(retry = 0; retry < 4; ++retry) { 381 for(retry = 0; retry < 4; ++retry) {
382 if(!parport_negotiate(cam->port, mode)) { 382 if(!parport_negotiate(cam->port, mode)) {
383 break; 383 break;
@@ -439,10 +439,10 @@ static int ReadPacket(struct pp_cam_entry *cam, u8 *packet, size_t size)
439 439
440 /* support for CPiA variant nibble reads */ 440 /* support for CPiA variant nibble reads */
441 if(cam->port->ieee1284.mode == IEEE1284_MODE_NIBBLE) { 441 if(cam->port->ieee1284.mode == IEEE1284_MODE_NIBBLE) {
442 if(cpia_read_nibble(cam->port, packet, size, 0) != size) 442 if(cpia_read_nibble(cam->port, packet, size, 0) != size)
443 retval = -EIO; 443 retval = -EIO;
444 } else { 444 } else {
445 if(parport_read(cam->port, packet, size) != size) 445 if(parport_read(cam->port, packet, size) != size)
446 retval = -EIO; 446 retval = -EIO;
447 } 447 }
448 EndTransferMode(cam); 448 EndTransferMode(cam);
@@ -542,18 +542,18 @@ static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock)
542 block_size = PARPORT_CHUNK_SIZE; 542 block_size = PARPORT_CHUNK_SIZE;
543 while( !cam->image_complete ) { 543 while( !cam->image_complete ) {
544 cond_resched(); 544 cond_resched();
545 545
546 new_bytes = cpia_pp_read(cam->port, buffer, block_size ); 546 new_bytes = cpia_pp_read(cam->port, buffer, block_size );
547 if( new_bytes <= 0 ) { 547 if( new_bytes <= 0 ) {
548 break; 548 break;
549 } 549 }
550 i=-1; 550 i=-1;
551 while(++i<new_bytes && endseen<4) { 551 while(++i<new_bytes && endseen<4) {
552 if(*buffer==EOI) { 552 if(*buffer==EOI) {
553 endseen++; 553 endseen++;
554 } else { 554 } else {
555 endseen=0; 555 endseen=0;
556 } 556 }
557 buffer++; 557 buffer++;
558 } 558 }
559 read_bytes += i; 559 read_bytes += i;
@@ -601,7 +601,7 @@ static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data)
601 } 601 }
602 if((err = ReadPacket(cam, buffer, 8)) < 0) { 602 if((err = ReadPacket(cam, buffer, 8)) < 0) {
603 DBG("Error reading command result\n"); 603 DBG("Error reading command result\n");
604 return err; 604 return err;
605 } 605 }
606 memcpy(data, buffer, databytes); 606 memcpy(data, buffer, databytes);
607 } else if(command[0] == DATA_OUT) { 607 } else if(command[0] == DATA_OUT) {
@@ -631,10 +631,10 @@ static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data)
631static int cpia_pp_open(void *privdata) 631static int cpia_pp_open(void *privdata)
632{ 632{
633 struct pp_cam_entry *cam = (struct pp_cam_entry *)privdata; 633 struct pp_cam_entry *cam = (struct pp_cam_entry *)privdata;
634 634
635 if (cam == NULL) 635 if (cam == NULL)
636 return -EINVAL; 636 return -EINVAL;
637 637
638 if(cam->open_count == 0) { 638 if(cam->open_count == 0) {
639 if (parport_claim(cam->pdev)) { 639 if (parport_claim(cam->pdev)) {
640 DBG("failed to claim the port\n"); 640 DBG("failed to claim the port\n");
@@ -645,12 +645,12 @@ static int cpia_pp_open(void *privdata)
645 parport_write_control(cam->port, PARPORT_CONTROL_SELECT); 645 parport_write_control(cam->port, PARPORT_CONTROL_SELECT);
646 udelay(50); 646 udelay(50);
647 parport_write_control(cam->port, 647 parport_write_control(cam->port,
648 PARPORT_CONTROL_SELECT 648 PARPORT_CONTROL_SELECT
649 | PARPORT_CONTROL_INIT); 649 | PARPORT_CONTROL_INIT);
650 } 650 }
651 651
652 ++cam->open_count; 652 ++cam->open_count;
653 653
654 return 0; 654 return 0;
655} 655}
656 656
@@ -663,7 +663,7 @@ static int cpia_pp_registerCallback(void *privdata, void (*cb)(void *cbdata), vo
663{ 663{
664 struct pp_cam_entry *cam = privdata; 664 struct pp_cam_entry *cam = privdata;
665 int retval = 0; 665 int retval = 0;
666 666
667 if(cam->port->irq != PARPORT_IRQ_NONE) { 667 if(cam->port->irq != PARPORT_IRQ_NONE) {
668 INIT_WORK(&cam->cb_task, cb, cbdata); 668 INIT_WORK(&cam->cb_task, cb, cbdata);
669 } else { 669 } else {
@@ -707,9 +707,9 @@ static int cpia_pp_register(struct parport *port)
707 LOG("failed to allocate camera structure\n"); 707 LOG("failed to allocate camera structure\n");
708 return -ENOMEM; 708 return -ENOMEM;
709 } 709 }
710 710
711 pdev = parport_register_device(port, "cpia_pp", NULL, NULL, 711 pdev = parport_register_device(port, "cpia_pp", NULL, NULL,
712 NULL, 0, cam); 712 NULL, 0, cam);
713 713
714 if (!pdev) { 714 if (!pdev) {
715 LOG("failed to parport_register_device\n"); 715 LOG("failed to parport_register_device\n");
@@ -753,19 +753,19 @@ static void cpia_pp_detach (struct parport *port)
753 } 753 }
754 cpia = NULL; 754 cpia = NULL;
755 } 755 }
756 spin_unlock( &cam_list_lock_pp ); 756 spin_unlock( &cam_list_lock_pp );
757 757
758 if (!cpia) { 758 if (!cpia) {
759 DBG("cpia_pp_detach failed to find cam_data in cam_list\n"); 759 DBG("cpia_pp_detach failed to find cam_data in cam_list\n");
760 return; 760 return;
761 } 761 }
762 762
763 cam = (struct pp_cam_entry *) cpia->lowlevel_data; 763 cam = (struct pp_cam_entry *) cpia->lowlevel_data;
764 cpia_unregister_camera(cpia); 764 cpia_unregister_camera(cpia);
765 if(cam->open_count > 0) 765 if(cam->open_count > 0)
766 cpia_pp_close(cam); 766 cpia_pp_close(cam);
767 parport_unregister_device(cam->pdev); 767 parport_unregister_device(cam->pdev);
768 cpia->lowlevel_data = NULL; 768 cpia->lowlevel_data = NULL;
769 kfree(cam); 769 kfree(cam);
770} 770}
771 771
@@ -805,14 +805,14 @@ static struct parport_driver cpia_pp_driver = {
805 805
806int cpia_pp_init(void) 806int cpia_pp_init(void)
807{ 807{
808 printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, 808 printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
809 CPIA_PP_MAJ_VER,CPIA_PP_MIN_VER,CPIA_PP_PATCH_VER); 809 CPIA_PP_MAJ_VER,CPIA_PP_MIN_VER,CPIA_PP_PATCH_VER);
810 810
811 if(parport_nr[0] == PPCPIA_PARPORT_OFF) { 811 if(parport_nr[0] == PPCPIA_PARPORT_OFF) {
812 printk(" disabled\n"); 812 printk(" disabled\n");
813 return 0; 813 return 0;
814 } 814 }
815 815
816 spin_lock_init( &cam_list_lock_pp ); 816 spin_lock_init( &cam_list_lock_pp );
817 817
818 if (parport_register_driver (&cpia_pp_driver)) { 818 if (parport_register_driver (&cpia_pp_driver)) {
diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c
index 03275c37c5d3..9c49a4b00116 100644
--- a/drivers/media/video/cpia_usb.c
+++ b/drivers/media/video/cpia_usb.c
@@ -22,7 +22,7 @@
22 */ 22 */
23 23
24/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ 24/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
25/* #define _CPIA_DEBUG_ 1 */ 25/* #define _CPIA_DEBUG_ 1 */
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
@@ -85,7 +85,7 @@ struct usb_cpia {
85 85
86static int cpia_usb_open(void *privdata); 86static int cpia_usb_open(void *privdata);
87static int cpia_usb_registerCallback(void *privdata, void (*cb) (void *cbdata), 87static int cpia_usb_registerCallback(void *privdata, void (*cb) (void *cbdata),
88 void *cbdata); 88 void *cbdata);
89static int cpia_usb_transferCmd(void *privdata, u8 *command, u8 *data); 89static int cpia_usb_transferCmd(void *privdata, u8 *command, u8 *data);
90static int cpia_usb_streamStart(void *privdata); 90static int cpia_usb_streamStart(void *privdata);
91static int cpia_usb_streamStop(void *privdata); 91static int cpia_usb_streamStop(void *privdata);
@@ -127,7 +127,7 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
127 ucpia->workbuff->status = FRAME_READING; 127 ucpia->workbuff->status = FRAME_READING;
128 ucpia->workbuff->length = 0; 128 ucpia->workbuff->length = 0;
129 } 129 }
130 130
131 for (i = 0; i < urb->number_of_packets; i++) { 131 for (i = 0; i < urb->number_of_packets; i++) {
132 int n = urb->iso_frame_desc[i].actual_length; 132 int n = urb->iso_frame_desc[i].actual_length;
133 int st = urb->iso_frame_desc[i].status; 133 int st = urb->iso_frame_desc[i].status;
@@ -141,9 +141,9 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
141 printk(KERN_DEBUG "cpia: scratch buf overflow!scr_len: %d, n: %d\n", ucpia->workbuff->length, n); 141 printk(KERN_DEBUG "cpia: scratch buf overflow!scr_len: %d, n: %d\n", ucpia->workbuff->length, n);
142 return; 142 return;
143 } 143 }
144 144
145 if (n) { 145 if (n) {
146 if ((ucpia->workbuff->length > 0) || 146 if ((ucpia->workbuff->length > 0) ||
147 (0x19 == cdata[0] && 0x68 == cdata[1])) { 147 (0x19 == cdata[0] && 0x68 == cdata[1])) {
148 memcpy(ucpia->workbuff->data + ucpia->workbuff->length, cdata, n); 148 memcpy(ucpia->workbuff->data + ucpia->workbuff->length, cdata, n);
149 ucpia->workbuff->length += n; 149 ucpia->workbuff->length += n;
@@ -160,7 +160,7 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
160 ucpia->workbuff = ucpia->workbuff->next; 160 ucpia->workbuff = ucpia->workbuff->next;
161 ucpia->workbuff->status = FRAME_EMPTY; 161 ucpia->workbuff->status = FRAME_EMPTY;
162 ucpia->workbuff->length = 0; 162 ucpia->workbuff->length = 0;
163 163
164 if (waitqueue_active(&ucpia->wq_stream)) 164 if (waitqueue_active(&ucpia->wq_stream))
165 wake_up_interruptible(&ucpia->wq_stream); 165 wake_up_interruptible(&ucpia->wq_stream);
166 } 166 }
@@ -178,7 +178,7 @@ static int cpia_usb_open(void *privdata)
178 struct usb_cpia *ucpia = (struct usb_cpia *) privdata; 178 struct usb_cpia *ucpia = (struct usb_cpia *) privdata;
179 struct urb *urb; 179 struct urb *urb;
180 int ret, retval = 0, fx, err; 180 int ret, retval = 0, fx, err;
181 181
182 if (!ucpia) 182 if (!ucpia)
183 return -EINVAL; 183 return -EINVAL;
184 184
@@ -191,7 +191,7 @@ static int cpia_usb_open(void *privdata)
191 retval = -EINVAL; 191 retval = -EINVAL;
192 goto error_0; 192 goto error_0;
193 } 193 }
194 194
195 ret = usb_set_interface(ucpia->dev, ucpia->iface, 3); 195 ret = usb_set_interface(ucpia->dev, ucpia->iface, 3);
196 if (ret < 0) { 196 if (ret < 0) {
197 printk(KERN_ERR "cpia_usb_open: usb_set_interface error (ret = %d)\n", ret); 197 printk(KERN_ERR "cpia_usb_open: usb_set_interface error (ret = %d)\n", ret);
@@ -286,7 +286,7 @@ error_1:
286error_0: 286error_0:
287 kfree (ucpia->sbuf[0].data); 287 kfree (ucpia->sbuf[0].data);
288 ucpia->sbuf[0].data = NULL; 288 ucpia->sbuf[0].data = NULL;
289 289
290 return retval; 290 return retval;
291} 291}
292 292
@@ -307,7 +307,7 @@ static int WritePacket(struct usb_device *udev, const u8 *packet, u8 *buf, size_
307 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 307 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
308 packet[1] + (packet[0] << 8), 308 packet[1] + (packet[0] << 8),
309 USB_TYPE_VENDOR | USB_RECIP_DEVICE, 309 USB_TYPE_VENDOR | USB_RECIP_DEVICE,
310 packet[2] + (packet[3] << 8), 310 packet[2] + (packet[3] << 8),
311 packet[4] + (packet[5] << 8), buf, size, 1000); 311 packet[4] + (packet[5] << 8), buf, size, 1000);
312} 312}
313 313
@@ -324,7 +324,7 @@ static int ReadPacket(struct usb_device *udev, u8 *packet, u8 *buf, size_t size)
324 return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 324 return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
325 packet[1] + (packet[0] << 8), 325 packet[1] + (packet[0] << 8),
326 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 326 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
327 packet[2] + (packet[3] << 8), 327 packet[2] + (packet[3] << 8),
328 packet[4] + (packet[5] << 8), buf, size, 1000); 328 packet[4] + (packet[5] << 8), buf, size, 1000);
329} 329}
330 330
@@ -393,7 +393,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
393 393
394 if (!ucpia || !ucpia->present) 394 if (!ucpia || !ucpia->present)
395 return -1; 395 return -1;
396 396
397 if (ucpia->curbuff->status != FRAME_READY) 397 if (ucpia->curbuff->status != FRAME_READY)
398 interruptible_sleep_on(&ucpia->wq_stream); 398 interruptible_sleep_on(&ucpia->wq_stream);
399 else 399 else
@@ -403,7 +403,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
403 403
404 if (!mybuff) 404 if (!mybuff)
405 return -1; 405 return -1;
406 406
407 if (mybuff->status != FRAME_READY || mybuff->length < 4) { 407 if (mybuff->status != FRAME_READY || mybuff->length < 4) {
408 DBG("Something went wrong!\n"); 408 DBG("Something went wrong!\n");
409 return -1; 409 return -1;
@@ -411,7 +411,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
411 411
412 memcpy(frame, mybuff->data, mybuff->length); 412 memcpy(frame, mybuff->data, mybuff->length);
413 mybuff->status = FRAME_EMPTY; 413 mybuff->status = FRAME_EMPTY;
414 414
415/* DBG("read done, %d bytes, Header: %x/%x, Footer: %x%x%x%x\n", */ 415/* DBG("read done, %d bytes, Header: %x/%x, Footer: %x%x%x%x\n", */
416/* mybuff->length, frame[0], frame[1], */ 416/* mybuff->length, frame[0], frame[1], */
417/* frame[mybuff->length-4], frame[mybuff->length-3], */ 417/* frame[mybuff->length-4], frame[mybuff->length-3], */
@@ -447,7 +447,7 @@ static void cpia_usb_free_resources(struct usb_cpia *ucpia, int try)
447 447
448 kfree(ucpia->sbuf[1].data); 448 kfree(ucpia->sbuf[1].data);
449 ucpia->sbuf[1].data = NULL; 449 ucpia->sbuf[1].data = NULL;
450 450
451 if (ucpia->sbuf[0].urb) { 451 if (ucpia->sbuf[0].urb) {
452 usb_kill_urb(ucpia->sbuf[0].urb); 452 usb_kill_urb(ucpia->sbuf[0].urb);
453 usb_free_urb(ucpia->sbuf[0].urb); 453 usb_free_urb(ucpia->sbuf[0].urb);
@@ -490,7 +490,7 @@ static int cpia_probe(struct usb_interface *intf,
490 struct usb_cpia *ucpia; 490 struct usb_cpia *ucpia;
491 struct cam_data *cam; 491 struct cam_data *cam;
492 int ret; 492 int ret;
493 493
494 /* A multi-config CPiA camera? */ 494 /* A multi-config CPiA camera? */
495 if (udev->descriptor.bNumConfigurations != 1) 495 if (udev->descriptor.bNumConfigurations != 1)
496 return -ENODEV; 496 return -ENODEV;
@@ -539,7 +539,7 @@ static int cpia_probe(struct usb_interface *intf,
539 539
540 /* Before register_camera, important */ 540 /* Before register_camera, important */
541 ucpia->present = 1; 541 ucpia->present = 1;
542 542
543 cam = cpia_register_camera(&cpia_usb_ops, ucpia); 543 cam = cpia_register_camera(&cpia_usb_ops, ucpia);
544 if (!cam) { 544 if (!cam) {
545 LOG("failed to cpia_register_camera\n"); 545 LOG("failed to cpia_register_camera\n");
@@ -591,7 +591,7 @@ static void cpia_disconnect(struct usb_interface *intf)
591 struct cam_data *cam = usb_get_intfdata(intf); 591 struct cam_data *cam = usb_get_intfdata(intf);
592 struct usb_cpia *ucpia; 592 struct usb_cpia *ucpia;
593 struct usb_device *udev; 593 struct usb_device *udev;
594 594
595 usb_set_intfdata(intf, NULL); 595 usb_set_intfdata(intf, NULL);
596 if (!cam) 596 if (!cam)
597 return; 597 return;
@@ -600,7 +600,7 @@ static void cpia_disconnect(struct usb_interface *intf)
600 spin_lock( &cam_list_lock_usb ); 600 spin_lock( &cam_list_lock_usb );
601 list_del(&cam->cam_data_list); 601 list_del(&cam->cam_data_list);
602 spin_unlock( &cam_list_lock_usb ); 602 spin_unlock( &cam_list_lock_usb );
603 603
604 ucpia->present = 0; 604 ucpia->present = 0;
605 605
606 cpia_unregister_camera(cam); 606 cpia_unregister_camera(cam);
@@ -631,7 +631,7 @@ static void cpia_disconnect(struct usb_interface *intf)
631 631
632static int __init usb_cpia_init(void) 632static int __init usb_cpia_init(void)
633{ 633{
634 printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, 634 printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
635 CPIA_USB_MAJ_VER,CPIA_USB_MIN_VER,CPIA_USB_PATCH_VER); 635 CPIA_USB_MAJ_VER,CPIA_USB_MIN_VER,CPIA_USB_PATCH_VER);
636 636
637 spin_lock_init(&cam_list_lock_usb); 637 spin_lock_init(&cam_list_lock_usb);
diff --git a/drivers/media/video/cs8420.h b/drivers/media/video/cs8420.h
index 2b22f3a38de5..621c0c6678ea 100644
--- a/drivers/media/video/cs8420.h
+++ b/drivers/media/video/cs8420.h
@@ -20,7 +20,7 @@
20#define __CS8420_H__ 20#define __CS8420_H__
21 21
22/* Initialization Sequence */ 22/* Initialization Sequence */
23 23
24static __u8 init8420[] = { 24static __u8 init8420[] = {
25 1, 0x01, 2, 0x02, 3, 0x00, 4, 0x46, 25 1, 0x01, 2, 0x02, 3, 0x00, 4, 0x46,
26 5, 0x24, 6, 0x84, 18, 0x18, 19, 0x13, 26 5, 0x24, 6, 0x84, 18, 0x18, 19, 0x13,
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c
index 1774ab7a40d2..b9ba95f5e026 100644
--- a/drivers/media/video/dabusb.c
+++ b/drivers/media/video/dabusb.c
@@ -86,7 +86,7 @@ static int dabusb_add_buf_tail (pdabusb_t s, struct list_head *dst, struct list_
86 return ret; 86 return ret;
87} 87}
88/*-------------------------------------------------------------------*/ 88/*-------------------------------------------------------------------*/
89#ifdef DEBUG 89#ifdef DEBUG
90static void dump_urb (struct urb *urb) 90static void dump_urb (struct urb *urb)
91{ 91{
92 dbg("urb :%p", urb); 92 dbg("urb :%p", urb);
@@ -136,7 +136,7 @@ static int dabusb_free_queue (struct list_head *q)
136 for (p = q->next; p != q;) { 136 for (p = q->next; p != q;) {
137 b = list_entry (p, buff_t, buff_list); 137 b = list_entry (p, buff_t, buff_list);
138 138
139#ifdef DEBUG 139#ifdef DEBUG
140 dump_urb(b->purb); 140 dump_urb(b->purb);
141#endif 141#endif
142 kfree(b->purb->transfer_buffer); 142 kfree(b->purb->transfer_buffer);
@@ -287,7 +287,7 @@ static int dabusb_bulk (pdabusb_t s, pbulk_transfer_t pb)
287 } 287 }
288 288
289 } 289 }
290 290
291 if( ret == -EPIPE ) { 291 if( ret == -EPIPE ) {
292 warn("CLEAR_FEATURE request to remove STALL condition."); 292 warn("CLEAR_FEATURE request to remove STALL condition.");
293 if(usb_clear_halt(s->usbdev, usb_pipeendpoint(pipe))) 293 if(usb_clear_halt(s->usbdev, usb_pipeendpoint(pipe)))
@@ -328,7 +328,7 @@ static int dabusb_loadmem (pdabusb_t s, const char *fname)
328 PINTEL_HEX_RECORD ptr = firmware; 328 PINTEL_HEX_RECORD ptr = firmware;
329 329
330 dbg("Enter dabusb_loadmem (internal)"); 330 dbg("Enter dabusb_loadmem (internal)");
331 331
332 ret = dabusb_8051_reset (s, 1); 332 ret = dabusb_8051_reset (s, 1);
333 while (ptr->Type == 0) { 333 while (ptr->Type == 0) {
334 334
@@ -449,7 +449,7 @@ static int dabusb_startrek (pdabusb_t s)
449 if (!list_empty (&s->free_buff_list)) { 449 if (!list_empty (&s->free_buff_list)) {
450 pbuff_t end; 450 pbuff_t end;
451 int ret; 451 int ret;
452 452
453 while (!dabusb_add_buf_tail (s, &s->rec_buff_list, &s->free_buff_list)) { 453 while (!dabusb_add_buf_tail (s, &s->rec_buff_list, &s->free_buff_list)) {
454 454
455 dbg("submitting: end:%p s->rec_buff_list:%p", s->rec_buff_list.prev, &s->rec_buff_list); 455 dbg("submitting: end:%p s->rec_buff_list:%p", s->rec_buff_list.prev, &s->rec_buff_list);
@@ -506,7 +506,7 @@ static ssize_t dabusb_read (struct file *file, char __user *buf, size_t count, l
506 err("error: rec_buf_list is empty"); 506 err("error: rec_buf_list is empty");
507 goto err; 507 goto err;
508 } 508 }
509 509
510 b = list_entry (s->rec_buff_list.next, buff_t, buff_list); 510 b = list_entry (s->rec_buff_list.next, buff_t, buff_list);
511 purb = b->purb; 511 purb = b->purb;
512 512
@@ -783,9 +783,9 @@ static void dabusb_disconnect (struct usb_interface *intf)
783 pdabusb_t s = usb_get_intfdata (intf); 783 pdabusb_t s = usb_get_intfdata (intf);
784 784
785 dbg("dabusb_disconnect"); 785 dbg("dabusb_disconnect");
786 786
787 init_waitqueue_entry(&__wait, current); 787 init_waitqueue_entry(&__wait, current);
788 788
789 usb_set_intfdata (intf, NULL); 789 usb_set_intfdata (intf, NULL);
790 if (s) { 790 if (s) {
791 usb_deregister_dev (intf, &dabusb_class); 791 usb_deregister_dev (intf, &dabusb_class);
@@ -797,7 +797,7 @@ static void dabusb_disconnect (struct usb_interface *intf)
797 schedule(); 797 schedule();
798 current->state = TASK_RUNNING; 798 current->state = TASK_RUNNING;
799 remove_wait_queue(&s->remove_ok, &__wait); 799 remove_wait_queue(&s->remove_ok, &__wait);
800 800
801 s->usbdev = NULL; 801 s->usbdev = NULL;
802 s->overruns = 0; 802 s->overruns = 0;
803 } 803 }
diff --git a/drivers/media/video/dabusb.h b/drivers/media/video/dabusb.h
index 96b03e4af8b9..00eb34c863eb 100644
--- a/drivers/media/video/dabusb.h
+++ b/drivers/media/video/dabusb.h
@@ -10,7 +10,7 @@ typedef struct
10#define DABUSB_VERSION 0x1000 10#define DABUSB_VERSION 0x1000
11#define IOCTL_DAB_BULK _IOWR('d', 0x30, bulk_transfer_t) 11#define IOCTL_DAB_BULK _IOWR('d', 0x30, bulk_transfer_t)
12#define IOCTL_DAB_OVERRUNS _IOR('d', 0x15, int) 12#define IOCTL_DAB_OVERRUNS _IOR('d', 0x15, int)
13#define IOCTL_DAB_VERSION _IOR('d', 0x3f, int) 13#define IOCTL_DAB_VERSION _IOR('d', 0x3f, int)
14 14
15#ifdef __KERNEL__ 15#ifdef __KERNEL__
16 16
@@ -36,7 +36,7 @@ typedef struct
36 struct list_head rec_buff_list; 36 struct list_head rec_buff_list;
37} dabusb_t,*pdabusb_t; 37} dabusb_t,*pdabusb_t;
38 38
39typedef struct 39typedef struct
40{ 40{
41 pdabusb_t s; 41 pdabusb_t s;
42 struct urb *purb; 42 struct urb *purb;
diff --git a/drivers/media/video/dsbr100.c b/drivers/media/video/dsbr100.c
index 25646804d5be..3b4e9985c3d7 100644
--- a/drivers/media/video/dsbr100.c
+++ b/drivers/media/video/dsbr100.c
@@ -37,28 +37,28 @@
37 Markus: Updates for 2.6.x kernels, code layout changes, name sanitizing 37 Markus: Updates for 2.6.x kernels, code layout changes, name sanitizing
38 38
39 Version 0.30: 39 Version 0.30:
40 Markus: Updates for 2.5.x kernel and more ISO compliant source 40 Markus: Updates for 2.5.x kernel and more ISO compliant source
41 41
42 Version 0.25: 42 Version 0.25:
43 PSL and Markus: Cleanup, radio now doesn't stop on device close 43 PSL and Markus: Cleanup, radio now doesn't stop on device close
44 44
45 Version 0.24: 45 Version 0.24:
46 Markus: Hope I got these silly VIDEO_TUNER_LOW issues finally 46 Markus: Hope I got these silly VIDEO_TUNER_LOW issues finally
47 right. Some minor cleanup, improved standalone compilation 47 right. Some minor cleanup, improved standalone compilation
48 48
49 Version 0.23: 49 Version 0.23:
50 Markus: Sign extension bug fixed by declaring transfer_buffer unsigned 50 Markus: Sign extension bug fixed by declaring transfer_buffer unsigned
51 51
52 Version 0.22: 52 Version 0.22:
53 Markus: Some (brown bag) cleanup in what VIDIOCSTUNER returns, 53 Markus: Some (brown bag) cleanup in what VIDIOCSTUNER returns,
54 thanks to Mike Cox for pointing the problem out. 54 thanks to Mike Cox for pointing the problem out.
55 55
56 Version 0.21: 56 Version 0.21:
57 Markus: Minor cleanup, warnings if something goes wrong, lame attempt 57 Markus: Minor cleanup, warnings if something goes wrong, lame attempt
58 to adhere to Documentation/CodingStyle 58 to adhere to Documentation/CodingStyle
59 59
60 Version 0.2: 60 Version 0.2:
61 Brad Hards <bradh@dynamite.com.au>: Fixes to make it work as non-module 61 Brad Hards <bradh@dynamite.com.au>: Fixes to make it work as non-module
62 Markus: Copyright clarification 62 Markus: Copyright clarification
63 63
64 Version 0.01: Markus: initial release 64 Version 0.01: Markus: initial release
@@ -163,11 +163,11 @@ static struct usb_driver usb_dsbr100_driver = {
163static int dsbr100_start(dsbr100_device *radio) 163static int dsbr100_start(dsbr100_device *radio)
164{ 164{
165 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 165 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
166 USB_REQ_GET_STATUS, 166 USB_REQ_GET_STATUS,
167 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 167 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
168 0x00, 0xC7, radio->transfer_buffer, 8, 300)<0 || 168 0x00, 0xC7, radio->transfer_buffer, 8, 300)<0 ||
169 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 169 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
170 DSB100_ONOFF, 170 DSB100_ONOFF,
171 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 171 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
172 0x01, 0x00, radio->transfer_buffer, 8, 300)<0) 172 0x01, 0x00, radio->transfer_buffer, 8, 300)<0)
173 return -1; 173 return -1;
@@ -179,11 +179,11 @@ static int dsbr100_start(dsbr100_device *radio)
179static int dsbr100_stop(dsbr100_device *radio) 179static int dsbr100_stop(dsbr100_device *radio)
180{ 180{
181 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 181 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
182 USB_REQ_GET_STATUS, 182 USB_REQ_GET_STATUS,
183 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 183 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
184 0x16, 0x1C, radio->transfer_buffer, 8, 300)<0 || 184 0x16, 0x1C, radio->transfer_buffer, 8, 300)<0 ||
185 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 185 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
186 DSB100_ONOFF, 186 DSB100_ONOFF,
187 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 187 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
188 0x00, 0x00, radio->transfer_buffer, 8, 300)<0) 188 0x00, 0x00, radio->transfer_buffer, 8, 300)<0)
189 return -1; 189 return -1;
@@ -195,16 +195,16 @@ static int dsbr100_setfreq(dsbr100_device *radio, int freq)
195{ 195{
196 freq = (freq/16*80)/1000+856; 196 freq = (freq/16*80)/1000+856;
197 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 197 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
198 DSB100_TUNE, 198 DSB100_TUNE,
199 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 199 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
200 (freq>>8)&0x00ff, freq&0xff, 200 (freq>>8)&0x00ff, freq&0xff,
201 radio->transfer_buffer, 8, 300)<0 || 201 radio->transfer_buffer, 8, 300)<0 ||
202 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 202 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
203 USB_REQ_GET_STATUS, 203 USB_REQ_GET_STATUS,
204 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 204 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
205 0x96, 0xB7, radio->transfer_buffer, 8, 300)<0 || 205 0x96, 0xB7, radio->transfer_buffer, 8, 300)<0 ||
206 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 206 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
207 USB_REQ_GET_STATUS, 207 USB_REQ_GET_STATUS,
208 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 208 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
209 0x00, 0x24, radio->transfer_buffer, 8, 300)<0) { 209 0x00, 0x24, radio->transfer_buffer, 8, 300)<0) {
210 radio->stereo = -1; 210 radio->stereo = -1;
@@ -219,7 +219,7 @@ sees a stereo signal or not. Pity. */
219static void dsbr100_getstat(dsbr100_device *radio) 219static void dsbr100_getstat(dsbr100_device *radio)
220{ 220{
221 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 221 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
222 USB_REQ_GET_STATUS, 222 USB_REQ_GET_STATUS,
223 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 223 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
224 0x00 , 0x24, radio->transfer_buffer, 8, 300)<0) 224 0x00 , 0x24, radio->transfer_buffer, 8, 300)<0)
225 radio->stereo = -1; 225 radio->stereo = -1;
@@ -232,7 +232,7 @@ static void dsbr100_getstat(dsbr100_device *radio)
232 232
233/* check if the device is present and register with v4l and 233/* check if the device is present and register with v4l and
234usb if it is */ 234usb if it is */
235static int usb_dsbr100_probe(struct usb_interface *intf, 235static int usb_dsbr100_probe(struct usb_interface *intf,
236 const struct usb_device_id *id) 236 const struct usb_device_id *id)
237{ 237{
238 dsbr100_device *radio; 238 dsbr100_device *radio;
@@ -243,7 +243,7 @@ static int usb_dsbr100_probe(struct usb_interface *intf,
243 kfree(radio); 243 kfree(radio);
244 return -ENOMEM; 244 return -ENOMEM;
245 } 245 }
246 memcpy(radio->videodev, &dsbr100_videodev_template, 246 memcpy(radio->videodev, &dsbr100_videodev_template,
247 sizeof(dsbr100_videodev_template)); 247 sizeof(dsbr100_videodev_template));
248 radio->removed = 0; 248 radio->removed = 0;
249 radio->users = 0; 249 radio->users = 0;
@@ -310,7 +310,7 @@ static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file,
310 struct video_tuner *v = arg; 310 struct video_tuner *v = arg;
311 311
312 dsbr100_getstat(radio); 312 dsbr100_getstat(radio);
313 if(v->tuner) /* Only 1 tuner */ 313 if(v->tuner) /* Only 1 tuner */
314 return -EINVAL; 314 return -EINVAL;
315 v->rangelow = FREQ_MIN*FREQ_MUL; 315 v->rangelow = FREQ_MIN*FREQ_MUL;
316 v->rangehigh = FREQ_MAX*FREQ_MUL; 316 v->rangehigh = FREQ_MAX*FREQ_MUL;
@@ -355,12 +355,12 @@ static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file,
355 v->volume = 1; 355 v->volume = 1;
356 v->step = 1; 356 v->step = 1;
357 strcpy(v->name, "Radio"); 357 strcpy(v->name, "Radio");
358 return 0; 358 return 0;
359 } 359 }
360 case VIDIOCSAUDIO: { 360 case VIDIOCSAUDIO: {
361 struct video_audio *v = arg; 361 struct video_audio *v = arg;
362 362
363 if (v->audio) 363 if (v->audio)
364 return -EINVAL; 364 return -EINVAL;
365 if (v->flags&VIDEO_AUDIO_MUTE) { 365 if (v->flags&VIDEO_AUDIO_MUTE) {
366 if (dsbr100_stop(radio)==-1) 366 if (dsbr100_stop(radio)==-1)
diff --git a/drivers/media/video/et61x251/et61x251.h b/drivers/media/video/et61x251/et61x251.h
index eee8afc9be72..2e5ca4032489 100644
--- a/drivers/media/video/et61x251/et61x251.h
+++ b/drivers/media/video/et61x251/et61x251.h
@@ -180,7 +180,7 @@ et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id)
180 180
181void 181void
182et61x251_attach_sensor(struct et61x251_device* cam, 182et61x251_attach_sensor(struct et61x251_device* cam,
183 struct et61x251_sensor* sensor) 183 struct et61x251_sensor* sensor)
184{ 184{
185 memcpy(&cam->sensor, sensor, sizeof(struct et61x251_sensor)); 185 memcpy(&cam->sensor, sensor, sizeof(struct et61x251_sensor));
186} 186}
@@ -199,7 +199,7 @@ do { \
199 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ 199 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
200 else if ((level) >= 3) \ 200 else if ((level) >= 3) \
201 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 201 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
202 __FUNCTION__, __LINE__ , ## args); \ 202 __FUNCTION__, __LINE__ , ## args); \
203 } \ 203 } \
204} while (0) 204} while (0)
205# define KDBG(level, fmt, args...) \ 205# define KDBG(level, fmt, args...) \
@@ -209,7 +209,7 @@ do { \
209 pr_info("et61x251: " fmt "\n", ## args); \ 209 pr_info("et61x251: " fmt "\n", ## args); \
210 else if ((level) == 3) \ 210 else if ((level) == 3) \
211 pr_debug("et61x251: [%s:%d] " fmt "\n", __FUNCTION__, \ 211 pr_debug("et61x251: [%s:%d] " fmt "\n", __FUNCTION__, \
212 __LINE__ , ## args); \ 212 __LINE__ , ## args); \
213 } \ 213 } \
214} while (0) 214} while (0)
215# define V4LDBG(level, name, cmd) \ 215# define V4LDBG(level, name, cmd) \
@@ -226,7 +226,7 @@ do { \
226#undef PDBG 226#undef PDBG
227#define PDBG(fmt, args...) \ 227#define PDBG(fmt, args...) \
228dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 228dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
229 __FUNCTION__, __LINE__ , ## args) 229 __FUNCTION__, __LINE__ , ## args)
230 230
231#undef PDBGG 231#undef PDBGG
232#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ 232#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index 7cc01b828b3d..dfc9dd732c9d 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -44,7 +44,7 @@
44/*****************************************************************************/ 44/*****************************************************************************/
45 45
46#define ET61X251_MODULE_NAME "V4L2 driver for ET61X[12]51 " \ 46#define ET61X251_MODULE_NAME "V4L2 driver for ET61X[12]51 " \
47 "PC Camera Controllers" 47 "PC Camera Controllers"
48#define ET61X251_MODULE_AUTHOR "(C) 2006 Luca Risolia" 48#define ET61X251_MODULE_AUTHOR "(C) 2006 Luca Risolia"
49#define ET61X251_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 49#define ET61X251_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
50#define ET61X251_MODULE_LICENSE "GPL" 50#define ET61X251_MODULE_LICENSE "GPL"
@@ -63,68 +63,68 @@ MODULE_LICENSE(ET61X251_MODULE_LICENSE);
63static short video_nr[] = {[0 ... ET61X251_MAX_DEVICES-1] = -1}; 63static short video_nr[] = {[0 ... ET61X251_MAX_DEVICES-1] = -1};
64module_param_array(video_nr, short, NULL, 0444); 64module_param_array(video_nr, short, NULL, 0444);
65MODULE_PARM_DESC(video_nr, 65MODULE_PARM_DESC(video_nr,
66 "\n<-1|n[,...]> Specify V4L2 minor mode number." 66 "\n<-1|n[,...]> Specify V4L2 minor mode number."
67 "\n -1 = use next available (default)" 67 "\n -1 = use next available (default)"
68 "\n n = use minor number n (integer >= 0)" 68 "\n n = use minor number n (integer >= 0)"
69 "\nYou can specify up to " 69 "\nYou can specify up to "
70 __MODULE_STRING(ET61X251_MAX_DEVICES) " cameras this way." 70 __MODULE_STRING(ET61X251_MAX_DEVICES) " cameras this way."
71 "\nFor example:" 71 "\nFor example:"
72 "\nvideo_nr=-1,2,-1 would assign minor number 2 to" 72 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
73 "\nthe second registered camera and use auto for the first" 73 "\nthe second registered camera and use auto for the first"
74 "\none and for every other camera." 74 "\none and for every other camera."
75 "\n"); 75 "\n");
76 76
77static short force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] = 77static short force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] =
78 ET61X251_FORCE_MUNMAP}; 78 ET61X251_FORCE_MUNMAP};
79module_param_array(force_munmap, bool, NULL, 0444); 79module_param_array(force_munmap, bool, NULL, 0444);
80MODULE_PARM_DESC(force_munmap, 80MODULE_PARM_DESC(force_munmap,
81 "\n<0|1[,...]> Force the application to unmap previously" 81 "\n<0|1[,...]> Force the application to unmap previously"
82 "\nmapped buffer memory before calling any VIDIOC_S_CROP or" 82 "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
83 "\nVIDIOC_S_FMT ioctl's. Not all the applications support" 83 "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
84 "\nthis feature. This parameter is specific for each" 84 "\nthis feature. This parameter is specific for each"
85 "\ndetected camera." 85 "\ndetected camera."
86 "\n 0 = do not force memory unmapping" 86 "\n 0 = do not force memory unmapping"
87 "\n 1 = force memory unmapping (save memory)" 87 "\n 1 = force memory unmapping (save memory)"
88 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." 88 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
89 "\n"); 89 "\n");
90 90
91static unsigned int frame_timeout[] = {[0 ... ET61X251_MAX_DEVICES-1] = 91static unsigned int frame_timeout[] = {[0 ... ET61X251_MAX_DEVICES-1] =
92 ET61X251_FRAME_TIMEOUT}; 92 ET61X251_FRAME_TIMEOUT};
93module_param_array(frame_timeout, uint, NULL, 0644); 93module_param_array(frame_timeout, uint, NULL, 0644);
94MODULE_PARM_DESC(frame_timeout, 94MODULE_PARM_DESC(frame_timeout,
95 "\n<n[,...]> Timeout for a video frame in seconds." 95 "\n<n[,...]> Timeout for a video frame in seconds."
96 "\nThis parameter is specific for each detected camera." 96 "\nThis parameter is specific for each detected camera."
97 "\nDefault value is " 97 "\nDefault value is "
98 __MODULE_STRING(ET61X251_FRAME_TIMEOUT)"." 98 __MODULE_STRING(ET61X251_FRAME_TIMEOUT)"."
99 "\n"); 99 "\n");
100 100
101#ifdef ET61X251_DEBUG 101#ifdef ET61X251_DEBUG
102static unsigned short debug = ET61X251_DEBUG_LEVEL; 102static unsigned short debug = ET61X251_DEBUG_LEVEL;
103module_param(debug, ushort, 0644); 103module_param(debug, ushort, 0644);
104MODULE_PARM_DESC(debug, 104MODULE_PARM_DESC(debug,
105 "\n<n> Debugging information level, from 0 to 3:" 105 "\n<n> Debugging information level, from 0 to 3:"
106 "\n0 = none (use carefully)" 106 "\n0 = none (use carefully)"
107 "\n1 = critical errors" 107 "\n1 = critical errors"
108 "\n2 = significant informations" 108 "\n2 = significant informations"
109 "\n3 = more verbose messages" 109 "\n3 = more verbose messages"
110 "\nLevel 3 is useful for testing only, when only " 110 "\nLevel 3 is useful for testing only, when only "
111 "one device is used." 111 "one device is used."
112 "\nDefault value is "__MODULE_STRING(ET61X251_DEBUG_LEVEL)"." 112 "\nDefault value is "__MODULE_STRING(ET61X251_DEBUG_LEVEL)"."
113 "\n"); 113 "\n");
114#endif 114#endif
115 115
116/*****************************************************************************/ 116/*****************************************************************************/
117 117
118static u32 118static u32
119et61x251_request_buffers(struct et61x251_device* cam, u32 count, 119et61x251_request_buffers(struct et61x251_device* cam, u32 count,
120 enum et61x251_io_method io) 120 enum et61x251_io_method io)
121{ 121{
122 struct v4l2_pix_format* p = &(cam->sensor.pix_format); 122 struct v4l2_pix_format* p = &(cam->sensor.pix_format);
123 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds); 123 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds);
124 const size_t imagesize = cam->module_param.force_munmap || 124 const size_t imagesize = cam->module_param.force_munmap ||
125 io == IO_READ ? 125 io == IO_READ ?
126 (p->width * p->height * p->priv) / 8 : 126 (p->width * p->height * p->priv) / 8 :
127 (r->width * r->height * p->priv) / 8; 127 (r->width * r->height * p->priv) / 8;
128 void* buff = NULL; 128 void* buff = NULL;
129 u32 i; 129 u32 i;
130 130
@@ -216,7 +216,7 @@ int et61x251_write_reg(struct et61x251_device* cam, u8 value, u16 index)
216 *buff = value; 216 *buff = value;
217 217
218 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 218 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
219 0, index, buff, 1, ET61X251_CTRL_TIMEOUT); 219 0, index, buff, 1, ET61X251_CTRL_TIMEOUT);
220 if (res < 0) { 220 if (res < 0) {
221 DBG(3, "Failed to write a register (value 0x%02X, index " 221 DBG(3, "Failed to write a register (value 0x%02X, index "
222 "0x%02X, error %d)", value, index, res); 222 "0x%02X, error %d)", value, index, res);
@@ -234,7 +234,7 @@ int et61x251_read_reg(struct et61x251_device* cam, u16 index)
234 int res; 234 int res;
235 235
236 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, 236 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
237 0, index, buff, 1, ET61X251_CTRL_TIMEOUT); 237 0, index, buff, 1, ET61X251_CTRL_TIMEOUT);
238 if (res < 0) 238 if (res < 0)
239 DBG(3, "Failed to read a register (index 0x%02X, error %d)", 239 DBG(3, "Failed to read a register (index 0x%02X, error %d)",
240 index, res); 240 index, res);
@@ -269,7 +269,7 @@ et61x251_i2c_wait(struct et61x251_device* cam, struct et61x251_sensor* sensor)
269 269
270int 270int
271et61x251_i2c_try_read(struct et61x251_device* cam, 271et61x251_i2c_try_read(struct et61x251_device* cam,
272 struct et61x251_sensor* sensor, u8 address) 272 struct et61x251_sensor* sensor, u8 address)
273{ 273{
274 struct usb_device* udev = cam->usbdev; 274 struct usb_device* udev = cam->usbdev;
275 u8* data = cam->control_buffer; 275 u8* data = cam->control_buffer;
@@ -280,14 +280,14 @@ et61x251_i2c_try_read(struct et61x251_device* cam,
280 data[2] = cam->sensor.rsta | 0x10; 280 data[2] = cam->sensor.rsta | 0x10;
281 data[3] = !(et61x251_read_reg(cam, 0x8b) & 0x02); 281 data[3] = !(et61x251_read_reg(cam, 0x8b) & 0x02);
282 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 282 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
283 0, 0x88, data, 4, ET61X251_CTRL_TIMEOUT); 283 0, 0x88, data, 4, ET61X251_CTRL_TIMEOUT);
284 if (res < 0) 284 if (res < 0)
285 err += res; 285 err += res;
286 286
287 err += et61x251_i2c_wait(cam, sensor); 287 err += et61x251_i2c_wait(cam, sensor);
288 288
289 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, 289 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
290 0, 0x80, data, 8, ET61X251_CTRL_TIMEOUT); 290 0, 0x80, data, 8, ET61X251_CTRL_TIMEOUT);
291 if (res < 0) 291 if (res < 0)
292 err += res; 292 err += res;
293 293
@@ -302,7 +302,7 @@ et61x251_i2c_try_read(struct et61x251_device* cam,
302 302
303int 303int
304et61x251_i2c_try_write(struct et61x251_device* cam, 304et61x251_i2c_try_write(struct et61x251_device* cam,
305 struct et61x251_sensor* sensor, u8 address, u8 value) 305 struct et61x251_sensor* sensor, u8 address, u8 value)
306{ 306{
307 struct usb_device* udev = cam->usbdev; 307 struct usb_device* udev = cam->usbdev;
308 u8* data = cam->control_buffer; 308 u8* data = cam->control_buffer;
@@ -312,13 +312,13 @@ et61x251_i2c_try_write(struct et61x251_device* cam,
312 data[1] = cam->sensor.i2c_slave_id; 312 data[1] = cam->sensor.i2c_slave_id;
313 data[2] = cam->sensor.rsta | 0x12; 313 data[2] = cam->sensor.rsta | 0x12;
314 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 314 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
315 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT); 315 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT);
316 if (res < 0) 316 if (res < 0)
317 err += res; 317 err += res;
318 318
319 data[0] = value; 319 data[0] = value;
320 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 320 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
321 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT); 321 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT);
322 if (res < 0) 322 if (res < 0)
323 err += res; 323 err += res;
324 324
@@ -335,8 +335,8 @@ et61x251_i2c_try_write(struct et61x251_device* cam,
335 335
336int 336int
337et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2, 337et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2,
338 u8 data3, u8 data4, u8 data5, u8 data6, u8 data7, 338 u8 data3, u8 data4, u8 data5, u8 data6, u8 data7,
339 u8 data8, u8 address) 339 u8 data8, u8 address)
340{ 340{
341 struct usb_device* udev = cam->usbdev; 341 struct usb_device* udev = cam->usbdev;
342 u8* data = cam->control_buffer; 342 u8* data = cam->control_buffer;
@@ -350,7 +350,7 @@ et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2,
350 data[5] = data7; 350 data[5] = data7;
351 data[6] = data8; 351 data[6] = data8;
352 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 352 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
353 0, 0x81, data, n-1, ET61X251_CTRL_TIMEOUT); 353 0, 0x81, data, n-1, ET61X251_CTRL_TIMEOUT);
354 if (res < 0) 354 if (res < 0)
355 err += res; 355 err += res;
356 356
@@ -358,14 +358,14 @@ et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2,
358 data[1] = cam->sensor.i2c_slave_id; 358 data[1] = cam->sensor.i2c_slave_id;
359 data[2] = cam->sensor.rsta | 0x02 | (n << 4); 359 data[2] = cam->sensor.rsta | 0x02 | (n << 4);
360 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 360 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
361 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT); 361 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT);
362 if (res < 0) 362 if (res < 0)
363 err += res; 363 err += res;
364 364
365 /* Start writing through the serial interface */ 365 /* Start writing through the serial interface */
366 data[0] = data1; 366 data[0] = data1;
367 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 367 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
368 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT); 368 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT);
369 if (res < 0) 369 if (res < 0)
370 err += res; 370 err += res;
371 371
@@ -432,11 +432,11 @@ static void et61x251_urb_complete(struct urb *urb, struct pt_regs* regs)
432 432
433 if (!(*f)) 433 if (!(*f))
434 (*f) = list_entry(cam->inqueue.next, struct et61x251_frame_t, 434 (*f) = list_entry(cam->inqueue.next, struct et61x251_frame_t,
435 frame); 435 frame);
436 436
437 imagesize = (cam->sensor.pix_format.width * 437 imagesize = (cam->sensor.pix_format.width *
438 cam->sensor.pix_format.height * 438 cam->sensor.pix_format.height *
439 cam->sensor.pix_format.priv) / 8; 439 cam->sensor.pix_format.priv) / 8;
440 440
441 for (i = 0; i < urb->number_of_packets; i++) { 441 for (i = 0; i < urb->number_of_packets; i++) {
442 unsigned int len, status; 442 unsigned int len, status;
@@ -476,7 +476,7 @@ start_of_frame:
476 if ((*f)->state == F_GRABBING) { 476 if ((*f)->state == F_GRABBING) {
477 if (sof && (*f)->buf.bytesused) { 477 if (sof && (*f)->buf.bytesused) {
478 if (cam->sensor.pix_format.pixelformat == 478 if (cam->sensor.pix_format.pixelformat ==
479 V4L2_PIX_FMT_ET61X251) 479 V4L2_PIX_FMT_ET61X251)
480 goto end_of_frame; 480 goto end_of_frame;
481 else { 481 else {
482 DBG(3, "Not expected SOF detected " 482 DBG(3, "Not expected SOF detected "
@@ -508,8 +508,8 @@ end_of_frame:
508 list_move_tail(&(*f)->frame, &cam->outqueue); 508 list_move_tail(&(*f)->frame, &cam->outqueue);
509 if (!list_empty(&cam->inqueue)) 509 if (!list_empty(&cam->inqueue))
510 (*f) = list_entry(cam->inqueue.next, 510 (*f) = list_entry(cam->inqueue.next,
511 struct et61x251_frame_t, 511 struct et61x251_frame_t,
512 frame); 512 frame);
513 else 513 else
514 (*f) = NULL; 514 (*f) = NULL;
515 spin_unlock(&cam->queue_lock); 515 spin_unlock(&cam->queue_lock);
@@ -521,7 +521,7 @@ end_of_frame:
521 521
522 if (sof && 522 if (sof &&
523 cam->sensor.pix_format.pixelformat == 523 cam->sensor.pix_format.pixelformat ==
524 V4L2_PIX_FMT_ET61X251) 524 V4L2_PIX_FMT_ET61X251)
525 goto start_of_frame; 525 goto start_of_frame;
526 } 526 }
527 } 527 }
@@ -544,15 +544,15 @@ static int et61x251_start_transfer(struct et61x251_device* cam)
544 struct usb_device *udev = cam->usbdev; 544 struct usb_device *udev = cam->usbdev;
545 struct urb* urb; 545 struct urb* urb;
546 const unsigned int wMaxPacketSize[] = {0, 256, 384, 512, 640, 768, 832, 546 const unsigned int wMaxPacketSize[] = {0, 256, 384, 512, 640, 768, 832,
547 864, 896, 920, 956, 980, 1000, 547 864, 896, 920, 956, 980, 1000,
548 1022}; 548 1022};
549 const unsigned int psz = wMaxPacketSize[ET61X251_ALTERNATE_SETTING]; 549 const unsigned int psz = wMaxPacketSize[ET61X251_ALTERNATE_SETTING];
550 s8 i, j; 550 s8 i, j;
551 int err = 0; 551 int err = 0;
552 552
553 for (i = 0; i < ET61X251_URBS; i++) { 553 for (i = 0; i < ET61X251_URBS; i++) {
554 cam->transfer_buffer[i] = kzalloc(ET61X251_ISO_PACKETS * psz, 554 cam->transfer_buffer[i] = kzalloc(ET61X251_ISO_PACKETS * psz,
555 GFP_KERNEL); 555 GFP_KERNEL);
556 if (!cam->transfer_buffer[i]) { 556 if (!cam->transfer_buffer[i]) {
557 err = -ENOMEM; 557 err = -ENOMEM;
558 DBG(1, "Not enough memory"); 558 DBG(1, "Not enough memory");
@@ -653,9 +653,9 @@ static int et61x251_stream_interrupt(struct et61x251_device* cam)
653 653
654 cam->stream = STREAM_INTERRUPT; 654 cam->stream = STREAM_INTERRUPT;
655 timeout = wait_event_timeout(cam->wait_stream, 655 timeout = wait_event_timeout(cam->wait_stream,
656 (cam->stream == STREAM_OFF) || 656 (cam->stream == STREAM_OFF) ||
657 (cam->state & DEV_DISCONNECTED), 657 (cam->state & DEV_DISCONNECTED),
658 ET61X251_URB_TIMEOUT); 658 ET61X251_URB_TIMEOUT);
659 if (cam->state & DEV_DISCONNECTED) 659 if (cam->state & DEV_DISCONNECTED)
660 return -ENODEV; 660 return -ENODEV;
661 else if (cam->stream != STREAM_OFF) { 661 else if (cam->stream != STREAM_OFF) {
@@ -699,7 +699,7 @@ static u8 et61x251_strtou8(const char* buff, size_t len, ssize_t* count)
699 699
700/* 700/*
701 NOTE 1: being inside one of the following methods implies that the v4l 701 NOTE 1: being inside one of the following methods implies that the v4l
702 device exists for sure (see kobjects and reference counters) 702 device exists for sure (see kobjects and reference counters)
703 NOTE 2: buffers are PAGE_SIZE long 703 NOTE 2: buffers are PAGE_SIZE long
704*/ 704*/
705 705
@@ -964,13 +964,13 @@ et61x251_store_i2c_val(struct class_device* cd, const char* buf, size_t len)
964 964
965 965
966static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, 966static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR,
967 et61x251_show_reg, et61x251_store_reg); 967 et61x251_show_reg, et61x251_store_reg);
968static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR, 968static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
969 et61x251_show_val, et61x251_store_val); 969 et61x251_show_val, et61x251_store_val);
970static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR, 970static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR,
971 et61x251_show_i2c_reg, et61x251_store_i2c_reg); 971 et61x251_show_i2c_reg, et61x251_store_i2c_reg);
972static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, 972static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
973 et61x251_show_i2c_val, et61x251_store_i2c_val); 973 et61x251_show_i2c_val, et61x251_store_i2c_val);
974 974
975 975
976static void et61x251_create_sysfs(struct et61x251_device* cam) 976static void et61x251_create_sysfs(struct et61x251_device* cam)
@@ -990,7 +990,7 @@ static void et61x251_create_sysfs(struct et61x251_device* cam)
990 990
991static int 991static int
992et61x251_set_pix_format(struct et61x251_device* cam, 992et61x251_set_pix_format(struct et61x251_device* cam,
993 struct v4l2_pix_format* pix) 993 struct v4l2_pix_format* pix)
994{ 994{
995 int r, err = 0; 995 int r, err = 0;
996 996
@@ -1007,7 +1007,7 @@ et61x251_set_pix_format(struct et61x251_device* cam,
1007 1007
1008static int 1008static int
1009et61x251_set_compression(struct et61x251_device* cam, 1009et61x251_set_compression(struct et61x251_device* cam,
1010 struct v4l2_jpegcompression* compression) 1010 struct v4l2_jpegcompression* compression)
1011{ 1011{
1012 int r, err = 0; 1012 int r, err = 0;
1013 1013
@@ -1049,9 +1049,9 @@ et61x251_set_crop(struct et61x251_device* cam, struct v4l2_rect* rect)
1049{ 1049{
1050 struct et61x251_sensor* s = &cam->sensor; 1050 struct et61x251_sensor* s = &cam->sensor;
1051 u16 fmw_sx = (u16)(rect->left - s->cropcap.bounds.left + 1051 u16 fmw_sx = (u16)(rect->left - s->cropcap.bounds.left +
1052 s->active_pixel.left), 1052 s->active_pixel.left),
1053 fmw_sy = (u16)(rect->top - s->cropcap.bounds.top + 1053 fmw_sy = (u16)(rect->top - s->cropcap.bounds.top +
1054 s->active_pixel.top), 1054 s->active_pixel.top),
1055 fmw_length = (u16)(rect->width), 1055 fmw_length = (u16)(rect->width),
1056 fmw_height = (u16)(rect->height); 1056 fmw_height = (u16)(rect->height);
1057 int err = 0; 1057 int err = 0;
@@ -1061,8 +1061,8 @@ et61x251_set_crop(struct et61x251_device* cam, struct v4l2_rect* rect)
1061 err += et61x251_write_reg(cam, fmw_length & 0xff, 0x6b); 1061 err += et61x251_write_reg(cam, fmw_length & 0xff, 0x6b);
1062 err += et61x251_write_reg(cam, fmw_height & 0xff, 0x6c); 1062 err += et61x251_write_reg(cam, fmw_height & 0xff, 0x6c);
1063 err += et61x251_write_reg(cam, (fmw_sx >> 8) | ((fmw_sy & 0x300) >> 6) 1063 err += et61x251_write_reg(cam, (fmw_sx >> 8) | ((fmw_sy & 0x300) >> 6)
1064 | ((fmw_length & 0x300) >> 4) 1064 | ((fmw_length & 0x300) >> 4)
1065 | ((fmw_height & 0x300) >> 2), 0x6d); 1065 | ((fmw_height & 0x300) >> 2), 0x6d);
1066 if (err) 1066 if (err)
1067 return -EIO; 1067 return -EIO;
1068 1068
@@ -1203,8 +1203,8 @@ static int et61x251_open(struct inode* inode, struct file* filp)
1203 } 1203 }
1204 mutex_unlock(&cam->dev_mutex); 1204 mutex_unlock(&cam->dev_mutex);
1205 err = wait_event_interruptible_exclusive(cam->open, 1205 err = wait_event_interruptible_exclusive(cam->open,
1206 cam->state & DEV_DISCONNECTED 1206 cam->state & DEV_DISCONNECTED
1207 || !cam->users); 1207 || !cam->users);
1208 if (err) { 1208 if (err) {
1209 up_read(&et61x251_disconnect); 1209 up_read(&et61x251_disconnect);
1210 return err; 1210 return err;
@@ -1277,7 +1277,7 @@ static int et61x251_release(struct inode* inode, struct file* filp)
1277 1277
1278static ssize_t 1278static ssize_t
1279et61x251_read(struct file* filp, char __user * buf, 1279et61x251_read(struct file* filp, char __user * buf,
1280 size_t count, loff_t* f_pos) 1280 size_t count, loff_t* f_pos)
1281{ 1281{
1282 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); 1282 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
1283 struct et61x251_frame_t* f, * i; 1283 struct et61x251_frame_t* f, * i;
@@ -1310,7 +1310,7 @@ et61x251_read(struct file* filp, char __user * buf,
1310 1310
1311 if (cam->io == IO_NONE) { 1311 if (cam->io == IO_NONE) {
1312 if (!et61x251_request_buffers(cam, cam->nreadbuffers, 1312 if (!et61x251_request_buffers(cam, cam->nreadbuffers,
1313 IO_READ)) { 1313 IO_READ)) {
1314 DBG(1, "read() failed, not enough memory"); 1314 DBG(1, "read() failed, not enough memory");
1315 mutex_unlock(&cam->fileop_mutex); 1315 mutex_unlock(&cam->fileop_mutex);
1316 return -ENOMEM; 1316 return -ENOMEM;
@@ -1336,12 +1336,12 @@ et61x251_read(struct file* filp, char __user * buf,
1336 return -EAGAIN; 1336 return -EAGAIN;
1337 } 1337 }
1338 timeout = wait_event_interruptible_timeout 1338 timeout = wait_event_interruptible_timeout
1339 ( cam->wait_frame, 1339 ( cam->wait_frame,
1340 (!list_empty(&cam->outqueue)) || 1340 (!list_empty(&cam->outqueue)) ||
1341 (cam->state & DEV_DISCONNECTED) || 1341 (cam->state & DEV_DISCONNECTED) ||
1342 (cam->state & DEV_MISCONFIGURED), 1342 (cam->state & DEV_MISCONFIGURED),
1343 cam->module_param.frame_timeout * 1343 cam->module_param.frame_timeout *
1344 1000 * msecs_to_jiffies(1) ); 1344 1000 * msecs_to_jiffies(1) );
1345 if (timeout < 0) { 1345 if (timeout < 0) {
1346 mutex_unlock(&cam->fileop_mutex); 1346 mutex_unlock(&cam->fileop_mutex);
1347 return timeout; 1347 return timeout;
@@ -1408,7 +1408,7 @@ static unsigned int et61x251_poll(struct file *filp, poll_table *wait)
1408 1408
1409 if (cam->io == IO_NONE) { 1409 if (cam->io == IO_NONE) {
1410 if (!et61x251_request_buffers(cam, cam->nreadbuffers, 1410 if (!et61x251_request_buffers(cam, cam->nreadbuffers,
1411 IO_READ)) { 1411 IO_READ)) {
1412 DBG(1, "poll() failed, not enough memory"); 1412 DBG(1, "poll() failed, not enough memory");
1413 goto error; 1413 goto error;
1414 } 1414 }
@@ -1465,7 +1465,7 @@ static int et61x251_mmap(struct file* filp, struct vm_area_struct *vma)
1465{ 1465{
1466 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); 1466 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
1467 unsigned long size = vma->vm_end - vma->vm_start, 1467 unsigned long size = vma->vm_end - vma->vm_start,
1468 start = vma->vm_start; 1468 start = vma->vm_start;
1469 void *pos; 1469 void *pos;
1470 u32 i; 1470 u32 i;
1471 1471
@@ -1533,13 +1533,13 @@ et61x251_vidioc_querycap(struct et61x251_device* cam, void __user * arg)
1533 .driver = "et61x251", 1533 .driver = "et61x251",
1534 .version = ET61X251_MODULE_VERSION_CODE, 1534 .version = ET61X251_MODULE_VERSION_CODE,
1535 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | 1535 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1536 V4L2_CAP_STREAMING, 1536 V4L2_CAP_STREAMING,
1537 }; 1537 };
1538 1538
1539 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card)); 1539 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
1540 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0) 1540 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
1541 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id, 1541 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
1542 sizeof(cap.bus_info)); 1542 sizeof(cap.bus_info));
1543 1543
1544 if (copy_to_user(arg, &cap, sizeof(cap))) 1544 if (copy_to_user(arg, &cap, sizeof(cap)))
1545 return -EFAULT; 1545 return -EFAULT;
@@ -1871,7 +1871,7 @@ et61x251_vidioc_g_fmt(struct et61x251_device* cam, void __user * arg)
1871 return -EINVAL; 1871 return -EINVAL;
1872 1872
1873 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_ET61X251) 1873 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_ET61X251)
1874 ? 0 : (pfmt->width * pfmt->priv) / 8; 1874 ? 0 : (pfmt->width * pfmt->priv) / 8;
1875 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8); 1875 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
1876 pfmt->field = V4L2_FIELD_NONE; 1876 pfmt->field = V4L2_FIELD_NONE;
1877 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt)); 1877 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
@@ -1885,7 +1885,7 @@ et61x251_vidioc_g_fmt(struct et61x251_device* cam, void __user * arg)
1885 1885
1886static int 1886static int
1887et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd, 1887et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
1888 void __user * arg) 1888 void __user * arg)
1889{ 1889{
1890 struct et61x251_sensor* s = &cam->sensor; 1890 struct et61x251_sensor* s = &cam->sensor;
1891 struct v4l2_format format; 1891 struct v4l2_format format;
@@ -1947,7 +1947,7 @@ et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
1947 pix->priv = pfmt->priv; /* bpp */ 1947 pix->priv = pfmt->priv; /* bpp */
1948 pix->colorspace = pfmt->colorspace; 1948 pix->colorspace = pfmt->colorspace;
1949 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_ET61X251) 1949 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_ET61X251)
1950 ? 0 : (pix->width * pix->priv) / 8; 1950 ? 0 : (pix->width * pix->priv) / 8;
1951 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8); 1951 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
1952 pix->field = V4L2_FIELD_NONE; 1952 pix->field = V4L2_FIELD_NONE;
1953 1953
@@ -2020,7 +2020,7 @@ static int
2020et61x251_vidioc_g_jpegcomp(struct et61x251_device* cam, void __user * arg) 2020et61x251_vidioc_g_jpegcomp(struct et61x251_device* cam, void __user * arg)
2021{ 2021{
2022 if (copy_to_user(arg, &cam->compression, 2022 if (copy_to_user(arg, &cam->compression,
2023 sizeof(cam->compression))) 2023 sizeof(cam->compression)))
2024 return -EFAULT; 2024 return -EFAULT;
2025 2025
2026 return 0; 2026 return 0;
@@ -2169,7 +2169,7 @@ et61x251_vidioc_qbuf(struct et61x251_device* cam, void __user * arg)
2169 2169
2170static int 2170static int
2171et61x251_vidioc_dqbuf(struct et61x251_device* cam, struct file* filp, 2171et61x251_vidioc_dqbuf(struct et61x251_device* cam, struct file* filp,
2172 void __user * arg) 2172 void __user * arg)
2173{ 2173{
2174 struct v4l2_buffer b; 2174 struct v4l2_buffer b;
2175 struct et61x251_frame_t *f; 2175 struct et61x251_frame_t *f;
@@ -2188,12 +2188,12 @@ et61x251_vidioc_dqbuf(struct et61x251_device* cam, struct file* filp,
2188 if (filp->f_flags & O_NONBLOCK) 2188 if (filp->f_flags & O_NONBLOCK)
2189 return -EAGAIN; 2189 return -EAGAIN;
2190 timeout = wait_event_interruptible_timeout 2190 timeout = wait_event_interruptible_timeout
2191 ( cam->wait_frame, 2191 ( cam->wait_frame,
2192 (!list_empty(&cam->outqueue)) || 2192 (!list_empty(&cam->outqueue)) ||
2193 (cam->state & DEV_DISCONNECTED) || 2193 (cam->state & DEV_DISCONNECTED) ||
2194 (cam->state & DEV_MISCONFIGURED), 2194 (cam->state & DEV_MISCONFIGURED),
2195 cam->module_param.frame_timeout * 2195 cam->module_param.frame_timeout *
2196 1000 * msecs_to_jiffies(1) ); 2196 1000 * msecs_to_jiffies(1) );
2197 if (timeout < 0) 2197 if (timeout < 0)
2198 return timeout; 2198 return timeout;
2199 if (cam->state & DEV_DISCONNECTED) 2199 if (cam->state & DEV_DISCONNECTED)
@@ -2317,7 +2317,7 @@ et61x251_vidioc_s_parm(struct et61x251_device* cam, void __user * arg)
2317 2317
2318 2318
2319static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp, 2319static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp,
2320 unsigned int cmd, void __user * arg) 2320 unsigned int cmd, void __user * arg)
2321{ 2321{
2322 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); 2322 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
2323 2323
@@ -2411,7 +2411,7 @@ static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp,
2411 2411
2412 2412
2413static int et61x251_ioctl(struct inode* inode, struct file* filp, 2413static int et61x251_ioctl(struct inode* inode, struct file* filp,
2414 unsigned int cmd, unsigned long arg) 2414 unsigned int cmd, unsigned long arg)
2415{ 2415{
2416 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); 2416 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
2417 int err = 0; 2417 int err = 0;
@@ -2518,7 +2518,7 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2518 mutex_lock(&cam->dev_mutex); 2518 mutex_lock(&cam->dev_mutex);
2519 2519
2520 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 2520 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
2521 video_nr[dev_nr]); 2521 video_nr[dev_nr]);
2522 if (err) { 2522 if (err) {
2523 DBG(1, "V4L2 device registration failed"); 2523 DBG(1, "V4L2 device registration failed");
2524 if (err == -ENFILE && video_nr[dev_nr] == -1) 2524 if (err == -ENFILE && video_nr[dev_nr] == -1)
diff --git a/drivers/media/video/et61x251/et61x251_sensor.h b/drivers/media/video/et61x251/et61x251_sensor.h
index 56841ae8a207..65edd08dc386 100644
--- a/drivers/media/video/et61x251/et61x251_sensor.h
+++ b/drivers/media/video/et61x251/et61x251_sensor.h
@@ -47,7 +47,7 @@ et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id);
47 47
48extern void 48extern void
49et61x251_attach_sensor(struct et61x251_device* cam, 49et61x251_attach_sensor(struct et61x251_device* cam,
50 struct et61x251_sensor* sensor); 50 struct et61x251_sensor* sensor);
51 51
52/*****************************************************************************/ 52/*****************************************************************************/
53 53
@@ -56,13 +56,13 @@ extern int et61x251_read_reg(struct et61x251_device*, u16 index);
56extern int et61x251_i2c_write(struct et61x251_device*, u8 address, u8 value); 56extern int et61x251_i2c_write(struct et61x251_device*, u8 address, u8 value);
57extern int et61x251_i2c_read(struct et61x251_device*, u8 address); 57extern int et61x251_i2c_read(struct et61x251_device*, u8 address);
58extern int et61x251_i2c_try_write(struct et61x251_device*, 58extern int et61x251_i2c_try_write(struct et61x251_device*,
59 struct et61x251_sensor*, u8 address, 59 struct et61x251_sensor*, u8 address,
60 u8 value); 60 u8 value);
61extern int et61x251_i2c_try_read(struct et61x251_device*, 61extern int et61x251_i2c_try_read(struct et61x251_device*,
62 struct et61x251_sensor*, u8 address); 62 struct et61x251_sensor*, u8 address);
63extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1, 63extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1,
64 u8 data2, u8 data3, u8 data4, u8 data5, 64 u8 data2, u8 data3, u8 data4, u8 data5,
65 u8 data6, u8 data7, u8 data8, u8 address); 65 u8 data6, u8 data7, u8 data8, u8 address);
66 66
67/*****************************************************************************/ 67/*****************************************************************************/
68 68
@@ -100,13 +100,13 @@ struct et61x251_sensor {
100 100
101 int (*init)(struct et61x251_device* cam); 101 int (*init)(struct et61x251_device* cam);
102 int (*get_ctrl)(struct et61x251_device* cam, 102 int (*get_ctrl)(struct et61x251_device* cam,
103 struct v4l2_control* ctrl); 103 struct v4l2_control* ctrl);
104 int (*set_ctrl)(struct et61x251_device* cam, 104 int (*set_ctrl)(struct et61x251_device* cam,
105 const struct v4l2_control* ctrl); 105 const struct v4l2_control* ctrl);
106 int (*set_crop)(struct et61x251_device* cam, 106 int (*set_crop)(struct et61x251_device* cam,
107 const struct v4l2_rect* rect); 107 const struct v4l2_rect* rect);
108 int (*set_pix_format)(struct et61x251_device* cam, 108 int (*set_pix_format)(struct et61x251_device* cam,
109 const struct v4l2_pix_format* pix); 109 const struct v4l2_pix_format* pix);
110 110
111 /* Private */ 111 /* Private */
112 struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS]; 112 struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS];
diff --git a/drivers/media/video/et61x251/et61x251_tas5130d1b.c b/drivers/media/video/et61x251/et61x251_tas5130d1b.c
index 3998d76a307a..a7d65b82b2fb 100644
--- a/drivers/media/video/et61x251/et61x251_tas5130d1b.c
+++ b/drivers/media/video/et61x251/et61x251_tas5130d1b.c
@@ -46,20 +46,20 @@ static int tas5130d1b_init(struct et61x251_device* cam)
46 46
47 47
48static int tas5130d1b_set_ctrl(struct et61x251_device* cam, 48static int tas5130d1b_set_ctrl(struct et61x251_device* cam,
49 const struct v4l2_control* ctrl) 49 const struct v4l2_control* ctrl)
50{ 50{
51 int err = 0; 51 int err = 0;
52 52
53 switch (ctrl->id) { 53 switch (ctrl->id) {
54 case V4L2_CID_GAIN: 54 case V4L2_CID_GAIN:
55 err += et61x251_i2c_raw_write(cam, 2, 0x20, 55 err += et61x251_i2c_raw_write(cam, 2, 0x20,
56 0xf6-ctrl->value, 0, 0, 0, 56 0xf6-ctrl->value, 0, 0, 0,
57 0, 0, 0, 0); 57 0, 0, 0, 0);
58 break; 58 break;
59 case V4L2_CID_EXPOSURE: 59 case V4L2_CID_EXPOSURE:
60 err += et61x251_i2c_raw_write(cam, 2, 0x40, 60 err += et61x251_i2c_raw_write(cam, 2, 0x40,
61 0x47-ctrl->value, 0, 0, 0, 61 0x47-ctrl->value, 0, 0, 0,
62 0, 0, 0, 0); 62 0, 0, 0, 0);
63 break; 63 break;
64 default: 64 default:
65 return -EINVAL; 65 return -EINVAL;
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index da44579d6f29..fdc8e3f13937 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -15,7 +15,7 @@
15 * 15 *
16 * Based on the Linux CPiA driver written by Peter Pregler, 16 * Based on the Linux CPiA driver written by Peter Pregler,
17 * Scott J. Bertin and Johannes Erdfelt. 17 * Scott J. Bertin and Johannes Erdfelt.
18 * 18 *
19 * Please see the file: Documentation/usb/ov511.txt 19 * Please see the file: Documentation/usb/ov511.txt
20 * and the website at: http://alpha.dyndns.org/ov511 20 * and the website at: http://alpha.dyndns.org/ov511
21 * for more info. 21 * for more info.
@@ -433,7 +433,7 @@ reg_w_mask(struct usb_ov511 *ov,
433 return (reg_w(ov, reg, newval)); 433 return (reg_w(ov, reg, newval));
434} 434}
435 435
436/* 436/*
437 * Writes multiple (n) byte value to a single register. Only valid with certain 437 * Writes multiple (n) byte value to a single register. Only valid with certain
438 * registers (0x30 and 0xc4 - 0xce). 438 * registers (0x30 and 0xc4 - 0xce).
439 */ 439 */
@@ -629,7 +629,7 @@ ov511_i2c_write_internal(struct usb_ov511 *ov,
629 /* Retry until idle */ 629 /* Retry until idle */
630 do 630 do
631 rc = reg_r(ov, R511_I2C_CTL); 631 rc = reg_r(ov, R511_I2C_CTL);
632 while (rc > 0 && ((rc&1) == 0)); 632 while (rc > 0 && ((rc&1) == 0));
633 if (rc < 0) 633 if (rc < 0)
634 break; 634 break;
635 635
@@ -1752,7 +1752,7 @@ sensor_set_picture(struct usb_ov511 *ov, struct video_picture *p)
1752 ov->whiteness = p->whiteness; 1752 ov->whiteness = p->whiteness;
1753 1753
1754 /* Don't return error if a setting is unsupported, or rest of settings 1754 /* Don't return error if a setting is unsupported, or rest of settings
1755 * will not be performed */ 1755 * will not be performed */
1756 1756
1757 rc = sensor_set_contrast(ov, p->contrast); 1757 rc = sensor_set_contrast(ov, p->contrast);
1758 if (FATAL_ERROR(rc)) 1758 if (FATAL_ERROR(rc))
@@ -1781,7 +1781,7 @@ sensor_get_picture(struct usb_ov511 *ov, struct video_picture *p)
1781 PDEBUG(4, "sensor_get_picture"); 1781 PDEBUG(4, "sensor_get_picture");
1782 1782
1783 /* Don't return error if a setting is unsupported, or rest of settings 1783 /* Don't return error if a setting is unsupported, or rest of settings
1784 * will not be performed */ 1784 * will not be performed */
1785 1785
1786 rc = sensor_get_contrast(ov, &(p->contrast)); 1786 rc = sensor_get_contrast(ov, &(p->contrast));
1787 if (FATAL_ERROR(rc)) 1787 if (FATAL_ERROR(rc))
@@ -2251,7 +2251,7 @@ mode_init_ov_sensor_regs(struct usb_ov511 *ov, int width, int height,
2251 2251
2252 /******** Clock programming ********/ 2252 /******** Clock programming ********/
2253 2253
2254 /* The OV6620 needs special handling. This prevents the 2254 /* The OV6620 needs special handling. This prevents the
2255 * severe banding that normally occurs */ 2255 * severe banding that normally occurs */
2256 if (ov->sensor == SEN_OV6620 || ov->sensor == SEN_OV6630) 2256 if (ov->sensor == SEN_OV6620 || ov->sensor == SEN_OV6630)
2257 { 2257 {
@@ -2326,7 +2326,7 @@ set_ov_sensor_window(struct usb_ov511 *ov, int width, int height, int mode,
2326 int sub_flag) 2326 int sub_flag)
2327{ 2327{
2328 int ret; 2328 int ret;
2329 int hwsbase, hwebase, vwsbase, vwebase, hwsize, vwsize; 2329 int hwsbase, hwebase, vwsbase, vwebase, hwsize, vwsize;
2330 int hoffset, voffset, hwscale = 0, vwscale = 0; 2330 int hoffset, voffset, hwscale = 0, vwscale = 0;
2331 2331
2332 /* The different sensor ICs handle setting up of window differently. 2332 /* The different sensor ICs handle setting up of window differently.
@@ -2575,7 +2575,7 @@ ov518_mode_init_regs(struct usb_ov511 *ov,
2575 /* OV518 needs U and V swapped */ 2575 /* OV518 needs U and V swapped */
2576 i2c_w_mask(ov, 0x15, 0x00, 0x01); 2576 i2c_w_mask(ov, 0x15, 0x00, 0x01);
2577 2577
2578 if (mode == VIDEO_PALETTE_GREY) { 2578 if (mode == VIDEO_PALETTE_GREY) {
2579 /* Set 16-bit input format (UV data are ignored) */ 2579 /* Set 16-bit input format (UV data are ignored) */
2580 reg_w_mask(ov, 0x20, 0x00, 0x08); 2580 reg_w_mask(ov, 0x20, 0x00, 0x08);
2581 2581
@@ -2894,7 +2894,7 @@ make_8x8(unsigned char *pIn, unsigned char *pOut, int w)
2894 * ... ... ... 2894 * ... ... ...
2895 * 56 57 ... 63 120 121 ... 127 248 249 ... 255 2895 * 56 57 ... 63 120 121 ... 127 248 249 ... 255
2896 * 2896 *
2897 */ 2897 */
2898static void 2898static void
2899yuv400raw_to_yuv400p(struct ov511_frame *frame, 2899yuv400raw_to_yuv400p(struct ov511_frame *frame,
2900 unsigned char *pIn0, unsigned char *pOut0) 2900 unsigned char *pIn0, unsigned char *pOut0)
@@ -2923,7 +2923,7 @@ yuv400raw_to_yuv400p(struct ov511_frame *frame,
2923 * 2923 *
2924 * 0 1 ... 7 2924 * 0 1 ... 7
2925 * 8 9 ... 15 2925 * 8 9 ... 15
2926 * ... 2926 * ...
2927 * 56 57 ... 63 2927 * 56 57 ... 63
2928 * 2928 *
2929 * U and V are shipped at half resolution (1 U,V sample -> one 2x2 block). 2929 * U and V are shipped at half resolution (1 U,V sample -> one 2x2 block).
@@ -3034,7 +3034,7 @@ decompress(struct usb_ov511 *ov, struct ov511_frame *frame,
3034 */ 3034 */
3035static void 3035static void
3036deinterlace(struct ov511_frame *frame, int rawformat, 3036deinterlace(struct ov511_frame *frame, int rawformat,
3037 unsigned char *pIn0, unsigned char *pOut0) 3037 unsigned char *pIn0, unsigned char *pOut0)
3038{ 3038{
3039 const int fieldheight = frame->rawheight / 2; 3039 const int fieldheight = frame->rawheight / 2;
3040 const int fieldpix = fieldheight * frame->rawwidth; 3040 const int fieldpix = fieldheight * frame->rawwidth;
@@ -3112,7 +3112,7 @@ ov51x_postprocess_grey(struct usb_ov511 *ov, struct ov511_frame *frame)
3112 frame->tempdata); 3112 frame->tempdata);
3113 3113
3114 deinterlace(frame, RAWFMT_YUV400, frame->tempdata, 3114 deinterlace(frame, RAWFMT_YUV400, frame->tempdata,
3115 frame->data); 3115 frame->data);
3116 } else { 3116 } else {
3117 if (frame->compressed) 3117 if (frame->compressed)
3118 decompress(ov, frame, frame->rawdata, 3118 decompress(ov, frame, frame->rawdata,
@@ -3136,7 +3136,7 @@ ov51x_postprocess_yuv420(struct usb_ov511 *ov, struct ov511_frame *frame)
3136 frame->tempdata); 3136 frame->tempdata);
3137 3137
3138 deinterlace(frame, RAWFMT_YUV420, frame->tempdata, 3138 deinterlace(frame, RAWFMT_YUV420, frame->tempdata,
3139 frame->data); 3139 frame->data);
3140 } else { 3140 } else {
3141 if (frame->compressed) 3141 if (frame->compressed)
3142 decompress(ov, frame, frame->rawdata, frame->data); 3142 decompress(ov, frame, frame->rawdata, frame->data);
@@ -3226,7 +3226,7 @@ ov511_move_data(struct usb_ov511 *ov, unsigned char *in, int n)
3226 frame->rawwidth = ((int)(in[9]) + 1) * 8; 3226 frame->rawwidth = ((int)(in[9]) + 1) * 8;
3227 frame->rawheight = ((int)(in[10]) + 1) * 8; 3227 frame->rawheight = ((int)(in[10]) + 1) * 8;
3228 3228
3229 PDEBUG(4, "Frame end, frame=%d, pnum=%d, w=%d, h=%d, recvd=%d", 3229 PDEBUG(4, "Frame end, frame=%d, pnum=%d, w=%d, h=%d, recvd=%d",
3230 ov->curframe, pnum, frame->rawwidth, frame->rawheight, 3230 ov->curframe, pnum, frame->rawwidth, frame->rawheight,
3231 frame->bytes_recvd); 3231 frame->bytes_recvd);
3232 3232
@@ -3527,10 +3527,10 @@ ov51x_isoc_irq(struct urb *urb, struct pt_regs *regs)
3527 return; 3527 return;
3528 } 3528 }
3529 3529
3530 if (urb->status == -ENOENT || urb->status == -ECONNRESET) { 3530 if (urb->status == -ENOENT || urb->status == -ECONNRESET) {
3531 PDEBUG(4, "URB unlinked"); 3531 PDEBUG(4, "URB unlinked");
3532 return; 3532 return;
3533 } 3533 }
3534 3534
3535 if (urb->status != -EINPROGRESS && urb->status != 0) { 3535 if (urb->status != -EINPROGRESS && urb->status != 0) {
3536 err("ERROR: urb->status=%d: %s", urb->status, 3536 err("ERROR: urb->status=%d: %s", urb->status,
@@ -4627,8 +4627,8 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma)
4627 PDEBUG(4, "mmap: %ld (%lX) bytes", size, size); 4627 PDEBUG(4, "mmap: %ld (%lX) bytes", size, size);
4628 4628
4629 if (size > (((OV511_NUMFRAMES 4629 if (size > (((OV511_NUMFRAMES
4630 * MAX_DATA_SIZE(ov->maxwidth, ov->maxheight) 4630 * MAX_DATA_SIZE(ov->maxwidth, ov->maxheight)
4631 + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))) 4631 + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))))
4632 return -EINVAL; 4632 return -EINVAL;
4633 4633
4634 if (mutex_lock_interruptible(&ov->lock)) 4634 if (mutex_lock_interruptible(&ov->lock))
@@ -5062,7 +5062,7 @@ ov6xx0_configure(struct usb_ov511 *ov)
5062} 5062}
5063 5063
5064/* This initializes the KS0127 and KS0127B video decoders. */ 5064/* This initializes the KS0127 and KS0127B video decoders. */
5065static int 5065static int
5066ks0127_configure(struct usb_ov511 *ov) 5066ks0127_configure(struct usb_ov511 *ov)
5067{ 5067{
5068 int rc; 5068 int rc;
@@ -5193,7 +5193,7 @@ saa7111a_configure(struct usb_ov511 *ov)
5193 return -1; 5193 return -1;
5194 5194
5195 /* Detect version of decoder. This must be done after writing the 5195 /* Detect version of decoder. This must be done after writing the
5196 * initial regs or the decoder will lock up. */ 5196 * initial regs or the decoder will lock up. */
5197 rc = i2c_r(ov, 0x00); 5197 rc = i2c_r(ov, 0x00);
5198 5198
5199 if (rc < 0) { 5199 if (rc < 0) {
@@ -5216,13 +5216,13 @@ saa7111a_configure(struct usb_ov511 *ov)
5216} 5216}
5217 5217
5218/* This initializes the OV511/OV511+ and the sensor */ 5218/* This initializes the OV511/OV511+ and the sensor */
5219static int 5219static int
5220ov511_configure(struct usb_ov511 *ov) 5220ov511_configure(struct usb_ov511 *ov)
5221{ 5221{
5222 static struct ov511_regvals aRegvalsInit511[] = { 5222 static struct ov511_regvals aRegvalsInit511[] = {
5223 { OV511_REG_BUS, R51x_SYS_RESET, 0x7f }, 5223 { OV511_REG_BUS, R51x_SYS_RESET, 0x7f },
5224 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 }, 5224 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 },
5225 { OV511_REG_BUS, R51x_SYS_RESET, 0x7f }, 5225 { OV511_REG_BUS, R51x_SYS_RESET, 0x7f },
5226 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 }, 5226 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 },
5227 { OV511_REG_BUS, R51x_SYS_RESET, 0x3f }, 5227 { OV511_REG_BUS, R51x_SYS_RESET, 0x3f },
5228 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 }, 5228 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 },
@@ -5269,7 +5269,7 @@ ov511_configure(struct usb_ov511 *ov)
5269 err("Please notify " EMAIL " of the name,"); 5269 err("Please notify " EMAIL " of the name,");
5270 err("manufacturer, model, and this number of your camera."); 5270 err("manufacturer, model, and this number of your camera.");
5271 err("Also include the output of the detection process."); 5271 err("Also include the output of the detection process.");
5272 } 5272 }
5273 5273
5274 if (ov->customid == 70) /* USB Life TV (PAL/SECAM) */ 5274 if (ov->customid == 70) /* USB Life TV (PAL/SECAM) */
5275 ov->pal = 1; 5275 ov->pal = 1;
@@ -5336,17 +5336,17 @@ ov511_configure(struct usb_ov511 *ov)
5336 5336
5337 if (i2c_w(ov, 0x10, 0x00) < 0) { 5337 if (i2c_w(ov, 0x10, 0x00) < 0) {
5338 err("Can't determine sensor slave IDs"); 5338 err("Can't determine sensor slave IDs");
5339 goto error; 5339 goto error;
5340 } else { 5340 } else {
5341 if (ks0127_configure(ov) < 0) { 5341 if (ks0127_configure(ov) < 0) {
5342 err("Failed to configure KS0127"); 5342 err("Failed to configure KS0127");
5343 goto error; 5343 goto error;
5344 } 5344 }
5345 } 5345 }
5346 } else { 5346 } else {
5347 if (saa7111a_configure(ov) < 0) { 5347 if (saa7111a_configure(ov) < 0) {
5348 err("Failed to configure SAA7111A"); 5348 err("Failed to configure SAA7111A");
5349 goto error; 5349 goto error;
5350 } 5350 }
5351 } 5351 }
5352 } else { 5352 } else {
@@ -5356,13 +5356,13 @@ ov511_configure(struct usb_ov511 *ov)
5356 } else { 5356 } else {
5357 if (ov6xx0_configure(ov) < 0) { 5357 if (ov6xx0_configure(ov) < 0) {
5358 err("Failed to configure OV6xx0"); 5358 err("Failed to configure OV6xx0");
5359 goto error; 5359 goto error;
5360 } 5360 }
5361 } 5361 }
5362 } else { 5362 } else {
5363 if (ov7xx0_configure(ov) < 0) { 5363 if (ov7xx0_configure(ov) < 0) {
5364 err("Failed to configure OV7xx0"); 5364 err("Failed to configure OV7xx0");
5365 goto error; 5365 goto error;
5366 } 5366 }
5367 } 5367 }
5368 5368
@@ -5381,12 +5381,12 @@ ov518_configure(struct usb_ov511 *ov)
5381 /* For 518 and 518+ */ 5381 /* For 518 and 518+ */
5382 static struct ov511_regvals aRegvalsInit518[] = { 5382 static struct ov511_regvals aRegvalsInit518[] = {
5383 { OV511_REG_BUS, R51x_SYS_RESET, 0x40 }, 5383 { OV511_REG_BUS, R51x_SYS_RESET, 0x40 },
5384 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 }, 5384 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 },
5385 { OV511_REG_BUS, R51x_SYS_RESET, 0x3e }, 5385 { OV511_REG_BUS, R51x_SYS_RESET, 0x3e },
5386 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 }, 5386 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 },
5387 { OV511_REG_BUS, R51x_SYS_RESET, 0x00 }, 5387 { OV511_REG_BUS, R51x_SYS_RESET, 0x00 },
5388 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 }, 5388 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 },
5389 { OV511_REG_BUS, 0x46, 0x00 }, 5389 { OV511_REG_BUS, 0x46, 0x00 },
5390 { OV511_REG_BUS, 0x5d, 0x03 }, 5390 { OV511_REG_BUS, 0x5d, 0x03 },
5391 { OV511_DONE_BUS, 0x0, 0x00}, 5391 { OV511_DONE_BUS, 0x0, 0x00},
5392 }; 5392 };
@@ -5517,7 +5517,7 @@ ov518_configure(struct usb_ov511 *ov)
5517 5517
5518 if (init_ov_sensor(ov) < 0) { 5518 if (init_ov_sensor(ov) < 0) {
5519 err("Can't determine sensor slave IDs"); 5519 err("Can't determine sensor slave IDs");
5520 goto error; 5520 goto error;
5521 } else { 5521 } else {
5522 err("Detected unsupported OV8xx0 sensor"); 5522 err("Detected unsupported OV8xx0 sensor");
5523 goto error; 5523 goto error;
@@ -5525,13 +5525,13 @@ ov518_configure(struct usb_ov511 *ov)
5525 } else { 5525 } else {
5526 if (ov6xx0_configure(ov) < 0) { 5526 if (ov6xx0_configure(ov) < 0) {
5527 err("Failed to configure OV6xx0"); 5527 err("Failed to configure OV6xx0");
5528 goto error; 5528 goto error;
5529 } 5529 }
5530 } 5530 }
5531 } else { 5531 } else {
5532 if (ov7xx0_configure(ov) < 0) { 5532 if (ov7xx0_configure(ov) < 0) {
5533 err("Failed to configure OV7xx0"); 5533 err("Failed to configure OV7xx0");
5534 goto error; 5534 goto error;
5535 } 5535 }
5536 } 5536 }
5537 5537
@@ -5564,28 +5564,28 @@ static ssize_t show_custom_id(struct class_device *cd, char *buf)
5564{ 5564{
5565 struct usb_ov511 *ov = cd_to_ov(cd); 5565 struct usb_ov511 *ov = cd_to_ov(cd);
5566 return sprintf(buf, "%d\n", ov->customid); 5566 return sprintf(buf, "%d\n", ov->customid);
5567} 5567}
5568static CLASS_DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL); 5568static CLASS_DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL);
5569 5569
5570static ssize_t show_model(struct class_device *cd, char *buf) 5570static ssize_t show_model(struct class_device *cd, char *buf)
5571{ 5571{
5572 struct usb_ov511 *ov = cd_to_ov(cd); 5572 struct usb_ov511 *ov = cd_to_ov(cd);
5573 return sprintf(buf, "%s\n", ov->desc); 5573 return sprintf(buf, "%s\n", ov->desc);
5574} 5574}
5575static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); 5575static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
5576 5576
5577static ssize_t show_bridge(struct class_device *cd, char *buf) 5577static ssize_t show_bridge(struct class_device *cd, char *buf)
5578{ 5578{
5579 struct usb_ov511 *ov = cd_to_ov(cd); 5579 struct usb_ov511 *ov = cd_to_ov(cd);
5580 return sprintf(buf, "%s\n", symbolic(brglist, ov->bridge)); 5580 return sprintf(buf, "%s\n", symbolic(brglist, ov->bridge));
5581} 5581}
5582static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL); 5582static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL);
5583 5583
5584static ssize_t show_sensor(struct class_device *cd, char *buf) 5584static ssize_t show_sensor(struct class_device *cd, char *buf)
5585{ 5585{
5586 struct usb_ov511 *ov = cd_to_ov(cd); 5586 struct usb_ov511 *ov = cd_to_ov(cd);
5587 return sprintf(buf, "%s\n", symbolic(senlist, ov->sensor)); 5587 return sprintf(buf, "%s\n", symbolic(senlist, ov->sensor));
5588} 5588}
5589static CLASS_DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL); 5589static CLASS_DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL);
5590 5590
5591static ssize_t show_brightness(struct class_device *cd, char *buf) 5591static ssize_t show_brightness(struct class_device *cd, char *buf)
@@ -5597,7 +5597,7 @@ static ssize_t show_brightness(struct class_device *cd, char *buf)
5597 return -ENODEV; 5597 return -ENODEV;
5598 sensor_get_brightness(ov, &x); 5598 sensor_get_brightness(ov, &x);
5599 return sprintf(buf, "%d\n", x >> 8); 5599 return sprintf(buf, "%d\n", x >> 8);
5600} 5600}
5601static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); 5601static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
5602 5602
5603static ssize_t show_saturation(struct class_device *cd, char *buf) 5603static ssize_t show_saturation(struct class_device *cd, char *buf)
@@ -5609,7 +5609,7 @@ static ssize_t show_saturation(struct class_device *cd, char *buf)
5609 return -ENODEV; 5609 return -ENODEV;
5610 sensor_get_saturation(ov, &x); 5610 sensor_get_saturation(ov, &x);
5611 return sprintf(buf, "%d\n", x >> 8); 5611 return sprintf(buf, "%d\n", x >> 8);
5612} 5612}
5613static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); 5613static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
5614 5614
5615static ssize_t show_contrast(struct class_device *cd, char *buf) 5615static ssize_t show_contrast(struct class_device *cd, char *buf)
@@ -5621,7 +5621,7 @@ static ssize_t show_contrast(struct class_device *cd, char *buf)
5621 return -ENODEV; 5621 return -ENODEV;
5622 sensor_get_contrast(ov, &x); 5622 sensor_get_contrast(ov, &x);
5623 return sprintf(buf, "%d\n", x >> 8); 5623 return sprintf(buf, "%d\n", x >> 8);
5624} 5624}
5625static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); 5625static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
5626 5626
5627static ssize_t show_hue(struct class_device *cd, char *buf) 5627static ssize_t show_hue(struct class_device *cd, char *buf)
@@ -5633,7 +5633,7 @@ static ssize_t show_hue(struct class_device *cd, char *buf)
5633 return -ENODEV; 5633 return -ENODEV;
5634 sensor_get_hue(ov, &x); 5634 sensor_get_hue(ov, &x);
5635 return sprintf(buf, "%d\n", x >> 8); 5635 return sprintf(buf, "%d\n", x >> 8);
5636} 5636}
5637static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); 5637static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
5638 5638
5639static ssize_t show_exposure(struct class_device *cd, char *buf) 5639static ssize_t show_exposure(struct class_device *cd, char *buf)
@@ -5645,7 +5645,7 @@ static ssize_t show_exposure(struct class_device *cd, char *buf)
5645 return -ENODEV; 5645 return -ENODEV;
5646 sensor_get_exposure(ov, &exp); 5646 sensor_get_exposure(ov, &exp);
5647 return sprintf(buf, "%d\n", exp >> 8); 5647 return sprintf(buf, "%d\n", exp >> 8);
5648} 5648}
5649static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL); 5649static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL);
5650 5650
5651static void ov_create_sysfs(struct video_device *vdev) 5651static void ov_create_sysfs(struct video_device *vdev)
diff --git a/drivers/media/video/ov511.h b/drivers/media/video/ov511.h
index bce9b3633889..12b3d51e1c34 100644
--- a/drivers/media/video/ov511.h
+++ b/drivers/media/video/ov511.h
@@ -130,7 +130,7 @@
130#define R511_COMP_QVY 0x76 130#define R511_COMP_QVY 0x76
131#define R511_COMP_QVUV 0x77 131#define R511_COMP_QVUV 0x77
132#define R511_COMP_EN 0x78 132#define R511_COMP_EN 0x78
133#define R511_COMP_LUT_EN 0x79 133#define R511_COMP_LUT_EN 0x79
134#define R511_COMP_LUT_BEGIN 0x80 134#define R511_COMP_LUT_BEGIN 0x80
135 135
136/* --------------------------------- */ 136/* --------------------------------- */
@@ -459,14 +459,14 @@ struct usb_ov511 {
459 int subh; /* Pix Array subcapture height */ 459 int subh; /* Pix Array subcapture height */
460 460
461 int curframe; /* Current receiving sbuf */ 461 int curframe; /* Current receiving sbuf */
462 struct ov511_frame frame[OV511_NUMFRAMES]; 462 struct ov511_frame frame[OV511_NUMFRAMES];
463 463
464 struct ov511_sbuf sbuf[OV511_NUMSBUF]; 464 struct ov511_sbuf sbuf[OV511_NUMSBUF];
465 465
466 wait_queue_head_t wq; /* Processes waiting */ 466 wait_queue_head_t wq; /* Processes waiting */
467 467
468 int snap_enabled; /* Snapshot mode enabled */ 468 int snap_enabled; /* Snapshot mode enabled */
469 469
470 int bridge; /* Type of bridge (BRG_*) */ 470 int bridge; /* Type of bridge (BRG_*) */
471 int bclass; /* Class of bridge (BCL_*) */ 471 int bclass; /* Class of bridge (BCL_*) */
472 int sensor; /* Type of image sensor chip (SEN_*) */ 472 int sensor; /* Type of image sensor chip (SEN_*) */
@@ -512,7 +512,7 @@ struct symbolic_list {
512/* Returns the name of the matching element in the symbolic_list array. The 512/* Returns the name of the matching element in the symbolic_list array. The
513 * end of the list must be marked with an element that has a NULL name. 513 * end of the list must be marked with an element that has a NULL name.
514 */ 514 */
515static inline char * 515static inline char *
516symbolic(struct symbolic_list list[], int num) 516symbolic(struct symbolic_list list[], int num)
517{ 517{
518 int i; 518 int i;
diff --git a/drivers/media/video/ovcamchip/Makefile b/drivers/media/video/ovcamchip/Makefile
index bca41ad93de8..cba4cdf20f49 100644
--- a/drivers/media/video/ovcamchip/Makefile
+++ b/drivers/media/video/ovcamchip/Makefile
@@ -1,4 +1,4 @@
1ovcamchip-objs := ovcamchip_core.o ov6x20.o ov6x30.o ov7x10.o ov7x20.o \ 1ovcamchip-objs := ovcamchip_core.o ov6x20.o ov6x30.o ov7x10.o ov7x20.o \
2 ov76be.o 2 ov76be.o
3 3
4obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip.o 4obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip.o
diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c
index e76b53d5909c..3fe9fa04cd84 100644
--- a/drivers/media/video/ovcamchip/ovcamchip_core.c
+++ b/drivers/media/video/ovcamchip/ovcamchip_core.c
@@ -266,17 +266,17 @@ static int ovcamchip_detect(struct i2c_client *c)
266 PDEBUG(3, "Testing for 0V6xx0"); 266 PDEBUG(3, "Testing for 0V6xx0");
267 c->addr = OV6xx0_SID; 267 c->addr = OV6xx0_SID;
268 if (init_camchip(c) < 0) { 268 if (init_camchip(c) < 0) {
269 return -ENODEV; 269 return -ENODEV;
270 } else { 270 } else {
271 if (ov6xx0_detect(c) < 0) { 271 if (ov6xx0_detect(c) < 0) {
272 PERROR("Failed to init OV6xx0"); 272 PERROR("Failed to init OV6xx0");
273 return -EIO; 273 return -EIO;
274 } 274 }
275 } 275 }
276 } else { 276 } else {
277 if (ov7xx0_detect(c) < 0) { 277 if (ov7xx0_detect(c) < 0) {
278 PERROR("Failed to init OV7xx0"); 278 PERROR("Failed to init OV7xx0");
279 return -EIO; 279 return -EIO;
280 } 280 }
281 } 281 }
282 282
diff --git a/drivers/media/video/ovcamchip/ovcamchip_priv.h b/drivers/media/video/ovcamchip/ovcamchip_priv.h
index 575e612a5546..1231335a9f4a 100644
--- a/drivers/media/video/ovcamchip/ovcamchip_priv.h
+++ b/drivers/media/video/ovcamchip/ovcamchip_priv.h
@@ -82,6 +82,6 @@ extern int ov_write_regvals(struct i2c_client *c,
82 struct ovcamchip_regvals *rvals); 82 struct ovcamchip_regvals *rvals);
83 83
84extern int ov_write_mask(struct i2c_client *c, unsigned char reg, 84extern int ov_write_mask(struct i2c_client *c, unsigned char reg,
85 unsigned char value, unsigned char mask); 85 unsigned char value, unsigned char mask);
86 86
87#endif 87#endif
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c
index 15fd85acabda..522e9ddeb089 100644
--- a/drivers/media/video/planb.c
+++ b/drivers/media/video/planb.c
@@ -1,4 +1,4 @@
1/* 1/*
2 planb - PlanB frame grabber driver 2 planb - PlanB frame grabber driver
3 3
4 PlanB is used in the 7x00/8x00 series of PowerMacintosh 4 PlanB is used in the 7x00/8x00 series of PowerMacintosh
@@ -584,7 +584,7 @@ finish:
584 wake_up_interruptible(&pb->suspendq); 584 wake_up_interruptible(&pb->suspendq);
585} 585}
586 586
587static void add_clip(struct planb *pb, struct video_clip *clip) 587static void add_clip(struct planb *pb, struct video_clip *clip)
588{ 588{
589 volatile unsigned char *base; 589 volatile unsigned char *base;
590 int xc = clip->x, yc = clip->y; 590 int xc = clip->x, yc = clip->y;
@@ -758,7 +758,7 @@ static void cmd_buff(struct planb *pb)
758 PLANB_SET(CH_SYNC)); 758 PLANB_SET(CH_SYNC));
759 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), 759 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
760 PLANB_SET(DMA_ABORT)); 760 PLANB_SET(DMA_ABORT));
761 761
762 /* odd field data: */ 762 /* odd field data: */
763 jump = virt_to_bus(c1 + nlines / 2); 763 jump = virt_to_bus(c1 + nlines / 2);
764 for (i=1; i < nlines; i += stepsize, c1++) 764 for (i=1; i < nlines; i += stepsize, c1++)
@@ -1247,7 +1247,7 @@ static volatile struct dbdma_cmd *setup_grab_cmd(int fr, struct planb *pb)
1247 tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++; 1247 tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++;
1248 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), 1248 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
1249 PLANB_SET(DMA_ABORT)); 1249 PLANB_SET(DMA_ABORT));
1250 1250
1251 /* odd field data: */ 1251 /* odd field data: */
1252 jump_addr = c1 + TAB_FACTOR * nlines / 2; 1252 jump_addr = c1 + TAB_FACTOR * nlines / 2;
1253 jump = virt_to_bus(jump_addr); 1253 jump = virt_to_bus(jump_addr);
@@ -1383,7 +1383,7 @@ static int planb_open(struct video_device *dev, int mode)
1383 pb->user++; 1383 pb->user++;
1384 1384
1385 DEBUG("PlanB: device opened\n"); 1385 DEBUG("PlanB: device opened\n");
1386 return 0; 1386 return 0;
1387} 1387}
1388 1388
1389static void planb_close(struct video_device *dev) 1389static void planb_close(struct video_device *dev)
@@ -1424,9 +1424,9 @@ static long planb_write(struct video_device *v, const char *buf,
1424static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) 1424static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1425{ 1425{
1426 struct planb *pb=(struct planb *)dev; 1426 struct planb *pb=(struct planb *)dev;
1427 1427
1428 switch (cmd) 1428 switch (cmd)
1429 { 1429 {
1430 case VIDIOCGCAP: 1430 case VIDIOCGCAP:
1431 { 1431 {
1432 struct video_capability b; 1432 struct video_capability b;
@@ -1440,26 +1440,26 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1440 b.channels = 2; /* composite & svhs */ 1440 b.channels = 2; /* composite & svhs */
1441 b.audios = 0; 1441 b.audios = 0;
1442 b.maxwidth = PLANB_MAXPIXELS; 1442 b.maxwidth = PLANB_MAXPIXELS;
1443 b.maxheight = PLANB_MAXLINES; 1443 b.maxheight = PLANB_MAXLINES;
1444 b.minwidth = 32; /* wild guess */ 1444 b.minwidth = 32; /* wild guess */
1445 b.minheight = 32; 1445 b.minheight = 32;
1446 if (copy_to_user(arg,&b,sizeof(b))) 1446 if (copy_to_user(arg,&b,sizeof(b)))
1447 return -EFAULT; 1447 return -EFAULT;
1448 return 0; 1448 return 0;
1449 } 1449 }
1450 case VIDIOCSFBUF: 1450 case VIDIOCSFBUF:
1451 { 1451 {
1452 struct video_buffer v; 1452 struct video_buffer v;
1453 unsigned short bpp; 1453 unsigned short bpp;
1454 unsigned int fmt; 1454 unsigned int fmt;
1455 1455
1456 DEBUG("PlanB: IOCTL VIDIOCSFBUF\n"); 1456 DEBUG("PlanB: IOCTL VIDIOCSFBUF\n");
1457 1457
1458 if (!capable(CAP_SYS_ADMIN) 1458 if (!capable(CAP_SYS_ADMIN)
1459 || !capable(CAP_SYS_RAWIO)) 1459 || !capable(CAP_SYS_RAWIO))
1460 return -EPERM; 1460 return -EPERM;
1461 if (copy_from_user(&v, arg,sizeof(v))) 1461 if (copy_from_user(&v, arg,sizeof(v)))
1462 return -EFAULT; 1462 return -EFAULT;
1463 planb_lock(pb); 1463 planb_lock(pb);
1464 switch(v.depth) { 1464 switch(v.depth) {
1465 case 8: 1465 case 8:
@@ -1478,7 +1478,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1478 break; 1478 break;
1479 default: 1479 default:
1480 planb_unlock(pb); 1480 planb_unlock(pb);
1481 return -EINVAL; 1481 return -EINVAL;
1482 } 1482 }
1483 if (bpp * v.width > v.bytesperline) { 1483 if (bpp * v.width > v.bytesperline) {
1484 planb_unlock(pb); 1484 planb_unlock(pb);
@@ -1493,7 +1493,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1493 pb->win.bpl = pb->win.bpp * pb->win.swidth; 1493 pb->win.bpl = pb->win.bpp * pb->win.swidth;
1494 pb->win.pad = v.bytesperline - pb->win.bpl; 1494 pb->win.pad = v.bytesperline - pb->win.bpl;
1495 1495
1496 DEBUG("PlanB: Display at %p is %d by %d, bytedepth %d," 1496 DEBUG("PlanB: Display at %p is %d by %d, bytedepth %d,"
1497 " bpl %d (+ %d)\n", v.base, v.width,v.height, 1497 " bpl %d (+ %d)\n", v.base, v.width,v.height,
1498 pb->win.bpp, pb->win.bpl, pb->win.pad); 1498 pb->win.bpp, pb->win.bpl, pb->win.pad);
1499 1499
@@ -1504,11 +1504,11 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1504 resume_overlay(pb); 1504 resume_overlay(pb);
1505 } 1505 }
1506 planb_unlock(pb); 1506 planb_unlock(pb);
1507 return 0; 1507 return 0;
1508 } 1508 }
1509 case VIDIOCGFBUF: 1509 case VIDIOCGFBUF:
1510 { 1510 {
1511 struct video_buffer v; 1511 struct video_buffer v;
1512 1512
1513 DEBUG("PlanB: IOCTL VIDIOCGFBUF\n"); 1513 DEBUG("PlanB: IOCTL VIDIOCGFBUF\n");
1514 1514
@@ -1518,15 +1518,15 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1518 v.depth = pb->win.depth; 1518 v.depth = pb->win.depth;
1519 v.bytesperline = pb->win.bpl + pb->win.pad; 1519 v.bytesperline = pb->win.bpl + pb->win.pad;
1520 if (copy_to_user(arg, &v, sizeof(v))) 1520 if (copy_to_user(arg, &v, sizeof(v)))
1521 return -EFAULT; 1521 return -EFAULT;
1522 return 0; 1522 return 0;
1523 } 1523 }
1524 case VIDIOCCAPTURE: 1524 case VIDIOCCAPTURE:
1525 { 1525 {
1526 int i; 1526 int i;
1527 1527
1528 if(copy_from_user(&i, arg, sizeof(i))) 1528 if(copy_from_user(&i, arg, sizeof(i)))
1529 return -EFAULT; 1529 return -EFAULT;
1530 if(i==0) { 1530 if(i==0) {
1531 DEBUG("PlanB: IOCTL VIDIOCCAPTURE Stop\n"); 1531 DEBUG("PlanB: IOCTL VIDIOCCAPTURE Stop\n");
1532 1532
@@ -1695,7 +1695,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1695 struct video_window vw; 1695 struct video_window vw;
1696 struct video_clip clip; 1696 struct video_clip clip;
1697 int i; 1697 int i;
1698 1698
1699 DEBUG("PlanB: IOCTL VIDIOCSWIN\n"); 1699 DEBUG("PlanB: IOCTL VIDIOCSWIN\n");
1700 1700
1701 if(copy_from_user(&vw,arg,sizeof(vw))) 1701 if(copy_from_user(&vw,arg,sizeof(vw)))
@@ -1749,7 +1749,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1749 return -EFAULT; 1749 return -EFAULT;
1750 return 0; 1750 return 0;
1751 } 1751 }
1752 case VIDIOCSYNC: { 1752 case VIDIOCSYNC: {
1753 int i; 1753 int i;
1754 1754
1755 IDEBUG("PlanB: IOCTL VIDIOCSYNC\n"); 1755 IDEBUG("PlanB: IOCTL VIDIOCSYNC\n");
@@ -1759,42 +1759,42 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1759 1759
1760 IDEBUG("PlanB: sync to frame %d\n", i); 1760 IDEBUG("PlanB: sync to frame %d\n", i);
1761 1761
1762 if(i > (MAX_GBUFFERS - 1) || i < 0) 1762 if(i > (MAX_GBUFFERS - 1) || i < 0)
1763 return -EINVAL; 1763 return -EINVAL;
1764chk_grab: 1764chk_grab:
1765 switch (pb->frame_stat[i]) { 1765 switch (pb->frame_stat[i]) {
1766 case GBUFFER_UNUSED: 1766 case GBUFFER_UNUSED:
1767 return -EINVAL; 1767 return -EINVAL;
1768 case GBUFFER_GRABBING: 1768 case GBUFFER_GRABBING:
1769 IDEBUG("PlanB: waiting for grab" 1769 IDEBUG("PlanB: waiting for grab"
1770 " done (%d)\n", i); 1770 " done (%d)\n", i);
1771 interruptible_sleep_on(&pb->capq); 1771 interruptible_sleep_on(&pb->capq);
1772 if(signal_pending(current)) 1772 if(signal_pending(current))
1773 return -EINTR; 1773 return -EINTR;
1774 goto chk_grab; 1774 goto chk_grab;
1775 case GBUFFER_DONE: 1775 case GBUFFER_DONE:
1776 pb->frame_stat[i] = GBUFFER_UNUSED; 1776 pb->frame_stat[i] = GBUFFER_UNUSED;
1777 break; 1777 break;
1778 } 1778 }
1779 return 0; 1779 return 0;
1780 } 1780 }
1781 1781
1782 case VIDIOCMCAPTURE: 1782 case VIDIOCMCAPTURE:
1783 { 1783 {
1784 struct video_mmap vm; 1784 struct video_mmap vm;
1785 volatile unsigned int status; 1785 volatile unsigned int status;
1786 1786
1787 IDEBUG("PlanB: IOCTL VIDIOCMCAPTURE\n"); 1787 IDEBUG("PlanB: IOCTL VIDIOCMCAPTURE\n");
1788 1788
1789 if(copy_from_user((void *) &vm,(void *)arg,sizeof(vm))) 1789 if(copy_from_user((void *) &vm,(void *)arg,sizeof(vm)))
1790 return -EFAULT; 1790 return -EFAULT;
1791 status = pb->frame_stat[vm.frame]; 1791 status = pb->frame_stat[vm.frame];
1792 if (status != GBUFFER_UNUSED) 1792 if (status != GBUFFER_UNUSED)
1793 return -EBUSY; 1793 return -EBUSY;
1794 1794
1795 return vgrab(pb, &vm); 1795 return vgrab(pb, &vm);
1796 } 1796 }
1797 1797
1798 case VIDIOCGMBUF: 1798 case VIDIOCGMBUF:
1799 { 1799 {
1800 int i; 1800 int i;
@@ -1811,7 +1811,7 @@ chk_grab:
1811 return -EFAULT; 1811 return -EFAULT;
1812 return 0; 1812 return 0;
1813 } 1813 }
1814 1814
1815 case PLANBIOCGSAAREGS: 1815 case PLANBIOCGSAAREGS:
1816 { 1816 {
1817 struct planb_saa_regs preg; 1817 struct planb_saa_regs preg;
@@ -1828,7 +1828,7 @@ chk_grab:
1828 return -EFAULT; 1828 return -EFAULT;
1829 return 0; 1829 return 0;
1830 } 1830 }
1831 1831
1832 case PLANBIOCSSAAREGS: 1832 case PLANBIOCSSAAREGS:
1833 { 1833 {
1834 struct planb_saa_regs preg; 1834 struct planb_saa_regs preg;
@@ -1842,7 +1842,7 @@ chk_grab:
1842 saa_set (preg.addr, preg.val, pb); 1842 saa_set (preg.addr, preg.val, pb);
1843 return 0; 1843 return 0;
1844 } 1844 }
1845 1845
1846 case PLANBIOCGSTAT: 1846 case PLANBIOCGSTAT:
1847 { 1847 {
1848 struct planb_stat_regs pstat; 1848 struct planb_stat_regs pstat;
@@ -1859,7 +1859,7 @@ chk_grab:
1859 return -EFAULT; 1859 return -EFAULT;
1860 return 0; 1860 return 0;
1861 } 1861 }
1862 1862
1863 case PLANBIOCSMODE: { 1863 case PLANBIOCSMODE: {
1864 int v; 1864 int v;
1865 1865
@@ -1985,10 +1985,10 @@ static int planb_mmap(struct vm_area_struct *vma, struct video_device *dev, cons
1985{ 1985{
1986 int i; 1986 int i;
1987 struct planb *pb = (struct planb *)dev; 1987 struct planb *pb = (struct planb *)dev;
1988 unsigned long start = (unsigned long)adr; 1988 unsigned long start = (unsigned long)adr;
1989 1989
1990 if (size > MAX_GBUFFERS * PLANB_MAX_FBUF) 1990 if (size > MAX_GBUFFERS * PLANB_MAX_FBUF)
1991 return -EINVAL; 1991 return -EINVAL;
1992 if (!pb->rawbuf) { 1992 if (!pb->rawbuf) {
1993 int err; 1993 int err;
1994 if((err=grabbuf_alloc(pb))) 1994 if((err=grabbuf_alloc(pb)))
@@ -2091,10 +2091,10 @@ static int init_planb(struct planb *pb)
2091 /* clear interrupt mask */ 2091 /* clear interrupt mask */
2092 pb->intr_mask = PLANB_CLR_IRQ; 2092 pb->intr_mask = PLANB_CLR_IRQ;
2093 2093
2094 result = request_irq(pb->irq, planb_irq, 0, "PlanB", (void *)pb); 2094 result = request_irq(pb->irq, planb_irq, 0, "PlanB", (void *)pb);
2095 if (result < 0) { 2095 if (result < 0) {
2096 if (result==-EINVAL) 2096 if (result==-EINVAL)
2097 printk(KERN_ERR "PlanB: Bad irq number (%d) " 2097 printk(KERN_ERR "PlanB: Bad irq number (%d) "
2098 "or handler\n", (int)pb->irq); 2098 "or handler\n", (int)pb->irq);
2099 else if (result==-EBUSY) 2099 else if (result==-EBUSY)
2100 printk(KERN_ERR "PlanB: I don't know why, " 2100 printk(KERN_ERR "PlanB: I don't know why, "
@@ -2102,7 +2102,7 @@ static int init_planb(struct planb *pb)
2102 return result; 2102 return result;
2103 } 2103 }
2104 disable_irq(pb->irq); 2104 disable_irq(pb->irq);
2105 2105
2106 /* Now add the template and register the device unit. */ 2106 /* Now add the template and register the device unit. */
2107 memcpy(&pb->video_dev,&planb_template,sizeof(planb_template)); 2107 memcpy(&pb->video_dev,&planb_template,sizeof(planb_template));
2108 2108
@@ -2143,7 +2143,7 @@ static int init_planb(struct planb *pb)
2143} 2143}
2144 2144
2145/* 2145/*
2146 * Scan for a PlanB controller, request the irq and map the io memory 2146 * Scan for a PlanB controller, request the irq and map the io memory
2147 */ 2147 */
2148 2148
2149static int find_planb(void) 2149static int find_planb(void)
@@ -2171,9 +2171,9 @@ static int find_planb(void)
2171 pb = &planbs[0]; 2171 pb = &planbs[0];
2172 planb_num = 1; 2172 planb_num = 1;
2173 2173
2174 if (planb_devices->n_addrs != 1) { 2174 if (planb_devices->n_addrs != 1) {
2175 printk (KERN_WARNING "PlanB: expecting 1 address for planb " 2175 printk (KERN_WARNING "PlanB: expecting 1 address for planb "
2176 "(got %d)", planb_devices->n_addrs); 2176 "(got %d)", planb_devices->n_addrs);
2177 return 0; 2177 return 0;
2178 } 2178 }
2179 2179
@@ -2236,7 +2236,7 @@ static int find_planb(void)
2236 pb->planb_base = planb_regs; 2236 pb->planb_base = planb_regs;
2237 pb->planb_base_phys = (struct planb_registers *)new_base; 2237 pb->planb_base_phys = (struct planb_registers *)new_base;
2238 pb->irq = irq; 2238 pb->irq = irq;
2239 2239
2240 return planb_num; 2240 return planb_num;
2241 2241
2242err_out_disable: 2242err_out_disable:
@@ -2251,7 +2251,7 @@ static void release_planb(void)
2251 int i; 2251 int i;
2252 struct planb *pb; 2252 struct planb *pb;
2253 2253
2254 for (i=0;i<planb_num; i++) 2254 for (i=0;i<planb_num; i++)
2255 { 2255 {
2256 pb=&planbs[i]; 2256 pb=&planbs[i];
2257 2257
@@ -2278,7 +2278,7 @@ static void release_planb(void)
2278static int __init init_planbs(void) 2278static int __init init_planbs(void)
2279{ 2279{
2280 int i; 2280 int i;
2281 2281
2282 if (find_planb()<=0) 2282 if (find_planb()<=0)
2283 return -EIO; 2283 return -EIO;
2284 2284
@@ -2288,9 +2288,9 @@ static int __init init_planbs(void)
2288 " with v4l\n", i); 2288 " with v4l\n", i);
2289 release_planb(); 2289 release_planb();
2290 return -EIO; 2290 return -EIO;
2291 } 2291 }
2292 printk(KERN_INFO "PlanB: registered device %d with v4l\n", i); 2292 printk(KERN_INFO "PlanB: registered device %d with v4l\n", i);
2293 } 2293 }
2294 return 0; 2294 return 0;
2295} 2295}
2296 2296
diff --git a/drivers/media/video/planb.h b/drivers/media/video/planb.h
index 79b6b561426e..92823211d0c5 100644
--- a/drivers/media/video/planb.h
+++ b/drivers/media/video/planb.h
@@ -1,4 +1,4 @@
1/* 1/*
2 planb - PlanB frame grabber driver 2 planb - PlanB frame grabber driver
3 3
4 PlanB is used in the 7x00/8x00 series of PowerMacintosh 4 PlanB is used in the 7x00/8x00 series of PowerMacintosh
@@ -167,7 +167,7 @@ struct planb {
167 struct video_device video_dev; 167 struct video_device video_dev;
168 struct video_picture picture; /* Current picture params */ 168 struct video_picture picture; /* Current picture params */
169 struct video_audio audio_dev; /* Current audio params */ 169 struct video_audio audio_dev; /* Current audio params */
170 170
171 volatile struct planb_registers *planb_base; /* virt base of planb */ 171 volatile struct planb_registers *planb_base; /* virt base of planb */
172 struct planb_registers *planb_base_phys; /* phys base of planb */ 172 struct planb_registers *planb_base_phys; /* phys base of planb */
173 void *priv_space; /* Org. alloc. mem for kfree */ 173 void *priv_space; /* Org. alloc. mem for kfree */
@@ -209,7 +209,7 @@ struct planb {
209 int gwidth[MAX_GBUFFERS], gheight[MAX_GBUFFERS]; 209 int gwidth[MAX_GBUFFERS], gheight[MAX_GBUFFERS];
210 unsigned int gfmt[MAX_GBUFFERS]; 210 unsigned int gfmt[MAX_GBUFFERS];
211 int gnorm_switch[MAX_GBUFFERS]; 211 int gnorm_switch[MAX_GBUFFERS];
212 volatile unsigned int *frame_stat; 212 volatile unsigned int *frame_stat;
213#define GBUFFER_UNUSED 0x00U 213#define GBUFFER_UNUSED 0x00U
214#define GBUFFER_GRABBING 0x01U 214#define GBUFFER_GRABBING 0x01U
215#define GBUFFER_DONE 0x02U 215#define GBUFFER_DONE 0x02U
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 05ca55939e77..09835ca098b1 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -12,10 +12,10 @@
12 * Most of this code is directly derived from his userspace driver. 12 * Most of this code is directly derived from his userspace driver.
13 * His driver works so send any reports to alan@redhat.com unless the 13 * His driver works so send any reports to alan@redhat.com unless the
14 * userspace driver also doesn't work for you... 14 * userspace driver also doesn't work for you...
15 * 15 *
16 * Changes: 16 * Changes:
17 * 08/07/2003 Daniele Bellucci <bellucda@tiscali.it> 17 * 08/07/2003 Daniele Bellucci <bellucda@tiscali.it>
18 * - pms_capture: report back -EFAULT 18 * - pms_capture: report back -EFAULT
19 */ 19 */
20 20
21#include <linux/module.h> 21#include <linux/module.h>
@@ -66,14 +66,14 @@ static int standard = 0; /* 0 - auto 1 - ntsc 2 - pal 3 - secam */
66/* 66/*
67 * I/O ports and Shared Memory 67 * I/O ports and Shared Memory
68 */ 68 */
69 69
70static int io_port = 0x250; 70static int io_port = 0x250;
71static int data_port = 0x251; 71static int data_port = 0x251;
72static int mem_base = 0xC8000; 72static int mem_base = 0xC8000;
73static void __iomem *mem; 73static void __iomem *mem;
74static int video_nr = -1; 74static int video_nr = -1;
75 75
76 76
77 77
78static inline void mvv_write(u8 index, u8 value) 78static inline void mvv_write(u8 index, u8 value)
79{ 79{
@@ -90,9 +90,9 @@ static int pms_i2c_stat(u8 slave)
90{ 90{
91 int counter; 91 int counter;
92 int i; 92 int i;
93 93
94 outb(0x28, io_port); 94 outb(0x28, io_port);
95 95
96 counter=0; 96 counter=0;
97 while((inb(data_port)&0x01)==0) 97 while((inb(data_port)&0x01)==0)
98 if(counter++==256) 98 if(counter++==256)
@@ -101,9 +101,9 @@ static int pms_i2c_stat(u8 slave)
101 while((inb(data_port)&0x01)!=0) 101 while((inb(data_port)&0x01)!=0)
102 if(counter++==256) 102 if(counter++==256)
103 break; 103 break;
104 104
105 outb(slave, io_port); 105 outb(slave, io_port);
106 106
107 counter=0; 107 counter=0;
108 while((inb(data_port)&0x01)==0) 108 while((inb(data_port)&0x01)==0)
109 if(counter++==256) 109 if(counter++==256)
@@ -112,7 +112,7 @@ static int pms_i2c_stat(u8 slave)
112 while((inb(data_port)&0x01)!=0) 112 while((inb(data_port)&0x01)!=0)
113 if(counter++==256) 113 if(counter++==256)
114 break; 114 break;
115 115
116 for(i=0;i<12;i++) 116 for(i=0;i<12;i++)
117 { 117 {
118 char st=inb(data_port); 118 char st=inb(data_port);
@@ -122,7 +122,7 @@ static int pms_i2c_stat(u8 slave)
122 break; 122 break;
123 } 123 }
124 outb(0x29, io_port); 124 outb(0x29, io_port);
125 return inb(data_port); 125 return inb(data_port);
126} 126}
127 127
128static int pms_i2c_write(u16 slave, u16 sub, u16 data) 128static int pms_i2c_write(u16 slave, u16 sub, u16 data)
@@ -130,19 +130,19 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
130 int skip=0; 130 int skip=0;
131 int count; 131 int count;
132 int i; 132 int i;
133 133
134 for(i=0;i<i2c_count;i++) 134 for(i=0;i<i2c_count;i++)
135 { 135 {
136 if((i2cinfo[i].slave==slave) && 136 if((i2cinfo[i].slave==slave) &&
137 (i2cinfo[i].sub == sub)) 137 (i2cinfo[i].sub == sub))
138 { 138 {
139 if(i2cinfo[i].data==data) 139 if(i2cinfo[i].data==data)
140 skip=1; 140 skip=1;
141 i2cinfo[i].data=data; 141 i2cinfo[i].data=data;
142 i=i2c_count+1; 142 i=i2c_count+1;
143 } 143 }
144 } 144 }
145 145
146 if(i==i2c_count && i2c_count<64) 146 if(i==i2c_count && i2c_count<64)
147 { 147 {
148 i2cinfo[i2c_count].slave=slave; 148 i2cinfo[i2c_count].slave=slave;
@@ -150,16 +150,16 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
150 i2cinfo[i2c_count].data=data; 150 i2cinfo[i2c_count].data=data;
151 i2c_count++; 151 i2c_count++;
152 } 152 }
153 153
154 if(skip) 154 if(skip)
155 return 0; 155 return 0;
156 156
157 mvv_write(0x29, sub); 157 mvv_write(0x29, sub);
158 mvv_write(0x2A, data); 158 mvv_write(0x2A, data);
159 mvv_write(0x28, slave); 159 mvv_write(0x28, slave);
160 160
161 outb(0x28, io_port); 161 outb(0x28, io_port);
162 162
163 count=0; 163 count=0;
164 while((inb(data_port)&1)==0) 164 while((inb(data_port)&1)==0)
165 if(count>255) 165 if(count>255)
@@ -167,9 +167,9 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
167 while((inb(data_port)&1)!=0) 167 while((inb(data_port)&1)!=0)
168 if(count>255) 168 if(count>255)
169 break; 169 break;
170 170
171 count=inb(data_port); 171 count=inb(data_port);
172 172
173 if(count&2) 173 if(count&2)
174 return -1; 174 return -1;
175 return count; 175 return count;
@@ -189,8 +189,8 @@ static int pms_i2c_read(int slave, int sub)
189 189
190static void pms_i2c_andor(int slave, int sub, int and, int or) 190static void pms_i2c_andor(int slave, int sub, int and, int or)
191{ 191{
192 u8 tmp; 192 u8 tmp;
193 193
194 tmp=pms_i2c_read(slave, sub); 194 tmp=pms_i2c_read(slave, sub);
195 tmp = (tmp&and)|or; 195 tmp = (tmp&and)|or;
196 pms_i2c_write(slave, sub, tmp); 196 pms_i2c_write(slave, sub, tmp);
@@ -199,7 +199,7 @@ static void pms_i2c_andor(int slave, int sub, int and, int or)
199/* 199/*
200 * Control functions 200 * Control functions
201 */ 201 */
202 202
203 203
204static void pms_videosource(short source) 204static void pms_videosource(short source)
205{ 205{
@@ -234,8 +234,8 @@ static void pms_colour(short colour)
234 break; 234 break;
235 } 235 }
236} 236}
237 237
238 238
239static void pms_contrast(short contrast) 239static void pms_contrast(short contrast)
240{ 240{
241 switch(decoder) 241 switch(decoder)
@@ -269,14 +269,14 @@ static void pms_format(short format)
269{ 269{
270 int target; 270 int target;
271 standard = format; 271 standard = format;
272 272
273 if(decoder==PHILIPS1) 273 if(decoder==PHILIPS1)
274 target=0x42; 274 target=0x42;
275 else if(decoder==PHILIPS2) 275 else if(decoder==PHILIPS2)
276 target=0x8A; 276 target=0x8A;
277 else 277 else
278 return; 278 return;
279 279
280 switch(format) 280 switch(format)
281 { 281 {
282 case 0: /* Auto */ 282 case 0: /* Auto */
@@ -302,7 +302,7 @@ static void pms_format(short format)
302 302
303/* 303/*
304 * These features of the PMS card are not currently exposes. They 304 * These features of the PMS card are not currently exposes. They
305 * could become a private v4l ioctl for PMSCONFIG or somesuch if 305 * could become a private v4l ioctl for PMSCONFIG or somesuch if
306 * people need it. We also don't yet use the PMS interrupt. 306 * people need it. We also don't yet use the PMS interrupt.
307 */ 307 */
308 308
@@ -324,7 +324,7 @@ static void pms_hstart(short start)
324/* 324/*
325 * Bandpass filters 325 * Bandpass filters
326 */ 326 */
327 327
328static void pms_bandpass(short pass) 328static void pms_bandpass(short pass)
329{ 329{
330 if(decoder==PHILIPS2) 330 if(decoder==PHILIPS2)
@@ -493,7 +493,7 @@ static void pms_vert(u8 deciden, u8 decinum)
493/* 493/*
494 * Turn 16bit ratios into best small ratio the chipset can grok 494 * Turn 16bit ratios into best small ratio the chipset can grok
495 */ 495 */
496 496
497static void pms_vertdeci(unsigned short decinum, unsigned short deciden) 497static void pms_vertdeci(unsigned short decinum, unsigned short deciden)
498{ 498{
499 /* Knock it down by /5 once */ 499 /* Knock it down by /5 once */
@@ -546,7 +546,7 @@ static void pms_horzdeci(short decinum, short deciden)
546 decinum=512; 546 decinum=512;
547 deciden=640; /* 768 would be ideal */ 547 deciden=640; /* 768 would be ideal */
548 } 548 }
549 549
550 while(((decinum|deciden)&1)==0) 550 while(((decinum|deciden)&1)==0)
551 { 551 {
552 decinum>>=1; 552 decinum>>=1;
@@ -559,7 +559,7 @@ static void pms_horzdeci(short decinum, short deciden)
559 } 559 }
560 if(deciden==32) 560 if(deciden==32)
561 deciden--; 561 deciden--;
562 562
563 mvv_write(0x24, 0x80|deciden); 563 mvv_write(0x24, 0x80|deciden);
564 mvv_write(0x25, decinum); 564 mvv_write(0x25, decinum);
565} 565}
@@ -567,14 +567,14 @@ static void pms_horzdeci(short decinum, short deciden)
567static void pms_resolution(short width, short height) 567static void pms_resolution(short width, short height)
568{ 568{
569 int fg_height; 569 int fg_height;
570 570
571 fg_height=height; 571 fg_height=height;
572 if(fg_height>280) 572 if(fg_height>280)
573 fg_height=280; 573 fg_height=280;
574 574
575 mvv_write(0x18, fg_height); 575 mvv_write(0x18, fg_height);
576 mvv_write(0x19, fg_height>>8); 576 mvv_write(0x19, fg_height>>8);
577 577
578 if(standard==1) 578 if(standard==1)
579 { 579 {
580 mvv_write(0x1A, 0xFC); 580 mvv_write(0x1A, 0xFC);
@@ -598,7 +598,7 @@ static void pms_resolution(short width, short height)
598 mvv_write(0x42, 0x00); 598 mvv_write(0x42, 0x00);
599 mvv_write(0x43, 0x00); 599 mvv_write(0x43, 0x00);
600 mvv_write(0x44, MVVMEMORYWIDTH); 600 mvv_write(0x44, MVVMEMORYWIDTH);
601 601
602 mvv_write(0x22, width+8); 602 mvv_write(0x22, width+8);
603 mvv_write(0x23, (width+8)>> 8); 603 mvv_write(0x23, (width+8)>> 8);
604 604
@@ -618,7 +618,7 @@ static void pms_resolution(short width, short height)
618/* 618/*
619 * Set Input 619 * Set Input
620 */ 620 */
621 621
622static void pms_vcrinput(short input) 622static void pms_vcrinput(short input)
623{ 623{
624 if(decoder==PHILIPS2) 624 if(decoder==PHILIPS2)
@@ -643,20 +643,20 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int
643 mvv_write(0x08,r8); /* capture rgb555/565, init DRAM, PC enable */ 643 mvv_write(0x08,r8); /* capture rgb555/565, init DRAM, PC enable */
644 644
645/* printf("%d %d %d %d %d %x %x\n",width,height,voff,nom,den,mvv_buf); */ 645/* printf("%d %d %d %d %d %x %x\n",width,height,voff,nom,den,mvv_buf); */
646 646
647 for (y = 0; y < dev->height; y++ ) 647 for (y = 0; y < dev->height; y++ )
648 { 648 {
649 writeb(0, mem); /* synchronisiert neue Zeile */ 649 writeb(0, mem); /* synchronisiert neue Zeile */
650 650
651 /* 651 /*
652 * This is in truth a fifo, be very careful as if you 652 * This is in truth a fifo, be very careful as if you
653 * forgot this odd things will occur 8) 653 * forgot this odd things will occur 8)
654 */ 654 */
655 655
656 memcpy_fromio(tmp, mem, dw+32); /* discard 16 word */ 656 memcpy_fromio(tmp, mem, dw+32); /* discard 16 word */
657 cnt -= dev->height; 657 cnt -= dev->height;
658 while (cnt <= 0) 658 while (cnt <= 0)
659 { 659 {
660 /* 660 /*
661 * Don't copy too far 661 * Don't copy too far
662 */ 662 */
@@ -666,7 +666,7 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int
666 cnt += dev->height; 666 cnt += dev->height;
667 if (copy_to_user(buf, tmp+32, dt)) 667 if (copy_to_user(buf, tmp+32, dt))
668 return len ? len : -EFAULT; 668 return len ? len : -EFAULT;
669 buf += dt; 669 buf += dt;
670 len += dt; 670 len += dt;
671 } 671 }
672 } 672 }
@@ -683,7 +683,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
683{ 683{
684 struct video_device *dev = video_devdata(file); 684 struct video_device *dev = video_devdata(file);
685 struct pms_device *pd=(struct pms_device *)dev; 685 struct pms_device *pd=(struct pms_device *)dev;
686 686
687 switch(cmd) 687 switch(cmd)
688 { 688 {
689 case VIDIOCGCAP: 689 case VIDIOCGCAP:
@@ -806,7 +806,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
806 ||(p->palette==VIDEO_PALETTE_RGB555 && p->depth==15))) 806 ||(p->palette==VIDEO_PALETTE_RGB555 && p->depth==15)))
807 return -EINVAL; 807 return -EINVAL;
808 pd->picture= *p; 808 pd->picture= *p;
809 809
810 /* 810 /*
811 * Now load the card. 811 * Now load the card.
812 */ 812 */
@@ -815,7 +815,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
815 pms_brightness(p->brightness>>8); 815 pms_brightness(p->brightness>>8);
816 pms_hue(p->hue>>8); 816 pms_hue(p->hue>>8);
817 pms_colour(p->colour>>8); 817 pms_colour(p->colour>>8);
818 pms_contrast(p->contrast>>8); 818 pms_contrast(p->contrast>>8);
819 mutex_unlock(&pd->lock); 819 mutex_unlock(&pd->lock);
820 return 0; 820 return 0;
821 } 821 }
@@ -873,7 +873,7 @@ static ssize_t pms_read(struct file *file, char __user *buf,
873 struct video_device *v = video_devdata(file); 873 struct video_device *v = video_devdata(file);
874 struct pms_device *pd=(struct pms_device *)v; 874 struct pms_device *pd=(struct pms_device *)v;
875 int len; 875 int len;
876 876
877 mutex_lock(&pd->lock); 877 mutex_lock(&pd->lock);
878 len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count); 878 len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count);
879 mutex_unlock(&pd->lock); 879 mutex_unlock(&pd->lock);
@@ -905,13 +905,13 @@ static struct pms_device pms_device;
905/* 905/*
906 * Probe for and initialise the Mediavision PMS 906 * Probe for and initialise the Mediavision PMS
907 */ 907 */
908 908
909static int init_mediavision(void) 909static int init_mediavision(void)
910{ 910{
911 int id; 911 int id;
912 int idec, decst; 912 int idec, decst;
913 int i; 913 int i;
914 914
915 unsigned char i2c_defs[]={ 915 unsigned char i2c_defs[]={
916 0x4C,0x30,0x00,0xE8, 916 0x4C,0x30,0x00,0xE8,
917 0xB6,0xE2,0x00,0x00, 917 0xB6,0xE2,0x00,0x00,
@@ -925,7 +925,7 @@ static int init_mediavision(void)
925 mem = ioremap(mem_base, 0x800); 925 mem = ioremap(mem_base, 0x800);
926 if (!mem) 926 if (!mem)
927 return -ENOMEM; 927 return -ENOMEM;
928 928
929 if (!request_region(0x9A01, 1, "Mediavision PMS config")) 929 if (!request_region(0x9A01, 1, "Mediavision PMS config"))
930 { 930 {
931 printk(KERN_WARNING "mediavision: unable to detect: 0x9A01 in use.\n"); 931 printk(KERN_WARNING "mediavision: unable to detect: 0x9A01 in use.\n");
@@ -941,18 +941,18 @@ static int init_mediavision(void)
941 } 941 }
942 outb(0xB8, 0x9A01); /* Unlock */ 942 outb(0xB8, 0x9A01); /* Unlock */
943 outb(io_port>>4, 0x9A01); /* Set IO port */ 943 outb(io_port>>4, 0x9A01); /* Set IO port */
944 944
945 945
946 id=mvv_read(3); 946 id=mvv_read(3);
947 decst=pms_i2c_stat(0x43); 947 decst=pms_i2c_stat(0x43);
948 948
949 if(decst!=-1) 949 if(decst!=-1)
950 idec=2; 950 idec=2;
951 else if(pms_i2c_stat(0xb9)!=-1) 951 else if(pms_i2c_stat(0xb9)!=-1)
952 idec=3; 952 idec=3;
953 else if(pms_i2c_stat(0x8b)!=-1) 953 else if(pms_i2c_stat(0x8b)!=-1)
954 idec=1; 954 idec=1;
955 else 955 else
956 idec=0; 956 idec=0;
957 957
958 printk(KERN_INFO "PMS type is %d\n", idec); 958 printk(KERN_INFO "PMS type is %d\n", idec);
@@ -966,11 +966,11 @@ static int init_mediavision(void)
966 /* 966 /*
967 * Ok we have a PMS of some sort 967 * Ok we have a PMS of some sort
968 */ 968 */
969 969
970 mvv_write(0x04, mem_base>>12); /* Set the memory area */ 970 mvv_write(0x04, mem_base>>12); /* Set the memory area */
971 971
972 /* Ok now load the defaults */ 972 /* Ok now load the defaults */
973 973
974 for(i=0;i<0x19;i++) 974 for(i=0;i<0x19;i++)
975 { 975 {
976 if(i2c_defs[i]==0xFF) 976 if(i2c_defs[i]==0xFF)
@@ -978,7 +978,7 @@ static int init_mediavision(void)
978 else 978 else
979 pms_i2c_write(0x8A, i, i2c_defs[i]); 979 pms_i2c_write(0x8A, i, i2c_defs[i]);
980 } 980 }
981 981
982 pms_i2c_write(0xB8,0x00,0x12); 982 pms_i2c_write(0xB8,0x00,0x12);
983 pms_i2c_write(0xB8,0x04,0x00); 983 pms_i2c_write(0xB8,0x04,0x00);
984 pms_i2c_write(0xB8,0x07,0x00); 984 pms_i2c_write(0xB8,0x07,0x00);
@@ -987,18 +987,18 @@ static int init_mediavision(void)
987 pms_i2c_write(0xB8,0x0A,0x00); 987 pms_i2c_write(0xB8,0x0A,0x00);
988 pms_i2c_write(0xB8,0x0B,0x10); 988 pms_i2c_write(0xB8,0x0B,0x10);
989 pms_i2c_write(0xB8,0x10,0x03); 989 pms_i2c_write(0xB8,0x10,0x03);
990 990
991 mvv_write(0x01, 0x00); 991 mvv_write(0x01, 0x00);
992 mvv_write(0x05, 0xA0); 992 mvv_write(0x05, 0xA0);
993 mvv_write(0x08, 0x25); 993 mvv_write(0x08, 0x25);
994 mvv_write(0x09, 0x00); 994 mvv_write(0x09, 0x00);
995 mvv_write(0x0A, 0x20|MVVMEMORYWIDTH); 995 mvv_write(0x0A, 0x20|MVVMEMORYWIDTH);
996 996
997 mvv_write(0x10, 0x02); 997 mvv_write(0x10, 0x02);
998 mvv_write(0x1E, 0x0C); 998 mvv_write(0x1E, 0x0C);
999 mvv_write(0x1F, 0x03); 999 mvv_write(0x1F, 0x03);
1000 mvv_write(0x26, 0x06); 1000 mvv_write(0x26, 0x06);
1001 1001
1002 mvv_write(0x2B, 0x00); 1002 mvv_write(0x2B, 0x00);
1003 mvv_write(0x2C, 0x20); 1003 mvv_write(0x2C, 0x20);
1004 mvv_write(0x2D, 0x00); 1004 mvv_write(0x2D, 0x00);
@@ -1018,13 +1018,13 @@ static int init_mediavision(void)
1018/* 1018/*
1019 * Initialization and module stuff 1019 * Initialization and module stuff
1020 */ 1020 */
1021 1021
1022static int __init init_pms_cards(void) 1022static int __init init_pms_cards(void)
1023{ 1023{
1024 printk(KERN_INFO "Mediavision Pro Movie Studio driver 0.02\n"); 1024 printk(KERN_INFO "Mediavision Pro Movie Studio driver 0.02\n");
1025 1025
1026 data_port = io_port +1; 1026 data_port = io_port +1;
1027 1027
1028 if(init_mediavision()) 1028 if(init_mediavision())
1029 { 1029 {
1030 printk(KERN_INFO "Board not found.\n"); 1030 printk(KERN_INFO "Board not found.\n");
diff --git a/drivers/media/video/pwc/Makefile b/drivers/media/video/pwc/Makefile
index 2d93a775011a..8326684f49f3 100644
--- a/drivers/media/video/pwc/Makefile
+++ b/drivers/media/video/pwc/Makefile
@@ -15,6 +15,6 @@ default:
15endif 15endif
16 16
17clean: 17clean:
18 rm -f *.[oas] .*.flags *.ko .*.cmd .*.d .*.tmp *.mod.c 18 rm -f *.[oas] .*.flags *.ko .*.cmd .*.d .*.tmp *.mod.c
19 rm -rf .tmp_versions 19 rm -rf .tmp_versions
20 20
diff --git a/drivers/media/video/pwc/philips.txt b/drivers/media/video/pwc/philips.txt
index 04a640d723ed..11f751a6bda5 100644
--- a/drivers/media/video/pwc/philips.txt
+++ b/drivers/media/video/pwc/philips.txt
@@ -47,17 +47,17 @@ don't know how to set it properly in the driver. The options are:
47size 47size
48 Can be one of 'sqcif', 'qsif', 'qcif', 'sif', 'cif' or 48 Can be one of 'sqcif', 'qsif', 'qcif', 'sif', 'cif' or
49 'vga', for an image size of resp. 128x96, 160x120, 176x144, 49 'vga', for an image size of resp. 128x96, 160x120, 176x144,
50 320x240, 352x288 and 640x480 (of course, only for those cameras that 50 320x240, 352x288 and 640x480 (of course, only for those cameras that
51 support these resolutions). 51 support these resolutions).
52 52
53fps 53fps
54 Specifies the desired framerate. Is an integer in the range of 4-30. 54 Specifies the desired framerate. Is an integer in the range of 4-30.
55 55
56fbufs 56fbufs
57 This paramter specifies the number of internal buffers to use for storing 57 This paramter specifies the number of internal buffers to use for storing
58 frames from the cam. This will help if the process that reads images from 58 frames from the cam. This will help if the process that reads images from
59 the cam is a bit slow or momentarely busy. However, on slow machines it 59 the cam is a bit slow or momentarely busy. However, on slow machines it
60 only introduces lag, so choose carefully. The default is 3, which is 60 only introduces lag, so choose carefully. The default is 3, which is
61 reasonable. You can set it between 2 and 5. 61 reasonable. You can set it between 2 and 5.
62 62
63mbufs 63mbufs
@@ -65,9 +65,9 @@ mbufs
65 buffers to reserve for mmap(), VIDIOCCGMBUF, VIDIOCMCAPTURE and friends. 65 buffers to reserve for mmap(), VIDIOCCGMBUF, VIDIOCMCAPTURE and friends.
66 The default is 2, which is adequate for most applications (double 66 The default is 2, which is adequate for most applications (double
67 buffering). 67 buffering).
68 68
69 Should you experience a lot of 'Dumping frame...' messages during 69 Should you experience a lot of 'Dumping frame...' messages during
70 grabbing with a tool that uses mmap(), you might want to increase if. 70 grabbing with a tool that uses mmap(), you might want to increase if.
71 However, it doesn't really buffer images, it just gives you a bit more 71 However, it doesn't really buffer images, it just gives you a bit more
72 slack when your program is behind. But you need a multi-threaded or 72 slack when your program is behind. But you need a multi-threaded or
73 forked program to really take advantage of these buffers. 73 forked program to really take advantage of these buffers.
@@ -88,15 +88,15 @@ power_save
88 88
89compression (only useful with the plugin) 89compression (only useful with the plugin)
90 With this option you can control the compression factor that the camera 90 With this option you can control the compression factor that the camera
91 uses to squeeze the image through the USB bus. You can set the 91 uses to squeeze the image through the USB bus. You can set the
92 parameter between 0 and 3: 92 parameter between 0 and 3:
93 0 = prefer uncompressed images; if the requested mode is not available 93 0 = prefer uncompressed images; if the requested mode is not available
94 in an uncompressed format, the driver will silently switch to low 94 in an uncompressed format, the driver will silently switch to low
95 compression. 95 compression.
96 1 = low compression. 96 1 = low compression.
97 2 = medium compression. 97 2 = medium compression.
98 3 = high compression. 98 3 = high compression.
99 99
100 High compression takes less bandwidth of course, but it could also 100 High compression takes less bandwidth of course, but it could also
101 introduce some unwanted artefacts. The default is 2, medium compression. 101 introduce some unwanted artefacts. The default is 2, medium compression.
102 See the FAQ on the website for an overview of which modes require 102 See the FAQ on the website for an overview of which modes require
@@ -112,7 +112,7 @@ leds
112 this is let the LED blink while the camera is in use. This: 112 this is let the LED blink while the camera is in use. This:
113 113
114 leds=500,500 114 leds=500,500
115 115
116 will blink the LED once every second. But with: 116 will blink the LED once every second. But with:
117 117
118 leds=0,0 118 leds=0,0
@@ -123,7 +123,7 @@ leds
123 when the camera is not used anymore. 123 when the camera is not used anymore.
124 124
125 This parameter works only with the ToUCam range of cameras (720, 730, 740, 125 This parameter works only with the ToUCam range of cameras (720, 730, 740,
126 750) and OEMs. For other cameras this command is silently ignored, and 126 750) and OEMs. For other cameras this command is silently ignored, and
127 the LED cannot be controlled. 127 the LED cannot be controlled.
128 128
129 Finally: this parameters does not take effect UNTIL the first time you 129 Finally: this parameters does not take effect UNTIL the first time you
@@ -144,35 +144,35 @@ dev_hint
144 format: 144 format:
145 145
146 [type[.serialnumber]:]node 146 [type[.serialnumber]:]node
147 147
148 The square brackets mean that both the type and the serialnumber are 148 The square brackets mean that both the type and the serialnumber are
149 optional, but a serialnumber cannot be specified without a type (which 149 optional, but a serialnumber cannot be specified without a type (which
150 would be rather pointless). The serialnumber is separated from the type 150 would be rather pointless). The serialnumber is separated from the type
151 by a '.'; the node number by a ':'. 151 by a '.'; the node number by a ':'.
152 152
153 This somewhat cryptic syntax is best explained by a few examples: 153 This somewhat cryptic syntax is best explained by a few examples:
154 154
155 dev_hint=3,5 The first detected cam gets assigned 155 dev_hint=3,5 The first detected cam gets assigned
156 /dev/video3, the second /dev/video5. Any 156 /dev/video3, the second /dev/video5. Any
157 other cameras will get the first free 157 other cameras will get the first free
158 available slot (see below). 158 available slot (see below).
159 159
160 dev_hint=645:1,680:2 The PCA645 camera will get /dev/video1, 160 dev_hint=645:1,680:2 The PCA645 camera will get /dev/video1,
161 and a PCVC680 /dev/video2. 161 and a PCVC680 /dev/video2.
162 162
163 dev_hint=645.0123:3,645.4567:0 The PCA645 camera with serialnumber 163 dev_hint=645.0123:3,645.4567:0 The PCA645 camera with serialnumber
164 0123 goes to /dev/video3, the same 164 0123 goes to /dev/video3, the same
165 camera model with the 4567 serial 165 camera model with the 4567 serial
166 gets /dev/video0. 166 gets /dev/video0.
167 167
168 dev_hint=750:1,4,5,6 The PCVC750 camera will get /dev/video1, the 168 dev_hint=750:1,4,5,6 The PCVC750 camera will get /dev/video1, the
169 next 3 Philips cams will use /dev/video4 169 next 3 Philips cams will use /dev/video4
170 through /dev/video6. 170 through /dev/video6.
171 171
172 Some points worth knowing: 172 Some points worth knowing:
173 - Serialnumbers are case sensitive and must be written full, including 173 - Serialnumbers are case sensitive and must be written full, including
174 leading zeroes (it's treated as a string). 174 leading zeroes (it's treated as a string).
175 - If a device node is already occupied, registration will fail and 175 - If a device node is already occupied, registration will fail and
176 the webcam is not available. 176 the webcam is not available.
177 - You can have up to 64 video devices; be sure to make enough device 177 - You can have up to 64 video devices; be sure to make enough device
178 nodes in /dev if you want to spread the numbers (this does not apply 178 nodes in /dev if you want to spread the numbers (this does not apply
@@ -186,13 +186,13 @@ trace
186 kernel log at debug level. 186 kernel log at debug level.
187 187
188 The trace variable is a bitmask; each bit represents a certain feature. 188 The trace variable is a bitmask; each bit represents a certain feature.
189 If you want to trace something, look up the bit value(s) in the table 189 If you want to trace something, look up the bit value(s) in the table
190 below, add the values together and supply that to the trace variable. 190 below, add the values together and supply that to the trace variable.
191 191
192 Value Value Description Default 192 Value Value Description Default
193 (dec) (hex) 193 (dec) (hex)
194 1 0x1 Module initialization; this will log messages On 194 1 0x1 Module initialization; this will log messages On
195 while loading and unloading the module 195 while loading and unloading the module
196 196
197 2 0x2 probe() and disconnect() traces On 197 2 0x2 probe() and disconnect() traces On
198 198
@@ -203,7 +203,7 @@ trace
203 16 0x10 Memory allocation of buffers, etc. Off 203 16 0x10 Memory allocation of buffers, etc. Off
204 204
205 32 0x20 Showing underflow, overflow and Dumping frame On 205 32 0x20 Showing underflow, overflow and Dumping frame On
206 messages 206 messages
207 207
208 64 0x40 Show viewport and image sizes Off 208 64 0x40 Show viewport and image sizes Off
209 209
@@ -217,7 +217,7 @@ trace
217 217
218 218
219Example: 219Example:
220 220
221 # modprobe pwc size=cif fps=15 power_save=1 221 # modprobe pwc size=cif fps=15 power_save=1
222 222
223The fbufs, mbufs and trace parameters are global and apply to all connected 223The fbufs, mbufs and trace parameters are global and apply to all connected
diff --git a/drivers/media/video/pwc/pwc-ctrl.c b/drivers/media/video/pwc/pwc-ctrl.c
index 0398b812e0ce..4ba549bfa0e0 100644
--- a/drivers/media/video/pwc/pwc-ctrl.c
+++ b/drivers/media/video/pwc/pwc-ctrl.c
@@ -31,17 +31,17 @@
31 31
32/* 32/*
33 Changes 33 Changes
34 2001/08/03 Alvarado Added methods for changing white balance and 34 2001/08/03 Alvarado Added methods for changing white balance and
35 red/green gains 35 red/green gains
36 */ 36 */
37 37
38/* Control functions for the cam; brightness, contrast, video mode, etc. */ 38/* Control functions for the cam; brightness, contrast, video mode, etc. */
39 39
40#ifdef __KERNEL__ 40#ifdef __KERNEL__
41#include <asm/uaccess.h> 41#include <asm/uaccess.h>
42#endif 42#endif
43#include <asm/errno.h> 43#include <asm/errno.h>
44 44
45#include "pwc.h" 45#include "pwc.h"
46#include "pwc-ioctl.h" 46#include "pwc-ioctl.h"
47#include "pwc-uncompress.h" 47#include "pwc-uncompress.h"
@@ -116,13 +116,13 @@ static const char *size2name[PSZ_MAX] =
116 "SIF", 116 "SIF",
117 "CIF", 117 "CIF",
118 "VGA", 118 "VGA",
119}; 119};
120 120
121/********/ 121/********/
122 122
123/* Entries for the Nala (645/646) camera; the Nala doesn't have compression 123/* Entries for the Nala (645/646) camera; the Nala doesn't have compression
124 preferences, so you either get compressed or non-compressed streams. 124 preferences, so you either get compressed or non-compressed streams.
125 125
126 An alternate value of 0 means this mode is not available at all. 126 An alternate value of 0 means this mode is not available at all.
127 */ 127 */
128 128
@@ -205,13 +205,13 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
205 { /* closest match of framerate */ 205 { /* closest match of framerate */
206 0, 0, 0, 0, 4, /* 0-4 */ 206 0, 0, 0, 0, 4, /* 0-4 */
207 5, 5, 7, 7, 10, /* 5-9 */ 207 5, 5, 7, 7, 10, /* 5-9 */
208 10, 10, 12, 12, 15, /* 10-14 */ 208 10, 10, 12, 12, 15, /* 10-14 */
209 15, 15, 15, 20, 20, /* 15-19 */ 209 15, 15, 15, 20, 20, /* 15-19 */
210 20, 20, 20, 24, 24, /* 20-24 */ 210 20, 20, 20, 24, 24, /* 20-24 */
211 24, 24, 24, 24, 24, /* 25-29 */ 211 24, 24, 24, 24, 24, /* 25-29 */
212 24 /* 30 */ 212 24 /* 30 */
213 }; 213 };
214 int frames2table[31] = 214 int frames2table[31] =
215 { 0, 0, 0, 0, 0, /* 0-4 */ 215 { 0, 0, 0, 0, 0, /* 0-4 */
216 1, 1, 1, 2, 2, /* 5-9 */ 216 1, 1, 1, 2, 2, /* 5-9 */
217 3, 3, 4, 4, 4, /* 10-14 */ 217 3, 3, 4, 4, 4, /* 10-14 */
@@ -220,7 +220,7 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
220 7, 7, 7, 7, 7, /* 25-29 */ 220 7, 7, 7, 7, 7, /* 25-29 */
221 7 /* 30 */ 221 7 /* 30 */
222 }; 222 };
223 223
224 if (size < 0 || size > PSZ_CIF || frames < 4 || frames > 25) 224 if (size < 0 || size > PSZ_CIF || frames < 4 || frames > 25)
225 return -EINVAL; 225 return -EINVAL;
226 frames = frames2frames[frames]; 226 frames = frames2frames[frames];
@@ -232,7 +232,7 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
232 if (pEntry->compressed) 232 if (pEntry->compressed)
233 return -ENOENT; /* Not supported. */ 233 return -ENOENT; /* Not supported. */
234 234
235 memcpy(buf, pEntry->mode, 3); 235 memcpy(buf, pEntry->mode, 3);
236 ret = send_video_command(pdev->udev, pdev->vendpoint, buf, 3); 236 ret = send_video_command(pdev->udev, pdev->vendpoint, buf, 3);
237 if (ret < 0) { 237 if (ret < 0) {
238 Debug("Failed to send video command... %d\n", ret); 238 Debug("Failed to send video command... %d\n", ret);
@@ -257,7 +257,7 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
257 break; 257 break;
258 } 258 }
259 } 259 }
260 260
261 pdev->cmd_len = 3; 261 pdev->cmd_len = 3;
262 memcpy(pdev->cmd_buf, buf, 3); 262 memcpy(pdev->cmd_buf, buf, 3);
263 263
@@ -352,13 +352,13 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
352 /* special case: VGA @ 5 fps and snapshot is raw bayer mode */ 352 /* special case: VGA @ 5 fps and snapshot is raw bayer mode */
353 if (size == PSZ_VGA && frames == 5 && snapshot) 353 if (size == PSZ_VGA && frames == 5 && snapshot)
354 { 354 {
355 /* Only available in case the raw palette is selected or 355 /* Only available in case the raw palette is selected or
356 we have the decompressor available. This mode is 356 we have the decompressor available. This mode is
357 only available in compressed form 357 only available in compressed form
358 */ 358 */
359 if (pdev->vpalette == VIDEO_PALETTE_RAW) 359 if (pdev->vpalette == VIDEO_PALETTE_RAW)
360 { 360 {
361 Info("Choosing VGA/5 BAYER mode (%d).\n", pdev->vpalette); 361 Info("Choosing VGA/5 BAYER mode (%d).\n", pdev->vpalette);
362 pChoose = &RawEntry; 362 pChoose = &RawEntry;
363 } 363 }
364 else 364 else
@@ -368,9 +368,9 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
368 } 368 }
369 else 369 else
370 { 370 {
371 /* Find a supported framerate with progressively higher compression ratios 371 /* Find a supported framerate with progressively higher compression ratios
372 if the preferred ratio is not available. 372 if the preferred ratio is not available.
373 Skip this step when using RAW modes. 373 Skip this step when using RAW modes.
374 */ 374 */
375 while (compression <= 3) { 375 while (compression <= 3) {
376 pChoose = &Kiara_table[size][fps][compression]; 376 pChoose = &Kiara_table[size][fps][compression];
@@ -383,7 +383,7 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
383 return -ENOENT; /* Not supported. */ 383 return -ENOENT; /* Not supported. */
384 384
385 Debug("Using alternate setting %d.\n", pChoose->alternate); 385 Debug("Using alternate setting %d.\n", pChoose->alternate);
386 386
387 /* usb_control_msg won't take staticly allocated arrays as argument?? */ 387 /* usb_control_msg won't take staticly allocated arrays as argument?? */
388 memcpy(buf, pChoose->mode, 12); 388 memcpy(buf, pChoose->mode, 12);
389 if (snapshot) 389 if (snapshot)
@@ -463,9 +463,9 @@ static void pwc_set_image_buffer_size(struct pwc_device *pdev)
463 */ 463 */
464int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot) 464int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot)
465{ 465{
466 int ret, size; 466 int ret, size;
467 467
468 Trace(TRACE_FLOW, "set_video_mode(%dx%d @ %d, palette %d).\n", width, height, frames, pdev->vpalette); 468 Trace(TRACE_FLOW, "set_video_mode(%dx%d @ %d, palette %d).\n", width, height, frames, pdev->vpalette);
469 size = pwc_decode_size(pdev, width, height); 469 size = pwc_decode_size(pdev, width, height);
470 if (size < 0) { 470 if (size < 0) {
471 Debug("Could not find suitable size.\n"); 471 Debug("Could not find suitable size.\n");
@@ -473,7 +473,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
473 } 473 }
474 Debug("decode_size = %d.\n", size); 474 Debug("decode_size = %d.\n", size);
475 475
476 ret = -EINVAL; 476 ret = -EINVAL;
477 switch(pdev->type) { 477 switch(pdev->type) {
478 case 645: 478 case 645:
479 case 646: 479 case 646:
@@ -485,7 +485,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
485 case 690: 485 case 690:
486 ret = set_video_mode_Timon(pdev, size, frames, compression, snapshot); 486 ret = set_video_mode_Timon(pdev, size, frames, compression, snapshot);
487 break; 487 break;
488 488
489 case 720: 489 case 720:
490 case 730: 490 case 730:
491 case 740: 491 case 740:
@@ -517,7 +517,7 @@ int pwc_get_brightness(struct pwc_device *pdev)
517 char buf; 517 char buf;
518 int ret; 518 int ret;
519 519
520 ret = RecvControlMsg(GET_LUM_CTL, BRIGHTNESS_FORMATTER, 1); 520 ret = RecvControlMsg(GET_LUM_CTL, BRIGHTNESS_FORMATTER, 1);
521 if (ret < 0) 521 if (ret < 0)
522 return ret; 522 return ret;
523 return buf << 9; 523 return buf << 9;
@@ -566,7 +566,7 @@ int pwc_get_gamma(struct pwc_device *pdev)
566{ 566{
567 char buf; 567 char buf;
568 int ret; 568 int ret;
569 569
570 ret = RecvControlMsg(GET_LUM_CTL, GAMMA_FORMATTER, 1); 570 ret = RecvControlMsg(GET_LUM_CTL, GAMMA_FORMATTER, 1);
571 if (ret < 0) 571 if (ret < 0)
572 return ret; 572 return ret;
@@ -622,14 +622,14 @@ static inline int pwc_set_agc(struct pwc_device *pdev, int mode, int value)
622{ 622{
623 char buf; 623 char buf;
624 int ret; 624 int ret;
625 625
626 if (mode) 626 if (mode)
627 buf = 0x0; /* auto */ 627 buf = 0x0; /* auto */
628 else 628 else
629 buf = 0xff; /* fixed */ 629 buf = 0xff; /* fixed */
630 630
631 ret = SendControlMsg(SET_LUM_CTL, AGC_MODE_FORMATTER, 1); 631 ret = SendControlMsg(SET_LUM_CTL, AGC_MODE_FORMATTER, 1);
632 632
633 if (!mode && ret >= 0) { 633 if (!mode && ret >= 0) {
634 if (value < 0) 634 if (value < 0)
635 value = 0; 635 value = 0;
@@ -647,7 +647,7 @@ static inline int pwc_get_agc(struct pwc_device *pdev, int *value)
647{ 647{
648 unsigned char buf; 648 unsigned char buf;
649 int ret; 649 int ret;
650 650
651 ret = RecvControlMsg(GET_LUM_CTL, AGC_MODE_FORMATTER, 1); 651 ret = RecvControlMsg(GET_LUM_CTL, AGC_MODE_FORMATTER, 1);
652 if (ret < 0) 652 if (ret < 0)
653 return ret; 653 return ret;
@@ -658,7 +658,7 @@ static inline int pwc_get_agc(struct pwc_device *pdev, int *value)
658 return ret; 658 return ret;
659 if (buf > 0x3F) 659 if (buf > 0x3F)
660 buf = 0x3F; 660 buf = 0x3F;
661 *value = (buf << 10); 661 *value = (buf << 10);
662 } 662 }
663 else { /* auto */ 663 else { /* auto */
664 ret = RecvControlMsg(GET_STATUS_CTL, READ_AGC_FORMATTER, 1); 664 ret = RecvControlMsg(GET_STATUS_CTL, READ_AGC_FORMATTER, 1);
@@ -683,7 +683,7 @@ static inline int pwc_set_shutter_speed(struct pwc_device *pdev, int mode, int v
683 buf[0] = 0x0; /* auto */ 683 buf[0] = 0x0; /* auto */
684 else 684 else
685 buf[0] = 0xff; /* fixed */ 685 buf[0] = 0xff; /* fixed */
686 686
687 ret = SendControlMsg(SET_LUM_CTL, SHUTTER_MODE_FORMATTER, 1); 687 ret = SendControlMsg(SET_LUM_CTL, SHUTTER_MODE_FORMATTER, 1);
688 688
689 if (!mode && ret >= 0) { 689 if (!mode && ret >= 0) {
@@ -713,7 +713,7 @@ static inline int pwc_set_shutter_speed(struct pwc_device *pdev, int mode, int v
713 ret = SendControlMsg(SET_LUM_CTL, PRESET_SHUTTER_FORMATTER, 2); 713 ret = SendControlMsg(SET_LUM_CTL, PRESET_SHUTTER_FORMATTER, 2);
714 } 714 }
715 return ret; 715 return ret;
716} 716}
717 717
718 718
719/* POWER */ 719/* POWER */
@@ -765,22 +765,22 @@ static inline int pwc_restore_factory(struct pwc_device *pdev)
765 * 02: fluorescent lighting 765 * 02: fluorescent lighting
766 * 03: manual 766 * 03: manual
767 * 04: auto 767 * 04: auto
768 */ 768 */
769static inline int pwc_set_awb(struct pwc_device *pdev, int mode) 769static inline int pwc_set_awb(struct pwc_device *pdev, int mode)
770{ 770{
771 char buf; 771 char buf;
772 int ret; 772 int ret;
773 773
774 if (mode < 0) 774 if (mode < 0)
775 mode = 0; 775 mode = 0;
776 776
777 if (mode > 4) 777 if (mode > 4)
778 mode = 4; 778 mode = 4;
779 779
780 buf = mode & 0x07; /* just the lowest three bits */ 780 buf = mode & 0x07; /* just the lowest three bits */
781 781
782 ret = SendControlMsg(SET_CHROM_CTL, WB_MODE_FORMATTER, 1); 782 ret = SendControlMsg(SET_CHROM_CTL, WB_MODE_FORMATTER, 1);
783 783
784 if (ret < 0) 784 if (ret < 0)
785 return ret; 785 return ret;
786 return 0; 786 return 0;
@@ -790,17 +790,17 @@ static inline int pwc_get_awb(struct pwc_device *pdev)
790{ 790{
791 unsigned char buf; 791 unsigned char buf;
792 int ret; 792 int ret;
793 793
794 ret = RecvControlMsg(GET_CHROM_CTL, WB_MODE_FORMATTER, 1); 794 ret = RecvControlMsg(GET_CHROM_CTL, WB_MODE_FORMATTER, 1);
795 795
796 if (ret < 0) 796 if (ret < 0)
797 return ret; 797 return ret;
798 return buf; 798 return buf;
799} 799}
800 800
801static inline int pwc_set_red_gain(struct pwc_device *pdev, int value) 801static inline int pwc_set_red_gain(struct pwc_device *pdev, int value)
802{ 802{
803 unsigned char buf; 803 unsigned char buf;
804 804
805 if (value < 0) 805 if (value < 0)
806 value = 0; 806 value = 0;
@@ -815,7 +815,7 @@ static inline int pwc_get_red_gain(struct pwc_device *pdev, int *value)
815{ 815{
816 unsigned char buf; 816 unsigned char buf;
817 int ret; 817 int ret;
818 818
819 ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_RED_GAIN_FORMATTER, 1); 819 ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_RED_GAIN_FORMATTER, 1);
820 if (ret < 0) 820 if (ret < 0)
821 return ret; 821 return ret;
@@ -841,7 +841,7 @@ static inline int pwc_get_blue_gain(struct pwc_device *pdev, int *value)
841{ 841{
842 unsigned char buf; 842 unsigned char buf;
843 int ret; 843 int ret;
844 844
845 ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_BLUE_GAIN_FORMATTER, 1); 845 ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_BLUE_GAIN_FORMATTER, 1);
846 if (ret < 0) 846 if (ret < 0)
847 return ret; 847 return ret;
@@ -851,14 +851,14 @@ static inline int pwc_get_blue_gain(struct pwc_device *pdev, int *value)
851 851
852 852
853/* The following two functions are different, since they only read the 853/* The following two functions are different, since they only read the
854 internal red/blue gains, which may be different from the manual 854 internal red/blue gains, which may be different from the manual
855 gains set or read above. 855 gains set or read above.
856 */ 856 */
857static inline int pwc_read_red_gain(struct pwc_device *pdev, int *value) 857static inline int pwc_read_red_gain(struct pwc_device *pdev, int *value)
858{ 858{
859 unsigned char buf; 859 unsigned char buf;
860 int ret; 860 int ret;
861 861
862 ret = RecvControlMsg(GET_STATUS_CTL, READ_RED_GAIN_FORMATTER, 1); 862 ret = RecvControlMsg(GET_STATUS_CTL, READ_RED_GAIN_FORMATTER, 1);
863 if (ret < 0) 863 if (ret < 0)
864 return ret; 864 return ret;
@@ -870,7 +870,7 @@ static inline int pwc_read_blue_gain(struct pwc_device *pdev, int *value)
870{ 870{
871 unsigned char buf; 871 unsigned char buf;
872 int ret; 872 int ret;
873 873
874 ret = RecvControlMsg(GET_STATUS_CTL, READ_BLUE_GAIN_FORMATTER, 1); 874 ret = RecvControlMsg(GET_STATUS_CTL, READ_BLUE_GAIN_FORMATTER, 1);
875 if (ret < 0) 875 if (ret < 0)
876 return ret; 876 return ret;
@@ -882,7 +882,7 @@ static inline int pwc_read_blue_gain(struct pwc_device *pdev, int *value)
882static inline int pwc_set_wb_speed(struct pwc_device *pdev, int speed) 882static inline int pwc_set_wb_speed(struct pwc_device *pdev, int speed)
883{ 883{
884 unsigned char buf; 884 unsigned char buf;
885 885
886 /* useful range is 0x01..0x20 */ 886 /* useful range is 0x01..0x20 */
887 buf = speed / 0x7f0; 887 buf = speed / 0x7f0;
888 return SendControlMsg(SET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1); 888 return SendControlMsg(SET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1);
@@ -892,7 +892,7 @@ static inline int pwc_get_wb_speed(struct pwc_device *pdev, int *value)
892{ 892{
893 unsigned char buf; 893 unsigned char buf;
894 int ret; 894 int ret;
895 895
896 ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1); 896 ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1);
897 if (ret < 0) 897 if (ret < 0)
898 return ret; 898 return ret;
@@ -904,7 +904,7 @@ static inline int pwc_get_wb_speed(struct pwc_device *pdev, int *value)
904static inline int pwc_set_wb_delay(struct pwc_device *pdev, int delay) 904static inline int pwc_set_wb_delay(struct pwc_device *pdev, int delay)
905{ 905{
906 unsigned char buf; 906 unsigned char buf;
907 907
908 /* useful range is 0x01..0x3F */ 908 /* useful range is 0x01..0x3F */
909 buf = (delay >> 10); 909 buf = (delay >> 10);
910 return SendControlMsg(SET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1); 910 return SendControlMsg(SET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1);
@@ -914,7 +914,7 @@ static inline int pwc_get_wb_delay(struct pwc_device *pdev, int *value)
914{ 914{
915 unsigned char buf; 915 unsigned char buf;
916 int ret; 916 int ret;
917 917
918 ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1); 918 ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1);
919 if (ret < 0) 919 if (ret < 0)
920 return ret; 920 return ret;
@@ -950,7 +950,7 @@ static int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value)
950{ 950{
951 unsigned char buf[2]; 951 unsigned char buf[2];
952 int ret; 952 int ret;
953 953
954 if (pdev->type < 730) { 954 if (pdev->type < 730) {
955 *on_value = -1; 955 *on_value = -1;
956 *off_value = -1; 956 *off_value = -1;
@@ -969,7 +969,7 @@ static inline int pwc_set_contour(struct pwc_device *pdev, int contour)
969{ 969{
970 unsigned char buf; 970 unsigned char buf;
971 int ret; 971 int ret;
972 972
973 if (contour < 0) 973 if (contour < 0)
974 buf = 0xff; /* auto contour on */ 974 buf = 0xff; /* auto contour on */
975 else 975 else
@@ -977,16 +977,16 @@ static inline int pwc_set_contour(struct pwc_device *pdev, int contour)
977 ret = SendControlMsg(SET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1); 977 ret = SendControlMsg(SET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1);
978 if (ret < 0) 978 if (ret < 0)
979 return ret; 979 return ret;
980 980
981 if (contour < 0) 981 if (contour < 0)
982 return 0; 982 return 0;
983 if (contour > 0xffff) 983 if (contour > 0xffff)
984 contour = 0xffff; 984 contour = 0xffff;
985 985
986 buf = (contour >> 10); /* contour preset is [0..3f] */ 986 buf = (contour >> 10); /* contour preset is [0..3f] */
987 ret = SendControlMsg(SET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1); 987 ret = SendControlMsg(SET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1);
988 if (ret < 0) 988 if (ret < 0)
989 return ret; 989 return ret;
990 return 0; 990 return 0;
991} 991}
992 992
@@ -994,7 +994,7 @@ static inline int pwc_get_contour(struct pwc_device *pdev, int *contour)
994{ 994{
995 unsigned char buf; 995 unsigned char buf;
996 int ret; 996 int ret;
997 997
998 ret = RecvControlMsg(GET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1); 998 ret = RecvControlMsg(GET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1);
999 if (ret < 0) 999 if (ret < 0)
1000 return ret; 1000 return ret;
@@ -1002,7 +1002,7 @@ static inline int pwc_get_contour(struct pwc_device *pdev, int *contour)
1002 if (buf == 0) { 1002 if (buf == 0) {
1003 /* auto mode off, query current preset value */ 1003 /* auto mode off, query current preset value */
1004 ret = RecvControlMsg(GET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1); 1004 ret = RecvControlMsg(GET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1);
1005 if (ret < 0) 1005 if (ret < 0)
1006 return ret; 1006 return ret;
1007 *contour = buf << 10; 1007 *contour = buf << 10;
1008 } 1008 }
@@ -1015,7 +1015,7 @@ static inline int pwc_get_contour(struct pwc_device *pdev, int *contour)
1015static inline int pwc_set_backlight(struct pwc_device *pdev, int backlight) 1015static inline int pwc_set_backlight(struct pwc_device *pdev, int backlight)
1016{ 1016{
1017 unsigned char buf; 1017 unsigned char buf;
1018 1018
1019 if (backlight) 1019 if (backlight)
1020 buf = 0xff; 1020 buf = 0xff;
1021 else 1021 else
@@ -1027,7 +1027,7 @@ static inline int pwc_get_backlight(struct pwc_device *pdev, int *backlight)
1027{ 1027{
1028 int ret; 1028 int ret;
1029 unsigned char buf; 1029 unsigned char buf;
1030 1030
1031 ret = RecvControlMsg(GET_LUM_CTL, BACK_LIGHT_COMPENSATION_FORMATTER, 1); 1031 ret = RecvControlMsg(GET_LUM_CTL, BACK_LIGHT_COMPENSATION_FORMATTER, 1);
1032 if (ret < 0) 1032 if (ret < 0)
1033 return ret; 1033 return ret;
@@ -1039,7 +1039,7 @@ static inline int pwc_get_backlight(struct pwc_device *pdev, int *backlight)
1039static inline int pwc_set_flicker(struct pwc_device *pdev, int flicker) 1039static inline int pwc_set_flicker(struct pwc_device *pdev, int flicker)
1040{ 1040{
1041 unsigned char buf; 1041 unsigned char buf;
1042 1042
1043 if (flicker) 1043 if (flicker)
1044 buf = 0xff; 1044 buf = 0xff;
1045 else 1045 else
@@ -1051,7 +1051,7 @@ static inline int pwc_get_flicker(struct pwc_device *pdev, int *flicker)
1051{ 1051{
1052 int ret; 1052 int ret;
1053 unsigned char buf; 1053 unsigned char buf;
1054 1054
1055 ret = RecvControlMsg(GET_LUM_CTL, FLICKERLESS_MODE_FORMATTER, 1); 1055 ret = RecvControlMsg(GET_LUM_CTL, FLICKERLESS_MODE_FORMATTER, 1);
1056 if (ret < 0) 1056 if (ret < 0)
1057 return ret; 1057 return ret;
@@ -1076,7 +1076,7 @@ static inline int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise)
1076{ 1076{
1077 int ret; 1077 int ret;
1078 unsigned char buf; 1078 unsigned char buf;
1079 1079
1080 ret = RecvControlMsg(GET_LUM_CTL, DYNAMIC_NOISE_CONTROL_FORMATTER, 1); 1080 ret = RecvControlMsg(GET_LUM_CTL, DYNAMIC_NOISE_CONTROL_FORMATTER, 1);
1081 if (ret < 0) 1081 if (ret < 0)
1082 return ret; 1082 return ret;
@@ -1087,7 +1087,7 @@ static inline int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise)
1087static int pwc_mpt_reset(struct pwc_device *pdev, int flags) 1087static int pwc_mpt_reset(struct pwc_device *pdev, int flags)
1088{ 1088{
1089 unsigned char buf; 1089 unsigned char buf;
1090 1090
1091 buf = flags & 0x03; // only lower two bits are currently used 1091 buf = flags & 0x03; // only lower two bits are currently used
1092 return SendControlMsg(SET_MPT_CTL, PT_RESET_CONTROL_FORMATTER, 1); 1092 return SendControlMsg(SET_MPT_CTL, PT_RESET_CONTROL_FORMATTER, 1);
1093} 1093}
@@ -1095,7 +1095,7 @@ static int pwc_mpt_reset(struct pwc_device *pdev, int flags)
1095static inline int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt) 1095static inline int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt)
1096{ 1096{
1097 unsigned char buf[4]; 1097 unsigned char buf[4];
1098 1098
1099 /* set new relative angle; angles are expressed in degrees * 100, 1099 /* set new relative angle; angles are expressed in degrees * 100,
1100 but cam as .5 degree resolution, hence divide by 200. Also 1100 but cam as .5 degree resolution, hence divide by 200. Also
1101 the angle must be multiplied by 64 before it's send to 1101 the angle must be multiplied by 64 before it's send to
@@ -1114,7 +1114,7 @@ static inline int pwc_mpt_get_status(struct pwc_device *pdev, struct pwc_mpt_sta
1114{ 1114{
1115 int ret; 1115 int ret;
1116 unsigned char buf[5]; 1116 unsigned char buf[5];
1117 1117
1118 ret = RecvControlMsg(GET_MPT_CTL, PT_STATUS_FORMATTER, 5); 1118 ret = RecvControlMsg(GET_MPT_CTL, PT_STATUS_FORMATTER, 5);
1119 if (ret < 0) 1119 if (ret < 0)
1120 return ret; 1120 return ret;
@@ -1129,14 +1129,14 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
1129{ 1129{
1130 unsigned char buf; 1130 unsigned char buf;
1131 int ret = -1, request; 1131 int ret = -1, request;
1132 1132
1133 if (pdev->type < 675) 1133 if (pdev->type < 675)
1134 request = SENSOR_TYPE_FORMATTER1; 1134 request = SENSOR_TYPE_FORMATTER1;
1135 else if (pdev->type < 730) 1135 else if (pdev->type < 730)
1136 return -1; /* The Vesta series doesn't have this call */ 1136 return -1; /* The Vesta series doesn't have this call */
1137 else 1137 else
1138 request = SENSOR_TYPE_FORMATTER2; 1138 request = SENSOR_TYPE_FORMATTER2;
1139 1139
1140 ret = RecvControlMsg(GET_STATUS_CTL, request, 1); 1140 ret = RecvControlMsg(GET_STATUS_CTL, request, 1);
1141 if (ret < 0) 1141 if (ret < 0)
1142 return ret; 1142 return ret;
@@ -1163,23 +1163,23 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1163 ret = -EINVAL; 1163 ret = -EINVAL;
1164 break; 1164 break;
1165 } 1165 }
1166 1166
1167 case VIDIOCPWCSUSER: 1167 case VIDIOCPWCSUSER:
1168 { 1168 {
1169 if (pwc_save_user(pdev)) 1169 if (pwc_save_user(pdev))
1170 ret = -EINVAL; 1170 ret = -EINVAL;
1171 break; 1171 break;
1172 } 1172 }
1173 1173
1174 case VIDIOCPWCFACTORY: 1174 case VIDIOCPWCFACTORY:
1175 { 1175 {
1176 if (pwc_restore_factory(pdev)) 1176 if (pwc_restore_factory(pdev))
1177 ret = -EINVAL; 1177 ret = -EINVAL;
1178 break; 1178 break;
1179 } 1179 }
1180 1180
1181 case VIDIOCPWCSCQUAL: 1181 case VIDIOCPWCSCQUAL:
1182 { 1182 {
1183 int *qual = arg; 1183 int *qual = arg;
1184 1184
1185 if (*qual < 0 || *qual > 3) 1185 if (*qual < 0 || *qual > 3)
@@ -1190,14 +1190,14 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1190 pdev->vcompression = *qual; 1190 pdev->vcompression = *qual;
1191 break; 1191 break;
1192 } 1192 }
1193 1193
1194 case VIDIOCPWCGCQUAL: 1194 case VIDIOCPWCGCQUAL:
1195 { 1195 {
1196 int *qual = arg; 1196 int *qual = arg;
1197 *qual = pdev->vcompression; 1197 *qual = pdev->vcompression;
1198 break; 1198 break;
1199 } 1199 }
1200 1200
1201 case VIDIOCPWCPROBE: 1201 case VIDIOCPWCPROBE:
1202 { 1202 {
1203 struct pwc_probe *probe = arg; 1203 struct pwc_probe *probe = arg;
@@ -1220,27 +1220,27 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1220 ret = -EINVAL; 1220 ret = -EINVAL;
1221 break; 1221 break;
1222 } 1222 }
1223 1223
1224 case VIDIOCPWCGAGC: 1224 case VIDIOCPWCGAGC:
1225 { 1225 {
1226 int *agc = arg; 1226 int *agc = arg;
1227 1227
1228 if (pwc_get_agc(pdev, agc)) 1228 if (pwc_get_agc(pdev, agc))
1229 ret = -EINVAL; 1229 ret = -EINVAL;
1230 break; 1230 break;
1231 } 1231 }
1232 1232
1233 case VIDIOCPWCSSHUTTER: 1233 case VIDIOCPWCSSHUTTER:
1234 { 1234 {
1235 int *shutter_speed = arg; 1235 int *shutter_speed = arg;
1236 ret = pwc_set_shutter_speed(pdev, *shutter_speed < 0 ? 1 : 0, *shutter_speed); 1236 ret = pwc_set_shutter_speed(pdev, *shutter_speed < 0 ? 1 : 0, *shutter_speed);
1237 break; 1237 break;
1238 } 1238 }
1239 1239
1240 case VIDIOCPWCSAWB: 1240 case VIDIOCPWCSAWB:
1241 { 1241 {
1242 struct pwc_whitebalance *wb = arg; 1242 struct pwc_whitebalance *wb = arg;
1243 1243
1244 ret = pwc_set_awb(pdev, wb->mode); 1244 ret = pwc_set_awb(pdev, wb->mode);
1245 if (ret >= 0 && wb->mode == PWC_WB_MANUAL) { 1245 if (ret >= 0 && wb->mode == PWC_WB_MANUAL) {
1246 pwc_set_red_gain(pdev, wb->manual_red); 1246 pwc_set_red_gain(pdev, wb->manual_red);
@@ -1270,18 +1270,18 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1270 ret = pwc_read_red_gain(pdev, &wb->read_red); 1270 ret = pwc_read_red_gain(pdev, &wb->read_red);
1271 if (ret < 0) 1271 if (ret < 0)
1272 break; 1272 break;
1273 ret = pwc_read_blue_gain(pdev, &wb->read_blue); 1273 ret = pwc_read_blue_gain(pdev, &wb->read_blue);
1274 if (ret < 0) 1274 if (ret < 0)
1275 break; 1275 break;
1276 } 1276 }
1277 } 1277 }
1278 break; 1278 break;
1279 } 1279 }
1280 1280
1281 case VIDIOCPWCSAWBSPEED: 1281 case VIDIOCPWCSAWBSPEED:
1282 { 1282 {
1283 struct pwc_wb_speed *wbs = arg; 1283 struct pwc_wb_speed *wbs = arg;
1284 1284
1285 if (wbs->control_speed > 0) { 1285 if (wbs->control_speed > 0) {
1286 ret = pwc_set_wb_speed(pdev, wbs->control_speed); 1286 ret = pwc_set_wb_speed(pdev, wbs->control_speed);
1287 } 1287 }
@@ -1290,11 +1290,11 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1290 } 1290 }
1291 break; 1291 break;
1292 } 1292 }
1293 1293
1294 case VIDIOCPWCGAWBSPEED: 1294 case VIDIOCPWCGAWBSPEED:
1295 { 1295 {
1296 struct pwc_wb_speed *wbs = arg; 1296 struct pwc_wb_speed *wbs = arg;
1297 1297
1298 ret = pwc_get_wb_speed(pdev, &wbs->control_speed); 1298 ret = pwc_get_wb_speed(pdev, &wbs->control_speed);
1299 if (ret < 0) 1299 if (ret < 0)
1300 break; 1300 break;
@@ -1304,7 +1304,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1304 break; 1304 break;
1305 } 1305 }
1306 1306
1307 case VIDIOCPWCSLED: 1307 case VIDIOCPWCSLED:
1308 { 1308 {
1309 struct pwc_leds *leds = arg; 1309 struct pwc_leds *leds = arg;
1310 ret = pwc_set_leds(pdev, leds->led_on, leds->led_off); 1310 ret = pwc_set_leds(pdev, leds->led_on, leds->led_off);
@@ -1325,14 +1325,14 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1325 ret = pwc_set_contour(pdev, *contour); 1325 ret = pwc_set_contour(pdev, *contour);
1326 break; 1326 break;
1327 } 1327 }
1328 1328
1329 case VIDIOCPWCGCONTOUR: 1329 case VIDIOCPWCGCONTOUR:
1330 { 1330 {
1331 int *contour = arg; 1331 int *contour = arg;
1332 ret = pwc_get_contour(pdev, contour); 1332 ret = pwc_get_contour(pdev, contour);
1333 break; 1333 break;
1334 } 1334 }
1335 1335
1336 case VIDIOCPWCSBACKLIGHT: 1336 case VIDIOCPWCSBACKLIGHT:
1337 { 1337 {
1338 int *backlight = arg; 1338 int *backlight = arg;
@@ -1346,7 +1346,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1346 ret = pwc_get_backlight(pdev, backlight); 1346 ret = pwc_get_backlight(pdev, backlight);
1347 break; 1347 break;
1348 } 1348 }
1349 1349
1350 case VIDIOCPWCSFLICKER: 1350 case VIDIOCPWCSFLICKER:
1351 { 1351 {
1352 int *flicker = arg; 1352 int *flicker = arg;
@@ -1360,14 +1360,14 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1360 ret = pwc_get_flicker(pdev, flicker); 1360 ret = pwc_get_flicker(pdev, flicker);
1361 break; 1361 break;
1362 } 1362 }
1363 1363
1364 case VIDIOCPWCSDYNNOISE: 1364 case VIDIOCPWCSDYNNOISE:
1365 { 1365 {
1366 int *dynnoise = arg; 1366 int *dynnoise = arg;
1367 ret = pwc_set_dynamic_noise(pdev, *dynnoise); 1367 ret = pwc_set_dynamic_noise(pdev, *dynnoise);
1368 break; 1368 break;
1369 } 1369 }
1370 1370
1371 case VIDIOCPWCGDYNNOISE: 1371 case VIDIOCPWCGDYNNOISE:
1372 { 1372 {
1373 int *dynnoise = arg; 1373 int *dynnoise = arg;
@@ -1381,61 +1381,61 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1381 size->width = pdev->image.x; 1381 size->width = pdev->image.x;
1382 size->height = pdev->image.y; 1382 size->height = pdev->image.y;
1383 break; 1383 break;
1384 } 1384 }
1385 1385
1386 case VIDIOCPWCMPTRESET: 1386 case VIDIOCPWCMPTRESET:
1387 { 1387 {
1388 if (pdev->features & FEATURE_MOTOR_PANTILT) 1388 if (pdev->features & FEATURE_MOTOR_PANTILT)
1389 { 1389 {
1390 int *flags = arg; 1390 int *flags = arg;
1391 1391
1392 ret = pwc_mpt_reset(pdev, *flags); 1392 ret = pwc_mpt_reset(pdev, *flags);
1393 if (ret >= 0) 1393 if (ret >= 0)
1394 { 1394 {
1395 pdev->pan_angle = 0; 1395 pdev->pan_angle = 0;
1396 pdev->tilt_angle = 0; 1396 pdev->tilt_angle = 0;
1397 } 1397 }
1398 } 1398 }
1399 else 1399 else
1400 { 1400 {
1401 ret = -ENXIO; 1401 ret = -ENXIO;
1402 } 1402 }
1403 break; 1403 break;
1404 } 1404 }
1405 1405
1406 case VIDIOCPWCMPTGRANGE: 1406 case VIDIOCPWCMPTGRANGE:
1407 { 1407 {
1408 if (pdev->features & FEATURE_MOTOR_PANTILT) 1408 if (pdev->features & FEATURE_MOTOR_PANTILT)
1409 { 1409 {
1410 struct pwc_mpt_range *range = arg; 1410 struct pwc_mpt_range *range = arg;
1411 *range = pdev->angle_range; 1411 *range = pdev->angle_range;
1412 } 1412 }
1413 else 1413 else
1414 { 1414 {
1415 ret = -ENXIO; 1415 ret = -ENXIO;
1416 } 1416 }
1417 break; 1417 break;
1418 } 1418 }
1419 1419
1420 case VIDIOCPWCMPTSANGLE: 1420 case VIDIOCPWCMPTSANGLE:
1421 { 1421 {
1422 int new_pan, new_tilt; 1422 int new_pan, new_tilt;
1423 1423
1424 if (pdev->features & FEATURE_MOTOR_PANTILT) 1424 if (pdev->features & FEATURE_MOTOR_PANTILT)
1425 { 1425 {
1426 struct pwc_mpt_angles *angles = arg; 1426 struct pwc_mpt_angles *angles = arg;
1427 /* The camera can only set relative angles, so 1427 /* The camera can only set relative angles, so
1428 do some calculations when getting an absolute angle . 1428 do some calculations when getting an absolute angle .
1429 */ 1429 */
1430 if (angles->absolute) 1430 if (angles->absolute)
1431 { 1431 {
1432 new_pan = angles->pan; 1432 new_pan = angles->pan;
1433 new_tilt = angles->tilt; 1433 new_tilt = angles->tilt;
1434 } 1434 }
1435 else 1435 else
1436 { 1436 {
1437 new_pan = pdev->pan_angle + angles->pan; 1437 new_pan = pdev->pan_angle + angles->pan;
1438 new_tilt = pdev->tilt_angle + angles->tilt; 1438 new_tilt = pdev->tilt_angle + angles->tilt;
1439 } 1439 }
1440 /* check absolute ranges */ 1440 /* check absolute ranges */
1441 if (new_pan < pdev->angle_range.pan_min || 1441 if (new_pan < pdev->angle_range.pan_min ||
@@ -1463,53 +1463,53 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1463 pdev->tilt_angle += new_tilt; 1463 pdev->tilt_angle += new_tilt;
1464 } 1464 }
1465 if (ret == -EPIPE) /* stall -> out of range */ 1465 if (ret == -EPIPE) /* stall -> out of range */
1466 ret = -ERANGE; 1466 ret = -ERANGE;
1467 } 1467 }
1468 } 1468 }
1469 else 1469 else
1470 { 1470 {
1471 ret = -ENXIO; 1471 ret = -ENXIO;
1472 } 1472 }
1473 break; 1473 break;
1474 } 1474 }
1475 1475
1476 case VIDIOCPWCMPTGANGLE: 1476 case VIDIOCPWCMPTGANGLE:
1477 { 1477 {
1478 1478
1479 if (pdev->features & FEATURE_MOTOR_PANTILT) 1479 if (pdev->features & FEATURE_MOTOR_PANTILT)
1480 { 1480 {
1481 struct pwc_mpt_angles *angles = arg; 1481 struct pwc_mpt_angles *angles = arg;
1482 1482
1483 angles->absolute = 1; 1483 angles->absolute = 1;
1484 angles->pan = pdev->pan_angle; 1484 angles->pan = pdev->pan_angle;
1485 angles->tilt = pdev->tilt_angle; 1485 angles->tilt = pdev->tilt_angle;
1486 } 1486 }
1487 else 1487 else
1488 { 1488 {
1489 ret = -ENXIO; 1489 ret = -ENXIO;
1490 } 1490 }
1491 break; 1491 break;
1492 } 1492 }
1493 1493
1494 case VIDIOCPWCMPTSTATUS: 1494 case VIDIOCPWCMPTSTATUS:
1495 { 1495 {
1496 if (pdev->features & FEATURE_MOTOR_PANTILT) 1496 if (pdev->features & FEATURE_MOTOR_PANTILT)
1497 { 1497 {
1498 struct pwc_mpt_status *status = arg; 1498 struct pwc_mpt_status *status = arg;
1499 ret = pwc_mpt_get_status(pdev, status); 1499 ret = pwc_mpt_get_status(pdev, status);
1500 } 1500 }
1501 else 1501 else
1502 { 1502 {
1503 ret = -ENXIO; 1503 ret = -ENXIO;
1504 } 1504 }
1505 break; 1505 break;
1506 } 1506 }
1507 1507
1508 case VIDIOCPWCGVIDCMD: 1508 case VIDIOCPWCGVIDCMD:
1509 { 1509 {
1510 struct pwc_video_command *cmd = arg; 1510 struct pwc_video_command *cmd = arg;
1511 1511
1512 cmd->type = pdev->type; 1512 cmd->type = pdev->type;
1513 cmd->release = pdev->release; 1513 cmd->release = pdev->release;
1514 cmd->command_len = pdev->cmd_len; 1514 cmd->command_len = pdev->cmd_len;
1515 memcpy(&cmd->command_buf, pdev->cmd_buf, pdev->cmd_len); 1515 memcpy(&cmd->command_buf, pdev->cmd_buf, pdev->cmd_len);
@@ -1531,7 +1531,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1531 ret = -ENOIOCTLCMD; 1531 ret = -ENOIOCTLCMD;
1532 break; 1532 break;
1533 } 1533 }
1534 1534
1535 if (ret > 0) 1535 if (ret > 0)
1536 return 0; 1536 return 0;
1537 return ret; 1537 return ret;
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 90eb26042817..41418294a32b 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -25,18 +25,18 @@
25 25
26*/ 26*/
27 27
28/* 28/*
29 This code forms the interface between the USB layers and the Philips 29 This code forms the interface between the USB layers and the Philips
30 specific stuff. Some adanved stuff of the driver falls under an 30 specific stuff. Some adanved stuff of the driver falls under an
31 NDA, signed between me and Philips B.V., Eindhoven, the Netherlands, and 31 NDA, signed between me and Philips B.V., Eindhoven, the Netherlands, and
32 is thus not distributed in source form. The binary pwcx.o module 32 is thus not distributed in source form. The binary pwcx.o module
33 contains the code that falls under the NDA. 33 contains the code that falls under the NDA.
34 34
35 In case you're wondering: 'pwc' stands for "Philips WebCam", but 35 In case you're wondering: 'pwc' stands for "Philips WebCam", but
36 I really didn't want to type 'philips_web_cam' every time (I'm lazy as 36 I really didn't want to type 'philips_web_cam' every time (I'm lazy as
37 any Linux kernel hacker, but I don't like uncomprehensible abbreviations 37 any Linux kernel hacker, but I don't like uncomprehensible abbreviations
38 without explanation). 38 without explanation).
39 39
40 Oh yes, convention: to disctinguish between all the various pointers to 40 Oh yes, convention: to disctinguish between all the various pointers to
41 device-structures, I use these names for the pointer variables: 41 device-structures, I use these names for the pointer variables:
42 udev: struct usb_device * 42 udev: struct usb_device *
@@ -170,14 +170,14 @@ static struct video_device pwc_template = {
170 170
171/* Okay, this is some magic that I worked out and the reasoning behind it... 171/* Okay, this is some magic that I worked out and the reasoning behind it...
172 172
173 The biggest problem with any USB device is of course: "what to do 173 The biggest problem with any USB device is of course: "what to do
174 when the user unplugs the device while it is in use by an application?" 174 when the user unplugs the device while it is in use by an application?"
175 We have several options: 175 We have several options:
176 1) Curse them with the 7 plagues when they do (requires divine intervention) 176 1) Curse them with the 7 plagues when they do (requires divine intervention)
177 2) Tell them not to (won't work: they'll do it anyway) 177 2) Tell them not to (won't work: they'll do it anyway)
178 3) Oops the kernel (this will have a negative effect on a user's uptime) 178 3) Oops the kernel (this will have a negative effect on a user's uptime)
179 4) Do something sensible. 179 4) Do something sensible.
180 180
181 Of course, we go for option 4. 181 Of course, we go for option 4.
182 182
183 It happens that this device will be linked to two times, once from 183 It happens that this device will be linked to two times, once from
@@ -185,15 +185,15 @@ static struct video_device pwc_template = {
185 pointers. This is done when the device is probed() and all initialization 185 pointers. This is done when the device is probed() and all initialization
186 succeeded. The pwc_device struct links back to both structures. 186 succeeded. The pwc_device struct links back to both structures.
187 187
188 When a device is unplugged while in use it will be removed from the 188 When a device is unplugged while in use it will be removed from the
189 list of known USB devices; I also de-register it as a V4L device, but 189 list of known USB devices; I also de-register it as a V4L device, but
190 unfortunately I can't free the memory since the struct is still in use 190 unfortunately I can't free the memory since the struct is still in use
191 by the file descriptor. This free-ing is then deferend until the first 191 by the file descriptor. This free-ing is then deferend until the first
192 opportunity. Crude, but it works. 192 opportunity. Crude, but it works.
193 193
194 A small 'advantage' is that if a user unplugs the cam and plugs it back 194 A small 'advantage' is that if a user unplugs the cam and plugs it back
195 in, it should get assigned the same video device minor, but unfortunately 195 in, it should get assigned the same video device minor, but unfortunately
196 it's non-trivial to re-link the cam back to the video device... (that 196 it's non-trivial to re-link the cam back to the video device... (that
197 would surely be magic! :)) 197 would surely be magic! :))
198*/ 198*/
199 199
@@ -203,14 +203,14 @@ static struct video_device pwc_template = {
203/* Here we want the physical address of the memory. 203/* Here we want the physical address of the memory.
204 * This is used when initializing the contents of the area. 204 * This is used when initializing the contents of the area.
205 */ 205 */
206static inline unsigned long kvirt_to_pa(unsigned long adr) 206static inline unsigned long kvirt_to_pa(unsigned long adr)
207{ 207{
208 unsigned long kva, ret; 208 unsigned long kva, ret;
209 209
210 kva = (unsigned long) page_address(vmalloc_to_page((void *)adr)); 210 kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
211 kva |= adr & (PAGE_SIZE-1); /* restore the offset */ 211 kva |= adr & (PAGE_SIZE-1); /* restore the offset */
212 ret = __pa(kva); 212 ret = __pa(kva);
213 return ret; 213 return ret;
214} 214}
215 215
216static void * rvmalloc(unsigned long size) 216static void * rvmalloc(unsigned long size)
@@ -219,13 +219,13 @@ static void * rvmalloc(unsigned long size)
219 unsigned long adr; 219 unsigned long adr;
220 220
221 size=PAGE_ALIGN(size); 221 size=PAGE_ALIGN(size);
222 mem=vmalloc_32(size); 222 mem=vmalloc_32(size);
223 if (mem) 223 if (mem)
224 { 224 {
225 memset(mem, 0, size); /* Clear the ram out, no junk to the user */ 225 memset(mem, 0, size); /* Clear the ram out, no junk to the user */
226 adr=(unsigned long) mem; 226 adr=(unsigned long) mem;
227 while (size > 0) 227 while (size > 0)
228 { 228 {
229 SetPageReserved(vmalloc_to_page((void *)adr)); 229 SetPageReserved(vmalloc_to_page((void *)adr));
230 adr+=PAGE_SIZE; 230 adr+=PAGE_SIZE;
231 size-=PAGE_SIZE; 231 size-=PAGE_SIZE;
@@ -236,13 +236,13 @@ static void * rvmalloc(unsigned long size)
236 236
237static void rvfree(void * mem, unsigned long size) 237static void rvfree(void * mem, unsigned long size)
238{ 238{
239 unsigned long adr; 239 unsigned long adr;
240 240
241 if (mem) 241 if (mem)
242 { 242 {
243 adr=(unsigned long) mem; 243 adr=(unsigned long) mem;
244 while ((long) size > 0) 244 while ((long) size > 0)
245 { 245 {
246 ClearPageReserved(vmalloc_to_page((void *)adr)); 246 ClearPageReserved(vmalloc_to_page((void *)adr));
247 adr+=PAGE_SIZE; 247 adr+=PAGE_SIZE;
248 size-=PAGE_SIZE; 248 size-=PAGE_SIZE;
@@ -263,13 +263,13 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
263 263
264 if (pdev == NULL) 264 if (pdev == NULL)
265 return -ENXIO; 265 return -ENXIO;
266 266
267#ifdef PWC_MAGIC 267#ifdef PWC_MAGIC
268 if (pdev->magic != PWC_MAGIC) { 268 if (pdev->magic != PWC_MAGIC) {
269 Err("allocate_buffers(): magic failed.\n"); 269 Err("allocate_buffers(): magic failed.\n");
270 return -ENXIO; 270 return -ENXIO;
271 } 271 }
272#endif 272#endif
273 /* Allocate Isochronous pipe buffers */ 273 /* Allocate Isochronous pipe buffers */
274 for (i = 0; i < MAX_ISO_BUFS; i++) { 274 for (i = 0; i < MAX_ISO_BUFS; i++) {
275 if (pdev->sbuf[i].data == NULL) { 275 if (pdev->sbuf[i].data == NULL) {
@@ -308,7 +308,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
308 memset(kbuf, 128, PWC_FRAME_SIZE); 308 memset(kbuf, 128, PWC_FRAME_SIZE);
309 } 309 }
310 } 310 }
311 311
312 /* Allocate decompressor table space */ 312 /* Allocate decompressor table space */
313 kbuf = NULL; 313 kbuf = NULL;
314 switch (pdev->type) 314 switch (pdev->type)
@@ -320,7 +320,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
320 case 730: 320 case 730:
321 case 740: 321 case 740:
322 case 750: 322 case 750:
323#if 0 323#if 0
324 Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private)); 324 Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private));
325 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */ 325 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */
326 break; 326 break;
@@ -329,11 +329,11 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
329 /* TODO & FIXME */ 329 /* TODO & FIXME */
330 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); 330 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL);
331 break; 331 break;
332#endif 332#endif
333 ; 333 ;
334 } 334 }
335 pdev->decompress_data = kbuf; 335 pdev->decompress_data = kbuf;
336 336
337 /* Allocate image buffer; double buffer for mmap() */ 337 /* Allocate image buffer; double buffer for mmap() */
338 kbuf = rvmalloc(default_mbufs * pdev->len_per_image); 338 kbuf = rvmalloc(default_mbufs * pdev->len_per_image);
339 if (kbuf == NULL) { 339 if (kbuf == NULL) {
@@ -348,7 +348,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
348 pdev->image_ptr[i] = NULL; 348 pdev->image_ptr[i] = NULL;
349 349
350 kbuf = NULL; 350 kbuf = NULL;
351 351
352 Trace(TRACE_MEMORY, "<< pwc_allocate_buffers()\n"); 352 Trace(TRACE_MEMORY, "<< pwc_allocate_buffers()\n");
353 return 0; 353 return 0;
354} 354}
@@ -366,7 +366,7 @@ static void pwc_free_buffers(struct pwc_device *pdev)
366 Err("free_buffers(): magic failed.\n"); 366 Err("free_buffers(): magic failed.\n");
367 return; 367 return;
368 } 368 }
369#endif 369#endif
370 370
371 /* Release Iso-pipe buffers */ 371 /* Release Iso-pipe buffers */
372 for (i = 0; i < MAX_ISO_BUFS; i++) 372 for (i = 0; i < MAX_ISO_BUFS; i++)
@@ -403,17 +403,17 @@ static void pwc_free_buffers(struct pwc_device *pdev)
403 rvfree(pdev->image_data, default_mbufs * pdev->len_per_image); 403 rvfree(pdev->image_data, default_mbufs * pdev->len_per_image);
404 } 404 }
405 pdev->image_data = NULL; 405 pdev->image_data = NULL;
406 406
407 Trace(TRACE_MEMORY, "Leaving free_buffers().\n"); 407 Trace(TRACE_MEMORY, "Leaving free_buffers().\n");
408} 408}
409 409
410/* The frame & image buffer mess. 410/* The frame & image buffer mess.
411 411
412 Yes, this is a mess. Well, it used to be simple, but alas... In this 412 Yes, this is a mess. Well, it used to be simple, but alas... In this
413 module, 3 buffers schemes are used to get the data from the USB bus to 413 module, 3 buffers schemes are used to get the data from the USB bus to
414 the user program. The first scheme involves the ISO buffers (called thus 414 the user program. The first scheme involves the ISO buffers (called thus
415 since they transport ISO data from the USB controller), and not really 415 since they transport ISO data from the USB controller), and not really
416 interesting. Suffices to say the data from this buffer is quickly 416 interesting. Suffices to say the data from this buffer is quickly
417 gathered in an interrupt handler (pwc_isoc_handler) and placed into the 417 gathered in an interrupt handler (pwc_isoc_handler) and placed into the
418 frame buffer. 418 frame buffer.
419 419
@@ -443,8 +443,8 @@ static void pwc_free_buffers(struct pwc_device *pdev)
443 and a 'full' frame list: 443 and a 'full' frame list:
444 * Initially, all frame buffers but one are on the 'empty' list; the one 444 * Initially, all frame buffers but one are on the 'empty' list; the one
445 remaining buffer is our initial fill frame. 445 remaining buffer is our initial fill frame.
446 * If a frame is needed for filling, we try to take it from the 'empty' 446 * If a frame is needed for filling, we try to take it from the 'empty'
447 list, unless that list is empty, in which case we take the buffer at 447 list, unless that list is empty, in which case we take the buffer at
448 the head of the 'full' list. 448 the head of the 'full' list.
449 * When our fill buffer has been filled, it is appended to the 'full' 449 * When our fill buffer has been filled, it is appended to the 'full'
450 list. 450 list.
@@ -646,7 +646,7 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
646 case -ETIMEDOUT: errmsg = "NAK (device does not respond)"; break; 646 case -ETIMEDOUT: errmsg = "NAK (device does not respond)"; break;
647 } 647 }
648 Trace(TRACE_FLOW, "pwc_isoc_handler() called with status %d [%s].\n", urb->status, errmsg); 648 Trace(TRACE_FLOW, "pwc_isoc_handler() called with status %d [%s].\n", urb->status, errmsg);
649 /* Give up after a number of contiguous errors on the USB bus. 649 /* Give up after a number of contiguous errors on the USB bus.
650 Appearantly something is wrong so we simulate an unplug event. 650 Appearantly something is wrong so we simulate an unplug event.
651 */ 651 */
652 if (++pdev->visoc_errors > MAX_ISOC_ERRORS) 652 if (++pdev->visoc_errors > MAX_ISOC_ERRORS)
@@ -673,8 +673,8 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
673 pdev->visoc_errors = 0; 673 pdev->visoc_errors = 0;
674 674
675 /* vsync: 0 = don't copy data 675 /* vsync: 0 = don't copy data
676 1 = sync-hunt 676 1 = sync-hunt
677 2 = synched 677 2 = synched
678 */ 678 */
679 /* Compact data */ 679 /* Compact data */
680 for (i = 0; i < urb->number_of_packets; i++) { 680 for (i = 0; i < urb->number_of_packets; i++) {
@@ -701,18 +701,18 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
701 } /* ..flen > 0 */ 701 } /* ..flen > 0 */
702 702
703 if (flen < pdev->vlast_packet_size) { 703 if (flen < pdev->vlast_packet_size) {
704 /* Shorter packet... We probably have the end of an image-frame; 704 /* Shorter packet... We probably have the end of an image-frame;
705 wake up read() process and let select()/poll() do something. 705 wake up read() process and let select()/poll() do something.
706 Decompression is done in user time over there. 706 Decompression is done in user time over there.
707 */ 707 */
708 if (pdev->vsync == 2) { 708 if (pdev->vsync == 2) {
709 /* The ToUCam Fun CMOS sensor causes the firmware to send 2 or 3 bogus 709 /* The ToUCam Fun CMOS sensor causes the firmware to send 2 or 3 bogus
710 frames on the USB wire after an exposure change. This conditition is 710 frames on the USB wire after an exposure change. This conditition is
711 however detected in the cam and a bit is set in the header. 711 however detected in the cam and a bit is set in the header.
712 */ 712 */
713 if (pdev->type == 730) { 713 if (pdev->type == 730) {
714 unsigned char *ptr = (unsigned char *)fbuf->data; 714 unsigned char *ptr = (unsigned char *)fbuf->data;
715 715
716 if (ptr[1] == 1 && ptr[0] & 0x10) { 716 if (ptr[1] == 1 && ptr[0] & 0x10) {
717#if PWC_DEBUG 717#if PWC_DEBUG
718 Debug("Hyundai CMOS sensor bug. Dropping frame %d.\n", fbuf->sequence); 718 Debug("Hyundai CMOS sensor bug. Dropping frame %d.\n", fbuf->sequence);
@@ -733,13 +733,13 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
733 Info("Image is normal.\n"); 733 Info("Image is normal.\n");
734 } 734 }
735 pdev->vmirror = ptr[0] & 0x03; 735 pdev->vmirror = ptr[0] & 0x03;
736 /* Sometimes the trailer of the 730 is still sent as a 4 byte packet 736 /* Sometimes the trailer of the 730 is still sent as a 4 byte packet
737 after a short frame; this condition is filtered out specifically. A 4 byte 737 after a short frame; this condition is filtered out specifically. A 4 byte
738 frame doesn't make sense anyway. 738 frame doesn't make sense anyway.
739 So we get either this sequence: 739 So we get either this sequence:
740 drop_bit set -> 4 byte frame -> short frame -> good frame 740 drop_bit set -> 4 byte frame -> short frame -> good frame
741 Or this one: 741 Or this one:
742 drop_bit set -> short frame -> good frame 742 drop_bit set -> short frame -> good frame
743 So we drop either 3 or 2 frames in all! 743 So we drop either 3 or 2 frames in all!
744 */ 744 */
745 if (fbuf->filled == 4) 745 if (fbuf->filled == 4)
@@ -830,7 +830,7 @@ static int pwc_isoc_init(struct pwc_device *pdev)
830 intf = usb_ifnum_to_if(udev, 0); 830 intf = usb_ifnum_to_if(udev, 0);
831 if (intf) 831 if (intf)
832 idesc = usb_altnum_to_altsetting(intf, pdev->valternate); 832 idesc = usb_altnum_to_altsetting(intf, pdev->valternate);
833 833
834 if (!idesc) 834 if (!idesc)
835 return -EFAULT; 835 return -EFAULT;
836 836
@@ -841,7 +841,7 @@ static int pwc_isoc_init(struct pwc_device *pdev)
841 pdev->vmax_packet_size = le16_to_cpu(idesc->endpoint[i].desc.wMaxPacketSize); 841 pdev->vmax_packet_size = le16_to_cpu(idesc->endpoint[i].desc.wMaxPacketSize);
842 break; 842 break;
843 } 843 }
844 844
845 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) { 845 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) {
846 Err("Failed to find packet size for video endpoint in current alternate setting.\n"); 846 Err("Failed to find packet size for video endpoint in current alternate setting.\n");
847 return -ENFILE; /* Odd error, that should be noticeable */ 847 return -ENFILE; /* Odd error, that should be noticeable */
@@ -875,18 +875,18 @@ static int pwc_isoc_init(struct pwc_device *pdev)
875 return ret; 875 return ret;
876 } 876 }
877 877
878 /* init URB structure */ 878 /* init URB structure */
879 for (i = 0; i < MAX_ISO_BUFS; i++) { 879 for (i = 0; i < MAX_ISO_BUFS; i++) {
880 urb = pdev->sbuf[i].urb; 880 urb = pdev->sbuf[i].urb;
881 881
882 urb->interval = 1; // devik 882 urb->interval = 1; // devik
883 urb->dev = udev; 883 urb->dev = udev;
884 urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint); 884 urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint);
885 urb->transfer_flags = URB_ISO_ASAP; 885 urb->transfer_flags = URB_ISO_ASAP;
886 urb->transfer_buffer = pdev->sbuf[i].data; 886 urb->transfer_buffer = pdev->sbuf[i].data;
887 urb->transfer_buffer_length = ISO_BUFFER_SIZE; 887 urb->transfer_buffer_length = ISO_BUFFER_SIZE;
888 urb->complete = pwc_isoc_handler; 888 urb->complete = pwc_isoc_handler;
889 urb->context = pdev; 889 urb->context = pdev;
890 urb->start_frame = 0; 890 urb->start_frame = 0;
891 urb->number_of_packets = ISO_FRAMES_PER_DESC; 891 urb->number_of_packets = ISO_FRAMES_PER_DESC;
892 for (j = 0; j < ISO_FRAMES_PER_DESC; j++) { 892 for (j = 0; j < ISO_FRAMES_PER_DESC; j++) {
@@ -935,7 +935,7 @@ static void pwc_isoc_cleanup(struct pwc_device *pdev)
935 } 935 }
936 936
937 /* Stop camera, but only if we are sure the camera is still there (unplug 937 /* Stop camera, but only if we are sure the camera is still there (unplug
938 is signalled by EPIPE) 938 is signalled by EPIPE)
939 */ 939 */
940 if (pdev->error_status && pdev->error_status != EPIPE) { 940 if (pdev->error_status && pdev->error_status != EPIPE) {
941 Trace(TRACE_OPEN, "Setting alternate interface 0.\n"); 941 Trace(TRACE_OPEN, "Setting alternate interface 0.\n");
@@ -956,12 +956,12 @@ int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_f
956 pwc_reset_buffers(pdev); 956 pwc_reset_buffers(pdev);
957 /* Try to set video mode... */ 957 /* Try to set video mode... */
958 start = ret = pwc_set_video_mode(pdev, width, height, new_fps, new_compression, new_snapshot); 958 start = ret = pwc_set_video_mode(pdev, width, height, new_fps, new_compression, new_snapshot);
959 if (ret) { 959 if (ret) {
960 Trace(TRACE_FLOW, "pwc_set_video_mode attempt 1 failed.\n"); 960 Trace(TRACE_FLOW, "pwc_set_video_mode attempt 1 failed.\n");
961 /* That failed... restore old mode (we know that worked) */ 961 /* That failed... restore old mode (we know that worked) */
962 start = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot); 962 start = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot);
963 if (start) { 963 if (start) {
964 Trace(TRACE_FLOW, "pwc_set_video_mode attempt 2 failed.\n"); 964 Trace(TRACE_FLOW, "pwc_set_video_mode attempt 2 failed.\n");
965 } 965 }
966 } 966 }
967 if (start == 0) 967 if (start == 0)
@@ -987,18 +987,18 @@ static int pwc_video_open(struct inode *inode, struct file *file)
987 struct pwc_device *pdev; 987 struct pwc_device *pdev;
988 988
989 Trace(TRACE_OPEN, ">> video_open called(vdev = 0x%p).\n", vdev); 989 Trace(TRACE_OPEN, ">> video_open called(vdev = 0x%p).\n", vdev);
990 990
991 pdev = (struct pwc_device *)vdev->priv; 991 pdev = (struct pwc_device *)vdev->priv;
992 if (pdev == NULL) 992 if (pdev == NULL)
993 BUG(); 993 BUG();
994 if (pdev->vopen) 994 if (pdev->vopen)
995 return -EBUSY; 995 return -EBUSY;
996 996
997 down(&pdev->modlock); 997 down(&pdev->modlock);
998 if (!pdev->usb_init) { 998 if (!pdev->usb_init) {
999 Trace(TRACE_OPEN, "Doing first time initialization.\n"); 999 Trace(TRACE_OPEN, "Doing first time initialization.\n");
1000 pdev->usb_init = 1; 1000 pdev->usb_init = 1;
1001 1001
1002 if (pwc_trace & TRACE_OPEN) 1002 if (pwc_trace & TRACE_OPEN)
1003 { 1003 {
1004 /* Query sensor type */ 1004 /* Query sensor type */
@@ -1036,7 +1036,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
1036 /* Set LED on/off time */ 1036 /* Set LED on/off time */
1037 if (pwc_set_leds(pdev, led_on, led_off) < 0) 1037 if (pwc_set_leds(pdev, led_on, led_off) < 0)
1038 Info("Failed to set LED on/off time.\n"); 1038 Info("Failed to set LED on/off time.\n");
1039 1039
1040 pwc_construct(pdev); /* set min/max sizes correct */ 1040 pwc_construct(pdev); /* set min/max sizes correct */
1041 1041
1042 /* So far, so good. Allocate memory. */ 1042 /* So far, so good. Allocate memory. */
@@ -1046,7 +1046,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
1046 up(&pdev->modlock); 1046 up(&pdev->modlock);
1047 return i; 1047 return i;
1048 } 1048 }
1049 1049
1050 /* Reset buffers & parameters */ 1050 /* Reset buffers & parameters */
1051 pwc_reset_buffers(pdev); 1051 pwc_reset_buffers(pdev);
1052 for (i = 0; i < default_mbufs; i++) 1052 for (i = 0; i < default_mbufs; i++)
@@ -1081,7 +1081,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
1081 up(&pdev->modlock); 1081 up(&pdev->modlock);
1082 return i; 1082 return i;
1083 } 1083 }
1084 1084
1085 i = pwc_isoc_init(pdev); 1085 i = pwc_isoc_init(pdev);
1086 if (i) { 1086 if (i) {
1087 Trace(TRACE_OPEN, "Failed to init ISOC stuff = %d.\n", i); 1087 Trace(TRACE_OPEN, "Failed to init ISOC stuff = %d.\n", i);
@@ -1155,13 +1155,13 @@ static int pwc_video_close(struct inode *inode, struct file *file)
1155/* 1155/*
1156 * FIXME: what about two parallel reads ???? 1156 * FIXME: what about two parallel reads ????
1157 * ANSWER: Not supported. You can't open the device more than once, 1157 * ANSWER: Not supported. You can't open the device more than once,
1158 despite what the V4L1 interface says. First, I don't see 1158 despite what the V4L1 interface says. First, I don't see
1159 the need, second there's no mechanism of alerting the 1159 the need, second there's no mechanism of alerting the
1160 2nd/3rd/... process of events like changing image size. 1160 2nd/3rd/... process of events like changing image size.
1161 And I don't see the point of blocking that for the 1161 And I don't see the point of blocking that for the
1162 2nd/3rd/... process. 1162 2nd/3rd/... process.
1163 In multi-threaded environments reading parallel from any 1163 In multi-threaded environments reading parallel from any
1164 device is tricky anyhow. 1164 device is tricky anyhow.
1165 */ 1165 */
1166 1166
1167static ssize_t pwc_video_read(struct file *file, char __user * buf, 1167static ssize_t pwc_video_read(struct file *file, char __user * buf,
@@ -1171,7 +1171,7 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf,
1171 struct pwc_device *pdev; 1171 struct pwc_device *pdev;
1172 int noblock = file->f_flags & O_NONBLOCK; 1172 int noblock = file->f_flags & O_NONBLOCK;
1173 DECLARE_WAITQUEUE(wait, current); 1173 DECLARE_WAITQUEUE(wait, current);
1174 int bytes_to_read; 1174 int bytes_to_read;
1175 1175
1176 Trace(TRACE_READ, "video_read(0x%p, %p, %zu) called.\n", vdev, buf, count); 1176 Trace(TRACE_READ, "video_read(0x%p, %p, %zu) called.\n", vdev, buf, count);
1177 if (vdev == NULL) 1177 if (vdev == NULL)
@@ -1193,22 +1193,22 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf,
1193 set_current_state(TASK_RUNNING); 1193 set_current_state(TASK_RUNNING);
1194 return -pdev->error_status ; 1194 return -pdev->error_status ;
1195 } 1195 }
1196 if (noblock) { 1196 if (noblock) {
1197 remove_wait_queue(&pdev->frameq, &wait); 1197 remove_wait_queue(&pdev->frameq, &wait);
1198 set_current_state(TASK_RUNNING); 1198 set_current_state(TASK_RUNNING);
1199 return -EWOULDBLOCK; 1199 return -EWOULDBLOCK;
1200 } 1200 }
1201 if (signal_pending(current)) { 1201 if (signal_pending(current)) {
1202 remove_wait_queue(&pdev->frameq, &wait); 1202 remove_wait_queue(&pdev->frameq, &wait);
1203 set_current_state(TASK_RUNNING); 1203 set_current_state(TASK_RUNNING);
1204 return -ERESTARTSYS; 1204 return -ERESTARTSYS;
1205 } 1205 }
1206 schedule(); 1206 schedule();
1207 set_current_state(TASK_INTERRUPTIBLE); 1207 set_current_state(TASK_INTERRUPTIBLE);
1208 } 1208 }
1209 remove_wait_queue(&pdev->frameq, &wait); 1209 remove_wait_queue(&pdev->frameq, &wait);
1210 set_current_state(TASK_RUNNING); 1210 set_current_state(TASK_RUNNING);
1211 1211
1212 /* Decompress and release frame */ 1212 /* Decompress and release frame */
1213 if (pwc_handle_frame(pdev)) 1213 if (pwc_handle_frame(pdev))
1214 return -EFAULT; 1214 return -EFAULT;
@@ -1218,7 +1218,7 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf,
1218 if (pdev->vpalette == VIDEO_PALETTE_RAW) 1218 if (pdev->vpalette == VIDEO_PALETTE_RAW)
1219 bytes_to_read = pdev->frame_size; 1219 bytes_to_read = pdev->frame_size;
1220 else 1220 else
1221 bytes_to_read = pdev->view.size; 1221 bytes_to_read = pdev->view.size;
1222 1222
1223 /* copy bytes to user space; we allow for partial reads */ 1223 /* copy bytes to user space; we allow for partial reads */
1224 if (count + pdev->image_read_pos > bytes_to_read) 1224 if (count + pdev->image_read_pos > bytes_to_read)
@@ -1348,11 +1348,11 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1348 struct video_picture *p = arg; 1348 struct video_picture *p = arg;
1349 /* 1349 /*
1350 * FIXME: Suppose we are mid read 1350 * FIXME: Suppose we are mid read
1351 ANSWER: No problem: the firmware of the camera 1351 ANSWER: No problem: the firmware of the camera
1352 can handle brightness/contrast/etc 1352 can handle brightness/contrast/etc
1353 changes at _any_ time, and the palette 1353 changes at _any_ time, and the palette
1354 is used exactly once in the uncompress 1354 is used exactly once in the uncompress
1355 routine. 1355 routine.
1356 */ 1356 */
1357 pwc_set_brightness(pdev, p->brightness); 1357 pwc_set_brightness(pdev, p->brightness);
1358 pwc_set_contrast(pdev, p->contrast); 1358 pwc_set_contrast(pdev, p->contrast);
@@ -1373,21 +1373,21 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1373 break; 1373 break;
1374 } 1374 }
1375 1375
1376 /* Window/size parameters */ 1376 /* Window/size parameters */
1377 case VIDIOCGWIN: 1377 case VIDIOCGWIN:
1378 { 1378 {
1379 struct video_window *vw = arg; 1379 struct video_window *vw = arg;
1380 1380
1381 vw->x = 0; 1381 vw->x = 0;
1382 vw->y = 0; 1382 vw->y = 0;
1383 vw->width = pdev->view.x; 1383 vw->width = pdev->view.x;
1384 vw->height = pdev->view.y; 1384 vw->height = pdev->view.y;
1385 vw->chromakey = 0; 1385 vw->chromakey = 0;
1386 vw->flags = (pdev->vframes << PWC_FPS_SHIFT) | 1386 vw->flags = (pdev->vframes << PWC_FPS_SHIFT) |
1387 (pdev->vsnapshot ? PWC_FPS_SNAPSHOT : 0); 1387 (pdev->vsnapshot ? PWC_FPS_SNAPSHOT : 0);
1388 break; 1388 break;
1389 } 1389 }
1390 1390
1391 case VIDIOCSWIN: 1391 case VIDIOCSWIN:
1392 { 1392 {
1393 struct video_window *vw = arg; 1393 struct video_window *vw = arg;
@@ -1402,9 +1402,9 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1402 ret = pwc_try_video_mode(pdev, vw->width, vw->height, fps, pdev->vcompression, snapshot); 1402 ret = pwc_try_video_mode(pdev, vw->width, vw->height, fps, pdev->vcompression, snapshot);
1403 if (ret) 1403 if (ret)
1404 return ret; 1404 return ret;
1405 break; 1405 break;
1406 } 1406 }
1407 1407
1408 /* We don't have overlay support (yet) */ 1408 /* We don't have overlay support (yet) */
1409 case VIDIOCGFBUF: 1409 case VIDIOCGFBUF:
1410 { 1410 {
@@ -1471,8 +1471,8 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1471 return -EBUSY; /* buffer wasn't available. Bummer */ 1471 return -EBUSY; /* buffer wasn't available. Bummer */
1472 pdev->image_used[vm->frame] = 1; 1472 pdev->image_used[vm->frame] = 1;
1473 1473
1474 /* Okay, we're done here. In the SYNC call we wait until a 1474 /* Okay, we're done here. In the SYNC call we wait until a
1475 frame comes available, then expand image into the given 1475 frame comes available, then expand image into the given
1476 buffer. 1476 buffer.
1477 In contrast to the CPiA cam the Philips cams deliver a 1477 In contrast to the CPiA cam the Philips cams deliver a
1478 constant stream, almost like a grabber card. Also, 1478 constant stream, almost like a grabber card. Also,
@@ -1487,16 +1487,16 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1487 { 1487 {
1488 /* The doc says: "Whenever a buffer is used it should 1488 /* The doc says: "Whenever a buffer is used it should
1489 call VIDIOCSYNC to free this frame up and continue." 1489 call VIDIOCSYNC to free this frame up and continue."
1490 1490
1491 The only odd thing about this whole procedure is 1491 The only odd thing about this whole procedure is
1492 that MCAPTURE flags the buffer as "in use", and 1492 that MCAPTURE flags the buffer as "in use", and
1493 SYNC immediately unmarks it, while it isn't 1493 SYNC immediately unmarks it, while it isn't
1494 after SYNC that you know that the buffer actually 1494 after SYNC that you know that the buffer actually
1495 got filled! So you better not start a CAPTURE in 1495 got filled! So you better not start a CAPTURE in
1496 the same frame immediately (use double buffering). 1496 the same frame immediately (use double buffering).
1497 This is not a problem for this cam, since it has 1497 This is not a problem for this cam, since it has
1498 extra intermediate buffers, but a hardware 1498 extra intermediate buffers, but a hardware
1499 grabber card will then overwrite the buffer 1499 grabber card will then overwrite the buffer
1500 you're working on. 1500 you're working on.
1501 */ 1501 */
1502 int *mbuf = arg; 1502 int *mbuf = arg;
@@ -1512,10 +1512,10 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1512 return -EINVAL; 1512 return -EINVAL;
1513 1513
1514 /* Add ourselves to the frame wait-queue. 1514 /* Add ourselves to the frame wait-queue.
1515 1515
1516 FIXME: needs auditing for safety. 1516 FIXME: needs auditing for safety.
1517 QUESTION: In what respect? I think that using the 1517 QUESTION: In what respect? I think that using the
1518 frameq is safe now. 1518 frameq is safe now.
1519 */ 1519 */
1520 add_wait_queue(&pdev->frameq, &wait); 1520 add_wait_queue(&pdev->frameq, &wait);
1521 while (pdev->full_frames == NULL) { 1521 while (pdev->full_frames == NULL) {
@@ -1524,21 +1524,21 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1524 set_current_state(TASK_RUNNING); 1524 set_current_state(TASK_RUNNING);
1525 return -pdev->error_status; 1525 return -pdev->error_status;
1526 } 1526 }
1527 1527
1528 if (signal_pending(current)) { 1528 if (signal_pending(current)) {
1529 remove_wait_queue(&pdev->frameq, &wait); 1529 remove_wait_queue(&pdev->frameq, &wait);
1530 set_current_state(TASK_RUNNING); 1530 set_current_state(TASK_RUNNING);
1531 return -ERESTARTSYS; 1531 return -ERESTARTSYS;
1532 } 1532 }
1533 schedule(); 1533 schedule();
1534 set_current_state(TASK_INTERRUPTIBLE); 1534 set_current_state(TASK_INTERRUPTIBLE);
1535 } 1535 }
1536 remove_wait_queue(&pdev->frameq, &wait); 1536 remove_wait_queue(&pdev->frameq, &wait);
1537 set_current_state(TASK_RUNNING); 1537 set_current_state(TASK_RUNNING);
1538 1538
1539 /* The frame is ready. Expand in the image buffer 1539 /* The frame is ready. Expand in the image buffer
1540 requested by the user. I don't care if you 1540 requested by the user. I don't care if you
1541 mmap() 5 buffers and request data in this order: 1541 mmap() 5 buffers and request data in this order:
1542 buffer 4 2 3 0 1 2 3 0 4 3 1 . . . 1542 buffer 4 2 3 0 1 2 3 0 4 3 1 . . .
1543 Grabber hardware may not be so forgiving. 1543 Grabber hardware may not be so forgiving.
1544 */ 1544 */
@@ -1551,11 +1551,11 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1551 return -EFAULT; 1551 return -EFAULT;
1552 break; 1552 break;
1553 } 1553 }
1554 1554
1555 case VIDIOCGAUDIO: 1555 case VIDIOCGAUDIO:
1556 { 1556 {
1557 struct video_audio *v = arg; 1557 struct video_audio *v = arg;
1558 1558
1559 strcpy(v->name, "Microphone"); 1559 strcpy(v->name, "Microphone");
1560 v->audio = -1; /* unknown audio minor */ 1560 v->audio = -1; /* unknown audio minor */
1561 v->flags = 0; 1561 v->flags = 0;
@@ -1565,19 +1565,19 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1565 v->treble = 0; 1565 v->treble = 0;
1566 v->balance = 0x8000; 1566 v->balance = 0x8000;
1567 v->step = 1; 1567 v->step = 1;
1568 break; 1568 break;
1569 } 1569 }
1570 1570
1571 case VIDIOCSAUDIO: 1571 case VIDIOCSAUDIO:
1572 { 1572 {
1573 /* Dummy: nothing can be set */ 1573 /* Dummy: nothing can be set */
1574 break; 1574 break;
1575 } 1575 }
1576 1576
1577 case VIDIOCGUNIT: 1577 case VIDIOCGUNIT:
1578 { 1578 {
1579 struct video_unit *vu = arg; 1579 struct video_unit *vu = arg;
1580 1580
1581 vu->video = pdev->vdev->minor & 0x3F; 1581 vu->video = pdev->vdev->minor & 0x3F;
1582 vu->audio = -1; /* not known yet */ 1582 vu->audio = -1; /* not known yet */
1583 vu->vbi = -1; 1583 vu->vbi = -1;
@@ -1589,7 +1589,7 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1589 return pwc_ioctl(pdev, cmd, arg); 1589 return pwc_ioctl(pdev, cmd, arg);
1590 } /* ..switch */ 1590 } /* ..switch */
1591 return 0; 1591 return 0;
1592} 1592}
1593 1593
1594static int pwc_video_ioctl(struct inode *inode, struct file *file, 1594static int pwc_video_ioctl(struct inode *inode, struct file *file,
1595 unsigned int cmd, unsigned long arg) 1595 unsigned int cmd, unsigned long arg)
@@ -1605,10 +1605,10 @@ static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma)
1605 unsigned long start = vma->vm_start; 1605 unsigned long start = vma->vm_start;
1606 unsigned long size = vma->vm_end-vma->vm_start; 1606 unsigned long size = vma->vm_end-vma->vm_start;
1607 unsigned long page, pos; 1607 unsigned long page, pos;
1608 1608
1609 Trace(TRACE_MEMORY, "mmap(0x%p, 0x%lx, %lu) called.\n", vdev, start, size); 1609 Trace(TRACE_MEMORY, "mmap(0x%p, 0x%lx, %lu) called.\n", vdev, start, size);
1610 pdev = vdev->priv; 1610 pdev = vdev->priv;
1611 1611
1612 vma->vm_flags |= VM_IO; 1612 vma->vm_flags |= VM_IO;
1613 1613
1614 pos = (unsigned long)pdev->image_data; 1614 pos = (unsigned long)pdev->image_data;
@@ -1646,7 +1646,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1646 char serial_number[30], *name; 1646 char serial_number[30], *name;
1647 1647
1648 /* Check if we can handle this device */ 1648 /* Check if we can handle this device */
1649 Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n", 1649 Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n",
1650 le16_to_cpu(udev->descriptor.idVendor), 1650 le16_to_cpu(udev->descriptor.idVendor),
1651 le16_to_cpu(udev->descriptor.idProduct), 1651 le16_to_cpu(udev->descriptor.idProduct),
1652 intf->altsetting->desc.bInterfaceNumber); 1652 intf->altsetting->desc.bInterfaceNumber);
@@ -1770,11 +1770,11 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1770 name = "Logitech QuickCam (res.)"; 1770 name = "Logitech QuickCam (res.)";
1771 type_id = 730; /* Assuming CMOS */ 1771 type_id = 730; /* Assuming CMOS */
1772 break; 1772 break;
1773 default: 1773 default:
1774 return -ENODEV; 1774 return -ENODEV;
1775 break; 1775 break;
1776 } 1776 }
1777 } 1777 }
1778 else if (vendor_id == 0x055d) { 1778 else if (vendor_id == 0x055d) {
1779 /* I don't know the difference between the C10 and the C30; 1779 /* I don't know the difference between the C10 and the C30;
1780 I suppose the difference is the sensor, but both cameras 1780 I suppose the difference is the sensor, but both cameras
@@ -1837,7 +1837,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1837 return -ENODEV; 1837 return -ENODEV;
1838 break; 1838 break;
1839 } 1839 }
1840 1840
1841 } 1841 }
1842 else if (vendor_id == 0x0d81) { 1842 else if (vendor_id == 0x0d81) {
1843 switch(product_id) { 1843 switch(product_id) {
@@ -1856,7 +1856,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1856 break; 1856 break;
1857 } 1857 }
1858 } 1858 }
1859 else 1859 else
1860 return -ENODEV; /* Not any of the know types; but the list keeps growing. */ 1860 return -ENODEV; /* Not any of the know types; but the list keeps growing. */
1861 1861
1862 memset(serial_number, 0, 30); 1862 memset(serial_number, 0, 30);
@@ -1880,9 +1880,9 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1880 if (vendor_id == 0x046D && product_id == 0x08B5) 1880 if (vendor_id == 0x046D && product_id == 0x08B5)
1881 { 1881 {
1882 /* Logitech QuickCam Orbit 1882 /* Logitech QuickCam Orbit
1883 The ranges have been determined experimentally; they may differ from cam to cam. 1883 The ranges have been determined experimentally; they may differ from cam to cam.
1884 Also, the exact ranges left-right and up-down are different for my cam 1884 Also, the exact ranges left-right and up-down are different for my cam
1885 */ 1885 */
1886 pdev->angle_range.pan_min = -7000; 1886 pdev->angle_range.pan_min = -7000;
1887 pdev->angle_range.pan_max = 7000; 1887 pdev->angle_range.pan_max = 7000;
1888 pdev->angle_range.tilt_min = -3000; 1888 pdev->angle_range.tilt_min = -3000;
@@ -1939,7 +1939,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1939 } 1939 }
1940 1940
1941 /* occupy slot */ 1941 /* occupy slot */
1942 if (hint < MAX_DEV_HINTS) 1942 if (hint < MAX_DEV_HINTS)
1943 device_hint[hint].pdev = pdev; 1943 device_hint[hint].pdev = pdev;
1944 1944
1945 Trace(TRACE_PROBE, "probe() function returning struct at 0x%p.\n", pdev); 1945 Trace(TRACE_PROBE, "probe() function returning struct at 0x%p.\n", pdev);
@@ -1968,13 +1968,13 @@ static void usb_pwc_disconnect(struct usb_interface *intf)
1968 Err("pwc_disconnect() Woops: pointer mismatch udev/pdev.\n"); 1968 Err("pwc_disconnect() Woops: pointer mismatch udev/pdev.\n");
1969 goto disconnect_out; 1969 goto disconnect_out;
1970 } 1970 }
1971#ifdef PWC_MAGIC 1971#ifdef PWC_MAGIC
1972 if (pdev->magic != PWC_MAGIC) { 1972 if (pdev->magic != PWC_MAGIC) {
1973 Err("pwc_disconnect() Magic number failed. Consult your scrolls and try again.\n"); 1973 Err("pwc_disconnect() Magic number failed. Consult your scrolls and try again.\n");
1974 goto disconnect_out; 1974 goto disconnect_out;
1975 } 1975 }
1976#endif 1976#endif
1977 1977
1978 /* We got unplugged; this is signalled by an EPIPE error code */ 1978 /* We got unplugged; this is signalled by an EPIPE error code */
1979 if (pdev->vopen) { 1979 if (pdev->vopen) {
1980 Info("Disconnected while webcam is in use!\n"); 1980 Info("Disconnected while webcam is in use!\n");
@@ -2017,8 +2017,8 @@ static int pwc_atoi(const char *s)
2017} 2017}
2018 2018
2019 2019
2020/* 2020/*
2021 * Initialization code & module stuff 2021 * Initialization code & module stuff
2022 */ 2022 */
2023 2023
2024static char size[10]; 2024static char size[10];
@@ -2168,7 +2168,7 @@ static int __init usb_pwc_init(void)
2168 if (*dot != '\0') { 2168 if (*dot != '\0') {
2169 /* There's a serial number as well */ 2169 /* There's a serial number as well */
2170 int k; 2170 int k;
2171 2171
2172 dot++; 2172 dot++;
2173 k = 0; 2173 k = 0;
2174 while (*dot != ':' && k < 29) { 2174 while (*dot != ':' && k < 29) {
@@ -2178,18 +2178,18 @@ static int __init usb_pwc_init(void)
2178 device_hint[i].serial_number[k] = '\0'; 2178 device_hint[i].serial_number[k] = '\0';
2179 } 2179 }
2180 } 2180 }
2181#if PWC_DEBUG 2181#if PWC_DEBUG
2182 Debug("device_hint[%d]:\n", i); 2182 Debug("device_hint[%d]:\n", i);
2183 Debug(" type : %d\n", device_hint[i].type); 2183 Debug(" type : %d\n", device_hint[i].type);
2184 Debug(" serial# : %s\n", device_hint[i].serial_number); 2184 Debug(" serial# : %s\n", device_hint[i].serial_number);
2185 Debug(" node : %d\n", device_hint[i].device_node); 2185 Debug(" node : %d\n", device_hint[i].device_node);
2186#endif 2186#endif
2187 } 2187 }
2188 else 2188 else
2189 device_hint[i].type = 0; /* not filled */ 2189 device_hint[i].type = 0; /* not filled */
2190 } /* ..for MAX_DEV_HINTS */ 2190 } /* ..for MAX_DEV_HINTS */
2191 2191
2192 Trace(TRACE_PROBE, "Registering driver at address 0x%p.\n", &pwc_driver); 2192 Trace(TRACE_PROBE, "Registering driver at address 0x%p.\n", &pwc_driver);
2193 return usb_register(&pwc_driver); 2193 return usb_register(&pwc_driver);
2194} 2194}
2195 2195
diff --git a/drivers/media/video/pwc/pwc-ioctl.h b/drivers/media/video/pwc/pwc-ioctl.h
index 5f9cb08bc02e..784bc72521fa 100644
--- a/drivers/media/video/pwc/pwc-ioctl.h
+++ b/drivers/media/video/pwc/pwc-ioctl.h
@@ -33,10 +33,10 @@
33/* 33/*
34 Changes 34 Changes
35 2001/08/03 Alvarado Added ioctl constants to access methods for 35 2001/08/03 Alvarado Added ioctl constants to access methods for
36 changing white balance and red/blue gains 36 changing white balance and red/blue gains
37 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE 37 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE
38 2003/12/13 Nemosft Unv. Some modifications to make interfacing to 38 2003/12/13 Nemosft Unv. Some modifications to make interfacing to
39 PWCX easier 39 PWCX easier
40 */ 40 */
41 41
42/* These are private ioctl() commands, specific for the Philips webcams. 42/* These are private ioctl() commands, specific for the Philips webcams.
@@ -45,10 +45,10 @@
45 45
46 The #define names are built up like follows: 46 The #define names are built up like follows:
47 VIDIOC VIDeo IOCtl prefix 47 VIDIOC VIDeo IOCtl prefix
48 PWC Philps WebCam 48 PWC Philps WebCam
49 G optional: Get 49 G optional: Get
50 S optional: Set 50 S optional: Set
51 ... the function 51 ... the function
52 */ 52 */
53 53
54 54
@@ -94,7 +94,7 @@ struct pwc_serial
94{ 94{
95 char serial[30]; /* String with serial number. Contains terminating 0 */ 95 char serial[30]; /* String with serial number. Contains terminating 0 */
96}; 96};
97 97
98/* pwc_whitebalance.mode values */ 98/* pwc_whitebalance.mode values */
99#define PWC_WB_INDOOR 0 99#define PWC_WB_INDOOR 0
100#define PWC_WB_OUTDOOR 1 100#define PWC_WB_OUTDOOR 1
@@ -102,14 +102,14 @@ struct pwc_serial
102#define PWC_WB_MANUAL 3 102#define PWC_WB_MANUAL 3
103#define PWC_WB_AUTO 4 103#define PWC_WB_AUTO 4
104 104
105/* Used with VIDIOCPWC[SG]AWB (Auto White Balance). 105/* Used with VIDIOCPWC[SG]AWB (Auto White Balance).
106 Set mode to one of the PWC_WB_* values above. 106 Set mode to one of the PWC_WB_* values above.
107 *red and *blue are the respective gains of these colour components inside 107 *red and *blue are the respective gains of these colour components inside
108 the camera; range 0..65535 108 the camera; range 0..65535
109 When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read; 109 When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read;
110 otherwise undefined. 110 otherwise undefined.
111 'read_red' and 'read_blue' are read-only. 111 'read_red' and 'read_blue' are read-only.
112*/ 112*/
113struct pwc_whitebalance 113struct pwc_whitebalance
114{ 114{
115 int mode; 115 int mode;
@@ -117,9 +117,9 @@ struct pwc_whitebalance
117 int read_red, read_blue; /* R/O */ 117 int read_red, read_blue; /* R/O */
118}; 118};
119 119
120/* 120/*
121 'control_speed' and 'control_delay' are used in automatic whitebalance mode, 121 'control_speed' and 'control_delay' are used in automatic whitebalance mode,
122 and tell the camera how fast it should react to changes in lighting, and 122 and tell the camera how fast it should react to changes in lighting, and
123 with how much delay. Valid values are 0..65535. 123 with how much delay. Valid values are 0..65535.
124*/ 124*/
125struct pwc_wb_speed 125struct pwc_wb_speed
@@ -148,11 +148,11 @@ struct pwc_imagesize
148#define PWC_MPT_TILT 0x02 148#define PWC_MPT_TILT 0x02
149#define PWC_MPT_TIMEOUT 0x04 /* for status */ 149#define PWC_MPT_TIMEOUT 0x04 /* for status */
150 150
151/* Set angles; when absolute != 0, the angle is absolute and the 151/* Set angles; when absolute != 0, the angle is absolute and the
152 driver calculates the relative offset for you. This can only 152 driver calculates the relative offset for you. This can only
153 be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns 153 be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns
154 absolute angles. 154 absolute angles.
155 */ 155 */
156struct pwc_mpt_angles 156struct pwc_mpt_angles
157{ 157{
158 int absolute; /* write-only */ 158 int absolute; /* write-only */
@@ -179,14 +179,14 @@ struct pwc_mpt_status
179/* This is used for out-of-kernel decompression. With it, you can get 179/* This is used for out-of-kernel decompression. With it, you can get
180 all the necessary information to initialize and use the decompressor 180 all the necessary information to initialize and use the decompressor
181 routines in standalone applications. 181 routines in standalone applications.
182 */ 182 */
183struct pwc_video_command 183struct pwc_video_command
184{ 184{
185 int type; /* camera type (645, 675, 730, etc.) */ 185 int type; /* camera type (645, 675, 730, etc.) */
186 int release; /* release number */ 186 int release; /* release number */
187 187
188 int size; /* one of PSZ_* */ 188 int size; /* one of PSZ_* */
189 int alternate; 189 int alternate;
190 int command_len; /* length of USB video command */ 190 int command_len; /* length of USB video command */
191 unsigned char command_buf[13]; /* Actual USB video command */ 191 unsigned char command_buf[13]; /* Actual USB video command */
192 int bandlength; /* >0 = compressed */ 192 int bandlength; /* >0 = compressed */
@@ -264,7 +264,7 @@ struct pwc_video_command
264 264
265 /* Flickerless mode; = 0 off, otherwise on */ 265 /* Flickerless mode; = 0 off, otherwise on */
266#define VIDIOCPWCSFLICKER _IOW('v', 208, int) 266#define VIDIOCPWCSFLICKER _IOW('v', 208, int)
267#define VIDIOCPWCGFLICKER _IOR('v', 208, int) 267#define VIDIOCPWCGFLICKER _IOR('v', 208, int)
268 268
269 /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ 269 /* Dynamic noise reduction; 0 off, 3 = high noise reduction */
270#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) 270#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int)
@@ -273,7 +273,7 @@ struct pwc_video_command
273 /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ 273 /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */
274#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) 274#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize)
275 275
276 /* Motorized pan & tilt functions */ 276 /* Motorized pan & tilt functions */
277#define VIDIOCPWCMPTRESET _IOW('v', 211, int) 277#define VIDIOCPWCMPTRESET _IOW('v', 211, int)
278#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) 278#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range)
279#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) 279#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles)
diff --git a/drivers/media/video/pwc/pwc-kiara.c b/drivers/media/video/pwc/pwc-kiara.c
index c498c68bace1..4c96037f7be5 100644
--- a/drivers/media/video/pwc/pwc-kiara.c
+++ b/drivers/media/video/pwc/pwc-kiara.c
@@ -48,270 +48,270 @@ const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] =
48 { 48 {
49 /* 5 fps */ 49 /* 5 fps */
50 { 50 {
51 {0, }, 51 {0, },
52 {0, }, 52 {0, },
53 {0, }, 53 {0, },
54 {0, }, 54 {0, },
55 }, 55 },
56 /* 10 fps */ 56 /* 10 fps */
57 { 57 {
58 {0, }, 58 {0, },
59 {0, }, 59 {0, },
60 {0, }, 60 {0, },
61 {0, }, 61 {0, },
62 }, 62 },
63 /* 15 fps */ 63 /* 15 fps */
64 { 64 {
65 {0, }, 65 {0, },
66 {0, }, 66 {0, },
67 {0, }, 67 {0, },
68 {0, }, 68 {0, },
69 }, 69 },
70 /* 20 fps */ 70 /* 20 fps */
71 { 71 {
72 {0, }, 72 {0, },
73 {0, }, 73 {0, },
74 {0, }, 74 {0, },
75 {0, }, 75 {0, },
76 }, 76 },
77 /* 25 fps */ 77 /* 25 fps */
78 { 78 {
79 {0, }, 79 {0, },
80 {0, }, 80 {0, },
81 {0, }, 81 {0, },
82 {0, }, 82 {0, },
83 }, 83 },
84 /* 30 fps */ 84 /* 30 fps */
85 { 85 {
86 {0, }, 86 {0, },
87 {0, }, 87 {0, },
88 {0, }, 88 {0, },
89 {0, }, 89 {0, },
90 }, 90 },
91 }, 91 },
92 /* QSIF */ 92 /* QSIF */
93 { 93 {
94 /* 5 fps */ 94 /* 5 fps */
95 { 95 {
96 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}}, 96 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
97 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}}, 97 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
98 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}}, 98 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
99 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}}, 99 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
100 }, 100 },
101 /* 10 fps */ 101 /* 10 fps */
102 { 102 {
103 {2, 291, 0, {0x1C, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0x01, 0x80}}, 103 {2, 291, 0, {0x1C, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0x01, 0x80}},
104 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}}, 104 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
105 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}}, 105 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
106 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}}, 106 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
107 }, 107 },
108 /* 15 fps */ 108 /* 15 fps */
109 { 109 {
110 {3, 437, 0, {0x1B, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x01, 0x80}}, 110 {3, 437, 0, {0x1B, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x01, 0x80}},
111 {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}}, 111 {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
112 {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}}, 112 {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
113 {1, 192, 420, {0x13, 0xF4, 0x30, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x18, 0xC0, 0x00, 0x80}}, 113 {1, 192, 420, {0x13, 0xF4, 0x30, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
114 }, 114 },
115 /* 20 fps */ 115 /* 20 fps */
116 { 116 {
117 {4, 589, 0, {0x1A, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4D, 0x02, 0x80}}, 117 {4, 589, 0, {0x1A, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4D, 0x02, 0x80}},
118 {3, 448, 730, {0x12, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xC0, 0x01, 0x80}}, 118 {3, 448, 730, {0x12, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xC0, 0x01, 0x80}},
119 {2, 292, 476, {0x12, 0xF4, 0x30, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0x01, 0x80}}, 119 {2, 292, 476, {0x12, 0xF4, 0x30, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0x01, 0x80}},
120 {1, 192, 312, {0x12, 0xF4, 0x50, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0x00, 0x80}}, 120 {1, 192, 312, {0x12, 0xF4, 0x50, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
121 }, 121 },
122 /* 25 fps */ 122 /* 25 fps */
123 { 123 {
124 {5, 703, 0, {0x19, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x02, 0x80}}, 124 {5, 703, 0, {0x19, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x02, 0x80}},
125 {3, 447, 610, {0x11, 0xF4, 0x30, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x28, 0xBF, 0x01, 0x80}}, 125 {3, 447, 610, {0x11, 0xF4, 0x30, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x28, 0xBF, 0x01, 0x80}},
126 {2, 292, 398, {0x11, 0xF4, 0x50, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x28, 0x24, 0x01, 0x80}}, 126 {2, 292, 398, {0x11, 0xF4, 0x50, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x28, 0x24, 0x01, 0x80}},
127 {1, 193, 262, {0x11, 0xF4, 0x50, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x28, 0xC1, 0x00, 0x80}}, 127 {1, 193, 262, {0x11, 0xF4, 0x50, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x28, 0xC1, 0x00, 0x80}},
128 }, 128 },
129 /* 30 fps */ 129 /* 30 fps */
130 { 130 {
131 {8, 874, 0, {0x18, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6A, 0x03, 0x80}}, 131 {8, 874, 0, {0x18, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6A, 0x03, 0x80}},
132 {5, 704, 730, {0x10, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x28, 0xC0, 0x02, 0x80}}, 132 {5, 704, 730, {0x10, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x28, 0xC0, 0x02, 0x80}},
133 {3, 448, 492, {0x10, 0xF4, 0x30, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x28, 0xC0, 0x01, 0x80}}, 133 {3, 448, 492, {0x10, 0xF4, 0x30, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x28, 0xC0, 0x01, 0x80}},
134 {2, 292, 320, {0x10, 0xF4, 0x50, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x28, 0x24, 0x01, 0x80}}, 134 {2, 292, 320, {0x10, 0xF4, 0x50, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x28, 0x24, 0x01, 0x80}},
135 }, 135 },
136 }, 136 },
137 /* QCIF */ 137 /* QCIF */
138 { 138 {
139 /* 5 fps */ 139 /* 5 fps */
140 { 140 {
141 {0, }, 141 {0, },
142 {0, }, 142 {0, },
143 {0, }, 143 {0, },
144 {0, }, 144 {0, },
145 }, 145 },
146 /* 10 fps */ 146 /* 10 fps */
147 { 147 {
148 {0, }, 148 {0, },
149 {0, }, 149 {0, },
150 {0, }, 150 {0, },
151 {0, }, 151 {0, },
152 }, 152 },
153 /* 15 fps */ 153 /* 15 fps */
154 { 154 {
155 {0, }, 155 {0, },
156 {0, }, 156 {0, },
157 {0, }, 157 {0, },
158 {0, }, 158 {0, },
159 }, 159 },
160 /* 20 fps */ 160 /* 20 fps */
161 { 161 {
162 {0, }, 162 {0, },
163 {0, }, 163 {0, },
164 {0, }, 164 {0, },
165 {0, }, 165 {0, },
166 }, 166 },
167 /* 25 fps */ 167 /* 25 fps */
168 { 168 {
169 {0, }, 169 {0, },
170 {0, }, 170 {0, },
171 {0, }, 171 {0, },
172 {0, }, 172 {0, },
173 }, 173 },
174 /* 30 fps */ 174 /* 30 fps */
175 { 175 {
176 {0, }, 176 {0, },
177 {0, }, 177 {0, },
178 {0, }, 178 {0, },
179 {0, }, 179 {0, },
180 }, 180 },
181 }, 181 },
182 /* SIF */ 182 /* SIF */
183 { 183 {
184 /* 5 fps */ 184 /* 5 fps */
185 { 185 {
186 {4, 582, 0, {0x0D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x02, 0x80}}, 186 {4, 582, 0, {0x0D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x02, 0x80}},
187 {3, 387, 1276, {0x05, 0xF4, 0x30, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x01, 0x80}}, 187 {3, 387, 1276, {0x05, 0xF4, 0x30, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x01, 0x80}},
188 {2, 291, 960, {0x05, 0xF4, 0x30, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0x01, 0x80}}, 188 {2, 291, 960, {0x05, 0xF4, 0x30, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0x01, 0x80}},
189 {1, 191, 630, {0x05, 0xF4, 0x50, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x18, 0xBF, 0x00, 0x80}}, 189 {1, 191, 630, {0x05, 0xF4, 0x50, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x18, 0xBF, 0x00, 0x80}},
190 }, 190 },
191 /* 10 fps */ 191 /* 10 fps */
192 { 192 {
193 {0, }, 193 {0, },
194 {6, 775, 1278, {0x04, 0xF4, 0x30, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x03, 0x80}}, 194 {6, 775, 1278, {0x04, 0xF4, 0x30, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x03, 0x80}},
195 {3, 447, 736, {0x04, 0xF4, 0x30, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x28, 0xBF, 0x01, 0x80}}, 195 {3, 447, 736, {0x04, 0xF4, 0x30, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x28, 0xBF, 0x01, 0x80}},
196 {2, 292, 480, {0x04, 0xF4, 0x70, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x28, 0x24, 0x01, 0x80}}, 196 {2, 292, 480, {0x04, 0xF4, 0x70, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x28, 0x24, 0x01, 0x80}},
197 }, 197 },
198 /* 15 fps */ 198 /* 15 fps */
199 { 199 {
200 {0, }, 200 {0, },
201 {9, 955, 1050, {0x03, 0xF4, 0x30, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x03, 0x80}}, 201 {9, 955, 1050, {0x03, 0xF4, 0x30, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x03, 0x80}},
202 {4, 592, 650, {0x03, 0xF4, 0x30, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x50, 0x02, 0x80}}, 202 {4, 592, 650, {0x03, 0xF4, 0x30, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x50, 0x02, 0x80}},
203 {3, 448, 492, {0x03, 0xF4, 0x50, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x38, 0xC0, 0x01, 0x80}}, 203 {3, 448, 492, {0x03, 0xF4, 0x50, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x38, 0xC0, 0x01, 0x80}},
204 }, 204 },
205 /* 20 fps */ 205 /* 20 fps */
206 { 206 {
207 {0, }, 207 {0, },
208 {9, 958, 782, {0x02, 0xF4, 0x30, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x03, 0x80}}, 208 {9, 958, 782, {0x02, 0xF4, 0x30, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x03, 0x80}},
209 {5, 703, 574, {0x02, 0xF4, 0x50, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x02, 0x80}}, 209 {5, 703, 574, {0x02, 0xF4, 0x50, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x02, 0x80}},
210 {3, 446, 364, {0x02, 0xF4, 0x90, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x38, 0xBE, 0x01, 0x80}}, 210 {3, 446, 364, {0x02, 0xF4, 0x90, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x38, 0xBE, 0x01, 0x80}},
211 }, 211 },
212 /* 25 fps */ 212 /* 25 fps */
213 { 213 {
214 {0, }, 214 {0, },
215 {9, 958, 654, {0x01, 0xF4, 0x30, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x03, 0x80}}, 215 {9, 958, 654, {0x01, 0xF4, 0x30, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x03, 0x80}},
216 {6, 776, 530, {0x01, 0xF4, 0x50, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x03, 0x80}}, 216 {6, 776, 530, {0x01, 0xF4, 0x50, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x03, 0x80}},
217 {4, 592, 404, {0x01, 0xF4, 0x70, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x48, 0x50, 0x02, 0x80}}, 217 {4, 592, 404, {0x01, 0xF4, 0x70, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x48, 0x50, 0x02, 0x80}},
218 }, 218 },
219 /* 30 fps */ 219 /* 30 fps */
220 { 220 {
221 {0, }, 221 {0, },
222 {9, 957, 526, {0x00, 0xF4, 0x50, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x03, 0x80}}, 222 {9, 957, 526, {0x00, 0xF4, 0x50, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x03, 0x80}},
223 {6, 775, 426, {0x00, 0xF4, 0x70, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x03, 0x80}}, 223 {6, 775, 426, {0x00, 0xF4, 0x70, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x03, 0x80}},
224 {4, 590, 324, {0x00, 0x7A, 0x88, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x50, 0x4E, 0x02, 0x80}}, 224 {4, 590, 324, {0x00, 0x7A, 0x88, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x50, 0x4E, 0x02, 0x80}},
225 }, 225 },
226 }, 226 },
227 /* CIF */ 227 /* CIF */
228 { 228 {
229 /* 5 fps */ 229 /* 5 fps */
230 { 230 {
231 {0, }, 231 {0, },
232 {0, }, 232 {0, },
233 {0, }, 233 {0, },
234 {0, }, 234 {0, },
235 }, 235 },
236 /* 10 fps */ 236 /* 10 fps */
237 { 237 {
238 {0, }, 238 {0, },
239 {0, }, 239 {0, },
240 {0, }, 240 {0, },
241 {0, }, 241 {0, },
242 }, 242 },
243 /* 15 fps */ 243 /* 15 fps */
244 { 244 {
245 {0, }, 245 {0, },
246 {0, }, 246 {0, },
247 {0, }, 247 {0, },
248 {0, }, 248 {0, },
249 }, 249 },
250 /* 20 fps */ 250 /* 20 fps */
251 { 251 {
252 {0, }, 252 {0, },
253 {0, }, 253 {0, },
254 {0, }, 254 {0, },
255 {0, }, 255 {0, },
256 }, 256 },
257 /* 25 fps */ 257 /* 25 fps */
258 { 258 {
259 {0, }, 259 {0, },
260 {0, }, 260 {0, },
261 {0, }, 261 {0, },
262 {0, }, 262 {0, },
263 }, 263 },
264 /* 30 fps */ 264 /* 30 fps */
265 { 265 {
266 {0, }, 266 {0, },
267 {0, }, 267 {0, },
268 {0, }, 268 {0, },
269 {0, }, 269 {0, },
270 }, 270 },
271 }, 271 },
272 /* VGA */ 272 /* VGA */
273 { 273 {
274 /* 5 fps */ 274 /* 5 fps */
275 { 275 {
276 {0, }, 276 {0, },
277 {6, 773, 1272, {0x25, 0xF4, 0x30, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}}, 277 {6, 773, 1272, {0x25, 0xF4, 0x30, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}},
278 {4, 592, 976, {0x25, 0xF4, 0x50, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x02, 0x80}}, 278 {4, 592, 976, {0x25, 0xF4, 0x50, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x02, 0x80}},
279 {3, 448, 738, {0x25, 0xF4, 0x90, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x01, 0x80}}, 279 {3, 448, 738, {0x25, 0xF4, 0x90, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x01, 0x80}},
280 }, 280 },
281 /* 10 fps */ 281 /* 10 fps */
282 { 282 {
283 {0, }, 283 {0, },
284 {9, 956, 788, {0x24, 0xF4, 0x70, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x03, 0x80}}, 284 {9, 956, 788, {0x24, 0xF4, 0x70, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x03, 0x80}},
285 {6, 776, 640, {0x24, 0xF4, 0xB0, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x03, 0x80}}, 285 {6, 776, 640, {0x24, 0xF4, 0xB0, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x03, 0x80}},
286 {4, 592, 488, {0x24, 0x7A, 0xE8, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x02, 0x80}}, 286 {4, 592, 488, {0x24, 0x7A, 0xE8, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x02, 0x80}},
287 }, 287 },
288 /* 15 fps */ 288 /* 15 fps */
289 { 289 {
290 {0, }, 290 {0, },
291 {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}}, 291 {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
292 {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}}, 292 {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
293 {8, 895, 492, {0x23, 0x7A, 0xE8, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x03, 0x80}}, 293 {8, 895, 492, {0x23, 0x7A, 0xE8, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x03, 0x80}},
294 }, 294 },
295 /* 20 fps */ 295 /* 20 fps */
296 { 296 {
297 {0, }, 297 {0, },
298 {0, }, 298 {0, },
299 {0, }, 299 {0, },
300 {0, }, 300 {0, },
301 }, 301 },
302 /* 25 fps */ 302 /* 25 fps */
303 { 303 {
304 {0, }, 304 {0, },
305 {0, }, 305 {0, },
306 {0, }, 306 {0, },
307 {0, }, 307 {0, },
308 }, 308 },
309 /* 30 fps */ 309 /* 30 fps */
310 { 310 {
311 {0, }, 311 {0, },
312 {0, }, 312 {0, },
313 {0, }, 313 {0, },
314 {0, }, 314 {0, },
315 }, 315 },
316 }, 316 },
317}; 317};
diff --git a/drivers/media/video/pwc/pwc-misc.c b/drivers/media/video/pwc/pwc-misc.c
index b7a4bd3524c7..58fe79747992 100644
--- a/drivers/media/video/pwc/pwc-misc.c
+++ b/drivers/media/video/pwc/pwc-misc.c
@@ -1,4 +1,4 @@
1/* Linux driver for Philips webcam 1/* Linux driver for Philips webcam
2 Various miscellaneous functions and tables. 2 Various miscellaneous functions and tables.
3 (C) 1999-2003 Nemosoft Unv. 3 (C) 1999-2003 Nemosoft Unv.
4 (C) 2004 Luc Saillard (luc@saillard.org) 4 (C) 2004 Luc Saillard (luc@saillard.org)
@@ -44,17 +44,17 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height)
44 int i, find; 44 int i, find;
45 45
46 /* Make sure we don't go beyond our max size. 46 /* Make sure we don't go beyond our max size.
47 NB: we have different limits for RAW and normal modes. In case 47 NB: we have different limits for RAW and normal modes. In case
48 you don't have the decompressor loaded or use RAW mode, 48 you don't have the decompressor loaded or use RAW mode,
49 the maximum viewable size is smaller. 49 the maximum viewable size is smaller.
50 */ 50 */
51 if (pdev->vpalette == VIDEO_PALETTE_RAW) 51 if (pdev->vpalette == VIDEO_PALETTE_RAW)
52 { 52 {
53 if (width > pdev->abs_max.x || height > pdev->abs_max.y) 53 if (width > pdev->abs_max.x || height > pdev->abs_max.y)
54 { 54 {
55 Debug("VIDEO_PALETTE_RAW: going beyond abs_max.\n"); 55 Debug("VIDEO_PALETTE_RAW: going beyond abs_max.\n");
56 return -1; 56 return -1;
57 } 57 }
58 } 58 }
59 else 59 else
60 { 60 {
@@ -88,8 +88,8 @@ void pwc_construct(struct pwc_device *pdev)
88 pdev->view_min.y = 96; 88 pdev->view_min.y = 96;
89 pdev->view_max.x = 352; 89 pdev->view_max.x = 352;
90 pdev->view_max.y = 288; 90 pdev->view_max.y = 288;
91 pdev->abs_max.x = 352; 91 pdev->abs_max.x = 352;
92 pdev->abs_max.y = 288; 92 pdev->abs_max.y = 288;
93 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF; 93 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF;
94 pdev->vcinterface = 2; 94 pdev->vcinterface = 2;
95 pdev->vendpoint = 4; 95 pdev->vendpoint = 4;
@@ -105,8 +105,8 @@ void pwc_construct(struct pwc_device *pdev)
105 pdev->view_max.x = 640; 105 pdev->view_max.x = 640;
106 pdev->view_max.y = 480; 106 pdev->view_max.y = 480;
107 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA; 107 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
108 pdev->abs_max.x = 640; 108 pdev->abs_max.x = 640;
109 pdev->abs_max.y = 480; 109 pdev->abs_max.y = 480;
110 pdev->vcinterface = 3; 110 pdev->vcinterface = 3;
111 pdev->vendpoint = 4; 111 pdev->vendpoint = 4;
112 pdev->frame_header_size = 0; 112 pdev->frame_header_size = 0;
@@ -121,8 +121,8 @@ void pwc_construct(struct pwc_device *pdev)
121 pdev->view_max.x = 640; 121 pdev->view_max.x = 640;
122 pdev->view_max.y = 480; 122 pdev->view_max.y = 480;
123 pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA; 123 pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
124 pdev->abs_max.x = 640; 124 pdev->abs_max.x = 640;
125 pdev->abs_max.y = 480; 125 pdev->abs_max.y = 480;
126 pdev->vcinterface = 3; 126 pdev->vcinterface = 3;
127 pdev->vendpoint = 5; 127 pdev->vendpoint = 5;
128 pdev->frame_header_size = TOUCAM_HEADER_SIZE; 128 pdev->frame_header_size = TOUCAM_HEADER_SIZE;
diff --git a/drivers/media/video/pwc/pwc-nala.h b/drivers/media/video/pwc/pwc-nala.h
index e6c5cb69d03b..168c73ef75d8 100644
--- a/drivers/media/video/pwc/pwc-nala.h
+++ b/drivers/media/video/pwc/pwc-nala.h
@@ -54,7 +54,7 @@
54 {0}, 54 {0},
55 }, 55 },
56 /* VGA */ 56 /* VGA */
57 { 57 {
58 {0}, 58 {0},
59 {0}, 59 {0},
60 {0}, 60 {0},
diff --git a/drivers/media/video/pwc/pwc-timon.c b/drivers/media/video/pwc/pwc-timon.c
index dee967173d6c..175250d089cf 100644
--- a/drivers/media/video/pwc/pwc-timon.c
+++ b/drivers/media/video/pwc/pwc-timon.c
@@ -46,270 +46,270 @@ const struct Timon_table_entry Timon_table[PSZ_MAX][6][4] =
46 { 46 {
47 /* 5 fps */ 47 /* 5 fps */
48 { 48 {
49 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}}, 49 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
50 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}}, 50 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
51 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}}, 51 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
52 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}}, 52 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
53 }, 53 },
54 /* 10 fps */ 54 /* 10 fps */
55 { 55 {
56 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}}, 56 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
57 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}}, 57 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
58 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}}, 58 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
59 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}}, 59 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
60 }, 60 },
61 /* 15 fps */ 61 /* 15 fps */
62 { 62 {
63 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}}, 63 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
64 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}}, 64 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
65 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}}, 65 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
66 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}}, 66 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
67 }, 67 },
68 /* 20 fps */ 68 /* 20 fps */
69 { 69 {
70 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}}, 70 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
71 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}}, 71 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
72 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}}, 72 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
73 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}}, 73 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
74 }, 74 },
75 /* 25 fps */ 75 /* 25 fps */
76 { 76 {
77 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}}, 77 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
78 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}}, 78 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
79 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}}, 79 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
80 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}}, 80 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
81 }, 81 },
82 /* 30 fps */ 82 /* 30 fps */
83 { 83 {
84 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}}, 84 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
85 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}}, 85 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
86 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}}, 86 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
87 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}}, 87 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
88 }, 88 },
89 }, 89 },
90 /* QSIF */ 90 /* QSIF */
91 { 91 {
92 /* 5 fps */ 92 /* 5 fps */
93 { 93 {
94 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}}, 94 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
95 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}}, 95 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
96 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}}, 96 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
97 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}}, 97 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
98 }, 98 },
99 /* 10 fps */ 99 /* 10 fps */
100 { 100 {
101 {2, 291, 0, {0x2C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0xA1, 0xC0, 0x02}}, 101 {2, 291, 0, {0x2C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0xA1, 0xC0, 0x02}},
102 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}}, 102 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
103 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}}, 103 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
104 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}}, 104 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
105 }, 105 },
106 /* 15 fps */ 106 /* 15 fps */
107 { 107 {
108 {3, 437, 0, {0x2B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x6D, 0xC0, 0x02}}, 108 {3, 437, 0, {0x2B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x6D, 0xC0, 0x02}},
109 {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}}, 109 {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
110 {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}}, 110 {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
111 {1, 191, 420, {0x2B, 0xF4, 0x0D, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x08, 0xBF, 0xF4, 0xC0, 0x02}}, 111 {1, 191, 420, {0x2B, 0xF4, 0x0D, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
112 }, 112 },
113 /* 20 fps */ 113 /* 20 fps */
114 { 114 {
115 {4, 588, 0, {0x2A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4C, 0x52, 0xC0, 0x02}}, 115 {4, 588, 0, {0x2A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4C, 0x52, 0xC0, 0x02}},
116 {3, 447, 730, {0x2A, 0xF4, 0x05, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xBF, 0x69, 0xC0, 0x02}}, 116 {3, 447, 730, {0x2A, 0xF4, 0x05, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
117 {2, 292, 476, {0x2A, 0xF4, 0x0D, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0xA1, 0xC0, 0x02}}, 117 {2, 292, 476, {0x2A, 0xF4, 0x0D, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
118 {1, 192, 312, {0x2A, 0xF4, 0x1D, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}}, 118 {1, 192, 312, {0x2A, 0xF4, 0x1D, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
119 }, 119 },
120 /* 25 fps */ 120 /* 25 fps */
121 { 121 {
122 {5, 703, 0, {0x29, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x42, 0xC0, 0x02}}, 122 {5, 703, 0, {0x29, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x42, 0xC0, 0x02}},
123 {3, 447, 610, {0x29, 0xF4, 0x05, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x18, 0xBF, 0x69, 0xC0, 0x02}}, 123 {3, 447, 610, {0x29, 0xF4, 0x05, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
124 {2, 292, 398, {0x29, 0xF4, 0x0D, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}}, 124 {2, 292, 398, {0x29, 0xF4, 0x0D, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
125 {1, 192, 262, {0x29, 0xF4, 0x25, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}}, 125 {1, 192, 262, {0x29, 0xF4, 0x25, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
126 }, 126 },
127 /* 30 fps */ 127 /* 30 fps */
128 { 128 {
129 {8, 873, 0, {0x28, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x69, 0x37, 0xC0, 0x02}}, 129 {8, 873, 0, {0x28, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x69, 0x37, 0xC0, 0x02}},
130 {5, 704, 774, {0x28, 0xF4, 0x05, 0x18, 0x21, 0x17, 0x59, 0x0F, 0x18, 0xC0, 0x42, 0xC0, 0x02}}, 130 {5, 704, 774, {0x28, 0xF4, 0x05, 0x18, 0x21, 0x17, 0x59, 0x0F, 0x18, 0xC0, 0x42, 0xC0, 0x02}},
131 {3, 448, 492, {0x28, 0xF4, 0x05, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x18, 0xC0, 0x69, 0xC0, 0x02}}, 131 {3, 448, 492, {0x28, 0xF4, 0x05, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x18, 0xC0, 0x69, 0xC0, 0x02}},
132 {2, 291, 320, {0x28, 0xF4, 0x1D, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}}, 132 {2, 291, 320, {0x28, 0xF4, 0x1D, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
133 }, 133 },
134 }, 134 },
135 /* QCIF */ 135 /* QCIF */
136 { 136 {
137 /* 5 fps */ 137 /* 5 fps */
138 { 138 {
139 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}}, 139 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
140 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}}, 140 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
141 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}}, 141 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
142 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}}, 142 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
143 }, 143 },
144 /* 10 fps */ 144 /* 10 fps */
145 { 145 {
146 {3, 385, 0, {0x0C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x81, 0x79, 0xC0, 0x02}}, 146 {3, 385, 0, {0x0C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x81, 0x79, 0xC0, 0x02}},
147 {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}}, 147 {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
148 {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}}, 148 {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
149 {1, 194, 532, {0x0C, 0xF4, 0x05, 0x10, 0x9A, 0x0F, 0xBE, 0x1B, 0x08, 0xC2, 0xF0, 0xC0, 0x02}}, 149 {1, 194, 532, {0x0C, 0xF4, 0x05, 0x10, 0x9A, 0x0F, 0xBE, 0x1B, 0x08, 0xC2, 0xF0, 0xC0, 0x02}},
150 }, 150 },
151 /* 15 fps */ 151 /* 15 fps */
152 { 152 {
153 {4, 577, 0, {0x0B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x41, 0x52, 0xC0, 0x02}}, 153 {4, 577, 0, {0x0B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x41, 0x52, 0xC0, 0x02}},
154 {3, 447, 818, {0x0B, 0xF4, 0x05, 0x19, 0x89, 0x18, 0xAD, 0x0F, 0x10, 0xBF, 0x69, 0xC0, 0x02}}, 154 {3, 447, 818, {0x0B, 0xF4, 0x05, 0x19, 0x89, 0x18, 0xAD, 0x0F, 0x10, 0xBF, 0x69, 0xC0, 0x02}},
155 {2, 292, 534, {0x0B, 0xF4, 0x05, 0x10, 0xA3, 0x0F, 0xC7, 0x19, 0x10, 0x24, 0xA1, 0xC0, 0x02}}, 155 {2, 292, 534, {0x0B, 0xF4, 0x05, 0x10, 0xA3, 0x0F, 0xC7, 0x19, 0x10, 0x24, 0xA1, 0xC0, 0x02}},
156 {1, 195, 356, {0x0B, 0xF4, 0x15, 0x0B, 0x11, 0x0A, 0x35, 0x1E, 0x10, 0xC3, 0xF0, 0xC0, 0x02}}, 156 {1, 195, 356, {0x0B, 0xF4, 0x15, 0x0B, 0x11, 0x0A, 0x35, 0x1E, 0x10, 0xC3, 0xF0, 0xC0, 0x02}},
157 }, 157 },
158 /* 20 fps */ 158 /* 20 fps */
159 { 159 {
160 {6, 776, 0, {0x0A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x08, 0x3F, 0xC0, 0x02}}, 160 {6, 776, 0, {0x0A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x08, 0x3F, 0xC0, 0x02}},
161 {4, 591, 804, {0x0A, 0xF4, 0x05, 0x19, 0x1E, 0x18, 0x42, 0x0F, 0x18, 0x4F, 0x4E, 0xC0, 0x02}}, 161 {4, 591, 804, {0x0A, 0xF4, 0x05, 0x19, 0x1E, 0x18, 0x42, 0x0F, 0x18, 0x4F, 0x4E, 0xC0, 0x02}},
162 {3, 447, 608, {0x0A, 0xF4, 0x05, 0x12, 0xFD, 0x12, 0x21, 0x15, 0x18, 0xBF, 0x69, 0xC0, 0x02}}, 162 {3, 447, 608, {0x0A, 0xF4, 0x05, 0x12, 0xFD, 0x12, 0x21, 0x15, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
163 {2, 291, 396, {0x0A, 0xF4, 0x15, 0x0C, 0x5E, 0x0B, 0x82, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}}, 163 {2, 291, 396, {0x0A, 0xF4, 0x15, 0x0C, 0x5E, 0x0B, 0x82, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
164 }, 164 },
165 /* 25 fps */ 165 /* 25 fps */
166 { 166 {
167 {9, 928, 0, {0x09, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xA0, 0x33, 0xC0, 0x02}}, 167 {9, 928, 0, {0x09, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xA0, 0x33, 0xC0, 0x02}},
168 {5, 703, 800, {0x09, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x10, 0x18, 0xBF, 0x42, 0xC0, 0x02}}, 168 {5, 703, 800, {0x09, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x10, 0x18, 0xBF, 0x42, 0xC0, 0x02}},
169 {3, 447, 508, {0x09, 0xF4, 0x0D, 0x0F, 0xD2, 0x0E, 0xF6, 0x1B, 0x18, 0xBF, 0x69, 0xC0, 0x02}}, 169 {3, 447, 508, {0x09, 0xF4, 0x0D, 0x0F, 0xD2, 0x0E, 0xF6, 0x1B, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
170 {2, 292, 332, {0x09, 0xF4, 0x1D, 0x0A, 0x5A, 0x09, 0x7E, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}}, 170 {2, 292, 332, {0x09, 0xF4, 0x1D, 0x0A, 0x5A, 0x09, 0x7E, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
171 }, 171 },
172 /* 30 fps */ 172 /* 30 fps */
173 { 173 {
174 {0, }, 174 {0, },
175 {9, 956, 876, {0x08, 0xF4, 0x05, 0x1B, 0x58, 0x1A, 0x7C, 0x0E, 0x20, 0xBC, 0x33, 0x10, 0x02}}, 175 {9, 956, 876, {0x08, 0xF4, 0x05, 0x1B, 0x58, 0x1A, 0x7C, 0x0E, 0x20, 0xBC, 0x33, 0x10, 0x02}},
176 {4, 592, 542, {0x08, 0xF4, 0x05, 0x10, 0xE4, 0x10, 0x08, 0x17, 0x20, 0x50, 0x4E, 0x10, 0x02}}, 176 {4, 592, 542, {0x08, 0xF4, 0x05, 0x10, 0xE4, 0x10, 0x08, 0x17, 0x20, 0x50, 0x4E, 0x10, 0x02}},
177 {2, 291, 266, {0x08, 0xF4, 0x25, 0x08, 0x48, 0x07, 0x6C, 0x1E, 0x20, 0x23, 0xA1, 0x10, 0x02}}, 177 {2, 291, 266, {0x08, 0xF4, 0x25, 0x08, 0x48, 0x07, 0x6C, 0x1E, 0x20, 0x23, 0xA1, 0x10, 0x02}},
178 }, 178 },
179 }, 179 },
180 /* SIF */ 180 /* SIF */
181 { 181 {
182 /* 5 fps */ 182 /* 5 fps */
183 { 183 {
184 {4, 582, 0, {0x35, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x52, 0x60, 0x02}}, 184 {4, 582, 0, {0x35, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x52, 0x60, 0x02}},
185 {3, 387, 1276, {0x35, 0xF4, 0x05, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x79, 0x60, 0x02}}, 185 {3, 387, 1276, {0x35, 0xF4, 0x05, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x79, 0x60, 0x02}},
186 {2, 291, 960, {0x35, 0xF4, 0x0D, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0xA1, 0x60, 0x02}}, 186 {2, 291, 960, {0x35, 0xF4, 0x0D, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0xA1, 0x60, 0x02}},
187 {1, 191, 630, {0x35, 0xF4, 0x1D, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x08, 0xBF, 0xF4, 0x60, 0x02}}, 187 {1, 191, 630, {0x35, 0xF4, 0x1D, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x08, 0xBF, 0xF4, 0x60, 0x02}},
188 }, 188 },
189 /* 10 fps */ 189 /* 10 fps */
190 { 190 {
191 {0, }, 191 {0, },
192 {6, 775, 1278, {0x34, 0xF4, 0x05, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x3F, 0x10, 0x02}}, 192 {6, 775, 1278, {0x34, 0xF4, 0x05, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x3F, 0x10, 0x02}},
193 {3, 447, 736, {0x34, 0xF4, 0x15, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x18, 0xBF, 0x69, 0x10, 0x02}}, 193 {3, 447, 736, {0x34, 0xF4, 0x15, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x18, 0xBF, 0x69, 0x10, 0x02}},
194 {2, 291, 480, {0x34, 0xF4, 0x2D, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x18, 0x23, 0xA1, 0x10, 0x02}}, 194 {2, 291, 480, {0x34, 0xF4, 0x2D, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x18, 0x23, 0xA1, 0x10, 0x02}},
195 }, 195 },
196 /* 15 fps */ 196 /* 15 fps */
197 { 197 {
198 {0, }, 198 {0, },
199 {9, 955, 1050, {0x33, 0xF4, 0x05, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x33, 0x10, 0x02}}, 199 {9, 955, 1050, {0x33, 0xF4, 0x05, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x33, 0x10, 0x02}},
200 {4, 591, 650, {0x33, 0xF4, 0x15, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x4F, 0x4E, 0x10, 0x02}}, 200 {4, 591, 650, {0x33, 0xF4, 0x15, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x4F, 0x4E, 0x10, 0x02}},
201 {3, 448, 492, {0x33, 0xF4, 0x25, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x28, 0xC0, 0x69, 0x10, 0x02}}, 201 {3, 448, 492, {0x33, 0xF4, 0x25, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x28, 0xC0, 0x69, 0x10, 0x02}},
202 }, 202 },
203 /* 20 fps */ 203 /* 20 fps */
204 { 204 {
205 {0, }, 205 {0, },
206 {9, 958, 782, {0x32, 0xF4, 0x0D, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x33, 0xD0, 0x02}}, 206 {9, 958, 782, {0x32, 0xF4, 0x0D, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x33, 0xD0, 0x02}},
207 {5, 703, 574, {0x32, 0xF4, 0x1D, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x42, 0xD0, 0x02}}, 207 {5, 703, 574, {0x32, 0xF4, 0x1D, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x42, 0xD0, 0x02}},
208 {3, 446, 364, {0x32, 0xF4, 0x3D, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x30, 0xBE, 0x69, 0xD0, 0x02}}, 208 {3, 446, 364, {0x32, 0xF4, 0x3D, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x30, 0xBE, 0x69, 0xD0, 0x02}},
209 }, 209 },
210 /* 25 fps */ 210 /* 25 fps */
211 { 211 {
212 {0, }, 212 {0, },
213 {9, 958, 654, {0x31, 0xF4, 0x15, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x33, 0x90, 0x02}}, 213 {9, 958, 654, {0x31, 0xF4, 0x15, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x33, 0x90, 0x02}},
214 {6, 776, 530, {0x31, 0xF4, 0x25, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x3F, 0x90, 0x02}}, 214 {6, 776, 530, {0x31, 0xF4, 0x25, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x3F, 0x90, 0x02}},
215 {4, 592, 404, {0x31, 0xF4, 0x35, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x38, 0x50, 0x4E, 0x90, 0x02}}, 215 {4, 592, 404, {0x31, 0xF4, 0x35, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x38, 0x50, 0x4E, 0x90, 0x02}},
216 }, 216 },
217 /* 30 fps */ 217 /* 30 fps */
218 { 218 {
219 {0, }, 219 {0, },
220 {9, 957, 526, {0x30, 0xF4, 0x25, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x33, 0x60, 0x02}}, 220 {9, 957, 526, {0x30, 0xF4, 0x25, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x33, 0x60, 0x02}},
221 {6, 775, 426, {0x30, 0xF4, 0x35, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x3F, 0x60, 0x02}}, 221 {6, 775, 426, {0x30, 0xF4, 0x35, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x3F, 0x60, 0x02}},
222 {4, 590, 324, {0x30, 0x7A, 0x4B, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x40, 0x4E, 0x52, 0x60, 0x02}}, 222 {4, 590, 324, {0x30, 0x7A, 0x4B, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x40, 0x4E, 0x52, 0x60, 0x02}},
223 }, 223 },
224 }, 224 },
225 /* CIF */ 225 /* CIF */
226 { 226 {
227 /* 5 fps */ 227 /* 5 fps */
228 { 228 {
229 {6, 771, 0, {0x15, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x3F, 0x80, 0x02}}, 229 {6, 771, 0, {0x15, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x3F, 0x80, 0x02}},
230 {4, 465, 1278, {0x15, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x03, 0x18, 0xD1, 0x65, 0x80, 0x02}}, 230 {4, 465, 1278, {0x15, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x03, 0x18, 0xD1, 0x65, 0x80, 0x02}},
231 {2, 291, 800, {0x15, 0xF4, 0x15, 0x18, 0xF4, 0x17, 0x3C, 0x05, 0x18, 0x23, 0xA1, 0x80, 0x02}}, 231 {2, 291, 800, {0x15, 0xF4, 0x15, 0x18, 0xF4, 0x17, 0x3C, 0x05, 0x18, 0x23, 0xA1, 0x80, 0x02}},
232 {1, 193, 528, {0x15, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x18, 0xC1, 0xF4, 0x80, 0x02}}, 232 {1, 193, 528, {0x15, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x18, 0xC1, 0xF4, 0x80, 0x02}},
233 }, 233 },
234 /* 10 fps */ 234 /* 10 fps */
235 { 235 {
236 {0, }, 236 {0, },
237 {9, 932, 1278, {0x14, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x04, 0x30, 0xA4, 0x33, 0x10, 0x02}}, 237 {9, 932, 1278, {0x14, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x04, 0x30, 0xA4, 0x33, 0x10, 0x02}},
238 {4, 591, 812, {0x14, 0xF4, 0x15, 0x19, 0x56, 0x17, 0x9E, 0x06, 0x28, 0x4F, 0x4E, 0x10, 0x02}}, 238 {4, 591, 812, {0x14, 0xF4, 0x15, 0x19, 0x56, 0x17, 0x9E, 0x06, 0x28, 0x4F, 0x4E, 0x10, 0x02}},
239 {2, 291, 400, {0x14, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x28, 0x23, 0xA1, 0x10, 0x02}}, 239 {2, 291, 400, {0x14, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x28, 0x23, 0xA1, 0x10, 0x02}},
240 }, 240 },
241 /* 15 fps */ 241 /* 15 fps */
242 { 242 {
243 {0, }, 243 {0, },
244 {9, 956, 876, {0x13, 0xF4, 0x0D, 0x1B, 0x58, 0x19, 0xA0, 0x05, 0x38, 0xBC, 0x33, 0x60, 0x02}}, 244 {9, 956, 876, {0x13, 0xF4, 0x0D, 0x1B, 0x58, 0x19, 0xA0, 0x05, 0x38, 0xBC, 0x33, 0x60, 0x02}},
245 {5, 703, 644, {0x13, 0xF4, 0x1D, 0x14, 0x1C, 0x12, 0x64, 0x08, 0x38, 0xBF, 0x42, 0x60, 0x02}}, 245 {5, 703, 644, {0x13, 0xF4, 0x1D, 0x14, 0x1C, 0x12, 0x64, 0x08, 0x38, 0xBF, 0x42, 0x60, 0x02}},
246 {3, 448, 410, {0x13, 0xF4, 0x3D, 0x0C, 0xC4, 0x0B, 0x0C, 0x0E, 0x38, 0xC0, 0x69, 0x60, 0x02}}, 246 {3, 448, 410, {0x13, 0xF4, 0x3D, 0x0C, 0xC4, 0x0B, 0x0C, 0x0E, 0x38, 0xC0, 0x69, 0x60, 0x02}},
247 }, 247 },
248 /* 20 fps */ 248 /* 20 fps */
249 { 249 {
250 {0, }, 250 {0, },
251 {9, 956, 650, {0x12, 0xF4, 0x1D, 0x14, 0x4A, 0x12, 0x92, 0x09, 0x48, 0xBC, 0x33, 0x10, 0x03}}, 251 {9, 956, 650, {0x12, 0xF4, 0x1D, 0x14, 0x4A, 0x12, 0x92, 0x09, 0x48, 0xBC, 0x33, 0x10, 0x03}},
252 {6, 776, 528, {0x12, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x40, 0x08, 0x3F, 0x10, 0x03}}, 252 {6, 776, 528, {0x12, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x40, 0x08, 0x3F, 0x10, 0x03}},
253 {4, 591, 402, {0x12, 0xF4, 0x3D, 0x0C, 0x8F, 0x0A, 0xD7, 0x0E, 0x40, 0x4F, 0x4E, 0x10, 0x03}}, 253 {4, 591, 402, {0x12, 0xF4, 0x3D, 0x0C, 0x8F, 0x0A, 0xD7, 0x0E, 0x40, 0x4F, 0x4E, 0x10, 0x03}},
254 }, 254 },
255 /* 25 fps */ 255 /* 25 fps */
256 { 256 {
257 {0, }, 257 {0, },
258 {9, 956, 544, {0x11, 0xF4, 0x25, 0x10, 0xF4, 0x0F, 0x3C, 0x0A, 0x48, 0xBC, 0x33, 0xC0, 0x02}}, 258 {9, 956, 544, {0x11, 0xF4, 0x25, 0x10, 0xF4, 0x0F, 0x3C, 0x0A, 0x48, 0xBC, 0x33, 0xC0, 0x02}},
259 {7, 840, 478, {0x11, 0xF4, 0x2D, 0x0E, 0xEB, 0x0D, 0x33, 0x0B, 0x48, 0x48, 0x3B, 0xC0, 0x02}}, 259 {7, 840, 478, {0x11, 0xF4, 0x2D, 0x0E, 0xEB, 0x0D, 0x33, 0x0B, 0x48, 0x48, 0x3B, 0xC0, 0x02}},
260 {5, 703, 400, {0x11, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x48, 0xBF, 0x42, 0xC0, 0x02}}, 260 {5, 703, 400, {0x11, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x48, 0xBF, 0x42, 0xC0, 0x02}},
261 }, 261 },
262 /* 30 fps */ 262 /* 30 fps */
263 { 263 {
264 {0, }, 264 {0, },
265 {9, 956, 438, {0x10, 0xF4, 0x35, 0x0D, 0xAC, 0x0B, 0xF4, 0x0D, 0x50, 0xBC, 0x33, 0x10, 0x02}}, 265 {9, 956, 438, {0x10, 0xF4, 0x35, 0x0D, 0xAC, 0x0B, 0xF4, 0x0D, 0x50, 0xBC, 0x33, 0x10, 0x02}},
266 {7, 838, 384, {0x10, 0xF4, 0x45, 0x0B, 0xFD, 0x0A, 0x45, 0x0F, 0x50, 0x46, 0x3B, 0x10, 0x02}}, 266 {7, 838, 384, {0x10, 0xF4, 0x45, 0x0B, 0xFD, 0x0A, 0x45, 0x0F, 0x50, 0x46, 0x3B, 0x10, 0x02}},
267 {6, 773, 354, {0x10, 0x7A, 0x4B, 0x0B, 0x0C, 0x09, 0x80, 0x10, 0x50, 0x05, 0x3F, 0x10, 0x02}}, 267 {6, 773, 354, {0x10, 0x7A, 0x4B, 0x0B, 0x0C, 0x09, 0x80, 0x10, 0x50, 0x05, 0x3F, 0x10, 0x02}},
268 }, 268 },
269 }, 269 },
270 /* VGA */ 270 /* VGA */
271 { 271 {
272 /* 5 fps */ 272 /* 5 fps */
273 { 273 {
274 {0, }, 274 {0, },
275 {6, 773, 1272, {0x1D, 0xF4, 0x15, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x3F, 0x10, 0x02}}, 275 {6, 773, 1272, {0x1D, 0xF4, 0x15, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x3F, 0x10, 0x02}},
276 {4, 592, 976, {0x1D, 0xF4, 0x25, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x4E, 0x10, 0x02}}, 276 {4, 592, 976, {0x1D, 0xF4, 0x25, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x4E, 0x10, 0x02}},
277 {3, 448, 738, {0x1D, 0xF4, 0x3D, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x69, 0x10, 0x02}}, 277 {3, 448, 738, {0x1D, 0xF4, 0x3D, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x69, 0x10, 0x02}},
278 }, 278 },
279 /* 10 fps */ 279 /* 10 fps */
280 { 280 {
281 {0, }, 281 {0, },
282 {9, 956, 788, {0x1C, 0xF4, 0x35, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x33, 0x10, 0x02}}, 282 {9, 956, 788, {0x1C, 0xF4, 0x35, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x33, 0x10, 0x02}},
283 {6, 776, 640, {0x1C, 0x7A, 0x53, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x3F, 0x10, 0x02}}, 283 {6, 776, 640, {0x1C, 0x7A, 0x53, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x3F, 0x10, 0x02}},
284 {4, 592, 488, {0x1C, 0x7A, 0x6B, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x4E, 0x10, 0x02}}, 284 {4, 592, 488, {0x1C, 0x7A, 0x6B, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x4E, 0x10, 0x02}},
285 }, 285 },
286 /* 15 fps */ 286 /* 15 fps */
287 { 287 {
288 {0, }, 288 {0, },
289 {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}}, 289 {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
290 {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}}, 290 {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
291 {8, 895, 492, {0x1B, 0x7A, 0x6B, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x37, 0x80, 0x02}}, 291 {8, 895, 492, {0x1B, 0x7A, 0x6B, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x37, 0x80, 0x02}},
292 }, 292 },
293 /* 20 fps */ 293 /* 20 fps */
294 { 294 {
295 {0, }, 295 {0, },
296 {0, }, 296 {0, },
297 {0, }, 297 {0, },
298 {0, }, 298 {0, },
299 }, 299 },
300 /* 25 fps */ 300 /* 25 fps */
301 { 301 {
302 {0, }, 302 {0, },
303 {0, }, 303 {0, },
304 {0, }, 304 {0, },
305 {0, }, 305 {0, },
306 }, 306 },
307 /* 30 fps */ 307 /* 30 fps */
308 { 308 {
309 {0, }, 309 {0, },
310 {0, }, 310 {0, },
311 {0, }, 311 {0, },
312 {0, }, 312 {0, },
313 }, 313 },
314 }, 314 },
315}; 315};
diff --git a/drivers/media/video/pwc/pwc-uncompress.c b/drivers/media/video/pwc/pwc-uncompress.c
index ef4204eab6c4..b37a89a163f9 100644
--- a/drivers/media/video/pwc/pwc-uncompress.c
+++ b/drivers/media/video/pwc/pwc-uncompress.c
@@ -109,9 +109,9 @@ int pwc_decompress(struct pwc_device *pdev)
109 in planar format immediately. 109 in planar format immediately.
110 */ 110 */
111 int flags; 111 int flags;
112 112
113 flags = PWCX_FLAG_PLANAR; 113 flags = PWCX_FLAG_PLANAR;
114 if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot) 114 if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot)
115 { 115 {
116 printk(KERN_ERR "pwc: Mode Bayer is not supported for now\n"); 116 printk(KERN_ERR "pwc: Mode Bayer is not supported for now\n");
117 flags |= PWCX_FLAG_BAYER; 117 flags |= PWCX_FLAG_BAYER;
diff --git a/drivers/media/video/pwc/pwc-uncompress.h b/drivers/media/video/pwc/pwc-uncompress.h
index d3b9250e4ed3..f75e1b6cbe19 100644
--- a/drivers/media/video/pwc/pwc-uncompress.h
+++ b/drivers/media/video/pwc/pwc-uncompress.h
@@ -24,7 +24,7 @@
24 24
25/* This file is the bridge between the kernel module and the plugin; it 25/* This file is the bridge between the kernel module and the plugin; it
26 describes the structures and datatypes used in both modules. Any 26 describes the structures and datatypes used in both modules. Any
27 significant change should be reflected by increasing the 27 significant change should be reflected by increasing the
28 pwc_decompressor_version major number. 28 pwc_decompressor_version major number.
29 */ 29 */
30#ifndef PWC_UNCOMPRESS_H 30#ifndef PWC_UNCOMPRESS_H
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 6dd76bb3dff1..1b0ee0ced0ed 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -123,7 +123,7 @@ struct pwc_device
123#endif 123#endif
124 /* Pointer to our usb_device */ 124 /* Pointer to our usb_device */
125 struct usb_device *udev; 125 struct usb_device *udev;
126 126
127 int type; /* type of cam (645, 646, 675, 680, 690, 720, 730, 740, 750) */ 127 int type; /* type of cam (645, 646, 675, 680, 690, 720, 730, 740, 750) */
128 int release; /* release number */ 128 int release; /* release number */
129 int features; /* feature bits */ 129 int features; /* feature bits */
@@ -149,7 +149,7 @@ struct pwc_device
149 char vsnapshot; /* snapshot mode */ 149 char vsnapshot; /* snapshot mode */
150 char vsync; /* used by isoc handler */ 150 char vsync; /* used by isoc handler */
151 char vmirror; /* for ToUCaM series */ 151 char vmirror; /* for ToUCaM series */
152 152
153 int cmd_len; 153 int cmd_len;
154 unsigned char cmd_buf[13]; 154 unsigned char cmd_buf[13];
155 155
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index a9f3cf0b1e3c..531e9461cb66 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -71,7 +71,7 @@
71#define NUM_BUFS 8 71#define NUM_BUFS 8
72#define IF_NAME "SAA5249" 72#define IF_NAME "SAA5249"
73 73
74static const int disp_modes[8][3] = 74static const int disp_modes[8][3] =
75{ 75{
76 { 0x46, 0x03, 0x03 }, /* DISPOFF */ 76 { 0x46, 0x03, 0x03 }, /* DISPOFF */
77 { 0x46, 0xcc, 0xcc }, /* DISPNORM */ 77 { 0x46, 0xcc, 0xcc }, /* DISPNORM */
@@ -150,8 +150,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
150 client=kmalloc(sizeof(*client), GFP_KERNEL); 150 client=kmalloc(sizeof(*client), GFP_KERNEL);
151 if(client==NULL) 151 if(client==NULL)
152 return -ENOMEM; 152 return -ENOMEM;
153 client_template.adapter = adap; 153 client_template.adapter = adap;
154 client_template.addr = addr; 154 client_template.addr = addr;
155 memcpy(client, &client_template, sizeof(*client)); 155 memcpy(client, &client_template, sizeof(*client));
156 t = kzalloc(sizeof(*t), GFP_KERNEL); 156 t = kzalloc(sizeof(*t), GFP_KERNEL);
157 if(t==NULL) 157 if(t==NULL)
@@ -161,11 +161,11 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
161 } 161 }
162 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); 162 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE);
163 mutex_init(&t->lock); 163 mutex_init(&t->lock);
164 164
165 /* 165 /*
166 * Now create a video4linux device 166 * Now create a video4linux device
167 */ 167 */
168 168
169 vd = kmalloc(sizeof(struct video_device), GFP_KERNEL); 169 vd = kmalloc(sizeof(struct video_device), GFP_KERNEL);
170 if(vd==NULL) 170 if(vd==NULL)
171 { 171 {
@@ -175,8 +175,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
175 } 175 }
176 i2c_set_clientdata(client, vd); 176 i2c_set_clientdata(client, vd);
177 memcpy(vd, &saa_template, sizeof(*vd)); 177 memcpy(vd, &saa_template, sizeof(*vd));
178 178
179 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) 179 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
180 { 180 {
181 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); 181 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
182 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs)); 182 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs));
@@ -186,9 +186,9 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
186 t->vdau[pgbuf].stopped = TRUE; 186 t->vdau[pgbuf].stopped = TRUE;
187 t->is_searching[pgbuf] = FALSE; 187 t->is_searching[pgbuf] = FALSE;
188 } 188 }
189 vd->priv=t; 189 vd->priv=t;
190 190
191 191
192 /* 192 /*
193 * Register it 193 * Register it
194 */ 194 */
@@ -208,7 +208,7 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
208/* 208/*
209 * We do most of the hard work when we become a device on the i2c. 209 * We do most of the hard work when we become a device on the i2c.
210 */ 210 */
211 211
212static int saa5249_probe(struct i2c_adapter *adap) 212static int saa5249_probe(struct i2c_adapter *adap)
213{ 213{
214 if (adap->class & I2C_CLASS_TV_ANALOG) 214 if (adap->class & I2C_CLASS_TV_ANALOG)
@@ -229,7 +229,7 @@ static int saa5249_detach(struct i2c_client *client)
229 229
230/* new I2C driver support */ 230/* new I2C driver support */
231 231
232static struct i2c_driver i2c_driver_videotext = 232static struct i2c_driver i2c_driver_videotext =
233{ 233{
234 .driver = { 234 .driver = {
235 .name = IF_NAME, /* name */ 235 .name = IF_NAME, /* name */
@@ -249,7 +249,7 @@ static struct i2c_client client_template = {
249 * delay may be longer. 249 * delay may be longer.
250 */ 250 */
251 251
252static void jdelay(unsigned long delay) 252static void jdelay(unsigned long delay)
253{ 253{
254 sigset_t oldblocked = current->blocked; 254 sigset_t oldblocked = current->blocked;
255 255
@@ -269,14 +269,14 @@ static void jdelay(unsigned long delay)
269/* 269/*
270 * I2C interfaces 270 * I2C interfaces
271 */ 271 */
272 272
273static int i2c_sendbuf(struct saa5249_device *t, int reg, int count, u8 *data) 273static int i2c_sendbuf(struct saa5249_device *t, int reg, int count, u8 *data)
274{ 274{
275 char buf[64]; 275 char buf[64];
276 276
277 buf[0] = reg; 277 buf[0] = reg;
278 memcpy(buf+1, data, count); 278 memcpy(buf+1, data, count);
279 279
280 if(i2c_master_send(t->client, buf, count+1)==count+1) 280 if(i2c_master_send(t->client, buf, count+1)==count+1)
281 return 0; 281 return 0;
282 return -1; 282 return -1;
@@ -289,7 +289,7 @@ static int i2c_senddata(struct saa5249_device *t, ...)
289 int ct=0; 289 int ct=0;
290 va_list argp; 290 va_list argp;
291 va_start(argp,t); 291 va_start(argp,t);
292 292
293 while((v=va_arg(argp,int))!=-1) 293 while((v=va_arg(argp,int))!=-1)
294 buf[ct++]=v; 294 buf[ct++]=v;
295 return i2c_sendbuf(t, buf[0], ct-1, buf+1); 295 return i2c_sendbuf(t, buf[0], ct-1, buf+1);
@@ -301,7 +301,7 @@ static int i2c_senddata(struct saa5249_device *t, ...)
301 * Returns -1 if I²C-device didn't send acknowledge, 0 otherwise 301 * Returns -1 if I²C-device didn't send acknowledge, 0 otherwise
302 */ 302 */
303 303
304static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf) 304static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf)
305{ 305{
306 if(i2c_master_recv(t->client, buf, count)!=count) 306 if(i2c_master_recv(t->client, buf, count)!=count)
307 return -1; 307 return -1;
@@ -320,9 +320,9 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
320 struct video_device *vd = video_devdata(file); 320 struct video_device *vd = video_devdata(file);
321 struct saa5249_device *t=vd->priv; 321 struct saa5249_device *t=vd->priv;
322 322
323 switch(cmd) 323 switch(cmd)
324 { 324 {
325 case VTXIOCGETINFO: 325 case VTXIOCGETINFO:
326 { 326 {
327 vtx_info_t *info = arg; 327 vtx_info_t *info = arg;
328 info->version_major = VTX_VER_MAJ; 328 info->version_major = VTX_VER_MAJ;
@@ -332,10 +332,10 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
332 return 0; 332 return 0;
333 } 333 }
334 334
335 case VTXIOCCLRPAGE: 335 case VTXIOCCLRPAGE:
336 { 336 {
337 vtx_pagereq_t *req = arg; 337 vtx_pagereq_t *req = arg;
338 338
339 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) 339 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
340 return -EINVAL; 340 return -EINVAL;
341 memset(t->vdau[req->pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); 341 memset(t->vdau[req->pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
@@ -343,17 +343,17 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
343 return 0; 343 return 0;
344 } 344 }
345 345
346 case VTXIOCCLRFOUND: 346 case VTXIOCCLRFOUND:
347 { 347 {
348 vtx_pagereq_t *req = arg; 348 vtx_pagereq_t *req = arg;
349 349
350 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) 350 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
351 return -EINVAL; 351 return -EINVAL;
352 t->vdau[req->pgbuf].clrfound = TRUE; 352 t->vdau[req->pgbuf].clrfound = TRUE;
353 return 0; 353 return 0;
354 } 354 }
355 355
356 case VTXIOCPAGEREQ: 356 case VTXIOCPAGEREQ:
357 { 357 {
358 vtx_pagereq_t *req = arg; 358 vtx_pagereq_t *req = arg;
359 if (!(req->pagemask & PGMASK_PAGE)) 359 if (!(req->pagemask & PGMASK_PAGE))
@@ -381,7 +381,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
381 return 0; 381 return 0;
382 } 382 }
383 383
384 case VTXIOCGETSTAT: 384 case VTXIOCGETSTAT:
385 { 385 {
386 vtx_pagereq_t *req = arg; 386 vtx_pagereq_t *req = arg;
387 u8 infobits[10]; 387 u8 infobits[10];
@@ -390,7 +390,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
390 390
391 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) 391 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
392 return -EINVAL; 392 return -EINVAL;
393 if (!t->vdau[req->pgbuf].stopped) 393 if (!t->vdau[req->pgbuf].stopped)
394 { 394 {
395 if (i2c_senddata(t, 2, 0, -1) || 395 if (i2c_senddata(t, 2, 0, -1) ||
396 i2c_sendbuf(t, 3, sizeof(t->vdau[0].sregs), t->vdau[req->pgbuf].sregs) || 396 i2c_sendbuf(t, 3, sizeof(t->vdau[0].sregs), t->vdau[req->pgbuf].sregs) ||
@@ -403,7 +403,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
403 return -EIO; 403 return -EIO;
404 404
405 if (!(infobits[8] & 0x10) && !(infobits[7] & 0xf0) && /* check FOUND-bit */ 405 if (!(infobits[8] & 0x10) && !(infobits[7] & 0xf0) && /* check FOUND-bit */
406 (memcmp(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)) || 406 (memcmp(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)) ||
407 time_after_eq(jiffies, t->vdau[req->pgbuf].expire))) 407 time_after_eq(jiffies, t->vdau[req->pgbuf].expire)))
408 { /* check if new page arrived */ 408 { /* check if new page arrived */
409 if (i2c_senddata(t, 8, 0, 0, 0, -1) || 409 if (i2c_senddata(t, 8, 0, 0, 0, -1) ||
@@ -411,7 +411,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
411 return -EIO; 411 return -EIO;
412 t->vdau[req->pgbuf].expire = jiffies + PGBUF_EXPIRE; 412 t->vdau[req->pgbuf].expire = jiffies + PGBUF_EXPIRE;
413 memset(t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE, ' ', VTX_VIRTUALSIZE - VTX_PAGESIZE); 413 memset(t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE, ' ', VTX_VIRTUALSIZE - VTX_PAGESIZE);
414 if (t->virtual_mode) 414 if (t->virtual_mode)
415 { 415 {
416 /* Packet X/24 */ 416 /* Packet X/24 */
417 if (i2c_senddata(t, 8, 0, 0x20, 0, -1) || 417 if (i2c_senddata(t, 8, 0, 0x20, 0, -1) ||
@@ -459,9 +459,9 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
459 info.notfound = !!(infobits[8] & 0x10); 459 info.notfound = !!(infobits[8] & 0x10);
460 info.pblf = !!(infobits[9] & 0x20); 460 info.pblf = !!(infobits[9] & 0x20);
461 info.hamming = 0; 461 info.hamming = 0;
462 for (a = 0; a <= 7; a++) 462 for (a = 0; a <= 7; a++)
463 { 463 {
464 if (infobits[a] & 0xf0) 464 if (infobits[a] & 0xf0)
465 { 465 {
466 info.hamming = 1; 466 info.hamming = 1;
467 break; 467 break;
@@ -471,14 +471,14 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
471 info.notfound = 1; 471 info.notfound = 1;
472 if(copy_to_user(req->buffer, &info, sizeof(vtx_pageinfo_t))) 472 if(copy_to_user(req->buffer, &info, sizeof(vtx_pageinfo_t)))
473 return -EFAULT; 473 return -EFAULT;
474 if (!info.hamming && !info.notfound) 474 if (!info.hamming && !info.notfound)
475 { 475 {
476 t->is_searching[req->pgbuf] = FALSE; 476 t->is_searching[req->pgbuf] = FALSE;
477 } 477 }
478 return 0; 478 return 0;
479 } 479 }
480 480
481 case VTXIOCGETPAGE: 481 case VTXIOCGETPAGE:
482 { 482 {
483 vtx_pagereq_t *req = arg; 483 vtx_pagereq_t *req = arg;
484 int start, end; 484 int start, end;
@@ -488,15 +488,15 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
488 return -EINVAL; 488 return -EINVAL;
489 if(copy_to_user(req->buffer, &t->vdau[req->pgbuf].pgbuf[req->start], req->end - req->start + 1)) 489 if(copy_to_user(req->buffer, &t->vdau[req->pgbuf].pgbuf[req->start], req->end - req->start + 1))
490 return -EFAULT; 490 return -EFAULT;
491 491
492 /* 492 /*
493 * Always read the time directly from SAA5249 493 * Always read the time directly from SAA5249
494 */ 494 */
495 495
496 if (req->start <= 39 && req->end >= 32) 496 if (req->start <= 39 && req->end >= 32)
497 { 497 {
498 int len; 498 int len;
499 char buf[16]; 499 char buf[16];
500 start = max(req->start, 32); 500 start = max(req->start, 32);
501 end = min(req->end, 39); 501 end = min(req->end, 39);
502 len=end-start+1; 502 len=end-start+1;
@@ -507,7 +507,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
507 return -EFAULT; 507 return -EFAULT;
508 } 508 }
509 /* Insert the current header if DAU is still searching for a page */ 509 /* Insert the current header if DAU is still searching for a page */
510 if (req->start <= 31 && req->end >= 7 && t->is_searching[req->pgbuf]) 510 if (req->start <= 31 && req->end >= 7 && t->is_searching[req->pgbuf])
511 { 511 {
512 char buf[32]; 512 char buf[32];
513 int len; 513 int len;
@@ -523,7 +523,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
523 return 0; 523 return 0;
524 } 524 }
525 525
526 case VTXIOCSTOPDAU: 526 case VTXIOCSTOPDAU:
527 { 527 {
528 vtx_pagereq_t *req = arg; 528 vtx_pagereq_t *req = arg;
529 529
@@ -534,12 +534,12 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
534 return 0; 534 return 0;
535 } 535 }
536 536
537 case VTXIOCPUTPAGE: 537 case VTXIOCPUTPAGE:
538 case VTXIOCSETDISP: 538 case VTXIOCSETDISP:
539 case VTXIOCPUTSTAT: 539 case VTXIOCPUTSTAT:
540 return 0; 540 return 0;
541 541
542 case VTXIOCCLRCACHE: 542 case VTXIOCCLRCACHE:
543 { 543 {
544 if (i2c_senddata(t, 0, NUM_DAUS, 0, 8, -1) || i2c_senddata(t, 11, 544 if (i2c_senddata(t, 0, NUM_DAUS, 0, 8, -1) || i2c_senddata(t, 11,
545 ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', 545 ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
@@ -551,7 +551,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
551 return 0; 551 return 0;
552 } 552 }
553 553
554 case VTXIOCSETVIRT: 554 case VTXIOCSETVIRT:
555 { 555 {
556 /* The SAA5249 has virtual-row reception turned on always */ 556 /* The SAA5249 has virtual-row reception turned on always */
557 t->virtual_mode = (int)(long)arg; 557 t->virtual_mode = (int)(long)arg;
@@ -612,14 +612,14 @@ static inline unsigned int vtx_fix_command(unsigned int cmd)
612/* 612/*
613 * Handle the locking 613 * Handle the locking
614 */ 614 */
615 615
616static int saa5249_ioctl(struct inode *inode, struct file *file, 616static int saa5249_ioctl(struct inode *inode, struct file *file,
617 unsigned int cmd, unsigned long arg) 617 unsigned int cmd, unsigned long arg)
618{ 618{
619 struct video_device *vd = video_devdata(file); 619 struct video_device *vd = video_devdata(file);
620 struct saa5249_device *t=vd->priv; 620 struct saa5249_device *t=vd->priv;
621 int err; 621 int err;
622 622
623 cmd = vtx_fix_command(cmd); 623 cmd = vtx_fix_command(cmd);
624 mutex_lock(&t->lock); 624 mutex_lock(&t->lock);
625 err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl); 625 err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl);
@@ -627,7 +627,7 @@ static int saa5249_ioctl(struct inode *inode, struct file *file,
627 return err; 627 return err;
628} 628}
629 629
630static int saa5249_open(struct inode *inode, struct file *file) 630static int saa5249_open(struct inode *inode, struct file *file)
631{ 631{
632 struct video_device *vd = video_devdata(file); 632 struct video_device *vd = video_devdata(file);
633 struct saa5249_device *t=vd->priv; 633 struct saa5249_device *t=vd->priv;
@@ -636,7 +636,7 @@ static int saa5249_open(struct inode *inode, struct file *file)
636 err = video_exclusive_open(inode,file); 636 err = video_exclusive_open(inode,file);
637 if (err < 0) 637 if (err < 0)
638 return err; 638 return err;
639 639
640 if (t->client==NULL) { 640 if (t->client==NULL) {
641 err = -ENODEV; 641 err = -ENODEV;
642 goto fail; 642 goto fail;
@@ -647,13 +647,13 @@ static int saa5249_open(struct inode *inode, struct file *file)
647 i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) || 647 i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) ||
648 /* Display TV-picture, no virtual rows */ 648 /* Display TV-picture, no virtual rows */
649 i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1)) /* Set display to page 4 */ 649 i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1)) /* Set display to page 4 */
650 650
651 { 651 {
652 err = -EIO; 652 err = -EIO;
653 goto fail; 653 goto fail;
654 } 654 }
655 655
656 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) 656 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
657 { 657 {
658 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); 658 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
659 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs)); 659 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs));
@@ -673,7 +673,7 @@ static int saa5249_open(struct inode *inode, struct file *file)
673 673
674 674
675 675
676static int saa5249_release(struct inode *inode, struct file *file) 676static int saa5249_release(struct inode *inode, struct file *file)
677{ 677{
678 struct video_device *vd = video_devdata(file); 678 struct video_device *vd = video_devdata(file);
679 struct saa5249_device *t=vd->priv; 679 struct saa5249_device *t=vd->priv;
@@ -690,7 +690,7 @@ static int __init init_saa_5249 (void)
690 return i2c_add_driver(&i2c_driver_videotext); 690 return i2c_add_driver(&i2c_driver_videotext);
691} 691}
692 692
693static void __exit cleanup_saa_5249 (void) 693static void __exit cleanup_saa_5249 (void)
694{ 694{
695 i2c_del_driver(&i2c_driver_videotext); 695 i2c_del_driver(&i2c_driver_videotext);
696} 696}
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index e18ea268384b..41d951db6ec0 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -139,7 +139,7 @@ saa7110_read (struct i2c_client *client)
139 139
140static int 140static int
141saa7110_selmux (struct i2c_client *client, 141saa7110_selmux (struct i2c_client *client,
142 int chan) 142 int chan)
143{ 143{
144 static const unsigned char modes[9][8] = { 144 static const unsigned char modes[9][8] = {
145 /* mode 0 */ 145 /* mode 0 */
@@ -457,7 +457,7 @@ static unsigned short normal_i2c[] = {
457}; 457};
458 458
459static unsigned short ignore = I2C_CLIENT_END; 459static unsigned short ignore = I2C_CLIENT_END;
460 460
461static struct i2c_client_address_data addr_data = { 461static struct i2c_client_address_data addr_data = {
462 .normal_i2c = normal_i2c, 462 .normal_i2c = normal_i2c,
463 .probe = &ignore, 463 .probe = &ignore,
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index f9ba0c943adf..686fd4746205 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * saa7111 - Philips SAA7111A video decoder driver version 0.0.3 2 * saa7111 - Philips SAA7111A video decoder driver version 0.0.3
3 * 3 *
4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -482,7 +482,7 @@ saa7111_command (struct i2c_client *client,
482static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; 482static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END };
483 483
484static unsigned short ignore = I2C_CLIENT_END; 484static unsigned short ignore = I2C_CLIENT_END;
485 485
486static struct i2c_client_address_data addr_data = { 486static struct i2c_client_address_data addr_data = {
487 .normal_i2c = normal_i2c, 487 .normal_i2c = normal_i2c,
488 .probe = &ignore, 488 .probe = &ignore,
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index 4a1f841d0c77..90398ab8252e 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * saa7114 - Philips SAA7114H video decoder driver version 0.0.1 2 * saa7114 - Philips SAA7114H video decoder driver version 0.0.1
3 * 3 *
4 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com> 4 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
@@ -300,7 +300,7 @@ static const unsigned char init[] = {
300 0x55, 0xff, 300 0x55, 0xff,
301 0x56, 0xff, 301 0x56, 0xff,
302 0x57, 0xff, 302 0x57, 0xff,
303 0x58, 0x40, // framing code 303 0x58, 0x40, // framing code
304 0x59, 0x47, // horizontal offset 304 0x59, 0x47, // horizontal offset
305 0x5a, 0x06, // vertical offset 305 0x5a, 0x06, // vertical offset
306 0x5b, 0x83, // field offset 306 0x5b, 0x83, // field offset
@@ -345,7 +345,7 @@ static const unsigned char init[] = {
345 0x82, 0x00, 345 0x82, 0x00,
346 0x83, 0x00, 346 0x83, 0x00,
347 0x84, 0xc5, 347 0x84, 0xc5,
348 0x85, 0x0d, // hsync and vsync ? 348 0x85, 0x0d, // hsync and vsync ?
349 0x86, 0x40, 349 0x86, 0x40,
350 0x87, 0x01, 350 0x87, 0x01,
351 0x88, 0x00, 351 0x88, 0x00,
@@ -434,7 +434,7 @@ static const unsigned char init[] = {
434 0xd9, 0x04, 434 0xd9, 0x04,
435 0xda, 0x00, // horizontal luminance phase offset 435 0xda, 0x00, // horizontal luminance phase offset
436 0xdb, 0x00, 436 0xdb, 0x00,
437 0xdc, 0x00, // horizontal chrominance scaling increment 437 0xdc, 0x00, // horizontal chrominance scaling increment
438 0xdd, 0x02, 438 0xdd, 0x02,
439 0xde, 0x00, // horizontal chrominance phase offset 439 0xde, 0x00, // horizontal chrominance phase offset
440 0xdf, 0x00, 440 0xdf, 0x00,
@@ -754,7 +754,7 @@ saa7114_command (struct i2c_client *client,
754 saa7114_write(client, 0x87, 754 saa7114_write(client, 0x87,
755 decoder->reg[REG_ADDR(0x87)]); 755 decoder->reg[REG_ADDR(0x87)]);
756 saa7114_write(client, 0x88, 0xd8); // sw reset scaler 756 saa7114_write(client, 0x88, 0xd8); // sw reset scaler
757 saa7114_write(client, 0x88, 0xf8); // sw reset scaler release 757 saa7114_write(client, 0x88, 0xf8); // sw reset scaler release
758 saa7114_write(client, 0x80, 0x36); 758 saa7114_write(client, 0x80, 0x36);
759 759
760 } 760 }
@@ -813,7 +813,7 @@ static unsigned short normal_i2c[] =
813 { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; 813 { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END };
814 814
815static unsigned short ignore = I2C_CLIENT_END; 815static unsigned short ignore = I2C_CLIENT_END;
816 816
817static struct i2c_client_address_data addr_data = { 817static struct i2c_client_address_data addr_data = {
818 .normal_i2c = normal_i2c, 818 .normal_i2c = normal_i2c,
819 .probe = &ignore, 819 .probe = &ignore,
diff --git a/drivers/media/video/saa7121.h b/drivers/media/video/saa7121.h
index 74e37d405208..66967ae37494 100644
--- a/drivers/media/video/saa7121.h
+++ b/drivers/media/video/saa7121.h
@@ -64,7 +64,7 @@
64#define PAL_MSB_VERTICAL 0x40 /* 7c */ 64#define PAL_MSB_VERTICAL 0x40 /* 7c */
65 65
66/* Initialization Sequence */ 66/* Initialization Sequence */
67 67
68static __u8 init7121ntsc[] = { 68static __u8 init7121ntsc[] = {
69 0x26, 0x0, 0x27, 0x0, 69 0x26, 0x0, 0x27, 0x0,
70 0x28, NTSC_BURST_START, 0x29, NTSC_BURST_END, 70 0x28, NTSC_BURST_START, 0x29, NTSC_BURST_END,
@@ -95,7 +95,7 @@ static __u8 init7121ntsc[] = {
95 0x78, 0x0, 0x79, 0x0, 0x7a, NTSC_FIRST_ACTIVE, 95 0x78, 0x0, 0x79, 0x0, 0x7a, NTSC_FIRST_ACTIVE,
96 0x7b, NTSC_LAST_ACTIVE, 0x7c, NTSC_MSB_VERTICAL, 96 0x7b, NTSC_LAST_ACTIVE, 0x7c, NTSC_MSB_VERTICAL,
97 0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0 97 0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0
98}; 98};
99#define INIT7121LEN (sizeof(init7121ntsc)/2) 99#define INIT7121LEN (sizeof(init7121ntsc)/2)
100 100
101static __u8 init7121pal[] = { 101static __u8 init7121pal[] = {
@@ -128,5 +128,5 @@ static __u8 init7121pal[] = {
128 0x78, 0x0, 0x79, 0x0, 0x7a, PAL_FIRST_ACTIVE, 128 0x78, 0x0, 0x79, 0x0, 0x7a, PAL_FIRST_ACTIVE,
129 0x7b, PAL_LAST_ACTIVE, 0x7c, PAL_MSB_VERTICAL, 129 0x7b, PAL_LAST_ACTIVE, 0x7c, PAL_MSB_VERTICAL,
130 0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0 130 0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0
131}; 131};
132#endif 132#endif
diff --git a/drivers/media/video/saa7146.h b/drivers/media/video/saa7146.h
index 756963f01bbd..2830b5e33aec 100644
--- a/drivers/media/video/saa7146.h
+++ b/drivers/media/video/saa7146.h
@@ -1,7 +1,7 @@
1/* 1/*
2 saa7146.h - definitions philips saa7146 based cards 2 saa7146.h - definitions philips saa7146 based cards
3 Copyright (C) 1999 Nathan Laredo (laredo@gnu.org) 3 Copyright (C) 1999 Nathan Laredo (laredo@gnu.org)
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
@@ -27,7 +27,7 @@
27 27
28#include <linux/videodev.h> 28#include <linux/videodev.h>
29 29
30#ifndef O_NONCAP 30#ifndef O_NONCAP
31#define O_NONCAP O_TRUNC 31#define O_NONCAP O_TRUNC
32#endif 32#endif
33 33
@@ -36,7 +36,7 @@
36 36
37#ifdef __KERNEL__ 37#ifdef __KERNEL__
38 38
39struct saa7146_window 39struct saa7146_window
40{ 40{
41 int x, y; 41 int x, y;
42 ushort width, height; 42 ushort width, height;
@@ -70,7 +70,7 @@ struct saa7146
70 int irqstate; /* irq routine is state driven */ 70 int irqstate; /* irq routine is state driven */
71 int writemode; 71 int writemode;
72 int playmode; 72 int playmode;
73 unsigned int nr; 73 unsigned int nr;
74 unsigned long irq; /* IRQ used by SAA7146 card */ 74 unsigned long irq; /* IRQ used by SAA7146 card */
75 unsigned short id; 75 unsigned short id;
76 unsigned char revision; 76 unsigned char revision;
diff --git a/drivers/media/video/saa7146reg.h b/drivers/media/video/saa7146reg.h
index 6cc910f50a4b..80ec2c146b4c 100644
--- a/drivers/media/video/saa7146reg.h
+++ b/drivers/media/video/saa7146reg.h
@@ -1,7 +1,7 @@
1/* 1/*
2 saa7146.h - definitions philips saa7146 based cards 2 saa7146.h - definitions philips saa7146 based cards
3 Copyright (C) 1999 Nathan Laredo (laredo@gnu.org) 3 Copyright (C) 1999 Nathan Laredo (laredo@gnu.org)
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 9f99ee1303e0..9c308410856d 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * saa7185 - Philips SAA7185B video encoder driver version 0.0.3 2 * saa7185 - Philips SAA7185B video encoder driver version 0.0.3
3 * 3 *
4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -377,7 +377,7 @@ saa7185_command (struct i2c_client *client,
377static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; 377static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END };
378 378
379static unsigned short ignore = I2C_CLIENT_END; 379static unsigned short ignore = I2C_CLIENT_END;
380 380
381static struct i2c_client_address_data addr_data = { 381static struct i2c_client_address_data addr_data = {
382 .normal_i2c = normal_i2c, 382 .normal_i2c = normal_i2c,
383 .probe = &ignore, 383 .probe = &ignore,
diff --git a/drivers/media/video/saa7196.h b/drivers/media/video/saa7196.h
index f92f21cfbcac..cd4b6354a7b3 100644
--- a/drivers/media/video/saa7196.h
+++ b/drivers/media/video/saa7196.h
@@ -2,14 +2,14 @@
2 Definitions for the Philips SAA7196 digital video decoder, 2 Definitions for the Philips SAA7196 digital video decoder,
3 scaler, and clock generator circuit (DESCpro), as used in 3 scaler, and clock generator circuit (DESCpro), as used in
4 the PlanB video input of the Powermac 7x00/8x00 series. 4 the PlanB video input of the Powermac 7x00/8x00 series.
5 5
6 Copyright (C) 1998 Michel Lanners (mlan@cpu.lu) 6 Copyright (C) 1998 Michel Lanners (mlan@cpu.lu)
7 7
8 The register defines are shamelessly copied from the meteor 8 The register defines are shamelessly copied from the meteor
9 driver out of NetBSD (with permission), 9 driver out of NetBSD (with permission),
10 and are copyrighted (c) 1995 Mark Tinguely and Jim Lowe 10 and are copyrighted (c) 1995 Mark Tinguely and Jim Lowe
11 (Thanks !) 11 (Thanks !)
12 12
13 Additional debugging and coding by Takashi Oe (toe@unlinfo.unl.edu) 13 Additional debugging and coding by Takashi Oe (toe@unlinfo.unl.edu)
14 14
15 The default values used for PlanB are my mistakes. 15 The default values used for PlanB are my mistakes.
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c
index f03ea7f89596..a846ebc78cd7 100644
--- a/drivers/media/video/se401.c
+++ b/drivers/media/video/se401.c
@@ -4,7 +4,7 @@
4 * Copyright (c) 2000 Jeroen B. Vreeken (pe1rxq@amsat.org) 4 * Copyright (c) 2000 Jeroen B. Vreeken (pe1rxq@amsat.org)
5 * 5 *
6 * Still somewhat based on the Linux ov511 driver. 6 * Still somewhat based on the Linux ov511 driver.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the 9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your 10 * Free Software Foundation; either version 2 of the License, or (at your
@@ -114,16 +114,16 @@ static int se401_sndctrl(int set, struct usb_se401 *se401, unsigned short req,
114 unsigned short value, unsigned char *cp, int size) 114 unsigned short value, unsigned char *cp, int size)
115{ 115{
116 return usb_control_msg ( 116 return usb_control_msg (
117 se401->dev, 117 se401->dev,
118 set ? usb_sndctrlpipe(se401->dev, 0) : usb_rcvctrlpipe(se401->dev, 0), 118 set ? usb_sndctrlpipe(se401->dev, 0) : usb_rcvctrlpipe(se401->dev, 0),
119 req, 119 req,
120 (set ? USB_DIR_OUT : USB_DIR_IN) | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 120 (set ? USB_DIR_OUT : USB_DIR_IN) | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
121 value, 121 value,
122 0, 122 0,
123 cp, 123 cp,
124 size, 124 size,
125 1000 125 1000
126 ); 126 );
127} 127}
128 128
129static int se401_set_feature(struct usb_se401 *se401, unsigned short selector, 129static int se401_set_feature(struct usb_se401 *se401, unsigned short selector,
@@ -140,30 +140,30 @@ static int se401_set_feature(struct usb_se401 *se401, unsigned short selector,
140 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 140 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
141 param, 141 param,
142 selector, 142 selector,
143 NULL, 143 NULL,
144 0, 144 0,
145 1000 145 1000
146 ); 146 );
147} 147}
148 148
149static unsigned short se401_get_feature(struct usb_se401 *se401, 149static unsigned short se401_get_feature(struct usb_se401 *se401,
150 unsigned short selector) 150 unsigned short selector)
151{ 151{
152 /* For 'set' the selecetor should be in index, not sure if the spec is 152 /* For 'set' the selecetor should be in index, not sure if the spec is
153 wrong here to.... 153 wrong here to....
154 */ 154 */
155 unsigned char cp[2]; 155 unsigned char cp[2];
156 usb_control_msg ( 156 usb_control_msg (
157 se401->dev, 157 se401->dev,
158 usb_rcvctrlpipe(se401->dev, 0), 158 usb_rcvctrlpipe(se401->dev, 0),
159 SE401_REQ_GET_EXT_FEATURE, 159 SE401_REQ_GET_EXT_FEATURE,
160 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 160 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
161 0, 161 0,
162 selector, 162 selector,
163 cp, 163 cp,
164 2, 164 2,
165 1000 165 1000
166 ); 166 );
167 return cp[0]+cp[1]*256; 167 return cp[0]+cp[1]*256;
168} 168}
169 169
@@ -183,14 +183,14 @@ static int se401_send_pict(struct usb_se401 *se401)
183 se401_set_feature(se401, HV7131_REG_ARCG, se401->rgain);/* red color gain */ 183 se401_set_feature(se401, HV7131_REG_ARCG, se401->rgain);/* red color gain */
184 se401_set_feature(se401, HV7131_REG_AGCG, se401->ggain);/* green color gain */ 184 se401_set_feature(se401, HV7131_REG_AGCG, se401->ggain);/* green color gain */
185 se401_set_feature(se401, HV7131_REG_ABCG, se401->bgain);/* blue color gain */ 185 se401_set_feature(se401, HV7131_REG_ABCG, se401->bgain);/* blue color gain */
186 186
187 return 0; 187 return 0;
188} 188}
189 189
190static void se401_set_exposure(struct usb_se401 *se401, int brightness) 190static void se401_set_exposure(struct usb_se401 *se401, int brightness)
191{ 191{
192 int integration=brightness<<5; 192 int integration=brightness<<5;
193 193
194 if (flickerless==50) { 194 if (flickerless==50) {
195 integration=integration-integration%106667; 195 integration=integration-integration%106667;
196 } 196 }
@@ -255,11 +255,11 @@ static void se401_auto_resetlevel(struct usb_se401 *se401)
255 /* For some reason this normally read-only register doesn't get reset 255 /* For some reason this normally read-only register doesn't get reset
256 to zero after reading them just once... 256 to zero after reading them just once...
257 */ 257 */
258 se401_get_feature(se401, HV7131_REG_HIREFNOH); 258 se401_get_feature(se401, HV7131_REG_HIREFNOH);
259 se401_get_feature(se401, HV7131_REG_HIREFNOL); 259 se401_get_feature(se401, HV7131_REG_HIREFNOL);
260 se401_get_feature(se401, HV7131_REG_LOREFNOH); 260 se401_get_feature(se401, HV7131_REG_LOREFNOH);
261 se401_get_feature(se401, HV7131_REG_LOREFNOL); 261 se401_get_feature(se401, HV7131_REG_LOREFNOL);
262 ahrc=256*se401_get_feature(se401, HV7131_REG_HIREFNOH) + 262 ahrc=256*se401_get_feature(se401, HV7131_REG_HIREFNOH) +
263 se401_get_feature(se401, HV7131_REG_HIREFNOL); 263 se401_get_feature(se401, HV7131_REG_HIREFNOL);
264 alrc=256*se401_get_feature(se401, HV7131_REG_LOREFNOH) + 264 alrc=256*se401_get_feature(se401, HV7131_REG_LOREFNOH) +
265 se401_get_feature(se401, HV7131_REG_LOREFNOL); 265 se401_get_feature(se401, HV7131_REG_LOREFNOL);
@@ -287,12 +287,12 @@ static void se401_button_irq(struct urb *urb, struct pt_regs *regs)
287{ 287{
288 struct usb_se401 *se401 = urb->context; 288 struct usb_se401 *se401 = urb->context;
289 int status; 289 int status;
290 290
291 if (!se401->dev) { 291 if (!se401->dev) {
292 info("ohoh: device vapourished"); 292 info("ohoh: device vapourished");
293 return; 293 return;
294 } 294 }
295 295
296 switch (urb->status) { 296 switch (urb->status) {
297 case 0: 297 case 0:
298 /* success */ 298 /* success */
@@ -368,7 +368,7 @@ static void se401_video_irq(struct urb *urb, struct pt_regs *regs)
368 if (se401->nullpackets > SE401_MAX_NULLPACKETS) { 368 if (se401->nullpackets > SE401_MAX_NULLPACKETS) {
369 if (waitqueue_active(&se401->wq)) { 369 if (waitqueue_active(&se401->wq)) {
370 wake_up_interruptible(&se401->wq); 370 wake_up_interruptible(&se401->wq);
371 } 371 }
372 } 372 }
373 } 373 }
374 374
@@ -433,8 +433,8 @@ static int se401_start_stream(struct usb_se401 *se401)
433 int err=0, i; 433 int err=0, i;
434 se401->streaming=1; 434 se401->streaming=1;
435 435
436 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0); 436 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0);
437 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0); 437 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
438 438
439 /* Set picture settings */ 439 /* Set picture settings */
440 se401_set_feature(se401, HV7131_REG_MODE_B, 0x05);/*windowed + pix intg */ 440 se401_set_feature(se401, HV7131_REG_MODE_B, 0x05);/*windowed + pix intg */
@@ -571,7 +571,7 @@ static inline void decode_JangGu_integrate(struct usb_se401 *se401, int data)
571 } 571 }
572 572
573 /* First three are absolute, all others relative. 573 /* First three are absolute, all others relative.
574 * Format is rgb from right to left (mirrorred image), 574 * Format is rgb from right to left (mirrorred image),
575 * we flip it to get bgr from left to right. */ 575 * we flip it to get bgr from left to right. */
576 if (frame->curlinepix < 3) { 576 if (frame->curlinepix < 3) {
577 *(frame->curline-frame->curlinepix)=1+data*4; 577 *(frame->curline-frame->curlinepix)=1+data*4;
@@ -703,7 +703,7 @@ static inline void decode_bayer (struct usb_se401 *se401, struct se401_scratch *
703 int width=se401->cwidth; 703 int width=se401->cwidth;
704 int blineoffset=0, bline; 704 int blineoffset=0, bline;
705 int linelength=width*3, i; 705 int linelength=width*3, i;
706 706
707 707
708 if (frame->curpix==0) { 708 if (frame->curpix==0) {
709 if (frame->grabstate==FRAME_READY) { 709 if (frame->grabstate==FRAME_READY) {
@@ -831,7 +831,7 @@ static int se401_newframe(struct usb_se401 *se401, int framenr)
831 se401->nullpackets=0; 831 se401->nullpackets=0;
832 info("to many null length packets, restarting capture"); 832 info("to many null length packets, restarting capture");
833 se401_stop_stream(se401); 833 se401_stop_stream(se401);
834 se401_start_stream(se401); 834 se401_start_stream(se401);
835 } else { 835 } else {
836 if (se401->scratch[se401->scratch_use].state!=BUFFER_READY) { 836 if (se401->scratch[se401->scratch_use].state!=BUFFER_READY) {
837 se401->frame[framenr].grabstate=FRAME_ERROR; 837 se401->frame[framenr].grabstate=FRAME_ERROR;
@@ -866,7 +866,7 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401)
866{ 866{
867 int i; 867 int i;
868 868
869 se401->dev = NULL; 869 se401->dev = NULL;
870 870
871 for (i=0; i<SE401_NUMSBUF; i++) 871 for (i=0; i<SE401_NUMSBUF; i++)
872 if (se401->urb[i]) { 872 if (se401->urb[i]) {
@@ -882,9 +882,9 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401)
882 usb_kill_urb(se401->inturb); 882 usb_kill_urb(se401->inturb);
883 usb_free_urb(se401->inturb); 883 usb_free_urb(se401->inturb);
884 } 884 }
885 info("%s disconnected", se401->camera_name); 885 info("%s disconnected", se401->camera_name);
886 886
887 /* Free the memory */ 887 /* Free the memory */
888 kfree(se401->width); 888 kfree(se401->width);
889 kfree(se401->height); 889 kfree(se401->height);
890 kfree(se401); 890 kfree(se401);
@@ -910,7 +910,7 @@ static int se401_open(struct inode *inode, struct file *file)
910 se401->fbuf = rvmalloc(se401->maxframesize * SE401_NUMFRAMES); 910 se401->fbuf = rvmalloc(se401->maxframesize * SE401_NUMFRAMES);
911 if (se401->fbuf) 911 if (se401->fbuf)
912 file->private_data = dev; 912 file->private_data = dev;
913 else 913 else
914 err = -ENOMEM; 914 err = -ENOMEM;
915 se401->user = !err; 915 se401->user = !err;
916 916
@@ -920,11 +920,11 @@ static int se401_open(struct inode *inode, struct file *file)
920static int se401_close(struct inode *inode, struct file *file) 920static int se401_close(struct inode *inode, struct file *file)
921{ 921{
922 struct video_device *dev = file->private_data; 922 struct video_device *dev = file->private_data;
923 struct usb_se401 *se401 = (struct usb_se401 *)dev; 923 struct usb_se401 *se401 = (struct usb_se401 *)dev;
924 int i; 924 int i;
925 925
926 rvfree(se401->fbuf, se401->maxframesize * SE401_NUMFRAMES); 926 rvfree(se401->fbuf, se401->maxframesize * SE401_NUMFRAMES);
927 if (se401->removed) { 927 if (se401->removed) {
928 usb_se401_remove_disconnected(se401); 928 usb_se401_remove_disconnected(se401);
929 info("device unregistered"); 929 info("device unregistered");
930 } else { 930 } else {
@@ -942,12 +942,12 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
942 unsigned int cmd, void *arg) 942 unsigned int cmd, void *arg)
943{ 943{
944 struct video_device *vdev = file->private_data; 944 struct video_device *vdev = file->private_data;
945 struct usb_se401 *se401 = (struct usb_se401 *)vdev; 945 struct usb_se401 *se401 = (struct usb_se401 *)vdev;
946 946
947 if (!se401->dev) 947 if (!se401->dev)
948 return -EIO; 948 return -EIO;
949 949
950 switch (cmd) { 950 switch (cmd) {
951 case VIDIOCGCAP: 951 case VIDIOCGCAP:
952 { 952 {
953 struct video_capability *b = arg; 953 struct video_capability *b = arg;
@@ -981,8 +981,8 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
981 return -EINVAL; 981 return -EINVAL;
982 return 0; 982 return 0;
983 } 983 }
984 case VIDIOCGPICT: 984 case VIDIOCGPICT:
985 { 985 {
986 struct video_picture *p = arg; 986 struct video_picture *p = arg;
987 987
988 se401_get_pict(se401, p); 988 se401_get_pict(se401, p);
@@ -1007,7 +1007,7 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
1007 if (se401_set_size(se401, vw->width, vw->height)) 1007 if (se401_set_size(se401, vw->width, vw->height))
1008 return -EINVAL; 1008 return -EINVAL;
1009 return 0; 1009 return 0;
1010 } 1010 }
1011 case VIDIOCGWIN: 1011 case VIDIOCGWIN:
1012 { 1012 {
1013 struct video_window *vw = arg; 1013 struct video_window *vw = arg;
@@ -1095,11 +1095,11 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
1095 case VIDIOCGAUDIO: 1095 case VIDIOCGAUDIO:
1096 case VIDIOCSAUDIO: 1096 case VIDIOCSAUDIO:
1097 return -EINVAL; 1097 return -EINVAL;
1098 default: 1098 default:
1099 return -ENOIOCTLCMD; 1099 return -ENOIOCTLCMD;
1100 } /* end switch */ 1100 } /* end switch */
1101 1101
1102 return 0; 1102 return 0;
1103} 1103}
1104 1104
1105static int se401_ioctl(struct inode *inode, struct file *file, 1105static int se401_ioctl(struct inode *inode, struct file *file,
@@ -1142,7 +1142,7 @@ static ssize_t se401_read(struct file *file, char __user *buf,
1142 1142
1143 se401->frame[0].grabstate=FRAME_UNUSED; 1143 se401->frame[0].grabstate=FRAME_UNUSED;
1144 if (ret) 1144 if (ret)
1145 return ret; 1145 return ret;
1146 if (copy_to_user(buf, se401->frame[0].data, realcount)) 1146 if (copy_to_user(buf, se401->frame[0].data, realcount))
1147 return -EFAULT; 1147 return -EFAULT;
1148 1148
@@ -1183,24 +1183,24 @@ static int se401_mmap(struct file *file, struct vm_area_struct *vma)
1183 } 1183 }
1184 mutex_unlock(&se401->lock); 1184 mutex_unlock(&se401->lock);
1185 1185
1186 return 0; 1186 return 0;
1187} 1187}
1188 1188
1189static struct file_operations se401_fops = { 1189static struct file_operations se401_fops = {
1190 .owner = THIS_MODULE, 1190 .owner = THIS_MODULE,
1191 .open = se401_open, 1191 .open = se401_open,
1192 .release = se401_close, 1192 .release = se401_close,
1193 .read = se401_read, 1193 .read = se401_read,
1194 .mmap = se401_mmap, 1194 .mmap = se401_mmap,
1195 .ioctl = se401_ioctl, 1195 .ioctl = se401_ioctl,
1196 .compat_ioctl = v4l_compat_ioctl32, 1196 .compat_ioctl = v4l_compat_ioctl32,
1197 .llseek = no_llseek, 1197 .llseek = no_llseek,
1198}; 1198};
1199static struct video_device se401_template = { 1199static struct video_device se401_template = {
1200 .owner = THIS_MODULE, 1200 .owner = THIS_MODULE,
1201 .name = "se401 USB camera", 1201 .name = "se401 USB camera",
1202 .type = VID_TYPE_CAPTURE, 1202 .type = VID_TYPE_CAPTURE,
1203 .hardware = VID_HARDWARE_SE401, 1203 .hardware = VID_HARDWARE_SE401,
1204 .fops = &se401_fops, 1204 .fops = &se401_fops,
1205}; 1205};
1206 1206
@@ -1209,12 +1209,12 @@ static struct video_device se401_template = {
1209/***************************/ 1209/***************************/
1210static int se401_init(struct usb_se401 *se401, int button) 1210static int se401_init(struct usb_se401 *se401, int button)
1211{ 1211{
1212 int i=0, rc; 1212 int i=0, rc;
1213 unsigned char cp[0x40]; 1213 unsigned char cp[0x40];
1214 char temp[200]; 1214 char temp[200];
1215 1215
1216 /* led on */ 1216 /* led on */
1217 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0); 1217 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
1218 1218
1219 /* get camera descriptor */ 1219 /* get camera descriptor */
1220 rc=se401_sndctrl(0, se401, SE401_REQ_GET_CAMERA_DESCRIPTOR, 0, cp, sizeof(cp)); 1220 rc=se401_sndctrl(0, se401, SE401_REQ_GET_CAMERA_DESCRIPTOR, 0, cp, sizeof(cp));
@@ -1254,7 +1254,7 @@ static int se401_init(struct usb_se401 *se401, int button)
1254 return 1; 1254 return 1;
1255 } 1255 }
1256 /* set output mode (BAYER) */ 1256 /* set output mode (BAYER) */
1257 se401_sndctrl(1, se401, SE401_REQ_SET_OUTPUT_MODE, SE401_FORMAT_BAYER, NULL, 0); 1257 se401_sndctrl(1, se401, SE401_REQ_SET_OUTPUT_MODE, SE401_FORMAT_BAYER, NULL, 0);
1258 1258
1259 rc=se401_sndctrl(0, se401, SE401_REQ_GET_BRT, 0, cp, sizeof(cp)); 1259 rc=se401_sndctrl(0, se401, SE401_REQ_GET_BRT, 0, cp, sizeof(cp));
1260 se401->brightness=cp[0]+cp[1]*256; 1260 se401->brightness=cp[0]+cp[1]*256;
@@ -1292,71 +1292,71 @@ static int se401_init(struct usb_se401 *se401, int button)
1292 } else 1292 } else
1293 se401->inturb=NULL; 1293 se401->inturb=NULL;
1294 1294
1295 /* Flash the led */ 1295 /* Flash the led */
1296 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0); 1296 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0);
1297 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0); 1297 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
1298 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 0, NULL, 0); 1298 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 0, NULL, 0);
1299 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 0, NULL, 0); 1299 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 0, NULL, 0);
1300 1300
1301 return 0; 1301 return 0;
1302} 1302}
1303 1303
1304static int se401_probe(struct usb_interface *intf, 1304static int se401_probe(struct usb_interface *intf,
1305 const struct usb_device_id *id) 1305 const struct usb_device_id *id)
1306{ 1306{
1307 struct usb_device *dev = interface_to_usbdev(intf); 1307 struct usb_device *dev = interface_to_usbdev(intf);
1308 struct usb_interface_descriptor *interface; 1308 struct usb_interface_descriptor *interface;
1309 struct usb_se401 *se401; 1309 struct usb_se401 *se401;
1310 char *camera_name=NULL; 1310 char *camera_name=NULL;
1311 int button=1; 1311 int button=1;
1312 1312
1313 /* We don't handle multi-config cameras */ 1313 /* We don't handle multi-config cameras */
1314 if (dev->descriptor.bNumConfigurations != 1) 1314 if (dev->descriptor.bNumConfigurations != 1)
1315 return -ENODEV; 1315 return -ENODEV;
1316 1316
1317 interface = &intf->cur_altsetting->desc; 1317 interface = &intf->cur_altsetting->desc;
1318 1318
1319 /* Is it an se401? */ 1319 /* Is it an se401? */
1320 if (le16_to_cpu(dev->descriptor.idVendor) == 0x03e8 && 1320 if (le16_to_cpu(dev->descriptor.idVendor) == 0x03e8 &&
1321 le16_to_cpu(dev->descriptor.idProduct) == 0x0004) { 1321 le16_to_cpu(dev->descriptor.idProduct) == 0x0004) {
1322 camera_name="Endpoints/Aox SE401"; 1322 camera_name="Endpoints/Aox SE401";
1323 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x0471 && 1323 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x0471 &&
1324 le16_to_cpu(dev->descriptor.idProduct) == 0x030b) { 1324 le16_to_cpu(dev->descriptor.idProduct) == 0x030b) {
1325 camera_name="Philips PCVC665K"; 1325 camera_name="Philips PCVC665K";
1326 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d && 1326 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
1327 le16_to_cpu(dev->descriptor.idProduct) == 0x5001) { 1327 le16_to_cpu(dev->descriptor.idProduct) == 0x5001) {
1328 camera_name="Kensington VideoCAM 67014"; 1328 camera_name="Kensington VideoCAM 67014";
1329 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d && 1329 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
1330 le16_to_cpu(dev->descriptor.idProduct) == 0x5002) { 1330 le16_to_cpu(dev->descriptor.idProduct) == 0x5002) {
1331 camera_name="Kensington VideoCAM 6701(5/7)"; 1331 camera_name="Kensington VideoCAM 6701(5/7)";
1332 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d && 1332 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
1333 le16_to_cpu(dev->descriptor.idProduct) == 0x5003) { 1333 le16_to_cpu(dev->descriptor.idProduct) == 0x5003) {
1334 camera_name="Kensington VideoCAM 67016"; 1334 camera_name="Kensington VideoCAM 67016";
1335 button=0; 1335 button=0;
1336 } else 1336 } else
1337 return -ENODEV; 1337 return -ENODEV;
1338 1338
1339 /* Checking vendor/product should be enough, but what the hell */ 1339 /* Checking vendor/product should be enough, but what the hell */
1340 if (interface->bInterfaceClass != 0x00) 1340 if (interface->bInterfaceClass != 0x00)
1341 return -ENODEV; 1341 return -ENODEV;
1342 if (interface->bInterfaceSubClass != 0x00) 1342 if (interface->bInterfaceSubClass != 0x00)
1343 return -ENODEV; 1343 return -ENODEV;
1344 1344
1345 /* We found one */ 1345 /* We found one */
1346 info("SE401 camera found: %s", camera_name); 1346 info("SE401 camera found: %s", camera_name);
1347 1347
1348 if ((se401 = kzalloc(sizeof(*se401), GFP_KERNEL)) == NULL) { 1348 if ((se401 = kzalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
1349 err("couldn't kmalloc se401 struct"); 1349 err("couldn't kmalloc se401 struct");
1350 return -ENOMEM; 1350 return -ENOMEM;
1351 } 1351 }
1352 1352
1353 se401->dev = dev; 1353 se401->dev = dev;
1354 se401->iface = interface->bInterfaceNumber; 1354 se401->iface = interface->bInterfaceNumber;
1355 se401->camera_name = camera_name; 1355 se401->camera_name = camera_name;
1356 1356
1357 info("firmware version: %02x", le16_to_cpu(dev->descriptor.bcdDevice) & 255); 1357 info("firmware version: %02x", le16_to_cpu(dev->descriptor.bcdDevice) & 255);
1358 1358
1359 if (se401_init(se401, button)) { 1359 if (se401_init(se401, button)) {
1360 kfree(se401); 1360 kfree(se401);
1361 return -EIO; 1361 return -EIO;
1362 } 1362 }
@@ -1375,7 +1375,7 @@ static int se401_probe(struct usb_interface *intf,
1375 info("registered new video device: video%d", se401->vdev.minor); 1375 info("registered new video device: video%d", se401->vdev.minor);
1376 1376
1377 usb_set_intfdata (intf, se401); 1377 usb_set_intfdata (intf, se401);
1378 return 0; 1378 return 0;
1379} 1379}
1380 1380
1381static void se401_disconnect(struct usb_interface *intf) 1381static void se401_disconnect(struct usb_interface *intf)
@@ -1400,10 +1400,10 @@ static void se401_disconnect(struct usb_interface *intf)
1400} 1400}
1401 1401
1402static struct usb_driver se401_driver = { 1402static struct usb_driver se401_driver = {
1403 .name = "se401", 1403 .name = "se401",
1404 .id_table = device_table, 1404 .id_table = device_table,
1405 .probe = se401_probe, 1405 .probe = se401_probe,
1406 .disconnect = se401_disconnect, 1406 .disconnect = se401_disconnect,
1407}; 1407};
1408 1408
1409 1409
diff --git a/drivers/media/video/se401.h b/drivers/media/video/se401.h
index e88a40d4c86a..a7a216bd4413 100644
--- a/drivers/media/video/se401.h
+++ b/drivers/media/video/se401.h
@@ -177,7 +177,7 @@ struct usb_se401 {
177 int expose_m; 177 int expose_m;
178 int expose_l; 178 int expose_l;
179 int resetlevel; 179 int resetlevel;
180 180
181 int enhance; 181 int enhance;
182 182
183 int format; 183 int format;
@@ -200,12 +200,12 @@ struct usb_se401 {
200 200
201 struct urb *urb[SE401_NUMSBUF]; 201 struct urb *urb[SE401_NUMSBUF];
202 struct urb *inturb; 202 struct urb *inturb;
203 203
204 int button; 204 int button;
205 int buttonpressed; 205 int buttonpressed;
206 206
207 int curframe; /* Current receiving frame */ 207 int curframe; /* Current receiving frame */
208 struct se401_frame frame[SE401_NUMFRAMES]; 208 struct se401_frame frame[SE401_NUMFRAMES];
209 int readcount; 209 int readcount;
210 int framecount; 210 int framecount;
211 int error; 211 int error;
diff --git a/drivers/media/video/sn9c102/Makefile b/drivers/media/video/sn9c102/Makefile
index 8bcb0f71d69f..536ad3098da4 100644
--- a/drivers/media/video/sn9c102/Makefile
+++ b/drivers/media/video/sn9c102/Makefile
@@ -1,7 +1,7 @@
1sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o \ 1sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o \
2 sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bca.o \ 2 sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bca.o \
3 sn9c102_pas202bcb.o sn9c102_tas5110c1b.o \ 3 sn9c102_pas202bcb.o sn9c102_tas5110c1b.o \
4 sn9c102_tas5130d1b.o 4 sn9c102_tas5130d1b.o
5 5
6obj-$(CONFIG_USB_SN9C102) += sn9c102.o 6obj-$(CONFIG_USB_SN9C102) += sn9c102.o
7 7
diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h
index 1d70a62b9f23..2c6ff396dafc 100644
--- a/drivers/media/video/sn9c102/sn9c102.h
+++ b/drivers/media/video/sn9c102/sn9c102.h
@@ -164,7 +164,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id)
164 164
165void 165void
166sn9c102_attach_sensor(struct sn9c102_device* cam, 166sn9c102_attach_sensor(struct sn9c102_device* cam,
167 struct sn9c102_sensor* sensor) 167 struct sn9c102_sensor* sensor)
168{ 168{
169 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor)); 169 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor));
170} 170}
@@ -183,7 +183,7 @@ do { \
183 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ 183 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
184 else if ((level) >= 3) \ 184 else if ((level) >= 3) \
185 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 185 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
186 __FUNCTION__, __LINE__ , ## args); \ 186 __FUNCTION__, __LINE__ , ## args); \
187 } \ 187 } \
188} while (0) 188} while (0)
189# define V4LDBG(level, name, cmd) \ 189# define V4LDBG(level, name, cmd) \
@@ -198,7 +198,7 @@ do { \
198 pr_info("sn9c102: " fmt "\n", ## args); \ 198 pr_info("sn9c102: " fmt "\n", ## args); \
199 else if ((level) == 3) \ 199 else if ((level) == 3) \
200 pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \ 200 pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \
201 __LINE__ , ## args); \ 201 __LINE__ , ## args); \
202 } \ 202 } \
203} while (0) 203} while (0)
204#else 204#else
@@ -210,7 +210,7 @@ do { \
210#undef PDBG 210#undef PDBG
211#define PDBG(fmt, args...) \ 211#define PDBG(fmt, args...) \
212dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 212dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
213 __FUNCTION__, __LINE__ , ## args) 213 __FUNCTION__, __LINE__ , ## args)
214 214
215#undef PDBGG 215#undef PDBGG
216#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ 216#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 4c6cc6395723..ea4394dc9415 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -62,53 +62,53 @@ MODULE_LICENSE(SN9C102_MODULE_LICENSE);
62static short video_nr[] = {[0 ... SN9C102_MAX_DEVICES-1] = -1}; 62static short video_nr[] = {[0 ... SN9C102_MAX_DEVICES-1] = -1};
63module_param_array(video_nr, short, NULL, 0444); 63module_param_array(video_nr, short, NULL, 0444);
64MODULE_PARM_DESC(video_nr, 64MODULE_PARM_DESC(video_nr,
65 "\n<-1|n[,...]> Specify V4L2 minor mode number." 65 "\n<-1|n[,...]> Specify V4L2 minor mode number."
66 "\n -1 = use next available (default)" 66 "\n -1 = use next available (default)"
67 "\n n = use minor number n (integer >= 0)" 67 "\n n = use minor number n (integer >= 0)"
68 "\nYou can specify up to "__MODULE_STRING(SN9C102_MAX_DEVICES) 68 "\nYou can specify up to "__MODULE_STRING(SN9C102_MAX_DEVICES)
69 " cameras this way." 69 " cameras this way."
70 "\nFor example:" 70 "\nFor example:"
71 "\nvideo_nr=-1,2,-1 would assign minor number 2 to" 71 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
72 "\nthe second camera and use auto for the first" 72 "\nthe second camera and use auto for the first"
73 "\none and for every other camera." 73 "\none and for every other camera."
74 "\n"); 74 "\n");
75 75
76static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] = 76static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] =
77 SN9C102_FORCE_MUNMAP}; 77 SN9C102_FORCE_MUNMAP};
78module_param_array(force_munmap, bool, NULL, 0444); 78module_param_array(force_munmap, bool, NULL, 0444);
79MODULE_PARM_DESC(force_munmap, 79MODULE_PARM_DESC(force_munmap,
80 "\n<0|1[,...]> Force the application to unmap previously" 80 "\n<0|1[,...]> Force the application to unmap previously"
81 "\nmapped buffer memory before calling any VIDIOC_S_CROP or" 81 "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
82 "\nVIDIOC_S_FMT ioctl's. Not all the applications support" 82 "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
83 "\nthis feature. This parameter is specific for each" 83 "\nthis feature. This parameter is specific for each"
84 "\ndetected camera." 84 "\ndetected camera."
85 "\n 0 = do not force memory unmapping" 85 "\n 0 = do not force memory unmapping"
86 "\n 1 = force memory unmapping (save memory)" 86 "\n 1 = force memory unmapping (save memory)"
87 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." 87 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
88 "\n"); 88 "\n");
89 89
90static unsigned int frame_timeout[] = {[0 ... SN9C102_MAX_DEVICES-1] = 90static unsigned int frame_timeout[] = {[0 ... SN9C102_MAX_DEVICES-1] =
91 SN9C102_FRAME_TIMEOUT}; 91 SN9C102_FRAME_TIMEOUT};
92module_param_array(frame_timeout, uint, NULL, 0644); 92module_param_array(frame_timeout, uint, NULL, 0644);
93MODULE_PARM_DESC(frame_timeout, 93MODULE_PARM_DESC(frame_timeout,
94 "\n<n[,...]> Timeout for a video frame in seconds." 94 "\n<n[,...]> Timeout for a video frame in seconds."
95 "\nThis parameter is specific for each detected camera." 95 "\nThis parameter is specific for each detected camera."
96 "\nDefault value is "__MODULE_STRING(SN9C102_FRAME_TIMEOUT)"." 96 "\nDefault value is "__MODULE_STRING(SN9C102_FRAME_TIMEOUT)"."
97 "\n"); 97 "\n");
98 98
99#ifdef SN9C102_DEBUG 99#ifdef SN9C102_DEBUG
100static unsigned short debug = SN9C102_DEBUG_LEVEL; 100static unsigned short debug = SN9C102_DEBUG_LEVEL;
101module_param(debug, ushort, 0644); 101module_param(debug, ushort, 0644);
102MODULE_PARM_DESC(debug, 102MODULE_PARM_DESC(debug,
103 "\n<n> Debugging information level, from 0 to 3:" 103 "\n<n> Debugging information level, from 0 to 3:"
104 "\n0 = none (use carefully)" 104 "\n0 = none (use carefully)"
105 "\n1 = critical errors" 105 "\n1 = critical errors"
106 "\n2 = significant informations" 106 "\n2 = significant informations"
107 "\n3 = more verbose messages" 107 "\n3 = more verbose messages"
108 "\nLevel 3 is useful for testing only, when only " 108 "\nLevel 3 is useful for testing only, when only "
109 "one device is used." 109 "one device is used."
110 "\nDefault value is "__MODULE_STRING(SN9C102_DEBUG_LEVEL)"." 110 "\nDefault value is "__MODULE_STRING(SN9C102_DEBUG_LEVEL)"."
111 "\n"); 111 "\n");
112#endif 112#endif
113 113
114/*****************************************************************************/ 114/*****************************************************************************/
@@ -131,16 +131,16 @@ static sn9c102_eof_header_t sn9c102_eof_header[] = {
131 131
132/*****************************************************************************/ 132/*****************************************************************************/
133 133
134static u32 134static u32
135sn9c102_request_buffers(struct sn9c102_device* cam, u32 count, 135sn9c102_request_buffers(struct sn9c102_device* cam, u32 count,
136 enum sn9c102_io_method io) 136 enum sn9c102_io_method io)
137{ 137{
138 struct v4l2_pix_format* p = &(cam->sensor.pix_format); 138 struct v4l2_pix_format* p = &(cam->sensor.pix_format);
139 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds); 139 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds);
140 const size_t imagesize = cam->module_param.force_munmap || 140 const size_t imagesize = cam->module_param.force_munmap ||
141 io == IO_READ ? 141 io == IO_READ ?
142 (p->width * p->height * p->priv) / 8 : 142 (p->width * p->height * p->priv) / 8 :
143 (r->width * r->height * p->priv) / 8; 143 (r->width * r->height * p->priv) / 8;
144 void* buff = NULL; 144 void* buff = NULL;
145 u32 i; 145 u32 i;
146 146
@@ -232,8 +232,8 @@ int sn9c102_write_regs(struct sn9c102_device* cam, u8* buff, u16 index)
232 return -1; 232 return -1;
233 233
234 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 234 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
235 index, 0, buff, sizeof(buff), 235 index, 0, buff, sizeof(buff),
236 SN9C102_CTRL_TIMEOUT*sizeof(buff)); 236 SN9C102_CTRL_TIMEOUT*sizeof(buff));
237 if (res < 0) { 237 if (res < 0) {
238 DBG(3, "Failed to write registers (index 0x%02X, error %d)", 238 DBG(3, "Failed to write registers (index 0x%02X, error %d)",
239 index, res); 239 index, res);
@@ -259,7 +259,7 @@ int sn9c102_write_reg(struct sn9c102_device* cam, u8 value, u16 index)
259 *buff = value; 259 *buff = value;
260 260
261 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 261 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
262 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT); 262 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
263 if (res < 0) { 263 if (res < 0) {
264 DBG(3, "Failed to write a register (value 0x%02X, index " 264 DBG(3, "Failed to write a register (value 0x%02X, index "
265 "0x%02X, error %d)", value, index, res); 265 "0x%02X, error %d)", value, index, res);
@@ -280,7 +280,7 @@ static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index)
280 int res; 280 int res;
281 281
282 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, 282 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
283 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT); 283 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
284 if (res < 0) 284 if (res < 0)
285 DBG(3, "Failed to read a register (index 0x%02X, error %d)", 285 DBG(3, "Failed to read a register (index 0x%02X, error %d)",
286 index, res); 286 index, res);
@@ -319,8 +319,8 @@ sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor)
319 319
320 320
321static int 321static int
322sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, 322sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
323 struct sn9c102_sensor* sensor) 323 struct sn9c102_sensor* sensor)
324{ 324{
325 int r; 325 int r;
326 r = sn9c102_read_reg(cam, 0x08); 326 r = sn9c102_read_reg(cam, 0x08);
@@ -329,8 +329,8 @@ sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
329 329
330 330
331static int 331static int
332sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, 332sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
333 struct sn9c102_sensor* sensor) 333 struct sn9c102_sensor* sensor)
334{ 334{
335 int r; 335 int r;
336 r = sn9c102_read_reg(cam, 0x08); 336 r = sn9c102_read_reg(cam, 0x08);
@@ -338,10 +338,10 @@ sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
338} 338}
339 339
340 340
341int 341int
342sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 342sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
343 struct sn9c102_sensor* sensor, u8 data0, u8 data1, 343 struct sn9c102_sensor* sensor, u8 data0, u8 data1,
344 u8 n, u8 buffer[]) 344 u8 n, u8 buffer[])
345{ 345{
346 struct usb_device* udev = cam->usbdev; 346 struct usb_device* udev = cam->usbdev;
347 u8* data = cam->control_buffer; 347 u8* data = cam->control_buffer;
@@ -349,12 +349,12 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
349 349
350 /* Write cycle */ 350 /* Write cycle */
351 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 351 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
352 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 0x10; 352 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 0x10;
353 data[1] = data0; /* I2C slave id */ 353 data[1] = data0; /* I2C slave id */
354 data[2] = data1; /* address */ 354 data[2] = data1; /* address */
355 data[7] = 0x10; 355 data[7] = 0x10;
356 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 356 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
357 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT); 357 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
358 if (res < 0) 358 if (res < 0)
359 err += res; 359 err += res;
360 360
@@ -362,12 +362,12 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
362 362
363 /* Read cycle - n bytes */ 363 /* Read cycle - n bytes */
364 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 364 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
365 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 365 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) |
366 (n << 4) | 0x02; 366 (n << 4) | 0x02;
367 data[1] = data0; 367 data[1] = data0;
368 data[7] = 0x10; 368 data[7] = 0x10;
369 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 369 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
370 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT); 370 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
371 if (res < 0) 371 if (res < 0)
372 err += res; 372 err += res;
373 373
@@ -375,7 +375,7 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
375 375
376 /* The first read byte will be placed in data[4] */ 376 /* The first read byte will be placed in data[4] */
377 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, 377 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
378 0x0a, 0, data, 5, SN9C102_CTRL_TIMEOUT); 378 0x0a, 0, data, 5, SN9C102_CTRL_TIMEOUT);
379 if (res < 0) 379 if (res < 0)
380 err += res; 380 err += res;
381 381
@@ -396,10 +396,10 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
396} 396}
397 397
398 398
399int 399int
400sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 400sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
401 struct sn9c102_sensor* sensor, u8 n, u8 data0, 401 struct sn9c102_sensor* sensor, u8 n, u8 data0,
402 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5) 402 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5)
403{ 403{
404 struct usb_device* udev = cam->usbdev; 404 struct usb_device* udev = cam->usbdev;
405 u8* data = cam->control_buffer; 405 u8* data = cam->control_buffer;
@@ -407,8 +407,8 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
407 407
408 /* Write cycle. It usually is address + value */ 408 /* Write cycle. It usually is address + value */
409 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 409 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
410 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) 410 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0)
411 | ((n - 1) << 4); 411 | ((n - 1) << 4);
412 data[1] = data0; 412 data[1] = data0;
413 data[2] = data1; 413 data[2] = data1;
414 data[3] = data2; 414 data[3] = data2;
@@ -417,7 +417,7 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
417 data[6] = data5; 417 data[6] = data5;
418 data[7] = 0x14; 418 data[7] = 0x14;
419 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 419 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
420 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT); 420 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
421 if (res < 0) 421 if (res < 0)
422 err += res; 422 err += res;
423 423
@@ -437,20 +437,20 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
437 437
438int 438int
439sn9c102_i2c_try_read(struct sn9c102_device* cam, 439sn9c102_i2c_try_read(struct sn9c102_device* cam,
440 struct sn9c102_sensor* sensor, u8 address) 440 struct sn9c102_sensor* sensor, u8 address)
441{ 441{
442 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id, 442 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id,
443 address, 1, NULL); 443 address, 1, NULL);
444} 444}
445 445
446 446
447int 447int
448sn9c102_i2c_try_write(struct sn9c102_device* cam, 448sn9c102_i2c_try_write(struct sn9c102_device* cam,
449 struct sn9c102_sensor* sensor, u8 address, u8 value) 449 struct sn9c102_sensor* sensor, u8 address, u8 value)
450{ 450{
451 return sn9c102_i2c_try_raw_write(cam, sensor, 3, 451 return sn9c102_i2c_try_raw_write(cam, sensor, 3,
452 sensor->i2c_slave_id, address, 452 sensor->i2c_slave_id, address,
453 value, 0, 0, 0); 453 value, 0, 0, 0);
454} 454}
455 455
456 456
@@ -484,7 +484,7 @@ sn9c102_find_sof_header(struct sn9c102_device* cam, void* mem, size_t len)
484 n = sizeof(sn9c103_sof_header) / soflen; 484 n = sizeof(sn9c103_sof_header) / soflen;
485 } 485 }
486 486
487 for (i = 0; (len >= soflen) && (i <= len - soflen); i++) 487 for (i = 0; (len >= soflen) && (i <= len - soflen); i++)
488 for (j = 0; j < n; j++) 488 for (j = 0; j < n; j++)
489 /* The invariable part of the header is 6 bytes long */ 489 /* The invariable part of the header is 6 bytes long */
490 if ((cam->bridge != BRIDGE_SN9C103 && 490 if ((cam->bridge != BRIDGE_SN9C103 &&
@@ -552,15 +552,15 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs)
552 552
553 if (!(*f)) 553 if (!(*f))
554 (*f) = list_entry(cam->inqueue.next, struct sn9c102_frame_t, 554 (*f) = list_entry(cam->inqueue.next, struct sn9c102_frame_t,
555 frame); 555 frame);
556 556
557 imagesize = (cam->sensor.pix_format.width * 557 imagesize = (cam->sensor.pix_format.width *
558 cam->sensor.pix_format.height * 558 cam->sensor.pix_format.height *
559 cam->sensor.pix_format.priv) / 8; 559 cam->sensor.pix_format.priv) / 8;
560 560
561 soflen = (cam->bridge) == BRIDGE_SN9C103 ? 561 soflen = (cam->bridge) == BRIDGE_SN9C103 ?
562 sizeof(sn9c103_sof_header_t) : 562 sizeof(sn9c103_sof_header_t) :
563 sizeof(sn9c102_sof_header_t); 563 sizeof(sn9c102_sof_header_t);
564 564
565 for (i = 0; i < urb->number_of_packets; i++) { 565 for (i = 0; i < urb->number_of_packets; i++) {
566 unsigned int img, len, status; 566 unsigned int img, len, status;
@@ -611,19 +611,19 @@ end_of_frame:
611 611
612 if ((*f)->buf.bytesused == imagesize || 612 if ((*f)->buf.bytesused == imagesize ||
613 (cam->sensor.pix_format.pixelformat == 613 (cam->sensor.pix_format.pixelformat ==
614 V4L2_PIX_FMT_SN9C10X && eof)) { 614 V4L2_PIX_FMT_SN9C10X && eof)) {
615 u32 b; 615 u32 b;
616 b = (*f)->buf.bytesused; 616 b = (*f)->buf.bytesused;
617 (*f)->state = F_DONE; 617 (*f)->state = F_DONE;
618 (*f)->buf.sequence= ++cam->frame_count; 618 (*f)->buf.sequence= ++cam->frame_count;
619 spin_lock(&cam->queue_lock); 619 spin_lock(&cam->queue_lock);
620 list_move_tail(&(*f)->frame, 620 list_move_tail(&(*f)->frame,
621 &cam->outqueue); 621 &cam->outqueue);
622 if (!list_empty(&cam->inqueue)) 622 if (!list_empty(&cam->inqueue))
623 (*f) = list_entry( 623 (*f) = list_entry(
624 cam->inqueue.next, 624 cam->inqueue.next,
625 struct sn9c102_frame_t, 625 struct sn9c102_frame_t,
626 frame ); 626 frame );
627 else 627 else
628 (*f) = NULL; 628 (*f) = NULL;
629 spin_unlock(&cam->queue_lock); 629 spin_unlock(&cam->queue_lock);
@@ -638,7 +638,7 @@ end_of_frame:
638 } else if (eof) { 638 } else if (eof) {
639 (*f)->state = F_ERROR; 639 (*f)->state = F_ERROR;
640 DBG(3, "Not expected EOF after %lu " 640 DBG(3, "Not expected EOF after %lu "
641 "bytes of image data", 641 "bytes of image data",
642 (unsigned long) 642 (unsigned long)
643 ((*f)->buf.bytesused)); 643 ((*f)->buf.bytesused));
644 } 644 }
@@ -676,7 +676,7 @@ start_of_frame:
676 goto end_of_frame; 676 goto end_of_frame;
677 } else { 677 } else {
678 DBG(3, "SOF before expected EOF after " 678 DBG(3, "SOF before expected EOF after "
679 "%lu bytes of image data", 679 "%lu bytes of image data",
680 (unsigned long) 680 (unsigned long)
681 ((*f)->buf.bytesused)); 681 ((*f)->buf.bytesused));
682 goto start_of_frame; 682 goto start_of_frame;
@@ -702,18 +702,18 @@ static int sn9c102_start_transfer(struct sn9c102_device* cam)
702 struct usb_device *udev = cam->usbdev; 702 struct usb_device *udev = cam->usbdev;
703 struct urb* urb; 703 struct urb* urb;
704 const unsigned int sn9c102_wMaxPacketSize[] = {0, 128, 256, 384, 512, 704 const unsigned int sn9c102_wMaxPacketSize[] = {0, 128, 256, 384, 512,
705 680, 800, 900, 1023}; 705 680, 800, 900, 1023};
706 const unsigned int sn9c103_wMaxPacketSize[] = {0, 128, 256, 384, 512, 706 const unsigned int sn9c103_wMaxPacketSize[] = {0, 128, 256, 384, 512,
707 680, 800, 900, 1003}; 707 680, 800, 900, 1003};
708 const unsigned int psz = (cam->bridge == BRIDGE_SN9C103) ? 708 const unsigned int psz = (cam->bridge == BRIDGE_SN9C103) ?
709 sn9c103_wMaxPacketSize[SN9C102_ALTERNATE_SETTING] : 709 sn9c103_wMaxPacketSize[SN9C102_ALTERNATE_SETTING] :
710 sn9c102_wMaxPacketSize[SN9C102_ALTERNATE_SETTING]; 710 sn9c102_wMaxPacketSize[SN9C102_ALTERNATE_SETTING];
711 s8 i, j; 711 s8 i, j;
712 int err = 0; 712 int err = 0;
713 713
714 for (i = 0; i < SN9C102_URBS; i++) { 714 for (i = 0; i < SN9C102_URBS; i++) {
715 cam->transfer_buffer[i] = kzalloc(SN9C102_ISO_PACKETS * psz, 715 cam->transfer_buffer[i] = kzalloc(SN9C102_ISO_PACKETS * psz,
716 GFP_KERNEL); 716 GFP_KERNEL);
717 if (!cam->transfer_buffer[i]) { 717 if (!cam->transfer_buffer[i]) {
718 err = -ENOMEM; 718 err = -ENOMEM;
719 DBG(1, "Not enough memory"); 719 DBG(1, "Not enough memory");
@@ -815,9 +815,9 @@ static int sn9c102_stream_interrupt(struct sn9c102_device* cam)
815 815
816 cam->stream = STREAM_INTERRUPT; 816 cam->stream = STREAM_INTERRUPT;
817 timeout = wait_event_timeout(cam->wait_stream, 817 timeout = wait_event_timeout(cam->wait_stream,
818 (cam->stream == STREAM_OFF) || 818 (cam->stream == STREAM_OFF) ||
819 (cam->state & DEV_DISCONNECTED), 819 (cam->state & DEV_DISCONNECTED),
820 SN9C102_URB_TIMEOUT); 820 SN9C102_URB_TIMEOUT);
821 if (cam->state & DEV_DISCONNECTED) 821 if (cam->state & DEV_DISCONNECTED)
822 return -ENODEV; 822 return -ENODEV;
823 else if (cam->stream != STREAM_OFF) { 823 else if (cam->stream != STREAM_OFF) {
@@ -861,7 +861,7 @@ static u8 sn9c102_strtou8(const char* buff, size_t len, ssize_t* count)
861 861
862/* 862/*
863 NOTE 1: being inside one of the following methods implies that the v4l 863 NOTE 1: being inside one of the following methods implies that the v4l
864 device exists for sure (see kobjects and reference counters) 864 device exists for sure (see kobjects and reference counters)
865 NOTE 2: buffers are PAGE_SIZE long 865 NOTE 2: buffers are PAGE_SIZE long
866*/ 866*/
867 867
@@ -884,10 +884,10 @@ static ssize_t sn9c102_show_reg(struct class_device* cd, char* buf)
884 mutex_unlock(&sn9c102_sysfs_lock); 884 mutex_unlock(&sn9c102_sysfs_lock);
885 885
886 return count; 886 return count;
887} 887}
888 888
889 889
890static ssize_t 890static ssize_t
891sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len) 891sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len)
892{ 892{
893 struct sn9c102_device* cam; 893 struct sn9c102_device* cam;
@@ -947,7 +947,7 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf)
947 mutex_unlock(&sn9c102_sysfs_lock); 947 mutex_unlock(&sn9c102_sysfs_lock);
948 948
949 return count; 949 return count;
950} 950}
951 951
952 952
953static ssize_t 953static ssize_t
@@ -1013,7 +1013,7 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf)
1013} 1013}
1014 1014
1015 1015
1016static ssize_t 1016static ssize_t
1017sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) 1017sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len)
1018{ 1018{
1019 struct sn9c102_device* cam; 1019 struct sn9c102_device* cam;
@@ -1078,7 +1078,7 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf)
1078 mutex_unlock(&sn9c102_sysfs_lock); 1078 mutex_unlock(&sn9c102_sysfs_lock);
1079 1079
1080 return count; 1080 return count;
1081} 1081}
1082 1082
1083 1083
1084static ssize_t 1084static ssize_t
@@ -1222,22 +1222,22 @@ static ssize_t sn9c102_show_frame_header(struct class_device* cd, char* buf)
1222 DBG(3, "Frame header, read bytes: %zd", count); 1222 DBG(3, "Frame header, read bytes: %zd", count);
1223 1223
1224 return count; 1224 return count;
1225} 1225}
1226 1226
1227 1227
1228static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, 1228static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR,
1229 sn9c102_show_reg, sn9c102_store_reg); 1229 sn9c102_show_reg, sn9c102_store_reg);
1230static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR, 1230static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
1231 sn9c102_show_val, sn9c102_store_val); 1231 sn9c102_show_val, sn9c102_store_val);
1232static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR, 1232static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR,
1233 sn9c102_show_i2c_reg, sn9c102_store_i2c_reg); 1233 sn9c102_show_i2c_reg, sn9c102_store_i2c_reg);
1234static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, 1234static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
1235 sn9c102_show_i2c_val, sn9c102_store_i2c_val); 1235 sn9c102_show_i2c_val, sn9c102_store_i2c_val);
1236static CLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green); 1236static CLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green);
1237static CLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue); 1237static CLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue);
1238static CLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red); 1238static CLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red);
1239static CLASS_DEVICE_ATTR(frame_header, S_IRUGO, 1239static CLASS_DEVICE_ATTR(frame_header, S_IRUGO,
1240 sn9c102_show_frame_header, NULL); 1240 sn9c102_show_frame_header, NULL);
1241 1241
1242 1242
1243static void sn9c102_create_sysfs(struct sn9c102_device* cam) 1243static void sn9c102_create_sysfs(struct sn9c102_device* cam)
@@ -1278,7 +1278,7 @@ sn9c102_set_pix_format(struct sn9c102_device* cam, struct v4l2_pix_format* pix)
1278 1278
1279static int 1279static int
1280sn9c102_set_compression(struct sn9c102_device* cam, 1280sn9c102_set_compression(struct sn9c102_device* cam,
1281 struct v4l2_jpegcompression* compression) 1281 struct v4l2_jpegcompression* compression)
1282{ 1282{
1283 int err = 0; 1283 int err = 0;
1284 1284
@@ -1469,8 +1469,8 @@ static int sn9c102_open(struct inode* inode, struct file* filp)
1469 } 1469 }
1470 mutex_unlock(&cam->dev_mutex); 1470 mutex_unlock(&cam->dev_mutex);
1471 err = wait_event_interruptible_exclusive(cam->open, 1471 err = wait_event_interruptible_exclusive(cam->open,
1472 cam->state & DEV_DISCONNECTED 1472 cam->state & DEV_DISCONNECTED
1473 || !cam->users); 1473 || !cam->users);
1474 if (err) { 1474 if (err) {
1475 up_read(&sn9c102_disconnect); 1475 up_read(&sn9c102_disconnect);
1476 return err; 1476 return err;
@@ -1600,12 +1600,12 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
1600 return -EAGAIN; 1600 return -EAGAIN;
1601 } 1601 }
1602 timeout = wait_event_interruptible_timeout 1602 timeout = wait_event_interruptible_timeout
1603 ( cam->wait_frame, 1603 ( cam->wait_frame,
1604 (!list_empty(&cam->outqueue)) || 1604 (!list_empty(&cam->outqueue)) ||
1605 (cam->state & DEV_DISCONNECTED) || 1605 (cam->state & DEV_DISCONNECTED) ||
1606 (cam->state & DEV_MISCONFIGURED), 1606 (cam->state & DEV_MISCONFIGURED),
1607 cam->module_param.frame_timeout * 1607 cam->module_param.frame_timeout *
1608 1000 * msecs_to_jiffies(1) ); 1608 1000 * msecs_to_jiffies(1) );
1609 if (timeout < 0) { 1609 if (timeout < 0) {
1610 mutex_unlock(&cam->fileop_mutex); 1610 mutex_unlock(&cam->fileop_mutex);
1611 return timeout; 1611 return timeout;
@@ -1672,7 +1672,7 @@ static unsigned int sn9c102_poll(struct file *filp, poll_table *wait)
1672 1672
1673 if (cam->io == IO_NONE) { 1673 if (cam->io == IO_NONE) {
1674 if (!sn9c102_request_buffers(cam, cam->nreadbuffers, 1674 if (!sn9c102_request_buffers(cam, cam->nreadbuffers,
1675 IO_READ)) { 1675 IO_READ)) {
1676 DBG(1, "poll() failed, not enough memory"); 1676 DBG(1, "poll() failed, not enough memory");
1677 goto error; 1677 goto error;
1678 } 1678 }
@@ -1729,7 +1729,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma)
1729{ 1729{
1730 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 1730 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
1731 unsigned long size = vma->vm_end - vma->vm_start, 1731 unsigned long size = vma->vm_end - vma->vm_start,
1732 start = vma->vm_start; 1732 start = vma->vm_start;
1733 void *pos; 1733 void *pos;
1734 u32 i; 1734 u32 i;
1735 1735
@@ -1797,13 +1797,13 @@ sn9c102_vidioc_querycap(struct sn9c102_device* cam, void __user * arg)
1797 .driver = "sn9c102", 1797 .driver = "sn9c102",
1798 .version = SN9C102_MODULE_VERSION_CODE, 1798 .version = SN9C102_MODULE_VERSION_CODE,
1799 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | 1799 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1800 V4L2_CAP_STREAMING, 1800 V4L2_CAP_STREAMING,
1801 }; 1801 };
1802 1802
1803 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card)); 1803 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
1804 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0) 1804 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
1805 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id, 1805 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
1806 sizeof(cap.bus_info)); 1806 sizeof(cap.bus_info));
1807 1807
1808 if (copy_to_user(arg, &cap, sizeof(cap))) 1808 if (copy_to_user(arg, &cap, sizeof(cap)))
1809 return -EFAULT; 1809 return -EFAULT;
@@ -2138,7 +2138,7 @@ sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg)
2138 return -EINVAL; 2138 return -EINVAL;
2139 2139
2140 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_SN9C10X) 2140 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_SN9C10X)
2141 ? 0 : (pfmt->width * pfmt->priv) / 8; 2141 ? 0 : (pfmt->width * pfmt->priv) / 8;
2142 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8); 2142 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
2143 pfmt->field = V4L2_FIELD_NONE; 2143 pfmt->field = V4L2_FIELD_NONE;
2144 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt)); 2144 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
@@ -2152,7 +2152,7 @@ sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg)
2152 2152
2153static int 2153static int
2154sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd, 2154sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
2155 void __user * arg) 2155 void __user * arg)
2156{ 2156{
2157 struct sn9c102_sensor* s = &cam->sensor; 2157 struct sn9c102_sensor* s = &cam->sensor;
2158 struct v4l2_format format; 2158 struct v4l2_format format;
@@ -2214,7 +2214,7 @@ sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
2214 pix->priv = pfmt->priv; /* bpp */ 2214 pix->priv = pfmt->priv; /* bpp */
2215 pix->colorspace = pfmt->colorspace; 2215 pix->colorspace = pfmt->colorspace;
2216 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) 2216 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_SN9C10X)
2217 ? 0 : (pix->width * pix->priv) / 8; 2217 ? 0 : (pix->width * pix->priv) / 8;
2218 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8); 2218 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
2219 pix->field = V4L2_FIELD_NONE; 2219 pix->field = V4L2_FIELD_NONE;
2220 2220
@@ -2287,7 +2287,7 @@ static int
2287sn9c102_vidioc_g_jpegcomp(struct sn9c102_device* cam, void __user * arg) 2287sn9c102_vidioc_g_jpegcomp(struct sn9c102_device* cam, void __user * arg)
2288{ 2288{
2289 if (copy_to_user(arg, &cam->compression, 2289 if (copy_to_user(arg, &cam->compression,
2290 sizeof(cam->compression))) 2290 sizeof(cam->compression)))
2291 return -EFAULT; 2291 return -EFAULT;
2292 2292
2293 return 0; 2293 return 0;
@@ -2436,7 +2436,7 @@ sn9c102_vidioc_qbuf(struct sn9c102_device* cam, void __user * arg)
2436 2436
2437static int 2437static int
2438sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp, 2438sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp,
2439 void __user * arg) 2439 void __user * arg)
2440{ 2440{
2441 struct v4l2_buffer b; 2441 struct v4l2_buffer b;
2442 struct sn9c102_frame_t *f; 2442 struct sn9c102_frame_t *f;
@@ -2455,12 +2455,12 @@ sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp,
2455 if (filp->f_flags & O_NONBLOCK) 2455 if (filp->f_flags & O_NONBLOCK)
2456 return -EAGAIN; 2456 return -EAGAIN;
2457 timeout = wait_event_interruptible_timeout 2457 timeout = wait_event_interruptible_timeout
2458 ( cam->wait_frame, 2458 ( cam->wait_frame,
2459 (!list_empty(&cam->outqueue)) || 2459 (!list_empty(&cam->outqueue)) ||
2460 (cam->state & DEV_DISCONNECTED) || 2460 (cam->state & DEV_DISCONNECTED) ||
2461 (cam->state & DEV_MISCONFIGURED), 2461 (cam->state & DEV_MISCONFIGURED),
2462 cam->module_param.frame_timeout * 2462 cam->module_param.frame_timeout *
2463 1000 * msecs_to_jiffies(1) ); 2463 1000 * msecs_to_jiffies(1) );
2464 if (timeout < 0) 2464 if (timeout < 0)
2465 return timeout; 2465 return timeout;
2466 if (cam->state & DEV_DISCONNECTED) 2466 if (cam->state & DEV_DISCONNECTED)
@@ -2584,7 +2584,7 @@ sn9c102_vidioc_s_parm(struct sn9c102_device* cam, void __user * arg)
2584 2584
2585 2585
2586static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, 2586static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
2587 unsigned int cmd, void __user * arg) 2587 unsigned int cmd, void __user * arg)
2588{ 2588{
2589 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 2589 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
2590 2590
@@ -2678,7 +2678,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
2678 2678
2679 2679
2680static int sn9c102_ioctl(struct inode* inode, struct file* filp, 2680static int sn9c102_ioctl(struct inode* inode, struct file* filp,
2681 unsigned int cmd, unsigned long arg) 2681 unsigned int cmd, unsigned long arg)
2682{ 2682{
2683 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 2683 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
2684 int err = 0; 2684 int err = 0;
@@ -2761,7 +2761,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2761 } 2761 }
2762 2762
2763 cam->bridge = (id->idProduct & 0xffc0) == 0x6080 ? 2763 cam->bridge = (id->idProduct & 0xffc0) == 0x6080 ?
2764 BRIDGE_SN9C103 : BRIDGE_SN9C102; 2764 BRIDGE_SN9C103 : BRIDGE_SN9C102;
2765 switch (cam->bridge) { 2765 switch (cam->bridge) {
2766 case BRIDGE_SN9C101: 2766 case BRIDGE_SN9C101:
2767 case BRIDGE_SN9C102: 2767 case BRIDGE_SN9C102:
@@ -2807,7 +2807,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2807 mutex_lock(&cam->dev_mutex); 2807 mutex_lock(&cam->dev_mutex);
2808 2808
2809 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 2809 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
2810 video_nr[dev_nr]); 2810 video_nr[dev_nr]);
2811 if (err) { 2811 if (err) {
2812 DBG(1, "V4L2 device registration failed"); 2812 DBG(1, "V4L2 device registration failed");
2813 if (err == -ENFILE && video_nr[dev_nr] == -1) 2813 if (err == -ENFILE && video_nr[dev_nr] == -1)
diff --git a/drivers/media/video/sn9c102/sn9c102_hv7131d.c b/drivers/media/video/sn9c102/sn9c102_hv7131d.c
index 46c12ec3ca62..c4117bf64b69 100644
--- a/drivers/media/video/sn9c102/sn9c102_hv7131d.c
+++ b/drivers/media/video/sn9c102/sn9c102_hv7131d.c
@@ -44,8 +44,8 @@ static int hv7131d_init(struct sn9c102_device* cam)
44} 44}
45 45
46 46
47static int hv7131d_get_ctrl(struct sn9c102_device* cam, 47static int hv7131d_get_ctrl(struct sn9c102_device* cam,
48 struct v4l2_control* ctrl) 48 struct v4l2_control* ctrl)
49{ 49{
50 switch (ctrl->id) { 50 switch (ctrl->id) {
51 case V4L2_CID_EXPOSURE: 51 case V4L2_CID_EXPOSURE:
@@ -88,8 +88,8 @@ static int hv7131d_get_ctrl(struct sn9c102_device* cam,
88} 88}
89 89
90 90
91static int hv7131d_set_ctrl(struct sn9c102_device* cam, 91static int hv7131d_set_ctrl(struct sn9c102_device* cam,
92 const struct v4l2_control* ctrl) 92 const struct v4l2_control* ctrl)
93{ 93{
94 int err = 0; 94 int err = 0;
95 95
@@ -121,8 +121,8 @@ static int hv7131d_set_ctrl(struct sn9c102_device* cam,
121} 121}
122 122
123 123
124static int hv7131d_set_crop(struct sn9c102_device* cam, 124static int hv7131d_set_crop(struct sn9c102_device* cam,
125 const struct v4l2_rect* rect) 125 const struct v4l2_rect* rect)
126{ 126{
127 struct sn9c102_sensor* s = &hv7131d; 127 struct sn9c102_sensor* s = &hv7131d;
128 int err = 0; 128 int err = 0;
@@ -136,8 +136,8 @@ static int hv7131d_set_crop(struct sn9c102_device* cam,
136} 136}
137 137
138 138
139static int hv7131d_set_pix_format(struct sn9c102_device* cam, 139static int hv7131d_set_pix_format(struct sn9c102_device* cam,
140 const struct v4l2_pix_format* pix) 140 const struct v4l2_pix_format* pix)
141{ 141{
142 int err = 0; 142 int err = 0;
143 143
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0343.c b/drivers/media/video/sn9c102/sn9c102_mi0343.c
index d9aa7a61095d..4169ea4a2e20 100644
--- a/drivers/media/video/sn9c102/sn9c102_mi0343.c
+++ b/drivers/media/video/sn9c102/sn9c102_mi0343.c
@@ -39,64 +39,64 @@ static int mi0343_init(struct sn9c102_device* cam)
39 err += sn9c102_write_reg(cam, 0xa0, 0x19); 39 err += sn9c102_write_reg(cam, 0xa0, 0x19);
40 40
41 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 41 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
42 0x0d, 0x00, 0x01, 0, 0); 42 0x0d, 0x00, 0x01, 0, 0);
43 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 43 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
44 0x0d, 0x00, 0x00, 0, 0); 44 0x0d, 0x00, 0x00, 0, 0);
45 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 45 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
46 0x03, 0x01, 0xe1, 0, 0); 46 0x03, 0x01, 0xe1, 0, 0);
47 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 47 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
48 0x04, 0x02, 0x81, 0, 0); 48 0x04, 0x02, 0x81, 0, 0);
49 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 49 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
50 0x05, 0x00, 0x17, 0, 0); 50 0x05, 0x00, 0x17, 0, 0);
51 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 51 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
52 0x06, 0x00, 0x11, 0, 0); 52 0x06, 0x00, 0x11, 0, 0);
53 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 53 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
54 0x62, 0x04, 0x9a, 0, 0); 54 0x62, 0x04, 0x9a, 0, 0);
55 55
56 return err; 56 return err;
57} 57}
58 58
59 59
60static int mi0343_get_ctrl(struct sn9c102_device* cam, 60static int mi0343_get_ctrl(struct sn9c102_device* cam,
61 struct v4l2_control* ctrl) 61 struct v4l2_control* ctrl)
62{ 62{
63 switch (ctrl->id) { 63 switch (ctrl->id) {
64 case V4L2_CID_EXPOSURE: 64 case V4L2_CID_EXPOSURE:
65 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 65 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
66 0x09, 2+1, mi0343_i2c_data) < 0) 66 0x09, 2+1, mi0343_i2c_data) < 0)
67 return -EIO; 67 return -EIO;
68 ctrl->value = mi0343_i2c_data[2]; 68 ctrl->value = mi0343_i2c_data[2];
69 return 0; 69 return 0;
70 case V4L2_CID_GAIN: 70 case V4L2_CID_GAIN:
71 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 71 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
72 0x35, 2+1, mi0343_i2c_data) < 0) 72 0x35, 2+1, mi0343_i2c_data) < 0)
73 return -EIO; 73 return -EIO;
74 break; 74 break;
75 case V4L2_CID_HFLIP: 75 case V4L2_CID_HFLIP:
76 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 76 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
77 0x20, 2+1, mi0343_i2c_data) < 0) 77 0x20, 2+1, mi0343_i2c_data) < 0)
78 return -EIO; 78 return -EIO;
79 ctrl->value = mi0343_i2c_data[3] & 0x20 ? 1 : 0; 79 ctrl->value = mi0343_i2c_data[3] & 0x20 ? 1 : 0;
80 return 0; 80 return 0;
81 case V4L2_CID_VFLIP: 81 case V4L2_CID_VFLIP:
82 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 82 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
83 0x20, 2+1, mi0343_i2c_data) < 0) 83 0x20, 2+1, mi0343_i2c_data) < 0)
84 return -EIO; 84 return -EIO;
85 ctrl->value = mi0343_i2c_data[3] & 0x80 ? 1 : 0; 85 ctrl->value = mi0343_i2c_data[3] & 0x80 ? 1 : 0;
86 return 0; 86 return 0;
87 case V4L2_CID_RED_BALANCE: 87 case V4L2_CID_RED_BALANCE:
88 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 88 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
89 0x2d, 2+1, mi0343_i2c_data) < 0) 89 0x2d, 2+1, mi0343_i2c_data) < 0)
90 return -EIO; 90 return -EIO;
91 break; 91 break;
92 case V4L2_CID_BLUE_BALANCE: 92 case V4L2_CID_BLUE_BALANCE:
93 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 93 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
94 0x2c, 2+1, mi0343_i2c_data) < 0) 94 0x2c, 2+1, mi0343_i2c_data) < 0)
95 return -EIO; 95 return -EIO;
96 break; 96 break;
97 case SN9C102_V4L2_CID_GREEN_BALANCE: 97 case SN9C102_V4L2_CID_GREEN_BALANCE:
98 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 98 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
99 0x2e, 2+1, mi0343_i2c_data) < 0) 99 0x2e, 2+1, mi0343_i2c_data) < 0)
100 return -EIO; 100 return -EIO;
101 break; 101 break;
102 default: 102 default:
@@ -121,8 +121,8 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam,
121} 121}
122 122
123 123
124static int mi0343_set_ctrl(struct sn9c102_device* cam, 124static int mi0343_set_ctrl(struct sn9c102_device* cam,
125 const struct v4l2_control* ctrl) 125 const struct v4l2_control* ctrl)
126{ 126{
127 u16 reg = 0; 127 u16 reg = 0;
128 int err = 0; 128 int err = 0;
@@ -144,51 +144,51 @@ static int mi0343_set_ctrl(struct sn9c102_device* cam,
144 switch (ctrl->id) { 144 switch (ctrl->id) {
145 case V4L2_CID_EXPOSURE: 145 case V4L2_CID_EXPOSURE:
146 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 146 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
147 mi0343.i2c_slave_id, 147 mi0343.i2c_slave_id,
148 0x09, ctrl->value, 0x00, 148 0x09, ctrl->value, 0x00,
149 0, 0); 149 0, 0);
150 break; 150 break;
151 case V4L2_CID_GAIN: 151 case V4L2_CID_GAIN:
152 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 152 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
153 mi0343.i2c_slave_id, 153 mi0343.i2c_slave_id,
154 0x35, reg >> 8, reg & 0xff, 154 0x35, reg >> 8, reg & 0xff,
155 0, 0); 155 0, 0);
156 break; 156 break;
157 case V4L2_CID_HFLIP: 157 case V4L2_CID_HFLIP:
158 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 158 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
159 mi0343.i2c_slave_id, 159 mi0343.i2c_slave_id,
160 0x20, ctrl->value ? 0x40:0x00, 160 0x20, ctrl->value ? 0x40:0x00,
161 ctrl->value ? 0x20:0x00, 161 ctrl->value ? 0x20:0x00,
162 0, 0); 162 0, 0);
163 break; 163 break;
164 case V4L2_CID_VFLIP: 164 case V4L2_CID_VFLIP:
165 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 165 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
166 mi0343.i2c_slave_id, 166 mi0343.i2c_slave_id,
167 0x20, ctrl->value ? 0x80:0x00, 167 0x20, ctrl->value ? 0x80:0x00,
168 ctrl->value ? 0x80:0x00, 168 ctrl->value ? 0x80:0x00,
169 0, 0); 169 0, 0);
170 break; 170 break;
171 case V4L2_CID_RED_BALANCE: 171 case V4L2_CID_RED_BALANCE:
172 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 172 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
173 mi0343.i2c_slave_id, 173 mi0343.i2c_slave_id,
174 0x2d, reg >> 8, reg & 0xff, 174 0x2d, reg >> 8, reg & 0xff,
175 0, 0); 175 0, 0);
176 break; 176 break;
177 case V4L2_CID_BLUE_BALANCE: 177 case V4L2_CID_BLUE_BALANCE:
178 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 178 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
179 mi0343.i2c_slave_id, 179 mi0343.i2c_slave_id,
180 0x2c, reg >> 8, reg & 0xff, 180 0x2c, reg >> 8, reg & 0xff,
181 0, 0); 181 0, 0);
182 break; 182 break;
183 case SN9C102_V4L2_CID_GREEN_BALANCE: 183 case SN9C102_V4L2_CID_GREEN_BALANCE:
184 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 184 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
185 mi0343.i2c_slave_id, 185 mi0343.i2c_slave_id,
186 0x2b, reg >> 8, reg & 0xff, 186 0x2b, reg >> 8, reg & 0xff,
187 0, 0); 187 0, 0);
188 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 188 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
189 mi0343.i2c_slave_id, 189 mi0343.i2c_slave_id,
190 0x2e, reg >> 8, reg & 0xff, 190 0x2e, reg >> 8, reg & 0xff,
191 0, 0); 191 0, 0);
192 break; 192 break;
193 default: 193 default:
194 return -EINVAL; 194 return -EINVAL;
@@ -198,8 +198,8 @@ static int mi0343_set_ctrl(struct sn9c102_device* cam,
198} 198}
199 199
200 200
201static int mi0343_set_crop(struct sn9c102_device* cam, 201static int mi0343_set_crop(struct sn9c102_device* cam,
202 const struct v4l2_rect* rect) 202 const struct v4l2_rect* rect)
203{ 203{
204 struct sn9c102_sensor* s = &mi0343; 204 struct sn9c102_sensor* s = &mi0343;
205 int err = 0; 205 int err = 0;
@@ -213,20 +213,20 @@ static int mi0343_set_crop(struct sn9c102_device* cam,
213} 213}
214 214
215 215
216static int mi0343_set_pix_format(struct sn9c102_device* cam, 216static int mi0343_set_pix_format(struct sn9c102_device* cam,
217 const struct v4l2_pix_format* pix) 217 const struct v4l2_pix_format* pix)
218{ 218{
219 int err = 0; 219 int err = 0;
220 220
221 if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { 221 if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) {
222 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 222 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
223 mi0343.i2c_slave_id, 223 mi0343.i2c_slave_id,
224 0x0a, 0x00, 0x03, 0, 0); 224 0x0a, 0x00, 0x03, 0, 0);
225 err += sn9c102_write_reg(cam, 0x20, 0x19); 225 err += sn9c102_write_reg(cam, 0x20, 0x19);
226 } else { 226 } else {
227 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 227 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
228 mi0343.i2c_slave_id, 228 mi0343.i2c_slave_id,
229 0x0a, 0x00, 0x05, 0, 0); 229 0x0a, 0x00, 0x05, 0, 0);
230 err += sn9c102_write_reg(cam, 0xa0, 0x19); 230 err += sn9c102_write_reg(cam, 0xa0, 0x19);
231 } 231 }
232 232
@@ -351,7 +351,7 @@ int sn9c102_probe_mi0343(struct sn9c102_device* cam)
351 return -EIO; 351 return -EIO;
352 352
353 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, 353 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00,
354 2, mi0343_i2c_data) < 0) 354 2, mi0343_i2c_data) < 0)
355 return -EIO; 355 return -EIO;
356 356
357 if (mi0343_i2c_data[4] != 0x32 && mi0343_i2c_data[3] != 0xe3) 357 if (mi0343_i2c_data[4] != 0x32 && mi0343_i2c_data[3] != 0xe3)
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7630.c b/drivers/media/video/sn9c102/sn9c102_ov7630.c
index 42852b7cb042..3da042021787 100644
--- a/drivers/media/video/sn9c102/sn9c102_ov7630.c
+++ b/drivers/media/video/sn9c102/sn9c102_ov7630.c
@@ -69,7 +69,7 @@ static int ov7630_init(struct sn9c102_device* cam)
69 69
70 70
71static int ov7630_set_ctrl(struct sn9c102_device* cam, 71static int ov7630_set_ctrl(struct sn9c102_device* cam,
72 const struct v4l2_control* ctrl) 72 const struct v4l2_control* ctrl)
73{ 73{
74 int err = 0; 74 int err = 0;
75 75
@@ -89,8 +89,8 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
89 break; 89 break;
90 case V4L2_CID_CONTRAST: 90 case V4L2_CID_CONTRAST:
91 err += ctrl->value ? sn9c102_i2c_write(cam, 0x05, 91 err += ctrl->value ? sn9c102_i2c_write(cam, 0x05,
92 (ctrl->value-1) | 0x20) 92 (ctrl->value-1) | 0x20)
93 : sn9c102_i2c_write(cam, 0x05, 0x00); 93 : sn9c102_i2c_write(cam, 0x05, 0x00);
94 break; 94 break;
95 case V4L2_CID_BRIGHTNESS: 95 case V4L2_CID_BRIGHTNESS:
96 err += sn9c102_i2c_write(cam, 0x06, ctrl->value); 96 err += sn9c102_i2c_write(cam, 0x06, ctrl->value);
@@ -100,8 +100,8 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
100 break; 100 break;
101 case V4L2_CID_HUE: 101 case V4L2_CID_HUE:
102 err += ctrl->value ? sn9c102_i2c_write(cam, 0x04, 102 err += ctrl->value ? sn9c102_i2c_write(cam, 0x04,
103 (ctrl->value-1) | 0x20) 103 (ctrl->value-1) | 0x20)
104 : sn9c102_i2c_write(cam, 0x04, 0x00); 104 : sn9c102_i2c_write(cam, 0x04, 0x00);
105 break; 105 break;
106 case V4L2_CID_DO_WHITE_BALANCE: 106 case V4L2_CID_DO_WHITE_BALANCE:
107 err += sn9c102_i2c_write(cam, 0x0c, ctrl->value); 107 err += sn9c102_i2c_write(cam, 0x0c, ctrl->value);
@@ -139,7 +139,7 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
139 139
140 140
141static int ov7630_set_crop(struct sn9c102_device* cam, 141static int ov7630_set_crop(struct sn9c102_device* cam,
142 const struct v4l2_rect* rect) 142 const struct v4l2_rect* rect)
143{ 143{
144 struct sn9c102_sensor* s = &ov7630; 144 struct sn9c102_sensor* s = &ov7630;
145 int err = 0; 145 int err = 0;
@@ -152,7 +152,7 @@ static int ov7630_set_crop(struct sn9c102_device* cam,
152 152
153 153
154static int ov7630_set_pix_format(struct sn9c102_device* cam, 154static int ov7630_set_pix_format(struct sn9c102_device* cam,
155 const struct v4l2_pix_format* pix) 155 const struct v4l2_pix_format* pix)
156{ 156{
157 int err = 0; 157 int err = 0;
158 158
diff --git a/drivers/media/video/sn9c102/sn9c102_pas106b.c b/drivers/media/video/sn9c102/sn9c102_pas106b.c
index b1dee78abe04..9915944235e8 100644
--- a/drivers/media/video/sn9c102/sn9c102_pas106b.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas106b.c
@@ -53,8 +53,8 @@ static int pas106b_init(struct sn9c102_device* cam)
53} 53}
54 54
55 55
56static int pas106b_get_ctrl(struct sn9c102_device* cam, 56static int pas106b_get_ctrl(struct sn9c102_device* cam,
57 struct v4l2_control* ctrl) 57 struct v4l2_control* ctrl)
58{ 58{
59 switch (ctrl->id) { 59 switch (ctrl->id) {
60 case V4L2_CID_EXPOSURE: 60 case V4L2_CID_EXPOSURE:
@@ -102,8 +102,8 @@ static int pas106b_get_ctrl(struct sn9c102_device* cam,
102} 102}
103 103
104 104
105static int pas106b_set_ctrl(struct sn9c102_device* cam, 105static int pas106b_set_ctrl(struct sn9c102_device* cam,
106 const struct v4l2_control* ctrl) 106 const struct v4l2_control* ctrl)
107{ 107{
108 int err = 0; 108 int err = 0;
109 109
@@ -140,8 +140,8 @@ static int pas106b_set_ctrl(struct sn9c102_device* cam,
140} 140}
141 141
142 142
143static int pas106b_set_crop(struct sn9c102_device* cam, 143static int pas106b_set_crop(struct sn9c102_device* cam,
144 const struct v4l2_rect* rect) 144 const struct v4l2_rect* rect)
145{ 145{
146 struct sn9c102_sensor* s = &pas106b; 146 struct sn9c102_sensor* s = &pas106b;
147 int err = 0; 147 int err = 0;
@@ -155,8 +155,8 @@ static int pas106b_set_crop(struct sn9c102_device* cam,
155} 155}
156 156
157 157
158static int pas106b_set_pix_format(struct sn9c102_device* cam, 158static int pas106b_set_pix_format(struct sn9c102_device* cam,
159 const struct v4l2_pix_format* pix) 159 const struct v4l2_pix_format* pix)
160{ 160{
161 int err = 0; 161 int err = 0;
162 162
diff --git a/drivers/media/video/sn9c102/sn9c102_pas202bca.c b/drivers/media/video/sn9c102/sn9c102_pas202bca.c
index 3453237055bb..c8f1ae2152b8 100644
--- a/drivers/media/video/sn9c102/sn9c102_pas202bca.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas202bca.c
@@ -54,7 +54,7 @@ static int pas202bca_init(struct sn9c102_device* cam)
54 54
55 55
56static int pas202bca_set_pix_format(struct sn9c102_device* cam, 56static int pas202bca_set_pix_format(struct sn9c102_device* cam,
57 const struct v4l2_pix_format* pix) 57 const struct v4l2_pix_format* pix)
58{ 58{
59 int err = 0; 59 int err = 0;
60 60
@@ -68,7 +68,7 @@ static int pas202bca_set_pix_format(struct sn9c102_device* cam,
68 68
69 69
70static int pas202bca_set_ctrl(struct sn9c102_device* cam, 70static int pas202bca_set_ctrl(struct sn9c102_device* cam,
71 const struct v4l2_control* ctrl) 71 const struct v4l2_control* ctrl)
72{ 72{
73 int err = 0; 73 int err = 0;
74 74
@@ -102,7 +102,7 @@ static int pas202bca_set_ctrl(struct sn9c102_device* cam,
102 102
103 103
104static int pas202bca_set_crop(struct sn9c102_device* cam, 104static int pas202bca_set_crop(struct sn9c102_device* cam,
105 const struct v4l2_rect* rect) 105 const struct v4l2_rect* rect)
106{ 106{
107 struct sn9c102_sensor* s = &pas202bca; 107 struct sn9c102_sensor* s = &pas202bca;
108 int err = 0; 108 int err = 0;
diff --git a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
index d068616ab337..e3c1178e339c 100644
--- a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
@@ -58,8 +58,8 @@ static int pas202bcb_init(struct sn9c102_device* cam)
58} 58}
59 59
60 60
61static int pas202bcb_get_ctrl(struct sn9c102_device* cam, 61static int pas202bcb_get_ctrl(struct sn9c102_device* cam,
62 struct v4l2_control* ctrl) 62 struct v4l2_control* ctrl)
63{ 63{
64 switch (ctrl->id) { 64 switch (ctrl->id) {
65 case V4L2_CID_EXPOSURE: 65 case V4L2_CID_EXPOSURE:
@@ -101,8 +101,8 @@ static int pas202bcb_get_ctrl(struct sn9c102_device* cam,
101} 101}
102 102
103 103
104static int pas202bcb_set_pix_format(struct sn9c102_device* cam, 104static int pas202bcb_set_pix_format(struct sn9c102_device* cam,
105 const struct v4l2_pix_format* pix) 105 const struct v4l2_pix_format* pix)
106{ 106{
107 int err = 0; 107 int err = 0;
108 108
@@ -115,8 +115,8 @@ static int pas202bcb_set_pix_format(struct sn9c102_device* cam,
115} 115}
116 116
117 117
118static int pas202bcb_set_ctrl(struct sn9c102_device* cam, 118static int pas202bcb_set_ctrl(struct sn9c102_device* cam,
119 const struct v4l2_control* ctrl) 119 const struct v4l2_control* ctrl)
120{ 120{
121 int err = 0; 121 int err = 0;
122 122
@@ -149,8 +149,8 @@ static int pas202bcb_set_ctrl(struct sn9c102_device* cam,
149} 149}
150 150
151 151
152static int pas202bcb_set_crop(struct sn9c102_device* cam, 152static int pas202bcb_set_crop(struct sn9c102_device* cam,
153 const struct v4l2_rect* rect) 153 const struct v4l2_rect* rect)
154{ 154{
155 struct sn9c102_sensor* s = &pas202bcb; 155 struct sn9c102_sensor* s = &pas202bcb;
156 int err = 0; 156 int err = 0;
@@ -167,7 +167,7 @@ static int pas202bcb_set_crop(struct sn9c102_device* cam,
167static struct sn9c102_sensor pas202bcb = { 167static struct sn9c102_sensor pas202bcb = {
168 .name = "PAS202BCB", 168 .name = "PAS202BCB",
169 .maintainer = "Carlos Eduardo Medaglia Dyonisio " 169 .maintainer = "Carlos Eduardo Medaglia Dyonisio "
170 "<medaglia@undl.org.br>", 170 "<medaglia@undl.org.br>",
171 .sysfs_ops = SN9C102_I2C_READ | SN9C102_I2C_WRITE, 171 .sysfs_ops = SN9C102_I2C_READ | SN9C102_I2C_WRITE,
172 .frequency = SN9C102_I2C_400KHZ | SN9C102_I2C_100KHZ, 172 .frequency = SN9C102_I2C_400KHZ | SN9C102_I2C_100KHZ,
173 .interface = SN9C102_I2C_2WIRES, 173 .interface = SN9C102_I2C_2WIRES,
diff --git a/drivers/media/video/sn9c102/sn9c102_sensor.h b/drivers/media/video/sn9c102/sn9c102_sensor.h
index 2afd9e9d09bb..2a874ee6f9f5 100644
--- a/drivers/media/video/sn9c102/sn9c102_sensor.h
+++ b/drivers/media/video/sn9c102/sn9c102_sensor.h
@@ -58,7 +58,7 @@ struct sn9c102_sensor;
58 Probing functions: on success, you must attach the sensor to the camera 58 Probing functions: on success, you must attach the sensor to the camera
59 by calling sn9c102_attach_sensor() provided below. 59 by calling sn9c102_attach_sensor() provided below.
60 To enable the I2C communication, you might need to perform a really basic 60 To enable the I2C communication, you might need to perform a really basic
61 initialization of the SN9C10X chip by using the write function declared 61 initialization of the SN9C10X chip by using the write function declared
62 ahead. 62 ahead.
63 Functions must return 0 on success, the appropriate error otherwise. 63 Functions must return 0 on success, the appropriate error otherwise.
64*/ 64*/
@@ -73,7 +73,7 @@ extern int sn9c102_probe_tas5130d1b(struct sn9c102_device* cam);
73 73
74/* 74/*
75 Add the above entries to this table. Be sure to add the entry in the right 75 Add the above entries to this table. Be sure to add the entry in the right
76 place, since, on failure, the next probing routine is called according to 76 place, since, on failure, the next probing routine is called according to
77 the order of the list below, from top to bottom. 77 the order of the list below, from top to bottom.
78*/ 78*/
79#define SN9C102_SENSOR_TABLE \ 79#define SN9C102_SENSOR_TABLE \
@@ -94,9 +94,9 @@ extern struct sn9c102_device*
94sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id); 94sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id);
95 95
96/* Attach a probed sensor to the camera. */ 96/* Attach a probed sensor to the camera. */
97extern void 97extern void
98sn9c102_attach_sensor(struct sn9c102_device* cam, 98sn9c102_attach_sensor(struct sn9c102_device* cam,
99 struct sn9c102_sensor* sensor); 99 struct sn9c102_sensor* sensor);
100 100
101/* 101/*
102 Each SN9C10x camera has proper PID/VID identifiers. 102 Each SN9C10x camera has proper PID/VID identifiers.
@@ -105,7 +105,7 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
105*/ 105*/
106#define SN9C102_USB_DEVICE(vend, prod, intclass) \ 106#define SN9C102_USB_DEVICE(vend, prod, intclass) \
107 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ 107 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
108 USB_DEVICE_ID_MATCH_INT_CLASS, \ 108 USB_DEVICE_ID_MATCH_INT_CLASS, \
109 .idVendor = (vend), \ 109 .idVendor = (vend), \
110 .idProduct = (prod), \ 110 .idProduct = (prod), \
111 .bInterfaceClass = (intclass) 111 .bInterfaceClass = (intclass)
@@ -162,19 +162,19 @@ static const struct usb_device_id sn9c102_id_table[] = { \
162 Read/write routines: they always return -1 on error, 0 or the read value 162 Read/write routines: they always return -1 on error, 0 or the read value
163 otherwise. NOTE that a real read operation is not supported by the SN9C10X 163 otherwise. NOTE that a real read operation is not supported by the SN9C10X
164 chip for some of its registers. To work around this problem, a pseudo-read 164 chip for some of its registers. To work around this problem, a pseudo-read
165 call is provided instead: it returns the last successfully written value 165 call is provided instead: it returns the last successfully written value
166 on the register (0 if it has never been written), the usual -1 on error. 166 on the register (0 if it has never been written), the usual -1 on error.
167*/ 167*/
168 168
169/* The "try" I2C I/O versions are used when probing the sensor */ 169/* The "try" I2C I/O versions are used when probing the sensor */
170extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*, 170extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*,
171 u8 address, u8 value); 171 u8 address, u8 value);
172extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, 172extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
173 u8 address); 173 u8 address);
174 174
175/* 175/*
176 These must be used if and only if the sensor doesn't implement the standard 176 These must be used if and only if the sensor doesn't implement the standard
177 I2C protocol. There are a number of good reasons why you must use the 177 I2C protocol. There are a number of good reasons why you must use the
178 single-byte versions of these functions: do not abuse. The first function 178 single-byte versions of these functions: do not abuse. The first function
179 writes n bytes, from data0 to datan, to registers 0x09 - 0x09+n of SN9C10X 179 writes n bytes, from data0 to datan, to registers 0x09 - 0x09+n of SN9C10X
180 chip. The second one programs the registers 0x09 and 0x10 with data0 and 180 chip. The second one programs the registers 0x09 and 0x10 with data0 and
@@ -184,12 +184,12 @@ extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
184 byte. 184 byte.
185*/ 185*/
186extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 186extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
187 struct sn9c102_sensor* sensor, u8 n, 187 struct sn9c102_sensor* sensor, u8 n,
188 u8 data0, u8 data1, u8 data2, u8 data3, 188 u8 data0, u8 data1, u8 data2, u8 data3,
189 u8 data4, u8 data5); 189 u8 data4, u8 data5);
190extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 190extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
191 struct sn9c102_sensor* sensor, u8 data0, 191 struct sn9c102_sensor* sensor, u8 data0,
192 u8 data1, u8 n, u8 buffer[]); 192 u8 data1, u8 n, u8 buffer[]);
193 193
194/* To be used after the sensor struct has been attached to the camera struct */ 194/* To be used after the sensor struct has been attached to the camera struct */
195extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); 195extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value);
@@ -252,17 +252,17 @@ struct sn9c102_sensor {
252 252
253 /* 253 /*
254 NOTE: Where not noted,most of the functions below are not mandatory. 254 NOTE: Where not noted,most of the functions below are not mandatory.
255 Set to null if you do not implement them. If implemented, 255 Set to null if you do not implement them. If implemented,
256 they must return 0 on success, the proper error otherwise. 256 they must return 0 on success, the proper error otherwise.
257 */ 257 */
258 258
259 int (*init)(struct sn9c102_device* cam); 259 int (*init)(struct sn9c102_device* cam);
260 /* 260 /*
261 This function will be called after the sensor has been attached. 261 This function will be called after the sensor has been attached.
262 It should be used to initialize the sensor only, but may also 262 It should be used to initialize the sensor only, but may also
263 configure part of the SN9C10X chip if necessary. You don't need to 263 configure part of the SN9C10X chip if necessary. You don't need to
264 setup picture settings like brightness, contrast, etc.. here, if 264 setup picture settings like brightness, contrast, etc.. here, if
265 the corrisponding controls are implemented (see below), since 265 the corrisponding controls are implemented (see below), since
266 they are adjusted in the core driver by calling the set_ctrl() 266 they are adjusted in the core driver by calling the set_ctrl()
267 method after init(), where the arguments are the default values 267 method after init(), where the arguments are the default values
268 specified in the v4l2_queryctrl list of supported controls; 268 specified in the v4l2_queryctrl list of supported controls;
@@ -273,13 +273,13 @@ struct sn9c102_sensor {
273 273
274 struct v4l2_queryctrl qctrl[SN9C102_MAX_CTRLS]; 274 struct v4l2_queryctrl qctrl[SN9C102_MAX_CTRLS];
275 /* 275 /*
276 Optional list of default controls, defined as indicated in the 276 Optional list of default controls, defined as indicated in the
277 V4L2 API. Menu type controls are not handled by this interface. 277 V4L2 API. Menu type controls are not handled by this interface.
278 */ 278 */
279 279
280 int (*get_ctrl)(struct sn9c102_device* cam, struct v4l2_control* ctrl); 280 int (*get_ctrl)(struct sn9c102_device* cam, struct v4l2_control* ctrl);
281 int (*set_ctrl)(struct sn9c102_device* cam, 281 int (*set_ctrl)(struct sn9c102_device* cam,
282 const struct v4l2_control* ctrl); 282 const struct v4l2_control* ctrl);
283 /* 283 /*
284 You must implement at least the set_ctrl method if you have defined 284 You must implement at least the set_ctrl method if you have defined
285 the list above. The returned value must follow the V4L2 285 the list above. The returned value must follow the V4L2
@@ -306,7 +306,7 @@ struct sn9c102_sensor {
306 specified in the cropcap substructures 'bounds' and 'defrect'. 306 specified in the cropcap substructures 'bounds' and 'defrect'.
307 By default, the source rectangle should cover the largest possible 307 By default, the source rectangle should cover the largest possible
308 area. Again, it is not always true that the largest source rectangle 308 area. Again, it is not always true that the largest source rectangle
309 can cover the entire active window, although it is a rare case for 309 can cover the entire active window, although it is a rare case for
310 the hardware we have. The bounds of the source rectangle _must_ be 310 the hardware we have. The bounds of the source rectangle _must_ be
311 multiple of 16 and must use the same coordinate system as indicated 311 multiple of 16 and must use the same coordinate system as indicated
312 before; their centers shall align initially. 312 before; their centers shall align initially.
@@ -317,13 +317,13 @@ struct sn9c102_sensor {
317 defined the correct default bounds in the structures. 317 defined the correct default bounds in the structures.
318 See the V4L2 API for further details. 318 See the V4L2 API for further details.
319 NOTE: once you have defined the bounds of the active window 319 NOTE: once you have defined the bounds of the active window
320 (struct cropcap.bounds) you must not change them.anymore. 320 (struct cropcap.bounds) you must not change them.anymore.
321 Only 'bounds' and 'defrect' fields are mandatory, other fields 321 Only 'bounds' and 'defrect' fields are mandatory, other fields
322 will be ignored. 322 will be ignored.
323 */ 323 */
324 324
325 int (*set_crop)(struct sn9c102_device* cam, 325 int (*set_crop)(struct sn9c102_device* cam,
326 const struct v4l2_rect* rect); 326 const struct v4l2_rect* rect);
327 /* 327 /*
328 To be called on VIDIOC_C_SETCROP. The core module always calls a 328 To be called on VIDIOC_C_SETCROP. The core module always calls a
329 default routine which configures the appropriate SN9C10X regs (also 329 default routine which configures the appropriate SN9C10X regs (also
@@ -332,12 +332,12 @@ struct sn9c102_sensor {
332 case you override the default function, you always have to program 332 case you override the default function, you always have to program
333 the chip to match those values; on error return the corresponding 333 the chip to match those values; on error return the corresponding
334 error code without rolling back. 334 error code without rolling back.
335 NOTE: in case, you must program the SN9C10X chip to get rid of 335 NOTE: in case, you must program the SN9C10X chip to get rid of
336 blank pixels or blank lines at the _start_ of each line or 336 blank pixels or blank lines at the _start_ of each line or
337 frame after each HSYNC or VSYNC, so that the image starts with 337 frame after each HSYNC or VSYNC, so that the image starts with
338 real RGB data (see regs 0x12, 0x13) (having set H_SIZE and, 338 real RGB data (see regs 0x12, 0x13) (having set H_SIZE and,
339 V_SIZE you don't have to care about blank pixels or blank 339 V_SIZE you don't have to care about blank pixels or blank
340 lines at the end of each line or frame). 340 lines at the end of each line or frame).
341 */ 341 */
342 342
343 struct v4l2_pix_format pix_format; 343 struct v4l2_pix_format pix_format;
@@ -349,17 +349,17 @@ struct sn9c102_sensor {
349 number of bits per pixel for uncompressed video, 8 or 9 (despite the 349 number of bits per pixel for uncompressed video, 8 or 9 (despite the
350 current value of 'pixelformat'). 350 current value of 'pixelformat').
351 NOTE 1: both 'width' and 'height' _must_ be either 1/1 or 1/2 or 1/4 351 NOTE 1: both 'width' and 'height' _must_ be either 1/1 or 1/2 or 1/4
352 of cropcap.defrect.width and cropcap.defrect.height. I 352 of cropcap.defrect.width and cropcap.defrect.height. I
353 suggest 1/1. 353 suggest 1/1.
354 NOTE 2: The initial compression quality is defined by the first bit 354 NOTE 2: The initial compression quality is defined by the first bit
355 of reg 0x17 during the initialization of the image sensor. 355 of reg 0x17 during the initialization of the image sensor.
356 NOTE 3: as said above, you have to program the SN9C10X chip to get 356 NOTE 3: as said above, you have to program the SN9C10X chip to get
357 rid of any blank pixels, so that the output of the sensor 357 rid of any blank pixels, so that the output of the sensor
358 matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR). 358 matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR).
359 */ 359 */
360 360
361 int (*set_pix_format)(struct sn9c102_device* cam, 361 int (*set_pix_format)(struct sn9c102_device* cam,
362 const struct v4l2_pix_format* pix); 362 const struct v4l2_pix_format* pix);
363 /* 363 /*
364 To be called on VIDIOC_S_FMT, when switching from the SBGGR8 to 364 To be called on VIDIOC_S_FMT, when switching from the SBGGR8 to
365 SN9C10X pixel format or viceversa. On error return the corresponding 365 SN9C10X pixel format or viceversa. On error return the corresponding
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
index 2e08c552f40a..294eb02fbd88 100644
--- a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
@@ -44,8 +44,8 @@ static int tas5110c1b_init(struct sn9c102_device* cam)
44} 44}
45 45
46 46
47static int tas5110c1b_set_ctrl(struct sn9c102_device* cam, 47static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
48 const struct v4l2_control* ctrl) 48 const struct v4l2_control* ctrl)
49{ 49{
50 int err = 0; 50 int err = 0;
51 51
@@ -61,8 +61,8 @@ static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
61} 61}
62 62
63 63
64static int tas5110c1b_set_crop(struct sn9c102_device* cam, 64static int tas5110c1b_set_crop(struct sn9c102_device* cam,
65 const struct v4l2_rect* rect) 65 const struct v4l2_rect* rect)
66{ 66{
67 struct sn9c102_sensor* s = &tas5110c1b; 67 struct sn9c102_sensor* s = &tas5110c1b;
68 int err = 0; 68 int err = 0;
@@ -81,8 +81,8 @@ static int tas5110c1b_set_crop(struct sn9c102_device* cam,
81} 81}
82 82
83 83
84static int tas5110c1b_set_pix_format(struct sn9c102_device* cam, 84static int tas5110c1b_set_pix_format(struct sn9c102_device* cam,
85 const struct v4l2_pix_format* pix) 85 const struct v4l2_pix_format* pix)
86{ 86{
87 int err = 0; 87 int err = 0;
88 88
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
index c7b339740bbf..9ecb09032b68 100644
--- a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
@@ -42,8 +42,8 @@ static int tas5130d1b_init(struct sn9c102_device* cam)
42} 42}
43 43
44 44
45static int tas5130d1b_set_ctrl(struct sn9c102_device* cam, 45static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
46 const struct v4l2_control* ctrl) 46 const struct v4l2_control* ctrl)
47{ 47{
48 int err = 0; 48 int err = 0;
49 49
@@ -62,8 +62,8 @@ static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
62} 62}
63 63
64 64
65static int tas5130d1b_set_crop(struct sn9c102_device* cam, 65static int tas5130d1b_set_crop(struct sn9c102_device* cam,
66 const struct v4l2_rect* rect) 66 const struct v4l2_rect* rect)
67{ 67{
68 struct sn9c102_sensor* s = &tas5130d1b; 68 struct sn9c102_sensor* s = &tas5130d1b;
69 u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 104, 69 u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 104,
@@ -82,8 +82,8 @@ static int tas5130d1b_set_crop(struct sn9c102_device* cam,
82} 82}
83 83
84 84
85static int tas5130d1b_set_pix_format(struct sn9c102_device* cam, 85static int tas5130d1b_set_pix_format(struct sn9c102_device* cam,
86 const struct v4l2_pix_format* pix) 86 const struct v4l2_pix_format* pix)
87{ 87{
88 int err = 0; 88 int err = 0;
89 89
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index 9d769264a329..07476c71174a 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * stradis.c - stradis 4:2:2 mpeg decoder driver 2 * stradis.c - stradis 4:2:2 mpeg decoder driver
3 * 3 *
4 * Stradis 4:2:2 MPEG-2 Decoder Driver 4 * Stradis 4:2:2 MPEG-2 Decoder Driver
@@ -1191,9 +1191,9 @@ static void saa7146_set_winsize(struct saa7146 *saa)
1191} 1191}
1192 1192
1193/* clip_draw_rectangle(cm,x,y,w,h) -- handle clipping an area 1193/* clip_draw_rectangle(cm,x,y,w,h) -- handle clipping an area
1194 * bitmap is fixed width, 128 bytes (1024 pixels represented) 1194 * bitmap is fixed width, 128 bytes (1024 pixels represented)
1195 * arranged most-sigificant-bit-left in 32-bit words 1195 * arranged most-sigificant-bit-left in 32-bit words
1196 * based on saa7146 clipping hardware, it swaps bytes if LE 1196 * based on saa7146 clipping hardware, it swaps bytes if LE
1197 * much of this makes up for egcs brain damage -- so if you 1197 * much of this makes up for egcs brain damage -- so if you
1198 * are wondering "why did he do this?" it is because the C 1198 * are wondering "why did he do this?" it is because the C
1199 * was adjusted to generate the optimal asm output without 1199 * was adjusted to generate the optimal asm output without
@@ -1259,7 +1259,7 @@ static void make_clip_tab(struct saa7146 *saa, struct video_clip *cr, int ncr)
1259 clip_draw_rectangle(clipmap, cr[i].x, cr[i].y, 1259 clip_draw_rectangle(clipmap, cr[i].x, cr[i].y,
1260 cr[i].width, cr[i].height); 1260 cr[i].width, cr[i].height);
1261 } 1261 }
1262 /* clip against viewing window AND screen 1262 /* clip against viewing window AND screen
1263 so we do not have to rely on the user program 1263 so we do not have to rely on the user program
1264 */ 1264 */
1265 clip_draw_rectangle(clipmap, (saa->win.x + width > saa->win.swidth) ? 1265 clip_draw_rectangle(clipmap, (saa->win.x + width > saa->win.swidth) ?
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index 9636da20748d..b38bda83a7c5 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -1,16 +1,16 @@
1/* 1/*
2 * STV0680 USB Camera Driver, by Kevin Sisson (kjsisson@bellsouth.net) 2 * STV0680 USB Camera Driver, by Kevin Sisson (kjsisson@bellsouth.net)
3 * 3 *
4 * Thanks to STMicroelectronics for information on the usb commands, and 4 * Thanks to STMicroelectronics for information on the usb commands, and
5 * to Steve Miller at STM for his help and encouragement while I was 5 * to Steve Miller at STM for his help and encouragement while I was
6 * writing this driver. 6 * writing this driver.
7 * 7 *
8 * This driver is based heavily on the 8 * This driver is based heavily on the
9 * Endpoints (formerly known as AOX) se401 USB Camera Driver 9 * Endpoints (formerly known as AOX) se401 USB Camera Driver
10 * Copyright (c) 2000 Jeroen B. Vreeken (pe1rxq@amsat.org) 10 * Copyright (c) 2000 Jeroen B. Vreeken (pe1rxq@amsat.org)
11 * 11 *
12 * Still somewhat based on the Linux ov511 driver. 12 * Still somewhat based on the Linux ov511 driver.
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify it 14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the 15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your 16 * Free Software Foundation; either version 2 of the License, or (at your
@@ -25,18 +25,18 @@
25 * along with this program; if not, write to the Free Software Foundation, 25 * along with this program; if not, write to the Free Software Foundation,
26 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 * 27 *
28 * History: 28 * History:
29 * ver 0.1 October, 2001. Initial attempt. 29 * ver 0.1 October, 2001. Initial attempt.
30 * 30 *
31 * ver 0.2 November, 2001. Fixed asbility to resize, added brightness 31 * ver 0.2 November, 2001. Fixed asbility to resize, added brightness
32 * function, made more stable (?) 32 * function, made more stable (?)
33 * 33 *
34 * ver 0.21 Nov, 2001. Added gamma correction and white balance, 34 * ver 0.21 Nov, 2001. Added gamma correction and white balance,
35 * due to Alexander Schwartz. Still trying to 35 * due to Alexander Schwartz. Still trying to
36 * improve stablility. Moved stuff into stv680.h 36 * improve stablility. Moved stuff into stv680.h
37 * 37 *
38 * ver 0.22 Nov, 2001. Added sharpen function (by Michael Sweet, 38 * ver 0.22 Nov, 2001. Added sharpen function (by Michael Sweet,
39 * mike@easysw.com) from GIMP, also used in pencam. 39 * mike@easysw.com) from GIMP, also used in pencam.
40 * Simple, fast, good integer math routine. 40 * Simple, fast, good integer math routine.
41 * 41 *
42 * ver 0.23 Dec, 2001 (gkh) 42 * ver 0.23 Dec, 2001 (gkh)
@@ -44,11 +44,11 @@
44 * Lindent, and did other minor tweaks to get 44 * Lindent, and did other minor tweaks to get
45 * things to work properly with 2.5.1 45 * things to work properly with 2.5.1
46 * 46 *
47 * ver 0.24 Jan, 2002 (kjs) 47 * ver 0.24 Jan, 2002 (kjs)
48 * Fixed the problem with webcam crashing after 48 * Fixed the problem with webcam crashing after
49 * two pictures. Changed the way pic is halved to 49 * two pictures. Changed the way pic is halved to
50 * improve quality. Got rid of green line around 50 * improve quality. Got rid of green line around
51 * frame. Fix brightness reset when changing size 51 * frame. Fix brightness reset when changing size
52 * bug. Adjusted gamma filters slightly. 52 * bug. Adjusted gamma filters slightly.
53 * 53 *
54 * ver 0.25 Jan, 2002 (kjs) 54 * ver 0.25 Jan, 2002 (kjs)
@@ -484,7 +484,7 @@ exit:
484 PDEBUG (1, "STV(i): swapRGB is (forced) ON"); 484 PDEBUG (1, "STV(i): swapRGB is (forced) ON");
485 else if (swapRGB_on == -1) 485 else if (swapRGB_on == -1)
486 PDEBUG (1, "STV(i): swapRGB is (forced) OFF"); 486 PDEBUG (1, "STV(i): swapRGB is (forced) OFF");
487 487
488 if (stv_set_video_mode (stv680) < 0) { 488 if (stv_set_video_mode (stv680) < 0) {
489 PDEBUG (0, "STV(e): Could not set video mode in stv_init"); 489 PDEBUG (0, "STV(e): Could not set video mode in stv_init");
490 return -1; 490 return -1;
@@ -570,7 +570,7 @@ static int stv680_set_pict (struct usb_stv *stv680, struct video_picture *p)
570 if (stv680->brightness != p->brightness) { 570 if (stv680->brightness != p->brightness) {
571 stv680->chgbright = 1; 571 stv680->chgbright = 1;
572 stv680->brightness = p->brightness; 572 stv680->brightness = p->brightness;
573 } 573 }
574 574
575 stv680->whiteness = p->whiteness; /* greyscale */ 575 stv680->whiteness = p->whiteness; /* greyscale */
576 stv680->colour = p->colour; 576 stv680->colour = p->colour;
@@ -612,7 +612,7 @@ static void stv680_video_irq (struct urb *urb, struct pt_regs *regs)
612 612
613 case BUFFER_UNUSED: 613 case BUFFER_UNUSED:
614 memcpy (stv680->scratch[stv680->scratch_next].data, 614 memcpy (stv680->scratch[stv680->scratch_next].data,
615 (unsigned char *) urb->transfer_buffer, length); 615 (unsigned char *) urb->transfer_buffer, length);
616 stv680->scratch[stv680->scratch_next].state = BUFFER_READY; 616 stv680->scratch[stv680->scratch_next].state = BUFFER_READY;
617 stv680->scratch[stv680->scratch_next].length = length; 617 stv680->scratch[stv680->scratch_next].length = length;
618 if (waitqueue_active (&stv680->wq)) { 618 if (waitqueue_active (&stv680->wq)) {
@@ -752,7 +752,7 @@ static int stv680_set_size (struct usb_stv *stv680, int width, int height)
752 PDEBUG (1, "STV(e): request for non-supported size: request: v.width = %i, v.height = %i actual: stv.width = %i, stv.height = %i", width, height, stv680->vwidth, stv680->vheight); 752 PDEBUG (1, "STV(e): request for non-supported size: request: v.width = %i, v.height = %i actual: stv.width = %i, stv.height = %i", width, height, stv680->vwidth, stv680->vheight);
753 return 1; 753 return 1;
754 } 754 }
755 755
756 /* Stop a current stream and start it again at the new size */ 756 /* Stop a current stream and start it again at the new size */
757 if (wasstreaming) 757 if (wasstreaming)
758 stv680_stop_stream (stv680); 758 stv680_stop_stream (stv680);
@@ -773,7 +773,7 @@ static int stv680_set_size (struct usb_stv *stv680, int width, int height)
773 773
774/* 774/*
775 * STV0680 Vision Camera Chipset Driver 775 * STV0680 Vision Camera Chipset Driver
776 * Copyright (C) 2000 Adam Harrison <adam@antispin.org> 776 * Copyright (C) 2000 Adam Harrison <adam@antispin.org>
777*/ 777*/
778 778
779#define RED 0 779#define RED 0
@@ -842,7 +842,7 @@ static void bayer_unshuffle (struct usb_stv *stv680, struct stv680_scratch *buff
842 colour = 2; 842 colour = 2;
843 break; 843 break;
844 } 844 }
845 i = (y * vw + x) * 3; 845 i = (y * vw + x) * 3;
846 *(output + i + colour) = (unsigned char) p; 846 *(output + i + colour) = (unsigned char) p;
847 } /* for x */ 847 } /* for x */
848 848
@@ -850,9 +850,9 @@ static void bayer_unshuffle (struct usb_stv *stv680, struct stv680_scratch *buff
850 850
851 /****** gamma correction plus hardcoded white balance */ 851 /****** gamma correction plus hardcoded white balance */
852 /* Thanks to Alexander Schwartx <alexander.schwartx@gmx.net> for this code. 852 /* Thanks to Alexander Schwartx <alexander.schwartx@gmx.net> for this code.
853 Correction values red[], green[], blue[], are generated by 853 Correction values red[], green[], blue[], are generated by
854 (pow(i/256.0, GAMMA)*255.0)*white balanceRGB where GAMMA=0.55, 1<i<255. 854 (pow(i/256.0, GAMMA)*255.0)*white balanceRGB where GAMMA=0.55, 1<i<255.
855 White balance (RGB)= 1.0, 1.17, 1.48. Values are calculated as double float and 855 White balance (RGB)= 1.0, 1.17, 1.48. Values are calculated as double float and
856 converted to unsigned char. Values are in stv680.h */ 856 converted to unsigned char. Values are in stv680.h */
857 857
858 for (y = 0; y < vh; y++) { 858 for (y = 0; y < vh; y++) {
diff --git a/drivers/media/video/stv680.h b/drivers/media/video/stv680.h
index ea46e0001e6d..a08f1b08a4b0 100644
--- a/drivers/media/video/stv680.h
+++ b/drivers/media/video/stv680.h
@@ -9,12 +9,12 @@
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -152,76 +152,76 @@ struct usb_stv {
152 152
153 153
154static const unsigned char red[256] = { 154static const unsigned char red[256] = {
155 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 155 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
156 18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42, 156 18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42,
157 44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69, 157 44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69,
158 71, 71, 73, 75, 77, 78, 80, 81, 82, 84, 85, 87, 158 71, 71, 73, 75, 77, 78, 80, 81, 82, 84, 85, 87,
159 88, 89, 90, 91, 93, 94, 95, 97, 98, 98, 99, 101, 159 88, 89, 90, 91, 93, 94, 95, 97, 98, 98, 99, 101,
160 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 160 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
161 114, 115, 116, 116, 117, 118, 119, 120, 121, 122, 123, 124, 161 114, 115, 116, 116, 117, 118, 119, 120, 121, 122, 123, 124,
162 125, 125, 126, 127, 128, 129, 129, 130, 131, 132, 133, 134, 162 125, 125, 126, 127, 128, 129, 129, 130, 131, 132, 133, 134,
163 134, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143, 163 134, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143,
164 143, 143, 144, 145, 146, 147, 147, 148, 149, 150, 150, 151, 164 143, 143, 144, 145, 146, 147, 147, 148, 149, 150, 150, 151,
165 152, 152, 152, 153, 154, 154, 155, 156, 157, 157, 158, 159, 165 152, 152, 152, 153, 154, 154, 155, 156, 157, 157, 158, 159,
166 159, 160, 161, 161, 161, 162, 163, 163, 164, 165, 165, 166, 166 159, 160, 161, 161, 161, 162, 163, 163, 164, 165, 165, 166,
167 167, 167, 168, 168, 169, 170, 170, 170, 171, 171, 172, 173, 167 167, 167, 168, 168, 169, 170, 170, 170, 171, 171, 172, 173,
168 173, 174, 174, 175, 176, 176, 177, 178, 178, 179, 179, 179, 168 173, 174, 174, 175, 176, 176, 177, 178, 178, 179, 179, 179,
169 180, 180, 181, 181, 182, 183, 183, 184, 184, 185, 185, 186, 169 180, 180, 181, 181, 182, 183, 183, 184, 184, 185, 185, 186,
170 187, 187, 188, 188, 188, 188, 189, 190, 190, 191, 191, 192, 170 187, 187, 188, 188, 188, 188, 189, 190, 190, 191, 191, 192,
171 192, 193, 193, 194, 195, 195, 196, 196, 197, 197, 197, 197, 171 192, 193, 193, 194, 195, 195, 196, 196, 197, 197, 197, 197,
172 198, 198, 199, 199, 200, 201, 201, 202, 202, 203, 203, 204, 172 198, 198, 199, 199, 200, 201, 201, 202, 202, 203, 203, 204,
173 204, 205, 205, 206, 206, 206, 206, 207, 207, 208, 208, 209, 173 204, 205, 205, 206, 206, 206, 206, 207, 207, 208, 208, 209,
174 209, 210, 210, 211, 211, 212, 212, 213, 213, 214, 214, 215, 174 209, 210, 210, 211, 211, 212, 212, 213, 213, 214, 214, 215,
175 215, 215, 215, 216, 216, 217, 217, 218, 218, 218, 219, 219, 175 215, 215, 215, 216, 216, 217, 217, 218, 218, 218, 219, 219,
176 220, 220, 221, 221 176 220, 220, 221, 221
177}; 177};
178 178
179static const unsigned char green[256] = { 179static const unsigned char green[256] = {
180 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 180 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
181 21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47, 181 21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47,
182 50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77, 182 50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77,
183 79, 80, 82, 84, 86, 87, 89, 91, 92, 94, 95, 97, 183 79, 80, 82, 84, 86, 87, 89, 91, 92, 94, 95, 97,
184 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 111, 113, 184 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 111, 113,
185 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 185 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126,
186 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 186 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
187 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149, 187 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149,
188 150, 151, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159, 188 150, 151, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159,
189 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168, 189 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168,
190 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177, 190 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177,
191 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185, 191 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185,
192 186, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193, 192 186, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193,
193 193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200, 193 193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200,
194 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206, 207, 194 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206, 207,
195 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 195 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214,
196 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220, 196 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220,
197 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227, 197 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,
198 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, 198 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233,
199 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, 199 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239,
200 239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244, 200 239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244,
201 245, 245, 246, 246 201 245, 245, 246, 246
202}; 202};
203 203
204static const unsigned char blue[256] = { 204static const unsigned char blue[256] = {
205 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 205 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
206 23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51, 206 23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51,
207 55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84, 207 55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84,
208 86, 88, 90, 92, 94, 95, 97, 100, 101, 103, 104, 106, 208 86, 88, 90, 92, 94, 95, 97, 100, 101, 103, 104, 106,
209 107, 110, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124, 209 107, 110, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124,
210 125, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138, 210 125, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138,
211 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151, 211 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151,
212 152, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163, 212 152, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163,
213 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 213 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174,
214 176, 176, 177, 178, 179, 180, 180, 181, 182, 183, 183, 184, 214 176, 176, 177, 178, 179, 180, 180, 181, 182, 183, 183, 184,
215 185, 187, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194, 215 185, 187, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194,
216 194, 195, 196, 196, 198, 199, 200, 200, 201, 202, 202, 203, 216 194, 195, 196, 196, 198, 199, 200, 200, 201, 202, 202, 203,
217 204, 204, 205, 205, 206, 207, 207, 209, 210, 210, 211, 212, 217 204, 204, 205, 205, 206, 207, 207, 209, 210, 210, 211, 212,
218 212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 218, 220, 218 212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 218, 220,
219 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227, 219 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,
220 228, 228, 229, 229, 231, 231, 232, 233, 233, 234, 234, 235, 220 228, 228, 229, 229, 231, 231, 232, 233, 233, 234, 234, 235,
221 235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 242, 242, 221 235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 242, 242,
222 243, 243, 244, 244, 245, 246, 246, 247, 247, 248, 248, 249, 222 243, 243, 244, 244, 245, 246, 246, 247, 247, 248, 248, 249,
223 249, 250, 250, 251, 251, 253, 253, 254, 254, 255, 255, 255, 223 249, 250, 250, 251, 251, 253, 253, 254, 254, 255, 255, 255,
224 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 224 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
225 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 225 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
226 255, 255, 255, 255 226 255, 255, 255, 255
227}; 227};
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index 56e08e156cf0..ef494febb5e4 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -35,7 +35,7 @@ static int debug = 0; /* insmod parameter */
35module_param(debug, int, 0644); 35module_param(debug, int, 0644);
36MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); 36MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
37#define dprintk(args...) \ 37#define dprintk(args...) \
38 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) 38 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
39 39
40#define SWITCH 0x00 40#define SWITCH 0x00
41#define LEVEL_ADJUST 0x02 41#define LEVEL_ADJUST 0x02
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index 774ed0dbc56d..523df0b8cc63 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -37,7 +37,7 @@ static int debug = 0; /* insmod parameter */
37module_param(debug, int, 0644); 37module_param(debug, int, 0644);
38MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); 38MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
39#define dprintk(args...) \ 39#define dprintk(args...) \
40 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) 40 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
41 41
42#define TEA6415C_NUM_INPUTS 8 42#define TEA6415C_NUM_INPUTS 8
43#define TEA6415C_NUM_OUTPUTS 6 43#define TEA6415C_NUM_OUTPUTS 6
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index b4263b630712..e0ff811fab6f 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -37,7 +37,7 @@ static int debug = 0; /* insmod parameter */
37module_param(debug, int, 0644); 37module_param(debug, int, 0644);
38MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); 38MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
39#define dprintk(args...) \ 39#define dprintk(args...) \
40 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) 40 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
41 41
42/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ 42/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */
43static unsigned short normal_i2c[] = { I2C_ADDR_TEA6420_1, I2C_ADDR_TEA6420_2, I2C_CLIENT_END }; 43static unsigned short normal_i2c[] = { I2C_ADDR_TEA6420_1, I2C_ADDR_TEA6420_2, I2C_CLIENT_END };
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index c4a78e7a5a58..74ab48c09c6a 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * The SAB3036 is just about different enough from the chips that 6 * The SAB3036 is just about different enough from the chips that
7 * tuner.c copes with to make it not worth the effort to crowbar 7 * tuner.c copes with to make it not worth the effort to crowbar
8 * the support into that file. So instead we have a separate driver. 8 * the support into that file. So instead we have a separate driver.
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
@@ -56,15 +56,15 @@ tuner_getstatus (struct i2c_client *c)
56 56
57#define TUNER_FL 0x80 57#define TUNER_FL 0x80
58 58
59static int 59static int
60tuner_islocked (struct i2c_client *c) 60tuner_islocked (struct i2c_client *c)
61{ 61{
62 return (tuner_getstatus(c) & TUNER_FL); 62 return (tuner_getstatus(c) & TUNER_FL);
63} 63}
64 64
65/* ---------------------------------------------------------------------- */ 65/* ---------------------------------------------------------------------- */
66 66
67static void 67static void
68set_tv_freq(struct i2c_client *c, int freq) 68set_tv_freq(struct i2c_client *c, int freq)
69{ 69{
70 u16 div = ((freq * 20) / 16); 70 u16 div = ((freq * 20) / 16);
@@ -73,26 +73,26 @@ set_tv_freq(struct i2c_client *c, int freq)
73 73
74 if (debug) 74 if (debug)
75 printk(KERN_DEBUG "tuner: setting frequency %dMHz, divisor %x\n", freq / 16, div); 75 printk(KERN_DEBUG "tuner: setting frequency %dMHz, divisor %x\n", freq / 16, div);
76 76
77 /* Select high tuning current */ 77 /* Select high tuning current */
78 buffer[0] = 0x29; 78 buffer[0] = 0x29;
79 buffer[1] = 0x3e; 79 buffer[1] = 0x3e;
80 80
81 if (i2c_master_send(c, buffer, 2) != 2) 81 if (i2c_master_send(c, buffer, 2) != 2)
82 printk("tuner: i2c i/o error 1\n"); 82 printk("tuner: i2c i/o error 1\n");
83 83
84 buffer[0] = 0x80 | ((div>>8) & 0x7f); 84 buffer[0] = 0x80 | ((div>>8) & 0x7f);
85 buffer[1] = div & 0xff; 85 buffer[1] = div & 0xff;
86 86
87 if (i2c_master_send(c, buffer, 2) != 2) 87 if (i2c_master_send(c, buffer, 2) != 2)
88 printk("tuner: i2c i/o error 2\n"); 88 printk("tuner: i2c i/o error 2\n");
89 89
90 while (!tuner_islocked(c) && time_before(jiffies, give_up)) 90 while (!tuner_islocked(c) && time_before(jiffies, give_up))
91 schedule(); 91 schedule();
92 92
93 if (!tuner_islocked(c)) 93 if (!tuner_islocked(c))
94 printk(KERN_WARNING "tuner: failed to achieve PLL lock\n"); 94 printk(KERN_WARNING "tuner: failed to achieve PLL lock\n");
95 95
96 /* Select low tuning current and engage AFC */ 96 /* Select low tuning current and engage AFC */
97 buffer[0] = 0x29; 97 buffer[0] = 0x29;
98 buffer[1] = 0xb2; 98 buffer[1] = 0xb2;
@@ -106,7 +106,7 @@ set_tv_freq(struct i2c_client *c, int freq)
106 106
107/* ---------------------------------------------------------------------- */ 107/* ---------------------------------------------------------------------- */
108 108
109static int 109static int
110tuner_attach(struct i2c_adapter *adap, int addr, int kind) 110tuner_attach(struct i2c_adapter *adap, int addr, int kind)
111{ 111{
112 static unsigned char buffer[] = { 0x29, 0x32, 0x2a, 0, 0x2b, 0 }; 112 static unsigned char buffer[] = { 0x29, 0x32, 0x2a, 0, 0x2b, 0 };
@@ -116,18 +116,18 @@ tuner_attach(struct i2c_adapter *adap, int addr, int kind)
116 if (this_adap > 0) 116 if (this_adap > 0)
117 return -1; 117 return -1;
118 this_adap++; 118 this_adap++;
119 119
120 client_template.adapter = adap; 120 client_template.adapter = adap;
121 client_template.addr = addr; 121 client_template.addr = addr;
122 122
123 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 123 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
124 if (client == NULL) 124 if (client == NULL)
125 return -ENOMEM; 125 return -ENOMEM;
126 memcpy(client, &client_template, sizeof(struct i2c_client)); 126 memcpy(client, &client_template, sizeof(struct i2c_client));
127 127
128 printk("tuner: SAB3036 found, status %02x\n", tuner_getstatus(client)); 128 printk("tuner: SAB3036 found, status %02x\n", tuner_getstatus(client));
129 129
130 i2c_attach_client(client); 130 i2c_attach_client(client);
131 131
132 if (i2c_master_send(client, buffer, 2) != 2) 132 if (i2c_master_send(client, buffer, 2) != 2)
133 printk("tuner: i2c i/o error 1\n"); 133 printk("tuner: i2c i/o error 1\n");
@@ -138,30 +138,30 @@ tuner_attach(struct i2c_adapter *adap, int addr, int kind)
138 return 0; 138 return 0;
139} 139}
140 140
141static int 141static int
142tuner_detach(struct i2c_client *c) 142tuner_detach(struct i2c_client *c)
143{ 143{
144 return 0; 144 return 0;
145} 145}
146 146
147static int 147static int
148tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) 148tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
149{ 149{
150 int *iarg = (int*)arg; 150 int *iarg = (int*)arg;
151 151
152 switch (cmd) 152 switch (cmd)
153 { 153 {
154 case VIDIOCSFREQ: 154 case VIDIOCSFREQ:
155 set_tv_freq(client, *iarg); 155 set_tv_freq(client, *iarg);
156 break; 156 break;
157 157
158 default: 158 default:
159 return -EINVAL; 159 return -EINVAL;
160 } 160 }
161 return 0; 161 return 0;
162} 162}
163 163
164static int 164static int
165tuner_probe(struct i2c_adapter *adap) 165tuner_probe(struct i2c_adapter *adap)
166{ 166{
167 this_adap = 0; 167 this_adap = 0;
@@ -172,8 +172,8 @@ tuner_probe(struct i2c_adapter *adap)
172 172
173/* ----------------------------------------------------------------------- */ 173/* ----------------------------------------------------------------------- */
174 174
175static struct i2c_driver 175static struct i2c_driver
176i2c_driver_tuner = 176i2c_driver_tuner =
177{ 177{
178 .driver = { 178 .driver = {
179 .name = "sab3036", 179 .name = "sab3036",
@@ -186,7 +186,7 @@ i2c_driver_tuner =
186 186
187static struct i2c_client client_template = 187static struct i2c_client client_template =
188{ 188{
189 .driver = &i2c_driver_tuner, 189 .driver = &i2c_driver_tuner,
190 .name = "SAB3036", 190 .name = "SAB3036",
191}; 191};
192 192
diff --git a/drivers/media/video/usbvideo/ibmcam.c b/drivers/media/video/usbvideo/ibmcam.c
index a42c22294124..76f771b6a32f 100644
--- a/drivers/media/video/usbvideo/ibmcam.c
+++ b/drivers/media/video/usbvideo/ibmcam.c
@@ -1300,11 +1300,11 @@ static void ibmcam_model2_Packet1(struct uvd *uvd, unsigned short v1, unsigned s
1300/* 1300/*
1301 * ibmcam_model3_Packet1() 1301 * ibmcam_model3_Packet1()
1302 * 1302 *
1303 * 00_0078_012d 1303 * 00_0078_012d
1304 * 00_0097_012f 1304 * 00_0097_012f
1305 * 00_d141_0124 1305 * 00_d141_0124
1306 * 00_0096_0127 1306 * 00_0096_0127
1307 * 00_fea8_0124 1307 * 00_fea8_0124
1308*/ 1308*/
1309static void ibmcam_model3_Packet1(struct uvd *uvd, unsigned short v1, unsigned short v2) 1309static void ibmcam_model3_Packet1(struct uvd *uvd, unsigned short v1, unsigned short v2)
1310{ 1310{
@@ -2687,7 +2687,7 @@ static void ibmcam_model4_setup_after_video_if(struct uvd *uvd)
2687 ibmcam_veio(uvd, 0, 0x0004, 0x0127); 2687 ibmcam_veio(uvd, 0, 0x0004, 0x0127);
2688 ibmcam_veio(uvd, 0, 0xfea8, 0x0124); 2688 ibmcam_veio(uvd, 0, 0xfea8, 0x0124);
2689 ibmcam_veio(uvd, 0, 0x00c0, 0x010c); 2689 ibmcam_veio(uvd, 0, 0x00c0, 0x010c);
2690 break; 2690 break;
2691 } 2691 }
2692 usb_clear_halt(uvd->dev, usb_rcvisocpipe(uvd->dev, uvd->video_endp)); 2692 usb_clear_halt(uvd->dev, usb_rcvisocpipe(uvd->dev, uvd->video_endp));
2693} 2693}
@@ -3238,7 +3238,7 @@ static void ibmcam_model3_setup_after_video_if(struct uvd *uvd)
3238 {0, 0x0062, 0x0107}, 3238 {0, 0x0062, 0x0107},
3239 {0, 0x0003, 0x0111}, 3239 {0, 0x0003, 0x0111},
3240 }; 3240 };
3241#define NUM_INIT_DATA 3241#define NUM_INIT_DATA
3242 3242
3243 unsigned short compression = 0; /* 0=none, 7=best frame rate */ 3243 unsigned short compression = 0; /* 0=none, 7=best frame rate */
3244 int f_rate; /* 0=Fastest 7=slowest */ 3244 int f_rate; /* 0=Fastest 7=slowest */
diff --git a/drivers/media/video/usbvideo/konicawc.c b/drivers/media/video/usbvideo/konicawc.c
index e2ede583518f..c11f5d46b114 100644
--- a/drivers/media/video/usbvideo/konicawc.c
+++ b/drivers/media/video/usbvideo/konicawc.c
@@ -36,7 +36,7 @@
36enum ctrl_req { 36enum ctrl_req {
37 SetWhitebal = 0x01, 37 SetWhitebal = 0x01,
38 SetBrightness = 0x02, 38 SetBrightness = 0x02,
39 SetSharpness = 0x03, 39 SetSharpness = 0x03,
40 SetContrast = 0x04, 40 SetContrast = 0x04,
41 SetSaturation = 0x05, 41 SetSaturation = 0x05,
42}; 42};
@@ -47,7 +47,7 @@ enum frame_sizes {
47 SIZE_160X136 = 1, 47 SIZE_160X136 = 1,
48 SIZE_176X144 = 2, 48 SIZE_176X144 = 2,
49 SIZE_320X240 = 3, 49 SIZE_320X240 = 3,
50 50
51}; 51};
52 52
53#define MAX_FRAME_SIZE SIZE_320X240 53#define MAX_FRAME_SIZE SIZE_320X240
@@ -69,7 +69,7 @@ static const int debug = 0;
69/* Some default values for initial camera settings, 69/* Some default values for initial camera settings,
70 can be set by modprobe */ 70 can be set by modprobe */
71 71
72static int size; 72static int size;
73static int speed = 6; /* Speed (fps) 0 (slowest) to 6 (fastest) */ 73static int speed = 6; /* Speed (fps) 0 (slowest) to 6 (fastest) */
74static int brightness = MAX_BRIGHTNESS/2; 74static int brightness = MAX_BRIGHTNESS/2;
75static int contrast = MAX_CONTRAST/2; 75static int contrast = MAX_CONTRAST/2;
@@ -132,24 +132,24 @@ struct konicawc {
132 132
133static int konicawc_ctrl_msg(struct uvd *uvd, u8 dir, u8 request, u16 value, u16 index, void *buf, int len) 133static int konicawc_ctrl_msg(struct uvd *uvd, u8 dir, u8 request, u16 value, u16 index, void *buf, int len)
134{ 134{
135 int retval = usb_control_msg(uvd->dev, 135 int retval = usb_control_msg(uvd->dev,
136 dir ? usb_rcvctrlpipe(uvd->dev, 0) : usb_sndctrlpipe(uvd->dev, 0), 136 dir ? usb_rcvctrlpipe(uvd->dev, 0) : usb_sndctrlpipe(uvd->dev, 0),
137 request, 0x40 | dir, value, index, buf, len, 1000); 137 request, 0x40 | dir, value, index, buf, len, 1000);
138 return retval < 0 ? retval : 0; 138 return retval < 0 ? retval : 0;
139} 139}
140 140
141 141
142static inline void konicawc_camera_on(struct uvd *uvd) 142static inline void konicawc_camera_on(struct uvd *uvd)
143{ 143{
144 DEBUG(0, "camera on"); 144 DEBUG(0, "camera on");
145 konicawc_set_misc(uvd, 0x2, 1, 0x0b); 145 konicawc_set_misc(uvd, 0x2, 1, 0x0b);
146} 146}
147 147
148 148
149static inline void konicawc_camera_off(struct uvd *uvd) 149static inline void konicawc_camera_off(struct uvd *uvd)
150{ 150{
151 DEBUG(0, "camera off"); 151 DEBUG(0, "camera off");
152 konicawc_set_misc(uvd, 0x2, 0, 0x0b); 152 konicawc_set_misc(uvd, 0x2, 0, 0x0b);
153} 153}
154 154
155 155
@@ -317,7 +317,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
317 button = !!(sts & 0x40); 317 button = !!(sts & 0x40);
318 sts &= ~0x40; 318 sts &= ~0x40;
319 } 319 }
320 320
321 /* work out the button status, but don't do 321 /* work out the button status, but don't do
322 anything with it for now */ 322 anything with it for now */
323 323
@@ -331,7 +331,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
331 discard++; 331 discard++;
332 continue; 332 continue;
333 } 333 }
334 334
335 if((sts > 0x01) && (sts < 0x80)) { 335 if((sts > 0x01) && (sts < 0x80)) {
336 info("unknown status %2.2x", sts); 336 info("unknown status %2.2x", sts);
337 bad++; 337 bad++;
@@ -350,7 +350,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
350 DEBUG(2, "found initial image"); 350 DEBUG(2, "found initial image");
351 cam->lastframe = -1; 351 cam->lastframe = -1;
352 } 352 }
353 353
354 marker[3] = sts & 0x7F; 354 marker[3] = sts & 0x7F;
355 RingQueue_Enqueue(&uvd->dp, marker, 4); 355 RingQueue_Enqueue(&uvd->dp, marker, 4);
356 totlen += 4; 356 totlen += 4;
@@ -367,16 +367,16 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
367 367
368static void resubmit_urb(struct uvd *uvd, struct urb *urb) 368static void resubmit_urb(struct uvd *uvd, struct urb *urb)
369{ 369{
370 int i, ret; 370 int i, ret;
371 for (i = 0; i < FRAMES_PER_DESC; i++) { 371 for (i = 0; i < FRAMES_PER_DESC; i++) {
372 urb->iso_frame_desc[i].status = 0; 372 urb->iso_frame_desc[i].status = 0;
373 } 373 }
374 urb->dev = uvd->dev; 374 urb->dev = uvd->dev;
375 urb->status = 0; 375 urb->status = 0;
376 ret = usb_submit_urb(urb, GFP_ATOMIC); 376 ret = usb_submit_urb(urb, GFP_ATOMIC);
377 DEBUG(3, "submitting urb of length %d", urb->transfer_buffer_length); 377 DEBUG(3, "submitting urb of length %d", urb->transfer_buffer_length);
378 if(ret) 378 if(ret)
379 err("usb_submit_urb error (%d)", ret); 379 err("usb_submit_urb error (%d)", ret);
380 380
381} 381}
382 382
@@ -490,7 +490,7 @@ static int konicawc_start_data(struct uvd *uvd)
490 } 490 }
491 491
492 cam->last_data_urb = NULL; 492 cam->last_data_urb = NULL;
493 493
494 /* Submit all URBs */ 494 /* Submit all URBs */
495 for (i=0; i < USBVIDEO_NUMSBUF; i++) { 495 for (i=0; i < USBVIDEO_NUMSBUF; i++) {
496 errFlag = usb_submit_urb(cam->sts_urb[i], GFP_KERNEL); 496 errFlag = usb_submit_urb(cam->sts_urb[i], GFP_KERNEL);
@@ -539,7 +539,7 @@ static void konicawc_stop_data(struct uvd *uvd)
539 539
540 540
541static void konicawc_process_isoc(struct uvd *uvd, struct usbvideo_frame *frame) 541static void konicawc_process_isoc(struct uvd *uvd, struct usbvideo_frame *frame)
542{ 542{
543 struct konicawc *cam = (struct konicawc *)uvd->user_data; 543 struct konicawc *cam = (struct konicawc *)uvd->user_data;
544 int maxline = cam->maxline; 544 int maxline = cam->maxline;
545 int yplanesz = cam->yplanesz; 545 int yplanesz = cam->yplanesz;
@@ -583,13 +583,13 @@ static void konicawc_process_isoc(struct uvd *uvd, struct usbvideo_frame *frame)
583 583
584 if(frame->scanstate == ScanState_Scanning) 584 if(frame->scanstate == ScanState_Scanning)
585 return; 585 return;
586 586
587 /* Try to move data from queue into frame buffer 587 /* Try to move data from queue into frame buffer
588 * We get data in blocks of 384 bytes made up of: 588 * We get data in blocks of 384 bytes made up of:
589 * 256 Y, 64 U, 64 V. 589 * 256 Y, 64 U, 64 V.
590 * This needs to be written out as a Y plane, a U plane and a V plane. 590 * This needs to be written out as a Y plane, a U plane and a V plane.
591 */ 591 */
592 592
593 while ( frame->curline < maxline && (RingQueue_GetLength(&uvd->dp) >= 384)) { 593 while ( frame->curline < maxline && (RingQueue_GetLength(&uvd->dp) >= 384)) {
594 /* Y */ 594 /* Y */
595 RingQueue_Dequeue(&uvd->dp, frame->data + (frame->curline * 256), 256); 595 RingQueue_Dequeue(&uvd->dp, frame->data + (frame->curline * 256), 256);
diff --git a/drivers/media/video/usbvideo/ultracam.c b/drivers/media/video/usbvideo/ultracam.c
index 75ff755224df..10c58b4a2e5b 100644
--- a/drivers/media/video/usbvideo/ultracam.c
+++ b/drivers/media/video/usbvideo/ultracam.c
@@ -23,7 +23,7 @@
23typedef struct { 23typedef struct {
24 int initialized; /* Had we already sent init sequence? */ 24 int initialized; /* Had we already sent init sequence? */
25 int camera_model; /* What type of IBM camera we got? */ 25 int camera_model; /* What type of IBM camera we got? */
26 int has_hdr; 26 int has_hdr;
27} ultracam_t; 27} ultracam_t;
28#define ULTRACAM_T(uvd) ((ultracam_t *)((uvd)->user_data)) 28#define ULTRACAM_T(uvd) ((ultracam_t *)((uvd)->user_data))
29 29
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index 0b51fae720a9..13b37c8c0d56 100644
--- a/drivers/media/video/usbvideo/usbvideo.c
+++ b/drivers/media/video/usbvideo/usbvideo.c
@@ -574,7 +574,7 @@ void usbvideo_TestPattern(struct uvd *uvd, int fullframe, int pmode)
574 } else { 574 } else {
575 /* Just the blue screen */ 575 /* Just the blue screen */
576 } 576 }
577 577
578 *f++ = cb; 578 *f++ = cb;
579 *f++ = cg; 579 *f++ = cg;
580 *f++ = cr; 580 *f++ = cr;
@@ -1243,7 +1243,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file)
1243 1243
1244#if USBVIDEO_REPORT_STATS 1244#if USBVIDEO_REPORT_STATS
1245 usbvideo_ReportStatistics(uvd); 1245 usbvideo_ReportStatistics(uvd);
1246#endif 1246#endif
1247 1247
1248 uvd->user--; 1248 uvd->user--;
1249 if (uvd->remove_pending) { 1249 if (uvd->remove_pending) {
@@ -1290,7 +1290,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
1290 return 0; 1290 return 0;
1291 } 1291 }
1292 case VIDIOCSCHAN: 1292 case VIDIOCSCHAN:
1293 { 1293 {
1294 struct video_channel *v = arg; 1294 struct video_channel *v = arg;
1295 if (v->channel != 0) 1295 if (v->channel != 0)
1296 return -EINVAL; 1296 return -EINVAL;
@@ -1347,7 +1347,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
1347 vw->chromakey = 0; 1347 vw->chromakey = 0;
1348 if (VALID_CALLBACK(uvd, getFPS)) 1348 if (VALID_CALLBACK(uvd, getFPS))
1349 vw->flags = GET_CALLBACK(uvd, getFPS)(uvd); 1349 vw->flags = GET_CALLBACK(uvd, getFPS)(uvd);
1350 else 1350 else
1351 vw->flags = 10; /* FIXME: do better! */ 1351 vw->flags = 10; /* FIXME: do better! */
1352 return 0; 1352 return 0;
1353 } 1353 }
@@ -1359,7 +1359,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
1359 memset(vm, 0, sizeof(*vm)); 1359 memset(vm, 0, sizeof(*vm));
1360 vm->size = uvd->max_frame_size * USBVIDEO_NUMFRAMES; 1360 vm->size = uvd->max_frame_size * USBVIDEO_NUMFRAMES;
1361 vm->frames = USBVIDEO_NUMFRAMES; 1361 vm->frames = USBVIDEO_NUMFRAMES;
1362 for(i = 0; i < USBVIDEO_NUMFRAMES; i++) 1362 for(i = 0; i < USBVIDEO_NUMFRAMES; i++)
1363 vm->offsets[i] = i * uvd->max_frame_size; 1363 vm->offsets[i] = i * uvd->max_frame_size;
1364 1364
1365 return 0; 1365 return 0;
@@ -1425,7 +1425,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
1425 1425
1426 if (*frameNum < 0 || *frameNum >= USBVIDEO_NUMFRAMES) 1426 if (*frameNum < 0 || *frameNum >= USBVIDEO_NUMFRAMES)
1427 return -EINVAL; 1427 return -EINVAL;
1428 1428
1429 if (uvd->debug >= 1) 1429 if (uvd->debug >= 1)
1430 info("VIDIOCSYNC: syncing to frame %d.", *frameNum); 1430 info("VIDIOCSYNC: syncing to frame %d.", *frameNum);
1431 if (uvd->flags & FLAGS_NO_DECODING) 1431 if (uvd->flags & FLAGS_NO_DECODING)
@@ -1454,8 +1454,8 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
1454 struct video_buffer *vb = arg; 1454 struct video_buffer *vb = arg;
1455 1455
1456 memset(vb, 0, sizeof(*vb)); 1456 memset(vb, 0, sizeof(*vb));
1457 return 0; 1457 return 0;
1458 } 1458 }
1459 case VIDIOCKEY: 1459 case VIDIOCKEY:
1460 return 0; 1460 return 0;
1461 1461
@@ -1704,7 +1704,7 @@ static void usbvideo_IsocIrq(struct urb *urb, struct pt_regs *regs)
1704 info("Not streaming, but interrupt!"); 1704 info("Not streaming, but interrupt!");
1705 return; 1705 return;
1706 } 1706 }
1707 1707
1708 uvd->stats.urb_count++; 1708 uvd->stats.urb_count++;
1709 if (urb->actual_length <= 0) 1709 if (urb->actual_length <= 0)
1710 goto urb_done_with; 1710 goto urb_done_with;
@@ -1763,7 +1763,7 @@ static int usbvideo_StartDataPump(struct uvd *uvd)
1763 } 1763 }
1764 if (VALID_CALLBACK(uvd, videoStart)) 1764 if (VALID_CALLBACK(uvd, videoStart))
1765 GET_CALLBACK(uvd, videoStart)(uvd); 1765 GET_CALLBACK(uvd, videoStart)(uvd);
1766 else 1766 else
1767 err("%s: videoStart not set", __FUNCTION__); 1767 err("%s: videoStart not set", __FUNCTION__);
1768 1768
1769 /* We double buffer the Iso lists */ 1769 /* We double buffer the Iso lists */
@@ -1830,7 +1830,7 @@ static void usbvideo_StopDataPump(struct uvd *uvd)
1830 /* Invoke minidriver's magic to stop the camera */ 1830 /* Invoke minidriver's magic to stop the camera */
1831 if (VALID_CALLBACK(uvd, videoStop)) 1831 if (VALID_CALLBACK(uvd, videoStop))
1832 GET_CALLBACK(uvd, videoStop)(uvd); 1832 GET_CALLBACK(uvd, videoStop)(uvd);
1833 else 1833 else
1834 err("%s: videoStop not set", __FUNCTION__); 1834 err("%s: videoStop not set", __FUNCTION__);
1835 1835
1836 /* Set packet size to 0 */ 1836 /* Set packet size to 0 */
@@ -1963,14 +1963,14 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
1963 info("%s($%p,%d.)", __FUNCTION__, uvd, frameNum); 1963 info("%s($%p,%d.)", __FUNCTION__, uvd, frameNum);
1964 1964
1965 switch (frame->frameState) { 1965 switch (frame->frameState) {
1966 case FrameState_Unused: 1966 case FrameState_Unused:
1967 if (uvd->debug >= 2) 1967 if (uvd->debug >= 2)
1968 info("%s: FrameState_Unused", __FUNCTION__); 1968 info("%s: FrameState_Unused", __FUNCTION__);
1969 return -EINVAL; 1969 return -EINVAL;
1970 case FrameState_Ready: 1970 case FrameState_Ready:
1971 case FrameState_Grabbing: 1971 case FrameState_Grabbing:
1972 case FrameState_Error: 1972 case FrameState_Error:
1973 { 1973 {
1974 int ntries, signalPending; 1974 int ntries, signalPending;
1975 redo: 1975 redo:
1976 if (!CAMERA_IS_OPERATIONAL(uvd)) { 1976 if (!CAMERA_IS_OPERATIONAL(uvd)) {
@@ -1978,7 +1978,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
1978 info("%s: Camera is not operational (1)", __FUNCTION__); 1978 info("%s: Camera is not operational (1)", __FUNCTION__);
1979 return -EIO; 1979 return -EIO;
1980 } 1980 }
1981 ntries = 0; 1981 ntries = 0;
1982 do { 1982 do {
1983 RingQueue_InterruptibleSleepOn(&uvd->dp); 1983 RingQueue_InterruptibleSleepOn(&uvd->dp);
1984 signalPending = signal_pending(current); 1984 signalPending = signal_pending(current);
@@ -2010,7 +2010,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
2010 usbvideo_CollectRawData(uvd, frame); 2010 usbvideo_CollectRawData(uvd, frame);
2011 else if (VALID_CALLBACK(uvd, processData)) 2011 else if (VALID_CALLBACK(uvd, processData))
2012 GET_CALLBACK(uvd, processData)(uvd, frame); 2012 GET_CALLBACK(uvd, processData)(uvd, frame);
2013 else 2013 else
2014 err("%s: processData not set", __FUNCTION__); 2014 err("%s: processData not set", __FUNCTION__);
2015 } 2015 }
2016 } while (frame->frameState == FrameState_Grabbing); 2016 } while (frame->frameState == FrameState_Grabbing);
@@ -2027,8 +2027,8 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
2027 goto redo; 2027 goto redo;
2028 } 2028 }
2029 /* Note that we fall through to meet our destiny below */ 2029 /* Note that we fall through to meet our destiny below */
2030 } 2030 }
2031 case FrameState_Done: 2031 case FrameState_Done:
2032 /* 2032 /*
2033 * Do all necessary postprocessing of data prepared in 2033 * Do all necessary postprocessing of data prepared in
2034 * "interrupt" code and the collecting code above. The 2034 * "interrupt" code and the collecting code above. The
@@ -2157,7 +2157,7 @@ EXPORT_SYMBOL(usbvideo_DeinterlaceFrame);
2157 * History: 2157 * History:
2158 * 09-Feb-2001 Created. 2158 * 09-Feb-2001 Created.
2159 */ 2159 */
2160static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd, 2160static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd,
2161 struct usbvideo_frame *frame) 2161 struct usbvideo_frame *frame)
2162{ 2162{
2163 int i, j, v4l_linesize; 2163 int i, j, v4l_linesize;
diff --git a/drivers/media/video/usbvideo/usbvideo.h b/drivers/media/video/usbvideo/usbvideo.h
index 135433c2680a..3cbf4fc499a3 100644
--- a/drivers/media/video/usbvideo/usbvideo.h
+++ b/drivers/media/video/usbvideo/usbvideo.h
@@ -189,11 +189,11 @@ struct usbvideo_frame {
189 189
190/* Statistics that can be overlaid on screen */ 190/* Statistics that can be overlaid on screen */
191struct usbvideo_statistics { 191struct usbvideo_statistics {
192 unsigned long frame_num; /* Sequential number of the frame */ 192 unsigned long frame_num; /* Sequential number of the frame */
193 unsigned long urb_count; /* How many URBs we received so far */ 193 unsigned long urb_count; /* How many URBs we received so far */
194 unsigned long urb_length; /* Length of last URB */ 194 unsigned long urb_length; /* Length of last URB */
195 unsigned long data_count; /* How many bytes we received */ 195 unsigned long data_count; /* How many bytes we received */
196 unsigned long header_count; /* How many frame headers we found */ 196 unsigned long header_count; /* How many frame headers we found */
197 unsigned long iso_skip_count; /* How many empty ISO packets received */ 197 unsigned long iso_skip_count; /* How many empty ISO packets received */
198 unsigned long iso_err_count; /* How many bad ISO packets received */ 198 unsigned long iso_err_count; /* How many bad ISO packets received */
199}; 199};
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 1d06e53ec7c5..90d48e8510ba 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -69,10 +69,10 @@
69#define VICAM_HEADER_SIZE 64 69#define VICAM_HEADER_SIZE 64
70 70
71#define clamp( x, l, h ) max_t( __typeof__( x ), \ 71#define clamp( x, l, h ) max_t( __typeof__( x ), \
72 ( l ), \ 72 ( l ), \
73 min_t( __typeof__( x ), \ 73 min_t( __typeof__( x ), \
74 ( h ), \ 74 ( h ), \
75 ( x ) ) ) 75 ( x ) ) )
76 76
77/* Not sure what all the bytes in these char 77/* Not sure what all the bytes in these char
78 * arrays do, but they're necessary to make 78 * arrays do, but they're necessary to make
@@ -357,7 +357,7 @@ static unsigned char setup5[] = {
357 * Not sure why these are not yet non-statics which I can reference through 357 * Not sure why these are not yet non-statics which I can reference through
358 * usbvideo.h the same as it is in 2.4.20. I bet this will get fixed sometime 358 * usbvideo.h the same as it is in 2.4.20. I bet this will get fixed sometime
359 * in the future. 359 * in the future.
360 * 360 *
361*/ 361*/
362static void *rvmalloc(unsigned long size) 362static void *rvmalloc(unsigned long size)
363{ 363{
@@ -603,12 +603,12 @@ vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsign
603 case VIDIOCSPICT: 603 case VIDIOCSPICT:
604 { 604 {
605 struct video_picture vp; 605 struct video_picture vp;
606 606
607 if (copy_from_user(&vp, user_arg, sizeof(vp))) { 607 if (copy_from_user(&vp, user_arg, sizeof(vp))) {
608 retval = -EFAULT; 608 retval = -EFAULT;
609 break; 609 break;
610 } 610 }
611 611
612 DBG("VIDIOCSPICT depth = %d, pal = %d\n", vp.depth, 612 DBG("VIDIOCSPICT depth = %d, pal = %d\n", vp.depth,
613 vp.palette); 613 vp.palette);
614 614
@@ -655,7 +655,7 @@ vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsign
655 } 655 }
656 656
657 DBG("VIDIOCSWIN %d x %d\n", vw.width, vw.height); 657 DBG("VIDIOCSWIN %d x %d\n", vw.width, vw.height);
658 658
659 if ( vw.width != 320 || vw.height != 240 ) 659 if ( vw.width != 320 || vw.height != 240 )
660 retval = -EFAULT; 660 retval = -EFAULT;
661 661
@@ -809,12 +809,12 @@ vicam_open(struct inode *inode, struct file *file)
809 cam->needsDummyRead = 1; 809 cam->needsDummyRead = 1;
810 cam->open_count++; 810 cam->open_count++;
811 811
812 file->private_data = cam; 812 file->private_data = cam;
813 813
814 return 0; 814 return 0;
815} 815}
816 816
817static int 817static int
818vicam_close(struct inode *inode, struct file *file) 818vicam_close(struct inode *inode, struct file *file)
819{ 819{
820 struct vicam_camera *cam = file->private_data; 820 struct vicam_camera *cam = file->private_data;
@@ -1187,7 +1187,7 @@ vicam_create_proc_entry(struct vicam_camera *cam)
1187 1187
1188 if ( !cam->proc_dir ) 1188 if ( !cam->proc_dir )
1189 return; // FIXME: We should probably return an error here 1189 return; // FIXME: We should probably return an error here
1190 1190
1191 ent = create_proc_entry("shutter", S_IFREG | S_IRUGO | S_IWUSR, 1191 ent = create_proc_entry("shutter", S_IFREG | S_IRUGO | S_IWUSR,
1192 cam->proc_dir); 1192 cam->proc_dir);
1193 if (ent) { 1193 if (ent) {
@@ -1282,7 +1282,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
1282 const struct usb_host_interface *interface; 1282 const struct usb_host_interface *interface;
1283 const struct usb_endpoint_descriptor *endpoint; 1283 const struct usb_endpoint_descriptor *endpoint;
1284 struct vicam_camera *cam; 1284 struct vicam_camera *cam;
1285 1285
1286 printk(KERN_INFO "ViCam based webcam connected\n"); 1286 printk(KERN_INFO "ViCam based webcam connected\n");
1287 1287
1288 interface = intf->cur_altsetting; 1288 interface = intf->cur_altsetting;
@@ -1331,7 +1331,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
1331 printk(KERN_INFO "ViCam webcam driver now controlling video device %d\n",cam->vdev.minor); 1331 printk(KERN_INFO "ViCam webcam driver now controlling video device %d\n",cam->vdev.minor);
1332 1332
1333 usb_set_intfdata (intf, cam); 1333 usb_set_intfdata (intf, cam);
1334 1334
1335 return 0; 1335 return 0;
1336} 1336}
1337 1337
diff --git a/drivers/media/video/videocodec.h b/drivers/media/video/videocodec.h
index b1239ac7f371..8c233720b6a5 100644
--- a/drivers/media/video/videocodec.h
+++ b/drivers/media/video/videocodec.h
@@ -57,7 +57,7 @@
57 therfor they may not be initialized. 57 therfor they may not be initialized.
58 58
59 The other fuctions are just for convenience, as they are for sure used by 59 The other fuctions are just for convenience, as they are for sure used by
60 most/all of the codecs. The last ones may be ommited, too. 60 most/all of the codecs. The last ones may be ommited, too.
61 61
62 See the structure declaration below for more information and which data has 62 See the structure declaration below for more information and which data has
63 to be set up for the master and the slave. 63 to be set up for the master and the slave.
@@ -75,52 +75,52 @@
75/* ========================================== */ 75/* ========================================== */
76 76
77/* 77/*
78 ==== master setup ==== 78 ==== master setup ====
79 name -> name of the device structure for reference and debugging 79 name -> name of the device structure for reference and debugging
80 master_data -> data ref. for the master (e.g. the zr36055,57,67) 80 master_data -> data ref. for the master (e.g. the zr36055,57,67)
81 readreg -> ref. to read-fn from register (setup by master, used by slave) 81 readreg -> ref. to read-fn from register (setup by master, used by slave)
82 writereg -> ref. to write-fn to register (setup by master, used by slave) 82 writereg -> ref. to write-fn to register (setup by master, used by slave)
83 this two functions do the lowlevel I/O job 83 this two functions do the lowlevel I/O job
84 84
85 ==== slave functionality setup ==== 85 ==== slave functionality setup ====
86 slave_data -> data ref. for the slave (e.g. the zr36050,60) 86 slave_data -> data ref. for the slave (e.g. the zr36050,60)
87 check -> fn-ref. checks availability of an device, returns -EIO on failure or 87 check -> fn-ref. checks availability of an device, returns -EIO on failure or
88 the type on success 88 the type on success
89 this makes espcecially sense if a driver module supports more than 89 this makes espcecially sense if a driver module supports more than
90 one codec which may be quite similar to access, nevertheless it 90 one codec which may be quite similar to access, nevertheless it
91 is good for a first functionality check 91 is good for a first functionality check
92 92
93 -- main functions you always need for compression/decompression -- 93 -- main functions you always need for compression/decompression --
94 94
95 set_mode -> this fn-ref. resets the entire codec, and sets up the mode 95 set_mode -> this fn-ref. resets the entire codec, and sets up the mode
96 with the last defined norm/size (or device default if not 96 with the last defined norm/size (or device default if not
97 available) - it returns 0 if the mode is possible 97 available) - it returns 0 if the mode is possible
98 set_size -> this fn-ref. sets the norm and image size for 98 set_size -> this fn-ref. sets the norm and image size for
99 compression/decompression (returns 0 on success) 99 compression/decompression (returns 0 on success)
100 the norm param is defined in videodev.h (VIDEO_MODE_*) 100 the norm param is defined in videodev.h (VIDEO_MODE_*)
101 101
102 additional setup may be available, too - but the codec should work with 102 additional setup may be available, too - but the codec should work with
103 some default values even without this 103 some default values even without this
104 104
105 set_data -> sets device-specific data (tables, quality etc.) 105 set_data -> sets device-specific data (tables, quality etc.)
106 get_data -> query device-specific data (tables, quality etc.) 106 get_data -> query device-specific data (tables, quality etc.)
107 107
108 if the device delivers interrupts, they may be setup/handled here 108 if the device delivers interrupts, they may be setup/handled here
109 setup_interrupt -> codec irq setup (not needed for 36050/60) 109 setup_interrupt -> codec irq setup (not needed for 36050/60)
110 handle_interrupt -> codec irq handling (not needed for 36050/60) 110 handle_interrupt -> codec irq handling (not needed for 36050/60)
111 111
112 if the device delivers pictures, they may be handled here 112 if the device delivers pictures, they may be handled here
113 put_image -> puts image data to the codec (not needed for 36050/60) 113 put_image -> puts image data to the codec (not needed for 36050/60)
114 get_image -> gets image data from the codec (not needed for 36050/60) 114 get_image -> gets image data from the codec (not needed for 36050/60)
115 the calls include frame numbers and flags (even/odd/...) 115 the calls include frame numbers and flags (even/odd/...)
116 if needed and a flag which allows blocking until its ready 116 if needed and a flag which allows blocking until its ready
117*/ 117*/
118 118
119/* ============== */ 119/* ============== */
120/* user interface */ 120/* user interface */
121/* ============== */ 121/* ============== */
122 122
123/* 123/*
124 Currently there is only a information display planned, as the layer 124 Currently there is only a information display planned, as the layer
125 is not visible for the user space at all. 125 is not visible for the user space at all.
126 126
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 0229819d0aac..a8c101494cf5 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -1555,12 +1555,12 @@ static void vino_update_line_size(struct vino_channel_settings *vcs)
1555 unsigned int w = vcs->clipping.right - vcs->clipping.left; 1555 unsigned int w = vcs->clipping.right - vcs->clipping.left;
1556 unsigned int d = vcs->decimation; 1556 unsigned int d = vcs->decimation;
1557 unsigned int bpp = vino_data_formats[vcs->data_format].bpp; 1557 unsigned int bpp = vino_data_formats[vcs->data_format].bpp;
1558 unsigned int lsize; 1558 unsigned int lsize;
1559 1559
1560 dprintk("update_line_size(): before: w = %d, d = %d, " 1560 dprintk("update_line_size(): before: w = %d, d = %d, "
1561 "line_size = %d\n", w, d, vcs->line_size); 1561 "line_size = %d\n", w, d, vcs->line_size);
1562 1562
1563 /* line size must be multiple of 8 bytes */ 1563 /* line size must be multiple of 8 bytes */
1564 lsize = (bpp * (w / d)) & ~7; 1564 lsize = (bpp * (w / d)) & ~7;
1565 w = (lsize / bpp) * d; 1565 w = (lsize / bpp) * d;
1566 1566
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 4cd579967487..40b205b91481 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * vpx3220a, vpx3216b & vpx3214c video decoder driver version 0.0.1 2 * vpx3220a, vpx3216b & vpx3214c video decoder driver version 0.0.1
3 * 3 *
4 * Copyright (C) 2001 Laurent Pinchart <lpinchart@freegates.be> 4 * Copyright (C) 2001 Laurent Pinchart <lpinchart@freegates.be>
@@ -176,8 +176,8 @@ vpx3220_write_block (struct i2c_client *client,
176 176
177static int 177static int
178vpx3220_write_fp_block (struct i2c_client *client, 178vpx3220_write_fp_block (struct i2c_client *client,
179 const u16 *data, 179 const u16 *data,
180 unsigned int len) 180 unsigned int len)
181{ 181{
182 u8 reg; 182 u8 reg;
183 int ret = 0; 183 int ret = 0;
@@ -316,7 +316,7 @@ vpx3220_command (struct i2c_client *client,
316 vpx3220_write_fp_block(client, init_fp, 316 vpx3220_write_fp_block(client, init_fp,
317 sizeof(init_fp) >> 1); 317 sizeof(init_fp) >> 1);
318 switch (decoder->norm) { 318 switch (decoder->norm) {
319 319
320 case VIDEO_MODE_NTSC: 320 case VIDEO_MODE_NTSC:
321 vpx3220_write_fp_block(client, init_ntsc, 321 vpx3220_write_fp_block(client, init_ntsc,
322 sizeof(init_ntsc) >> 1); 322 sizeof(init_ntsc) >> 1);
@@ -324,7 +324,7 @@ vpx3220_command (struct i2c_client *client,
324 324
325 case VIDEO_MODE_PAL: 325 case VIDEO_MODE_PAL:
326 vpx3220_write_fp_block(client, init_pal, 326 vpx3220_write_fp_block(client, init_pal,
327 sizeof(init_pal) >> 1); 327 sizeof(init_pal) >> 1);
328 break; 328 break;
329 case VIDEO_MODE_SECAM: 329 case VIDEO_MODE_SECAM:
330 vpx3220_write_fp_block(client, init_secam, 330 vpx3220_write_fp_block(client, init_secam,
@@ -332,10 +332,10 @@ vpx3220_command (struct i2c_client *client,
332 break; 332 break;
333 default: 333 default:
334 vpx3220_write_fp_block(client, init_pal, 334 vpx3220_write_fp_block(client, init_pal,
335 sizeof(init_pal) >> 1); 335 sizeof(init_pal) >> 1);
336 break; 336 break;
337 } 337 }
338 } 338 }
339 break; 339 break;
340 340
341 case DECODER_DUMP: 341 case DECODER_DUMP:
@@ -411,7 +411,7 @@ vpx3220_command (struct i2c_client *client,
411 411
412 /* Here we back up the input selection because it gets 412 /* Here we back up the input selection because it gets
413 overwritten when we fill the registers with the 413 overwritten when we fill the registers with the
414 choosen video norm */ 414 choosen video norm */
415 temp_input = vpx3220_fp_read(client, 0xf2); 415 temp_input = vpx3220_fp_read(client, 0xf2);
416 416
417 dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n", 417 dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n",
@@ -578,7 +578,7 @@ static unsigned short normal_i2c[] =
578}; 578};
579 579
580static unsigned short ignore = I2C_CLIENT_END; 580static unsigned short ignore = I2C_CLIENT_END;
581 581
582static struct i2c_client_address_data addr_data = { 582static struct i2c_client_address_data addr_data = {
583 .normal_i2c = normal_i2c, 583 .normal_i2c = normal_i2c,
584 .probe = &ignore, 584 .probe = &ignore,
@@ -661,7 +661,7 @@ vpx3220_detect_client (struct i2c_adapter *adapter,
661 break; 661 break;
662 default: 662 default:
663 dprintk(1, 663 dprintk(1,
664 KERN_INFO 664 KERN_INFO
665 "%s: Wrong part number (0x%04x)\n", 665 "%s: Wrong part number (0x%04x)\n",
666 __func__, pn); 666 __func__, pn);
667 kfree(client); 667 kfree(client);
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index b7b0afffd214..80ef8a1b8f63 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -26,7 +26,7 @@
26 Does any other model using the w9966 interface chip exist ? 26 Does any other model using the w9966 interface chip exist ?
27 27
28 Todo: 28 Todo:
29 29
30 *Add a working EPP mode, since DMA ECP read isn't implemented 30 *Add a working EPP mode, since DMA ECP read isn't implemented
31 in the parport drivers. (That's why it's so sloow) 31 in the parport drivers. (That's why it's so sloow)
32 32
@@ -47,9 +47,9 @@
47 *Probably some bugs that I don't know of 47 *Probably some bugs that I don't know of
48 48
49 Please support me by sending feedback! 49 Please support me by sending feedback!
50 50
51 Changes: 51 Changes:
52 52
53 Alan Cox: Removed RGB mode for kernel merge, added THIS_MODULE 53 Alan Cox: Removed RGB mode for kernel merge, added THIS_MODULE
54 and owner support for newer module locks 54 and owner support for newer module locks
55*/ 55*/
@@ -204,7 +204,7 @@ static struct video_device w9966_template = {
204 */ 204 */
205 205
206 206
207// Set camera phase flags, so we know what to uninit when terminating 207// Set camera phase flags, so we know what to uninit when terminating
208static inline void w9966_setState(struct w9966_dev* cam, int mask, int val) 208static inline void w9966_setState(struct w9966_dev* cam, int mask, int val)
209{ 209{
210 cam->dev_state = (cam->dev_state & ~mask) ^ val; 210 cam->dev_state = (cam->dev_state & ~mask) ^ val;
@@ -233,7 +233,7 @@ static inline void w9966_pdev_release(struct w9966_dev* cam)
233 parport_release(cam->pdev); 233 parport_release(cam->pdev);
234 w9966_setState(cam, W9966_STATE_CLAIMED, 0); 234 w9966_setState(cam, W9966_STATE_CLAIMED, 0);
235} 235}
236 236
237// Read register from W9966 interface-chip 237// Read register from W9966 interface-chip
238// Expects a claimed pdev 238// Expects a claimed pdev
239// -1 on error, else register data (byte) 239// -1 on error, else register data (byte)
@@ -242,7 +242,7 @@ static int w9966_rReg(struct w9966_dev* cam, int reg)
242 // ECP, read, regtransfer, REG, REG, REG, REG, REG 242 // ECP, read, regtransfer, REG, REG, REG, REG, REG
243 const unsigned char addr = 0x80 | (reg & 0x1f); 243 const unsigned char addr = 0x80 | (reg & 0x1f);
244 unsigned char val; 244 unsigned char val;
245 245
246 if (parport_negotiate(cam->pport, cam->ppmode | IEEE1284_ADDR) != 0) 246 if (parport_negotiate(cam->pport, cam->ppmode | IEEE1284_ADDR) != 0)
247 return -1; 247 return -1;
248 if (parport_write(cam->pport, &addr, 1) != 1) 248 if (parport_write(cam->pport, &addr, 1) != 1)
@@ -263,7 +263,7 @@ static int w9966_wReg(struct w9966_dev* cam, int reg, int data)
263 // ECP, write, regtransfer, REG, REG, REG, REG, REG 263 // ECP, write, regtransfer, REG, REG, REG, REG, REG
264 const unsigned char addr = 0xc0 | (reg & 0x1f); 264 const unsigned char addr = 0xc0 | (reg & 0x1f);
265 const unsigned char val = data; 265 const unsigned char val = data;
266 266
267 if (parport_negotiate(cam->pport, cam->ppmode | IEEE1284_ADDR) != 0) 267 if (parport_negotiate(cam->pport, cam->ppmode | IEEE1284_ADDR) != 0)
268 return -1; 268 return -1;
269 if (parport_write(cam->pport, &addr, 1) != 1) 269 if (parport_write(cam->pport, &addr, 1) != 1)
@@ -284,7 +284,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
284{ 284{
285 if (cam->dev_state != 0) 285 if (cam->dev_state != 0)
286 return -1; 286 return -1;
287 287
288 cam->pport = port; 288 cam->pport = port;
289 cam->brightness = 128; 289 cam->brightness = 128;
290 cam->contrast = 64; 290 cam->contrast = 64;
@@ -302,7 +302,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
302 cam->ppmode = IEEE1284_MODE_EPP; 302 cam->ppmode = IEEE1284_MODE_EPP;
303 else 303 else
304 cam->ppmode = IEEE1284_MODE_ECP; 304 cam->ppmode = IEEE1284_MODE_ECP;
305 break; 305 break;
306 case 1: // hw- or sw-ecp 306 case 1: // hw- or sw-ecp
307 cam->ppmode = IEEE1284_MODE_ECP; 307 cam->ppmode = IEEE1284_MODE_ECP;
308 break; 308 break;
@@ -310,7 +310,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
310 cam->ppmode = IEEE1284_MODE_EPP; 310 cam->ppmode = IEEE1284_MODE_EPP;
311 break; 311 break;
312 } 312 }
313 313
314// Tell the parport driver that we exists 314// Tell the parport driver that we exists
315 cam->pdev = parport_register_device(port, "w9966", NULL, NULL, NULL, 0, NULL); 315 cam->pdev = parport_register_device(port, "w9966", NULL, NULL, NULL, 0, NULL);
316 if (cam->pdev == NULL) { 316 if (cam->pdev == NULL) {
@@ -320,7 +320,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
320 w9966_setState(cam, W9966_STATE_PDEV, W9966_STATE_PDEV); 320 w9966_setState(cam, W9966_STATE_PDEV, W9966_STATE_PDEV);
321 321
322 w9966_pdev_claim(cam); 322 w9966_pdev_claim(cam);
323 323
324// Setup a default capture mode 324// Setup a default capture mode
325 if (w9966_setup(cam, 0, 0, 1023, 1023, 200, 160) != 0) { 325 if (w9966_setup(cam, 0, 0, 1023, 1023, 200, 160) != 0) {
326 DPRINTF("w9966_setup() failed.\n"); 326 DPRINTF("w9966_setup() failed.\n");
@@ -333,11 +333,11 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
333 memcpy(&cam->vdev, &w9966_template, sizeof(struct video_device)); 333 memcpy(&cam->vdev, &w9966_template, sizeof(struct video_device));
334 cam->vdev.priv = cam; 334 cam->vdev.priv = cam;
335 335
336 if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) == -1) 336 if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) == -1)
337 return -1; 337 return -1;
338 338
339 w9966_setState(cam, W9966_STATE_VDEV, W9966_STATE_VDEV); 339 w9966_setState(cam, W9966_STATE_VDEV, W9966_STATE_VDEV);
340 340
341 // All ok 341 // All ok
342 printk( 342 printk(
343 "w9966cf: Found and initialized a webcam on %s.\n", 343 "w9966cf: Found and initialized a webcam on %s.\n",
@@ -391,7 +391,7 @@ static int w9966_findlen(int near, int size, int maxlen)
391 // Only continue as long as we keep getting better values 391 // Only continue as long as we keep getting better values
392 if (err > besterr) 392 if (err > besterr)
393 break; 393 break;
394 394
395 besterr = err; 395 besterr = err;
396 bestlen = len; 396 bestlen = len;
397 } 397 }
@@ -399,7 +399,7 @@ static int w9966_findlen(int near, int size, int maxlen)
399 return bestlen; 399 return bestlen;
400} 400}
401 401
402// Modify capture window (if necessary) 402// Modify capture window (if necessary)
403// and calculate downscaling 403// and calculate downscaling
404// Return -1 on error 404// Return -1 on error
405static int w9966_calcscale(int size, int min, int max, int* beg, int* end, unsigned char* factor) 405static int w9966_calcscale(int size, int min, int max, int* beg, int* end, unsigned char* factor)
@@ -407,7 +407,7 @@ static int w9966_calcscale(int size, int min, int max, int* beg, int* end, unsig
407 int maxlen = max - min; 407 int maxlen = max - min;
408 int len = *end - *beg + 1; 408 int len = *end - *beg + 1;
409 int newlen = w9966_findlen(len, size, maxlen); 409 int newlen = w9966_findlen(len, size, maxlen);
410 int err = newlen - len; 410 int err = newlen - len;
411 411
412 // Check for bad format 412 // Check for bad format
413 if (newlen > maxlen || newlen < size) 413 if (newlen > maxlen || newlen < size)
@@ -452,8 +452,8 @@ static int w9966_setup(struct w9966_dev* cam, int x1, int y1, int x2, int y2, in
452 0x48, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 452 0x48, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
453 0x00, 0x00, 0x00, 0x71, 0xe7, 0x00, 0x00, 0xc0 453 0x00, 0x00, 0x00, 0x71, 0xe7, 0x00, 0x00, 0xc0
454 }; 454 };
455 455
456 456
457 if (w*h*2 > W9966_SRAMSIZE) 457 if (w*h*2 > W9966_SRAMSIZE)
458 { 458 {
459 DPRINTF("capture window exceeds SRAM size!.\n"); 459 DPRINTF("capture window exceeds SRAM size!.\n");
@@ -469,9 +469,9 @@ static int w9966_setup(struct w9966_dev* cam, int x1, int y1, int x2, int y2, in
469 cam->width = w; 469 cam->width = w;
470 cam->height = h; 470 cam->height = h;
471 471
472 enh_s = 0; 472 enh_s = 0;
473 enh_e = w*h*2; 473 enh_e = w*h*2;
474 474
475// Modify capture window if necessary and calculate downscaling 475// Modify capture window if necessary and calculate downscaling
476 if ( 476 if (
477 w9966_calcscale(w, W9966_WND_MIN_X, W9966_WND_MAX_X, &x1, &x2, &scale_x) != 0 || 477 w9966_calcscale(w, W9966_WND_MIN_X, W9966_WND_MAX_X, &x1, &x2, &scale_x) != 0 ||
@@ -482,14 +482,14 @@ static int w9966_setup(struct w9966_dev* cam, int x1, int y1, int x2, int y2, in
482 "%dx%d, x: %d<->%d, y: %d<->%d, sx: %d/64, sy: %d/64.\n", 482 "%dx%d, x: %d<->%d, y: %d<->%d, sx: %d/64, sy: %d/64.\n",
483 w, h, x1, x2, y1, y2, scale_x&~0x80, scale_y&~0x80 483 w, h, x1, x2, y1, y2, scale_x&~0x80, scale_y&~0x80
484 ); 484 );
485 485
486// Setup registers 486// Setup registers
487 regs[0x00] = 0x00; // Set normal operation 487 regs[0x00] = 0x00; // Set normal operation
488 regs[0x01] = 0x18; // Capture mode 488 regs[0x01] = 0x18; // Capture mode
489 regs[0x02] = scale_y; // V-scaling 489 regs[0x02] = scale_y; // V-scaling
490 regs[0x03] = scale_x; // H-scaling 490 regs[0x03] = scale_x; // H-scaling
491 491
492 // Capture window 492 // Capture window
493 regs[0x04] = (x1 & 0x0ff); // X-start (8 low bits) 493 regs[0x04] = (x1 & 0x0ff); // X-start (8 low bits)
494 regs[0x05] = (x1 & 0x300)>>8; // X-start (2 high bits) 494 regs[0x05] = (x1 & 0x300)>>8; // X-start (2 high bits)
495 regs[0x06] = (y1 & 0x0ff); // Y-start (8 low bits) 495 regs[0x06] = (y1 & 0x0ff); // Y-start (8 low bits)
@@ -499,7 +499,7 @@ static int w9966_setup(struct w9966_dev* cam, int x1, int y1, int x2, int y2, in
499 regs[0x0a] = (y2 & 0x0ff); // Y-end (8 low bits) 499 regs[0x0a] = (y2 & 0x0ff); // Y-end (8 low bits)
500 500
501 regs[0x0c] = W9966_SRAMID; // SRAM-banks (1x 128kb) 501 regs[0x0c] = W9966_SRAMID; // SRAM-banks (1x 128kb)
502 502
503 // Enhancement layer 503 // Enhancement layer
504 regs[0x0d] = (enh_s& 0x000ff); // Enh. start (0-7) 504 regs[0x0d] = (enh_s& 0x000ff); // Enh. start (0-7)
505 regs[0x0e] = (enh_s& 0x0ff00)>>8; // Enh. start (8-15) 505 regs[0x0e] = (enh_s& 0x0ff00)>>8; // Enh. start (8-15)
@@ -515,7 +515,7 @@ static int w9966_setup(struct w9966_dev* cam, int x1, int y1, int x2, int y2, in
515 regs[0x19] = 0xff; // I/O port direction control 515 regs[0x19] = 0xff; // I/O port direction control
516 regs[0x1a] = 0xff; // I/O port data register 516 regs[0x1a] = 0xff; // I/O port data register
517 regs[0x1b] = 0x10; // ??? 517 regs[0x1b] = 0x10; // ???
518 518
519 // SAA7111 chip settings 519 // SAA7111 chip settings
520 saa7111_regs[0x0a] = cam->brightness; 520 saa7111_regs[0x0a] = cam->brightness;
521 saa7111_regs[0x0b] = cam->contrast; 521 saa7111_regs[0x0b] = cam->contrast;
@@ -551,7 +551,7 @@ static inline void w9966_i2c_setsda(struct w9966_dev* cam, int state)
551 cam->i2c_state |= W9966_I2C_W_DATA; 551 cam->i2c_state |= W9966_I2C_W_DATA;
552 else 552 else
553 cam->i2c_state &= ~W9966_I2C_W_DATA; 553 cam->i2c_state &= ~W9966_I2C_W_DATA;
554 554
555 w9966_wReg(cam, 0x18, cam->i2c_state); 555 w9966_wReg(cam, 0x18, cam->i2c_state);
556 udelay(5); 556 udelay(5);
557} 557}
@@ -577,7 +577,7 @@ static inline int w9966_i2c_setscl(struct w9966_dev* cam, int state)
577 577
578 w9966_wReg(cam, 0x18, cam->i2c_state); 578 w9966_wReg(cam, 0x18, cam->i2c_state);
579 udelay(5); 579 udelay(5);
580 580
581 // we go to high, we also expect the peripheral to ack. 581 // we go to high, we also expect the peripheral to ack.
582 if (state) { 582 if (state) {
583 timeout = jiffies + 100; 583 timeout = jiffies + 100;
@@ -607,16 +607,16 @@ static int w9966_i2c_wbyte(struct w9966_dev* cam, int data)
607 w9966_i2c_setsda(cam, (data >> i) & 0x01); 607 w9966_i2c_setsda(cam, (data >> i) & 0x01);
608 608
609 if (w9966_i2c_setscl(cam, 1) == -1) 609 if (w9966_i2c_setscl(cam, 1) == -1)
610 return -1; 610 return -1;
611 w9966_i2c_setscl(cam, 0); 611 w9966_i2c_setscl(cam, 0);
612 } 612 }
613 613
614 w9966_i2c_setsda(cam, 1); 614 w9966_i2c_setsda(cam, 1);
615 615
616 if (w9966_i2c_setscl(cam, 1) == -1) 616 if (w9966_i2c_setscl(cam, 1) == -1)
617 return -1; 617 return -1;
618 w9966_i2c_setscl(cam, 0); 618 w9966_i2c_setscl(cam, 0);
619 619
620 return 0; 620 return 0;
621} 621}
622 622
@@ -626,8 +626,8 @@ static int w9966_i2c_wbyte(struct w9966_dev* cam, int data)
626static int w9966_i2c_rbyte(struct w9966_dev* cam) 626static int w9966_i2c_rbyte(struct w9966_dev* cam)
627{ 627{
628 unsigned char data = 0x00; 628 unsigned char data = 0x00;
629 int i; 629 int i;
630 630
631 w9966_i2c_setsda(cam, 1); 631 w9966_i2c_setsda(cam, 1);
632 632
633 for (i = 0; i < 8; i++) 633 for (i = 0; i < 8; i++)
@@ -637,7 +637,7 @@ static int w9966_i2c_rbyte(struct w9966_dev* cam)
637 data = data << 1; 637 data = data << 1;
638 if (w9966_i2c_getsda(cam)) 638 if (w9966_i2c_getsda(cam))
639 data |= 0x01; 639 data |= 0x01;
640 640
641 w9966_i2c_setscl(cam, 0); 641 w9966_i2c_setscl(cam, 0);
642 } 642 }
643 return data; 643 return data;
@@ -673,11 +673,11 @@ static int w9966_rReg_i2c(struct w9966_dev* cam, int reg)
673 return -1; 673 return -1;
674 674
675 w9966_i2c_setsda(cam, 0); 675 w9966_i2c_setsda(cam, 0);
676 676
677 if (w9966_i2c_setscl(cam, 1) == -1) 677 if (w9966_i2c_setscl(cam, 1) == -1)
678 return -1; 678 return -1;
679 w9966_i2c_setsda(cam, 1); 679 w9966_i2c_setsda(cam, 1);
680 680
681 return data; 681 return data;
682} 682}
683#endif 683#endif
@@ -699,7 +699,7 @@ static int w9966_wReg_i2c(struct w9966_dev* cam, int reg, int data)
699 w9966_i2c_setsda(cam, 0); 699 w9966_i2c_setsda(cam, 0);
700 if (w9966_i2c_setscl(cam, 1) == -1) 700 if (w9966_i2c_setscl(cam, 1) == -1)
701 return -1; 701 return -1;
702 702
703 w9966_i2c_setsda(cam, 1); 703 w9966_i2c_setsda(cam, 1);
704 704
705 return 0; 705 return 0;
@@ -714,7 +714,7 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
714{ 714{
715 struct video_device *vdev = video_devdata(file); 715 struct video_device *vdev = video_devdata(file);
716 struct w9966_dev *cam = vdev->priv; 716 struct w9966_dev *cam = vdev->priv;
717 717
718 switch(cmd) 718 switch(cmd)
719 { 719 {
720 case VIDIOCGCAP: 720 case VIDIOCGCAP:
@@ -790,14 +790,14 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
790 struct video_picture *vpic = arg; 790 struct video_picture *vpic = arg;
791 if (vpic->depth != 16 || vpic->palette != VIDEO_PALETTE_YUV422) 791 if (vpic->depth != 16 || vpic->palette != VIDEO_PALETTE_YUV422)
792 return -EINVAL; 792 return -EINVAL;
793 793
794 cam->brightness = vpic->brightness >> 8; 794 cam->brightness = vpic->brightness >> 8;
795 cam->hue = (vpic->hue >> 8) - 128; 795 cam->hue = (vpic->hue >> 8) - 128;
796 cam->color = vpic->colour >> 9; 796 cam->color = vpic->colour >> 9;
797 cam->contrast = vpic->contrast >> 9; 797 cam->contrast = vpic->contrast >> 9;
798 798
799 w9966_pdev_claim(cam); 799 w9966_pdev_claim(cam);
800 800
801 if ( 801 if (
802 w9966_wReg_i2c(cam, 0x0a, cam->brightness) == -1 || 802 w9966_wReg_i2c(cam, 0x0a, cam->brightness) == -1 ||
803 w9966_wReg_i2c(cam, 0x0b, cam->contrast) == -1 || 803 w9966_wReg_i2c(cam, 0x0b, cam->contrast) == -1 ||
@@ -807,7 +807,7 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
807 w9966_pdev_release(cam); 807 w9966_pdev_release(cam);
808 return -EIO; 808 return -EIO;
809 } 809 }
810 810
811 w9966_pdev_release(cam); 811 w9966_pdev_release(cam);
812 return 0; 812 return 0;
813 } 813 }
@@ -815,13 +815,13 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
815 { 815 {
816 int ret; 816 int ret;
817 struct video_window *vwin = arg; 817 struct video_window *vwin = arg;
818 818
819 if (vwin->flags != 0) 819 if (vwin->flags != 0)
820 return -EINVAL; 820 return -EINVAL;
821 if (vwin->clipcount != 0) 821 if (vwin->clipcount != 0)
822 return -EINVAL; 822 return -EINVAL;
823 if (vwin->width < 2 || vwin->width > W9966_WND_MAX_W) 823 if (vwin->width < 2 || vwin->width > W9966_WND_MAX_W)
824 return -EINVAL; 824 return -EINVAL;
825 if (vwin->height < 1 || vwin->height > W9966_WND_MAX_H) 825 if (vwin->height < 1 || vwin->height > W9966_WND_MAX_H)
826 return -EINVAL; 826 return -EINVAL;
827 827
@@ -829,12 +829,12 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
829 w9966_pdev_claim(cam); 829 w9966_pdev_claim(cam);
830 ret = w9966_setup(cam, 0, 0, 1023, 1023, vwin->width, vwin->height); 830 ret = w9966_setup(cam, 0, 0, 1023, 1023, vwin->width, vwin->height);
831 w9966_pdev_release(cam); 831 w9966_pdev_release(cam);
832 832
833 if (ret != 0) { 833 if (ret != 0) {
834 DPRINTF("VIDIOCSWIN: w9966_setup() failed.\n"); 834 DPRINTF("VIDIOCSWIN: w9966_setup() failed.\n");
835 return -EIO; 835 return -EIO;
836 } 836 }
837 837
838 return 0; 838 return 0;
839 } 839 }
840 case VIDIOCGWIN: 840 case VIDIOCGWIN:
@@ -846,7 +846,7 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
846 return 0; 846 return 0;
847 } 847 }
848 // Unimplemented 848 // Unimplemented
849 case VIDIOCCAPTURE: 849 case VIDIOCCAPTURE:
850 case VIDIOCGFBUF: 850 case VIDIOCGFBUF:
851 case VIDIOCSFBUF: 851 case VIDIOCSFBUF:
852 case VIDIOCKEY: 852 case VIDIOCKEY:
@@ -877,17 +877,17 @@ static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
877 unsigned char __user *dest = (unsigned char __user *)buf; 877 unsigned char __user *dest = (unsigned char __user *)buf;
878 unsigned long dleft = count; 878 unsigned long dleft = count;
879 unsigned char *tbuf; 879 unsigned char *tbuf;
880 880
881 // Why would anyone want more than this?? 881 // Why would anyone want more than this??
882 if (count > cam->width * cam->height * 2) 882 if (count > cam->width * cam->height * 2)
883 return -EINVAL; 883 return -EINVAL;
884 884
885 w9966_pdev_claim(cam); 885 w9966_pdev_claim(cam);
886 w9966_wReg(cam, 0x00, 0x02); // Reset ECP-FIFO buffer 886 w9966_wReg(cam, 0x00, 0x02); // Reset ECP-FIFO buffer
887 w9966_wReg(cam, 0x00, 0x00); // Return to normal operation 887 w9966_wReg(cam, 0x00, 0x00); // Return to normal operation
888 w9966_wReg(cam, 0x01, 0x98); // Enable capture 888 w9966_wReg(cam, 0x01, 0x98); // Enable capture
889 889
890 // write special capture-addr and negotiate into data transfer 890 // write special capture-addr and negotiate into data transfer
891 if ( 891 if (
892 (parport_negotiate(cam->pport, cam->ppmode|IEEE1284_ADDR) != 0 )|| 892 (parport_negotiate(cam->pport, cam->ppmode|IEEE1284_ADDR) != 0 )||
893 (parport_write(cam->pport, &addr, 1) != 1 )|| 893 (parport_write(cam->pport, &addr, 1) != 1 )||
@@ -906,7 +906,7 @@ static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
906 while(dleft > 0) 906 while(dleft > 0)
907 { 907 {
908 unsigned long tsize = (dleft > W9966_RBUFFER) ? W9966_RBUFFER : dleft; 908 unsigned long tsize = (dleft > W9966_RBUFFER) ? W9966_RBUFFER : dleft;
909 909
910 if (parport_read(cam->pport, tbuf, tsize) < tsize) { 910 if (parport_read(cam->pport, tbuf, tsize) < tsize) {
911 count = -EFAULT; 911 count = -EFAULT;
912 goto out; 912 goto out;
@@ -933,7 +933,7 @@ out:
933static void w9966_attach(struct parport *port) 933static void w9966_attach(struct parport *port)
934{ 934{
935 int i; 935 int i;
936 936
937 for (i = 0; i < W9966_MAXCAMS; i++) 937 for (i = 0; i < W9966_MAXCAMS; i++)
938 { 938 {
939 if (w9966_cams[i].dev_state != 0) // Cam is already assigned 939 if (w9966_cams[i].dev_state != 0) // Cam is already assigned
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index b57dec3782e0..20f211b55ad4 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -71,39 +71,39 @@ MODULE_SUPPORTED_DEVICE("Video");
71static int ovmod_load = W9968CF_OVMOD_LOAD; 71static int ovmod_load = W9968CF_OVMOD_LOAD;
72static unsigned short simcams = W9968CF_SIMCAMS; 72static unsigned short simcams = W9968CF_SIMCAMS;
73static short video_nr[]={[0 ... W9968CF_MAX_DEVICES-1] = -1}; /*-1=first free*/ 73static short video_nr[]={[0 ... W9968CF_MAX_DEVICES-1] = -1}; /*-1=first free*/
74static unsigned int packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1] = 74static unsigned int packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1] =
75 W9968CF_PACKET_SIZE}; 75 W9968CF_PACKET_SIZE};
76static unsigned short max_buffers[] = {[0 ... W9968CF_MAX_DEVICES-1] = 76static unsigned short max_buffers[] = {[0 ... W9968CF_MAX_DEVICES-1] =
77 W9968CF_BUFFERS}; 77 W9968CF_BUFFERS};
78static int double_buffer[] = {[0 ... W9968CF_MAX_DEVICES-1] = 78static int double_buffer[] = {[0 ... W9968CF_MAX_DEVICES-1] =
79 W9968CF_DOUBLE_BUFFER}; 79 W9968CF_DOUBLE_BUFFER};
80static int clamping[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLAMPING}; 80static int clamping[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLAMPING};
81static unsigned short filter_type[]= {[0 ... W9968CF_MAX_DEVICES-1] = 81static unsigned short filter_type[]= {[0 ... W9968CF_MAX_DEVICES-1] =
82 W9968CF_FILTER_TYPE}; 82 W9968CF_FILTER_TYPE};
83static int largeview[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_LARGEVIEW}; 83static int largeview[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_LARGEVIEW};
84static unsigned short decompression[] = {[0 ... W9968CF_MAX_DEVICES-1] = 84static unsigned short decompression[] = {[0 ... W9968CF_MAX_DEVICES-1] =
85 W9968CF_DECOMPRESSION}; 85 W9968CF_DECOMPRESSION};
86static int upscaling[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_UPSCALING}; 86static int upscaling[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_UPSCALING};
87static unsigned short force_palette[] = {[0 ... W9968CF_MAX_DEVICES-1] = 0}; 87static unsigned short force_palette[] = {[0 ... W9968CF_MAX_DEVICES-1] = 0};
88static int force_rgb[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_FORCE_RGB}; 88static int force_rgb[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_FORCE_RGB};
89static int autobright[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOBRIGHT}; 89static int autobright[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOBRIGHT};
90static int autoexp[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOEXP}; 90static int autoexp[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOEXP};
91static unsigned short lightfreq[] = {[0 ... W9968CF_MAX_DEVICES-1] = 91static unsigned short lightfreq[] = {[0 ... W9968CF_MAX_DEVICES-1] =
92 W9968CF_LIGHTFREQ}; 92 W9968CF_LIGHTFREQ};
93static int bandingfilter[] = {[0 ... W9968CF_MAX_DEVICES-1]= 93static int bandingfilter[] = {[0 ... W9968CF_MAX_DEVICES-1]=
94 W9968CF_BANDINGFILTER}; 94 W9968CF_BANDINGFILTER};
95static short clockdiv[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLOCKDIV}; 95static short clockdiv[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLOCKDIV};
96static int backlight[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_BACKLIGHT}; 96static int backlight[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_BACKLIGHT};
97static int mirror[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_MIRROR}; 97static int mirror[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_MIRROR};
98static int monochrome[] = {[0 ... W9968CF_MAX_DEVICES-1]=W9968CF_MONOCHROME}; 98static int monochrome[] = {[0 ... W9968CF_MAX_DEVICES-1]=W9968CF_MONOCHROME};
99static unsigned int brightness[] = {[0 ... W9968CF_MAX_DEVICES-1] = 99static unsigned int brightness[] = {[0 ... W9968CF_MAX_DEVICES-1] =
100 W9968CF_BRIGHTNESS}; 100 W9968CF_BRIGHTNESS};
101static unsigned int hue[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_HUE}; 101static unsigned int hue[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_HUE};
102static unsigned int colour[]={[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_COLOUR}; 102static unsigned int colour[]={[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_COLOUR};
103static unsigned int contrast[] = {[0 ... W9968CF_MAX_DEVICES-1] = 103static unsigned int contrast[] = {[0 ... W9968CF_MAX_DEVICES-1] =
104 W9968CF_CONTRAST}; 104 W9968CF_CONTRAST};
105static unsigned int whiteness[] = {[0 ... W9968CF_MAX_DEVICES-1] = 105static unsigned int whiteness[] = {[0 ... W9968CF_MAX_DEVICES-1] =
106 W9968CF_WHITENESS}; 106 W9968CF_WHITENESS};
107#ifdef W9968CF_DEBUG 107#ifdef W9968CF_DEBUG
108static unsigned short debug = W9968CF_DEBUG_LEVEL; 108static unsigned short debug = W9968CF_DEBUG_LEVEL;
109static int specific_debug = W9968CF_SPECIFIC_DEBUG; 109static int specific_debug = W9968CF_SPECIFIC_DEBUG;
@@ -145,251 +145,251 @@ module_param(specific_debug, bool, 0644);
145#endif 145#endif
146 146
147#ifdef CONFIG_KMOD 147#ifdef CONFIG_KMOD
148MODULE_PARM_DESC(ovmod_load, 148MODULE_PARM_DESC(ovmod_load,
149 "\n<0|1> Automatic 'ovcamchip' module loading." 149 "\n<0|1> Automatic 'ovcamchip' module loading."
150 "\n0 disabled, 1 enabled." 150 "\n0 disabled, 1 enabled."
151 "\nIf enabled,'insmod' searches for the required 'ovcamchip'" 151 "\nIf enabled,'insmod' searches for the required 'ovcamchip'"
152 "\nmodule in the system, according to its configuration, and" 152 "\nmodule in the system, according to its configuration, and"
153 "\nattempts to load that module automatically. This action is" 153 "\nattempts to load that module automatically. This action is"
154 "\nperformed once as soon as the 'w9968cf' module is loaded" 154 "\nperformed once as soon as the 'w9968cf' module is loaded"
155 "\ninto memory." 155 "\ninto memory."
156 "\nDefault value is "__MODULE_STRING(W9968CF_OVMOD_LOAD)"." 156 "\nDefault value is "__MODULE_STRING(W9968CF_OVMOD_LOAD)"."
157 "\n"); 157 "\n");
158#endif 158#endif
159MODULE_PARM_DESC(simcams, 159MODULE_PARM_DESC(simcams,
160 "\n<n> Number of cameras allowed to stream simultaneously." 160 "\n<n> Number of cameras allowed to stream simultaneously."
161 "\nn may vary from 0 to " 161 "\nn may vary from 0 to "
162 __MODULE_STRING(W9968CF_MAX_DEVICES)"." 162 __MODULE_STRING(W9968CF_MAX_DEVICES)"."
163 "\nDefault value is "__MODULE_STRING(W9968CF_SIMCAMS)"." 163 "\nDefault value is "__MODULE_STRING(W9968CF_SIMCAMS)"."
164 "\n"); 164 "\n");
165MODULE_PARM_DESC(video_nr, 165MODULE_PARM_DESC(video_nr,
166 "\n<-1|n[,...]> Specify V4L minor mode number." 166 "\n<-1|n[,...]> Specify V4L minor mode number."
167 "\n -1 = use next available (default)" 167 "\n -1 = use next available (default)"
168 "\n n = use minor number n (integer >= 0)" 168 "\n n = use minor number n (integer >= 0)"
169 "\nYou can specify up to "__MODULE_STRING(W9968CF_MAX_DEVICES) 169 "\nYou can specify up to "__MODULE_STRING(W9968CF_MAX_DEVICES)
170 " cameras this way." 170 " cameras this way."
171 "\nFor example:" 171 "\nFor example:"
172 "\nvideo_nr=-1,2,-1 would assign minor number 2 to" 172 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
173 "\nthe second camera and use auto for the first" 173 "\nthe second camera and use auto for the first"
174 "\none and for every other camera." 174 "\none and for every other camera."
175 "\n"); 175 "\n");
176MODULE_PARM_DESC(packet_size, 176MODULE_PARM_DESC(packet_size,
177 "\n<n[,...]> Specify the maximum data payload" 177 "\n<n[,...]> Specify the maximum data payload"
178 "\nsize in bytes for alternate settings, for each device." 178 "\nsize in bytes for alternate settings, for each device."
179 "\nn is scaled between 63 and 1023 " 179 "\nn is scaled between 63 and 1023 "
180 "(default is "__MODULE_STRING(W9968CF_PACKET_SIZE)")." 180 "(default is "__MODULE_STRING(W9968CF_PACKET_SIZE)")."
181 "\n"); 181 "\n");
182MODULE_PARM_DESC(max_buffers, 182MODULE_PARM_DESC(max_buffers,
183 "\n<n[,...]> For advanced users." 183 "\n<n[,...]> For advanced users."
184 "\nSpecify the maximum number of video frame buffers" 184 "\nSpecify the maximum number of video frame buffers"
185 "\nto allocate for each device, from 2 to " 185 "\nto allocate for each device, from 2 to "
186 __MODULE_STRING(W9968CF_MAX_BUFFERS) 186 __MODULE_STRING(W9968CF_MAX_BUFFERS)
187 ". (default is "__MODULE_STRING(W9968CF_BUFFERS)")." 187 ". (default is "__MODULE_STRING(W9968CF_BUFFERS)")."
188 "\n"); 188 "\n");
189MODULE_PARM_DESC(double_buffer, 189MODULE_PARM_DESC(double_buffer,
190 "\n<0|1[,...]> " 190 "\n<0|1[,...]> "
191 "Hardware double buffering: 0 disabled, 1 enabled." 191 "Hardware double buffering: 0 disabled, 1 enabled."
192 "\nIt should be enabled if you want smooth video output: if" 192 "\nIt should be enabled if you want smooth video output: if"
193 "\nyou obtain out of sync. video, disable it, or try to" 193 "\nyou obtain out of sync. video, disable it, or try to"
194 "\ndecrease the 'clockdiv' module parameter value." 194 "\ndecrease the 'clockdiv' module parameter value."
195 "\nDefault value is "__MODULE_STRING(W9968CF_DOUBLE_BUFFER) 195 "\nDefault value is "__MODULE_STRING(W9968CF_DOUBLE_BUFFER)
196 " for every device." 196 " for every device."
197 "\n"); 197 "\n");
198MODULE_PARM_DESC(clamping, 198MODULE_PARM_DESC(clamping,
199 "\n<0|1[,...]> Video data clamping: 0 disabled, 1 enabled." 199 "\n<0|1[,...]> Video data clamping: 0 disabled, 1 enabled."
200 "\nDefault value is "__MODULE_STRING(W9968CF_CLAMPING) 200 "\nDefault value is "__MODULE_STRING(W9968CF_CLAMPING)
201 " for every device." 201 " for every device."
202 "\n"); 202 "\n");
203MODULE_PARM_DESC(filter_type, 203MODULE_PARM_DESC(filter_type,
204 "\n<0|1|2[,...]> Video filter type." 204 "\n<0|1|2[,...]> Video filter type."
205 "\n0 none, 1 (1-2-1) 3-tap filter, " 205 "\n0 none, 1 (1-2-1) 3-tap filter, "
206 "2 (2-3-6-3-2) 5-tap filter." 206 "2 (2-3-6-3-2) 5-tap filter."
207 "\nDefault value is "__MODULE_STRING(W9968CF_FILTER_TYPE) 207 "\nDefault value is "__MODULE_STRING(W9968CF_FILTER_TYPE)
208 " for every device." 208 " for every device."
209 "\nThe filter is used to reduce noise and aliasing artifacts" 209 "\nThe filter is used to reduce noise and aliasing artifacts"
210 "\nproduced by the CCD or CMOS image sensor, and the scaling" 210 "\nproduced by the CCD or CMOS image sensor, and the scaling"
211 " process." 211 " process."
212 "\n"); 212 "\n");
213MODULE_PARM_DESC(largeview, 213MODULE_PARM_DESC(largeview,
214 "\n<0|1[,...]> Large view: 0 disabled, 1 enabled." 214 "\n<0|1[,...]> Large view: 0 disabled, 1 enabled."
215 "\nDefault value is "__MODULE_STRING(W9968CF_LARGEVIEW) 215 "\nDefault value is "__MODULE_STRING(W9968CF_LARGEVIEW)
216 " for every device." 216 " for every device."
217 "\n"); 217 "\n");
218MODULE_PARM_DESC(upscaling, 218MODULE_PARM_DESC(upscaling,
219 "\n<0|1[,...]> Software scaling (for non-compressed video):" 219 "\n<0|1[,...]> Software scaling (for non-compressed video):"
220 "\n0 disabled, 1 enabled." 220 "\n0 disabled, 1 enabled."
221 "\nDisable it if you have a slow CPU or you don't have" 221 "\nDisable it if you have a slow CPU or you don't have"
222 " enough memory." 222 " enough memory."
223 "\nDefault value is "__MODULE_STRING(W9968CF_UPSCALING) 223 "\nDefault value is "__MODULE_STRING(W9968CF_UPSCALING)
224 " for every device." 224 " for every device."
225 "\nIf 'w9968cf-vpp' is not present, this parameter is" 225 "\nIf 'w9968cf-vpp' is not present, this parameter is"
226 " set to 0." 226 " set to 0."
227 "\n"); 227 "\n");
228MODULE_PARM_DESC(decompression, 228MODULE_PARM_DESC(decompression,
229 "\n<0|1|2[,...]> Software video decompression:" 229 "\n<0|1|2[,...]> Software video decompression:"
230 "\n- 0 disables decompression (doesn't allow formats needing" 230 "\n- 0 disables decompression (doesn't allow formats needing"
231 " decompression)" 231 " decompression)"
232 "\n- 1 forces decompression (allows formats needing" 232 "\n- 1 forces decompression (allows formats needing"
233 " decompression only);" 233 " decompression only);"
234 "\n- 2 allows any permitted formats." 234 "\n- 2 allows any permitted formats."
235 "\nFormats supporting compressed video are YUV422P and" 235 "\nFormats supporting compressed video are YUV422P and"
236 " YUV420P/YUV420 " 236 " YUV420P/YUV420 "
237 "\nin any resolutions where both width and height are " 237 "\nin any resolutions where both width and height are "
238 "a multiple of 16." 238 "a multiple of 16."
239 "\nDefault value is "__MODULE_STRING(W9968CF_DECOMPRESSION) 239 "\nDefault value is "__MODULE_STRING(W9968CF_DECOMPRESSION)
240 " for every device." 240 " for every device."
241 "\nIf 'w9968cf-vpp' is not present, forcing decompression is " 241 "\nIf 'w9968cf-vpp' is not present, forcing decompression is "
242 "\nnot allowed; in this case this parameter is set to 2." 242 "\nnot allowed; in this case this parameter is set to 2."
243 "\n"); 243 "\n");
244MODULE_PARM_DESC(force_palette, 244MODULE_PARM_DESC(force_palette,
245 "\n<0" 245 "\n<0"
246 "|" __MODULE_STRING(VIDEO_PALETTE_UYVY) 246 "|" __MODULE_STRING(VIDEO_PALETTE_UYVY)
247 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420) 247 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420)
248 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422P) 248 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422P)
249 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420P) 249 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420P)
250 "|" __MODULE_STRING(VIDEO_PALETTE_YUYV) 250 "|" __MODULE_STRING(VIDEO_PALETTE_YUYV)
251 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422) 251 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422)
252 "|" __MODULE_STRING(VIDEO_PALETTE_GREY) 252 "|" __MODULE_STRING(VIDEO_PALETTE_GREY)
253 "|" __MODULE_STRING(VIDEO_PALETTE_RGB555) 253 "|" __MODULE_STRING(VIDEO_PALETTE_RGB555)
254 "|" __MODULE_STRING(VIDEO_PALETTE_RGB565) 254 "|" __MODULE_STRING(VIDEO_PALETTE_RGB565)
255 "|" __MODULE_STRING(VIDEO_PALETTE_RGB24) 255 "|" __MODULE_STRING(VIDEO_PALETTE_RGB24)
256 "|" __MODULE_STRING(VIDEO_PALETTE_RGB32) 256 "|" __MODULE_STRING(VIDEO_PALETTE_RGB32)
257 "[,...]>" 257 "[,...]>"
258 " Force picture palette." 258 " Force picture palette."
259 "\nIn order:" 259 "\nIn order:"
260 "\n- 0 allows any of the following formats:" 260 "\n- 0 allows any of the following formats:"
261 "\n- UYVY 16 bpp - Original video, compression disabled" 261 "\n- UYVY 16 bpp - Original video, compression disabled"
262 "\n- YUV420 12 bpp - Original video, compression enabled" 262 "\n- YUV420 12 bpp - Original video, compression enabled"
263 "\n- YUV422P 16 bpp - Original video, compression enabled" 263 "\n- YUV422P 16 bpp - Original video, compression enabled"
264 "\n- YUV420P 12 bpp - Original video, compression enabled" 264 "\n- YUV420P 12 bpp - Original video, compression enabled"
265 "\n- YUVY 16 bpp - Software conversion from UYVY" 265 "\n- YUVY 16 bpp - Software conversion from UYVY"
266 "\n- YUV422 16 bpp - Software conversion from UYVY" 266 "\n- YUV422 16 bpp - Software conversion from UYVY"
267 "\n- GREY 8 bpp - Software conversion from UYVY" 267 "\n- GREY 8 bpp - Software conversion from UYVY"
268 "\n- RGB555 16 bpp - Software conversion from UYVY" 268 "\n- RGB555 16 bpp - Software conversion from UYVY"
269 "\n- RGB565 16 bpp - Software conversion from UYVY" 269 "\n- RGB565 16 bpp - Software conversion from UYVY"
270 "\n- RGB24 24 bpp - Software conversion from UYVY" 270 "\n- RGB24 24 bpp - Software conversion from UYVY"
271 "\n- RGB32 32 bpp - Software conversion from UYVY" 271 "\n- RGB32 32 bpp - Software conversion from UYVY"
272 "\nWhen not 0, this parameter will override 'decompression'." 272 "\nWhen not 0, this parameter will override 'decompression'."
273 "\nDefault value is 0 for every device." 273 "\nDefault value is 0 for every device."
274 "\nInitial palette is " 274 "\nInitial palette is "
275 __MODULE_STRING(W9968CF_PALETTE_DECOMP_ON)"." 275 __MODULE_STRING(W9968CF_PALETTE_DECOMP_ON)"."
276 "\nIf 'w9968cf-vpp' is not present, this parameter is" 276 "\nIf 'w9968cf-vpp' is not present, this parameter is"
277 " set to 9 (UYVY)." 277 " set to 9 (UYVY)."
278 "\n"); 278 "\n");
279MODULE_PARM_DESC(force_rgb, 279MODULE_PARM_DESC(force_rgb,
280 "\n<0|1[,...]> Read RGB video data instead of BGR:" 280 "\n<0|1[,...]> Read RGB video data instead of BGR:"
281 "\n 1 = use RGB component ordering." 281 "\n 1 = use RGB component ordering."
282 "\n 0 = use BGR component ordering." 282 "\n 0 = use BGR component ordering."
283 "\nThis parameter has effect when using RGBX palettes only." 283 "\nThis parameter has effect when using RGBX palettes only."
284 "\nDefault value is "__MODULE_STRING(W9968CF_FORCE_RGB) 284 "\nDefault value is "__MODULE_STRING(W9968CF_FORCE_RGB)
285 " for every device." 285 " for every device."
286 "\n"); 286 "\n");
287MODULE_PARM_DESC(autobright, 287MODULE_PARM_DESC(autobright,
288 "\n<0|1[,...]> Image sensor automatically changes brightness:" 288 "\n<0|1[,...]> Image sensor automatically changes brightness:"
289 "\n 0 = no, 1 = yes" 289 "\n 0 = no, 1 = yes"
290 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOBRIGHT) 290 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOBRIGHT)
291 " for every device." 291 " for every device."
292 "\n"); 292 "\n");
293MODULE_PARM_DESC(autoexp, 293MODULE_PARM_DESC(autoexp,
294 "\n<0|1[,...]> Image sensor automatically changes exposure:" 294 "\n<0|1[,...]> Image sensor automatically changes exposure:"
295 "\n 0 = no, 1 = yes" 295 "\n 0 = no, 1 = yes"
296 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOEXP) 296 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOEXP)
297 " for every device." 297 " for every device."
298 "\n"); 298 "\n");
299MODULE_PARM_DESC(lightfreq, 299MODULE_PARM_DESC(lightfreq,
300 "\n<50|60[,...]> Light frequency in Hz:" 300 "\n<50|60[,...]> Light frequency in Hz:"
301 "\n 50 for European and Asian lighting," 301 "\n 50 for European and Asian lighting,"
302 " 60 for American lighting." 302 " 60 for American lighting."
303 "\nDefault value is "__MODULE_STRING(W9968CF_LIGHTFREQ) 303 "\nDefault value is "__MODULE_STRING(W9968CF_LIGHTFREQ)
304 " for every device." 304 " for every device."
305 "\n"); 305 "\n");
306MODULE_PARM_DESC(bandingfilter, 306MODULE_PARM_DESC(bandingfilter,
307 "\n<0|1[,...]> Banding filter to reduce effects of" 307 "\n<0|1[,...]> Banding filter to reduce effects of"
308 " fluorescent lighting:" 308 " fluorescent lighting:"
309 "\n 0 disabled, 1 enabled." 309 "\n 0 disabled, 1 enabled."
310 "\nThis filter tries to reduce the pattern of horizontal" 310 "\nThis filter tries to reduce the pattern of horizontal"
311 "\nlight/dark bands caused by some (usually fluorescent)" 311 "\nlight/dark bands caused by some (usually fluorescent)"
312 " lighting." 312 " lighting."
313 "\nDefault value is "__MODULE_STRING(W9968CF_BANDINGFILTER) 313 "\nDefault value is "__MODULE_STRING(W9968CF_BANDINGFILTER)
314 " for every device." 314 " for every device."
315 "\n"); 315 "\n");
316MODULE_PARM_DESC(clockdiv, 316MODULE_PARM_DESC(clockdiv,
317 "\n<-1|n[,...]> " 317 "\n<-1|n[,...]> "
318 "Force pixel clock divisor to a specific value (for experts):" 318 "Force pixel clock divisor to a specific value (for experts):"
319 "\n n may vary from 0 to 127." 319 "\n n may vary from 0 to 127."
320 "\n -1 for automatic value." 320 "\n -1 for automatic value."
321 "\nSee also the 'double_buffer' module parameter." 321 "\nSee also the 'double_buffer' module parameter."
322 "\nDefault value is "__MODULE_STRING(W9968CF_CLOCKDIV) 322 "\nDefault value is "__MODULE_STRING(W9968CF_CLOCKDIV)
323 " for every device." 323 " for every device."
324 "\n"); 324 "\n");
325MODULE_PARM_DESC(backlight, 325MODULE_PARM_DESC(backlight,
326 "\n<0|1[,...]> Objects are lit from behind:" 326 "\n<0|1[,...]> Objects are lit from behind:"
327 "\n 0 = no, 1 = yes" 327 "\n 0 = no, 1 = yes"
328 "\nDefault value is "__MODULE_STRING(W9968CF_BACKLIGHT) 328 "\nDefault value is "__MODULE_STRING(W9968CF_BACKLIGHT)
329 " for every device." 329 " for every device."
330 "\n"); 330 "\n");
331MODULE_PARM_DESC(mirror, 331MODULE_PARM_DESC(mirror,
332 "\n<0|1[,...]> Reverse image horizontally:" 332 "\n<0|1[,...]> Reverse image horizontally:"
333 "\n 0 = no, 1 = yes" 333 "\n 0 = no, 1 = yes"
334 "\nDefault value is "__MODULE_STRING(W9968CF_MIRROR) 334 "\nDefault value is "__MODULE_STRING(W9968CF_MIRROR)
335 " for every device." 335 " for every device."
336 "\n"); 336 "\n");
337MODULE_PARM_DESC(monochrome, 337MODULE_PARM_DESC(monochrome,
338 "\n<0|1[,...]> Use image sensor as monochrome sensor:" 338 "\n<0|1[,...]> Use image sensor as monochrome sensor:"
339 "\n 0 = no, 1 = yes" 339 "\n 0 = no, 1 = yes"
340 "\nNot all the sensors support monochrome color." 340 "\nNot all the sensors support monochrome color."
341 "\nDefault value is "__MODULE_STRING(W9968CF_MONOCHROME) 341 "\nDefault value is "__MODULE_STRING(W9968CF_MONOCHROME)
342 " for every device." 342 " for every device."
343 "\n"); 343 "\n");
344MODULE_PARM_DESC(brightness, 344MODULE_PARM_DESC(brightness,
345 "\n<n[,...]> Set picture brightness (0-65535)." 345 "\n<n[,...]> Set picture brightness (0-65535)."
346 "\nDefault value is "__MODULE_STRING(W9968CF_BRIGHTNESS) 346 "\nDefault value is "__MODULE_STRING(W9968CF_BRIGHTNESS)
347 " for every device." 347 " for every device."
348 "\nThis parameter has no effect if 'autobright' is enabled." 348 "\nThis parameter has no effect if 'autobright' is enabled."
349 "\n"); 349 "\n");
350MODULE_PARM_DESC(hue, 350MODULE_PARM_DESC(hue,
351 "\n<n[,...]> Set picture hue (0-65535)." 351 "\n<n[,...]> Set picture hue (0-65535)."
352 "\nDefault value is "__MODULE_STRING(W9968CF_HUE) 352 "\nDefault value is "__MODULE_STRING(W9968CF_HUE)
353 " for every device." 353 " for every device."
354 "\n"); 354 "\n");
355MODULE_PARM_DESC(colour, 355MODULE_PARM_DESC(colour,
356 "\n<n[,...]> Set picture saturation (0-65535)." 356 "\n<n[,...]> Set picture saturation (0-65535)."
357 "\nDefault value is "__MODULE_STRING(W9968CF_COLOUR) 357 "\nDefault value is "__MODULE_STRING(W9968CF_COLOUR)
358 " for every device." 358 " for every device."
359 "\n"); 359 "\n");
360MODULE_PARM_DESC(contrast, 360MODULE_PARM_DESC(contrast,
361 "\n<n[,...]> Set picture contrast (0-65535)." 361 "\n<n[,...]> Set picture contrast (0-65535)."
362 "\nDefault value is "__MODULE_STRING(W9968CF_CONTRAST) 362 "\nDefault value is "__MODULE_STRING(W9968CF_CONTRAST)
363 " for every device." 363 " for every device."
364 "\n"); 364 "\n");
365MODULE_PARM_DESC(whiteness, 365MODULE_PARM_DESC(whiteness,
366 "\n<n[,...]> Set picture whiteness (0-65535)." 366 "\n<n[,...]> Set picture whiteness (0-65535)."
367 "\nDefault value is "__MODULE_STRING(W9968CF_WHITENESS) 367 "\nDefault value is "__MODULE_STRING(W9968CF_WHITENESS)
368 " for every device." 368 " for every device."
369 "\n"); 369 "\n");
370#ifdef W9968CF_DEBUG 370#ifdef W9968CF_DEBUG
371MODULE_PARM_DESC(debug, 371MODULE_PARM_DESC(debug,
372 "\n<n> Debugging information level, from 0 to 6:" 372 "\n<n> Debugging information level, from 0 to 6:"
373 "\n0 = none (use carefully)" 373 "\n0 = none (use carefully)"
374 "\n1 = critical errors" 374 "\n1 = critical errors"
375 "\n2 = significant informations" 375 "\n2 = significant informations"
376 "\n3 = configuration or general messages" 376 "\n3 = configuration or general messages"
377 "\n4 = warnings" 377 "\n4 = warnings"
378 "\n5 = called functions" 378 "\n5 = called functions"
379 "\n6 = function internals" 379 "\n6 = function internals"
380 "\nLevel 5 and 6 are useful for testing only, when only " 380 "\nLevel 5 and 6 are useful for testing only, when only "
381 "one device is used." 381 "one device is used."
382 "\nDefault value is "__MODULE_STRING(W9968CF_DEBUG_LEVEL)"." 382 "\nDefault value is "__MODULE_STRING(W9968CF_DEBUG_LEVEL)"."
383 "\n"); 383 "\n");
384MODULE_PARM_DESC(specific_debug, 384MODULE_PARM_DESC(specific_debug,
385 "\n<0|1> Enable or disable specific debugging messages:" 385 "\n<0|1> Enable or disable specific debugging messages:"
386 "\n0 = print messages concerning every level" 386 "\n0 = print messages concerning every level"
387 " <= 'debug' level." 387 " <= 'debug' level."
388 "\n1 = print messages concerning the level" 388 "\n1 = print messages concerning the level"
389 " indicated by 'debug'." 389 " indicated by 'debug'."
390 "\nDefault value is " 390 "\nDefault value is "
391 __MODULE_STRING(W9968CF_SPECIFIC_DEBUG)"." 391 __MODULE_STRING(W9968CF_SPECIFIC_DEBUG)"."
392 "\n"); 392 "\n");
393#endif /* W9968CF_DEBUG */ 393#endif /* W9968CF_DEBUG */
394 394
395 395
@@ -406,7 +406,7 @@ static int w9968cf_mmap(struct file*, struct vm_area_struct*);
406static int w9968cf_ioctl(struct inode*, struct file*, unsigned, unsigned long); 406static int w9968cf_ioctl(struct inode*, struct file*, unsigned, unsigned long);
407static ssize_t w9968cf_read(struct file*, char __user *, size_t, loff_t*); 407static ssize_t w9968cf_read(struct file*, char __user *, size_t, loff_t*);
408static int w9968cf_v4l_ioctl(struct inode*, struct file*, unsigned int, 408static int w9968cf_v4l_ioctl(struct inode*, struct file*, unsigned int,
409 void __user *); 409 void __user *);
410 410
411/* USB-specific */ 411/* USB-specific */
412static int w9968cf_start_transfer(struct w9968cf_device*); 412static int w9968cf_start_transfer(struct w9968cf_device*);
@@ -428,25 +428,25 @@ static int w9968cf_smbus_write_ack(struct w9968cf_device*);
428static int w9968cf_smbus_read_ack(struct w9968cf_device*); 428static int w9968cf_smbus_read_ack(struct w9968cf_device*);
429static int w9968cf_smbus_refresh_bus(struct w9968cf_device*); 429static int w9968cf_smbus_refresh_bus(struct w9968cf_device*);
430static int w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam, 430static int w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
431 u16 address, u8* value); 431 u16 address, u8* value);
432static int w9968cf_i2c_adap_read_byte_data(struct w9968cf_device*, u16 address, 432static int w9968cf_i2c_adap_read_byte_data(struct w9968cf_device*, u16 address,
433 u8 subaddress, u8* value); 433 u8 subaddress, u8* value);
434static int w9968cf_i2c_adap_write_byte(struct w9968cf_device*, 434static int w9968cf_i2c_adap_write_byte(struct w9968cf_device*,
435 u16 address, u8 subaddress); 435 u16 address, u8 subaddress);
436static int w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device*, 436static int w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device*,
437 u16 address, u8 subaddress, 437 u16 address, u8 subaddress,
438 u8 value); 438 u8 value);
439 439
440/* I2C interface to kernel */ 440/* I2C interface to kernel */
441static int w9968cf_i2c_init(struct w9968cf_device*); 441static int w9968cf_i2c_init(struct w9968cf_device*);
442static int w9968cf_i2c_smbus_xfer(struct i2c_adapter*, u16 addr, 442static int w9968cf_i2c_smbus_xfer(struct i2c_adapter*, u16 addr,
443 unsigned short flags, char read_write, 443 unsigned short flags, char read_write,
444 u8 command, int size, union i2c_smbus_data*); 444 u8 command, int size, union i2c_smbus_data*);
445static u32 w9968cf_i2c_func(struct i2c_adapter*); 445static u32 w9968cf_i2c_func(struct i2c_adapter*);
446static int w9968cf_i2c_attach_inform(struct i2c_client*); 446static int w9968cf_i2c_attach_inform(struct i2c_client*);
447static int w9968cf_i2c_detach_inform(struct i2c_client*); 447static int w9968cf_i2c_detach_inform(struct i2c_client*);
448static int w9968cf_i2c_control(struct i2c_adapter*, unsigned int cmd, 448static int w9968cf_i2c_control(struct i2c_adapter*, unsigned int cmd,
449 unsigned long arg); 449 unsigned long arg);
450 450
451/* Memory management */ 451/* Memory management */
452static void* rvmalloc(unsigned long size); 452static void* rvmalloc(unsigned long size);
@@ -458,17 +458,17 @@ static int w9968cf_allocate_memory(struct w9968cf_device*);
458static int w9968cf_sensor_set_control(struct w9968cf_device*,int cid,int val); 458static int w9968cf_sensor_set_control(struct w9968cf_device*,int cid,int val);
459static int w9968cf_sensor_get_control(struct w9968cf_device*,int cid,int *val); 459static int w9968cf_sensor_get_control(struct w9968cf_device*,int cid,int *val);
460static int w9968cf_sensor_cmd(struct w9968cf_device*, 460static int w9968cf_sensor_cmd(struct w9968cf_device*,
461 unsigned int cmd, void *arg); 461 unsigned int cmd, void *arg);
462static int w9968cf_sensor_init(struct w9968cf_device*); 462static int w9968cf_sensor_init(struct w9968cf_device*);
463static int w9968cf_sensor_update_settings(struct w9968cf_device*); 463static int w9968cf_sensor_update_settings(struct w9968cf_device*);
464static int w9968cf_sensor_get_picture(struct w9968cf_device*); 464static int w9968cf_sensor_get_picture(struct w9968cf_device*);
465static int w9968cf_sensor_update_picture(struct w9968cf_device*, 465static int w9968cf_sensor_update_picture(struct w9968cf_device*,
466 struct video_picture pict); 466 struct video_picture pict);
467 467
468/* Other helper functions */ 468/* Other helper functions */
469static void w9968cf_configure_camera(struct w9968cf_device*,struct usb_device*, 469static void w9968cf_configure_camera(struct w9968cf_device*,struct usb_device*,
470 enum w9968cf_model_id, 470 enum w9968cf_model_id,
471 const unsigned short dev_nr); 471 const unsigned short dev_nr);
472static void w9968cf_adjust_configuration(struct w9968cf_device*); 472static void w9968cf_adjust_configuration(struct w9968cf_device*);
473static int w9968cf_turn_on_led(struct w9968cf_device*); 473static int w9968cf_turn_on_led(struct w9968cf_device*);
474static int w9968cf_init_chip(struct w9968cf_device*); 474static int w9968cf_init_chip(struct w9968cf_device*);
@@ -477,8 +477,8 @@ static inline u16 w9968cf_valid_depth(u16 palette);
477static inline u8 w9968cf_need_decompression(u16 palette); 477static inline u8 w9968cf_need_decompression(u16 palette);
478static int w9968cf_set_picture(struct w9968cf_device*, struct video_picture); 478static int w9968cf_set_picture(struct w9968cf_device*, struct video_picture);
479static int w9968cf_set_window(struct w9968cf_device*, struct video_window); 479static int w9968cf_set_window(struct w9968cf_device*, struct video_window);
480static int w9968cf_postprocess_frame(struct w9968cf_device*, 480static int w9968cf_postprocess_frame(struct w9968cf_device*,
481 struct w9968cf_frame_t*); 481 struct w9968cf_frame_t*);
482static int w9968cf_adjust_window_size(struct w9968cf_device*, u16* w, u16* h); 482static int w9968cf_adjust_window_size(struct w9968cf_device*, u16* w, u16* h);
483static void w9968cf_init_framelist(struct w9968cf_device*); 483static void w9968cf_init_framelist(struct w9968cf_device*);
484static void w9968cf_push_frame(struct w9968cf_device*, u8 f_num); 484static void w9968cf_push_frame(struct w9968cf_device*, u8 f_num);
@@ -497,11 +497,11 @@ struct w9968cf_symbolic_list {
497 const char *name; 497 const char *name;
498}; 498};
499 499
500/*-------------------------------------------------------------------------- 500/*--------------------------------------------------------------------------
501 Returns the name of the matching element in the symbolic_list array. The 501 Returns the name of the matching element in the symbolic_list array. The
502 end of the list must be marked with an element that has a NULL name. 502 end of the list must be marked with an element that has a NULL name.
503 --------------------------------------------------------------------------*/ 503 --------------------------------------------------------------------------*/
504static inline const char * 504static inline const char *
505symbolic(struct w9968cf_symbolic_list list[], const int num) 505symbolic(struct w9968cf_symbolic_list list[], const int num)
506{ 506{
507 int i; 507 int i;
@@ -568,7 +568,7 @@ static struct w9968cf_symbolic_list v4l1_plist[] = {
568static struct w9968cf_symbolic_list decoder_errlist[] = { 568static struct w9968cf_symbolic_list decoder_errlist[] = {
569 { W9968CF_DEC_ERR_CORRUPTED_DATA, "Corrupted data" }, 569 { W9968CF_DEC_ERR_CORRUPTED_DATA, "Corrupted data" },
570 { W9968CF_DEC_ERR_BUF_OVERFLOW, "Buffer overflow" }, 570 { W9968CF_DEC_ERR_BUF_OVERFLOW, "Buffer overflow" },
571 { W9968CF_DEC_ERR_NO_SOI, "SOI marker not found" }, 571 { W9968CF_DEC_ERR_NO_SOI, "SOI marker not found" },
572 { W9968CF_DEC_ERR_NO_SOF0, "SOF0 marker not found" }, 572 { W9968CF_DEC_ERR_NO_SOF0, "SOF0 marker not found" },
573 { W9968CF_DEC_ERR_NO_SOS, "SOS marker not found" }, 573 { W9968CF_DEC_ERR_NO_SOS, "SOS marker not found" },
574 { W9968CF_DEC_ERR_NO_EOI, "EOI marker not found" }, 574 { W9968CF_DEC_ERR_NO_EOI, "EOI marker not found" },
@@ -695,7 +695,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
695 bpp = (w9968cf_vpp) ? 4 : 2; 695 bpp = (w9968cf_vpp) ? 4 : 2;
696 if (cam->upscaling) 696 if (cam->upscaling)
697 vpp_bufsize = max(W9968CF_MAX_WIDTH*W9968CF_MAX_HEIGHT*bpp, 697 vpp_bufsize = max(W9968CF_MAX_WIDTH*W9968CF_MAX_HEIGHT*bpp,
698 cam->maxwidth*cam->maxheight*bpp); 698 cam->maxwidth*cam->maxheight*bpp);
699 else 699 else
700 vpp_bufsize = cam->maxwidth*cam->maxheight*bpp; 700 vpp_bufsize = cam->maxwidth*cam->maxheight*bpp;
701 701
@@ -704,7 +704,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
704 if (!(cam->transfer_buffer[i] = 704 if (!(cam->transfer_buffer[i] =
705 kzalloc(W9968CF_ISO_PACKETS*p_size, GFP_KERNEL))) { 705 kzalloc(W9968CF_ISO_PACKETS*p_size, GFP_KERNEL))) {
706 DBG(1, "Couldn't allocate memory for the isochronous " 706 DBG(1, "Couldn't allocate memory for the isochronous "
707 "transfer buffers (%u bytes)", 707 "transfer buffers (%u bytes)",
708 p_size * W9968CF_ISO_PACKETS) 708 p_size * W9968CF_ISO_PACKETS)
709 return -ENOMEM; 709 return -ENOMEM;
710 } 710 }
@@ -780,7 +780,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
780 of the next video frame; if an error is encountered in a packet, the entire 780 of the next video frame; if an error is encountered in a packet, the entire
781 video frame is discarded and grabbed again. 781 video frame is discarded and grabbed again.
782 If there are no requested frames in the FIFO list, packets are collected into 782 If there are no requested frames in the FIFO list, packets are collected into
783 a temporary buffer. 783 a temporary buffer.
784 --------------------------------------------------------------------------*/ 784 --------------------------------------------------------------------------*/
785static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs) 785static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
786{ 786{
@@ -799,7 +799,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
799 /* "(*f)" will be used instead of "cam->frame_current" */ 799 /* "(*f)" will be used instead of "cam->frame_current" */
800 f = &cam->frame_current; 800 f = &cam->frame_current;
801 801
802 /* If a frame has been requested and we are grabbing into 802 /* If a frame has been requested and we are grabbing into
803 the temporary frame, we'll switch to that requested frame */ 803 the temporary frame, we'll switch to that requested frame */
804 if ((*f) == &cam->frame_tmp && *cam->requested_frame) { 804 if ((*f) == &cam->frame_tmp && *cam->requested_frame) {
805 if (cam->frame_tmp.status == F_GRABBING) { 805 if (cam->frame_tmp.status == F_GRABBING) {
@@ -808,7 +808,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
808 (*f)->length = cam->frame_tmp.length; 808 (*f)->length = cam->frame_tmp.length;
809 memcpy((*f)->buffer, cam->frame_tmp.buffer, 809 memcpy((*f)->buffer, cam->frame_tmp.buffer,
810 (*f)->length); 810 (*f)->length);
811 DBG(6, "Switched from temp. frame to frame #%d", 811 DBG(6, "Switched from temp. frame to frame #%d",
812 (*f)->number) 812 (*f)->number)
813 } 813 }
814 } 814 }
@@ -850,7 +850,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
850 850
851 if (cam->vpp_flag & VPP_DECOMPRESSION) { 851 if (cam->vpp_flag & VPP_DECOMPRESSION) {
852 err = w9968cf_vpp->check_headers((*f)->buffer, 852 err = w9968cf_vpp->check_headers((*f)->buffer,
853 (*f)->length); 853 (*f)->length);
854 if (err) { 854 if (err) {
855 DBG(4, "Skip corrupted frame: %s", 855 DBG(4, "Skip corrupted frame: %s",
856 symbolic(decoder_errlist, err)) 856 symbolic(decoder_errlist, err))
@@ -975,7 +975,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
975 cam->frame_current = &cam->frame_tmp; 975 cam->frame_current = &cam->frame_tmp;
976 976
977 if (!(cam->vpp_flag & VPP_DECOMPRESSION)) 977 if (!(cam->vpp_flag & VPP_DECOMPRESSION))
978 DBG(5, "Isochronous transfer size: %lu bytes/frame", 978 DBG(5, "Isochronous transfer size: %lu bytes/frame",
979 (unsigned long)t_size*2) 979 (unsigned long)t_size*2)
980 980
981 DBG(5, "Starting the isochronous transfer...") 981 DBG(5, "Starting the isochronous transfer...")
@@ -992,7 +992,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
992 usb_free_urb(cam->urb[j]); 992 usb_free_urb(cam->urb[j]);
993 } 993 }
994 DBG(1, "Couldn't send a transfer request to the " 994 DBG(1, "Couldn't send a transfer request to the "
995 "USB core (error #%d, %s)", err, 995 "USB core (error #%d, %s)", err,
996 symbolic(urb_errlist, err)) 996 symbolic(urb_errlist, err))
997 return err; 997 return err;
998 } 998 }
@@ -1016,7 +1016,7 @@ static int w9968cf_stop_transfer(struct w9968cf_device* cam)
1016 if (!cam->streaming) 1016 if (!cam->streaming)
1017 return 0; 1017 return 0;
1018 1018
1019 /* This avoids race conditions with usb_submit_urb() 1019 /* This avoids race conditions with usb_submit_urb()
1020 in the URB completition handler */ 1020 in the URB completition handler */
1021 spin_lock_irqsave(&cam->urb_lock, lock_flags); 1021 spin_lock_irqsave(&cam->urb_lock, lock_flags);
1022 cam->streaming = 0; 1022 cam->streaming = 0;
@@ -1050,7 +1050,7 @@ exit:
1050 1050
1051 1051
1052/*-------------------------------------------------------------------------- 1052/*--------------------------------------------------------------------------
1053 Write a W9968CF register. 1053 Write a W9968CF register.
1054 Return 0 on success, -1 otherwise. 1054 Return 0 on success, -1 otherwise.
1055 --------------------------------------------------------------------------*/ 1055 --------------------------------------------------------------------------*/
1056static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index) 1056static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index)
@@ -1059,8 +1059,8 @@ static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index)
1059 int res; 1059 int res;
1060 1060
1061 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0, 1061 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0,
1062 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 1062 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
1063 value, index, NULL, 0, W9968CF_USB_CTRL_TIMEOUT); 1063 value, index, NULL, 0, W9968CF_USB_CTRL_TIMEOUT);
1064 1064
1065 if (res < 0) 1065 if (res < 0)
1066 DBG(4, "Failed to write a register " 1066 DBG(4, "Failed to write a register "
@@ -1072,7 +1072,7 @@ static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index)
1072 1072
1073 1073
1074/*-------------------------------------------------------------------------- 1074/*--------------------------------------------------------------------------
1075 Read a W9968CF register. 1075 Read a W9968CF register.
1076 Return the register value on success, -1 otherwise. 1076 Return the register value on success, -1 otherwise.
1077 --------------------------------------------------------------------------*/ 1077 --------------------------------------------------------------------------*/
1078static int w9968cf_read_reg(struct w9968cf_device* cam, u16 index) 1078static int w9968cf_read_reg(struct w9968cf_device* cam, u16 index)
@@ -1082,8 +1082,8 @@ static int w9968cf_read_reg(struct w9968cf_device* cam, u16 index)
1082 int res; 1082 int res;
1083 1083
1084 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 1, 1084 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 1,
1085 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1085 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1086 0, index, buff, 2, W9968CF_USB_CTRL_TIMEOUT); 1086 0, index, buff, 2, W9968CF_USB_CTRL_TIMEOUT);
1087 1087
1088 if (res < 0) 1088 if (res < 0)
1089 DBG(4, "Failed to read a register " 1089 DBG(4, "Failed to read a register "
@@ -1107,8 +1107,8 @@ static int w9968cf_write_fsb(struct w9968cf_device* cam, u16* data)
1107 value = *data++; 1107 value = *data++;
1108 1108
1109 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0, 1109 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0,
1110 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 1110 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
1111 value, 0x06, data, 6, W9968CF_USB_CTRL_TIMEOUT); 1111 value, 0x06, data, 6, W9968CF_USB_CTRL_TIMEOUT);
1112 1112
1113 if (res < 0) 1113 if (res < 0)
1114 DBG(4, "Failed to write the FSB registers " 1114 DBG(4, "Failed to write the FSB registers "
@@ -1287,9 +1287,9 @@ static int w9968cf_smbus_refresh_bus(struct w9968cf_device* cam)
1287 1287
1288 1288
1289/* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */ 1289/* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */
1290static int 1290static int
1291w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam, 1291w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
1292 u16 address, u8 subaddress,u8 value) 1292 u16 address, u8 subaddress,u8 value)
1293{ 1293{
1294 u16* data = cam->data_buffer; 1294 u16* data = cam->data_buffer;
1295 int err = 0; 1295 int err = 0;
@@ -1348,7 +1348,7 @@ w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
1348 "value 0x%02X", address, subaddress, value) 1348 "value 0x%02X", address, subaddress, value)
1349 else 1349 else
1350 DBG(5, "I2C write byte data failed, addr.0x%04X, " 1350 DBG(5, "I2C write byte data failed, addr.0x%04X, "
1351 "subaddr.0x%02X, value 0x%02X", 1351 "subaddr.0x%02X, value 0x%02X",
1352 address, subaddress, value) 1352 address, subaddress, value)
1353 1353
1354 return err; 1354 return err;
@@ -1356,10 +1356,10 @@ w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
1356 1356
1357 1357
1358/* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */ 1358/* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */
1359static int 1359static int
1360w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam, 1360w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
1361 u16 address, u8 subaddress, 1361 u16 address, u8 subaddress,
1362 u8* value) 1362 u8* value)
1363{ 1363{
1364 int err = 0; 1364 int err = 0;
1365 1365
@@ -1384,7 +1384,7 @@ w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
1384 1384
1385 if (!err) 1385 if (!err)
1386 DBG(5, "I2C read byte data done, addr.0x%04X, " 1386 DBG(5, "I2C read byte data done, addr.0x%04X, "
1387 "subaddr.0x%02X, value 0x%02X", 1387 "subaddr.0x%02X, value 0x%02X",
1388 address, subaddress, *value) 1388 address, subaddress, *value)
1389 else 1389 else
1390 DBG(5, "I2C read byte data failed, addr.0x%04X, " 1390 DBG(5, "I2C read byte data failed, addr.0x%04X, "
@@ -1396,9 +1396,9 @@ w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
1396 1396
1397 1397
1398/* SMBus protocol: S Addr+1 Rd [A] [Value] NA P */ 1398/* SMBus protocol: S Addr+1 Rd [A] [Value] NA P */
1399static int 1399static int
1400w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam, 1400w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
1401 u16 address, u8* value) 1401 u16 address, u8* value)
1402{ 1402{
1403 int err = 0; 1403 int err = 0;
1404 1404
@@ -1411,7 +1411,7 @@ w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
1411 err += w9968cf_smbus_read_byte(cam, value); 1411 err += w9968cf_smbus_read_byte(cam, value);
1412 err += w9968cf_smbus_write_ack(cam); 1412 err += w9968cf_smbus_write_ack(cam);
1413 err += w9968cf_smbus_stop(cam); 1413 err += w9968cf_smbus_stop(cam);
1414 1414
1415 /* Serial data disable */ 1415 /* Serial data disable */
1416 err += w9968cf_write_sb(cam, 0x0000); 1416 err += w9968cf_write_sb(cam, 0x0000);
1417 1417
@@ -1427,9 +1427,9 @@ w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
1427 1427
1428 1428
1429/* SMBus protocol: S Addr Wr [A] Value [A] P */ 1429/* SMBus protocol: S Addr Wr [A] Value [A] P */
1430static int 1430static int
1431w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam, 1431w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam,
1432 u16 address, u8 value) 1432 u16 address, u8 value)
1433{ 1433{
1434 DBG(4, "i2c_write_byte() is an unsupported transfer mode") 1434 DBG(4, "i2c_write_byte() is an unsupported transfer mode")
1435 return -EINVAL; 1435 return -EINVAL;
@@ -1442,13 +1442,13 @@ w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam,
1442 ****************************************************************************/ 1442 ****************************************************************************/
1443 1443
1444static int 1444static int
1445w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, 1445w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
1446 unsigned short flags, char read_write, u8 command, 1446 unsigned short flags, char read_write, u8 command,
1447 int size, union i2c_smbus_data *data) 1447 int size, union i2c_smbus_data *data)
1448{ 1448{
1449 struct w9968cf_device* cam = i2c_get_adapdata(adapter); 1449 struct w9968cf_device* cam = i2c_get_adapdata(adapter);
1450 u8 i; 1450 u8 i;
1451 int err = 0; 1451 int err = 0;
1452 1452
1453 switch (addr) { 1453 switch (addr) {
1454 case OV6xx0_SID: 1454 case OV6xx0_SID:
@@ -1464,20 +1464,20 @@ w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
1464 addr <<= 1; 1464 addr <<= 1;
1465 1465
1466 if (read_write == I2C_SMBUS_WRITE) 1466 if (read_write == I2C_SMBUS_WRITE)
1467 err = w9968cf_i2c_adap_write_byte(cam, addr, command); 1467 err = w9968cf_i2c_adap_write_byte(cam, addr, command);
1468 else if (read_write == I2C_SMBUS_READ) 1468 else if (read_write == I2C_SMBUS_READ)
1469 err = w9968cf_i2c_adap_read_byte(cam,addr,&data->byte); 1469 err = w9968cf_i2c_adap_read_byte(cam,addr,&data->byte);
1470 1470
1471 } else if (size == I2C_SMBUS_BYTE_DATA) { 1471 } else if (size == I2C_SMBUS_BYTE_DATA) {
1472 addr <<= 1; 1472 addr <<= 1;
1473 1473
1474 if (read_write == I2C_SMBUS_WRITE) 1474 if (read_write == I2C_SMBUS_WRITE)
1475 err = w9968cf_i2c_adap_fastwrite_byte_data(cam, addr, 1475 err = w9968cf_i2c_adap_fastwrite_byte_data(cam, addr,
1476 command, data->byte); 1476 command, data->byte);
1477 else if (read_write == I2C_SMBUS_READ) { 1477 else if (read_write == I2C_SMBUS_READ) {
1478 for (i = 1; i <= W9968CF_I2C_RW_RETRIES; i++) { 1478 for (i = 1; i <= W9968CF_I2C_RW_RETRIES; i++) {
1479 err = w9968cf_i2c_adap_read_byte_data(cam,addr, 1479 err = w9968cf_i2c_adap_read_byte_data(cam,addr,
1480 command, &data->byte); 1480 command, &data->byte);
1481 if (err) { 1481 if (err) {
1482 if (w9968cf_smbus_refresh_bus(cam)) { 1482 if (w9968cf_smbus_refresh_bus(cam)) {
1483 err = -EIO; 1483 err = -EIO;
@@ -1520,7 +1520,7 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client)
1520 return err; 1520 return err;
1521 } 1521 }
1522 } else { 1522 } else {
1523 DBG(4, "Rejected client [%s] with driver [%s]", 1523 DBG(4, "Rejected client [%s] with driver [%s]",
1524 client->name, client->driver->driver.name) 1524 client->name, client->driver->driver.name)
1525 return -EINVAL; 1525 return -EINVAL;
1526 } 1526 }
@@ -1545,9 +1545,9 @@ static int w9968cf_i2c_detach_inform(struct i2c_client* client)
1545} 1545}
1546 1546
1547 1547
1548static int 1548static int
1549w9968cf_i2c_control(struct i2c_adapter* adapter, unsigned int cmd, 1549w9968cf_i2c_control(struct i2c_adapter* adapter, unsigned int cmd,
1550 unsigned long arg) 1550 unsigned long arg)
1551{ 1551{
1552 return 0; 1552 return 0;
1553} 1553}
@@ -1625,12 +1625,12 @@ static int w9968cf_turn_on_led(struct w9968cf_device* cam)
1625static int w9968cf_init_chip(struct w9968cf_device* cam) 1625static int w9968cf_init_chip(struct w9968cf_device* cam)
1626{ 1626{
1627 unsigned long hw_bufsize = cam->maxwidth*cam->maxheight*2, 1627 unsigned long hw_bufsize = cam->maxwidth*cam->maxheight*2,
1628 y0 = 0x0000, 1628 y0 = 0x0000,
1629 u0 = y0 + hw_bufsize/2, 1629 u0 = y0 + hw_bufsize/2,
1630 v0 = u0 + hw_bufsize/4, 1630 v0 = u0 + hw_bufsize/4,
1631 y1 = v0 + hw_bufsize/4, 1631 y1 = v0 + hw_bufsize/4,
1632 u1 = y1 + hw_bufsize/2, 1632 u1 = y1 + hw_bufsize/2,
1633 v1 = u1 + hw_bufsize/4; 1633 v1 = u1 + hw_bufsize/4;
1634 int err = 0; 1634 int err = 0;
1635 1635
1636 err += w9968cf_write_reg(cam, 0xff00, 0x00); /* power off */ 1636 err += w9968cf_write_reg(cam, 0xff00, 0x00); /* power off */
@@ -1762,7 +1762,7 @@ w9968cf_set_picture(struct w9968cf_device* cam, struct video_picture pict)
1762 cam->vpp_flag = VPP_SWAP_YUV_BYTES; 1762 cam->vpp_flag = VPP_SWAP_YUV_BYTES;
1763 hw_palette = VIDEO_PALETTE_UYVY; 1763 hw_palette = VIDEO_PALETTE_UYVY;
1764 break; 1764 break;
1765 /* Original video is used instead of RGBX palettes. 1765 /* Original video is used instead of RGBX palettes.
1766 Software conversion later. */ 1766 Software conversion later. */
1767 case VIDEO_PALETTE_GREY: 1767 case VIDEO_PALETTE_GREY:
1768 case VIDEO_PALETTE_RGB555: 1768 case VIDEO_PALETTE_RGB555:
@@ -1777,7 +1777,7 @@ w9968cf_set_picture(struct w9968cf_device* cam, struct video_picture pict)
1777 } 1777 }
1778 1778
1779 /* NOTE: due to memory issues, it is better to disable the hardware 1779 /* NOTE: due to memory issues, it is better to disable the hardware
1780 double buffering during compression */ 1780 double buffering during compression */
1781 if (cam->double_buffer && !(cam->vpp_flag & VPP_DECOMPRESSION)) 1781 if (cam->double_buffer && !(cam->vpp_flag & VPP_DECOMPRESSION))
1782 reg_v |= 0x0080; 1782 reg_v |= 0x0080;
1783 1783
@@ -1832,8 +1832,8 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1832 #define __UNSC(x) ((x) >> 10) 1832 #define __UNSC(x) ((x) >> 10)
1833 1833
1834 /* Make sure we are using a supported resolution */ 1834 /* Make sure we are using a supported resolution */
1835 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width, 1835 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width,
1836 (u16*)&win.height))) 1836 (u16*)&win.height)))
1837 goto error; 1837 goto error;
1838 1838
1839 /* Scaling factors */ 1839 /* Scaling factors */
@@ -1962,7 +1962,7 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1962 /* Settings changed, so we clear the frame buffers */ 1962 /* Settings changed, so we clear the frame buffers */
1963 memset(cam->frame[0].buffer, 0, cam->nbuffers*cam->frame[0].size); 1963 memset(cam->frame[0].buffer, 0, cam->nbuffers*cam->frame[0].size);
1964 1964
1965 DBG(4, "The capture area is %dx%d, Offset (x,y)=(%u,%u)", 1965 DBG(4, "The capture area is %dx%d, Offset (x,y)=(%u,%u)",
1966 win.width, win.height, win.x, win.y) 1966 win.width, win.height, win.x, win.y)
1967 1967
1968 PDBGG("x=%u ,y=%u, w=%u, h=%u, ax=%u, ay=%u, s_win.x=%u, s_win.y=%u, " 1968 PDBGG("x=%u ,y=%u, w=%u, h=%u, ax=%u, ay=%u, s_win.x=%u, s_win.y=%u, "
@@ -1978,11 +1978,11 @@ error:
1978} 1978}
1979 1979
1980 1980
1981/*-------------------------------------------------------------------------- 1981/*--------------------------------------------------------------------------
1982 Adjust the asked values for window width and height. 1982 Adjust the asked values for window width and height.
1983 Return 0 on success, -1 otherwise. 1983 Return 0 on success, -1 otherwise.
1984 --------------------------------------------------------------------------*/ 1984 --------------------------------------------------------------------------*/
1985static int 1985static int
1986w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height) 1986w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height)
1987{ 1987{
1988 u16 maxw, maxh; 1988 u16 maxw, maxh;
@@ -1992,10 +1992,10 @@ w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height)
1992 1992
1993 maxw = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) && 1993 maxw = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) &&
1994 w9968cf_vpp ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth) 1994 w9968cf_vpp ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
1995 : cam->maxwidth; 1995 : cam->maxwidth;
1996 maxh = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) && 1996 maxh = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) &&
1997 w9968cf_vpp ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight) 1997 w9968cf_vpp ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight)
1998 : cam->maxheight; 1998 : cam->maxheight;
1999 1999
2000 if (*width > maxw) 2000 if (*width > maxw)
2001 *width = maxw; 2001 *width = maxw;
@@ -2054,7 +2054,7 @@ static void w9968cf_push_frame(struct w9968cf_device* cam, u8 f_num)
2054 Read, store and remove the first pointer in the FIFO list of requested 2054 Read, store and remove the first pointer in the FIFO list of requested
2055 frames. This function is called in interrupt context. 2055 frames. This function is called in interrupt context.
2056 --------------------------------------------------------------------------*/ 2056 --------------------------------------------------------------------------*/
2057static void 2057static void
2058w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep) 2058w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep)
2059{ 2059{
2060 u8 i; 2060 u8 i;
@@ -2078,9 +2078,9 @@ w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep)
2078 High-level video post-processing routine on grabbed frames. 2078 High-level video post-processing routine on grabbed frames.
2079 Return 0 on success, a negative number otherwise. 2079 Return 0 on success, a negative number otherwise.
2080 --------------------------------------------------------------------------*/ 2080 --------------------------------------------------------------------------*/
2081static int 2081static int
2082w9968cf_postprocess_frame(struct w9968cf_device* cam, 2082w9968cf_postprocess_frame(struct w9968cf_device* cam,
2083 struct w9968cf_frame_t* fr) 2083 struct w9968cf_frame_t* fr)
2084{ 2084{
2085 void *pIn = fr->buffer, *pOut = cam->frame_vpp.buffer, *tmp; 2085 void *pIn = fr->buffer, *pOut = cam->frame_vpp.buffer, *tmp;
2086 u16 w = cam->window.width, 2086 u16 w = cam->window.width,
@@ -2127,7 +2127,7 @@ w9968cf_postprocess_frame(struct w9968cf_device* cam,
2127 w9968cf_vpp->uyvy_to_rgbx(pIn, fr->length, pOut, fmt, rgb); 2127 w9968cf_vpp->uyvy_to_rgbx(pIn, fr->length, pOut, fmt, rgb);
2128 fr->length = (w*h*d)/8; 2128 fr->length = (w*h*d)/8;
2129 _PSWAP(pIn, pOut) 2129 _PSWAP(pIn, pOut)
2130 DBG(6, "UYVY-16bit to %s conversion done", 2130 DBG(6, "UYVY-16bit to %s conversion done",
2131 symbolic(v4l1_plist, fmt)) 2131 symbolic(v4l1_plist, fmt))
2132 } 2132 }
2133 2133
@@ -2143,7 +2143,7 @@ w9968cf_postprocess_frame(struct w9968cf_device* cam,
2143 * Image sensor control routines * 2143 * Image sensor control routines *
2144 ****************************************************************************/ 2144 ****************************************************************************/
2145 2145
2146static int 2146static int
2147w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val) 2147w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val)
2148{ 2148{
2149 struct ovcamchip_control ctl; 2149 struct ovcamchip_control ctl;
@@ -2158,7 +2158,7 @@ w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val)
2158} 2158}
2159 2159
2160 2160
2161static int 2161static int
2162w9968cf_sensor_get_control(struct w9968cf_device* cam, int cid, int* val) 2162w9968cf_sensor_get_control(struct w9968cf_device* cam, int cid, int* val)
2163{ 2163{
2164 struct ovcamchip_control ctl; 2164 struct ovcamchip_control ctl;
@@ -2198,38 +2198,38 @@ static int w9968cf_sensor_update_settings(struct w9968cf_device* cam)
2198 int err = 0; 2198 int err = 0;
2199 2199
2200 /* Auto brightness */ 2200 /* Auto brightness */
2201 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOBRIGHT, 2201 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOBRIGHT,
2202 cam->auto_brt); 2202 cam->auto_brt);
2203 if (err) 2203 if (err)
2204 return err; 2204 return err;
2205 2205
2206 /* Auto exposure */ 2206 /* Auto exposure */
2207 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOEXP, 2207 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOEXP,
2208 cam->auto_exp); 2208 cam->auto_exp);
2209 if (err) 2209 if (err)
2210 return err; 2210 return err;
2211 2211
2212 /* Banding filter */ 2212 /* Banding filter */
2213 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BANDFILT, 2213 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BANDFILT,
2214 cam->bandfilt); 2214 cam->bandfilt);
2215 if (err) 2215 if (err)
2216 return err; 2216 return err;
2217 2217
2218 /* Light frequency */ 2218 /* Light frequency */
2219 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_FREQ, 2219 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_FREQ,
2220 cam->lightfreq); 2220 cam->lightfreq);
2221 if (err) 2221 if (err)
2222 return err; 2222 return err;
2223 2223
2224 /* Back light */ 2224 /* Back light */
2225 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BACKLIGHT, 2225 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BACKLIGHT,
2226 cam->backlight); 2226 cam->backlight);
2227 if (err) 2227 if (err)
2228 return err; 2228 return err;
2229 2229
2230 /* Mirror */ 2230 /* Mirror */
2231 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_MIRROR, 2231 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_MIRROR,
2232 cam->mirror); 2232 cam->mirror);
2233 if (err) 2233 if (err)
2234 return err; 2234 return err;
2235 2235
@@ -2281,15 +2281,15 @@ static int w9968cf_sensor_get_picture(struct w9968cf_device* cam)
2281 Returns: 0 on success, a negative number otherwise. 2281 Returns: 0 on success, a negative number otherwise.
2282 --------------------------------------------------------------------------*/ 2282 --------------------------------------------------------------------------*/
2283static int 2283static int
2284w9968cf_sensor_update_picture(struct w9968cf_device* cam, 2284w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2285 struct video_picture pict) 2285 struct video_picture pict)
2286{ 2286{
2287 int err = 0; 2287 int err = 0;
2288 2288
2289 if ((!cam->sensor_initialized) 2289 if ((!cam->sensor_initialized)
2290 || pict.contrast != cam->picture.contrast) { 2290 || pict.contrast != cam->picture.contrast) {
2291 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_CONT, 2291 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_CONT,
2292 pict.contrast); 2292 pict.contrast);
2293 if (err) 2293 if (err)
2294 goto fail; 2294 goto fail;
2295 DBG(4, "Contrast changed from %u to %u", 2295 DBG(4, "Contrast changed from %u to %u",
@@ -2297,10 +2297,10 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2297 cam->picture.contrast = pict.contrast; 2297 cam->picture.contrast = pict.contrast;
2298 } 2298 }
2299 2299
2300 if (((!cam->sensor_initialized) || 2300 if (((!cam->sensor_initialized) ||
2301 pict.brightness != cam->picture.brightness) && (!cam->auto_brt)) { 2301 pict.brightness != cam->picture.brightness) && (!cam->auto_brt)) {
2302 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BRIGHT, 2302 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BRIGHT,
2303 pict.brightness); 2303 pict.brightness);
2304 if (err) 2304 if (err)
2305 goto fail; 2305 goto fail;
2306 DBG(4, "Brightness changed from %u to %u", 2306 DBG(4, "Brightness changed from %u to %u",
@@ -2309,8 +2309,8 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2309 } 2309 }
2310 2310
2311 if ((!cam->sensor_initialized) || pict.colour != cam->picture.colour) { 2311 if ((!cam->sensor_initialized) || pict.colour != cam->picture.colour) {
2312 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_SAT, 2312 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_SAT,
2313 pict.colour); 2313 pict.colour);
2314 if (err) 2314 if (err)
2315 goto fail; 2315 goto fail;
2316 DBG(4, "Colour changed from %u to %u", 2316 DBG(4, "Colour changed from %u to %u",
@@ -2319,8 +2319,8 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2319 } 2319 }
2320 2320
2321 if ((!cam->sensor_initialized) || pict.hue != cam->picture.hue) { 2321 if ((!cam->sensor_initialized) || pict.hue != cam->picture.hue) {
2322 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_HUE, 2322 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_HUE,
2323 pict.hue); 2323 pict.hue);
2324 if (err) 2324 if (err)
2325 goto fail; 2325 goto fail;
2326 DBG(4, "Hue changed from %u to %u", 2326 DBG(4, "Hue changed from %u to %u",
@@ -2349,12 +2349,12 @@ static int w9968cf_sensor_init(struct w9968cf_device* cam)
2349{ 2349{
2350 int err = 0; 2350 int err = 0;
2351 2351
2352 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_INITIALIZE, 2352 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_INITIALIZE,
2353 &cam->monochrome))) 2353 &cam->monochrome)))
2354 goto error; 2354 goto error;
2355 2355
2356 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_Q_SUBTYPE, 2356 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_Q_SUBTYPE,
2357 &cam->sensor))) 2357 &cam->sensor)))
2358 goto error; 2358 goto error;
2359 2359
2360 /* NOTE: Make sure width and height are a multiple of 16 */ 2360 /* NOTE: Make sure width and height are a multiple of 16 */
@@ -2416,14 +2416,14 @@ error:
2416 2416
2417/*-------------------------------------------------------------------------- 2417/*--------------------------------------------------------------------------
2418 Fill some basic fields in the main device data structure. 2418 Fill some basic fields in the main device data structure.
2419 This function is called once on w9968cf_usb_probe() for each recognized 2419 This function is called once on w9968cf_usb_probe() for each recognized
2420 camera. 2420 camera.
2421 --------------------------------------------------------------------------*/ 2421 --------------------------------------------------------------------------*/
2422static void 2422static void
2423w9968cf_configure_camera(struct w9968cf_device* cam, 2423w9968cf_configure_camera(struct w9968cf_device* cam,
2424 struct usb_device* udev, 2424 struct usb_device* udev,
2425 enum w9968cf_model_id mod_id, 2425 enum w9968cf_model_id mod_id,
2426 const unsigned short dev_nr) 2426 const unsigned short dev_nr)
2427{ 2427{
2428 mutex_init(&cam->fileop_mutex); 2428 mutex_init(&cam->fileop_mutex);
2429 init_waitqueue_head(&cam->open); 2429 init_waitqueue_head(&cam->open);
@@ -2444,60 +2444,60 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
2444 packet_size[dev_nr] < wMaxPacketSize[cam->altsetting-1]; 2444 packet_size[dev_nr] < wMaxPacketSize[cam->altsetting-1];
2445 cam->altsetting++); 2445 cam->altsetting++);
2446 2446
2447 cam->max_buffers = (max_buffers[dev_nr] < 2 || 2447 cam->max_buffers = (max_buffers[dev_nr] < 2 ||
2448 max_buffers[dev_nr] > W9968CF_MAX_BUFFERS) 2448 max_buffers[dev_nr] > W9968CF_MAX_BUFFERS)
2449 ? W9968CF_BUFFERS : (u8)max_buffers[dev_nr]; 2449 ? W9968CF_BUFFERS : (u8)max_buffers[dev_nr];
2450 2450
2451 cam->double_buffer = (double_buffer[dev_nr] == 0 || 2451 cam->double_buffer = (double_buffer[dev_nr] == 0 ||
2452 double_buffer[dev_nr] == 1) 2452 double_buffer[dev_nr] == 1)
2453 ? (u8)double_buffer[dev_nr]:W9968CF_DOUBLE_BUFFER; 2453 ? (u8)double_buffer[dev_nr]:W9968CF_DOUBLE_BUFFER;
2454 2454
2455 cam->clamping = (clamping[dev_nr] == 0 || clamping[dev_nr] == 1) 2455 cam->clamping = (clamping[dev_nr] == 0 || clamping[dev_nr] == 1)
2456 ? (u8)clamping[dev_nr] : W9968CF_CLAMPING; 2456 ? (u8)clamping[dev_nr] : W9968CF_CLAMPING;
2457 2457
2458 cam->filter_type = (filter_type[dev_nr] == 0 || 2458 cam->filter_type = (filter_type[dev_nr] == 0 ||
2459 filter_type[dev_nr] == 1 || 2459 filter_type[dev_nr] == 1 ||
2460 filter_type[dev_nr] == 2) 2460 filter_type[dev_nr] == 2)
2461 ? (u8)filter_type[dev_nr] : W9968CF_FILTER_TYPE; 2461 ? (u8)filter_type[dev_nr] : W9968CF_FILTER_TYPE;
2462 2462
2463 cam->capture = 1; 2463 cam->capture = 1;
2464 2464
2465 cam->largeview = (largeview[dev_nr] == 0 || largeview[dev_nr] == 1) 2465 cam->largeview = (largeview[dev_nr] == 0 || largeview[dev_nr] == 1)
2466 ? (u8)largeview[dev_nr] : W9968CF_LARGEVIEW; 2466 ? (u8)largeview[dev_nr] : W9968CF_LARGEVIEW;
2467 2467
2468 cam->decompression = (decompression[dev_nr] == 0 || 2468 cam->decompression = (decompression[dev_nr] == 0 ||
2469 decompression[dev_nr] == 1 || 2469 decompression[dev_nr] == 1 ||
2470 decompression[dev_nr] == 2) 2470 decompression[dev_nr] == 2)
2471 ? (u8)decompression[dev_nr]:W9968CF_DECOMPRESSION; 2471 ? (u8)decompression[dev_nr]:W9968CF_DECOMPRESSION;
2472 2472
2473 cam->upscaling = (upscaling[dev_nr] == 0 || 2473 cam->upscaling = (upscaling[dev_nr] == 0 ||
2474 upscaling[dev_nr] == 1) 2474 upscaling[dev_nr] == 1)
2475 ? (u8)upscaling[dev_nr] : W9968CF_UPSCALING; 2475 ? (u8)upscaling[dev_nr] : W9968CF_UPSCALING;
2476 2476
2477 cam->auto_brt = (autobright[dev_nr] == 0 || autobright[dev_nr] == 1) 2477 cam->auto_brt = (autobright[dev_nr] == 0 || autobright[dev_nr] == 1)
2478 ? (u8)autobright[dev_nr] : W9968CF_AUTOBRIGHT; 2478 ? (u8)autobright[dev_nr] : W9968CF_AUTOBRIGHT;
2479 2479
2480 cam->auto_exp = (autoexp[dev_nr] == 0 || autoexp[dev_nr] == 1) 2480 cam->auto_exp = (autoexp[dev_nr] == 0 || autoexp[dev_nr] == 1)
2481 ? (u8)autoexp[dev_nr] : W9968CF_AUTOEXP; 2481 ? (u8)autoexp[dev_nr] : W9968CF_AUTOEXP;
2482 2482
2483 cam->lightfreq = (lightfreq[dev_nr] == 50 || lightfreq[dev_nr] == 60) 2483 cam->lightfreq = (lightfreq[dev_nr] == 50 || lightfreq[dev_nr] == 60)
2484 ? (u8)lightfreq[dev_nr] : W9968CF_LIGHTFREQ; 2484 ? (u8)lightfreq[dev_nr] : W9968CF_LIGHTFREQ;
2485 2485
2486 cam->bandfilt = (bandingfilter[dev_nr] == 0 || 2486 cam->bandfilt = (bandingfilter[dev_nr] == 0 ||
2487 bandingfilter[dev_nr] == 1) 2487 bandingfilter[dev_nr] == 1)
2488 ? (u8)bandingfilter[dev_nr] : W9968CF_BANDINGFILTER; 2488 ? (u8)bandingfilter[dev_nr] : W9968CF_BANDINGFILTER;
2489 2489
2490 cam->backlight = (backlight[dev_nr] == 0 || backlight[dev_nr] == 1) 2490 cam->backlight = (backlight[dev_nr] == 0 || backlight[dev_nr] == 1)
2491 ? (u8)backlight[dev_nr] : W9968CF_BACKLIGHT; 2491 ? (u8)backlight[dev_nr] : W9968CF_BACKLIGHT;
2492 2492
2493 cam->clockdiv = (clockdiv[dev_nr] == -1 || clockdiv[dev_nr] >= 0) 2493 cam->clockdiv = (clockdiv[dev_nr] == -1 || clockdiv[dev_nr] >= 0)
2494 ? (s8)clockdiv[dev_nr] : W9968CF_CLOCKDIV; 2494 ? (s8)clockdiv[dev_nr] : W9968CF_CLOCKDIV;
2495 2495
2496 cam->mirror = (mirror[dev_nr] == 0 || mirror[dev_nr] == 1) 2496 cam->mirror = (mirror[dev_nr] == 0 || mirror[dev_nr] == 1)
2497 ? (u8)mirror[dev_nr] : W9968CF_MIRROR; 2497 ? (u8)mirror[dev_nr] : W9968CF_MIRROR;
2498 2498
2499 cam->monochrome = (monochrome[dev_nr] == 0 || monochrome[dev_nr] == 1) 2499 cam->monochrome = (monochrome[dev_nr] == 0 || monochrome[dev_nr] == 1)
2500 ? monochrome[dev_nr] : W9968CF_MONOCHROME; 2500 ? monochrome[dev_nr] : W9968CF_MONOCHROME;
2501 2501
2502 cam->picture.brightness = (u16)brightness[dev_nr]; 2502 cam->picture.brightness = (u16)brightness[dev_nr];
2503 cam->picture.hue = (u16)hue[dev_nr]; 2503 cam->picture.hue = (u16)hue[dev_nr];
@@ -2519,7 +2519,7 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
2519 cam->picture.depth = w9968cf_valid_depth(cam->picture.palette); 2519 cam->picture.depth = w9968cf_valid_depth(cam->picture.palette);
2520 2520
2521 cam->force_rgb = (force_rgb[dev_nr] == 0 || force_rgb[dev_nr] == 1) 2521 cam->force_rgb = (force_rgb[dev_nr] == 0 || force_rgb[dev_nr] == 1)
2522 ? (u8)force_rgb[dev_nr] : W9968CF_FORCE_RGB; 2522 ? (u8)force_rgb[dev_nr] : W9968CF_FORCE_RGB;
2523 2523
2524 cam->window.x = 0; 2524 cam->window.x = 0;
2525 cam->window.y = 0; 2525 cam->window.y = 0;
@@ -2531,16 +2531,16 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
2531 2531
2532 DBG(3, "%s configured with settings #%u:", 2532 DBG(3, "%s configured with settings #%u:",
2533 symbolic(camlist, cam->id), dev_nr) 2533 symbolic(camlist, cam->id), dev_nr)
2534 2534
2535 DBG(3, "- Data packet size for USB isochrnous transfer: %u bytes", 2535 DBG(3, "- Data packet size for USB isochrnous transfer: %u bytes",
2536 wMaxPacketSize[cam->altsetting-1]) 2536 wMaxPacketSize[cam->altsetting-1])
2537 2537
2538 DBG(3, "- Number of requested video frame buffers: %u", 2538 DBG(3, "- Number of requested video frame buffers: %u",
2539 cam->max_buffers) 2539 cam->max_buffers)
2540 2540
2541 if (cam->double_buffer) 2541 if (cam->double_buffer)
2542 DBG(3, "- Hardware double buffering enabled") 2542 DBG(3, "- Hardware double buffering enabled")
2543 else 2543 else
2544 DBG(3, "- Hardware double buffering disabled") 2544 DBG(3, "- Hardware double buffering disabled")
2545 2545
2546 if (cam->filter_type == 0) 2546 if (cam->filter_type == 0)
@@ -2648,7 +2648,7 @@ static void w9968cf_adjust_configuration(struct w9968cf_device* cam)
2648 2648
2649/*-------------------------------------------------------------------------- 2649/*--------------------------------------------------------------------------
2650 Release the resources used by the driver. 2650 Release the resources used by the driver.
2651 This function is called on disconnect 2651 This function is called on disconnect
2652 (or on close if deallocation has been deferred) 2652 (or on close if deallocation has been deferred)
2653 --------------------------------------------------------------------------*/ 2653 --------------------------------------------------------------------------*/
2654static void w9968cf_release_resources(struct w9968cf_device* cam) 2654static void w9968cf_release_resources(struct w9968cf_device* cam)
@@ -2706,8 +2706,8 @@ static int w9968cf_open(struct inode* inode, struct file* filp)
2706 } 2706 }
2707 mutex_unlock(&cam->dev_mutex); 2707 mutex_unlock(&cam->dev_mutex);
2708 err = wait_event_interruptible_exclusive(cam->open, 2708 err = wait_event_interruptible_exclusive(cam->open,
2709 cam->disconnected || 2709 cam->disconnected ||
2710 !cam->users); 2710 !cam->users);
2711 if (err) { 2711 if (err) {
2712 up_read(&w9968cf_disconnect); 2712 up_read(&w9968cf_disconnect);
2713 return err; 2713 return err;
@@ -2820,9 +2820,9 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
2820 w9968cf_push_frame(cam, 1); 2820 w9968cf_push_frame(cam, 1);
2821 2821
2822 err = wait_event_interruptible(cam->wait_queue, 2822 err = wait_event_interruptible(cam->wait_queue,
2823 cam->frame[0].status == F_READY || 2823 cam->frame[0].status == F_READY ||
2824 cam->frame[1].status == F_READY || 2824 cam->frame[1].status == F_READY ||
2825 cam->disconnected); 2825 cam->disconnected);
2826 if (err) { 2826 if (err) {
2827 mutex_unlock(&cam->fileop_mutex); 2827 mutex_unlock(&cam->fileop_mutex);
2828 return err; 2828 return err;
@@ -2859,12 +2859,12 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
2859static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma) 2859static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma)
2860{ 2860{
2861 struct w9968cf_device* cam = (struct w9968cf_device*) 2861 struct w9968cf_device* cam = (struct w9968cf_device*)
2862 video_get_drvdata(video_devdata(filp)); 2862 video_get_drvdata(video_devdata(filp));
2863 unsigned long vsize = vma->vm_end - vma->vm_start, 2863 unsigned long vsize = vma->vm_end - vma->vm_start,
2864 psize = cam->nbuffers * cam->frame[0].size, 2864 psize = cam->nbuffers * cam->frame[0].size,
2865 start = vma->vm_start, 2865 start = vma->vm_start,
2866 pos = (unsigned long)cam->frame[0].buffer, 2866 pos = (unsigned long)cam->frame[0].buffer,
2867 page; 2867 page;
2868 2868
2869 if (cam->disconnected) { 2869 if (cam->disconnected) {
2870 DBG(2, "Device not present") 2870 DBG(2, "Device not present")
@@ -2898,7 +2898,7 @@ static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma)
2898 2898
2899static int 2899static int
2900w9968cf_ioctl(struct inode* inode, struct file* filp, 2900w9968cf_ioctl(struct inode* inode, struct file* filp,
2901 unsigned int cmd, unsigned long arg) 2901 unsigned int cmd, unsigned long arg)
2902{ 2902{
2903 struct w9968cf_device* cam; 2903 struct w9968cf_device* cam;
2904 int err; 2904 int err;
@@ -2928,21 +2928,21 @@ w9968cf_ioctl(struct inode* inode, struct file* filp,
2928 2928
2929 2929
2930static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp, 2930static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
2931 unsigned int cmd, void __user * arg) 2931 unsigned int cmd, void __user * arg)
2932{ 2932{
2933 struct w9968cf_device* cam; 2933 struct w9968cf_device* cam;
2934 const char* v4l1_ioctls[] = { 2934 const char* v4l1_ioctls[] = {
2935 "?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER", 2935 "?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER",
2936 "GPICT", "SPICT", "CCAPTURE", "GWIN", "SWIN", "GFBUF", 2936 "GPICT", "SPICT", "CCAPTURE", "GWIN", "SWIN", "GFBUF",
2937 "SFBUF", "KEY", "GFREQ", "SFREQ", "GAUDIO", "SAUDIO", 2937 "SFBUF", "KEY", "GFREQ", "SFREQ", "GAUDIO", "SAUDIO",
2938 "SYNC", "MCAPTURE", "GMBUF", "GUNIT", "GCAPTURE", "SCAPTURE", 2938 "SYNC", "MCAPTURE", "GMBUF", "GUNIT", "GCAPTURE", "SCAPTURE",
2939 "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", "SMICROCODE", 2939 "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", "SMICROCODE",
2940 "GVBIFMT", "SVBIFMT" 2940 "GVBIFMT", "SVBIFMT"
2941 }; 2941 };
2942 2942
2943 #define V4L1_IOCTL(cmd) \ 2943 #define V4L1_IOCTL(cmd) \
2944 ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \ 2944 ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \
2945 v4l1_ioctls[_IOC_NR((cmd))] : "?") 2945 v4l1_ioctls[_IOC_NR((cmd))] : "?")
2946 2946
2947 cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); 2947 cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp));
2948 2948
@@ -2957,14 +2957,14 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
2957 .minwidth = cam->minwidth, 2957 .minwidth = cam->minwidth,
2958 .minheight = cam->minheight, 2958 .minheight = cam->minheight,
2959 }; 2959 };
2960 sprintf(cap.name, "W996[87]CF USB Camera #%d", 2960 sprintf(cap.name, "W996[87]CF USB Camera #%d",
2961 cam->v4ldev->minor); 2961 cam->v4ldev->minor);
2962 cap.maxwidth = (cam->upscaling && w9968cf_vpp) 2962 cap.maxwidth = (cam->upscaling && w9968cf_vpp)
2963 ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth) 2963 ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
2964 : cam->maxwidth; 2964 : cam->maxwidth;
2965 cap.maxheight = (cam->upscaling && w9968cf_vpp) 2965 cap.maxheight = (cam->upscaling && w9968cf_vpp)
2966 ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight) 2966 ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight)
2967 : cam->maxheight; 2967 : cam->maxheight;
2968 2968
2969 if (copy_to_user(arg, &cap, sizeof(cap))) 2969 if (copy_to_user(arg, &cap, sizeof(cap)))
2970 return -EFAULT; 2970 return -EFAULT;
@@ -3029,7 +3029,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3029 if (copy_from_user(&pict, arg, sizeof(pict))) 3029 if (copy_from_user(&pict, arg, sizeof(pict)))
3030 return -EFAULT; 3030 return -EFAULT;
3031 3031
3032 if ( (cam->force_palette || !w9968cf_vpp) 3032 if ( (cam->force_palette || !w9968cf_vpp)
3033 && pict.palette != cam->picture.palette ) { 3033 && pict.palette != cam->picture.palette ) {
3034 DBG(4, "Palette %s rejected: only %s is allowed", 3034 DBG(4, "Palette %s rejected: only %s is allowed",
3035 symbolic(v4l1_plist, pict.palette), 3035 symbolic(v4l1_plist, pict.palette),
@@ -3046,24 +3046,24 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3046 if (!cam->force_palette) { 3046 if (!cam->force_palette) {
3047 if (cam->decompression == 0) { 3047 if (cam->decompression == 0) {
3048 if (w9968cf_need_decompression(pict.palette)) { 3048 if (w9968cf_need_decompression(pict.palette)) {
3049 DBG(4, "Decompression disabled: palette %s is not " 3049 DBG(4, "Decompression disabled: palette %s is not "
3050 "allowed. VIDIOCSPICT failed", 3050 "allowed. VIDIOCSPICT failed",
3051 symbolic(v4l1_plist, pict.palette)) 3051 symbolic(v4l1_plist, pict.palette))
3052 return -EINVAL; 3052 return -EINVAL;
3053 } 3053 }
3054 } else if (cam->decompression == 1) { 3054 } else if (cam->decompression == 1) {
3055 if (!w9968cf_need_decompression(pict.palette)) { 3055 if (!w9968cf_need_decompression(pict.palette)) {
3056 DBG(4, "Decompression forced: palette %s is not " 3056 DBG(4, "Decompression forced: palette %s is not "
3057 "allowed. VIDIOCSPICT failed", 3057 "allowed. VIDIOCSPICT failed",
3058 symbolic(v4l1_plist, pict.palette)) 3058 symbolic(v4l1_plist, pict.palette))
3059 return -EINVAL; 3059 return -EINVAL;
3060 } 3060 }
3061 } 3061 }
3062 } 3062 }
3063 3063
3064 if (pict.depth != w9968cf_valid_depth(pict.palette)) { 3064 if (pict.depth != w9968cf_valid_depth(pict.palette)) {
3065 DBG(4, "Requested depth %u bpp is not valid for %s " 3065 DBG(4, "Requested depth %u bpp is not valid for %s "
3066 "palette: ignored and changed to %u bpp", 3066 "palette: ignored and changed to %u bpp",
3067 pict.depth, symbolic(v4l1_plist, pict.palette), 3067 pict.depth, symbolic(v4l1_plist, pict.palette),
3068 w9968cf_valid_depth(pict.palette)) 3068 w9968cf_valid_depth(pict.palette))
3069 pict.depth = w9968cf_valid_depth(pict.palette); 3069 pict.depth = w9968cf_valid_depth(pict.palette);
@@ -3074,9 +3074,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3074 || cam->frame_current->queued) { 3074 || cam->frame_current->queued) {
3075 err = wait_event_interruptible 3075 err = wait_event_interruptible
3076 ( cam->wait_queue, 3076 ( cam->wait_queue,
3077 cam->disconnected || 3077 cam->disconnected ||
3078 (!*cam->requested_frame && 3078 (!*cam->requested_frame &&
3079 !cam->frame_current->queued) ); 3079 !cam->frame_current->queued) );
3080 if (err) 3080 if (err)
3081 return err; 3081 return err;
3082 if (cam->disconnected) 3082 if (cam->disconnected)
@@ -3116,7 +3116,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3116 return -EINVAL; 3116 return -EINVAL;
3117 3117
3118 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width, 3118 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width,
3119 (u16*)&win.height))) { 3119 (u16*)&win.height))) {
3120 DBG(4, "Resolution not supported (%ux%u). " 3120 DBG(4, "Resolution not supported (%ux%u). "
3121 "VIDIOCSWIN failed", win.width, win.height) 3121 "VIDIOCSWIN failed", win.width, win.height)
3122 return err; 3122 return err;
@@ -3130,9 +3130,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3130 || cam->frame_current->queued) { 3130 || cam->frame_current->queued) {
3131 err = wait_event_interruptible 3131 err = wait_event_interruptible
3132 ( cam->wait_queue, 3132 ( cam->wait_queue,
3133 cam->disconnected || 3133 cam->disconnected ||
3134 (!*cam->requested_frame && 3134 (!*cam->requested_frame &&
3135 !cam->frame_current->queued) ); 3135 !cam->frame_current->queued) );
3136 if (err) 3136 if (err)
3137 return err; 3137 return err;
3138 if (cam->disconnected) 3138 if (cam->disconnected)
@@ -3175,7 +3175,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3175 mbuf.frames = cam->nbuffers; 3175 mbuf.frames = cam->nbuffers;
3176 for (i = 0; i < cam->nbuffers; i++) 3176 for (i = 0; i < cam->nbuffers; i++)
3177 mbuf.offsets[i] = (unsigned long)cam->frame[i].buffer - 3177 mbuf.offsets[i] = (unsigned long)cam->frame[i].buffer -
3178 (unsigned long)cam->frame[0].buffer; 3178 (unsigned long)cam->frame[0].buffer;
3179 3179
3180 if (copy_to_user(arg, &mbuf, sizeof(mbuf))) 3180 if (copy_to_user(arg, &mbuf, sizeof(mbuf)))
3181 return -EFAULT; 3181 return -EFAULT;
@@ -3194,7 +3194,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3194 return -EFAULT; 3194 return -EFAULT;
3195 3195
3196 DBG(6, "VIDIOCMCAPTURE called: frame #%u, format=%s, %dx%d", 3196 DBG(6, "VIDIOCMCAPTURE called: frame #%u, format=%s, %dx%d",
3197 mmap.frame, symbolic(v4l1_plist, mmap.format), 3197 mmap.frame, symbolic(v4l1_plist, mmap.format),
3198 mmap.width, mmap.height) 3198 mmap.width, mmap.height)
3199 3199
3200 if (mmap.frame >= cam->nbuffers) { 3200 if (mmap.frame >= cam->nbuffers) {
@@ -3203,7 +3203,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3203 return -EINVAL; 3203 return -EINVAL;
3204 } 3204 }
3205 3205
3206 if (mmap.format!=cam->picture.palette && 3206 if (mmap.format!=cam->picture.palette &&
3207 (cam->force_palette || !w9968cf_vpp)) { 3207 (cam->force_palette || !w9968cf_vpp)) {
3208 DBG(4, "Palette %s rejected: only %s is allowed", 3208 DBG(4, "Palette %s rejected: only %s is allowed",
3209 symbolic(v4l1_plist, mmap.format), 3209 symbolic(v4l1_plist, mmap.format),
@@ -3213,7 +3213,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3213 3213
3214 if (!w9968cf_valid_palette(mmap.format)) { 3214 if (!w9968cf_valid_palette(mmap.format)) {
3215 DBG(4, "Palette %s not supported. " 3215 DBG(4, "Palette %s not supported. "
3216 "VIDIOCMCAPTURE failed", 3216 "VIDIOCMCAPTURE failed",
3217 symbolic(v4l1_plist, mmap.format)) 3217 symbolic(v4l1_plist, mmap.format))
3218 return -EINVAL; 3218 return -EINVAL;
3219 } 3219 }
@@ -3221,23 +3221,23 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3221 if (!cam->force_palette) { 3221 if (!cam->force_palette) {
3222 if (cam->decompression == 0) { 3222 if (cam->decompression == 0) {
3223 if (w9968cf_need_decompression(mmap.format)) { 3223 if (w9968cf_need_decompression(mmap.format)) {
3224 DBG(4, "Decompression disabled: palette %s is not " 3224 DBG(4, "Decompression disabled: palette %s is not "
3225 "allowed. VIDIOCSPICT failed", 3225 "allowed. VIDIOCSPICT failed",
3226 symbolic(v4l1_plist, mmap.format)) 3226 symbolic(v4l1_plist, mmap.format))
3227 return -EINVAL; 3227 return -EINVAL;
3228 } 3228 }
3229 } else if (cam->decompression == 1) { 3229 } else if (cam->decompression == 1) {
3230 if (!w9968cf_need_decompression(mmap.format)) { 3230 if (!w9968cf_need_decompression(mmap.format)) {
3231 DBG(4, "Decompression forced: palette %s is not " 3231 DBG(4, "Decompression forced: palette %s is not "
3232 "allowed. VIDIOCSPICT failed", 3232 "allowed. VIDIOCSPICT failed",
3233 symbolic(v4l1_plist, mmap.format)) 3233 symbolic(v4l1_plist, mmap.format))
3234 return -EINVAL; 3234 return -EINVAL;
3235 } 3235 }
3236 } 3236 }
3237 } 3237 }
3238 3238
3239 if ((err = w9968cf_adjust_window_size(cam, (u16*)&mmap.width, 3239 if ((err = w9968cf_adjust_window_size(cam, (u16*)&mmap.width,
3240 (u16*)&mmap.height))) { 3240 (u16*)&mmap.height))) {
3241 DBG(4, "Resolution not supported (%dx%d). " 3241 DBG(4, "Resolution not supported (%dx%d). "
3242 "VIDIOCMCAPTURE failed", 3242 "VIDIOCMCAPTURE failed",
3243 mmap.width, mmap.height) 3243 mmap.width, mmap.height)
@@ -3258,12 +3258,12 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3258 DBG(6, "VIDIOCMCAPTURE. Change settings for " 3258 DBG(6, "VIDIOCMCAPTURE. Change settings for "
3259 "frame #%u: %dx%d, format %s. Wait...", 3259 "frame #%u: %dx%d, format %s. Wait...",
3260 mmap.frame, mmap.width, mmap.height, 3260 mmap.frame, mmap.width, mmap.height,
3261 symbolic(v4l1_plist, mmap.format)) 3261 symbolic(v4l1_plist, mmap.format))
3262 err = wait_event_interruptible 3262 err = wait_event_interruptible
3263 ( cam->wait_queue, 3263 ( cam->wait_queue,
3264 cam->disconnected || 3264 cam->disconnected ||
3265 (!*cam->requested_frame && 3265 (!*cam->requested_frame &&
3266 !cam->frame_current->queued) ); 3266 !cam->frame_current->queued) );
3267 if (err) 3267 if (err)
3268 return err; 3268 return err;
3269 if (cam->disconnected) 3269 if (cam->disconnected)
@@ -3280,7 +3280,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3280 goto ioctl_fail; 3280 goto ioctl_fail;
3281 3281
3282 /* This before set_window */ 3282 /* This before set_window */
3283 if (w9968cf_set_picture(cam, pict)) 3283 if (w9968cf_set_picture(cam, pict))
3284 goto ioctl_fail; 3284 goto ioctl_fail;
3285 3285
3286 if (w9968cf_set_window(cam, win)) 3286 if (w9968cf_set_window(cam, win))
@@ -3292,10 +3292,10 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3292 } else if (fr->queued) { 3292 } else if (fr->queued) {
3293 3293
3294 DBG(6, "Wait until frame #%u is free", mmap.frame) 3294 DBG(6, "Wait until frame #%u is free", mmap.frame)
3295 3295
3296 err = wait_event_interruptible(cam->wait_queue, 3296 err = wait_event_interruptible(cam->wait_queue,
3297 cam->disconnected || 3297 cam->disconnected ||
3298 (!fr->queued)); 3298 (!fr->queued));
3299 if (err) 3299 if (err)
3300 return err; 3300 return err;
3301 if (cam->disconnected) 3301 if (cam->disconnected)
@@ -3335,9 +3335,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3335 } 3335 }
3336 case F_ERROR: 3336 case F_ERROR:
3337 case F_GRABBING: 3337 case F_GRABBING:
3338 err = wait_event_interruptible(cam->wait_queue, 3338 err = wait_event_interruptible(cam->wait_queue,
3339 (fr->status == F_READY) 3339 (fr->status == F_READY)
3340 || cam->disconnected); 3340 || cam->disconnected);
3341 if (err) 3341 if (err)
3342 return err; 3342 return err;
3343 if (cam->disconnected) 3343 if (cam->disconnected)
@@ -3439,7 +3439,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3439 DBG(4, "Unsupported V4L1 IOCtl: VIDIOC%s " 3439 DBG(4, "Unsupported V4L1 IOCtl: VIDIOC%s "
3440 "(type 0x%01X, " 3440 "(type 0x%01X, "
3441 "n. 0x%01X, " 3441 "n. 0x%01X, "
3442 "dir. 0x%01X, " 3442 "dir. 0x%01X, "
3443 "size 0x%02X)", 3443 "size 0x%02X)",
3444 V4L1_IOCTL(cmd), 3444 V4L1_IOCTL(cmd),
3445 _IOC_TYPE(cmd),_IOC_NR(cmd),_IOC_DIR(cmd),_IOC_SIZE(cmd)) 3445 _IOC_TYPE(cmd),_IOC_NR(cmd),_IOC_DIR(cmd),_IOC_SIZE(cmd))
@@ -3499,13 +3499,13 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3499 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct) 3499 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct)
3500 mod_id = W9968CF_MOD_CLVBWGP; /* see camlist[] table */ 3500 mod_id = W9968CF_MOD_CLVBWGP; /* see camlist[] table */
3501 else if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[1].idVendor && 3501 else if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[1].idVendor &&
3502 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[1].idProduct) 3502 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[1].idProduct)
3503 mod_id = W9968CF_MOD_GENERIC; /* see camlist[] table */ 3503 mod_id = W9968CF_MOD_GENERIC; /* see camlist[] table */
3504 else 3504 else
3505 return -ENODEV; 3505 return -ENODEV;
3506 3506
3507 cam = (struct w9968cf_device*) 3507 cam = (struct w9968cf_device*)
3508 kzalloc(sizeof(struct w9968cf_device), GFP_KERNEL); 3508 kzalloc(sizeof(struct w9968cf_device), GFP_KERNEL);
3509 if (!cam) 3509 if (!cam)
3510 return -ENOMEM; 3510 return -ENOMEM;
3511 3511
@@ -3569,7 +3569,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3569 cam->v4ldev->dev = &cam->dev; 3569 cam->v4ldev->dev = &cam->dev;
3570 3570
3571 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 3571 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
3572 video_nr[dev_nr]); 3572 video_nr[dev_nr]);
3573 if (err) { 3573 if (err) {
3574 DBG(1, "V4L device registration failed") 3574 DBG(1, "V4L device registration failed")
3575 if (err == -ENFILE && video_nr[dev_nr] == -1) 3575 if (err == -ENFILE && video_nr[dev_nr] == -1)
@@ -3611,7 +3611,7 @@ fail: /* Free unused memory */
3611 3611
3612static void w9968cf_usb_disconnect(struct usb_interface* intf) 3612static void w9968cf_usb_disconnect(struct usb_interface* intf)
3613{ 3613{
3614 struct w9968cf_device* cam = 3614 struct w9968cf_device* cam =
3615 (struct w9968cf_device*)usb_get_intfdata(intf); 3615 (struct w9968cf_device*)usb_get_intfdata(intf);
3616 3616
3617 down_write(&w9968cf_disconnect); 3617 down_write(&w9968cf_disconnect);
diff --git a/drivers/media/video/w9968cf.h b/drivers/media/video/w9968cf.h
index a87be719a281..2836b45ec206 100644
--- a/drivers/media/video/w9968cf.h
+++ b/drivers/media/video/w9968cf.h
@@ -61,7 +61,7 @@
61 61
62/* Maximum data payload sizes in bytes for alternate settings */ 62/* Maximum data payload sizes in bytes for alternate settings */
63static const u16 wMaxPacketSize[] = {1023, 959, 895, 831, 767, 703, 639, 575, 63static const u16 wMaxPacketSize[] = {1023, 959, 895, 831, 767, 703, 639, 575,
64 511, 447, 383, 319, 255, 191, 127, 63}; 64 511, 447, 383, 319, 255, 191, 127, 63};
65#define W9968CF_PACKET_SIZE 1023 /* according to wMaxPacketSizes[] */ 65#define W9968CF_PACKET_SIZE 1023 /* according to wMaxPacketSizes[] */
66#define W9968CF_MIN_PACKET_SIZE 63 /* minimum value */ 66#define W9968CF_MIN_PACKET_SIZE 63 /* minimum value */
67#define W9968CF_ISO_PACKETS 5 /* n.of packets for isochronous transfers */ 67#define W9968CF_ISO_PACKETS 5 /* n.of packets for isochronous transfers */
@@ -134,7 +134,7 @@ static const struct w9968cf_format w9968cf_formatlist[] = {
134 ****************************************************************************/ 134 ****************************************************************************/
135 135
136#define W9968CF_MODULE_NAME "V4L driver for W996[87]CF JPEG USB " \ 136#define W9968CF_MODULE_NAME "V4L driver for W996[87]CF JPEG USB " \
137 "Dual Mode Camera Chip" 137 "Dual Mode Camera Chip"
138#define W9968CF_MODULE_VERSION "1:1.33-basic" 138#define W9968CF_MODULE_VERSION "1:1.33-basic"
139#define W9968CF_MODULE_AUTHOR "(C) 2002-2004 Luca Risolia" 139#define W9968CF_MODULE_AUTHOR "(C) 2002-2004 Luca Risolia"
140#define W9968CF_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 140#define W9968CF_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
@@ -270,9 +270,9 @@ struct w9968cf_device {
270 270
271 /* Locks */ 271 /* Locks */
272 struct mutex dev_mutex, /* for probe, disconnect,open and close */ 272 struct mutex dev_mutex, /* for probe, disconnect,open and close */
273 fileop_mutex; /* for read and ioctl */ 273 fileop_mutex; /* for read and ioctl */
274 spinlock_t urb_lock, /* for submit_urb() and unlink_urb() */ 274 spinlock_t urb_lock, /* for submit_urb() and unlink_urb() */
275 flist_lock; /* for requested frame list accesses */ 275 flist_lock; /* for requested frame list accesses */
276 wait_queue_head_t open, wait_queue; 276 wait_queue_head_t open, wait_queue;
277 277
278 char command[16]; /* name of the program holding the device */ 278 char command[16]; /* name of the program holding the device */
@@ -299,7 +299,7 @@ struct w9968cf_device {
299 dev_warn(&cam->dev, fmt "\n", ## args); \ 299 dev_warn(&cam->dev, fmt "\n", ## args); \
300 else if ((level) >= 5) \ 300 else if ((level) >= 5) \
301 dev_info(&cam->dev, "[%s:%d] " fmt "\n", \ 301 dev_info(&cam->dev, "[%s:%d] " fmt "\n", \
302 __FUNCTION__, __LINE__ , ## args); \ 302 __FUNCTION__, __LINE__ , ## args); \
303 } \ 303 } \
304} 304}
305/* For generic kernel (not device specific) messages */ 305/* For generic kernel (not device specific) messages */
@@ -311,7 +311,7 @@ struct w9968cf_device {
311 pr_info("w9968cf: " fmt "\n", ## args); \ 311 pr_info("w9968cf: " fmt "\n", ## args); \
312 else if ((level) >= 5) \ 312 else if ((level) >= 5) \
313 pr_debug("w9968cf: [%s:%d] " fmt "\n", __FUNCTION__, \ 313 pr_debug("w9968cf: [%s:%d] " fmt "\n", __FUNCTION__, \
314 __LINE__ , ## args); \ 314 __LINE__ , ## args); \
315 } \ 315 } \
316} 316}
317#else 317#else
diff --git a/drivers/media/video/w9968cf_decoder.h b/drivers/media/video/w9968cf_decoder.h
index 31faccbe8f03..59decbfc540a 100644
--- a/drivers/media/video/w9968cf_decoder.h
+++ b/drivers/media/video/w9968cf_decoder.h
@@ -78,9 +78,9 @@ static const unsigned char UV_QUANTABLE[64] = {
78#define W9968CF_DEC_ERR_NO_EOI -6 78#define W9968CF_DEC_ERR_NO_EOI -6
79 79
80extern void w9968cf_init_decoder(void); 80extern void w9968cf_init_decoder(void);
81extern int w9968cf_check_headers(const unsigned char* Pin, 81extern int w9968cf_check_headers(const unsigned char* Pin,
82 const unsigned long BUF_SIZE); 82 const unsigned long BUF_SIZE);
83extern int w9968cf_decode(const char* Pin, const unsigned long BUF_SIZE, 83extern int w9968cf_decode(const char* Pin, const unsigned long BUF_SIZE,
84 const unsigned W, const unsigned H, char* Pout); 84 const unsigned W, const unsigned H, char* Pout);
85 85
86#endif /* _W9968CF_DECODER_H_ */ 86#endif /* _W9968CF_DECODER_H_ */
diff --git a/drivers/media/video/w9968cf_vpp.h b/drivers/media/video/w9968cf_vpp.h
index f3b91b782671..88c9b6c0cc36 100644
--- a/drivers/media/video/w9968cf_vpp.h
+++ b/drivers/media/video/w9968cf_vpp.h
@@ -29,7 +29,7 @@ struct w9968cf_vpp_t {
29 struct module* owner; 29 struct module* owner;
30 int (*check_headers)(const unsigned char*, const unsigned long); 30 int (*check_headers)(const unsigned char*, const unsigned long);
31 int (*decode)(const char*, const unsigned long, const unsigned, 31 int (*decode)(const char*, const unsigned long, const unsigned,
32 const unsigned, char*); 32 const unsigned, char*);
33 void (*swap_yuvbytes)(void*, unsigned long); 33 void (*swap_yuvbytes)(void*, unsigned long);
34 void (*uyvy_to_rgbx)(u8*, unsigned long, u8*, u16, u8); 34 void (*uyvy_to_rgbx)(u8*, unsigned long, u8*, u16, u8);
35 void (*scale_up)(u8*, u8*, u16, u16, u16, u16, u16); 35 void (*scale_up)(u8*, u8*, u16, u16, u16, u16, u16);
diff --git a/drivers/media/video/zc0301/zc0301.h b/drivers/media/video/zc0301/zc0301.h
index 8e0655140e60..b9c93b8c16f7 100644
--- a/drivers/media/video/zc0301/zc0301.h
+++ b/drivers/media/video/zc0301/zc0301.h
@@ -157,7 +157,7 @@ do { \
157 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ 157 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
158 else if ((level) >= 3) \ 158 else if ((level) >= 3) \
159 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 159 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
160 __FUNCTION__, __LINE__ , ## args); \ 160 __FUNCTION__, __LINE__ , ## args); \
161 } \ 161 } \
162} while (0) 162} while (0)
163# define KDBG(level, fmt, args...) \ 163# define KDBG(level, fmt, args...) \
@@ -167,7 +167,7 @@ do { \
167 pr_info("zc0301: " fmt "\n", ## args); \ 167 pr_info("zc0301: " fmt "\n", ## args); \
168 else if ((level) == 3) \ 168 else if ((level) == 3) \
169 pr_debug("zc0301: [%s:%d] " fmt "\n", __FUNCTION__, \ 169 pr_debug("zc0301: [%s:%d] " fmt "\n", __FUNCTION__, \
170 __LINE__ , ## args); \ 170 __LINE__ , ## args); \
171 } \ 171 } \
172} while (0) 172} while (0)
173# define V4LDBG(level, name, cmd) \ 173# define V4LDBG(level, name, cmd) \
@@ -184,7 +184,7 @@ do { \
184#undef PDBG 184#undef PDBG
185#define PDBG(fmt, args...) \ 185#define PDBG(fmt, args...) \
186dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 186dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
187 __FUNCTION__, __LINE__ , ## args) 187 __FUNCTION__, __LINE__ , ## args)
188 188
189#undef PDBGG 189#undef PDBGG
190#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ 190#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c
index 4036c6268bff..0fad39754f7a 100644
--- a/drivers/media/video/zc0301/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -48,7 +48,7 @@
48/*****************************************************************************/ 48/*****************************************************************************/
49 49
50#define ZC0301_MODULE_NAME "V4L2 driver for ZC0301 " \ 50#define ZC0301_MODULE_NAME "V4L2 driver for ZC0301 " \
51 "Image Processor and Control Chip" 51 "Image Processor and Control Chip"
52#define ZC0301_MODULE_AUTHOR "(C) 2006 Luca Risolia" 52#define ZC0301_MODULE_AUTHOR "(C) 2006 Luca Risolia"
53#define ZC0301_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 53#define ZC0301_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
54#define ZC0301_MODULE_LICENSE "GPL" 54#define ZC0301_MODULE_LICENSE "GPL"
@@ -67,67 +67,67 @@ MODULE_LICENSE(ZC0301_MODULE_LICENSE);
67static short video_nr[] = {[0 ... ZC0301_MAX_DEVICES-1] = -1}; 67static short video_nr[] = {[0 ... ZC0301_MAX_DEVICES-1] = -1};
68module_param_array(video_nr, short, NULL, 0444); 68module_param_array(video_nr, short, NULL, 0444);
69MODULE_PARM_DESC(video_nr, 69MODULE_PARM_DESC(video_nr,
70 "\n<-1|n[,...]> Specify V4L2 minor mode number." 70 "\n<-1|n[,...]> Specify V4L2 minor mode number."
71 "\n -1 = use next available (default)" 71 "\n -1 = use next available (default)"
72 "\n n = use minor number n (integer >= 0)" 72 "\n n = use minor number n (integer >= 0)"
73 "\nYou can specify up to " 73 "\nYou can specify up to "
74 __MODULE_STRING(ZC0301_MAX_DEVICES) " cameras this way." 74 __MODULE_STRING(ZC0301_MAX_DEVICES) " cameras this way."
75 "\nFor example:" 75 "\nFor example:"
76 "\nvideo_nr=-1,2,-1 would assign minor number 2 to" 76 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
77 "\nthe second registered camera and use auto for the first" 77 "\nthe second registered camera and use auto for the first"
78 "\none and for every other camera." 78 "\none and for every other camera."
79 "\n"); 79 "\n");
80 80
81static short force_munmap[] = {[0 ... ZC0301_MAX_DEVICES-1] = 81static short force_munmap[] = {[0 ... ZC0301_MAX_DEVICES-1] =
82 ZC0301_FORCE_MUNMAP}; 82 ZC0301_FORCE_MUNMAP};
83module_param_array(force_munmap, bool, NULL, 0444); 83module_param_array(force_munmap, bool, NULL, 0444);
84MODULE_PARM_DESC(force_munmap, 84MODULE_PARM_DESC(force_munmap,
85 "\n<0|1[,...]> Force the application to unmap previously" 85 "\n<0|1[,...]> Force the application to unmap previously"
86 "\nmapped buffer memory before calling any VIDIOC_S_CROP or" 86 "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
87 "\nVIDIOC_S_FMT ioctl's. Not all the applications support" 87 "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
88 "\nthis feature. This parameter is specific for each" 88 "\nthis feature. This parameter is specific for each"
89 "\ndetected camera." 89 "\ndetected camera."
90 "\n 0 = do not force memory unmapping" 90 "\n 0 = do not force memory unmapping"
91 "\n 1 = force memory unmapping (save memory)" 91 "\n 1 = force memory unmapping (save memory)"
92 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." 92 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
93 "\n"); 93 "\n");
94 94
95static unsigned int frame_timeout[] = {[0 ... ZC0301_MAX_DEVICES-1] = 95static unsigned int frame_timeout[] = {[0 ... ZC0301_MAX_DEVICES-1] =
96 ZC0301_FRAME_TIMEOUT}; 96 ZC0301_FRAME_TIMEOUT};
97module_param_array(frame_timeout, uint, NULL, 0644); 97module_param_array(frame_timeout, uint, NULL, 0644);
98MODULE_PARM_DESC(frame_timeout, 98MODULE_PARM_DESC(frame_timeout,
99 "\n<n[,...]> Timeout for a video frame in seconds." 99 "\n<n[,...]> Timeout for a video frame in seconds."
100 "\nThis parameter is specific for each detected camera." 100 "\nThis parameter is specific for each detected camera."
101 "\nDefault value is "__MODULE_STRING(ZC0301_FRAME_TIMEOUT)"." 101 "\nDefault value is "__MODULE_STRING(ZC0301_FRAME_TIMEOUT)"."
102 "\n"); 102 "\n");
103 103
104#ifdef ZC0301_DEBUG 104#ifdef ZC0301_DEBUG
105static unsigned short debug = ZC0301_DEBUG_LEVEL; 105static unsigned short debug = ZC0301_DEBUG_LEVEL;
106module_param(debug, ushort, 0644); 106module_param(debug, ushort, 0644);
107MODULE_PARM_DESC(debug, 107MODULE_PARM_DESC(debug,
108 "\n<n> Debugging information level, from 0 to 3:" 108 "\n<n> Debugging information level, from 0 to 3:"
109 "\n0 = none (use carefully)" 109 "\n0 = none (use carefully)"
110 "\n1 = critical errors" 110 "\n1 = critical errors"
111 "\n2 = significant informations" 111 "\n2 = significant informations"
112 "\n3 = more verbose messages" 112 "\n3 = more verbose messages"
113 "\nLevel 3 is useful for testing only, when only " 113 "\nLevel 3 is useful for testing only, when only "
114 "one device is used." 114 "one device is used."
115 "\nDefault value is "__MODULE_STRING(ZC0301_DEBUG_LEVEL)"." 115 "\nDefault value is "__MODULE_STRING(ZC0301_DEBUG_LEVEL)"."
116 "\n"); 116 "\n");
117#endif 117#endif
118 118
119/*****************************************************************************/ 119/*****************************************************************************/
120 120
121static u32 121static u32
122zc0301_request_buffers(struct zc0301_device* cam, u32 count, 122zc0301_request_buffers(struct zc0301_device* cam, u32 count,
123 enum zc0301_io_method io) 123 enum zc0301_io_method io)
124{ 124{
125 struct v4l2_pix_format* p = &(cam->sensor.pix_format); 125 struct v4l2_pix_format* p = &(cam->sensor.pix_format);
126 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds); 126 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds);
127 const size_t imagesize = cam->module_param.force_munmap || 127 const size_t imagesize = cam->module_param.force_munmap ||
128 io == IO_READ ? 128 io == IO_READ ?
129 (p->width * p->height * p->priv) / 8 : 129 (p->width * p->height * p->priv) / 8 :
130 (r->width * r->height * p->priv) / 8; 130 (r->width * r->height * p->priv) / 8;
131 void* buff = NULL; 131 void* buff = NULL;
132 u32 i; 132 u32 i;
133 133
@@ -216,7 +216,7 @@ int zc0301_write_reg(struct zc0301_device* cam, u16 index, u16 value)
216 int res; 216 int res;
217 217
218 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0xa0, 0x40, 218 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0xa0, 0x40,
219 value, index, NULL, 0, ZC0301_CTRL_TIMEOUT); 219 value, index, NULL, 0, ZC0301_CTRL_TIMEOUT);
220 if (res < 0) { 220 if (res < 0) {
221 DBG(3, "Failed to write a register (index 0x%04X, " 221 DBG(3, "Failed to write a register (index 0x%04X, "
222 "value 0x%02X, error %d)",index, value, res); 222 "value 0x%02X, error %d)",index, value, res);
@@ -234,7 +234,7 @@ int zc0301_read_reg(struct zc0301_device* cam, u16 index)
234 int res; 234 int res;
235 235
236 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0xa1, 0xc0, 236 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0xa1, 0xc0,
237 0x0001, index, buff, 1, ZC0301_CTRL_TIMEOUT); 237 0x0001, index, buff, 1, ZC0301_CTRL_TIMEOUT);
238 if (res < 0) 238 if (res < 0)
239 DBG(3, "Failed to read a register (index 0x%04X, error %d)", 239 DBG(3, "Failed to read a register (index 0x%04X, error %d)",
240 index, res); 240 index, res);
@@ -337,11 +337,11 @@ static void zc0301_urb_complete(struct urb *urb, struct pt_regs* regs)
337 337
338 if (!(*f)) 338 if (!(*f))
339 (*f) = list_entry(cam->inqueue.next, struct zc0301_frame_t, 339 (*f) = list_entry(cam->inqueue.next, struct zc0301_frame_t,
340 frame); 340 frame);
341 341
342 imagesize = (cam->sensor.pix_format.width * 342 imagesize = (cam->sensor.pix_format.width *
343 cam->sensor.pix_format.height * 343 cam->sensor.pix_format.height *
344 cam->sensor.pix_format.priv) / 8; 344 cam->sensor.pix_format.priv) / 8;
345 345
346 for (i = 0; i < urb->number_of_packets; i++) { 346 for (i = 0; i < urb->number_of_packets; i++) {
347 unsigned int len, status; 347 unsigned int len, status;
@@ -395,8 +395,8 @@ end_of_frame:
395 list_move_tail(&(*f)->frame, &cam->outqueue); 395 list_move_tail(&(*f)->frame, &cam->outqueue);
396 if (!list_empty(&cam->inqueue)) 396 if (!list_empty(&cam->inqueue))
397 (*f) = list_entry(cam->inqueue.next, 397 (*f) = list_entry(cam->inqueue.next,
398 struct zc0301_frame_t, 398 struct zc0301_frame_t,
399 frame); 399 frame);
400 else 400 else
401 (*f) = NULL; 401 (*f) = NULL;
402 spin_unlock(&cam->queue_lock); 402 spin_unlock(&cam->queue_lock);
@@ -429,14 +429,14 @@ static int zc0301_start_transfer(struct zc0301_device* cam)
429 struct usb_device *udev = cam->usbdev; 429 struct usb_device *udev = cam->usbdev;
430 struct urb* urb; 430 struct urb* urb;
431 const unsigned int wMaxPacketSize[] = {0, 128, 192, 256, 384, 431 const unsigned int wMaxPacketSize[] = {0, 128, 192, 256, 384,
432 512, 768, 1023}; 432 512, 768, 1023};
433 const unsigned int psz = wMaxPacketSize[ZC0301_ALTERNATE_SETTING]; 433 const unsigned int psz = wMaxPacketSize[ZC0301_ALTERNATE_SETTING];
434 s8 i, j; 434 s8 i, j;
435 int err = 0; 435 int err = 0;
436 436
437 for (i = 0; i < ZC0301_URBS; i++) { 437 for (i = 0; i < ZC0301_URBS; i++) {
438 cam->transfer_buffer[i] = kzalloc(ZC0301_ISO_PACKETS * psz, 438 cam->transfer_buffer[i] = kzalloc(ZC0301_ISO_PACKETS * psz,
439 GFP_KERNEL); 439 GFP_KERNEL);
440 if (!cam->transfer_buffer[i]) { 440 if (!cam->transfer_buffer[i]) {
441 err = -ENOMEM; 441 err = -ENOMEM;
442 DBG(1, "Not enough memory"); 442 DBG(1, "Not enough memory");
@@ -528,9 +528,9 @@ static int zc0301_stream_interrupt(struct zc0301_device* cam)
528 528
529 cam->stream = STREAM_INTERRUPT; 529 cam->stream = STREAM_INTERRUPT;
530 timeout = wait_event_timeout(cam->wait_stream, 530 timeout = wait_event_timeout(cam->wait_stream,
531 (cam->stream == STREAM_OFF) || 531 (cam->stream == STREAM_OFF) ||
532 (cam->state & DEV_DISCONNECTED), 532 (cam->state & DEV_DISCONNECTED),
533 ZC0301_URB_TIMEOUT); 533 ZC0301_URB_TIMEOUT);
534 if (cam->state & DEV_DISCONNECTED) 534 if (cam->state & DEV_DISCONNECTED)
535 return -ENODEV; 535 return -ENODEV;
536 else if (cam->stream != STREAM_OFF) { 536 else if (cam->stream != STREAM_OFF) {
@@ -548,7 +548,7 @@ static int zc0301_stream_interrupt(struct zc0301_device* cam)
548 548
549static int 549static int
550zc0301_set_compression(struct zc0301_device* cam, 550zc0301_set_compression(struct zc0301_device* cam,
551 struct v4l2_jpegcompression* compression) 551 struct v4l2_jpegcompression* compression)
552{ 552{
553 int r, err = 0; 553 int r, err = 0;
554 554
@@ -670,8 +670,8 @@ static int zc0301_open(struct inode* inode, struct file* filp)
670 } 670 }
671 mutex_unlock(&cam->dev_mutex); 671 mutex_unlock(&cam->dev_mutex);
672 err = wait_event_interruptible_exclusive(cam->open, 672 err = wait_event_interruptible_exclusive(cam->open,
673 cam->state & DEV_DISCONNECTED 673 cam->state & DEV_DISCONNECTED
674 || !cam->users); 674 || !cam->users);
675 if (err) { 675 if (err) {
676 up_read(&zc0301_disconnect); 676 up_read(&zc0301_disconnect);
677 return err; 677 return err;
@@ -802,12 +802,12 @@ zc0301_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
802 return -EAGAIN; 802 return -EAGAIN;
803 } 803 }
804 timeout = wait_event_interruptible_timeout 804 timeout = wait_event_interruptible_timeout
805 ( cam->wait_frame, 805 ( cam->wait_frame,
806 (!list_empty(&cam->outqueue)) || 806 (!list_empty(&cam->outqueue)) ||
807 (cam->state & DEV_DISCONNECTED) || 807 (cam->state & DEV_DISCONNECTED) ||
808 (cam->state & DEV_MISCONFIGURED), 808 (cam->state & DEV_MISCONFIGURED),
809 cam->module_param.frame_timeout * 809 cam->module_param.frame_timeout *
810 1000 * msecs_to_jiffies(1) ); 810 1000 * msecs_to_jiffies(1) );
811 if (timeout < 0) { 811 if (timeout < 0) {
812 mutex_unlock(&cam->fileop_mutex); 812 mutex_unlock(&cam->fileop_mutex);
813 return timeout; 813 return timeout;
@@ -930,7 +930,7 @@ static int zc0301_mmap(struct file* filp, struct vm_area_struct *vma)
930{ 930{
931 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp)); 931 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
932 unsigned long size = vma->vm_end - vma->vm_start, 932 unsigned long size = vma->vm_end - vma->vm_start,
933 start = vma->vm_start; 933 start = vma->vm_start;
934 void *pos; 934 void *pos;
935 u32 i; 935 u32 i;
936 936
@@ -998,13 +998,13 @@ zc0301_vidioc_querycap(struct zc0301_device* cam, void __user * arg)
998 .driver = "zc0301", 998 .driver = "zc0301",
999 .version = ZC0301_MODULE_VERSION_CODE, 999 .version = ZC0301_MODULE_VERSION_CODE,
1000 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | 1000 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1001 V4L2_CAP_STREAMING, 1001 V4L2_CAP_STREAMING,
1002 }; 1002 };
1003 1003
1004 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card)); 1004 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
1005 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0) 1005 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
1006 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id, 1006 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
1007 sizeof(cap.bus_info)); 1007 sizeof(cap.bus_info));
1008 1008
1009 if (copy_to_user(arg, &cap, sizeof(cap))) 1009 if (copy_to_user(arg, &cap, sizeof(cap)))
1010 return -EFAULT; 1010 return -EFAULT;
@@ -1337,7 +1337,7 @@ zc0301_vidioc_g_fmt(struct zc0301_device* cam, void __user * arg)
1337 1337
1338static int 1338static int
1339zc0301_vidioc_try_s_fmt(struct zc0301_device* cam, unsigned int cmd, 1339zc0301_vidioc_try_s_fmt(struct zc0301_device* cam, unsigned int cmd,
1340 void __user * arg) 1340 void __user * arg)
1341{ 1341{
1342 struct zc0301_sensor* s = &cam->sensor; 1342 struct zc0301_sensor* s = &cam->sensor;
1343 struct v4l2_format format; 1343 struct v4l2_format format;
@@ -1600,7 +1600,7 @@ zc0301_vidioc_qbuf(struct zc0301_device* cam, void __user * arg)
1600 1600
1601static int 1601static int
1602zc0301_vidioc_dqbuf(struct zc0301_device* cam, struct file* filp, 1602zc0301_vidioc_dqbuf(struct zc0301_device* cam, struct file* filp,
1603 void __user * arg) 1603 void __user * arg)
1604{ 1604{
1605 struct v4l2_buffer b; 1605 struct v4l2_buffer b;
1606 struct zc0301_frame_t *f; 1606 struct zc0301_frame_t *f;
@@ -1619,12 +1619,12 @@ zc0301_vidioc_dqbuf(struct zc0301_device* cam, struct file* filp,
1619 if (filp->f_flags & O_NONBLOCK) 1619 if (filp->f_flags & O_NONBLOCK)
1620 return -EAGAIN; 1620 return -EAGAIN;
1621 timeout = wait_event_interruptible_timeout 1621 timeout = wait_event_interruptible_timeout
1622 ( cam->wait_frame, 1622 ( cam->wait_frame,
1623 (!list_empty(&cam->outqueue)) || 1623 (!list_empty(&cam->outqueue)) ||
1624 (cam->state & DEV_DISCONNECTED) || 1624 (cam->state & DEV_DISCONNECTED) ||
1625 (cam->state & DEV_MISCONFIGURED), 1625 (cam->state & DEV_MISCONFIGURED),
1626 cam->module_param.frame_timeout * 1626 cam->module_param.frame_timeout *
1627 1000 * msecs_to_jiffies(1) ); 1627 1000 * msecs_to_jiffies(1) );
1628 if (timeout < 0) 1628 if (timeout < 0)
1629 return timeout; 1629 return timeout;
1630 if (cam->state & DEV_DISCONNECTED) 1630 if (cam->state & DEV_DISCONNECTED)
@@ -1748,7 +1748,7 @@ zc0301_vidioc_s_parm(struct zc0301_device* cam, void __user * arg)
1748 1748
1749 1749
1750static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp, 1750static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp,
1751 unsigned int cmd, void __user * arg) 1751 unsigned int cmd, void __user * arg)
1752{ 1752{
1753 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp)); 1753 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
1754 1754
@@ -1842,7 +1842,7 @@ static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp,
1842 1842
1843 1843
1844static int zc0301_ioctl(struct inode* inode, struct file* filp, 1844static int zc0301_ioctl(struct inode* inode, struct file* filp,
1845 unsigned int cmd, unsigned long arg) 1845 unsigned int cmd, unsigned long arg)
1846{ 1846{
1847 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp)); 1847 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
1848 int err = 0; 1848 int err = 0;
@@ -1948,7 +1948,7 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
1948 mutex_lock(&cam->dev_mutex); 1948 mutex_lock(&cam->dev_mutex);
1949 1949
1950 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 1950 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
1951 video_nr[dev_nr]); 1951 video_nr[dev_nr]);
1952 if (err) { 1952 if (err) {
1953 DBG(1, "V4L2 device registration failed"); 1953 DBG(1, "V4L2 device registration failed");
1954 if (err == -ENFILE && video_nr[dev_nr] == -1) 1954 if (err == -ENFILE && video_nr[dev_nr] == -1)
diff --git a/drivers/media/video/zc0301/zc0301_pas202bcb.c b/drivers/media/video/zc0301/zc0301_pas202bcb.c
index 9d282a22c15f..eaadf0252049 100644
--- a/drivers/media/video/zc0301/zc0301_pas202bcb.c
+++ b/drivers/media/video/zc0301/zc0301_pas202bcb.c
@@ -24,10 +24,10 @@
24 24
25/* 25/*
26 NOTE: Sensor controls are disabled for now, becouse changing them while 26 NOTE: Sensor controls are disabled for now, becouse changing them while
27 streaming sometimes results in out-of-sync video frames. We'll use 27 streaming sometimes results in out-of-sync video frames. We'll use
28 the default initialization, until we know how to stop and start video 28 the default initialization, until we know how to stop and start video
29 in the chip. However, the image quality still looks good under various 29 in the chip. However, the image quality still looks good under various
30 light conditions. 30 light conditions.
31*/ 31*/
32 32
33#include <linux/delay.h> 33#include <linux/delay.h>
@@ -165,7 +165,7 @@ static int pas202bcb_init(struct zc0301_device* cam)
165 165
166 166
167static int pas202bcb_get_ctrl(struct zc0301_device* cam, 167static int pas202bcb_get_ctrl(struct zc0301_device* cam,
168 struct v4l2_control* ctrl) 168 struct v4l2_control* ctrl)
169{ 169{
170 switch (ctrl->id) { 170 switch (ctrl->id) {
171 case V4L2_CID_EXPOSURE: 171 case V4L2_CID_EXPOSURE:
@@ -208,7 +208,7 @@ static int pas202bcb_get_ctrl(struct zc0301_device* cam,
208 208
209 209
210static int pas202bcb_set_ctrl(struct zc0301_device* cam, 210static int pas202bcb_set_ctrl(struct zc0301_device* cam,
211 const struct v4l2_control* ctrl) 211 const struct v4l2_control* ctrl)
212{ 212{
213 int err = 0; 213 int err = 0;
214 214
diff --git a/drivers/media/video/zc0301/zc0301_sensor.h b/drivers/media/video/zc0301/zc0301_sensor.h
index cf0965a81d01..1f95c28b1015 100644
--- a/drivers/media/video/zc0301/zc0301_sensor.h
+++ b/drivers/media/video/zc0301/zc0301_sensor.h
@@ -51,7 +51,7 @@ zc0301_attach_sensor(struct zc0301_device* cam, struct zc0301_sensor* sensor);
51 51
52#define ZC0301_USB_DEVICE(vend, prod, intclass) \ 52#define ZC0301_USB_DEVICE(vend, prod, intclass) \
53 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ 53 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
54 USB_DEVICE_ID_MATCH_INT_CLASS, \ 54 USB_DEVICE_ID_MATCH_INT_CLASS, \
55 .idVendor = (vend), \ 55 .idVendor = (vend), \
56 .idProduct = (prod), \ 56 .idProduct = (prod), \
57 .bInterfaceClass = (intclass) 57 .bInterfaceClass = (intclass)
@@ -92,7 +92,7 @@ struct zc0301_sensor {
92 int (*init)(struct zc0301_device*); 92 int (*init)(struct zc0301_device*);
93 int (*get_ctrl)(struct zc0301_device*, struct v4l2_control* ctrl); 93 int (*get_ctrl)(struct zc0301_device*, struct v4l2_control* ctrl);
94 int (*set_ctrl)(struct zc0301_device*, 94 int (*set_ctrl)(struct zc0301_device*,
95 const struct v4l2_control* ctrl); 95 const struct v4l2_control* ctrl);
96 int (*set_crop)(struct zc0301_device*, const struct v4l2_rect* rect); 96 int (*set_crop)(struct zc0301_device*, const struct v4l2_rect* rect);
97 97
98 /* Private */ 98 /* Private */
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
index ad04a129499d..0166f555a5ca 100644
--- a/drivers/media/video/zoran.h
+++ b/drivers/media/video/zoran.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * zoran - Iomega Buz driver 2 * zoran - Iomega Buz driver
3 * 3 *
4 * Copyright (C) 1999 Rainer Johanni <Rainer@Johanni.de> 4 * Copyright (C) 1999 Rainer Johanni <Rainer@Johanni.de>
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index b22dbb6d18f6..0a85c9e7fb48 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles card-specific data and detection 6 * This part handles card-specific data and detection
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
diff --git a/drivers/media/video/zoran_card.h b/drivers/media/video/zoran_card.h
index e5b6acd3eedc..ad997c30bee5 100644
--- a/drivers/media/video/zoran_card.h
+++ b/drivers/media/video/zoran_card.h
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles card-specific data and detection 6 * This part handles card-specific data and detection
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
index 4e15afdec4c9..c690b2ee880a 100644
--- a/drivers/media/video/zoran_device.c
+++ b/drivers/media/video/zoran_device.c
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles device access (PCI/I2C/codec/...) 6 * This part handles device access (PCI/I2C/codec/...)
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
@@ -492,7 +492,7 @@ zr36057_set_vfe (struct zoran *zr,
492 /* (Ronald) don't write this if overlay_mask = NULL */ 492 /* (Ronald) don't write this if overlay_mask = NULL */
493 if (zr->overlay_mask) { 493 if (zr->overlay_mask) {
494 /* Write overlay clipping mask data, but don't enable overlay clipping */ 494 /* Write overlay clipping mask data, but don't enable overlay clipping */
495 /* RJ: since this makes only sense on the screen, we use 495 /* RJ: since this makes only sense on the screen, we use
496 * zr->overlay_settings.width instead of video_width */ 496 * zr->overlay_settings.width instead of video_width */
497 497
498 mask_line_size = (BUZ_MAX_WIDTH + 31) / 32; 498 mask_line_size = (BUZ_MAX_WIDTH + 31) / 32;
@@ -819,12 +819,12 @@ zr36057_set_jpg (struct zoran *zr,
819 if (zr->card.vfe_pol.hsync_pol) 819 if (zr->card.vfe_pol.hsync_pol)
820 btor(ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR); 820 btor(ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR);
821 else 821 else
822 btand(~ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR); 822 btand(~ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR);
823 reg = ((tvn->HSyncStart) << ZR36057_HSP_HsyncStart) | 823 reg = ((tvn->HSyncStart) << ZR36057_HSP_HsyncStart) |
824 (tvn->Wt << ZR36057_HSP_LineTot); 824 (tvn->Wt << ZR36057_HSP_LineTot);
825 btwrite(reg, ZR36057_HSP); 825 btwrite(reg, ZR36057_HSP);
826 reg = ((zr->jpg_settings.img_x + 826 reg = ((zr->jpg_settings.img_x +
827 tvn->HStart + 4) << ZR36057_FHAP_NAX) | 827 tvn->HStart + 4) << ZR36057_FHAP_NAX) |
828 (zr->jpg_settings.img_width << ZR36057_FHAP_PAX); 828 (zr->jpg_settings.img_width << ZR36057_FHAP_PAX);
829 btwrite(reg, ZR36057_FHAP); 829 btwrite(reg, ZR36057_FHAP);
830 830
@@ -1272,15 +1272,15 @@ error_handler (struct zoran *zr,
1272 if (zr->JPEG_error != 1) { 1272 if (zr->JPEG_error != 1) {
1273 /* 1273 /*
1274 * First entry: error just happened during normal operation 1274 * First entry: error just happened during normal operation
1275 * 1275 *
1276 * In BUZ_MODE_MOTION_COMPRESS: 1276 * In BUZ_MODE_MOTION_COMPRESS:
1277 * 1277 *
1278 * Possible glitch in TV signal. In this case we should 1278 * Possible glitch in TV signal. In this case we should
1279 * stop the codec and wait for good quality signal before 1279 * stop the codec and wait for good quality signal before
1280 * restarting it to avoid further problems 1280 * restarting it to avoid further problems
1281 * 1281 *
1282 * In BUZ_MODE_MOTION_DECOMPRESS: 1282 * In BUZ_MODE_MOTION_DECOMPRESS:
1283 * 1283 *
1284 * Bad JPEG frame: we have to mark it as processed (codec crashed 1284 * Bad JPEG frame: we have to mark it as processed (codec crashed
1285 * and was not able to do it itself), and to remove it from queue. 1285 * and was not able to do it itself), and to remove it from queue.
1286 */ 1286 */
diff --git a/drivers/media/video/zoran_device.h b/drivers/media/video/zoran_device.h
index f315203d7105..f19705cbdb39 100644
--- a/drivers/media/video/zoran_device.h
+++ b/drivers/media/video/zoran_device.h
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles card-specific data and detection 6 * This part handles card-specific data and detection
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index b2c6e01e3923..b5a576a37fd2 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -94,7 +94,7 @@
94 V4L2_CAP_VIDEO_CAPTURE |\ 94 V4L2_CAP_VIDEO_CAPTURE |\
95 V4L2_CAP_VIDEO_OUTPUT |\ 95 V4L2_CAP_VIDEO_OUTPUT |\
96 V4L2_CAP_VIDEO_OVERLAY \ 96 V4L2_CAP_VIDEO_OVERLAY \
97 ) 97 )
98#endif 98#endif
99 99
100#include <asm/byteorder.h> 100#include <asm/byteorder.h>
@@ -165,7 +165,7 @@ const struct zoran_format zoran_formats[] = {
165#endif 165#endif
166 .depth = 16, 166 .depth = 16,
167 .flags = ZORAN_FORMAT_CAPTURE | 167 .flags = ZORAN_FORMAT_CAPTURE |
168 ZORAN_FORMAT_OVERLAY, 168 ZORAN_FORMAT_OVERLAY,
169 }, { 169 }, {
170 .name = "Hardware-encoded Motion-JPEG", 170 .name = "Hardware-encoded Motion-JPEG",
171 .palette = -1, 171 .palette = -1,
@@ -670,7 +670,7 @@ jpg_fbuffer_free (struct file *file)
670 j])))); 670 j]))));
671 free_page((unsigned long) 671 free_page((unsigned long)
672 bus_to_virt 672 bus_to_virt
673 (le32_to_cpu 673 (le32_to_cpu
674 (fh->jpg_buffers. 674 (fh->jpg_buffers.
675 buffer[i]. 675 buffer[i].
676 frag_tab[2 * j]))); 676 frag_tab[2 * j])));
@@ -1871,7 +1871,7 @@ zoran_v4l2_buffer_status (struct file *file,
1871 1871
1872static int 1872static int
1873zoran_set_norm (struct zoran *zr, 1873zoran_set_norm (struct zoran *zr,
1874 int norm) /* VIDEO_MODE_* */ 1874 int norm) /* VIDEO_MODE_* */
1875{ 1875{
1876 int norm_encoder, on; 1876 int norm_encoder, on;
1877 1877
@@ -2006,9 +2006,9 @@ zoran_set_input (struct zoran *zr,
2006 2006
2007static int 2007static int
2008zoran_do_ioctl (struct inode *inode, 2008zoran_do_ioctl (struct inode *inode,
2009 struct file *file, 2009 struct file *file,
2010 unsigned int cmd, 2010 unsigned int cmd,
2011 void *arg) 2011 void *arg)
2012{ 2012{
2013 struct zoran_fh *fh = file->private_data; 2013 struct zoran_fh *fh = file->private_data;
2014 struct zoran *zr = fh->zr; 2014 struct zoran *zr = fh->zr;
@@ -2095,7 +2095,7 @@ zoran_do_ioctl (struct inode *inode,
2095 break; 2095 break;
2096 2096
2097 /* RJ: the documentation at http://roadrunner.swansea.linux.org.uk/v4lapi.shtml says: 2097 /* RJ: the documentation at http://roadrunner.swansea.linux.org.uk/v4lapi.shtml says:
2098 * 2098 *
2099 * * "The VIDIOCSCHAN ioctl takes an integer argument and switches the capture to this input." 2099 * * "The VIDIOCSCHAN ioctl takes an integer argument and switches the capture to this input."
2100 * * ^^^^^^^ 2100 * * ^^^^^^^
2101 * * The famos BTTV driver has it implemented with a struct video_channel argument 2101 * * The famos BTTV driver has it implemented with a struct video_channel argument
diff --git a/drivers/media/video/zoran_procfs.c b/drivers/media/video/zoran_procfs.c
index f0d9b13c3c6c..a00fae90229a 100644
--- a/drivers/media/video/zoran_procfs.c
+++ b/drivers/media/video/zoran_procfs.c
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles the procFS entries (/proc/ZORAN[%d]) 6 * This part handles the procFS entries (/proc/ZORAN[%d])
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
diff --git a/drivers/media/video/zoran_procfs.h b/drivers/media/video/zoran_procfs.h
index 8904fc959555..f2d5b1ba448f 100644
--- a/drivers/media/video/zoran_procfs.h
+++ b/drivers/media/video/zoran_procfs.h
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles card-specific data and detection 6 * This part handles card-specific data and detection
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
diff --git a/drivers/media/video/zr36016.c b/drivers/media/video/zr36016.c
index 10130ef67ea7..62f77584fb85 100644
--- a/drivers/media/video/zr36016.c
+++ b/drivers/media/video/zr36016.c
@@ -34,7 +34,7 @@
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/wait.h> 35#include <linux/wait.h>
36 36
37/* includes for structures and defines regarding video 37/* includes for structures and defines regarding video
38 #include<linux/videodev.h> */ 38 #include<linux/videodev.h> */
39 39
40/* I/O commands, error codes */ 40/* I/O commands, error codes */
@@ -143,8 +143,8 @@ zr36016_readi (struct zr36016 *ptr,
143 143
144static void 144static void
145zr36016_writei (struct zr36016 *ptr, 145zr36016_writei (struct zr36016 *ptr,
146 u16 reg, 146 u16 reg,
147 u8 value) 147 u8 value)
148{ 148{
149 dprintk(4, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name, 149 dprintk(4, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name,
150 value, reg); 150 value, reg);
@@ -192,7 +192,7 @@ zr36016_basic_test (struct zr36016 *ptr)
192 dprintk(1, "\n"); 192 dprintk(1, "\n");
193 } 193 }
194 // for testing just write 0, then the default value to a register and read 194 // for testing just write 0, then the default value to a register and read
195 // it back in both cases 195 // it back in both cases
196 zr36016_writei(ptr, ZR016I_PAX_LO, 0x00); 196 zr36016_writei(ptr, ZR016I_PAX_LO, 0x00);
197 if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0) { 197 if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0) {
198 dprintk(1, 198 dprintk(1,
@@ -232,17 +232,17 @@ zr36016_basic_test (struct zr36016 *ptr)
232static int zr36016_pushit (struct zr36016 *ptr, 232static int zr36016_pushit (struct zr36016 *ptr,
233 u16 startreg, 233 u16 startreg,
234 u16 len, 234 u16 len,
235 const char *data) 235 const char *data)
236{ 236{
237 int i=0; 237 int i=0;
238 238
239 dprintk(4, "%s: write data block to 0x%04x (len=%d)\n", 239 dprintk(4, "%s: write data block to 0x%04x (len=%d)\n",
240 ptr->name, startreg,len); 240 ptr->name, startreg,len);
241 while (i<len) { 241 while (i<len) {
242 zr36016_writei(ptr, startreg++, data[i++]); 242 zr36016_writei(ptr, startreg++, data[i++]);
243 } 243 }
244 244
245 return i; 245 return i;
246} 246}
247#endif 247#endif
248 248
diff --git a/drivers/media/video/zr36050.c b/drivers/media/video/zr36050.c
index 6699725be605..a6bbd125631c 100644
--- a/drivers/media/video/zr36050.c
+++ b/drivers/media/video/zr36050.c
@@ -34,7 +34,7 @@
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/wait.h> 35#include <linux/wait.h>
36 36
37/* includes for structures and defines regarding video 37/* includes for structures and defines regarding video
38 #include<linux/videodev.h> */ 38 #include<linux/videodev.h> */
39 39
40/* I/O commands, error codes */ 40/* I/O commands, error codes */
@@ -171,7 +171,7 @@ zr36050_wait_end (struct zr36050 *ptr)
171/* ========================================================================= 171/* =========================================================================
172 Local helper function: 172 Local helper function:
173 173
174 basic test of "connectivity", writes/reads to/from memory the SOF marker 174 basic test of "connectivity", writes/reads to/from memory the SOF marker
175 ========================================================================= */ 175 ========================================================================= */
176 176
177static int 177static int
@@ -218,9 +218,9 @@ zr36050_basic_test (struct zr36050 *ptr)
218 218
219static int 219static int
220zr36050_pushit (struct zr36050 *ptr, 220zr36050_pushit (struct zr36050 *ptr,
221 u16 startreg, 221 u16 startreg,
222 u16 len, 222 u16 len,
223 const char *data) 223 const char *data)
224{ 224{
225 int i = 0; 225 int i = 0;
226 226
@@ -345,7 +345,7 @@ static const char zr36050_decimation_v[8] = { 1, 1, 1, 0, 0, 0, 0, 0 };
345/* ------------------------------------------------------------------------- */ 345/* ------------------------------------------------------------------------- */
346 346
347/* SOF (start of frame) segment depends on width, height and sampling ratio 347/* SOF (start of frame) segment depends on width, height and sampling ratio
348 of each color component */ 348 of each color component */
349 349
350static int 350static int
351zr36050_set_sof (struct zr36050 *ptr) 351zr36050_set_sof (struct zr36050 *ptr)
@@ -376,8 +376,8 @@ zr36050_set_sof (struct zr36050 *ptr)
376 376
377/* ------------------------------------------------------------------------- */ 377/* ------------------------------------------------------------------------- */
378 378
379/* SOS (start of scan) segment depends on the used scan components 379/* SOS (start of scan) segment depends on the used scan components
380 of each color component */ 380 of each color component */
381 381
382static int 382static int
383zr36050_set_sos (struct zr36050 *ptr) 383zr36050_set_sos (struct zr36050 *ptr)
diff --git a/drivers/media/video/zr36057.h b/drivers/media/video/zr36057.h
index 159abfa034d9..54c9362aa980 100644
--- a/drivers/media/video/zr36057.h
+++ b/drivers/media/video/zr36057.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * zr36057.h - zr36057 register offsets 2 * zr36057.h - zr36057 register offsets
3 * 3 *
4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -27,14 +27,14 @@
27#define ZR36057_VFEHCR 0x000 /* Video Front End, Horizontal Configuration Register */ 27#define ZR36057_VFEHCR 0x000 /* Video Front End, Horizontal Configuration Register */
28#define ZR36057_VFEHCR_HSPol (1<<30) 28#define ZR36057_VFEHCR_HSPol (1<<30)
29#define ZR36057_VFEHCR_HStart 10 29#define ZR36057_VFEHCR_HStart 10
30#define ZR36057_VFEHCR_HEnd 0 30#define ZR36057_VFEHCR_HEnd 0
31#define ZR36057_VFEHCR_Hmask 0x3ff 31#define ZR36057_VFEHCR_Hmask 0x3ff
32 32
33#define ZR36057_VFEVCR 0x004 /* Video Front End, Vertical Configuration Register */ 33#define ZR36057_VFEVCR 0x004 /* Video Front End, Vertical Configuration Register */
34#define ZR36057_VFEVCR_VSPol (1<<30) 34#define ZR36057_VFEVCR_VSPol (1<<30)
35#define ZR36057_VFEVCR_VStart 10 35#define ZR36057_VFEVCR_VStart 10
36#define ZR36057_VFEVCR_VEnd 0 36#define ZR36057_VFEVCR_VEnd 0
37#define ZR36057_VFEVCR_Vmask 0x3ff 37#define ZR36057_VFEVCR_Vmask 0x3ff
38 38
39#define ZR36057_VFESPFR 0x008 /* Video Front End, Scaler and Pixel Format Register */ 39#define ZR36057_VFESPFR 0x008 /* Video Front End, Scaler and Pixel Format Register */
40#define ZR36057_VFESPFR_ExtFl (1<<26) 40#define ZR36057_VFESPFR_ExtFl (1<<26)
diff --git a/drivers/media/video/zr36060.c b/drivers/media/video/zr36060.c
index d8dd003a7aad..97c8f9b9dc12 100644
--- a/drivers/media/video/zr36060.c
+++ b/drivers/media/video/zr36060.c
@@ -34,7 +34,7 @@
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/wait.h> 35#include <linux/wait.h>
36 36
37/* includes for structures and defines regarding video 37/* includes for structures and defines regarding video
38 #include<linux/videodev.h> */ 38 #include<linux/videodev.h> */
39 39
40/* I/O commands, error codes */ 40/* I/O commands, error codes */
@@ -173,7 +173,7 @@ zr36060_wait_end (struct zr36060 *ptr)
173/* ========================================================================= 173/* =========================================================================
174 Local helper function: 174 Local helper function:
175 175
176 basic test of "connectivity", writes/reads to/from memory the SOF marker 176 basic test of "connectivity", writes/reads to/from memory the SOF marker
177 ========================================================================= */ 177 ========================================================================= */
178 178
179static int 179static int
@@ -208,9 +208,9 @@ zr36060_basic_test (struct zr36060 *ptr)
208 208
209static int 209static int
210zr36060_pushit (struct zr36060 *ptr, 210zr36060_pushit (struct zr36060 *ptr,
211 u16 startreg, 211 u16 startreg,
212 u16 len, 212 u16 len,
213 const char *data) 213 const char *data)
214{ 214{
215 int i = 0; 215 int i = 0;
216 216
@@ -335,7 +335,7 @@ static const char zr36060_decimation_v[8] = { 1, 1, 1, 0, 0, 0, 0, 0 };
335/* ------------------------------------------------------------------------- */ 335/* ------------------------------------------------------------------------- */
336 336
337/* SOF (start of frame) segment depends on width, height and sampling ratio 337/* SOF (start of frame) segment depends on width, height and sampling ratio
338 of each color component */ 338 of each color component */
339 339
340static int 340static int
341zr36060_set_sof (struct zr36060 *ptr) 341zr36060_set_sof (struct zr36060 *ptr)
@@ -367,8 +367,8 @@ zr36060_set_sof (struct zr36060 *ptr)
367 367
368/* ------------------------------------------------------------------------- */ 368/* ------------------------------------------------------------------------- */
369 369
370/* SOS (start of scan) segment depends on the used scan components 370/* SOS (start of scan) segment depends on the used scan components
371 of each color component */ 371 of each color component */
372 372
373static int 373static int
374zr36060_set_sos (struct zr36060 *ptr) 374zr36060_set_sos (struct zr36060 *ptr)
@@ -385,7 +385,7 @@ zr36060_set_sos (struct zr36060 *ptr)
385 for (i = 0; i < NO_OF_COMPONENTS; i++) { 385 for (i = 0; i < NO_OF_COMPONENTS; i++) {
386 sos_data[5 + (i * 2)] = i; // index 386 sos_data[5 + (i * 2)] = i; // index
387 sos_data[6 + (i * 2)] = (zr36060_td[i] << 4) | 387 sos_data[6 + (i * 2)] = (zr36060_td[i] << 4) |
388 zr36060_ta[i]; // AC/DC tbl.sel. 388 zr36060_ta[i]; // AC/DC tbl.sel.
389 } 389 }
390 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 2] = 00; // scan start 390 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 2] = 00; // scan start
391 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 3] = 0x3f; 391 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 3] = 0x3f;
@@ -999,7 +999,7 @@ zr36060_cleanup_module (void)
999 dprintk(1, 999 dprintk(1,
1000 "zr36060: something's wrong - %d codecs left somehow.\n", 1000 "zr36060: something's wrong - %d codecs left somehow.\n",
1001 zr36060_codecs); 1001 zr36060_codecs);
1002 } 1002 }
1003 1003
1004 /* however, we can't just stay alive */ 1004 /* however, we can't just stay alive */
1005 videocodec_unregister(&zr36060_codec); 1005 videocodec_unregister(&zr36060_codec);
diff --git a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c
index d4c633b8a7f5..9d340aa443c3 100644
--- a/drivers/media/video/zr36120.c
+++ b/drivers/media/video/zr36120.c
@@ -316,7 +316,7 @@ DEBUG(printk(CARD_DEBUG "%p added to queue\n",CARD,item));
316 item->status = FBUFFER_BUSY; 316 item->status = FBUFFER_BUSY;
317 if (!lastitem) 317 if (!lastitem)
318 ztv->workqueue = item; 318 ztv->workqueue = item;
319 else 319 else
320 lastitem->next = item; 320 lastitem->next = item;
321 lastitem = item; 321 lastitem = item;
322 } 322 }
@@ -516,7 +516,7 @@ DEBUG(printk(KERN_DEBUG " %d: clip(%d,%d,%d,%d)\n", i,vp->x,vp->y,vp->widt
516 zraor((ztv->vidInterlace*ystep)<<0,~ZORAN_OCR_MASKSTRIDE,ZORAN_OCR); 516 zraor((ztv->vidInterlace*ystep)<<0,~ZORAN_OCR_MASKSTRIDE,ZORAN_OCR);
517} 517}
518 518
519struct tvnorm 519struct tvnorm
520{ 520{
521 u16 Wt, Wa, Ht, Ha, HStart, VStart; 521 u16 Wt, Wa, Ht, Ha, HStart, VStart;
522}; 522};
@@ -660,7 +660,7 @@ DEBUG(printk(KERN_DEBUG " Y: scale=0, start=%d, end=%d\n", Hstart, Hend));
660 int HorDcm = 64-X; 660 int HorDcm = 64-X;
661 int hcrop1 = 2*(Wa-We)/4; 661 int hcrop1 = 2*(Wa-We)/4;
662 /* 662 /*
663 * BUGFIX: Juha Nurmela <junki@qn-lpr2-165.quicknet.inet.fi> 663 * BUGFIX: Juha Nurmela <junki@qn-lpr2-165.quicknet.inet.fi>
664 * found the solution to the color phase shift. 664 * found the solution to the color phase shift.
665 * See ChangeLog for the full explanation) 665 * See ChangeLog for the full explanation)
666 */ 666 */
@@ -812,12 +812,12 @@ void zoran_close(struct video_device* dev)
812 812
813 zoran_common_close(ztv); 813 zoran_common_close(ztv);
814 814
815 /* 815 /*
816 * This is sucky but right now I can't find a good way to 816 * This is sucky but right now I can't find a good way to
817 * be sure its safe to free the buffer. We wait 5-6 fields 817 * be sure its safe to free the buffer. We wait 5-6 fields
818 * which is more than sufficient to be sure. 818 * which is more than sufficient to be sure.
819 */ 819 */
820 msleep(100); /* Wait 1/10th of a second */ 820 msleep(100); /* Wait 1/10th of a second */
821 821
822 /* free the allocated framebuffer */ 822 /* free the allocated framebuffer */
823 bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE); 823 bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE);
@@ -1436,7 +1436,7 @@ int zoran_ioctl(struct video_device* dev, unsigned int cmd, void *arg)
1436 1436
1437 /* Why isn't this in the API? 1437 /* Why isn't this in the API?
1438 * And why doesn't it take a buffer number? 1438 * And why doesn't it take a buffer number?
1439 case BTTV_FIELDNR: 1439 case BTTV_FIELDNR:
1440 { 1440 {
1441 unsigned long v = ztv->lastfieldnr; 1441 unsigned long v = ztv->lastfieldnr;
1442 if (copy_to_user(arg,&v,sizeof(v))) 1442 if (copy_to_user(arg,&v,sizeof(v)))
@@ -1557,12 +1557,12 @@ void vbi_close(struct video_device *dev)
1557 1557
1558 zoran_common_close(ztv); 1558 zoran_common_close(ztv);
1559 1559
1560 /* 1560 /*
1561 * This is sucky but right now I can't find a good way to 1561 * This is sucky but right now I can't find a good way to
1562 * be sure its safe to free the buffer. We wait 5-6 fields 1562 * be sure its safe to free the buffer. We wait 5-6 fields
1563 * which is more than sufficient to be sure. 1563 * which is more than sufficient to be sure.
1564 */ 1564 */
1565 msleep(100); /* Wait 1/10th of a second */ 1565 msleep(100); /* Wait 1/10th of a second */
1566 1566
1567 for (item=ztv->readinfo; item!=ztv->readinfo+ZORAN_VBI_BUFFERS; item++) 1567 for (item=ztv->readinfo; item!=ztv->readinfo+ZORAN_VBI_BUFFERS; item++)
1568 { 1568 {
@@ -1620,7 +1620,7 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb
1620 write_unlock_irq(&ztv->lock); 1620 write_unlock_irq(&ztv->lock);
1621 return -EWOULDBLOCK; 1621 return -EWOULDBLOCK;
1622 } 1622 }
1623 1623
1624 /* mark the unused buffer as wanted */ 1624 /* mark the unused buffer as wanted */
1625 unused->status = FBUFFER_BUSY; 1625 unused->status = FBUFFER_BUSY;
1626 unused->next = 0; 1626 unused->next = 0;
@@ -1671,7 +1671,7 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb
1671 if (count == 2*19*2048) { 1671 if (count == 2*19*2048) {
1672 /* 1672 /*
1673 * Extreme HACK, old VBI programs expect 2048 points 1673 * Extreme HACK, old VBI programs expect 2048 points
1674 * of data, and we only got 864 orso. Double each 1674 * of data, and we only got 864 orso. Double each
1675 * datapoint and clear the rest of the line. 1675 * datapoint and clear the rest of the line.
1676 * This way we have appear to have a 1676 * This way we have appear to have a
1677 * sample_frequency of 29.5 Mc. 1677 * sample_frequency of 29.5 Mc.
@@ -1956,7 +1956,7 @@ int __init init_zoran(int card)
1956 zrand(~ZORAN_VDC_TRICOM, ZORAN_VDC); 1956 zrand(~ZORAN_VDC_TRICOM, ZORAN_VDC);
1957 1957
1958 /* external FL determines TOP frame */ 1958 /* external FL determines TOP frame */
1959 zror(ZORAN_VFEC_EXTFL, ZORAN_VFEC); 1959 zror(ZORAN_VFEC_EXTFL, ZORAN_VFEC);
1960 1960
1961 /* set HSpol */ 1961 /* set HSpol */
1962 if (ztv->card->hsync_pos) 1962 if (ztv->card->hsync_pos)
@@ -2012,7 +2012,7 @@ void release_zoran(int max)
2012 struct zoran *ztv; 2012 struct zoran *ztv;
2013 int i; 2013 int i;
2014 2014
2015 for (i=0;i<max; i++) 2015 for (i=0;i<max; i++)
2016 { 2016 {
2017 ztv = &zorans[i]; 2017 ztv = &zorans[i];
2018 2018
@@ -2029,7 +2029,7 @@ void release_zoran(int max)
2029 2029
2030 /* free it */ 2030 /* free it */
2031 free_irq(ztv->dev->irq,ztv); 2031 free_irq(ztv->dev->irq,ztv);
2032 2032
2033 /* unregister i2c_bus */ 2033 /* unregister i2c_bus */
2034 i2c_unregister_bus((&ztv->i2c)); 2034 i2c_unregister_bus((&ztv->i2c));
2035 2035
@@ -2050,7 +2050,7 @@ void __exit zr36120_exit(void)
2050int __init zr36120_init(void) 2050int __init zr36120_init(void)
2051{ 2051{
2052 int card; 2052 int card;
2053 2053
2054 handle_chipset(); 2054 handle_chipset();
2055 zoran_cards = find_zoran(); 2055 zoran_cards = find_zoran();
2056 if (zoran_cards<0) 2056 if (zoran_cards<0)
@@ -2063,7 +2063,7 @@ int __init zr36120_init(void)
2063 /* only release the zorans we have registered */ 2063 /* only release the zorans we have registered */
2064 release_zoran(card); 2064 release_zoran(card);
2065 return -EIO; 2065 return -EIO;
2066 } 2066 }
2067 } 2067 }
2068 return 0; 2068 return 0;
2069} 2069}
diff --git a/drivers/media/video/zr36120.h b/drivers/media/video/zr36120.h
index 571f8e84b58a..a71e485b0f98 100644
--- a/drivers/media/video/zr36120.h
+++ b/drivers/media/video/zr36120.h
@@ -1,4 +1,4 @@
1/* 1/*
2 zr36120.h - Zoran 36120/36125 based framegrabbers 2 zr36120.h - Zoran 36120/36125 based framegrabbers
3 3
4 Copyright (C) 1998-1999 Pauline Middelink (middelin@polyware.nl) 4 Copyright (C) 1998-1999 Pauline Middelink (middelin@polyware.nl)
@@ -89,7 +89,7 @@ struct vidinfo {
89 ulong* overlay; /* kernel addr of overlay mask */ 89 ulong* overlay; /* kernel addr of overlay mask */
90}; 90};
91 91
92struct zoran 92struct zoran
93{ 93{
94 struct video_device video_dev; 94 struct video_device video_dev;
95#define CARD_DEBUG KERN_DEBUG "%s(%lu): " 95#define CARD_DEBUG KERN_DEBUG "%s(%lu): "
@@ -106,7 +106,7 @@ struct zoran
106 uint norm; /* 0=PAL, 1=NTSC, 2=SECAM */ 106 uint norm; /* 0=PAL, 1=NTSC, 2=SECAM */
107 uint tuner_freq; /* Current freq in kHz */ 107 uint tuner_freq; /* Current freq in kHz */
108 struct video_picture picture; /* Current picture params */ 108 struct video_picture picture; /* Current picture params */
109 109
110 /* videocard details */ 110 /* videocard details */
111 uint swidth; /* screen width */ 111 uint swidth; /* screen width */
112 uint sheight; /* screen height */ 112 uint sheight; /* screen height */