aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/Kconfig45
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c4
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c5
-rw-r--r--drivers/media/video/cx88/cx88-video.c1
-rw-r--r--drivers/media/video/cx88/cx88-vp3054-i2c.c7
-rw-r--r--drivers/media/video/cx88/cx88-vp3054-i2c.h1
-rw-r--r--drivers/media/video/em28xx/Kconfig2
-rw-r--r--drivers/media/video/et61x251/Kconfig2
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c2
-rw-r--r--drivers/media/video/pvrusb2/Kconfig2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-encoder.c13
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c10
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c23
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c14
-rw-r--r--drivers/media/video/pwc/Kconfig2
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c123
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c17
-rw-r--r--drivers/media/video/saa7134/saa7134.h3
-rw-r--r--drivers/media/video/sn9c102/Kconfig2
-rw-r--r--drivers/media/video/sn9c102/sn9c102.h2
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c91
-rw-r--r--drivers/media/video/sn9c102/sn9c102_devtable.h4
-rw-r--r--drivers/media/video/sn9c102/sn9c102_hv7131d.c6
-rw-r--r--drivers/media/video/sn9c102/sn9c102_hv7131r.c8
-rw-r--r--drivers/media/video/sn9c102/sn9c102_mi0343.c51
-rw-r--r--drivers/media/video/sn9c102/sn9c102_mi0360.c220
-rw-r--r--drivers/media/video/sn9c102/sn9c102_ov7630.c25
-rw-r--r--drivers/media/video/sn9c102/sn9c102_ov7660.c63
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas106b.c14
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas202bcb.c48
-rw-r--r--drivers/media/video/sn9c102/sn9c102_sensor.h33
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5110c1b.c2
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5110d.c2
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5130d1b.c2
-rw-r--r--drivers/media/video/usbvideo/Kconfig8
-rw-r--r--drivers/media/video/usbvision/Kconfig2
-rw-r--r--drivers/media/video/v4l1-compat.c62
-rw-r--r--drivers/media/video/video-buf.c4
-rw-r--r--drivers/media/video/videodev.c50
-rw-r--r--drivers/media/video/zc0301/Kconfig2
41 files changed, 647 insertions, 332 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index bc773781993a..5cb3f54b548b 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -2,14 +2,19 @@
2# Multimedia Video device configuration 2# Multimedia Video device configuration
3# 3#
4 4
5menu "Video Capture Adapters" 5menuconfig VIDEO_CAPTURE_DRIVERS
6 bool "Video capture adapters"
6 depends on VIDEO_DEV 7 depends on VIDEO_DEV
8 default y
9 ---help---
10 Say Y here to enable selecting the video adapters for
11 webcams, analog TV, and hybrid analog/digital TV.
12 Some of those devices also supports FM radio.
7 13
8comment "Video Capture Adapters" 14if VIDEO_CAPTURE_DRIVERS
9 15
10config VIDEO_ADV_DEBUG 16config VIDEO_ADV_DEBUG
11 bool "Enable advanced debug functionality" 17 bool "Enable advanced debug functionality"
12 depends on VIDEO_DEV
13 default n 18 default n
14 ---help--- 19 ---help---
15 Say Y here to enable advanced debugging functionality on some 20 Say Y here to enable advanced debugging functionality on some
@@ -34,7 +39,7 @@ config VIDEO_HELPER_CHIPS_AUTO
34# 39#
35 40
36menu "Encoders/decoders and other helper chips" 41menu "Encoders/decoders and other helper chips"
37 depends on VIDEO_DEV && !VIDEO_HELPER_CHIPS_AUTO 42 depends on !VIDEO_HELPER_CHIPS_AUTO
38 43
39comment "Audio decoders" 44comment "Audio decoders"
40 45
@@ -61,7 +66,7 @@ config VIDEO_TDA7432
61 66
62config VIDEO_TDA9840 67config VIDEO_TDA9840
63 tristate "Philips TDA9840 audio processor" 68 tristate "Philips TDA9840 audio processor"
64 depends on VIDEO_DEV && I2C 69 depends on I2C
65 ---help--- 70 ---help---
66 Support for tda9840 audio decoder chip found on some Zoran boards. 71 Support for tda9840 audio decoder chip found on some Zoran boards.
67 72
@@ -79,7 +84,7 @@ config VIDEO_TDA9875
79 84
80config VIDEO_TEA6415C 85config VIDEO_TEA6415C
81 tristate "Philips TEA6415C audio processor" 86 tristate "Philips TEA6415C audio processor"
82 depends on VIDEO_DEV && I2C 87 depends on I2C
83 ---help--- 88 ---help---
84 Support for tea6415c audio decoder chip found on some bt8xx boards. 89 Support for tea6415c audio decoder chip found on some bt8xx boards.
85 90
@@ -88,7 +93,7 @@ config VIDEO_TEA6415C
88 93
89config VIDEO_TEA6420 94config VIDEO_TEA6420
90 tristate "Philips TEA6420 audio processor" 95 tristate "Philips TEA6420 audio processor"
91 depends on VIDEO_DEV && I2C 96 depends on I2C
92 ---help--- 97 ---help---
93 Support for tea6420 audio decoder chip found on some bt8xx boards. 98 Support for tea6420 audio decoder chip found on some bt8xx boards.
94 99
@@ -469,7 +474,7 @@ config VIDEO_SAA5246A
469 474
470config VIDEO_SAA5249 475config VIDEO_SAA5249
471 tristate "SAA5249 Teletext processor" 476 tristate "SAA5249 Teletext processor"
472 depends on VIDEO_DEV && I2C && VIDEO_V4L2 477 depends on I2C && VIDEO_V4L2
473 help 478 help
474 Support for I2C bus based teletext using the SAA5249 chip. At the 479 Support for I2C bus based teletext using the SAA5249 chip. At the
475 moment this is only useful on some European WinTV cards. 480 moment this is only useful on some European WinTV cards.
@@ -479,7 +484,7 @@ config VIDEO_SAA5249
479 484
480config TUNER_3036 485config TUNER_3036
481 tristate "SAB3036 tuner" 486 tristate "SAB3036 tuner"
482 depends on VIDEO_DEV && I2C && VIDEO_V4L1 487 depends on I2C && VIDEO_V4L1
483 help 488 help
484 Say Y here to include support for Philips SAB3036 compatible tuners. 489 Say Y here to include support for Philips SAB3036 compatible tuners.
485 If in doubt, say N. 490 If in doubt, say N.
@@ -681,8 +686,12 @@ config VIDEO_CAFE_CCIC
681# USB Multimedia device configuration 686# USB Multimedia device configuration
682# 687#
683 688
684menu "V4L USB devices" 689menuconfig V4L_USB_DRIVERS
685 depends on USB && VIDEO_DEV 690 bool "V4L USB devices"
691 depends on USB
692 default y
693
694if V4L_USB_DRIVERS
686 695
687source "drivers/media/video/pvrusb2/Kconfig" 696source "drivers/media/video/pvrusb2/Kconfig"
688 697
@@ -707,7 +716,7 @@ config VIDEO_OVCAMCHIP
707 716
708config USB_W9968CF 717config USB_W9968CF
709 tristate "USB W996[87]CF JPEG Dual Mode Camera support" 718 tristate "USB W996[87]CF JPEG Dual Mode Camera support"
710 depends on USB && VIDEO_V4L1 && I2C 719 depends on VIDEO_V4L1 && I2C
711 select VIDEO_OVCAMCHIP 720 select VIDEO_OVCAMCHIP
712 ---help--- 721 ---help---
713 Say Y here if you want support for cameras based on OV681 or 722 Say Y here if you want support for cameras based on OV681 or
@@ -725,7 +734,7 @@ config USB_W9968CF
725 734
726config USB_OV511 735config USB_OV511
727 tristate "USB OV511 Camera support" 736 tristate "USB OV511 Camera support"
728 depends on USB && VIDEO_V4L1 737 depends on VIDEO_V4L1
729 ---help--- 738 ---help---
730 Say Y here if you want to connect this type of camera to your 739 Say Y here if you want to connect this type of camera to your
731 computer's USB port. See <file:Documentation/video4linux/ov511.txt> 740 computer's USB port. See <file:Documentation/video4linux/ov511.txt>
@@ -736,7 +745,7 @@ config USB_OV511
736 745
737config USB_SE401 746config USB_SE401
738 tristate "USB SE401 Camera support" 747 tristate "USB SE401 Camera support"
739 depends on USB && VIDEO_V4L1 748 depends on VIDEO_V4L1
740 ---help--- 749 ---help---
741 Say Y here if you want to connect this type of camera to your 750 Say Y here if you want to connect this type of camera to your
742 computer's USB port. See <file:Documentation/video4linux/se401.txt> 751 computer's USB port. See <file:Documentation/video4linux/se401.txt>
@@ -749,7 +758,7 @@ source "drivers/media/video/sn9c102/Kconfig"
749 758
750config USB_STV680 759config USB_STV680
751 tristate "USB STV680 (Pencam) Camera support" 760 tristate "USB STV680 (Pencam) Camera support"
752 depends on USB && VIDEO_V4L1 761 depends on VIDEO_V4L1
753 ---help--- 762 ---help---
754 Say Y here if you want to connect this type of camera to your 763 Say Y here if you want to connect this type of camera to your
755 computer's USB port. This includes the Pencam line of cameras. 764 computer's USB port. This includes the Pencam line of cameras.
@@ -765,7 +774,7 @@ source "drivers/media/video/pwc/Kconfig"
765 774
766config USB_ZR364XX 775config USB_ZR364XX
767 tristate "USB ZR364XX Camera support" 776 tristate "USB ZR364XX Camera support"
768 depends on USB && VIDEO_V4L2 777 depends on VIDEO_V4L2
769 ---help--- 778 ---help---
770 Say Y here if you want to connect this type of camera to your 779 Say Y here if you want to connect this type of camera to your
771 computer's USB port. 780 computer's USB port.
@@ -775,6 +784,6 @@ config USB_ZR364XX
775 To compile this driver as a module, choose M here: the 784 To compile this driver as a module, choose M here: the
776 module will be called zr364xx. 785 module will be called zr364xx.
777 786
778endmenu # V4L USB devices 787endif # V4L_USB_DRIVERS
779 788
780endmenu 789endif # VIDEO_CAPTURE_DRIVERS
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 1757a588970f..67bda9f9a44b 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -555,7 +555,7 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
555{ 555{
556 struct v4l2_pix_format *pix; 556 struct v4l2_pix_format *pix;
557 int HSC, VSC, Vsrc, Hsrc, filter, Vlines; 557 int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
558 int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_NTSC); 558 int is_50Hz = !(cx25840_get_v4lstd(client) & V4L2_STD_525_60);
559 559
560 switch (fmt->type) { 560 switch (fmt->type) {
561 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 561 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -567,7 +567,7 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
567 Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4; 567 Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4;
568 Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4; 568 Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4;
569 569
570 Vlines = pix->height + (is_pal ? 4 : 7); 570 Vlines = pix->height + (is_50Hz ? 4 : 7);
571 571
572 if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) || 572 if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) ||
573 (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) { 573 (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) {
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 2ebde2fdbcbe..543b05ebc0e7 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -28,6 +28,7 @@
28#include <linux/device.h> 28#include <linux/device.h>
29#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/dma-mapping.h>
31#include <asm/delay.h> 32#include <asm/delay.h>
32 33
33#include "cx88.h" 34#include "cx88.h"
@@ -612,7 +613,7 @@ struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board
612} 613}
613 614
614/* Driver asked for hardware access. */ 615/* Driver asked for hardware access. */
615int cx8802_request_acquire(struct cx8802_driver *drv) 616static int cx8802_request_acquire(struct cx8802_driver *drv)
616{ 617{
617 struct cx88_core *core = drv->core; 618 struct cx88_core *core = drv->core;
618 619
@@ -632,7 +633,7 @@ int cx8802_request_acquire(struct cx8802_driver *drv)
632} 633}
633 634
634/* Driver asked to release hardware. */ 635/* Driver asked to release hardware. */
635int cx8802_request_release(struct cx8802_driver *drv) 636static int cx8802_request_release(struct cx8802_driver *drv)
636{ 637{
637 struct cx88_core *core = drv->core; 638 struct cx88_core *core = drv->core;
638 639
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index b94ef8ab28c1..98fa35421bdd 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -36,6 +36,7 @@
36#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/kthread.h> 38#include <linux/kthread.h>
39#include <linux/dma-mapping.h>
39#include <asm/div64.h> 40#include <asm/div64.h>
40 41
41#include "cx88.h" 42#include "cx88.h"
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c
index 6068c9bf82cd..82bc3a28aa22 100644
--- a/drivers/media/video/cx88/cx88-vp3054-i2c.c
+++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c
@@ -111,10 +111,6 @@ static struct i2c_adapter vp3054_i2c_adap_template = {
111 .id = I2C_HW_B_CX2388x, 111 .id = I2C_HW_B_CX2388x,
112}; 112};
113 113
114static struct i2c_client vp3054_i2c_client_template = {
115 .name = "VP-3054",
116};
117
118int vp3054_i2c_probe(struct cx8802_dev *dev) 114int vp3054_i2c_probe(struct cx8802_dev *dev)
119{ 115{
120 struct cx88_core *core = dev->core; 116 struct cx88_core *core = dev->core;
@@ -133,8 +129,6 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
133 sizeof(vp3054_i2c->adap)); 129 sizeof(vp3054_i2c->adap));
134 memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, 130 memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template,
135 sizeof(vp3054_i2c->algo)); 131 sizeof(vp3054_i2c->algo));
136 memcpy(&vp3054_i2c->client, &vp3054_i2c_client_template,
137 sizeof(vp3054_i2c->client));
138 132
139 vp3054_i2c->adap.class |= I2C_CLASS_TV_DIGITAL; 133 vp3054_i2c->adap.class |= I2C_CLASS_TV_DIGITAL;
140 134
@@ -144,7 +138,6 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
144 vp3054_i2c->algo.data = dev; 138 vp3054_i2c->algo.data = dev;
145 i2c_set_adapdata(&vp3054_i2c->adap, dev); 139 i2c_set_adapdata(&vp3054_i2c->adap, dev);
146 vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; 140 vp3054_i2c->adap.algo_data = &vp3054_i2c->algo;
147 vp3054_i2c->client.adapter = &vp3054_i2c->adap;
148 141
149 vp3054_bit_setscl(dev,1); 142 vp3054_bit_setscl(dev,1);
150 vp3054_bit_setsda(dev,1); 143 vp3054_bit_setsda(dev,1);
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.h b/drivers/media/video/cx88/cx88-vp3054-i2c.h
index b7a0a04d2423..637a7d232238 100644
--- a/drivers/media/video/cx88/cx88-vp3054-i2c.h
+++ b/drivers/media/video/cx88/cx88-vp3054-i2c.h
@@ -26,7 +26,6 @@
26struct vp3054_i2c_state { 26struct vp3054_i2c_state {
27 struct i2c_adapter adap; 27 struct i2c_adapter adap;
28 struct i2c_algo_bit_data algo; 28 struct i2c_algo_bit_data algo;
29 struct i2c_client client;
30 u32 state; 29 u32 state;
31}; 30};
32 31
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig
index 9285a58e47aa..3823b62da4a4 100644
--- a/drivers/media/video/em28xx/Kconfig
+++ b/drivers/media/video/em28xx/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_EM28XX 1config VIDEO_EM28XX
2 tristate "Empia EM2800/2820/2840 USB video capture support" 2 tristate "Empia EM2800/2820/2840 USB video capture support"
3 depends on VIDEO_V4L1 && USB && I2C 3 depends on VIDEO_V4L1 && I2C
4 select VIDEO_BUF 4 select VIDEO_BUF
5 select VIDEO_TUNER 5 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
diff --git a/drivers/media/video/et61x251/Kconfig b/drivers/media/video/et61x251/Kconfig
index c6bff705688d..664676f44068 100644
--- a/drivers/media/video/et61x251/Kconfig
+++ b/drivers/media/video/et61x251/Kconfig
@@ -1,6 +1,6 @@
1config USB_ET61X251 1config USB_ET61X251
2 tristate "USB ET61X[12]51 PC Camera Controller support" 2 tristate "USB ET61X[12]51 PC Camera Controller support"
3 depends on USB && VIDEO_V4L1 3 depends on VIDEO_V4L1
4 ---help--- 4 ---help---
5 Say Y here if you want support for cameras based on Etoms ET61X151 5 Say Y here if you want support for cameras based on Etoms ET61X151
6 or ET61X251 PC Camera Controllers. 6 or ET61X251 PC Camera Controllers.
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index 45b9328a538f..e29f949adf57 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -74,7 +74,7 @@ int ivtv_first_minor = 0;
74struct ivtv *ivtv_cards[IVTV_MAX_CARDS]; 74struct ivtv *ivtv_cards[IVTV_MAX_CARDS];
75 75
76/* Protects ivtv_cards_active */ 76/* Protects ivtv_cards_active */
77spinlock_t ivtv_cards_lock = SPIN_LOCK_UNLOCKED; 77DEFINE_SPINLOCK(ivtv_cards_lock);
78 78
79/* add your revision and whatnot here */ 79/* add your revision and whatnot here */
80static struct pci_device_id ivtv_pci_tbl[] __devinitdata = { 80static struct pci_device_id ivtv_pci_tbl[] __devinitdata = {
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 1637097ddec7..8976487a65f3 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -804,7 +804,7 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
804 struct ivtv_open_id *item; 804 struct ivtv_open_id *item;
805 struct ivtv *itv = NULL; 805 struct ivtv *itv = NULL;
806 struct ivtv_stream *s = NULL; 806 struct ivtv_stream *s = NULL;
807 int minor = MINOR(inode->i_rdev); 807 int minor = iminor(inode);
808 808
809 /* Find which card this open was on */ 809 /* Find which card this open was on */
810 spin_lock(&ivtv_cards_lock); 810 spin_lock(&ivtv_cards_lock);
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig
index 5645c9318890..d0c2cd785430 100644
--- a/drivers/media/video/pvrusb2/Kconfig
+++ b/drivers/media/video/pvrusb2/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_PVRUSB2 1config VIDEO_PVRUSB2
2 tristate "Hauppauge WinTV-PVR USB2 support" 2 tristate "Hauppauge WinTV-PVR USB2 support"
3 depends on VIDEO_V4L2 && USB && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
4 select FW_LOADER 4 select FW_LOADER
5 select VIDEO_TUNER 5 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
index 5669c8ca9ca3..20b614436d2c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
@@ -391,22 +391,29 @@ static int pvr2_encoder_prep_config(struct pvr2_hdw *hdw)
391int pvr2_encoder_configure(struct pvr2_hdw *hdw) 391int pvr2_encoder_configure(struct pvr2_hdw *hdw)
392{ 392{
393 int ret; 393 int ret;
394 int val;
394 pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure" 395 pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure"
395 " (cx2341x module)"); 396 " (cx2341x module)");
396 hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING; 397 hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING;
397 hdw->enc_ctl_state.width = hdw->res_hor_val; 398 hdw->enc_ctl_state.width = hdw->res_hor_val;
398 hdw->enc_ctl_state.height = hdw->res_ver_val; 399 hdw->enc_ctl_state.height = hdw->res_ver_val;
399 hdw->enc_ctl_state.is_50hz = ((hdw->std_mask_cur & 400 hdw->enc_ctl_state.is_50hz = ((hdw->std_mask_cur & V4L2_STD_525_60) ?
400 (V4L2_STD_NTSC|V4L2_STD_PAL_M)) ?
401 0 : 1); 401 0 : 1);
402 402
403 ret = 0; 403 ret = 0;
404 404
405 ret |= pvr2_encoder_prep_config(hdw); 405 ret |= pvr2_encoder_prep_config(hdw);
406 406
407 /* saa7115: 0xf0 */
408 val = 0xf0;
409 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) {
410 /* ivtv cx25840: 0x140 */
411 val = 0x140;
412 }
413
407 if (!ret) ret = pvr2_encoder_vcmd( 414 if (!ret) ret = pvr2_encoder_vcmd(
408 hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 415 hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2,
409 0xf0, 0xf0); 416 val, val);
410 417
411 /* setup firmware to notify us about some events (don't know why...) */ 418 /* setup firmware to notify us about some events (don't know why...) */
412 if (!ret) ret = pvr2_encoder_vcmd( 419 if (!ret) ret = pvr2_encoder_vcmd(
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index acf651e01f94..1311891e7ee3 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -83,7 +83,7 @@ static struct pvr2_string_table pvr2_client_lists[] = {
83}; 83};
84 84
85static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; 85static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL};
86static DECLARE_MUTEX(pvr2_unit_sem); 86static DEFINE_MUTEX(pvr2_unit_mtx);
87 87
88static int ctlchg = 0; 88static int ctlchg = 0;
89static int initusbreset = 1; 89static int initusbreset = 1;
@@ -2076,14 +2076,14 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
2076 hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); 2076 hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL);
2077 if (!hdw->ctl_read_urb) goto fail; 2077 if (!hdw->ctl_read_urb) goto fail;
2078 2078
2079 down(&pvr2_unit_sem); do { 2079 mutex_lock(&pvr2_unit_mtx); do {
2080 for (idx = 0; idx < PVR_NUM; idx++) { 2080 for (idx = 0; idx < PVR_NUM; idx++) {
2081 if (unit_pointers[idx]) continue; 2081 if (unit_pointers[idx]) continue;
2082 hdw->unit_number = idx; 2082 hdw->unit_number = idx;
2083 unit_pointers[idx] = hdw; 2083 unit_pointers[idx] = hdw;
2084 break; 2084 break;
2085 } 2085 }
2086 } while (0); up(&pvr2_unit_sem); 2086 } while (0); mutex_unlock(&pvr2_unit_mtx);
2087 2087
2088 cnt1 = 0; 2088 cnt1 = 0;
2089 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); 2089 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2");
@@ -2186,13 +2186,13 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
2186 } 2186 }
2187 pvr2_i2c_core_done(hdw); 2187 pvr2_i2c_core_done(hdw);
2188 pvr2_hdw_remove_usb_stuff(hdw); 2188 pvr2_hdw_remove_usb_stuff(hdw);
2189 down(&pvr2_unit_sem); do { 2189 mutex_lock(&pvr2_unit_mtx); do {
2190 if ((hdw->unit_number >= 0) && 2190 if ((hdw->unit_number >= 0) &&
2191 (hdw->unit_number < PVR_NUM) && 2191 (hdw->unit_number < PVR_NUM) &&
2192 (unit_pointers[hdw->unit_number] == hdw)) { 2192 (unit_pointers[hdw->unit_number] == hdw)) {
2193 unit_pointers[hdw->unit_number] = NULL; 2193 unit_pointers[hdw->unit_number] = NULL;
2194 } 2194 }
2195 } while (0); up(&pvr2_unit_sem); 2195 } while (0); mutex_unlock(&pvr2_unit_mtx);
2196 kfree(hdw->controls); 2196 kfree(hdw->controls);
2197 kfree(hdw->mpeg_ctrl_info); 2197 kfree(hdw->mpeg_ctrl_info);
2198 kfree(hdw->std_defs); 2198 kfree(hdw->std_defs);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index 58fc3c730fe1..6786d3c0c98b 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -23,6 +23,7 @@
23#include "pvrusb2-hdw-internal.h" 23#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h" 24#include "pvrusb2-debug.h"
25#include "pvrusb2-fx2-cmd.h" 25#include "pvrusb2-fx2-cmd.h"
26#include "pvrusb2.h"
26 27
27#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__) 28#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__)
28 29
@@ -38,6 +39,10 @@ static unsigned int i2c_scan = 0;
38module_param(i2c_scan, int, S_IRUGO|S_IWUSR); 39module_param(i2c_scan, int, S_IRUGO|S_IWUSR);
39MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 40MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
40 41
42static int ir_mode[PVR_NUM] = { [0 ... PVR_NUM-1] = 1 };
43module_param_array(ir_mode, int, NULL, 0444);
44MODULE_PARM_DESC(ir_mode,"specify: 0=disable IR reception, 1=normal IR");
45
41static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp, 46static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp,
42 unsigned int detail, 47 unsigned int detail,
43 char *buf,unsigned int maxlen); 48 char *buf,unsigned int maxlen);
@@ -273,6 +278,15 @@ static int i2c_hack_wm8775(struct pvr2_hdw *hdw,
273 return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen); 278 return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen);
274} 279}
275 280
281/* This is an entry point designed to always fail any attempt to perform a
282 transfer. We use this to cause certain I2C addresses to not be
283 probed. */
284static int i2c_black_hole(struct pvr2_hdw *hdw,
285 u8 i2c_addr,u8 *wdata,u16 wlen,u8 *rdata,u16 rlen)
286{
287 return -EIO;
288}
289
276/* This is a special entry point that is entered if an I2C operation is 290/* This is a special entry point that is entered if an I2C operation is
277 attempted to a cx25840 chip on model 24xxx hardware. This chip can 291 attempted to a cx25840 chip on model 24xxx hardware. This chip can
278 sometimes wedge itself. Worse still, when this happens msp3400 can 292 sometimes wedge itself. Worse still, when this happens msp3400 can
@@ -994,10 +1008,17 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
994 } 1008 }
995 1009
996 /* However, deal with various special cases for 24xxx hardware. */ 1010 /* However, deal with various special cases for 24xxx hardware. */
1011 if (ir_mode[hdw->unit_number] == 0) {
1012 printk(KERN_INFO "%s: IR disabled\n",hdw->name);
1013 hdw->i2c_func[0x18] = i2c_black_hole;
1014 } else if (ir_mode[hdw->unit_number] == 1) {
1015 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) {
1016 hdw->i2c_func[0x18] = i2c_24xxx_ir;
1017 }
1018 }
997 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { 1019 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) {
998 hdw->i2c_func[0x1b] = i2c_hack_wm8775; 1020 hdw->i2c_func[0x1b] = i2c_hack_wm8775;
999 hdw->i2c_func[0x44] = i2c_hack_cx25840; 1021 hdw->i2c_func[0x44] = i2c_hack_cx25840;
1000 hdw->i2c_func[0x18] = i2c_24xxx_ir;
1001 } 1022 }
1002 1023
1003 // Configure the adapter and set up everything else related to it. 1024 // Configure the adapter and set up everything else related to it.
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index a741c556a39a..7ab79baa1c8c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -518,40 +518,32 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id)
518 } 518 }
519 sfp->item_last = cip; 519 sfp->item_last = cip;
520 520
521 cip->attr_name.attr.owner = THIS_MODULE;
522 cip->attr_name.attr.name = "name"; 521 cip->attr_name.attr.name = "name";
523 cip->attr_name.attr.mode = S_IRUGO; 522 cip->attr_name.attr.mode = S_IRUGO;
524 cip->attr_name.show = fp->show_name; 523 cip->attr_name.show = fp->show_name;
525 524
526 cip->attr_type.attr.owner = THIS_MODULE;
527 cip->attr_type.attr.name = "type"; 525 cip->attr_type.attr.name = "type";
528 cip->attr_type.attr.mode = S_IRUGO; 526 cip->attr_type.attr.mode = S_IRUGO;
529 cip->attr_type.show = fp->show_type; 527 cip->attr_type.show = fp->show_type;
530 528
531 cip->attr_min.attr.owner = THIS_MODULE;
532 cip->attr_min.attr.name = "min_val"; 529 cip->attr_min.attr.name = "min_val";
533 cip->attr_min.attr.mode = S_IRUGO; 530 cip->attr_min.attr.mode = S_IRUGO;
534 cip->attr_min.show = fp->show_min; 531 cip->attr_min.show = fp->show_min;
535 532
536 cip->attr_max.attr.owner = THIS_MODULE;
537 cip->attr_max.attr.name = "max_val"; 533 cip->attr_max.attr.name = "max_val";
538 cip->attr_max.attr.mode = S_IRUGO; 534 cip->attr_max.attr.mode = S_IRUGO;
539 cip->attr_max.show = fp->show_max; 535 cip->attr_max.show = fp->show_max;
540 536
541 cip->attr_val.attr.owner = THIS_MODULE;
542 cip->attr_val.attr.name = "cur_val"; 537 cip->attr_val.attr.name = "cur_val";
543 cip->attr_val.attr.mode = S_IRUGO; 538 cip->attr_val.attr.mode = S_IRUGO;
544 539
545 cip->attr_custom.attr.owner = THIS_MODULE;
546 cip->attr_custom.attr.name = "custom_val"; 540 cip->attr_custom.attr.name = "custom_val";
547 cip->attr_custom.attr.mode = S_IRUGO; 541 cip->attr_custom.attr.mode = S_IRUGO;
548 542
549 cip->attr_enum.attr.owner = THIS_MODULE;
550 cip->attr_enum.attr.name = "enum_val"; 543 cip->attr_enum.attr.name = "enum_val";
551 cip->attr_enum.attr.mode = S_IRUGO; 544 cip->attr_enum.attr.mode = S_IRUGO;
552 cip->attr_enum.show = fp->show_enum; 545 cip->attr_enum.show = fp->show_enum;
553 546
554 cip->attr_bits.attr.owner = THIS_MODULE;
555 cip->attr_bits.attr.name = "bit_val"; 547 cip->attr_bits.attr.name = "bit_val";
556 cip->attr_bits.attr.mode = S_IRUGO; 548 cip->attr_bits.attr.mode = S_IRUGO;
557 cip->attr_bits.show = fp->show_bits; 549 cip->attr_bits.show = fp->show_bits;
@@ -616,12 +608,10 @@ static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp)
616 608
617 dip = kzalloc(sizeof(*dip),GFP_KERNEL); 609 dip = kzalloc(sizeof(*dip),GFP_KERNEL);
618 if (!dip) return; 610 if (!dip) return;
619 dip->attr_debugcmd.attr.owner = THIS_MODULE;
620 dip->attr_debugcmd.attr.name = "debugcmd"; 611 dip->attr_debugcmd.attr.name = "debugcmd";
621 dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP; 612 dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP;
622 dip->attr_debugcmd.show = debugcmd_show; 613 dip->attr_debugcmd.show = debugcmd_show;
623 dip->attr_debugcmd.store = debugcmd_store; 614 dip->attr_debugcmd.store = debugcmd_store;
624 dip->attr_debuginfo.attr.owner = THIS_MODULE;
625 dip->attr_debuginfo.attr.name = "debuginfo"; 615 dip->attr_debuginfo.attr.name = "debuginfo";
626 dip->attr_debuginfo.attr.mode = S_IRUGO; 616 dip->attr_debuginfo.attr.mode = S_IRUGO;
627 dip->attr_debuginfo.show = debuginfo_show; 617 dip->attr_debuginfo.show = debuginfo_show;
@@ -811,7 +801,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
811 return; 801 return;
812 } 802 }
813 803
814 sfp->attr_v4l_minor_number.attr.owner = THIS_MODULE;
815 sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number"; 804 sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number";
816 sfp->attr_v4l_minor_number.attr.mode = S_IRUGO; 805 sfp->attr_v4l_minor_number.attr.mode = S_IRUGO;
817 sfp->attr_v4l_minor_number.show = v4l_minor_number_show; 806 sfp->attr_v4l_minor_number.show = v4l_minor_number_show;
@@ -825,7 +814,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
825 sfp->v4l_minor_number_created_ok = !0; 814 sfp->v4l_minor_number_created_ok = !0;
826 } 815 }
827 816
828 sfp->attr_v4l_radio_minor_number.attr.owner = THIS_MODULE;
829 sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number"; 817 sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number";
830 sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO; 818 sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO;
831 sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show; 819 sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show;
@@ -839,7 +827,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
839 sfp->v4l_radio_minor_number_created_ok = !0; 827 sfp->v4l_radio_minor_number_created_ok = !0;
840 } 828 }
841 829
842 sfp->attr_unit_number.attr.owner = THIS_MODULE;
843 sfp->attr_unit_number.attr.name = "unit_number"; 830 sfp->attr_unit_number.attr.name = "unit_number";
844 sfp->attr_unit_number.attr.mode = S_IRUGO; 831 sfp->attr_unit_number.attr.mode = S_IRUGO;
845 sfp->attr_unit_number.show = unit_number_show; 832 sfp->attr_unit_number.show = unit_number_show;
@@ -852,7 +839,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
852 sfp->unit_number_created_ok = !0; 839 sfp->unit_number_created_ok = !0;
853 } 840 }
854 841
855 sfp->attr_bus_info.attr.owner = THIS_MODULE;
856 sfp->attr_bus_info.attr.name = "bus_info_str"; 842 sfp->attr_bus_info.attr.name = "bus_info_str";
857 sfp->attr_bus_info.attr.mode = S_IRUGO; 843 sfp->attr_bus_info.attr.mode = S_IRUGO;
858 sfp->attr_bus_info.show = bus_info_show; 844 sfp->attr_bus_info.show = bus_info_show;
diff --git a/drivers/media/video/pwc/Kconfig b/drivers/media/video/pwc/Kconfig
index 8fdf7101d3bf..7298cf2e1650 100644
--- a/drivers/media/video/pwc/Kconfig
+++ b/drivers/media/video/pwc/Kconfig
@@ -1,6 +1,6 @@
1config USB_PWC 1config USB_PWC
2 tristate "USB Philips Cameras" 2 tristate "USB Philips Cameras"
3 depends on USB && VIDEO_V4L1 3 depends on VIDEO_V4L1
4 ---help--- 4 ---help---
5 Say Y or M here if you want to use one of these Philips & OEM 5 Say Y or M here if you want to use one of these Philips & OEM
6 webcams: 6 webcams:
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 4ea479baee74..50f15adfa7c8 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -1170,6 +1170,42 @@ struct saa7134_board saa7134_boards[] = {
1170 .amux = LINE2, 1170 .amux = LINE2,
1171 }, 1171 },
1172 }, 1172 },
1173 [SAA7134_BOARD_ECS_TVP3XP_4CB6] = {
1174 /* Barry Scott <barry.scott@onelan.co.uk> */
1175 .name = "Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM)",
1176 .audio_clock = 0x187de7,
1177 .tuner_type = TUNER_PHILIPS_PAL_I,
1178 .radio_type = UNSET,
1179 .tuner_addr = ADDR_UNSET,
1180 .radio_addr = ADDR_UNSET,
1181 .inputs = {{
1182 .name = name_tv,
1183 .vmux = 1,
1184 .amux = TV,
1185 .tv = 1,
1186 },{
1187 .name = name_tv_mono,
1188 .vmux = 1,
1189 .amux = LINE2,
1190 .tv = 1,
1191 },{
1192 .name = name_comp1,
1193 .vmux = 3,
1194 .amux = LINE1,
1195 },{
1196 .name = name_svideo,
1197 .vmux = 8,
1198 .amux = LINE1,
1199 },{
1200 .name = "CVid over SVid",
1201 .vmux = 0,
1202 .amux = LINE1,
1203 }},
1204 .radio = {
1205 .name = name_radio,
1206 .amux = LINE2,
1207 },
1208 },
1173 [SAA7134_BOARD_AVACSSMARTTV] = { 1209 [SAA7134_BOARD_AVACSSMARTTV] = {
1174 /* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */ 1210 /* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */
1175 .name = "AVACS SmartTV", 1211 .name = "AVACS SmartTV",
@@ -2754,6 +2790,35 @@ struct saa7134_board saa7134_boards[] = {
2754 .amux = LINE1, 2790 .amux = LINE1,
2755 }, 2791 },
2756 }, 2792 },
2793 [SAA7134_BOARD_KWORLD_DVBT_210] = {
2794 .name = "KWorld DVB-T 210",
2795 .audio_clock = 0x00187de7,
2796 .tuner_type = TUNER_PHILIPS_TDA8290,
2797 .radio_type = UNSET,
2798 .tuner_addr = ADDR_UNSET,
2799 .radio_addr = ADDR_UNSET,
2800 .mpeg = SAA7134_MPEG_DVB,
2801 .gpiomask = 1 << 21,
2802 .inputs = {{
2803 .name = name_tv,
2804 .vmux = 1,
2805 .amux = TV,
2806 .tv = 1,
2807 },{
2808 .name = name_comp1,
2809 .vmux = 3,
2810 .amux = LINE1,
2811 },{
2812 .name = name_svideo,
2813 .vmux = 8,
2814 .amux = LINE1,
2815 }},
2816 .radio = {
2817 .name = name_radio,
2818 .amux = TV,
2819 .gpio = 0x0200000,
2820 },
2821 },
2757 [SAA7134_BOARD_KWORLD_ATSC110] = { 2822 [SAA7134_BOARD_KWORLD_ATSC110] = {
2758 .name = "Kworld ATSC110", 2823 .name = "Kworld ATSC110",
2759 .audio_clock = 0x00187de7, 2824 .audio_clock = 0x00187de7,
@@ -3407,6 +3472,36 @@ struct saa7134_board saa7134_boards[] = {
3407 .gpio = 0x0200000, 3472 .gpio = 0x0200000,
3408 }, 3473 },
3409 }, 3474 },
3475 [SAA7134_BOARD_SABRENT_TV_PCB05] = {
3476 .name = "Sabrent PCMCIA TV-PCB05",
3477 .audio_clock = 0x00187de7,
3478 .tuner_type = TUNER_PHILIPS_TDA8290,
3479 .radio_type = UNSET,
3480 .tuner_addr = ADDR_UNSET,
3481 .radio_addr = ADDR_UNSET,
3482 .inputs = {{
3483 .name = name_tv,
3484 .vmux = 1,
3485 .amux = TV,
3486 .tv = 1,
3487 },{
3488 .name = name_comp1,
3489 .vmux = 3,
3490 .amux = LINE1,
3491 },{
3492 .name = name_comp2,
3493 .vmux = 0,
3494 .amux = LINE1,
3495 },{
3496 .name = name_svideo,
3497 .vmux = 8,
3498 .amux = LINE1,
3499 }},
3500 .mute = {
3501 .name = name_mute,
3502 .amux = TV,
3503 },
3504 },
3410}; 3505};
3411 3506
3412const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 3507const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -3515,7 +3610,13 @@ struct pci_device_id saa7134_pci_tbl[] = {
3515 .vendor = PCI_VENDOR_ID_PHILIPS, 3610 .vendor = PCI_VENDOR_ID_PHILIPS,
3516 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 3611 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3517 .subvendor = 0x5168, /* Animation Technologies (LifeView) */ 3612 .subvendor = 0x5168, /* Animation Technologies (LifeView) */
3518 .subdevice = 0x0214, /* Standard PCI, LR214WF */ 3613 .subdevice = 0x0214, /* Standard PCI, LR214 Rev E and earlier (SAA7135) */
3614 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM,
3615 },{
3616 .vendor = PCI_VENDOR_ID_PHILIPS,
3617 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3618 .subvendor = 0x5168, /* Animation Technologies (LifeView) */
3619 .subdevice = 0x5214, /* Standard PCI, LR214 Rev F onwards (SAA7131) */
3519 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, 3620 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM,
3520 },{ 3621 },{
3521 .vendor = PCI_VENDOR_ID_PHILIPS, 3622 .vendor = PCI_VENDOR_ID_PHILIPS,
@@ -3689,6 +3790,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
3689 .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5, 3790 .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5,
3690 },{ 3791 },{
3691 .vendor = PCI_VENDOR_ID_PHILIPS, 3792 .vendor = PCI_VENDOR_ID_PHILIPS,
3793 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
3794 .subvendor = 0x1019,
3795 .subdevice = 0x4cb6,
3796 .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB6,
3797 },{
3798 .vendor = PCI_VENDOR_ID_PHILIPS,
3692 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 3799 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3693 .subvendor = 0x12ab, 3800 .subvendor = 0x12ab,
3694 .subdevice = 0x0800, 3801 .subdevice = 0x0800,
@@ -3915,6 +4022,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
3915 .driver_data = SAA7134_BOARD_TEVION_DVBT_220RF, 4022 .driver_data = SAA7134_BOARD_TEVION_DVBT_220RF,
3916 },{ 4023 },{
3917 .vendor = PCI_VENDOR_ID_PHILIPS, 4024 .vendor = PCI_VENDOR_ID_PHILIPS,
4025 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
4026 .subvendor = 0x17de,
4027 .subdevice = 0x7250,
4028 .driver_data = SAA7134_BOARD_KWORLD_DVBT_210,
4029 },{
4030 .vendor = PCI_VENDOR_ID_PHILIPS,
3918 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, /* SAA7135HL */ 4031 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, /* SAA7135HL */
3919 .subvendor = 0x17de, 4032 .subvendor = 0x17de,
3920 .subdevice = 0x7350, 4033 .subdevice = 0x7350,
@@ -4100,6 +4213,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
4100 .subdevice = 0x4857, 4213 .subdevice = 0x4857,
4101 .driver_data = SAA7134_BOARD_ASUSTeK_P7131_DUAL, 4214 .driver_data = SAA7134_BOARD_ASUSTeK_P7131_DUAL,
4102 },{ 4215 },{
4216 .vendor = PCI_VENDOR_ID_PHILIPS,
4217 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
4218 .subvendor = 0x0919, /* SinoVideo PCI 2309 Proteus (7134) */
4219 .subdevice = 0x2003, /* OEM cardbus */
4220 .driver_data = SAA7134_BOARD_SABRENT_TV_PCB05,
4221 },{
4103 /* --- boards without eeprom + subsystem ID --- */ 4222 /* --- boards without eeprom + subsystem ID --- */
4104 .vendor = PCI_VENDOR_ID_PHILIPS, 4223 .vendor = PCI_VENDOR_ID_PHILIPS,
4105 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 4224 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -4178,6 +4297,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
4178 case SAA7134_BOARD_CINERGY600_MK3: 4297 case SAA7134_BOARD_CINERGY600_MK3:
4179 case SAA7134_BOARD_ECS_TVP3XP: 4298 case SAA7134_BOARD_ECS_TVP3XP:
4180 case SAA7134_BOARD_ECS_TVP3XP_4CB5: 4299 case SAA7134_BOARD_ECS_TVP3XP_4CB5:
4300 case SAA7134_BOARD_ECS_TVP3XP_4CB6:
4181 case SAA7134_BOARD_MD2819: 4301 case SAA7134_BOARD_MD2819:
4182 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: 4302 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
4183 case SAA7134_BOARD_KWORLD_XPERT: 4303 case SAA7134_BOARD_KWORLD_XPERT:
@@ -4426,6 +4546,7 @@ int saa7134_board_init2(struct saa7134_dev *dev)
4426 } 4546 }
4427 break; 4547 break;
4428 case SAA7134_BOARD_PINNACLE_PCTV_310i: 4548 case SAA7134_BOARD_PINNACLE_PCTV_310i:
4549 case SAA7134_BOARD_KWORLD_DVBT_210:
4429 case SAA7134_BOARD_TEVION_DVBT_220RF: 4550 case SAA7134_BOARD_TEVION_DVBT_220RF:
4430 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 4551 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
4431 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: 4552 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 65aec881bbde..e0eec80088c7 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -887,6 +887,20 @@ static struct tda1004x_config asus_p7131_hybrid_lna_config = {
887 .antenna_switch= 2, 887 .antenna_switch= 2,
888 .request_firmware = philips_tda1004x_request_firmware 888 .request_firmware = philips_tda1004x_request_firmware
889}; 889};
890static struct tda1004x_config kworld_dvb_t_210_config = {
891 .demod_address = 0x08,
892 .invert = 1,
893 .invert_oclk = 0,
894 .xtal_freq = TDA10046_XTAL_16M,
895 .agc_config = TDA10046_AGC_TDA827X,
896 .gpio_config = TDA10046_GP11_I,
897 .if_freq = TDA10046_FREQ_045,
898 .i2c_gate = 0x4b,
899 .tuner_address = 0x61,
900 .tuner_config = 2,
901 .antenna_switch= 1,
902 .request_firmware = philips_tda1004x_request_firmware
903};
890/* ------------------------------------------------------------------ 904/* ------------------------------------------------------------------
891 * special case: this card uses saa713x GPIO22 for the mode switch 905 * special case: this card uses saa713x GPIO22 for the mode switch
892 */ 906 */
@@ -1039,6 +1053,9 @@ static int dvb_init(struct saa7134_dev *dev)
1039 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; 1053 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1040 } 1054 }
1041 break; 1055 break;
1056 case SAA7134_BOARD_KWORLD_DVBT_210:
1057 configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
1058 break;
1042 case SAA7134_BOARD_PHILIPS_TIGER: 1059 case SAA7134_BOARD_PHILIPS_TIGER:
1043 configure_tda827x_fe(dev, &philips_tiger_config); 1060 configure_tda827x_fe(dev, &philips_tiger_config);
1044 break; 1061 break;
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 62224cc958f1..15623b27ad2e 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -235,6 +235,9 @@ struct saa7134_format {
235#define SAA7134_BOARD_AVERMEDIA_M102 110 235#define SAA7134_BOARD_AVERMEDIA_M102 110
236#define SAA7134_BOARD_ASUS_P7131_4871 111 236#define SAA7134_BOARD_ASUS_P7131_4871 111
237#define SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA 112 237#define SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA 112
238#define SAA7134_BOARD_ECS_TVP3XP_4CB6 113
239#define SAA7134_BOARD_KWORLD_DVBT_210 114
240#define SAA7134_BOARD_SABRENT_TV_PCB05 115
238 241
239#define SAA7134_MAXBOARDS 8 242#define SAA7134_MAXBOARDS 8
240#define SAA7134_INPUT_MAX 8 243#define SAA7134_INPUT_MAX 8
diff --git a/drivers/media/video/sn9c102/Kconfig b/drivers/media/video/sn9c102/Kconfig
index 19204f5686e1..f71f272776de 100644
--- a/drivers/media/video/sn9c102/Kconfig
+++ b/drivers/media/video/sn9c102/Kconfig
@@ -1,6 +1,6 @@
1config USB_SN9C102 1config USB_SN9C102
2 tristate "USB SN9C1xx PC Camera Controller support" 2 tristate "USB SN9C1xx PC Camera Controller support"
3 depends on USB && VIDEO_V4L2 3 depends on VIDEO_V4L2
4 ---help--- 4 ---help---
5 Say Y here if you want support for cameras based on SONiX SN9C101, 5 Say Y here if you want support for cameras based on SONiX SN9C101,
6 SN9C102, SN9C103, SN9C105 and SN9C120 PC Camera Controllers. 6 SN9C102, SN9C103, SN9C105 and SN9C120 PC Camera Controllers.
diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h
index 680e74634527..11fcb49f5b99 100644
--- a/drivers/media/video/sn9c102/sn9c102.h
+++ b/drivers/media/video/sn9c102/sn9c102.h
@@ -141,7 +141,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id)
141 141
142void 142void
143sn9c102_attach_sensor(struct sn9c102_device* cam, 143sn9c102_attach_sensor(struct sn9c102_device* cam,
144 struct sn9c102_sensor* sensor) 144 const struct sn9c102_sensor* sensor)
145{ 145{
146 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor)); 146 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor));
147} 147}
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 89f83354de3b..74a204f8ebc8 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -48,8 +48,8 @@
48#define SN9C102_MODULE_AUTHOR "(C) 2004-2007 Luca Risolia" 48#define SN9C102_MODULE_AUTHOR "(C) 2004-2007 Luca Risolia"
49#define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 49#define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
50#define SN9C102_MODULE_LICENSE "GPL" 50#define SN9C102_MODULE_LICENSE "GPL"
51#define SN9C102_MODULE_VERSION "1:1.39" 51#define SN9C102_MODULE_VERSION "1:1.44"
52#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 39) 52#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 44)
53 53
54/*****************************************************************************/ 54/*****************************************************************************/
55 55
@@ -209,38 +209,41 @@ static void sn9c102_queue_unusedframes(struct sn9c102_device* cam)
209} 209}
210 210
211/*****************************************************************************/ 211/*****************************************************************************/
212
212/* 213/*
213 * Write a sequence of count value/register pairs. Returns -1 after the 214 Write a sequence of count value/register pairs. Returns -1 after the first
214 * first failed write, or 0 for no errors. 215 failed write, or 0 for no errors.
215 */ 216*/
216int sn9c102_write_regs(struct sn9c102_device* cam, const u8 valreg[][2], 217int sn9c102_write_regs(struct sn9c102_device* cam, const u8 valreg[][2],
217 int count) 218 int count)
218{ 219{
219 struct usb_device* udev = cam->usbdev; 220 struct usb_device* udev = cam->usbdev;
220 u8* value = cam->control_buffer; /* Needed for DMA'able memory */ 221 u8* buff = cam->control_buffer;
221 int i, res; 222 int i, res;
222 223
223 for (i = 0; i < count; i++) { 224 for (i = 0; i < count; i++) {
224 u8 index = valreg[i][1]; 225 u8 index = valreg[i][1];
225 226
226 /* 227 /*
227 * index is a u8, so it must be <256 and can't be out of range. 228 index is a u8, so it must be <256 and can't be out of range.
228 * If we put in a check anyway, gcc annoys us with a warning 229 If we put in a check anyway, gcc annoys us with a warning
229 * that our check is useless. People get all uppity when they 230 hat our check is useless. People get all uppity when they
230 * see warnings in the kernel compile. 231 see warnings in the kernel compile.
231 */ 232 */
232 233
233 *value = valreg[i][0]; 234 *buff = valreg[i][0];
234 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 235
235 0x08, 0x41, index, 0, 236 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08,
236 value, 1, SN9C102_CTRL_TIMEOUT); 237 0x41, index, 0, buff, 1,
238 SN9C102_CTRL_TIMEOUT);
239
237 if (res < 0) { 240 if (res < 0) {
238 DBG(3, "Failed to write a register (value 0x%02X, " 241 DBG(3, "Failed to write a register (value 0x%02X, "
239 "index 0x%02X, error %d)", *value, index, res); 242 "index 0x%02X, error %d)", *buff, index, res);
240 return -1; 243 return -1;
241 } 244 }
242 245
243 cam->reg[index] = *value; 246 cam->reg[index] = *buff;
244 } 247 }
245 248
246 return 0; 249 return 0;
@@ -272,8 +275,8 @@ int sn9c102_write_reg(struct sn9c102_device* cam, u8 value, u16 index)
272} 275}
273 276
274 277
275/* NOTE: reading some registers always returns 0 */ 278/* NOTE: with the SN9C10[123] reading some registers always returns 0 */
276static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index) 279int sn9c102_read_reg(struct sn9c102_device* cam, u16 index)
277{ 280{
278 struct usb_device* udev = cam->usbdev; 281 struct usb_device* udev = cam->usbdev;
279 u8* buff = cam->control_buffer; 282 u8* buff = cam->control_buffer;
@@ -299,7 +302,8 @@ int sn9c102_pread_reg(struct sn9c102_device* cam, u16 index)
299 302
300 303
301static int 304static int
302sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor) 305sn9c102_i2c_wait(struct sn9c102_device* cam,
306 const struct sn9c102_sensor* sensor)
303{ 307{
304 int i, r; 308 int i, r;
305 309
@@ -320,7 +324,7 @@ sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor)
320 324
321static int 325static int
322sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, 326sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
323 struct sn9c102_sensor* sensor) 327 const struct sn9c102_sensor* sensor)
324{ 328{
325 int r , err = 0; 329 int r , err = 0;
326 330
@@ -342,7 +346,7 @@ sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
342 346
343static int 347static int
344sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, 348sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
345 struct sn9c102_sensor* sensor) 349 const struct sn9c102_sensor* sensor)
346{ 350{
347 int r; 351 int r;
348 r = sn9c102_read_reg(cam, 0x08); 352 r = sn9c102_read_reg(cam, 0x08);
@@ -352,12 +356,12 @@ sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
352 356
353int 357int
354sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 358sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
355 struct sn9c102_sensor* sensor, u8 data0, u8 data1, 359 const struct sn9c102_sensor* sensor, u8 data0,
356 u8 n, u8 buffer[]) 360 u8 data1, u8 n, u8 buffer[])
357{ 361{
358 struct usb_device* udev = cam->usbdev; 362 struct usb_device* udev = cam->usbdev;
359 u8* data = cam->control_buffer; 363 u8* data = cam->control_buffer;
360 int err = 0, res; 364 int i = 0, err = 0, res;
361 365
362 /* Write cycle */ 366 /* Write cycle */
363 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 367 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
@@ -402,7 +406,8 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
402 } 406 }
403 407
404 if (buffer) 408 if (buffer)
405 memcpy(buffer, data, sizeof(buffer)); 409 for (i = 0; i < n && i < 5; i++)
410 buffer[n-i-1] = data[4-i];
406 411
407 return (int)data[4]; 412 return (int)data[4];
408} 413}
@@ -410,7 +415,7 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
410 415
411int 416int
412sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 417sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
413 struct sn9c102_sensor* sensor, u8 n, u8 data0, 418 const struct sn9c102_sensor* sensor, u8 n, u8 data0,
414 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5) 419 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5)
415{ 420{
416 struct usb_device* udev = cam->usbdev; 421 struct usb_device* udev = cam->usbdev;
@@ -449,7 +454,7 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
449 454
450int 455int
451sn9c102_i2c_try_read(struct sn9c102_device* cam, 456sn9c102_i2c_try_read(struct sn9c102_device* cam,
452 struct sn9c102_sensor* sensor, u8 address) 457 const struct sn9c102_sensor* sensor, u8 address)
453{ 458{
454 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id, 459 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id,
455 address, 1, NULL); 460 address, 1, NULL);
@@ -458,7 +463,7 @@ sn9c102_i2c_try_read(struct sn9c102_device* cam,
458 463
459int 464int
460sn9c102_i2c_try_write(struct sn9c102_device* cam, 465sn9c102_i2c_try_write(struct sn9c102_device* cam,
461 struct sn9c102_sensor* sensor, u8 address, u8 value) 466 const struct sn9c102_sensor* sensor, u8 address, u8 value)
462{ 467{
463 return sn9c102_i2c_try_raw_write(cam, sensor, 3, 468 return sn9c102_i2c_try_raw_write(cam, sensor, 3,
464 sensor->i2c_slave_id, address, 469 sensor->i2c_slave_id, address,
@@ -657,16 +662,6 @@ sn9c102_write_jpegheader(struct sn9c102_device* cam, struct sn9c102_frame_t* f)
657} 662}
658 663
659 664
660static void
661sn9c102_write_eoimarker(struct sn9c102_device* cam, struct sn9c102_frame_t* f)
662{
663 static const u8 eoi_marker[2] = {0xff, 0xd9};
664
665 memcpy(f->bufmem + f->buf.bytesused, eoi_marker, sizeof(eoi_marker));
666 f->buf.bytesused += sizeof(eoi_marker);
667}
668
669
670static void sn9c102_urb_complete(struct urb *urb) 665static void sn9c102_urb_complete(struct urb *urb)
671{ 666{
672 struct sn9c102_device* cam = urb->context; 667 struct sn9c102_device* cam = urb->context;
@@ -3181,14 +3176,14 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp,
3181 3176
3182static const struct file_operations sn9c102_fops = { 3177static const struct file_operations sn9c102_fops = {
3183 .owner = THIS_MODULE, 3178 .owner = THIS_MODULE,
3184 .open = sn9c102_open, 3179 .open = sn9c102_open,
3185 .release = sn9c102_release, 3180 .release = sn9c102_release,
3186 .ioctl = sn9c102_ioctl, 3181 .ioctl = sn9c102_ioctl,
3187 .compat_ioctl = v4l_compat_ioctl32, 3182 .compat_ioctl = v4l_compat_ioctl32,
3188 .read = sn9c102_read, 3183 .read = sn9c102_read,
3189 .poll = sn9c102_poll, 3184 .poll = sn9c102_poll,
3190 .mmap = sn9c102_mmap, 3185 .mmap = sn9c102_mmap,
3191 .llseek = no_llseek, 3186 .llseek = no_llseek,
3192}; 3187};
3193 3188
3194/*****************************************************************************/ 3189/*****************************************************************************/
@@ -3251,7 +3246,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3251 break; 3246 break;
3252 } 3247 }
3253 3248
3254 for (i = 0; sn9c102_sensor_table[i]; i++) { 3249 for (i = 0; i < ARRAY_SIZE(sn9c102_sensor_table); i++) {
3255 err = sn9c102_sensor_table[i](cam); 3250 err = sn9c102_sensor_table[i](cam);
3256 if (!err) 3251 if (!err)
3257 break; 3252 break;
@@ -3262,7 +3257,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3262 DBG(3, "Support for %s maintained by %s", 3257 DBG(3, "Support for %s maintained by %s",
3263 cam->sensor.name, cam->sensor.maintainer); 3258 cam->sensor.name, cam->sensor.maintainer);
3264 } else { 3259 } else {
3265 DBG(1, "No supported image sensor detected"); 3260 DBG(1, "No supported image sensor detected for this bridge");
3266 err = -ENODEV; 3261 err = -ENODEV;
3267 goto fail; 3262 goto fail;
3268 } 3263 }
diff --git a/drivers/media/video/sn9c102/sn9c102_devtable.h b/drivers/media/video/sn9c102/sn9c102_devtable.h
index f49bd8c5b86e..916054faf9be 100644
--- a/drivers/media/video/sn9c102/sn9c102_devtable.h
+++ b/drivers/media/video/sn9c102/sn9c102_devtable.h
@@ -86,6 +86,8 @@ static const struct usb_device_id sn9c102_id_table[] = {
86 { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), }, 86 { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), },
87 { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), }, 87 { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), },
88 /* SN9C105 */ 88 /* SN9C105 */
89 { SN9C102_USB_DEVICE(0x045e, 0x00f5, BRIDGE_SN9C105), },
90 { SN9C102_USB_DEVICE(0x045e, 0x00f7, BRIDGE_SN9C105), },
89 { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), }, 91 { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), },
90 { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), }, 92 { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), },
91 { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), }, 93 { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), },
@@ -100,6 +102,7 @@ static const struct usb_device_id sn9c102_id_table[] = {
100 { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), }, 102 { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), },
101 { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), }, 103 { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), },
102 /* SN9C120 */ 104 /* SN9C120 */
105 { SN9C102_USB_DEVICE(0x0458, 0x7025, BRIDGE_SN9C120), },
103 { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, 106 { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), },
104 { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, 107 { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), },
105 { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, 108 { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), },
@@ -148,7 +151,6 @@ static int (*sn9c102_sensor_table[])(struct sn9c102_device*) = {
148 &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ 151 &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */
149 &sn9c102_probe_tas5110d, /* detection based on USB pid/vid */ 152 &sn9c102_probe_tas5110d, /* detection based on USB pid/vid */
150 &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ 153 &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */
151 NULL,
152}; 154};
153 155
154#endif /* _SN9C102_DEVTABLE_H_ */ 156#endif /* _SN9C102_DEVTABLE_H_ */
diff --git a/drivers/media/video/sn9c102/sn9c102_hv7131d.c b/drivers/media/video/sn9c102/sn9c102_hv7131d.c
index 28a861aed044..eaf9ad0dc8a6 100644
--- a/drivers/media/video/sn9c102/sn9c102_hv7131d.c
+++ b/drivers/media/video/sn9c102/sn9c102_hv7131d.c
@@ -144,7 +144,7 @@ static int hv7131d_set_pix_format(struct sn9c102_device* cam,
144} 144}
145 145
146 146
147static struct sn9c102_sensor hv7131d = { 147static const struct sn9c102_sensor hv7131d = {
148 .name = "HV7131D", 148 .name = "HV7131D",
149 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 149 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
150 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 150 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
@@ -248,12 +248,10 @@ int sn9c102_probe_hv7131d(struct sn9c102_device* cam)
248 248
249 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, 249 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
250 {0x28, 0x17}); 250 {0x28, 0x17});
251 if (err)
252 return -EIO;
253 251
254 r0 = sn9c102_i2c_try_read(cam, &hv7131d, 0x00); 252 r0 = sn9c102_i2c_try_read(cam, &hv7131d, 0x00);
255 r1 = sn9c102_i2c_try_read(cam, &hv7131d, 0x01); 253 r1 = sn9c102_i2c_try_read(cam, &hv7131d, 0x01);
256 if (r0 < 0 || r1 < 0) 254 if (err || r0 < 0 || r1 < 0)
257 return -EIO; 255 return -EIO;
258 256
259 if (r0 != 0x00 || r1 != 0x04) 257 if (r0 != 0x00 || r1 != 0x04)
diff --git a/drivers/media/video/sn9c102/sn9c102_hv7131r.c b/drivers/media/video/sn9c102/sn9c102_hv7131r.c
index 5a495baa5f95..0fc401223cfc 100644
--- a/drivers/media/video/sn9c102/sn9c102_hv7131r.c
+++ b/drivers/media/video/sn9c102/sn9c102_hv7131r.c
@@ -44,7 +44,6 @@ static int hv7131r_init(struct sn9c102_device* cam)
44 {0xb0, 0x2b}, {0xc0, 0x2c}, 44 {0xb0, 0x2b}, {0xc0, 0x2c},
45 {0xd0, 0x2d}, {0xe0, 0x2e}, 45 {0xd0, 0x2d}, {0xe0, 0x2e},
46 {0xf0, 0x2f}, {0xff, 0x30}); 46 {0xf0, 0x2f}, {0xff, 0x30});
47
48 break; 47 break;
49 case BRIDGE_SN9C105: 48 case BRIDGE_SN9C105:
50 case BRIDGE_SN9C120: 49 case BRIDGE_SN9C120:
@@ -254,7 +253,7 @@ static int hv7131r_set_pix_format(struct sn9c102_device* cam,
254} 253}
255 254
256 255
257static struct sn9c102_sensor hv7131r = { 256static const struct sn9c102_sensor hv7131r = {
258 .name = "HV7131R", 257 .name = "HV7131R",
259 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 258 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
260 .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120, 259 .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120,
@@ -350,11 +349,8 @@ int sn9c102_probe_hv7131r(struct sn9c102_device* cam)
350 {0x34, 0x01}, {0x20, 0x17}, 349 {0x34, 0x01}, {0x20, 0x17},
351 {0x34, 0x01}, {0x46, 0x01}); 350 {0x34, 0x01}, {0x46, 0x01});
352 351
353 if (err)
354 return -EIO;
355
356 devid = sn9c102_i2c_try_read(cam, &hv7131r, 0x00); 352 devid = sn9c102_i2c_try_read(cam, &hv7131r, 0x00);
357 if (devid < 0) 353 if (err || devid < 0)
358 return -EIO; 354 return -EIO;
359 355
360 if (devid != 0x02) 356 if (devid != 0x02)
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0343.c b/drivers/media/video/sn9c102/sn9c102_mi0343.c
index 9200845d011b..00b134ca0a3d 100644
--- a/drivers/media/video/sn9c102/sn9c102_mi0343.c
+++ b/drivers/media/video/sn9c102/sn9c102_mi0343.c
@@ -55,45 +55,45 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam,
55 struct v4l2_control* ctrl) 55 struct v4l2_control* ctrl)
56{ 56{
57 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 57 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
58 u8 data[5+1]; 58 u8 data[2];
59 59
60 switch (ctrl->id) { 60 switch (ctrl->id) {
61 case V4L2_CID_EXPOSURE: 61 case V4L2_CID_EXPOSURE:
62 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 62 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2,
63 2+1, data) < 0) 63 data) < 0)
64 return -EIO; 64 return -EIO;
65 ctrl->value = data[2]; 65 ctrl->value = data[0];
66 return 0; 66 return 0;
67 case V4L2_CID_GAIN: 67 case V4L2_CID_GAIN:
68 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 68 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2,
69 2+1, data) < 0) 69 data) < 0)
70 return -EIO; 70 return -EIO;
71 break; 71 break;
72 case V4L2_CID_HFLIP: 72 case V4L2_CID_HFLIP:
73 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 73 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2,
74 2+1, data) < 0) 74 data) < 0)
75 return -EIO; 75 return -EIO;
76 ctrl->value = data[3] & 0x20 ? 1 : 0; 76 ctrl->value = data[1] & 0x20 ? 1 : 0;
77 return 0; 77 return 0;
78 case V4L2_CID_VFLIP: 78 case V4L2_CID_VFLIP:
79 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 79 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2,
80 2+1, data) < 0) 80 data) < 0)
81 return -EIO; 81 return -EIO;
82 ctrl->value = data[3] & 0x80 ? 1 : 0; 82 ctrl->value = data[1] & 0x80 ? 1 : 0;
83 return 0; 83 return 0;
84 case V4L2_CID_RED_BALANCE: 84 case V4L2_CID_RED_BALANCE:
85 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 85 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2,
86 2+1, data) < 0) 86 data) < 0)
87 return -EIO; 87 return -EIO;
88 break; 88 break;
89 case V4L2_CID_BLUE_BALANCE: 89 case V4L2_CID_BLUE_BALANCE:
90 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 90 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2,
91 2+1, data) < 0) 91 data) < 0)
92 return -EIO; 92 return -EIO;
93 break; 93 break;
94 case SN9C102_V4L2_CID_GREEN_BALANCE: 94 case SN9C102_V4L2_CID_GREEN_BALANCE:
95 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 95 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2,
96 2+1, data) < 0) 96 data) < 0)
97 return -EIO; 97 return -EIO;
98 break; 98 break;
99 default: 99 default:
@@ -105,7 +105,7 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam,
105 case V4L2_CID_RED_BALANCE: 105 case V4L2_CID_RED_BALANCE:
106 case V4L2_CID_BLUE_BALANCE: 106 case V4L2_CID_BLUE_BALANCE:
107 case SN9C102_V4L2_CID_GREEN_BALANCE: 107 case SN9C102_V4L2_CID_GREEN_BALANCE:
108 ctrl->value = data[3] | (data[2] << 8); 108 ctrl->value = data[1] | (data[0] << 8);
109 if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) 109 if (ctrl->value >= 0x10 && ctrl->value <= 0x3f)
110 ctrl->value -= 0x10; 110 ctrl->value -= 0x10;
111 else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) 111 else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f)
@@ -223,7 +223,7 @@ static int mi0343_set_pix_format(struct sn9c102_device* cam,
223} 223}
224 224
225 225
226static struct sn9c102_sensor mi0343 = { 226static const struct sn9c102_sensor mi0343 = {
227 .name = "MI-0343", 227 .name = "MI-0343",
228 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 228 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
229 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 229 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
@@ -332,20 +332,17 @@ static struct sn9c102_sensor mi0343 = {
332 332
333int sn9c102_probe_mi0343(struct sn9c102_device* cam) 333int sn9c102_probe_mi0343(struct sn9c102_device* cam)
334{ 334{
335 u8 data[5+1]; 335 u8 data[2];
336 int err = 0;
337
338 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
339 {0x28, 0x17});
340 336
341 if (err) 337 if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
338 {0x28, 0x17}))
342 return -EIO; 339 return -EIO;
343 340
344 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, 341 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00,
345 2, data) < 0) 342 2, data) < 0)
346 return -EIO; 343 return -EIO;
347 344
348 if (data[4] != 0x32 || data[3] != 0xe3) 345 if (data[1] != 0x42 || data[0] != 0xe3)
349 return -ENODEV; 346 return -ENODEV;
350 347
351 sn9c102_attach_sensor(cam, &mi0343); 348 sn9c102_attach_sensor(cam, &mi0343);
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0360.c b/drivers/media/video/sn9c102/sn9c102_mi0360.c
index 64698acb0b15..f8d81d82e8d5 100644
--- a/drivers/media/video/sn9c102/sn9c102_mi0360.c
+++ b/drivers/media/video/sn9c102/sn9c102_mi0360.c
@@ -27,20 +27,105 @@ static int mi0360_init(struct sn9c102_device* cam)
27 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 27 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
28 int err = 0; 28 int err = 0;
29 29
30 err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, 30 switch (sn9c102_get_bridge(cam)) {
31 {0x0a, 0x14}, {0x40, 0x01}, 31 case BRIDGE_SN9C103:
32 {0x20, 0x17}, {0x07, 0x18}, 32 err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11},
33 {0xa0, 0x19}, {0x02, 0x1c}, 33 {0x0a, 0x14}, {0x40, 0x01},
34 {0x03, 0x1d}, {0x0f, 0x1e}, 34 {0x20, 0x17}, {0x07, 0x18},
35 {0x0c, 0x1f}, {0x00, 0x20}, 35 {0xa0, 0x19}, {0x02, 0x1c},
36 {0x10, 0x21}, {0x20, 0x22}, 36 {0x03, 0x1d}, {0x0f, 0x1e},
37 {0x30, 0x23}, {0x40, 0x24}, 37 {0x0c, 0x1f}, {0x00, 0x20},
38 {0x50, 0x25}, {0x60, 0x26}, 38 {0x10, 0x21}, {0x20, 0x22},
39 {0x70, 0x27}, {0x80, 0x28}, 39 {0x30, 0x23}, {0x40, 0x24},
40 {0x90, 0x29}, {0xa0, 0x2a}, 40 {0x50, 0x25}, {0x60, 0x26},
41 {0xb0, 0x2b}, {0xc0, 0x2c}, 41 {0x70, 0x27}, {0x80, 0x28},
42 {0xd0, 0x2d}, {0xe0, 0x2e}, 42 {0x90, 0x29}, {0xa0, 0x2a},
43 {0xf0, 0x2f}, {0xff, 0x30}); 43 {0xb0, 0x2b}, {0xc0, 0x2c},
44 {0xd0, 0x2d}, {0xe0, 0x2e},
45 {0xf0, 0x2f}, {0xff, 0x30});
46 break;
47 case BRIDGE_SN9C105:
48 case BRIDGE_SN9C120:
49 err = sn9c102_write_const_regs(cam, {0x44, 0x01}, {0x40, 0x02},
50 {0x00, 0x03}, {0x1a, 0x04},
51 {0x50, 0x05}, {0x20, 0x06},
52 {0x10, 0x07}, {0x03, 0x10},
53 {0x08, 0x14}, {0xa2, 0x17},
54 {0x47, 0x18}, {0x00, 0x19},
55 {0x1d, 0x1a}, {0x10, 0x1b},
56 {0x02, 0x1c}, {0x03, 0x1d},
57 {0x0f, 0x1e}, {0x0c, 0x1f},
58 {0x00, 0x20}, {0x29, 0x21},
59 {0x40, 0x22}, {0x54, 0x23},
60 {0x66, 0x24}, {0x76, 0x25},
61 {0x85, 0x26}, {0x94, 0x27},
62 {0xa1, 0x28}, {0xae, 0x29},
63 {0xbb, 0x2a}, {0xc7, 0x2b},
64 {0xd3, 0x2c}, {0xde, 0x2d},
65 {0xea, 0x2e}, {0xf4, 0x2f},
66 {0xff, 0x30}, {0x00, 0x3F},
67 {0xC7, 0x40}, {0x01, 0x41},
68 {0x44, 0x42}, {0x00, 0x43},
69 {0x44, 0x44}, {0x00, 0x45},
70 {0x44, 0x46}, {0x00, 0x47},
71 {0xC7, 0x48}, {0x01, 0x49},
72 {0xC7, 0x4A}, {0x01, 0x4B},
73 {0xC7, 0x4C}, {0x01, 0x4D},
74 {0x44, 0x4E}, {0x00, 0x4F},
75 {0x44, 0x50}, {0x00, 0x51},
76 {0x44, 0x52}, {0x00, 0x53},
77 {0xC7, 0x54}, {0x01, 0x55},
78 {0xC7, 0x56}, {0x01, 0x57},
79 {0xC7, 0x58}, {0x01, 0x59},
80 {0x44, 0x5A}, {0x00, 0x5B},
81 {0x44, 0x5C}, {0x00, 0x5D},
82 {0x44, 0x5E}, {0x00, 0x5F},
83 {0xC7, 0x60}, {0x01, 0x61},
84 {0xC7, 0x62}, {0x01, 0x63},
85 {0xC7, 0x64}, {0x01, 0x65},
86 {0x44, 0x66}, {0x00, 0x67},
87 {0x44, 0x68}, {0x00, 0x69},
88 {0x44, 0x6A}, {0x00, 0x6B},
89 {0xC7, 0x6C}, {0x01, 0x6D},
90 {0xC7, 0x6E}, {0x01, 0x6F},
91 {0xC7, 0x70}, {0x01, 0x71},
92 {0x44, 0x72}, {0x00, 0x73},
93 {0x44, 0x74}, {0x00, 0x75},
94 {0x44, 0x76}, {0x00, 0x77},
95 {0xC7, 0x78}, {0x01, 0x79},
96 {0xC7, 0x7A}, {0x01, 0x7B},
97 {0xC7, 0x7C}, {0x01, 0x7D},
98 {0x44, 0x7E}, {0x00, 0x7F},
99 {0x14, 0x84}, {0x00, 0x85},
100 {0x27, 0x86}, {0x00, 0x87},
101 {0x07, 0x88}, {0x00, 0x89},
102 {0xEC, 0x8A}, {0x0f, 0x8B},
103 {0xD8, 0x8C}, {0x0f, 0x8D},
104 {0x3D, 0x8E}, {0x00, 0x8F},
105 {0x3D, 0x90}, {0x00, 0x91},
106 {0xCD, 0x92}, {0x0f, 0x93},
107 {0xf7, 0x94}, {0x0f, 0x95},
108 {0x0C, 0x96}, {0x00, 0x97},
109 {0x00, 0x98}, {0x66, 0x99},
110 {0x05, 0x9A}, {0x00, 0x9B},
111 {0x04, 0x9C}, {0x00, 0x9D},
112 {0x08, 0x9E}, {0x00, 0x9F},
113 {0x2D, 0xC0}, {0x2D, 0xC1},
114 {0x3A, 0xC2}, {0x05, 0xC3},
115 {0x04, 0xC4}, {0x3F, 0xC5},
116 {0x00, 0xC6}, {0x00, 0xC7},
117 {0x50, 0xC8}, {0x3C, 0xC9},
118 {0x28, 0xCA}, {0xD8, 0xCB},
119 {0x14, 0xCC}, {0xEC, 0xCD},
120 {0x32, 0xCE}, {0xDD, 0xCF},
121 {0x32, 0xD0}, {0xDD, 0xD1},
122 {0x6A, 0xD2}, {0x50, 0xD3},
123 {0x00, 0xD4}, {0x00, 0xD5},
124 {0x00, 0xD6});
125 break;
126 default:
127 break;
128 }
44 129
45 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, 130 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d,
46 0x00, 0x01, 0, 0); 131 0x00, 0x01, 0, 0);
@@ -65,50 +150,50 @@ static int mi0360_get_ctrl(struct sn9c102_device* cam,
65 struct v4l2_control* ctrl) 150 struct v4l2_control* ctrl)
66{ 151{
67 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 152 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
68 u8 data[5+1]; 153 u8 data[2];
69 154
70 switch (ctrl->id) { 155 switch (ctrl->id) {
71 case V4L2_CID_EXPOSURE: 156 case V4L2_CID_EXPOSURE:
72 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 157 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2,
73 2+1, data) < 0) 158 data) < 0)
74 return -EIO; 159 return -EIO;
75 ctrl->value = data[2]; 160 ctrl->value = data[0];
76 return 0; 161 return 0;
77 case V4L2_CID_GAIN: 162 case V4L2_CID_GAIN:
78 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 163 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2,
79 2+1, data) < 0) 164 data) < 0)
80 return -EIO; 165 return -EIO;
81 ctrl->value = data[3]; 166 ctrl->value = data[1];
82 return 0; 167 return 0;
83 case V4L2_CID_RED_BALANCE: 168 case V4L2_CID_RED_BALANCE:
84 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 169 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2,
85 2+1, data) < 0) 170 data) < 0)
86 return -EIO; 171 return -EIO;
87 ctrl->value = data[3]; 172 ctrl->value = data[1];
88 return 0; 173 return 0;
89 case V4L2_CID_BLUE_BALANCE: 174 case V4L2_CID_BLUE_BALANCE:
90 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 175 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2,
91 2+1, data) < 0) 176 data) < 0)
92 return -EIO; 177 return -EIO;
93 ctrl->value = data[3]; 178 ctrl->value = data[1];
94 return 0; 179 return 0;
95 case SN9C102_V4L2_CID_GREEN_BALANCE: 180 case SN9C102_V4L2_CID_GREEN_BALANCE:
96 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 181 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2,
97 2+1, data) < 0) 182 data) < 0)
98 return -EIO; 183 return -EIO;
99 ctrl->value = data[3]; 184 ctrl->value = data[1];
100 return 0; 185 return 0;
101 case V4L2_CID_HFLIP: 186 case V4L2_CID_HFLIP:
102 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 187 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2,
103 2+1, data) < 0) 188 data) < 0)
104 return -EIO; 189 return -EIO;
105 ctrl->value = data[3] & 0x20 ? 1 : 0; 190 ctrl->value = data[1] & 0x20 ? 1 : 0;
106 return 0; 191 return 0;
107 case V4L2_CID_VFLIP: 192 case V4L2_CID_VFLIP:
108 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 193 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2,
109 2+1, data) < 0) 194 data) < 0)
110 return -EIO; 195 return -EIO;
111 ctrl->value = data[3] & 0x80 ? 1 : 0; 196 ctrl->value = data[1] & 0x80 ? 1 : 0;
112 return 0; 197 return 0;
113 default: 198 default:
114 return -EINVAL; 199 return -EINVAL;
@@ -178,8 +263,19 @@ static int mi0360_set_crop(struct sn9c102_device* cam,
178{ 263{
179 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 264 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
180 int err = 0; 265 int err = 0;
181 u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0, 266 u8 h_start = 0, v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1;
182 v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1; 267
268 switch (sn9c102_get_bridge(cam)) {
269 case BRIDGE_SN9C103:
270 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0;
271 break;
272 case BRIDGE_SN9C105:
273 case BRIDGE_SN9C120:
274 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 1;
275 break;
276 default:
277 break;
278 }
183 279
184 err += sn9c102_write_reg(cam, h_start, 0x12); 280 err += sn9c102_write_reg(cam, h_start, 0x12);
185 err += sn9c102_write_reg(cam, v_start, 0x13); 281 err += sn9c102_write_reg(cam, v_start, 0x13);
@@ -194,24 +290,30 @@ static int mi0360_set_pix_format(struct sn9c102_device* cam,
194 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 290 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
195 int err = 0; 291 int err = 0;
196 292
197 if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { 293 if (pix->pixelformat == V4L2_PIX_FMT_SBGGR8) {
198 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id,
199 0x0a, 0x00, 0x02, 0, 0);
200 err += sn9c102_write_reg(cam, 0x20, 0x19);
201 } else {
202 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 294 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id,
203 0x0a, 0x00, 0x05, 0, 0); 295 0x0a, 0x00, 0x05, 0, 0);
204 err += sn9c102_write_reg(cam, 0x60, 0x19); 296 err += sn9c102_write_reg(cam, 0x60, 0x19);
297 if (sn9c102_get_bridge(cam) == BRIDGE_SN9C105 ||
298 sn9c102_get_bridge(cam) == BRIDGE_SN9C120)
299 err += sn9c102_write_reg(cam, 0xa6, 0x17);
300 } else {
301 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id,
302 0x0a, 0x00, 0x02, 0, 0);
303 err += sn9c102_write_reg(cam, 0x20, 0x19);
304 if (sn9c102_get_bridge(cam) == BRIDGE_SN9C105 ||
305 sn9c102_get_bridge(cam) == BRIDGE_SN9C120)
306 err += sn9c102_write_reg(cam, 0xa2, 0x17);
205 } 307 }
206 308
207 return err; 309 return err;
208} 310}
209 311
210 312
211static struct sn9c102_sensor mi0360 = { 313static const struct sn9c102_sensor mi0360 = {
212 .name = "MI-0360", 314 .name = "MI-0360",
213 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 315 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
214 .supported_bridge = BRIDGE_SN9C103, 316 .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120,
215 .frequency = SN9C102_I2C_100KHZ, 317 .frequency = SN9C102_I2C_100KHZ,
216 .interface = SN9C102_I2C_2WIRES, 318 .interface = SN9C102_I2C_2WIRES,
217 .i2c_slave_id = 0x5d, 319 .i2c_slave_id = 0x5d,
@@ -317,19 +419,31 @@ static struct sn9c102_sensor mi0360 = {
317 419
318int sn9c102_probe_mi0360(struct sn9c102_device* cam) 420int sn9c102_probe_mi0360(struct sn9c102_device* cam)
319{ 421{
320 u8 data[5+1];
321 int err;
322 422
323 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, 423 u8 data[2];
324 {0x28, 0x17}); 424
325 if (err) 425 switch (sn9c102_get_bridge(cam)) {
326 return -EIO; 426 case BRIDGE_SN9C103:
427 if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
428 {0x28, 0x17}))
429 return -EIO;
430 break;
431 case BRIDGE_SN9C105:
432 case BRIDGE_SN9C120:
433 if (sn9c102_write_const_regs(cam, {0x01, 0xf1}, {0x00, 0xf1},
434 {0x01, 0x01}, {0x00, 0x01},
435 {0x28, 0x17}))
436 return -EIO;
437 break;
438 default:
439 break;
440 }
327 441
328 if (sn9c102_i2c_try_raw_read(cam, &mi0360, mi0360.i2c_slave_id, 0x00, 442 if (sn9c102_i2c_try_raw_read(cam, &mi0360, mi0360.i2c_slave_id, 0x00,
329 2+1, data) < 0) 443 2, data) < 0)
330 return -EIO; 444 return -EIO;
331 445
332 if (data[2] != 0x82 || data[3] != 0x43) 446 if (data[0] != 0x82 || data[1] != 0x43)
333 return -ENODEV; 447 return -ENODEV;
334 448
335 sn9c102_attach_sensor(cam, &mi0360); 449 sn9c102_attach_sensor(cam, &mi0360);
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7630.c b/drivers/media/video/sn9c102/sn9c102_ov7630.c
index 31b6080b0615..e6832347894f 100644
--- a/drivers/media/video/sn9c102/sn9c102_ov7630.c
+++ b/drivers/media/video/sn9c102/sn9c102_ov7630.c
@@ -29,9 +29,8 @@ static int ov7630_init(struct sn9c102_device* cam)
29 switch (sn9c102_get_bridge(cam)) { 29 switch (sn9c102_get_bridge(cam)) {
30 case BRIDGE_SN9C101: 30 case BRIDGE_SN9C101:
31 case BRIDGE_SN9C102: 31 case BRIDGE_SN9C102:
32 err = sn9c102_write_const_regs(cam, {0x00, 0x14}, 32 err = sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17},
33 {0x60, 0x17}, {0x0f, 0x18}, 33 {0x0f, 0x18}, {0x50, 0x19});
34 {0x50, 0x19});
35 34
36 err += sn9c102_i2c_write(cam, 0x12, 0x8d); 35 err += sn9c102_i2c_write(cam, 0x12, 0x8d);
37 err += sn9c102_i2c_write(cam, 0x12, 0x0d); 36 err += sn9c102_i2c_write(cam, 0x12, 0x0d);
@@ -61,7 +60,6 @@ static int ov7630_init(struct sn9c102_device* cam)
61 err += sn9c102_i2c_write(cam, 0x71, 0x00); 60 err += sn9c102_i2c_write(cam, 0x71, 0x00);
62 err += sn9c102_i2c_write(cam, 0x74, 0x21); 61 err += sn9c102_i2c_write(cam, 0x74, 0x21);
63 err += sn9c102_i2c_write(cam, 0x7d, 0xf7); 62 err += sn9c102_i2c_write(cam, 0x7d, 0xf7);
64
65 break; 63 break;
66 case BRIDGE_SN9C103: 64 case BRIDGE_SN9C103:
67 err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03}, 65 err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03},
@@ -253,7 +251,7 @@ static int ov7630_set_pix_format(struct sn9c102_device* cam,
253} 251}
254 252
255 253
256static struct sn9c102_sensor ov7630 = { 254static const struct sn9c102_sensor ov7630 = {
257 .name = "OV7630", 255 .name = "OV7630",
258 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 256 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
259 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, 257 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103,
@@ -408,19 +406,16 @@ int sn9c102_probe_ov7630(struct sn9c102_device* cam)
408 switch (sn9c102_get_bridge(cam)) { 406 switch (sn9c102_get_bridge(cam)) {
409 case BRIDGE_SN9C101: 407 case BRIDGE_SN9C101:
410 case BRIDGE_SN9C102: 408 case BRIDGE_SN9C102:
411 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, 409 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
412 {0x00, 0x01}, {0x28, 0x17}); 410 {0x28, 0x17});
413
414 break; 411 break;
415 case BRIDGE_SN9C103: /* do _not_ change anything! */ 412 case BRIDGE_SN9C103: /* do _not_ change anything! */
416 err = sn9c102_write_const_regs(cam, {0x09, 0x01}, 413 err = sn9c102_write_const_regs(cam, {0x09, 0x01}, {0x42, 0x01},
417 {0x42, 0x01}, {0x28, 0x17}, 414 {0x28, 0x17}, {0x44, 0x02});
418 {0x44, 0x02});
419 pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a); 415 pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a);
420 if (err || pid < 0) { /* try a different initialization */ 416 if (err || pid < 0) /* try a different initialization */
421 err = sn9c102_write_reg(cam, 0x01, 0x01); 417 err += sn9c102_write_const_regs(cam, {0x01, 0x01},
422 err += sn9c102_write_reg(cam, 0x00, 0x01); 418 {0x00, 0x01});
423 }
424 break; 419 break;
425 default: 420 default:
426 break; 421 break;
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7660.c b/drivers/media/video/sn9c102/sn9c102_ov7660.c
index c898e948fe8d..4b6474048a72 100644
--- a/drivers/media/video/sn9c102/sn9c102_ov7660.c
+++ b/drivers/media/video/sn9c102/sn9c102_ov7660.c
@@ -104,8 +104,8 @@ static int ov7660_init(struct sn9c102_device* cam)
104 err += sn9c102_i2c_write(cam, 0x12, 0x80); 104 err += sn9c102_i2c_write(cam, 0x12, 0x80);
105 err += sn9c102_i2c_write(cam, 0x11, 0x09); 105 err += sn9c102_i2c_write(cam, 0x11, 0x09);
106 err += sn9c102_i2c_write(cam, 0x00, 0x0A); 106 err += sn9c102_i2c_write(cam, 0x00, 0x0A);
107 err += sn9c102_i2c_write(cam, 0x01, 0x78); 107 err += sn9c102_i2c_write(cam, 0x01, 0x80);
108 err += sn9c102_i2c_write(cam, 0x02, 0x90); 108 err += sn9c102_i2c_write(cam, 0x02, 0x80);
109 err += sn9c102_i2c_write(cam, 0x03, 0x00); 109 err += sn9c102_i2c_write(cam, 0x03, 0x00);
110 err += sn9c102_i2c_write(cam, 0x04, 0x00); 110 err += sn9c102_i2c_write(cam, 0x04, 0x00);
111 err += sn9c102_i2c_write(cam, 0x05, 0x08); 111 err += sn9c102_i2c_write(cam, 0x05, 0x08);
@@ -122,7 +122,7 @@ static int ov7660_init(struct sn9c102_device* cam)
122 err += sn9c102_i2c_write(cam, 0x10, 0x20); 122 err += sn9c102_i2c_write(cam, 0x10, 0x20);
123 err += sn9c102_i2c_write(cam, 0x11, 0x03); 123 err += sn9c102_i2c_write(cam, 0x11, 0x03);
124 err += sn9c102_i2c_write(cam, 0x12, 0x05); 124 err += sn9c102_i2c_write(cam, 0x12, 0x05);
125 err += sn9c102_i2c_write(cam, 0x13, 0xF8); 125 err += sn9c102_i2c_write(cam, 0x13, 0xC7);
126 err += sn9c102_i2c_write(cam, 0x14, 0x2C); 126 err += sn9c102_i2c_write(cam, 0x14, 0x2C);
127 err += sn9c102_i2c_write(cam, 0x15, 0x00); 127 err += sn9c102_i2c_write(cam, 0x15, 0x00);
128 err += sn9c102_i2c_write(cam, 0x16, 0x02); 128 err += sn9c102_i2c_write(cam, 0x16, 0x02);
@@ -162,7 +162,7 @@ static int ov7660_init(struct sn9c102_device* cam)
162 err += sn9c102_i2c_write(cam, 0x38, 0x02); 162 err += sn9c102_i2c_write(cam, 0x38, 0x02);
163 err += sn9c102_i2c_write(cam, 0x39, 0x43); 163 err += sn9c102_i2c_write(cam, 0x39, 0x43);
164 err += sn9c102_i2c_write(cam, 0x3A, 0x00); 164 err += sn9c102_i2c_write(cam, 0x3A, 0x00);
165 err += sn9c102_i2c_write(cam, 0x3B, 0x02); 165 err += sn9c102_i2c_write(cam, 0x3B, 0x0A);
166 err += sn9c102_i2c_write(cam, 0x3C, 0x6C); 166 err += sn9c102_i2c_write(cam, 0x3C, 0x6C);
167 err += sn9c102_i2c_write(cam, 0x3D, 0x99); 167 err += sn9c102_i2c_write(cam, 0x3D, 0x99);
168 err += sn9c102_i2c_write(cam, 0x3E, 0x0E); 168 err += sn9c102_i2c_write(cam, 0x3E, 0x0E);
@@ -281,25 +281,34 @@ static int ov7660_get_ctrl(struct sn9c102_device* cam,
281 return -EIO; 281 return -EIO;
282 break; 282 break;
283 case V4L2_CID_DO_WHITE_BALANCE: 283 case V4L2_CID_DO_WHITE_BALANCE:
284 ctrl->value = sn9c102_pread_reg(cam, 0x02); 284 if ((ctrl->value = sn9c102_read_reg(cam, 0x02)) < 0)
285 return -EIO;
285 ctrl->value = (ctrl->value & 0x04) ? 1 : 0; 286 ctrl->value = (ctrl->value & 0x04) ? 1 : 0;
286 break; 287 break;
287 case V4L2_CID_RED_BALANCE: 288 case V4L2_CID_RED_BALANCE:
288 ctrl->value = sn9c102_pread_reg(cam, 0x05); 289 if ((ctrl->value = sn9c102_read_reg(cam, 0x05)) < 0)
290 return -EIO;
289 ctrl->value &= 0x7f; 291 ctrl->value &= 0x7f;
290 break; 292 break;
291 case V4L2_CID_BLUE_BALANCE: 293 case V4L2_CID_BLUE_BALANCE:
292 ctrl->value = sn9c102_pread_reg(cam, 0x06); 294 if ((ctrl->value = sn9c102_read_reg(cam, 0x06)) < 0)
295 return -EIO;
293 ctrl->value &= 0x7f; 296 ctrl->value &= 0x7f;
294 break; 297 break;
295 case SN9C102_V4L2_CID_GREEN_BALANCE: 298 case SN9C102_V4L2_CID_GREEN_BALANCE:
296 ctrl->value = sn9c102_pread_reg(cam, 0x07); 299 if ((ctrl->value = sn9c102_read_reg(cam, 0x07)) < 0)
300 return -EIO;
297 ctrl->value &= 0x7f; 301 ctrl->value &= 0x7f;
298 break; 302 break;
303 case SN9C102_V4L2_CID_BAND_FILTER:
304 if ((ctrl->value = sn9c102_i2c_read(cam, 0x3b)) < 0)
305 return -EIO;
306 ctrl->value &= 0x08;
307 break;
299 case V4L2_CID_GAIN: 308 case V4L2_CID_GAIN:
300 if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0) 309 if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0)
301 return -EIO; 310 return -EIO;
302 ctrl->value &= 0x7f; 311 ctrl->value &= 0x1f;
303 break; 312 break;
304 case V4L2_CID_AUTOGAIN: 313 case V4L2_CID_AUTOGAIN:
305 if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0) 314 if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0)
@@ -335,12 +344,15 @@ static int ov7660_set_ctrl(struct sn9c102_device* cam,
335 case SN9C102_V4L2_CID_GREEN_BALANCE: 344 case SN9C102_V4L2_CID_GREEN_BALANCE:
336 err += sn9c102_write_reg(cam, ctrl->value, 0x07); 345 err += sn9c102_write_reg(cam, ctrl->value, 0x07);
337 break; 346 break;
347 case SN9C102_V4L2_CID_BAND_FILTER:
348 err += sn9c102_i2c_write(cam, ctrl->value << 3, 0x3b);
349 break;
338 case V4L2_CID_GAIN: 350 case V4L2_CID_GAIN:
339 err += sn9c102_i2c_write(cam, 0x00, ctrl->value); 351 err += sn9c102_i2c_write(cam, 0x00, 0x60 + ctrl->value);
340 break; 352 break;
341 case V4L2_CID_AUTOGAIN: 353 case V4L2_CID_AUTOGAIN:
342 err += sn9c102_i2c_write(cam, 0x13, 0xf0 | ctrl->value | 354 err += sn9c102_i2c_write(cam, 0x13, 0xc0 |
343 (ctrl->value << 1)); 355 (ctrl->value * 0x07));
344 break; 356 break;
345 default: 357 default:
346 return -EINVAL; 358 return -EINVAL;
@@ -386,7 +398,7 @@ static int ov7660_set_pix_format(struct sn9c102_device* cam,
386} 398}
387 399
388 400
389static struct sn9c102_sensor ov7660 = { 401static const struct sn9c102_sensor ov7660 = {
390 .name = "OV7660", 402 .name = "OV7660",
391 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 403 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
392 .supported_bridge = BRIDGE_SN9C105 | BRIDGE_SN9C120, 404 .supported_bridge = BRIDGE_SN9C105 | BRIDGE_SN9C120,
@@ -401,9 +413,9 @@ static struct sn9c102_sensor ov7660 = {
401 .type = V4L2_CTRL_TYPE_INTEGER, 413 .type = V4L2_CTRL_TYPE_INTEGER,
402 .name = "global gain", 414 .name = "global gain",
403 .minimum = 0x00, 415 .minimum = 0x00,
404 .maximum = 0x7f, 416 .maximum = 0x1f,
405 .step = 0x01, 417 .step = 0x01,
406 .default_value = 0x0a, 418 .default_value = 0x09,
407 .flags = 0, 419 .flags = 0,
408 }, 420 },
409 { 421 {
@@ -413,7 +425,7 @@ static struct sn9c102_sensor ov7660 = {
413 .minimum = 0x00, 425 .minimum = 0x00,
414 .maximum = 0xff, 426 .maximum = 0xff,
415 .step = 0x01, 427 .step = 0x01,
416 .default_value = 0x50, 428 .default_value = 0x27,
417 .flags = 0, 429 .flags = 0,
418 }, 430 },
419 { 431 {
@@ -433,7 +445,7 @@ static struct sn9c102_sensor ov7660 = {
433 .minimum = 0x00, 445 .minimum = 0x00,
434 .maximum = 0x7f, 446 .maximum = 0x7f,
435 .step = 0x01, 447 .step = 0x01,
436 .default_value = 0x1f, 448 .default_value = 0x14,
437 .flags = 0, 449 .flags = 0,
438 }, 450 },
439 { 451 {
@@ -443,7 +455,7 @@ static struct sn9c102_sensor ov7660 = {
443 .minimum = 0x00, 455 .minimum = 0x00,
444 .maximum = 0x7f, 456 .maximum = 0x7f,
445 .step = 0x01, 457 .step = 0x01,
446 .default_value = 0x1e, 458 .default_value = 0x14,
447 .flags = 0, 459 .flags = 0,
448 }, 460 },
449 { 461 {
@@ -453,7 +465,7 @@ static struct sn9c102_sensor ov7660 = {
453 .minimum = 0x00, 465 .minimum = 0x00,
454 .maximum = 0x01, 466 .maximum = 0x01,
455 .step = 0x01, 467 .step = 0x01,
456 .default_value = 0x00, 468 .default_value = 0x01,
457 .flags = 0, 469 .flags = 0,
458 }, 470 },
459 { 471 {
@@ -463,7 +475,17 @@ static struct sn9c102_sensor ov7660 = {
463 .minimum = 0x00, 475 .minimum = 0x00,
464 .maximum = 0x7f, 476 .maximum = 0x7f,
465 .step = 0x01, 477 .step = 0x01,
466 .default_value = 0x20, 478 .default_value = 0x14,
479 .flags = 0,
480 },
481 {
482 .id = SN9C102_V4L2_CID_BAND_FILTER,
483 .type = V4L2_CTRL_TYPE_BOOLEAN,
484 .name = "band filter",
485 .minimum = 0x00,
486 .maximum = 0x01,
487 .step = 0x01,
488 .default_value = 0x00,
467 .flags = 0, 489 .flags = 0,
468 }, 490 },
469 }, 491 },
@@ -508,6 +530,7 @@ int sn9c102_probe_ov7660(struct sn9c102_device* cam)
508 return -EIO; 530 return -EIO;
509 if (pid != 0x76 || ver != 0x60) 531 if (pid != 0x76 || ver != 0x60)
510 return -ENODEV; 532 return -ENODEV;
533
511 sn9c102_attach_sensor(cam, &ov7660); 534 sn9c102_attach_sensor(cam, &ov7660);
512 535
513 return 0; 536 return 0;
diff --git a/drivers/media/video/sn9c102/sn9c102_pas106b.c b/drivers/media/video/sn9c102/sn9c102_pas106b.c
index 67151964801f..360f2a848bc0 100644
--- a/drivers/media/video/sn9c102/sn9c102_pas106b.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas106b.c
@@ -163,7 +163,7 @@ static int pas106b_set_pix_format(struct sn9c102_device* cam,
163} 163}
164 164
165 165
166static struct sn9c102_sensor pas106b = { 166static const struct sn9c102_sensor pas106b = {
167 .name = "PAS106B", 167 .name = "PAS106B",
168 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 168 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
169 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 169 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
@@ -273,23 +273,21 @@ static struct sn9c102_sensor pas106b = {
273 273
274int sn9c102_probe_pas106b(struct sn9c102_device* cam) 274int sn9c102_probe_pas106b(struct sn9c102_device* cam)
275{ 275{
276 int r0 = 0, r1 = 0, err; 276 int r0 = 0, r1 = 0;
277 unsigned int pid = 0; 277 unsigned int pid = 0;
278 278
279 /* 279 /*
280 Minimal initialization to enable the I2C communication 280 Minimal initialization to enable the I2C communication
281 NOTE: do NOT change the values! 281 NOTE: do NOT change the values!
282 */ 282 */
283 err = sn9c102_write_const_regs(cam, 283 if (sn9c102_write_const_regs(cam,
284 {0x01, 0x01}, /* sensor power down */ 284 {0x01, 0x01}, /* sensor power down */
285 {0x00, 0x01}, /* sensor power on */ 285 {0x00, 0x01}, /* sensor power on */
286 {0x28, 0x17});/* sensor clock 24 MHz */ 286 {0x28, 0x17})) /* sensor clock at 24 MHz */
287 if (err)
288 return -EIO; 287 return -EIO;
289 288
290 r0 = sn9c102_i2c_try_read(cam, &pas106b, 0x00); 289 r0 = sn9c102_i2c_try_read(cam, &pas106b, 0x00);
291 r1 = sn9c102_i2c_try_read(cam, &pas106b, 0x01); 290 r1 = sn9c102_i2c_try_read(cam, &pas106b, 0x01);
292
293 if (r0 < 0 || r1 < 0) 291 if (r0 < 0 || r1 < 0)
294 return -EIO; 292 return -EIO;
295 293
diff --git a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
index c1b8d6b63b47..ca4a1506ed3d 100644
--- a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
@@ -35,29 +35,28 @@ static int pas202bcb_init(struct sn9c102_device* cam)
35 switch (sn9c102_get_bridge(cam)) { 35 switch (sn9c102_get_bridge(cam)) {
36 case BRIDGE_SN9C101: 36 case BRIDGE_SN9C101:
37 case BRIDGE_SN9C102: 37 case BRIDGE_SN9C102:
38 err = sn9c102_write_const_regs(cam, {0x00, 0x10}, 38 err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11},
39 {0x00, 0x11}, {0x00, 0x14}, 39 {0x00, 0x14}, {0x20, 0x17},
40 {0x20, 0x17}, {0x30, 0x19}, 40 {0x30, 0x19}, {0x09, 0x18});
41 {0x09, 0x18});
42 break; 41 break;
43 case BRIDGE_SN9C103: 42 case BRIDGE_SN9C103:
44 err = sn9c102_write_const_regs(cam, {0x00, 0x02}, 43 err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03},
45 {0x00, 0x03}, {0x1a, 0x04}, 44 {0x1a, 0x04}, {0x20, 0x05},
46 {0x20, 0x05}, {0x20, 0x06}, 45 {0x20, 0x06}, {0x20, 0x07},
47 {0x20, 0x07}, {0x00, 0x10}, 46 {0x00, 0x10}, {0x00, 0x11},
48 {0x00, 0x11}, {0x00, 0x14}, 47 {0x00, 0x14}, {0x20, 0x17},
49 {0x20, 0x17}, {0x30, 0x19}, 48 {0x30, 0x19}, {0x09, 0x18},
50 {0x09, 0x18}, {0x02, 0x1c}, 49 {0x02, 0x1c}, {0x03, 0x1d},
51 {0x03, 0x1d}, {0x0f, 0x1e}, 50 {0x0f, 0x1e}, {0x0c, 0x1f},
52 {0x0c, 0x1f}, {0x00, 0x20}, 51 {0x00, 0x20}, {0x10, 0x21},
53 {0x10, 0x21}, {0x20, 0x22}, 52 {0x20, 0x22}, {0x30, 0x23},
54 {0x30, 0x23}, {0x40, 0x24}, 53 {0x40, 0x24}, {0x50, 0x25},
55 {0x50, 0x25}, {0x60, 0x26}, 54 {0x60, 0x26}, {0x70, 0x27},
56 {0x70, 0x27}, {0x80, 0x28}, 55 {0x80, 0x28}, {0x90, 0x29},
57 {0x90, 0x29}, {0xa0, 0x2a}, 56 {0xa0, 0x2a}, {0xb0, 0x2b},
58 {0xb0, 0x2b}, {0xc0, 0x2c}, 57 {0xc0, 0x2c}, {0xd0, 0x2d},
59 {0xd0, 0x2d}, {0xe0, 0x2e}, 58 {0xe0, 0x2e}, {0xf0, 0x2f},
60 {0xf0, 0x2f}, {0xff, 0x30}); 59 {0xff, 0x30});
61 break; 60 break;
62 default: 61 default:
63 break; 62 break;
@@ -197,7 +196,7 @@ static int pas202bcb_set_crop(struct sn9c102_device* cam,
197} 196}
198 197
199 198
200static struct sn9c102_sensor pas202bcb = { 199static const struct sn9c102_sensor pas202bcb = {
201 .name = "PAS202BCB", 200 .name = "PAS202BCB",
202 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 201 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
203 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, 202 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103,
@@ -313,9 +312,8 @@ int sn9c102_probe_pas202bcb(struct sn9c102_device* cam)
313 {0x28, 0x17});/* clock 24 MHz */ 312 {0x28, 0x17});/* clock 24 MHz */
314 break; 313 break;
315 case BRIDGE_SN9C103: /* do _not_ change anything! */ 314 case BRIDGE_SN9C103: /* do _not_ change anything! */
316 err = sn9c102_write_const_regs(cam, {0x09, 0x01}, 315 err = sn9c102_write_const_regs(cam, {0x09, 0x01}, {0x44, 0x01},
317 {0x44, 0x01}, {0x44, 0x02}, 316 {0x44, 0x02}, {0x29, 0x17});
318 {0x29, 0x17});
319 break; 317 break;
320 default: 318 default:
321 break; 319 break;
diff --git a/drivers/media/video/sn9c102/sn9c102_sensor.h b/drivers/media/video/sn9c102/sn9c102_sensor.h
index 1bbf64c897a2..2d7d786b8430 100644
--- a/drivers/media/video/sn9c102/sn9c102_sensor.h
+++ b/drivers/media/video/sn9c102/sn9c102_sensor.h
@@ -22,7 +22,7 @@
22#define _SN9C102_SENSOR_H_ 22#define _SN9C102_SENSOR_H_
23 23
24#include <linux/usb.h> 24#include <linux/usb.h>
25#include <linux/videodev.h> 25#include <linux/videodev2.h>
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/stddef.h> 27#include <linux/stddef.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
@@ -74,7 +74,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id);
74/* Attach a probed sensor to the camera. */ 74/* Attach a probed sensor to the camera. */
75extern void 75extern void
76sn9c102_attach_sensor(struct sn9c102_device* cam, 76sn9c102_attach_sensor(struct sn9c102_device* cam,
77 struct sn9c102_sensor* sensor); 77 const struct sn9c102_sensor* sensor);
78 78
79/* 79/*
80 Read/write routines: they always return -1 on error, 0 or the read value 80 Read/write routines: they always return -1 on error, 0 or the read value
@@ -85,10 +85,11 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
85*/ 85*/
86 86
87/* The "try" I2C I/O versions are used when probing the sensor */ 87/* The "try" I2C I/O versions are used when probing the sensor */
88extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*, 88extern int sn9c102_i2c_try_write(struct sn9c102_device*,
89 u8 address, u8 value); 89 const struct sn9c102_sensor*, u8 address,
90extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, 90 u8 value);
91 u8 address); 91extern int sn9c102_i2c_try_read(struct sn9c102_device*,
92 const struct sn9c102_sensor*, u8 address);
92 93
93/* 94/*
94 These must be used if and only if the sensor doesn't implement the standard 95 These must be used if and only if the sensor doesn't implement the standard
@@ -102,29 +103,31 @@ extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
102 byte. 103 byte.
103*/ 104*/
104extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 105extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
105 struct sn9c102_sensor* sensor, u8 n, 106 const struct sn9c102_sensor* sensor, u8 n,
106 u8 data0, u8 data1, u8 data2, u8 data3, 107 u8 data0, u8 data1, u8 data2, u8 data3,
107 u8 data4, u8 data5); 108 u8 data4, u8 data5);
108extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 109extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
109 struct sn9c102_sensor* sensor, u8 data0, 110 const struct sn9c102_sensor* sensor,
110 u8 data1, u8 n, u8 buffer[]); 111 u8 data0, u8 data1, u8 n, u8 buffer[]);
111 112
112/* To be used after the sensor struct has been attached to the camera struct */ 113/* To be used after the sensor struct has been attached to the camera struct */
113extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); 114extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value);
114extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address); 115extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address);
115 116
116/* I/O on registers in the bridge. Could be used by the sensor methods too */ 117/* I/O on registers in the bridge. Could be used by the sensor methods too */
118extern int sn9c102_read_reg(struct sn9c102_device*, u16 index);
117extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index); 119extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index);
118extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); 120extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index);
119extern int sn9c102_write_regs(struct sn9c102_device*, const u8 valreg[][2], 121extern int sn9c102_write_regs(struct sn9c102_device*, const u8 valreg[][2],
120 int count); 122 int count);
121/* 123/*
122 * Write multiple registers with constant values. For example: 124 Write multiple registers with constant values. For example:
123 * sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18}); 125 sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18});
124 */ 126 Register adresses must be < 256.
125#define sn9c102_write_const_regs(device, data...) \ 127*/
126 ({ const static u8 _data[][2] = {data}; \ 128#define sn9c102_write_const_regs(sn9c102_device, data...) \
127 sn9c102_write_regs(device, _data, ARRAY_SIZE(_data)); }) 129 ({ const static u8 _valreg[][2] = {data}; \
130 sn9c102_write_regs(sn9c102_device, _valreg, ARRAY_SIZE(_valreg)); })
128 131
129/*****************************************************************************/ 132/*****************************************************************************/
130 133
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
index 0e7ec8662c70..e7d2de2bace1 100644
--- a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
@@ -88,7 +88,7 @@ static int tas5110c1b_set_pix_format(struct sn9c102_device* cam,
88} 88}
89 89
90 90
91static struct sn9c102_sensor tas5110c1b = { 91static const struct sn9c102_sensor tas5110c1b = {
92 .name = "TAS5110C1B", 92 .name = "TAS5110C1B",
93 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 93 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
94 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 94 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5110d.c b/drivers/media/video/sn9c102/sn9c102_tas5110d.c
index 83a39e8b5e71..d32fdbccdc5e 100644
--- a/drivers/media/video/sn9c102/sn9c102_tas5110d.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5110d.c
@@ -68,7 +68,7 @@ static int tas5110d_set_pix_format(struct sn9c102_device* cam,
68} 68}
69 69
70 70
71static struct sn9c102_sensor tas5110d = { 71static const struct sn9c102_sensor tas5110d = {
72 .name = "TAS5110D", 72 .name = "TAS5110D",
73 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 73 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
74 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 74 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
index 50406503fc40..56fb1d575a8a 100644
--- a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
@@ -89,7 +89,7 @@ static int tas5130d1b_set_pix_format(struct sn9c102_device* cam,
89} 89}
90 90
91 91
92static struct sn9c102_sensor tas5130d1b = { 92static const struct sn9c102_sensor tas5130d1b = {
93 .name = "TAS5130D1B", 93 .name = "TAS5130D1B",
94 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 94 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
95 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 95 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
diff --git a/drivers/media/video/usbvideo/Kconfig b/drivers/media/video/usbvideo/Kconfig
index a0fd82b924f2..e4cb99c1f94b 100644
--- a/drivers/media/video/usbvideo/Kconfig
+++ b/drivers/media/video/usbvideo/Kconfig
@@ -3,7 +3,7 @@ config VIDEO_USBVIDEO
3 3
4config USB_VICAM 4config USB_VICAM
5 tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)" 5 tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)"
6 depends on USB && VIDEO_DEV && VIDEO_V4L1 && EXPERIMENTAL 6 depends on VIDEO_V4L1 && EXPERIMENTAL
7 select VIDEO_USBVIDEO 7 select VIDEO_USBVIDEO
8 ---help--- 8 ---help---
9 Say Y here if you have 3com homeconnect camera (vicam). 9 Say Y here if you have 3com homeconnect camera (vicam).
@@ -13,7 +13,7 @@ config USB_VICAM
13 13
14config USB_IBMCAM 14config USB_IBMCAM
15 tristate "USB IBM (Xirlink) C-it Camera support" 15 tristate "USB IBM (Xirlink) C-it Camera support"
16 depends on USB && VIDEO_DEV && VIDEO_V4L1 16 depends on VIDEO_V4L1
17 select VIDEO_USBVIDEO 17 select VIDEO_USBVIDEO
18 ---help--- 18 ---help---
19 Say Y here if you want to connect a IBM "C-It" camera, also known as 19 Say Y here if you want to connect a IBM "C-It" camera, also known as
@@ -28,7 +28,7 @@ config USB_IBMCAM
28 28
29config USB_KONICAWC 29config USB_KONICAWC
30 tristate "USB Konica Webcam support" 30 tristate "USB Konica Webcam support"
31 depends on USB && VIDEO_DEV && VIDEO_V4L1 31 depends on VIDEO_V4L1
32 select VIDEO_USBVIDEO 32 select VIDEO_USBVIDEO
33 ---help--- 33 ---help---
34 Say Y here if you want support for webcams based on a Konica 34 Say Y here if you want support for webcams based on a Konica
@@ -39,7 +39,7 @@ config USB_KONICAWC
39 39
40config USB_QUICKCAM_MESSENGER 40config USB_QUICKCAM_MESSENGER
41 tristate "USB Logitech Quickcam Messenger" 41 tristate "USB Logitech Quickcam Messenger"
42 depends on USB && VIDEO_DEV && VIDEO_V4L1 42 depends on VIDEO_V4L1
43 select VIDEO_USBVIDEO 43 select VIDEO_USBVIDEO
44 ---help--- 44 ---help---
45 Say Y or M here to enable support for the USB Logitech Quickcam 45 Say Y or M here to enable support for the USB Logitech Quickcam
diff --git a/drivers/media/video/usbvision/Kconfig b/drivers/media/video/usbvision/Kconfig
index c43a5d899091..fc24ef05b3f3 100644
--- a/drivers/media/video/usbvision/Kconfig
+++ b/drivers/media/video/usbvision/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_USBVISION 1config VIDEO_USBVISION
2 tristate "USB video devices based on Nogatech NT1003/1004/1005" 2 tristate "USB video devices based on Nogatech NT1003/1004/1005"
3 depends on I2C && VIDEO_V4L2 && USB 3 depends on I2C && VIDEO_V4L2
4 select VIDEO_TUNER 4 select VIDEO_TUNER
5 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO 5 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
6 ---help--- 6 ---help---
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index a861e150865e..ede8543818bf 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -127,7 +127,7 @@ set_v4l_control(struct inode *inode,
127 127
128/* ----------------------------------------------------------------- */ 128/* ----------------------------------------------------------------- */
129 129
130static int palette2pixelformat[] = { 130const static unsigned int palette2pixelformat[] = {
131 [VIDEO_PALETTE_GREY] = V4L2_PIX_FMT_GREY, 131 [VIDEO_PALETTE_GREY] = V4L2_PIX_FMT_GREY,
132 [VIDEO_PALETTE_RGB555] = V4L2_PIX_FMT_RGB555, 132 [VIDEO_PALETTE_RGB555] = V4L2_PIX_FMT_RGB555,
133 [VIDEO_PALETTE_RGB565] = V4L2_PIX_FMT_RGB565, 133 [VIDEO_PALETTE_RGB565] = V4L2_PIX_FMT_RGB565,
@@ -145,7 +145,7 @@ static int palette2pixelformat[] = {
145 [VIDEO_PALETTE_YUV422P] = V4L2_PIX_FMT_YUV422P, 145 [VIDEO_PALETTE_YUV422P] = V4L2_PIX_FMT_YUV422P,
146}; 146};
147 147
148static unsigned int 148static unsigned int __attribute_pure__
149palette_to_pixelformat(unsigned int palette) 149palette_to_pixelformat(unsigned int palette)
150{ 150{
151 if (palette < ARRAY_SIZE(palette2pixelformat)) 151 if (palette < ARRAY_SIZE(palette2pixelformat))
@@ -154,8 +154,8 @@ palette_to_pixelformat(unsigned int palette)
154 return 0; 154 return 0;
155} 155}
156 156
157static unsigned int 157static unsigned int __attribute_const__
158pixelformat_to_palette(int pixelformat) 158pixelformat_to_palette(unsigned int pixelformat)
159{ 159{
160 int palette = 0; 160 int palette = 0;
161 switch (pixelformat) 161 switch (pixelformat)
@@ -616,6 +616,8 @@ v4l_compat_translate_ioctl(struct inode *inode,
616 case VIDIOCSPICT: /* set tone controls & partial capture format */ 616 case VIDIOCSPICT: /* set tone controls & partial capture format */
617 { 617 {
618 struct video_picture *pict = arg; 618 struct video_picture *pict = arg;
619 int mem_err = 0, ovl_err = 0;
620
619 memset(&fbuf2, 0, sizeof(fbuf2)); 621 memset(&fbuf2, 0, sizeof(fbuf2));
620 622
621 set_v4l_control(inode, file, 623 set_v4l_control(inode, file,
@@ -628,33 +630,59 @@ v4l_compat_translate_ioctl(struct inode *inode,
628 V4L2_CID_SATURATION, pict->colour, drv); 630 V4L2_CID_SATURATION, pict->colour, drv);
629 set_v4l_control(inode, file, 631 set_v4l_control(inode, file,
630 V4L2_CID_WHITENESS, pict->whiteness, drv); 632 V4L2_CID_WHITENESS, pict->whiteness, drv);
633 /*
634 * V4L1 uses this ioctl to set both memory capture and overlay
635 * pixel format, while V4L2 has two different ioctls for this.
636 * Some cards may not support one or the other, and may support
637 * different pixel formats for memory vs overlay.
638 */
631 639
632 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); 640 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
633 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 641 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
634 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 642 err = drv(inode, file, VIDIOC_G_FMT, fmt2);
635 if (err < 0) 643 /* If VIDIOC_G_FMT failed, then the driver likely doesn't
644 support memory capture. Trying to set the memory capture
645 parameters would be pointless. */
646 if (err < 0) {
636 dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err); 647 dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err);
637 if (fmt2->fmt.pix.pixelformat != 648 mem_err = -1000; /* didn't even try */
638 palette_to_pixelformat(pict->palette)) { 649 } else if (fmt2->fmt.pix.pixelformat !=
650 palette_to_pixelformat(pict->palette)) {
639 fmt2->fmt.pix.pixelformat = palette_to_pixelformat( 651 fmt2->fmt.pix.pixelformat = palette_to_pixelformat(
640 pict->palette); 652 pict->palette);
641 err = drv(inode, file, VIDIOC_S_FMT, fmt2); 653 mem_err = drv(inode, file, VIDIOC_S_FMT, fmt2);
642 if (err < 0) 654 if (mem_err < 0)
643 dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n",err); 655 dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n",
656 mem_err);
644 } 657 }
645 658
646 err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); 659 err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2);
647 if (err < 0) 660 /* If VIDIOC_G_FBUF failed, then the driver likely doesn't
661 support overlay. Trying to set the overlay parameters
662 would be quite pointless. */
663 if (err < 0) {
648 dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n",err); 664 dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n",err);
649 if (fbuf2.fmt.pixelformat != 665 ovl_err = -1000; /* didn't even try */
650 palette_to_pixelformat(pict->palette)) { 666 } else if (fbuf2.fmt.pixelformat !=
667 palette_to_pixelformat(pict->palette)) {
651 fbuf2.fmt.pixelformat = palette_to_pixelformat( 668 fbuf2.fmt.pixelformat = palette_to_pixelformat(
652 pict->palette); 669 pict->palette);
653 err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); 670 ovl_err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2);
654 if (err < 0) 671 if (ovl_err < 0)
655 dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n",err); 672 dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n",
656 err = 0; /* likely fails for non-root */ 673 ovl_err);
657 } 674 }
675 if (ovl_err < 0 && mem_err < 0)
676 /* ioctl failed, couldn't set either parameter */
677 if (mem_err != -1000) {
678 err = mem_err;
679 } else if (ovl_err == -EPERM) {
680 err = 0;
681 } else {
682 err = ovl_err;
683 }
684 else
685 err = 0;
658 break; 686 break;
659 } 687 }
660 case VIDIOCGTUNER: /* get tuner information */ 688 case VIDIOCGTUNER: /* get tuner information */
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index 459786ff459a..a32dfbe0585a 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -702,9 +702,7 @@ videobuf_qbuf(struct videobuf_queue *q,
702 dprintk(1,"qbuf: memory type is wrong.\n"); 702 dprintk(1,"qbuf: memory type is wrong.\n");
703 goto done; 703 goto done;
704 } 704 }
705 if (buf->state == STATE_QUEUED || 705 if (buf->state != STATE_NEEDS_INIT && buf->state != STATE_IDLE) {
706 buf->state == STATE_PREPARED ||
707 buf->state == STATE_ACTIVE) {
708 dprintk(1,"qbuf: buffer is already queued or active.\n"); 706 dprintk(1,"qbuf: buffer is already queued or active.\n");
709 goto done; 707 goto done;
710 } 708 }
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 5263b50463e1..b876aca69c73 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -433,13 +433,43 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
433 int ret = -EINVAL; 433 int ret = -EINVAL;
434 434
435 if ( (vfd->debug & V4L2_DEBUG_IOCTL) && 435 if ( (vfd->debug & V4L2_DEBUG_IOCTL) &&
436 !(vfd->debug | V4L2_DEBUG_IOCTL_ARG)) { 436 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
437 v4l_print_ioctl(vfd->name, cmd); 437 v4l_print_ioctl(vfd->name, cmd);
438 } 438 }
439 439
440#ifdef CONFIG_VIDEO_V4L1_COMPAT
441 /***********************************************************
442 Handles calls to the obsoleted V4L1 API
443 Due to the nature of VIDIOCGMBUF, each driver that supports
444 V4L1 should implement its own handler for this ioctl.
445 ***********************************************************/
446
447 /* --- streaming capture ------------------------------------- */
448 if (cmd == VIDIOCGMBUF) {
449 struct video_mbuf *p=arg;
450
451 memset(p,0,sizeof(p));
452
453 if (!vfd->vidiocgmbuf)
454 return ret;
455 ret=vfd->vidiocgmbuf(file, fh, p);
456 if (!ret)
457 dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
458 p->size, p->frames,
459 (unsigned long)p->offsets);
460 return ret;
461 }
462
463 /********************************************************
464 All other V4L1 calls are handled by v4l1_compat module.
465 Those calls will be translated into V4L2 calls, and
466 __video_do_ioctl will be called again, with one or more
467 V4L2 ioctls.
468 ********************************************************/
440 if (_IOC_TYPE(cmd)=='v') 469 if (_IOC_TYPE(cmd)=='v')
441 return v4l_compat_translate_ioctl(inode,file,cmd,arg, 470 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
442 __video_do_ioctl); 471 __video_do_ioctl);
472#endif
443 473
444 switch(cmd) { 474 switch(cmd) {
445 /* --- capabilities ------------------------------------------ */ 475 /* --- capabilities ------------------------------------------ */
@@ -791,24 +821,6 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
791 ret=vfd->vidioc_overlay(file, fh, *i); 821 ret=vfd->vidioc_overlay(file, fh, *i);
792 break; 822 break;
793 } 823 }
794#ifdef CONFIG_VIDEO_V4L1_COMPAT
795 /* --- streaming capture ------------------------------------- */
796 case VIDIOCGMBUF:
797 {
798 struct video_mbuf *p=arg;
799
800 memset(p,0,sizeof(p));
801
802 if (!vfd->vidiocgmbuf)
803 break;
804 ret=vfd->vidiocgmbuf(file, fh, p);
805 if (!ret)
806 dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
807 p->size, p->frames,
808 (unsigned long)p->offsets);
809 break;
810 }
811#endif
812 case VIDIOC_G_FBUF: 824 case VIDIOC_G_FBUF:
813 { 825 {
814 struct v4l2_framebuffer *p=arg; 826 struct v4l2_framebuffer *p=arg;
diff --git a/drivers/media/video/zc0301/Kconfig b/drivers/media/video/zc0301/Kconfig
index a859a6920189..47cd93f9c7de 100644
--- a/drivers/media/video/zc0301/Kconfig
+++ b/drivers/media/video/zc0301/Kconfig
@@ -1,6 +1,6 @@
1config USB_ZC0301 1config USB_ZC0301
2 tristate "USB ZC0301[P] Image Processor and Control Chip support" 2 tristate "USB ZC0301[P] Image Processor and Control Chip support"
3 depends on USB && VIDEO_V4L1 3 depends on VIDEO_V4L1
4 ---help--- 4 ---help---
5 Say Y here if you want support for cameras based on the ZC0301 or 5 Say Y here if you want support for cameras based on the ZC0301 or
6 ZC0301P Image Processors and Control Chips. 6 ZC0301P Image Processors and Control Chips.