aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/Kconfig24
-rw-r--r--drivers/media/dvb/bt8xx/Kconfig1
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c12
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c18
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.h2
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c54
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u.c47
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h2
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x-fe.c5
-rw-r--r--drivers/media/dvb/frontends/Kconfig12
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c12
-rw-r--r--drivers/media/dvb/ttpci/av7110.c8
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c2
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c13
-rw-r--r--drivers/media/dvb/ttpci/budget-core.c78
-rw-r--r--drivers/media/dvb/ttpci/budget-patch.c24
-rw-r--r--drivers/media/dvb/ttpci/budget.h13
-rw-r--r--drivers/media/video/Kconfig233
-rw-r--r--drivers/media/video/Makefile6
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c170
-rw-r--r--drivers/media/video/bt8xx/bttv-vbi.c2
-rw-r--r--drivers/media/video/cpia.c13
-rw-r--r--drivers/media/video/cpia2/cpia2.h2
-rw-r--r--drivers/media/video/cx25840/cx25840-audio.c3
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c24
-rw-r--r--drivers/media/video/cx25840/cx25840-core.h (renamed from drivers/media/video/cx25840/cx25840.h)46
-rw-r--r--drivers/media/video/cx25840/cx25840-firmware.c15
-rw-r--r--drivers/media/video/cx25840/cx25840-vbi.c9
-rw-r--r--drivers/media/video/cx88/Kconfig15
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c4
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c33
-rw-r--r--drivers/media/video/et61x251/Kconfig14
-rw-r--r--drivers/media/video/ir-kbd-i2c.c3
-rw-r--r--drivers/media/video/msp3400-driver.c91
-rw-r--r--drivers/media/video/msp3400-driver.h6
-rw-r--r--drivers/media/video/msp3400-kthreads.c121
-rw-r--r--drivers/media/video/pwc/Kconfig28
-rw-r--r--drivers/media/video/saa7115.c65
-rw-r--r--drivers/media/video/saa7127.c43
-rw-r--r--drivers/media/video/saa7134/Kconfig1
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c66
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c4
-rw-r--r--drivers/media/video/saa7134/saa7134.h1
-rw-r--r--drivers/media/video/sn9c102/Kconfig11
-rw-r--r--drivers/media/video/tuner-core.c12
-rw-r--r--drivers/media/video/tvaudio.c15
-rw-r--r--drivers/media/video/tveeprom.c6
-rw-r--r--drivers/media/video/tvp5150.c140
-rw-r--r--drivers/media/video/upd64031a.c286
-rw-r--r--drivers/media/video/upd64083.c262
-rw-r--r--drivers/media/video/usbvideo/Kconfig38
-rw-r--r--drivers/media/video/usbvideo/Makefile8
-rw-r--r--drivers/media/video/v4l2-common.c8
-rw-r--r--drivers/media/video/video-buf.c14
-rw-r--r--drivers/media/video/wm8739.c355
-rw-r--r--drivers/media/video/zc0301/Kconfig11
56 files changed, 1779 insertions, 732 deletions
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index baa9f58beffc..fffc711c260c 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -51,18 +51,18 @@ config VIDEO_TVEEPROM
51 tristate 51 tristate
52 52
53config USB_DABUSB 53config USB_DABUSB
54 tristate "DABUSB driver" 54 tristate "DABUSB driver"
55 depends on USB 55 depends on USB
56 ---help--- 56 ---help---
57 A Digital Audio Broadcasting (DAB) Receiver for USB and Linux 57 A Digital Audio Broadcasting (DAB) Receiver for USB and Linux
58 brought to you by the DAB-Team 58 brought to you by the DAB-Team
59 <http://wwwbode.cs.tum.edu/Par/arch/dab/>. This driver can be taken 59 <http://wwwbode.cs.tum.edu/Par/arch/dab/>. This driver can be taken
60 as an example for URB-based bulk, control, and isochronous 60 as an example for URB-based bulk, control, and isochronous
61 transactions. URB's are explained in 61 transactions. URB's are explained in
62 <Documentation/usb/URB.txt>. 62 <Documentation/usb/URB.txt>.
63 63
64 To compile this driver as a module, choose M here: the 64 To compile this driver as a module, choose M here: the
65 module will be called dabusb. 65 module will be called dabusb.
66 66
67endmenu 67endmenu
68 68
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig
index 2337b41714e0..376ca48f1d1d 100644
--- a/drivers/media/dvb/bt8xx/Kconfig
+++ b/drivers/media/dvb/bt8xx/Kconfig
@@ -7,6 +7,7 @@ config DVB_BT8XX
7 select DVB_CX24110 7 select DVB_CX24110
8 select DVB_OR51211 8 select DVB_OR51211
9 select DVB_LGDT330X 9 select DVB_LGDT330X
10 select FW_LOADER
10 help 11 help
11 Support for PCI cards based on the Bt8xx PCI bridge. Examples are 12 Support for PCI cards based on the Bt8xx PCI bridge. Examples are
12 the Nebula cards, the Pinnacle PCTV cards, the Twinhan DST cards, 13 the Nebula cards, the Pinnacle PCTV cards, the Twinhan DST cards,
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 09e96e9ddbdf..04578df3f249 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -141,12 +141,18 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
141 } 141 }
142 142
143 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { 143 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
144 void *mem = vmalloc(DVR_BUFFER_SIZE); 144 void *mem;
145 if (!dvbdev->readers) {
146 mutex_unlock(&dmxdev->mutex);
147 return -EBUSY;
148 }
149 mem = vmalloc(DVR_BUFFER_SIZE);
145 if (!mem) { 150 if (!mem) {
146 mutex_unlock(&dmxdev->mutex); 151 mutex_unlock(&dmxdev->mutex);
147 return -ENOMEM; 152 return -ENOMEM;
148 } 153 }
149 dvb_ringbuffer_init(&dmxdev->dvr_buffer, mem, DVR_BUFFER_SIZE); 154 dvb_ringbuffer_init(&dmxdev->dvr_buffer, mem, DVR_BUFFER_SIZE);
155 dvbdev->readers--;
150 } 156 }
151 157
152 if ((file->f_flags & O_ACCMODE) == O_WRONLY) { 158 if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
@@ -184,6 +190,7 @@ static int dvb_dvr_release(struct inode *inode, struct file *file)
184 dmxdev->dvr_orig_fe); 190 dmxdev->dvr_orig_fe);
185 } 191 }
186 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { 192 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
193 dvbdev->readers++;
187 if (dmxdev->dvr_buffer.data) { 194 if (dmxdev->dvr_buffer.data) {
188 void *mem = dmxdev->dvr_buffer.data; 195 void *mem = dmxdev->dvr_buffer.data;
189 mb(); 196 mb();
@@ -1029,8 +1036,7 @@ static struct file_operations dvb_dvr_fops = {
1029 1036
1030static struct dvb_device dvbdev_dvr = { 1037static struct dvb_device dvbdev_dvr = {
1031 .priv = NULL, 1038 .priv = NULL,
1032 .users = 1, 1039 .readers = 1,
1033 .writers = 1,
1034 .fops = &dvb_dvr_fops 1040 .fops = &dvb_dvr_fops
1035}; 1041};
1036 1042
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 2c3ea8f95dcd..4f8f257e6795 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -105,6 +105,7 @@ struct dvb_frontend_private {
105 fe_status_t status; 105 fe_status_t status;
106 unsigned long tune_mode_flags; 106 unsigned long tune_mode_flags;
107 unsigned int delay; 107 unsigned int delay;
108 unsigned int reinitialise;
108 109
109 /* swzigzag values */ 110 /* swzigzag values */
110 unsigned int state; 111 unsigned int state;
@@ -121,6 +122,7 @@ struct dvb_frontend_private {
121 unsigned int check_wrapped; 122 unsigned int check_wrapped;
122}; 123};
123 124
125static void dvb_frontend_wakeup(struct dvb_frontend *fe);
124 126
125static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) 127static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
126{ 128{
@@ -213,6 +215,15 @@ static void dvb_frontend_init(struct dvb_frontend *fe)
213 fe->ops->init(fe); 215 fe->ops->init(fe);
214} 216}
215 217
218void dvb_frontend_reinitialise(struct dvb_frontend *fe)
219{
220 struct dvb_frontend_private *fepriv = fe->frontend_priv;
221
222 fepriv->reinitialise = 1;
223 dvb_frontend_wakeup(fe);
224}
225EXPORT_SYMBOL(dvb_frontend_reinitialise);
226
216static void dvb_frontend_swzigzag_update_delay(struct dvb_frontend_private *fepriv, int locked) 227static void dvb_frontend_swzigzag_update_delay(struct dvb_frontend_private *fepriv, int locked)
217{ 228{
218 int q2; 229 int q2;
@@ -505,8 +516,8 @@ static int dvb_frontend_thread(void *data)
505 fepriv->quality = 0; 516 fepriv->quality = 0;
506 fepriv->delay = 3*HZ; 517 fepriv->delay = 3*HZ;
507 fepriv->status = 0; 518 fepriv->status = 0;
508 dvb_frontend_init(fe);
509 fepriv->wakeup = 0; 519 fepriv->wakeup = 0;
520 fepriv->reinitialise = 1;
510 521
511 while (1) { 522 while (1) {
512 up(&fepriv->sem); /* is locked when we enter the thread... */ 523 up(&fepriv->sem); /* is locked when we enter the thread... */
@@ -524,6 +535,11 @@ static int dvb_frontend_thread(void *data)
524 if (down_interruptible(&fepriv->sem)) 535 if (down_interruptible(&fepriv->sem))
525 break; 536 break;
526 537
538 if (fepriv->reinitialise) {
539 dvb_frontend_init(fe);
540 fepriv->reinitialise = 0;
541 }
542
527 /* do an iteration of the tuning loop */ 543 /* do an iteration of the tuning loop */
528 if (fe->ops->tune) { 544 if (fe->ops->tune) {
529 /* have we been asked to retune? */ 545 /* have we been asked to retune? */
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h
index d5aee5ad67a0..5926a3b745c9 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.h
@@ -112,6 +112,8 @@ extern int dvb_register_frontend(struct dvb_adapter* dvb,
112 112
113extern int dvb_unregister_frontend(struct dvb_frontend* fe); 113extern int dvb_unregister_frontend(struct dvb_frontend* fe);
114 114
115extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
116
115extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec); 117extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec);
116extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime); 118extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime);
117 119
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index a14e737ec848..7edd6362b9cc 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -233,6 +233,45 @@ static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
233 { 0xfe, 0x4e, KEY_POWER }, 233 { 0xfe, 0x4e, KEY_POWER },
234}; 234};
235 235
236static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
237 { 0xfc, 0x02, KEY_SETUP }, /* Profile */
238 { 0xfc, 0x43, KEY_POWER2 },
239 { 0xfc, 0x06, KEY_EPG },
240 { 0xfc, 0x5a, KEY_BACK },
241 { 0xfc, 0x05, KEY_MENU },
242 { 0xfc, 0x47, KEY_INFO },
243 { 0xfc, 0x01, KEY_TAB },
244 { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
245 { 0xfc, 0x49, KEY_VOLUMEUP },
246 { 0xfc, 0x09, KEY_VOLUMEDOWN },
247 { 0xfc, 0x54, KEY_CHANNELUP },
248 { 0xfc, 0x0b, KEY_CHANNELDOWN },
249 { 0xfc, 0x16, KEY_CAMERA },
250 { 0xfc, 0x40, KEY_TUNER }, /* ATV/DTV */
251 { 0xfc, 0x45, KEY_OPEN },
252 { 0xfc, 0x19, KEY_1 },
253 { 0xfc, 0x18, KEY_2 },
254 { 0xfc, 0x1b, KEY_3 },
255 { 0xfc, 0x1a, KEY_4 },
256 { 0xfc, 0x58, KEY_5 },
257 { 0xfc, 0x59, KEY_6 },
258 { 0xfc, 0x15, KEY_7 },
259 { 0xfc, 0x14, KEY_8 },
260 { 0xfc, 0x17, KEY_9 },
261 { 0xfc, 0x44, KEY_ANGLE }, /* Aspect */
262 { 0xfc, 0x55, KEY_0 },
263 { 0xfc, 0x07, KEY_ZOOM },
264 { 0xfc, 0x0a, KEY_REWIND },
265 { 0xfc, 0x08, KEY_PLAYPAUSE },
266 { 0xfc, 0x4b, KEY_FASTFORWARD },
267 { 0xfc, 0x5b, KEY_MUTE },
268 { 0xfc, 0x04, KEY_STOP },
269 { 0xfc, 0x56, KEY_RECORD },
270 { 0xfc, 0x57, KEY_POWER },
271 { 0xfc, 0x41, KEY_UNKNOWN }, /* INPUT */
272 { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */
273};
274
236static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) 275static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
237{ 276{
238 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 }; 277 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
@@ -511,6 +550,11 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
511 550
512 .i2c_algo = &cxusb_i2c_algo, 551 .i2c_algo = &cxusb_i2c_algo,
513 552
553 .rc_interval = 100,
554 .rc_key_map = dvico_portable_rc_keys,
555 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
556 .rc_query = cxusb_rc_query,
557
514 .generic_bulk_ctrl_endpoint = 0x01, 558 .generic_bulk_ctrl_endpoint = 0x01,
515 /* parameter for the MPEG2-data transfer */ 559 /* parameter for the MPEG2-data transfer */
516 .urb = { 560 .urb = {
@@ -600,6 +644,11 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = {
600 644
601 .i2c_algo = &cxusb_i2c_algo, 645 .i2c_algo = &cxusb_i2c_algo,
602 646
647 .rc_interval = 100,
648 .rc_key_map = dvico_portable_rc_keys,
649 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
650 .rc_query = cxusb_rc_query,
651
603 .generic_bulk_ctrl_endpoint = 0x01, 652 .generic_bulk_ctrl_endpoint = 0x01,
604 /* parameter for the MPEG2-data transfer */ 653 /* parameter for the MPEG2-data transfer */
605 .urb = { 654 .urb = {
@@ -640,6 +689,11 @@ static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = {
640 689
641 .i2c_algo = &cxusb_i2c_algo, 690 .i2c_algo = &cxusb_i2c_algo,
642 691
692 .rc_interval = 100,
693 .rc_key_map = dvico_portable_rc_keys,
694 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
695 .rc_query = cxusb_rc_query,
696
643 .generic_bulk_ctrl_endpoint = 0x01, 697 .generic_bulk_ctrl_endpoint = 0x01,
644 /* parameter for the MPEG2-data transfer */ 698 /* parameter for the MPEG2-data transfer */
645 .urb = { 699 .urb = {
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c
index 12ebaf8bddca..70afcfd141ca 100644
--- a/drivers/media/dvb/dvb-usb/dtt200u.c
+++ b/drivers/media/dvb/dvb-usb/dtt200u.c
@@ -94,12 +94,14 @@ static int dtt200u_frontend_attach(struct dvb_usb_device *d)
94 94
95static struct dvb_usb_properties dtt200u_properties; 95static struct dvb_usb_properties dtt200u_properties;
96static struct dvb_usb_properties wt220u_properties; 96static struct dvb_usb_properties wt220u_properties;
97static struct dvb_usb_properties wt220u_zl0353_properties;
97 98
98static int dtt200u_usb_probe(struct usb_interface *intf, 99static int dtt200u_usb_probe(struct usb_interface *intf,
99 const struct usb_device_id *id) 100 const struct usb_device_id *id)
100{ 101{
101 if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 || 102 if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 ||
102 dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0) 103 dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0 ||
104 dvb_usb_device_init(intf,&wt220u_zl0353_properties,THIS_MODULE,NULL) == 0)
103 return 0; 105 return 0;
104 106
105 return -ENODEV; 107 return -ENODEV;
@@ -110,6 +112,8 @@ static struct usb_device_id dtt200u_usb_table [] = {
110 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) }, 112 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) },
111 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) }, 113 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) },
112 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) }, 114 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) },
115 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZL0353_COLD) },
116 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZL0353_WARM) },
113 { 0 }, 117 { 0 },
114}; 118};
115MODULE_DEVICE_TABLE(usb, dtt200u_usb_table); 119MODULE_DEVICE_TABLE(usb, dtt200u_usb_table);
@@ -196,6 +200,47 @@ static struct dvb_usb_properties wt220u_properties = {
196 } 200 }
197}; 201};
198 202
203static struct dvb_usb_properties wt220u_zl0353_properties = {
204 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
205 .pid_filter_count = 15,
206
207 .usb_ctrl = CYPRESS_FX2,
208 .firmware = "dvb-usb-wt220u-zl0353-01.fw",
209
210 .power_ctrl = dtt200u_power_ctrl,
211 .streaming_ctrl = dtt200u_streaming_ctrl,
212 .pid_filter = dtt200u_pid_filter,
213 .frontend_attach = dtt200u_frontend_attach,
214
215 .rc_interval = 300,
216 .rc_key_map = dtt200u_rc_keys,
217 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
218 .rc_query = dtt200u_rc_query,
219
220 .generic_bulk_ctrl_endpoint = 0x01,
221
222 /* parameter for the MPEG2-data transfer */
223 .urb = {
224 .type = DVB_USB_BULK,
225 .count = 7,
226 .endpoint = 0x02,
227 .u = {
228 .bulk = {
229 .buffersize = 4096,
230 }
231 }
232 },
233
234 .num_device_descs = 1,
235 .devices = {
236 { .name = "WideView WT-220U PenType Receiver (based on ZL353)",
237 .cold_ids = { &dtt200u_usb_table[4], NULL },
238 .warm_ids = { &dtt200u_usb_table[5], NULL },
239 },
240 { NULL },
241 }
242};
243
199/* usb specific object needed to register this driver with the usb subsystem */ 244/* usb specific object needed to register this driver with the usb subsystem */
200static struct usb_driver dtt200u_usb_driver = { 245static struct usb_driver dtt200u_usb_driver = {
201 .name = "dvb_usb_dtt200u", 246 .name = "dvb_usb_dtt200u",
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index 4a1b9e77e339..cb239049b098 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -83,6 +83,8 @@
83#define USB_PID_DTT200U_WARM 0x0301 83#define USB_PID_DTT200U_WARM 0x0301
84#define USB_PID_WT220U_COLD 0x0222 84#define USB_PID_WT220U_COLD 0x0222
85#define USB_PID_WT220U_WARM 0x0221 85#define USB_PID_WT220U_WARM 0x0221
86#define USB_PID_WT220U_ZL0353_COLD 0x022a
87#define USB_PID_WT220U_ZL0353_WARM 0x022b
86#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300 88#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300
87#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301 89#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301
88#define USB_PID_NEBULA_DIGITV 0x0201 90#define USB_PID_NEBULA_DIGITV 0x0201
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c
index b6d95e1c9c52..2a89f8c5da99 100644
--- a/drivers/media/dvb/dvb-usb/vp702x-fe.c
+++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c
@@ -147,8 +147,9 @@ static int vp702x_fe_set_frontend(struct dvb_frontend* fe,
147 cmd[4] = (sr >> 4) & 0xff; 147 cmd[4] = (sr >> 4) & 0xff;
148 cmd[5] = (sr << 4) & 0xf0; 148 cmd[5] = (sr << 4) & 0xf0;
149 149
150 deb_fe("setting frontend to: %u -> %u (%x) LNB-based GHz, symbolrate: %d -> %Lu (%Lx)\n", 150 deb_fe("setting frontend to: %u -> %u (%x) LNB-based GHz, symbolrate: %d -> %lu (%lx)\n",
151 fep->frequency,freq,freq, fep->u.qpsk.symbol_rate, sr, sr); 151 fep->frequency,freq,freq, fep->u.qpsk.symbol_rate,
152 (unsigned long) sr, (unsigned long) sr);
152 153
153/* if (fep->inversion == INVERSION_ON) 154/* if (fep->inversion == INVERSION_ON)
154 cmd[6] |= 0x80; */ 155 cmd[6] |= 0x80; */
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index 94233168d241..37d5e0af1683 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -181,6 +181,11 @@ config DVB_OR51211
181 help 181 help
182 An ATSC 8VSB tuner module. Say Y when you want to support this frontend. 182 An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
183 183
184 This driver needs external firmware. Please use the command
185 "<kerneldir>/Documentation/dvb/get_dvb_firmware or51211" to
186 download it, and then copy it to /usr/lib/hotplug/firmware
187 or /lib/firmware (depending on configuration of firmware hotplug).
188
184config DVB_OR51132 189config DVB_OR51132
185 tristate "Oren OR51132 based" 190 tristate "Oren OR51132 based"
186 depends on DVB_CORE 191 depends on DVB_CORE
@@ -189,6 +194,13 @@ config DVB_OR51132
189 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want 194 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
190 to support this frontend. 195 to support this frontend.
191 196
197 This driver needs external firmware. Please use the commands
198 "<kerneldir>/Documentation/dvb/get_dvb_firmware or51132_vsb" and/or
199 "<kerneldir>/Documentation/dvb/get_dvb_firmware or51132_qam" to
200 download firmwares for 8VSB and QAM64/256, respectively. Copy them to
201 /usr/lib/hotplug/firmware or /lib/firmware (depending on
202 configuration of firmware hotplug).
203
192config DVB_BCM3510 204config DVB_BCM3510
193 tristate "Broadcom BCM3510" 205 tristate "Broadcom BCM3510"
194 depends on DVB_CORE 206 depends on DVB_CORE
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
index 8e8df7b4ca0e..b83dafa4e12c 100644
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ b/drivers/media/dvb/frontends/tda1004x.c
@@ -52,7 +52,6 @@ struct tda1004x_state {
52 struct dvb_frontend frontend; 52 struct dvb_frontend frontend;
53 53
54 /* private demod data */ 54 /* private demod data */
55 u8 initialised;
56 enum tda1004x_demod demod_type; 55 enum tda1004x_demod demod_type;
57}; 56};
58 57
@@ -594,9 +593,6 @@ static int tda10045_init(struct dvb_frontend* fe)
594 593
595 dprintk("%s\n", __FUNCTION__); 594 dprintk("%s\n", __FUNCTION__);
596 595
597 if (state->initialised)
598 return 0;
599
600 if (tda10045_fwupload(fe)) { 596 if (tda10045_fwupload(fe)) {
601 printk("tda1004x: firmware upload failed\n"); 597 printk("tda1004x: firmware upload failed\n");
602 return -EIO; 598 return -EIO;
@@ -626,7 +622,6 @@ static int tda10045_init(struct dvb_frontend* fe)
626 622
627 tda1004x_write_mask(state, 0x1f, 0x01, state->config->invert_oclk); 623 tda1004x_write_mask(state, 0x1f, 0x01, state->config->invert_oclk);
628 624
629 state->initialised = 1;
630 return 0; 625 return 0;
631} 626}
632 627
@@ -635,9 +630,6 @@ static int tda10046_init(struct dvb_frontend* fe)
635 struct tda1004x_state* state = fe->demodulator_priv; 630 struct tda1004x_state* state = fe->demodulator_priv;
636 dprintk("%s\n", __FUNCTION__); 631 dprintk("%s\n", __FUNCTION__);
637 632
638 if (state->initialised)
639 return 0;
640
641 if (tda10046_fwupload(fe)) { 633 if (tda10046_fwupload(fe)) {
642 printk("tda1004x: firmware upload failed\n"); 634 printk("tda1004x: firmware upload failed\n");
643 return -EIO; 635 return -EIO;
@@ -697,7 +689,6 @@ static int tda10046_init(struct dvb_frontend* fe)
697 // tda1004x_write_mask(state, 0x50, 0x80, 0x80); // handle out of guard echoes 689 // tda1004x_write_mask(state, 0x50, 0x80, 0x80); // handle out of guard echoes
698 tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7); 690 tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7);
699 691
700 state->initialised = 1;
701 return 0; 692 return 0;
702} 693}
703 694
@@ -1207,7 +1198,6 @@ static int tda1004x_sleep(struct dvb_frontend* fe)
1207 tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1); 1198 tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1);
1208 break; 1199 break;
1209 } 1200 }
1210 state->initialised = 0;
1211 1201
1212 return 0; 1202 return 0;
1213} 1203}
@@ -1271,7 +1261,6 @@ struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
1271 state->config = config; 1261 state->config = config;
1272 state->i2c = i2c; 1262 state->i2c = i2c;
1273 memcpy(&state->ops, &tda10045_ops, sizeof(struct dvb_frontend_ops)); 1263 memcpy(&state->ops, &tda10045_ops, sizeof(struct dvb_frontend_ops));
1274 state->initialised = 0;
1275 state->demod_type = TDA1004X_DEMOD_TDA10045; 1264 state->demod_type = TDA1004X_DEMOD_TDA10045;
1276 1265
1277 /* check if the demod is there */ 1266 /* check if the demod is there */
@@ -1330,7 +1319,6 @@ struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
1330 state->config = config; 1319 state->config = config;
1331 state->i2c = i2c; 1320 state->i2c = i2c;
1332 memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops)); 1321 memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
1333 state->initialised = 0;
1334 state->demod_type = TDA1004X_DEMOD_TDA10046; 1322 state->demod_type = TDA1004X_DEMOD_TDA10046;
1335 1323
1336 /* check if the demod is there */ 1324 /* check if the demod is there */
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 840efec32cb6..d028245c8eed 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -87,6 +87,7 @@ static int volume = 255;
87static int budgetpatch; 87static int budgetpatch;
88static int wss_cfg_4_3 = 0x4008; 88static int wss_cfg_4_3 = 0x4008;
89static int wss_cfg_16_9 = 0x0007; 89static int wss_cfg_16_9 = 0x0007;
90static int tv_standard;
90 91
91module_param_named(debug, av7110_debug, int, 0644); 92module_param_named(debug, av7110_debug, int, 0644);
92MODULE_PARM_DESC(debug, "debug level (bitmask, default 0)"); 93MODULE_PARM_DESC(debug, "debug level (bitmask, default 0)");
@@ -109,6 +110,8 @@ module_param(wss_cfg_4_3, int, 0444);
109MODULE_PARM_DESC(wss_cfg_4_3, "WSS 4:3 - default 0x4008 - bit 15: disable, 14: burst mode, 13..0: wss data"); 110MODULE_PARM_DESC(wss_cfg_4_3, "WSS 4:3 - default 0x4008 - bit 15: disable, 14: burst mode, 13..0: wss data");
110module_param(wss_cfg_16_9, int, 0444); 111module_param(wss_cfg_16_9, int, 0444);
111MODULE_PARM_DESC(wss_cfg_16_9, "WSS 16:9 - default 0x0007 - bit 15: disable, 14: burst mode, 13..0: wss data"); 112MODULE_PARM_DESC(wss_cfg_16_9, "WSS 16:9 - default 0x0007 - bit 15: disable, 14: burst mode, 13..0: wss data");
113module_param(tv_standard, int, 0444);
114MODULE_PARM_DESC(tv_standard, "TV standard: 0 PAL (default), 1 NTSC");
112 115
113static void restart_feeds(struct av7110 *av7110); 116static void restart_feeds(struct av7110 *av7110);
114 117
@@ -2123,7 +2126,7 @@ static int frontend_init(struct av7110 *av7110)
2123 read_pwm(av7110)); 2126 read_pwm(av7110));
2124 break; 2127 break;
2125 case 0x0003: 2128 case 0x0003:
2126 /* Haupauge DVB-C 2.1 VES1820/ALPS TDBE2 */ 2129 /* Hauppauge DVB-C 2.1 VES1820/ALPS TDBE2 */
2127 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, 2130 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap,
2128 read_pwm(av7110)); 2131 read_pwm(av7110));
2129 break; 2132 break;
@@ -2543,6 +2546,9 @@ static int __devinit av7110_attach(struct saa7146_dev* dev,
2543 av7110->osdwin = 1; 2546 av7110->osdwin = 1;
2544 mutex_init(&av7110->osd_mutex); 2547 mutex_init(&av7110->osd_mutex);
2545 2548
2549 /* TV standard */
2550 av7110->vidmode = tv_standard == 1 ? VIDEO_MODE_NTSC : VIDEO_MODE_PAL;
2551
2546 /* ARM "watchdog" */ 2552 /* ARM "watchdog" */
2547 init_waitqueue_head(&av7110->arm_wait); 2553 init_waitqueue_head(&av7110->arm_wait);
2548 av7110->arm_thread = NULL; 2554 av7110->arm_thread = NULL;
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 400facec7407..2eff09f638d3 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -1479,8 +1479,6 @@ int av7110_av_init(struct av7110 *av7110)
1479 void (*play[])(u8 *, int, void *) = { play_audio_cb, play_video_cb }; 1479 void (*play[])(u8 *, int, void *) = { play_audio_cb, play_video_cb };
1480 int i, ret; 1480 int i, ret;
1481 1481
1482 av7110->vidmode = VIDEO_MODE_PAL;
1483
1484 for (i = 0; i < 2; i++) { 1482 for (i = 0; i < 2; i++) {
1485 struct ipack *ipack = av7110->ipack + i; 1483 struct ipack *ipack = av7110->ipack + i;
1486 1484
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 9dd4745f5312..8efe3ce5f66c 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -60,11 +60,11 @@ struct budget_av {
60 struct dvb_ca_en50221 ca; 60 struct dvb_ca_en50221 ca;
61}; 61};
62 62
63/* GPIO CI Connections: 63/* GPIO Connections:
64 * 0 - Vcc/Reset (Reset is controlled by capacitor) 64 * 0 - Vcc/Reset (Reset is controlled by capacitor). Resets the frontend *AS WELL*!
65 * 1 - Attribute Memory 65 * 1 - CI memory select 0=>IO memory, 1=>Attribute Memory
66 * 2 - Card Enable (Active Low) 66 * 2 - CI Card Enable (Active Low)
67 * 3 - Card Detect 67 * 3 - CI Card Detect
68 */ 68 */
69 69
70/**************************************************************************** 70/****************************************************************************
@@ -214,6 +214,9 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
214 while (--timeout > 0 && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d) 214 while (--timeout > 0 && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d)
215 msleep(100); 215 msleep(100);
216 216
217 /* reinitialise the frontend */
218 dvb_frontend_reinitialise(budget_av->budget.dvb_frontend);
219
217 if (timeout <= 0) 220 if (timeout <= 0)
218 { 221 {
219 printk(KERN_ERR "budget-av: cam reset failed (timeout).\n"); 222 printk(KERN_ERR "budget-av: cam reset failed (timeout).\n");
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c
index 633e68c341c8..ea2066d461fc 100644
--- a/drivers/media/dvb/ttpci/budget-core.c
+++ b/drivers/media/dvb/ttpci/budget-core.c
@@ -39,9 +39,21 @@
39#include "budget.h" 39#include "budget.h"
40#include "ttpci-eeprom.h" 40#include "ttpci-eeprom.h"
41 41
42#define TS_WIDTH (2 * TS_SIZE)
43#define TS_WIDTH_ACTIVY TS_SIZE
44#define TS_HEIGHT_MASK 0xf00
45#define TS_HEIGHT_MASK_ACTIVY 0xc00
46#define TS_MIN_BUFSIZE_K 188
47#define TS_MAX_BUFSIZE_K 1410
48#define TS_MAX_BUFSIZE_K_ACTIVY 564
49#define BUFFER_WARNING_WAIT (30*HZ)
50
42int budget_debug; 51int budget_debug;
52static int dma_buffer_size = TS_MIN_BUFSIZE_K;
43module_param_named(debug, budget_debug, int, 0644); 53module_param_named(debug, budget_debug, int, 0644);
54module_param_named(bufsize, dma_buffer_size, int, 0444);
44MODULE_PARM_DESC(debug, "Turn on/off budget debugging (default:off)."); 55MODULE_PARM_DESC(debug, "Turn on/off budget debugging (default:off).");
56MODULE_PARM_DESC(bufsize, "DMA buffer size in KB, default: 188, min: 188, max: 1410 (Activy: 564)");
45 57
46/**************************************************************************** 58/****************************************************************************
47 * TT budget / WinTV Nova 59 * TT budget / WinTV Nova
@@ -70,11 +82,10 @@ static int start_ts_capture(struct budget *budget)
70 82
71 saa7146_write(dev, MC1, MASK_20); // DMA3 off 83 saa7146_write(dev, MC1, MASK_20); // DMA3 off
72 84
73 memset(budget->grabbing, 0x00, TS_HEIGHT * TS_WIDTH); 85 memset(budget->grabbing, 0x00, budget->buffer_size);
74 86
75 saa7146_write(dev, PCI_BT_V1, 0x001c0000 | (saa7146_read(dev, PCI_BT_V1) & ~0x001f0000)); 87 saa7146_write(dev, PCI_BT_V1, 0x001c0000 | (saa7146_read(dev, PCI_BT_V1) & ~0x001f0000));
76 88
77 budget->tsf = 0xff;
78 budget->ttbp = 0; 89 budget->ttbp = 0;
79 90
80 /* 91 /*
@@ -115,16 +126,12 @@ static int start_ts_capture(struct budget *budget)
115 126
116 saa7146_write(dev, BASE_ODD3, 0); 127 saa7146_write(dev, BASE_ODD3, 0);
117 saa7146_write(dev, BASE_EVEN3, 0); 128 saa7146_write(dev, BASE_EVEN3, 0);
118 saa7146_write(dev, PROT_ADDR3, TS_WIDTH * TS_HEIGHT); 129 saa7146_write(dev, PROT_ADDR3, budget->buffer_size);
119 saa7146_write(dev, BASE_PAGE3, budget->pt.dma | ME1 | 0x90); 130 saa7146_write(dev, BASE_PAGE3, budget->pt.dma | ME1 | 0x90);
120 131
121 if (budget->card->type == BUDGET_FS_ACTIVY) { 132 saa7146_write(dev, PITCH3, budget->buffer_width);
122 saa7146_write(dev, PITCH3, TS_WIDTH / 2); 133 saa7146_write(dev, NUM_LINE_BYTE3,
123 saa7146_write(dev, NUM_LINE_BYTE3, ((TS_HEIGHT * 2) << 16) | (TS_WIDTH / 2)); 134 (budget->buffer_height << 16) | budget->buffer_width);
124 } else {
125 saa7146_write(dev, PITCH3, TS_WIDTH);
126 saa7146_write(dev, NUM_LINE_BYTE3, (TS_HEIGHT << 16) | TS_WIDTH);
127 }
128 135
129 saa7146_write(dev, MC2, (MASK_04 | MASK_20)); 136 saa7146_write(dev, MC2, (MASK_04 | MASK_20));
130 137
@@ -141,11 +148,12 @@ static void vpeirq(unsigned long data)
141 u8 *mem = (u8 *) (budget->grabbing); 148 u8 *mem = (u8 *) (budget->grabbing);
142 u32 olddma = budget->ttbp; 149 u32 olddma = budget->ttbp;
143 u32 newdma = saa7146_read(budget->dev, PCI_VDP3); 150 u32 newdma = saa7146_read(budget->dev, PCI_VDP3);
151 u32 count;
144 152
145 /* nearest lower position divisible by 188 */ 153 /* nearest lower position divisible by 188 */
146 newdma -= newdma % 188; 154 newdma -= newdma % 188;
147 155
148 if (newdma >= TS_BUFLEN) 156 if (newdma >= budget->buffer_size)
149 return; 157 return;
150 158
151 budget->ttbp = newdma; 159 budget->ttbp = newdma;
@@ -154,11 +162,24 @@ static void vpeirq(unsigned long data)
154 return; 162 return;
155 163
156 if (newdma > olddma) { /* no wraparound, dump olddma..newdma */ 164 if (newdma > olddma) { /* no wraparound, dump olddma..newdma */
157 dvb_dmx_swfilter_packets(&budget->demux, mem + olddma, (newdma - olddma) / 188); 165 count = newdma - olddma;
166 dvb_dmx_swfilter_packets(&budget->demux, mem + olddma, count / 188);
158 } else { /* wraparound, dump olddma..buflen and 0..newdma */ 167 } else { /* wraparound, dump olddma..buflen and 0..newdma */
159 dvb_dmx_swfilter_packets(&budget->demux, mem + olddma, (TS_BUFLEN - olddma) / 188); 168 count = budget->buffer_size - olddma;
169 dvb_dmx_swfilter_packets(&budget->demux, mem + olddma, count / 188);
170 count += newdma;
160 dvb_dmx_swfilter_packets(&budget->demux, mem, newdma / 188); 171 dvb_dmx_swfilter_packets(&budget->demux, mem, newdma / 188);
161 } 172 }
173
174 if (count > budget->buffer_warning_threshold)
175 budget->buffer_warnings++;
176
177 if (budget->buffer_warnings && time_after(jiffies, budget->buffer_warning_time)) {
178 printk("%s %s: used %d times >80%% of buffer (%u bytes now)\n",
179 budget->dev->name, __FUNCTION__, budget->buffer_warnings, count);
180 budget->buffer_warning_time = jiffies + BUFFER_WARNING_WAIT;
181 budget->buffer_warnings = 0;
182 }
162} 183}
163 184
164 185
@@ -341,9 +362,10 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
341 struct saa7146_pci_extension_data *info, 362 struct saa7146_pci_extension_data *info,
342 struct module *owner) 363 struct module *owner)
343{ 364{
344 int length = TS_WIDTH * TS_HEIGHT;
345 int ret = 0; 365 int ret = 0;
346 struct budget_info *bi = info->ext_priv; 366 struct budget_info *bi = info->ext_priv;
367 int max_bufsize;
368 int height_mask;
347 369
348 memset(budget, 0, sizeof(struct budget)); 370 memset(budget, 0, sizeof(struct budget));
349 371
@@ -352,6 +374,32 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
352 budget->card = bi; 374 budget->card = bi;
353 budget->dev = (struct saa7146_dev *) dev; 375 budget->dev = (struct saa7146_dev *) dev;
354 376
377 if (budget->card->type == BUDGET_FS_ACTIVY) {
378 budget->buffer_width = TS_WIDTH_ACTIVY;
379 max_bufsize = TS_MAX_BUFSIZE_K_ACTIVY;
380 height_mask = TS_HEIGHT_MASK_ACTIVY;
381 } else {
382 budget->buffer_width = TS_WIDTH;
383 max_bufsize = TS_MAX_BUFSIZE_K;
384 height_mask = TS_HEIGHT_MASK;
385 }
386
387 if (dma_buffer_size < TS_MIN_BUFSIZE_K)
388 dma_buffer_size = TS_MIN_BUFSIZE_K;
389 else if (dma_buffer_size > max_bufsize)
390 dma_buffer_size = max_bufsize;
391
392 budget->buffer_height = dma_buffer_size * 1024 / budget->buffer_width;
393 budget->buffer_height &= height_mask;
394 budget->buffer_size = budget->buffer_height * budget->buffer_width;
395 budget->buffer_warning_threshold = budget->buffer_size * 80/100;
396 budget->buffer_warnings = 0;
397 budget->buffer_warning_time = jiffies;
398
399 dprintk(2, "%s: width = %d, height = %d\n",
400 budget->dev->name, budget->buffer_width, budget->buffer_height);
401 printk("%s: dma buffer size %u\n", budget->dev->name, budget->buffer_size);
402
355 dvb_register_adapter(&budget->dvb_adapter, budget->card->name, owner); 403 dvb_register_adapter(&budget->dvb_adapter, budget->card->name, owner);
356 404
357 /* set dd1 stream a & b */ 405 /* set dd1 stream a & b */
@@ -392,7 +440,7 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
392 ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac); 440 ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac);
393 441
394 if (NULL == 442 if (NULL ==
395 (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, length, &budget->pt))) { 443 (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, budget->buffer_size, &budget->pt))) {
396 ret = -ENOMEM; 444 ret = -ENOMEM;
397 goto err; 445 goto err;
398 } 446 }
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
index 9fc9185a8426..1b3aaac5e763 100644
--- a/drivers/media/dvb/ttpci/budget-patch.c
+++ b/drivers/media/dvb/ttpci/budget-patch.c
@@ -577,6 +577,17 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
577 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); 577 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
578 // Set RPS1 Address register to point to RPS code (r108 p42) 578 // Set RPS1 Address register to point to RPS code (r108 p42)
579 saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle); 579 saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
580
581 if (!(budget = kmalloc (sizeof(struct budget_patch), GFP_KERNEL)))
582 return -ENOMEM;
583
584 dprintk(2, "budget: %p\n", budget);
585
586 if ((err = ttpci_budget_init (budget, dev, info, THIS_MODULE))) {
587 kfree (budget);
588 return err;
589 }
590
580 // Set Source Line Counter Threshold, using BRS (rCC p43) 591 // Set Source Line Counter Threshold, using BRS (rCC p43)
581 // It generates HS event every TS_HEIGHT lines 592 // It generates HS event every TS_HEIGHT lines
582 // this is related to TS_WIDTH set in register 593 // this is related to TS_WIDTH set in register
@@ -585,24 +596,13 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
585 //,then RPS_THRESH1 596 //,then RPS_THRESH1
586 // should be set to trigger every TS_HEIGHT (512) lines. 597 // should be set to trigger every TS_HEIGHT (512) lines.
587 // 598 //
588 saa7146_write(dev, RPS_THRESH1, (TS_HEIGHT*1) | MASK_12 ); 599 saa7146_write(dev, RPS_THRESH1, budget->buffer_height | MASK_12 );
589 600
590 // saa7146_write(dev, RPS_THRESH0, ((TS_HEIGHT/2)<<16) |MASK_28| (TS_HEIGHT/2) |MASK_12 ); 601 // saa7146_write(dev, RPS_THRESH0, ((TS_HEIGHT/2)<<16) |MASK_28| (TS_HEIGHT/2) |MASK_12 );
591 // Enable RPS1 (rFC p33) 602 // Enable RPS1 (rFC p33)
592 saa7146_write(dev, MC1, (MASK_13 | MASK_29)); 603 saa7146_write(dev, MC1, (MASK_13 | MASK_29));
593 604
594 605
595 if (!(budget = kmalloc (sizeof(struct budget_patch), GFP_KERNEL)))
596 return -ENOMEM;
597
598 dprintk(2, "budget: %p\n", budget);
599
600 if ((err = ttpci_budget_init (budget, dev, info, THIS_MODULE))) {
601 kfree (budget);
602 return err;
603 }
604
605
606 dev->ext_priv = budget; 606 dev->ext_priv = budget;
607 607
608 budget->dvb_adapter.priv = budget; 608 budget->dvb_adapter.priv = budget;
diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h
index 4ac0f4d08025..ecea3a13030e 100644
--- a/drivers/media/dvb/ttpci/budget.h
+++ b/drivers/media/dvb/ttpci/budget.h
@@ -58,7 +58,13 @@ struct budget {
58 int ci_present; 58 int ci_present;
59 int video_port; 59 int video_port;
60 60
61 u8 tsf; 61 u32 buffer_width;
62 u32 buffer_height;
63 u32 buffer_size;
64 u32 buffer_warning_threshold;
65 u32 buffer_warnings;
66 unsigned long buffer_warning_time;
67
62 u32 ttbp; 68 u32 ttbp;
63 int feeding; 69 int feeding;
64 70
@@ -79,11 +85,6 @@ static struct saa7146_pci_extension_data x_var = { \
79 .ext_priv = &x_var ## _info, \ 85 .ext_priv = &x_var ## _info, \
80 .ext = &budget_extension }; 86 .ext = &budget_extension };
81 87
82#define TS_WIDTH (376)
83#define TS_HEIGHT (512)
84#define TS_BUFLEN (TS_WIDTH*TS_HEIGHT)
85#define TS_MAX_PACKETS (TS_BUFLEN/TS_SIZE)
86
87#define BUDGET_TT 0 88#define BUDGET_TT 0
88#define BUDGET_TT_HW_DISEQC 1 89#define BUDGET_TT_HW_DISEQC 1
89#define BUDGET_PATCH 3 90#define BUDGET_PATCH 3
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index f31a19890b15..85888a8a93c9 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -300,7 +300,7 @@ config VIDEO_OVCAMCHIP
300 camera drivers. 300 camera drivers.
301 301
302 To compile this driver as a module, choose M here: the 302 To compile this driver as a module, choose M here: the
303 module will be called ovcamchip 303 module will be called ovcamchip.
304 304
305config VIDEO_M32R_AR 305config VIDEO_M32R_AR
306 tristate "AR devices" 306 tristate "AR devices"
@@ -316,6 +316,13 @@ config VIDEO_M32R_AR_M64278
316 Say Y here to use the Renesas M64278E-800 camera module, 316 Say Y here to use the Renesas M64278E-800 camera module,
317 which supports VGA(640x480 pixcels) size of images. 317 which supports VGA(640x480 pixcels) size of images.
318 318
319#
320# Encoder / Decoder module configuration
321#
322
323menu "Encoders and Decoders"
324 depends on VIDEO_DEV
325
319config VIDEO_MSP3400 326config VIDEO_MSP3400
320 tristate "Micronas MSP34xx audio decoders" 327 tristate "Micronas MSP34xx audio decoders"
321 depends on VIDEO_DEV && I2C 328 depends on VIDEO_DEV && I2C
@@ -323,7 +330,7 @@ config VIDEO_MSP3400
323 Support for the Micronas MSP34xx series of audio decoders. 330 Support for the Micronas MSP34xx series of audio decoders.
324 331
325 To compile this driver as a module, choose M here: the 332 To compile this driver as a module, choose M here: the
326 module will be called msp3400 333 module will be called msp3400.
327 334
328config VIDEO_CS53L32A 335config VIDEO_CS53L32A
329 tristate "Cirrus Logic CS53L32A audio ADC" 336 tristate "Cirrus Logic CS53L32A audio ADC"
@@ -333,17 +340,27 @@ config VIDEO_CS53L32A
333 stereo A/D converter. 340 stereo A/D converter.
334 341
335 To compile this driver as a module, choose M here: the 342 To compile this driver as a module, choose M here: the
336 module will be called cs53l32a 343 module will be called cs53l32a.
337 344
338config VIDEO_WM8775 345config VIDEO_WM8775
339 tristate "Wolfson Microelectronics WM8775 audio ADC" 346 tristate "Wolfson Microelectronics WM8775 audio ADC with input mixer"
340 depends on VIDEO_DEV && I2C && EXPERIMENTAL 347 depends on VIDEO_DEV && I2C && EXPERIMENTAL
341 ---help--- 348 ---help---
342 Support for the Wolfson Microelectronics WM8775 349 Support for the Wolfson Microelectronics WM8775 high
343 high performance stereo A/D Converter. 350 performance stereo A/D Converter with a 4 channel input mixer.
344 351
345 To compile this driver as a module, choose M here: the 352 To compile this driver as a module, choose M here: the
346 module will be called wm8775 353 module will be called wm8775.
354
355config VIDEO_WM8739
356 tristate "Wolfson Microelectronics WM8739 stereo audio ADC"
357 depends on VIDEO_DEV && I2C && EXPERIMENTAL
358 ---help---
359 Support for the Wolfson Microelectronics WM8739
360 stereo A/D Converter.
361
362 To compile this driver as a module, choose M here: the
363 module will be called wm8739.
347 364
348source "drivers/media/video/cx25840/Kconfig" 365source "drivers/media/video/cx25840/Kconfig"
349 366
@@ -354,7 +371,7 @@ config VIDEO_SAA711X
354 Support for the Philips SAA7113/4/5 video decoders. 371 Support for the Philips SAA7113/4/5 video decoders.
355 372
356 To compile this driver as a module, choose M here: the 373 To compile this driver as a module, choose M here: the
357 module will be called saa7115 374 module will be called saa7115.
358 375
359config VIDEO_SAA7127 376config VIDEO_SAA7127
360 tristate "Philips SAA7127/9 digital video encoders" 377 tristate "Philips SAA7127/9 digital video encoders"
@@ -363,7 +380,32 @@ config VIDEO_SAA7127
363 Support for the Philips SAA7127/9 digital video encoders. 380 Support for the Philips SAA7127/9 digital video encoders.
364 381
365 To compile this driver as a module, choose M here: the 382 To compile this driver as a module, choose M here: the
366 module will be called saa7127 383 module will be called saa7127.
384
385config VIDEO_UPD64031A
386 tristate "NEC Electronics uPD64031A Ghost Reduction"
387 depends on VIDEO_DEV && I2C && EXPERIMENTAL
388 ---help---
389 Support for the NEC Electronics uPD64031A Ghost Reduction
390 video chip. It is most often found in NTSC TV cards made for
391 Japan and is used to reduce the 'ghosting' effect that can
392 be present in analog TV broadcasts.
393
394 To compile this driver as a module, choose M here: the
395 module will be called upd64031a.
396
397config VIDEO_UPD64083
398 tristate "NEC Electronics uPD64083 3-Dimensional Y/C separation"
399 depends on VIDEO_DEV && I2C && EXPERIMENTAL
400 ---help---
401 Support for the NEC Electronics uPD64083 3-Dimensional Y/C
402 separation video chip. It is used to improve the quality of
403 the colors of a composite signal.
404
405 To compile this driver as a module, choose M here: the
406 module will be called upd64083.
407
408endmenu # encoder / decoder chips
367 409
368# 410#
369# USB Multimedia device configuration 411# USB Multimedia device configuration
@@ -374,20 +416,6 @@ menu "V4L USB devices"
374 416
375source "drivers/media/video/em28xx/Kconfig" 417source "drivers/media/video/em28xx/Kconfig"
376 418
377config USB_VICAM
378 tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)"
379 depends on USB && VIDEO_DEV && EXPERIMENTAL
380 ---help---
381 Say Y here if you have 3com homeconnect camera (vicam).
382
383 This driver uses the Video For Linux API. You must say Y or M to
384 "Video For Linux" (under Multimedia Devices) to use this driver.
385 Information on this API and pointers to "v4l" programs may be found
386 at <file:Documentation/video4linux/API.html>.
387
388 To compile this driver as a module, choose M here: the
389 module will be called vicam.
390
391config USB_DSBR 419config USB_DSBR
392 tristate "D-Link USB FM radio support (EXPERIMENTAL)" 420 tristate "D-Link USB FM radio support (EXPERIMENTAL)"
393 depends on USB && VIDEO_DEV && EXPERIMENTAL 421 depends on USB && VIDEO_DEV && EXPERIMENTAL
@@ -397,79 +425,20 @@ config USB_DSBR
397 you must connect the line out connector to a sound card or a 425 you must connect the line out connector to a sound card or a
398 set of speakers. 426 set of speakers.
399 427
400 This driver uses the Video For Linux API. You must enable
401 (Y or M in config) Video For Linux (under Character Devices)
402 to use this driver. Information on this API and pointers to
403 "v4l" programs may be found at
404 <file:Documentation/video4linux/API.html>.
405
406 To compile this driver as a module, choose M here: the 428 To compile this driver as a module, choose M here: the
407 module will be called dsbr100. 429 module will be called dsbr100.
408 430
409config USB_ET61X251 431source "drivers/media/video/usbvideo/Kconfig"
410 tristate "USB ET61X[12]51 PC Camera Controller support"
411 depends on USB && VIDEO_DEV
412 ---help---
413 Say Y here if you want support for cameras based on Etoms ET61X151
414 or ET61X251 PC Camera Controllers.
415
416 See <file:Documentation/usb/et61x251.txt> for more informations.
417
418 This driver uses the Video For Linux API. You must say Y or M to
419 "Video For Linux" to use this driver.
420
421 To compile this driver as a module, choose M here: the
422 module will be called et61x251.
423 432
424config USB_IBMCAM 433source "drivers/media/video/et61x251/Kconfig"
425 tristate "USB IBM (Xirlink) C-it Camera support"
426 depends on USB && VIDEO_DEV
427 ---help---
428 Say Y here if you want to connect a IBM "C-It" camera, also known as
429 "Xirlink PC Camera" to your computer's USB port. For more
430 information, read <file:Documentation/usb/ibmcam.txt>.
431
432 This driver uses the Video For Linux API. You must enable
433 (Y or M in config) Video For Linux (under Character Devices)
434 to use this driver. Information on this API and pointers to
435 "v4l" programs may be found at
436 <file:Documentation/video4linux/API.html>.
437
438 To compile this driver as a module, choose M here: the
439 module will be called ibmcam.
440
441 This camera has several configuration options which
442 can be specified when you load the module. Read
443 <file:Documentation/usb/ibmcam.txt> to learn more.
444
445config USB_KONICAWC
446 tristate "USB Konica Webcam support"
447 depends on USB && VIDEO_DEV
448 ---help---
449 Say Y here if you want support for webcams based on a Konica
450 chipset. This is known to work with the Intel YC76 webcam.
451
452 This driver uses the Video For Linux API. You must enable
453 (Y or M in config) Video For Linux (under Character Devices)
454 to use this driver. Information on this API and pointers to
455 "v4l" programs may be found at
456 <file:Documentation/video4linux/API.html>.
457
458 To compile this driver as a module, choose M here: the
459 module will be called konicawc.
460 434
461config USB_OV511 435config USB_OV511
462 tristate "USB OV511 Camera support" 436 tristate "USB OV511 Camera support"
463 depends on USB && VIDEO_DEV 437 depends on USB && VIDEO_DEV
464 ---help--- 438 ---help---
465 Say Y here if you want to connect this type of camera to your 439 Say Y here if you want to connect this type of camera to your
466 computer's USB port. See <file:Documentation/usb/ov511.txt> for more 440 computer's USB port. See <file:Documentation/video4linux/ov511.txt>
467 information and for a list of supported cameras. 441 for more information and for a list of supported cameras.
468
469 This driver uses the Video For Linux API. You must say Y or M to
470 "Video For Linux" (under Character Devices) to use this driver.
471 Information on this API and pointers to "v4l" programs may be found
472 at <file:Documentation/video4linux/API.html>.
473 442
474 To compile this driver as a module, choose M here: the 443 To compile this driver as a module, choose M here: the
475 module will be called ov511. 444 module will be called ov511.
@@ -479,31 +448,13 @@ config USB_SE401
479 depends on USB && VIDEO_DEV 448 depends on USB && VIDEO_DEV
480 ---help--- 449 ---help---
481 Say Y here if you want to connect this type of camera to your 450 Say Y here if you want to connect this type of camera to your
482 computer's USB port. See <file:Documentation/usb/se401.txt> for more 451 computer's USB port. See <file:Documentation/video4linux/se401.txt>
483 information and for a list of supported cameras. 452 for more information and for a list of supported cameras.
484
485 This driver uses the Video For Linux API. You must say Y or M to
486 "Video For Linux" (under Multimedia Devices) to use this driver.
487 Information on this API and pointers to "v4l" programs may be found
488 at <file:Documentation/video4linux/API.html>.
489 453
490 To compile this driver as a module, choose M here: the 454 To compile this driver as a module, choose M here: the
491 module will be called se401. 455 module will be called se401.
492 456
493config USB_SN9C102 457source "drivers/media/video/sn9c102/Kconfig"
494 tristate "USB SN9C10x PC Camera Controller support"
495 depends on USB && VIDEO_DEV
496 ---help---
497 Say Y here if you want support for cameras based on SONiX SN9C101,
498 SN9C102 or SN9C103 PC Camera Controllers.
499
500 See <file:Documentation/usb/sn9c102.txt> for more informations.
501
502 This driver uses the Video For Linux API. You must say Y or M to
503 "Video For Linux" to use this driver.
504
505 To compile this driver as a module, choose M here: the
506 module will be called sn9c102.
507 458
508config USB_STV680 459config USB_STV680
509 tristate "USB STV680 (Pencam) Camera support" 460 tristate "USB STV680 (Pencam) Camera support"
@@ -511,20 +462,16 @@ config USB_STV680
511 ---help--- 462 ---help---
512 Say Y here if you want to connect this type of camera to your 463 Say Y here if you want to connect this type of camera to your
513 computer's USB port. This includes the Pencam line of cameras. 464 computer's USB port. This includes the Pencam line of cameras.
514 See <file:Documentation/usb/stv680.txt> for more information and for 465 See <file:Documentation/video4linux/stv680.txt> for more information
515 a list of supported cameras. 466 and for a list of supported cameras.
516
517 This driver uses the Video For Linux API. You must say Y or M to
518 "Video For Linux" (under Multimedia Devices) to use this driver.
519 Information on this API and pointers to "v4l" programs may be found
520 at <file:Documentation/video4linux/API.html>.
521 467
522 To compile this driver as a module, choose M here: the 468 To compile this driver as a module, choose M here: the
523 module will be called stv680. 469 module will be called stv680.
524 470
525config USB_W9968CF 471config USB_W9968CF
526 tristate "USB W996[87]CF JPEG Dual Mode Camera support" 472 tristate "USB W996[87]CF JPEG Dual Mode Camera support"
527 depends on USB && VIDEO_DEV && I2C && VIDEO_OVCAMCHIP 473 depends on USB && VIDEO_DEV && I2C
474 select VIDEO_OVCAMCHIP
528 ---help--- 475 ---help---
529 Say Y here if you want support for cameras based on OV681 or 476 Say Y here if you want support for cameras based on OV681 or
530 Winbond W9967CF/W9968CF JPEG USB Dual Mode Camera Chips. 477 Winbond W9967CF/W9968CF JPEG USB Dual Mode Camera Chips.
@@ -534,64 +481,14 @@ config USB_W9968CF
534 resolutions and framerates, but cannot be included in the official 481 resolutions and framerates, but cannot be included in the official
535 Linux kernel for performance purposes. 482 Linux kernel for performance purposes.
536 483
537 See <file:Documentation/usb/w9968cf.txt> for more informations. 484 See <file:Documentation/video4linux/w9968cf.txt> for more info.
538
539 This driver uses the Video For Linux and the I2C APIs. It needs the
540 OmniVision Camera Chip support as well. You must say Y or M to
541 "Video For Linux", "I2C Support" and "OmniVision Camera Chip
542 support" to use this driver.
543 485
544 To compile this driver as a module, choose M here: the 486 To compile this driver as a module, choose M here: the
545 module will be called w9968cf. 487 module will be called w9968cf.
546 488
547config USB_ZC0301 489source "drivers/media/video/zc0301/Kconfig"
548 tristate "USB ZC0301 Image Processor and Control Chip support"
549 depends on USB && VIDEO_DEV
550 ---help---
551 Say Y here if you want support for cameras based on the ZC0301
552 Image Processor and Control Chip.
553
554 See <file:Documentation/usb/zc0301.txt> for more informations.
555
556 This driver uses the Video For Linux API. You must say Y or M to
557 "Video For Linux" to use this driver.
558
559 To compile this driver as a module, choose M here: the
560 module will be called zc0301.
561
562config USB_PWC
563 tristate "USB Philips Cameras"
564 depends on USB && VIDEO_DEV
565 ---help---
566 Say Y or M here if you want to use one of these Philips & OEM
567 webcams:
568 * Philips PCA645, PCA646
569 * Philips PCVC675, PCVC680, PCVC690
570 * Philips PCVC720/40, PCVC730, PCVC740, PCVC750
571 * Askey VC010
572 * Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro'
573 and 'Orbit'/'Sphere'
574 * Samsung MPC-C10, MPC-C30
575 * Creative Webcam 5, Pro Ex
576 * SOTEC Afina Eye
577 * Visionite VCS-UC300, VCS-UM100
578
579 The PCA635, PCVC665 and PCVC720/20 are not supported by this driver
580 and never will be, but the 665 and 720/20 are supported by other
581 drivers.
582
583 See <file:Documentation/usb/philips.txt> for more information and
584 installation instructions.
585
586 The built-in microphone is enabled by selecting USB Audio support.
587
588 This driver uses the Video For Linux API. You must say Y or M to
589 "Video For Linux" (under Character Devices) to use this driver.
590 Information on this API and pointers to "v4l" programs may be found
591 at <file:Documentation/video4linux/API.html>.
592 490
593 To compile this driver as a module, choose M here: the 491source "drivers/media/video/pwc/Kconfig"
594 module will be called pwc.
595 492
596endmenu # V4L USB devices 493endmenu # V4L USB devices
597 494
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 1c0e72e5a593..4092a5e37ffc 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_VIDEO_EM28XX) += tvp5150.o
45obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o 45obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
46obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o 46obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
47obj-$(CONFIG_VIDEO_WM8775) += wm8775.o 47obj-$(CONFIG_VIDEO_WM8775) += wm8775.o
48obj-$(CONFIG_VIDEO_WM8739) += wm8739.o
48obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/ 49obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/
49obj-$(CONFIG_VIDEO_CPIA2) += cpia2/ 50obj-$(CONFIG_VIDEO_CPIA2) += cpia2/
50obj-$(CONFIG_VIDEO_MXB) += saa7111.o tda9840.o tea6415c.o tea6420.o mxb.o 51obj-$(CONFIG_VIDEO_MXB) += saa7111.o tda9840.o tea6415c.o tea6420.o mxb.o
@@ -64,9 +65,8 @@ obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
64obj-$(CONFIG_VIDEO_CX25840) += cx25840/ 65obj-$(CONFIG_VIDEO_CX25840) += cx25840/
65obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o 66obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o
66obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o 67obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
67 68obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
68et61x251-objs := et61x251_core.o et61x251_tas5130d1b.o 69obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
69zc0301-objs := zc0301_core.o zc0301_pas202bcb.o
70 70
71obj-$(CONFIG_USB_DABUSB) += dabusb.o 71obj-$(CONFIG_USB_DABUSB) += dabusb.o
72obj-$(CONFIG_USB_DSBR) += dsbr100.o 72obj-$(CONFIG_USB_DSBR) += dsbr100.o
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 74def9c23952..423e954948be 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -973,12 +973,12 @@ audio_mux(struct bttv *btv, int input, int mute)
973 For now this is sufficient. */ 973 For now this is sufficient. */
974 switch (input) { 974 switch (input) {
975 case TVAUDIO_INPUT_RADIO: 975 case TVAUDIO_INPUT_RADIO:
976 route.input = MSP_INPUT(MSP_IN_SCART_2, MSP_IN_TUNER_1, 976 route.input = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1,
977 MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART); 977 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
978 break; 978 break;
979 case TVAUDIO_INPUT_EXTERN: 979 case TVAUDIO_INPUT_EXTERN:
980 route.input = MSP_INPUT(MSP_IN_SCART_1, MSP_IN_TUNER_1, 980 route.input = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
981 MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART); 981 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
982 break; 982 break;
983 case TVAUDIO_INPUT_INTERN: 983 case TVAUDIO_INPUT_INTERN:
984 /* Yes, this is the same input as for RADIO. I doubt 984 /* Yes, this is the same input as for RADIO. I doubt
@@ -986,8 +986,8 @@ audio_mux(struct bttv *btv, int input, int mute)
986 input is the BTTV_BOARD_AVERMEDIA98. I wonder how 986 input is the BTTV_BOARD_AVERMEDIA98. I wonder how
987 that was tested. My guess is that the whole INTERN 987 that was tested. My guess is that the whole INTERN
988 input does not work. */ 988 input does not work. */
989 route.input = MSP_INPUT(MSP_IN_SCART_2, MSP_IN_TUNER_1, 989 route.input = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1,
990 MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART); 990 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
991 break; 991 break;
992 case TVAUDIO_INPUT_TUNER: 992 case TVAUDIO_INPUT_TUNER:
993 default: 993 default:
@@ -1023,14 +1023,11 @@ audio_input(struct bttv *btv, int input)
1023static void 1023static void
1024i2c_vidiocschan(struct bttv *btv) 1024i2c_vidiocschan(struct bttv *btv)
1025{ 1025{
1026 struct video_channel c; 1026 v4l2_std_id std = bttv_tvnorms[btv->tvnorm].v4l2_id;
1027 1027
1028 memset(&c,0,sizeof(c)); 1028 bttv_call_i2c_clients(btv, VIDIOC_S_STD, &std);
1029 c.norm = btv->tvnorm;
1030 c.channel = btv->input;
1031 bttv_call_i2c_clients(btv,VIDIOCSCHAN,&c);
1032 if (btv->c.type == BTTV_BOARD_VOODOOTV_FM) 1029 if (btv->c.type == BTTV_BOARD_VOODOOTV_FM)
1033 bttv_tda9880_setnorm(btv,c.norm); 1030 bttv_tda9880_setnorm(btv,btv->tvnorm);
1034} 1031}
1035 1032
1036static int 1033static int
@@ -1184,11 +1181,27 @@ static int get_control(struct bttv *btv, struct v4l2_control *c)
1184 break; 1181 break;
1185 if (i == BTTV_CTLS) 1182 if (i == BTTV_CTLS)
1186 return -EINVAL; 1183 return -EINVAL;
1187 if (i >= 4 && i <= 8) { 1184 if (btv->audio_hook && i >= 4 && i <= 8) {
1188 memset(&va,0,sizeof(va)); 1185 memset(&va,0,sizeof(va));
1189 bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va); 1186 btv->audio_hook(btv,&va,0);
1190 if (btv->audio_hook) 1187 switch (c->id) {
1191 btv->audio_hook(btv,&va,0); 1188 case V4L2_CID_AUDIO_MUTE:
1189 c->value = (VIDEO_AUDIO_MUTE & va.flags) ? 1 : 0;
1190 break;
1191 case V4L2_CID_AUDIO_VOLUME:
1192 c->value = va.volume;
1193 break;
1194 case V4L2_CID_AUDIO_BALANCE:
1195 c->value = va.balance;
1196 break;
1197 case V4L2_CID_AUDIO_BASS:
1198 c->value = va.bass;
1199 break;
1200 case V4L2_CID_AUDIO_TREBLE:
1201 c->value = va.treble;
1202 break;
1203 }
1204 return 0;
1192 } 1205 }
1193 switch (c->id) { 1206 switch (c->id) {
1194 case V4L2_CID_BRIGHTNESS: 1207 case V4L2_CID_BRIGHTNESS:
@@ -1205,19 +1218,11 @@ static int get_control(struct bttv *btv, struct v4l2_control *c)
1205 break; 1218 break;
1206 1219
1207 case V4L2_CID_AUDIO_MUTE: 1220 case V4L2_CID_AUDIO_MUTE:
1208 c->value = (VIDEO_AUDIO_MUTE & va.flags) ? 1 : 0;
1209 break;
1210 case V4L2_CID_AUDIO_VOLUME: 1221 case V4L2_CID_AUDIO_VOLUME:
1211 c->value = va.volume;
1212 break;
1213 case V4L2_CID_AUDIO_BALANCE: 1222 case V4L2_CID_AUDIO_BALANCE:
1214 c->value = va.balance;
1215 break;
1216 case V4L2_CID_AUDIO_BASS: 1223 case V4L2_CID_AUDIO_BASS:
1217 c->value = va.bass;
1218 break;
1219 case V4L2_CID_AUDIO_TREBLE: 1224 case V4L2_CID_AUDIO_TREBLE:
1220 c->value = va.treble; 1225 bttv_call_i2c_clients(btv,VIDIOC_G_CTRL,c);
1221 break; 1226 break;
1222 1227
1223 case V4L2_CID_PRIVATE_CHROMA_AGC: 1228 case V4L2_CID_PRIVATE_CHROMA_AGC:
@@ -1269,11 +1274,35 @@ static int set_control(struct bttv *btv, struct v4l2_control *c)
1269 break; 1274 break;
1270 if (i == BTTV_CTLS) 1275 if (i == BTTV_CTLS)
1271 return -EINVAL; 1276 return -EINVAL;
1272 if (i >= 4 && i <= 8) { 1277 if (btv->audio_hook && i >= 4 && i <= 8) {
1273 memset(&va,0,sizeof(va)); 1278 memset(&va,0,sizeof(va));
1274 bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va); 1279 btv->audio_hook(btv,&va,0);
1275 if (btv->audio_hook) 1280 switch (c->id) {
1276 btv->audio_hook(btv,&va,0); 1281 case V4L2_CID_AUDIO_MUTE:
1282 if (c->value) {
1283 va.flags |= VIDEO_AUDIO_MUTE;
1284 audio_mute(btv, 1);
1285 } else {
1286 va.flags &= ~VIDEO_AUDIO_MUTE;
1287 audio_mute(btv, 0);
1288 }
1289 break;
1290
1291 case V4L2_CID_AUDIO_VOLUME:
1292 va.volume = c->value;
1293 break;
1294 case V4L2_CID_AUDIO_BALANCE:
1295 va.balance = c->value;
1296 break;
1297 case V4L2_CID_AUDIO_BASS:
1298 va.bass = c->value;
1299 break;
1300 case V4L2_CID_AUDIO_TREBLE:
1301 va.treble = c->value;
1302 break;
1303 }
1304 btv->audio_hook(btv,&va,1);
1305 return 0;
1277 } 1306 }
1278 switch (c->id) { 1307 switch (c->id) {
1279 case V4L2_CID_BRIGHTNESS: 1308 case V4L2_CID_BRIGHTNESS:
@@ -1289,26 +1318,13 @@ static int set_control(struct bttv *btv, struct v4l2_control *c)
1289 bt848_sat(btv,c->value); 1318 bt848_sat(btv,c->value);
1290 break; 1319 break;
1291 case V4L2_CID_AUDIO_MUTE: 1320 case V4L2_CID_AUDIO_MUTE:
1292 if (c->value) { 1321 audio_mute(btv, c->value);
1293 va.flags |= VIDEO_AUDIO_MUTE; 1322 /* fall through */
1294 audio_mute(btv, 1);
1295 } else {
1296 va.flags &= ~VIDEO_AUDIO_MUTE;
1297 audio_mute(btv, 0);
1298 }
1299 break;
1300
1301 case V4L2_CID_AUDIO_VOLUME: 1323 case V4L2_CID_AUDIO_VOLUME:
1302 va.volume = c->value;
1303 break;
1304 case V4L2_CID_AUDIO_BALANCE: 1324 case V4L2_CID_AUDIO_BALANCE:
1305 va.balance = c->value;
1306 break;
1307 case V4L2_CID_AUDIO_BASS: 1325 case V4L2_CID_AUDIO_BASS:
1308 va.bass = c->value;
1309 break;
1310 case V4L2_CID_AUDIO_TREBLE: 1326 case V4L2_CID_AUDIO_TREBLE:
1311 va.treble = c->value; 1327 bttv_call_i2c_clients(btv,VIDIOC_S_CTRL,c);
1312 break; 1328 break;
1313 1329
1314 case V4L2_CID_PRIVATE_CHROMA_AGC: 1330 case V4L2_CID_PRIVATE_CHROMA_AGC:
@@ -1364,11 +1380,6 @@ static int set_control(struct bttv *btv, struct v4l2_control *c)
1364 default: 1380 default:
1365 return -EINVAL; 1381 return -EINVAL;
1366 } 1382 }
1367 if (i >= 4 && i <= 8) {
1368 bttv_call_i2c_clients(btv, VIDIOCSAUDIO, &va);
1369 if (btv->audio_hook)
1370 btv->audio_hook(btv,&va,1);
1371 }
1372 return 0; 1383 return 0;
1373} 1384}
1374 1385
@@ -1591,12 +1602,16 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1591 } 1602 }
1592 case VIDIOCSFREQ: 1603 case VIDIOCSFREQ:
1593 { 1604 {
1594 unsigned long *freq = arg; 1605 struct v4l2_frequency freq;
1606
1607 memset(&freq, 0, sizeof(freq));
1608 freq.frequency = *(unsigned long *)arg;
1595 mutex_lock(&btv->lock); 1609 mutex_lock(&btv->lock);
1596 btv->freq=*freq; 1610 freq.type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1597 bttv_call_i2c_clients(btv,VIDIOCSFREQ,freq); 1611 btv->freq = *(unsigned long *)arg;
1612 bttv_call_i2c_clients(btv,VIDIOC_S_FREQUENCY,&freq);
1598 if (btv->has_matchbox && btv->radio_user) 1613 if (btv->has_matchbox && btv->radio_user)
1599 tea5757_set_freq(btv,*freq); 1614 tea5757_set_freq(btv,*(unsigned long *)arg);
1600 mutex_unlock(&btv->lock); 1615 mutex_unlock(&btv->lock);
1601 return 0; 1616 return 0;
1602 } 1617 }
@@ -1827,33 +1842,26 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1827 return -EINVAL; 1842 return -EINVAL;
1828 mutex_lock(&btv->lock); 1843 mutex_lock(&btv->lock);
1829 memset(t,0,sizeof(*t)); 1844 memset(t,0,sizeof(*t));
1845 t->rxsubchans = V4L2_TUNER_SUB_MONO;
1846 bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t);
1830 strcpy(t->name, "Television"); 1847 strcpy(t->name, "Television");
1831 t->type = V4L2_TUNER_ANALOG_TV;
1832 t->capability = V4L2_TUNER_CAP_NORM; 1848 t->capability = V4L2_TUNER_CAP_NORM;
1833 t->rxsubchans = V4L2_TUNER_SUB_MONO; 1849 t->type = V4L2_TUNER_ANALOG_TV;
1834 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC) 1850 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC)
1835 t->signal = 0xffff; 1851 t->signal = 0xffff;
1836 { 1852
1837 struct video_tuner tuner; 1853 if (btv->audio_hook) {
1838
1839 memset(&tuner, 0, sizeof (tuner));
1840 tuner.rangehigh = 0xffffffffUL;
1841 bttv_call_i2c_clients(btv, VIDIOCGTUNER, &tuner);
1842 t->rangelow = tuner.rangelow;
1843 t->rangehigh = tuner.rangehigh;
1844 }
1845 {
1846 /* Hmmm ... */ 1854 /* Hmmm ... */
1847 struct video_audio va; 1855 struct video_audio va;
1848 memset(&va, 0, sizeof(struct video_audio)); 1856 memset(&va, 0, sizeof(struct video_audio));
1849 bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va); 1857 btv->audio_hook(btv,&va,0);
1850 if (btv->audio_hook) 1858 t->audmode = V4L2_TUNER_MODE_MONO;
1851 btv->audio_hook(btv,&va,0); 1859 t->rxsubchans = V4L2_TUNER_SUB_MONO;
1852 if(va.mode & VIDEO_SOUND_STEREO) { 1860 if(va.mode & VIDEO_SOUND_STEREO) {
1853 t->audmode = V4L2_TUNER_MODE_STEREO; 1861 t->audmode = V4L2_TUNER_MODE_STEREO;
1854 t->rxsubchans |= V4L2_TUNER_SUB_STEREO; 1862 t->rxsubchans = V4L2_TUNER_SUB_STEREO;
1855 } 1863 }
1856 if(va.mode & VIDEO_SOUND_LANG1) { 1864 if(va.mode & VIDEO_SOUND_LANG2) {
1857 t->audmode = V4L2_TUNER_MODE_LANG1; 1865 t->audmode = V4L2_TUNER_MODE_LANG1;
1858 t->rxsubchans = V4L2_TUNER_SUB_LANG1 1866 t->rxsubchans = V4L2_TUNER_SUB_LANG1
1859 | V4L2_TUNER_SUB_LANG2; 1867 | V4L2_TUNER_SUB_LANG2;
@@ -1872,10 +1880,10 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1872 if (0 != t->index) 1880 if (0 != t->index)
1873 return -EINVAL; 1881 return -EINVAL;
1874 mutex_lock(&btv->lock); 1882 mutex_lock(&btv->lock);
1875 { 1883 bttv_call_i2c_clients(btv, VIDIOC_S_TUNER, t);
1884 if (btv->audio_hook) {
1876 struct video_audio va; 1885 struct video_audio va;
1877 memset(&va, 0, sizeof(struct video_audio)); 1886 memset(&va, 0, sizeof(struct video_audio));
1878 bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va);
1879 if (t->audmode == V4L2_TUNER_MODE_MONO) 1887 if (t->audmode == V4L2_TUNER_MODE_MONO)
1880 va.mode = VIDEO_SOUND_MONO; 1888 va.mode = VIDEO_SOUND_MONO;
1881 else if (t->audmode == V4L2_TUNER_MODE_STEREO || 1889 else if (t->audmode == V4L2_TUNER_MODE_STEREO ||
@@ -1885,9 +1893,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1885 va.mode = VIDEO_SOUND_LANG1; 1893 va.mode = VIDEO_SOUND_LANG1;
1886 else if (t->audmode == V4L2_TUNER_MODE_LANG2) 1894 else if (t->audmode == V4L2_TUNER_MODE_LANG2)
1887 va.mode = VIDEO_SOUND_LANG2; 1895 va.mode = VIDEO_SOUND_LANG2;
1888 bttv_call_i2c_clients(btv, VIDIOCSAUDIO, &va); 1896 btv->audio_hook(btv,&va,1);
1889 if (btv->audio_hook)
1890 btv->audio_hook(btv,&va,1);
1891 } 1897 }
1892 mutex_unlock(&btv->lock); 1898 mutex_unlock(&btv->lock);
1893 return 0; 1899 return 0;
@@ -1912,7 +1918,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1912 return -EINVAL; 1918 return -EINVAL;
1913 mutex_lock(&btv->lock); 1919 mutex_lock(&btv->lock);
1914 btv->freq = f->frequency; 1920 btv->freq = f->frequency;
1915 bttv_call_i2c_clients(btv,VIDIOCSFREQ,&btv->freq); 1921 bttv_call_i2c_clients(btv,VIDIOC_S_FREQUENCY,f);
1916 if (btv->has_matchbox && btv->radio_user) 1922 if (btv->has_matchbox && btv->radio_user)
1917 tea5757_set_freq(btv,btv->freq); 1923 tea5757_set_freq(btv,btv->freq);
1918 mutex_unlock(&btv->lock); 1924 mutex_unlock(&btv->lock);
@@ -1920,7 +1926,9 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1920 } 1926 }
1921 case VIDIOC_LOG_STATUS: 1927 case VIDIOC_LOG_STATUS:
1922 { 1928 {
1929 printk(KERN_INFO "bttv%d: ================= START STATUS CARD #%d =================\n", btv->c.nr, btv->c.nr);
1923 bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, NULL); 1930 bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, NULL);
1931 printk(KERN_INFO "bttv%d: ================== END STATUS CARD #%d ==================\n", btv->c.nr, btv->c.nr);
1924 return 0; 1932 return 0;
1925 } 1933 }
1926 1934
@@ -2870,12 +2878,10 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2870 return 0; 2878 return 0;
2871 } 2879 }
2872 *c = bttv_ctls[i]; 2880 *c = bttv_ctls[i];
2873 if (i >= 4 && i <= 8) { 2881 if (btv->audio_hook && i >= 4 && i <= 8) {
2874 struct video_audio va; 2882 struct video_audio va;
2875 memset(&va,0,sizeof(va)); 2883 memset(&va,0,sizeof(va));
2876 bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va); 2884 btv->audio_hook(btv,&va,0);
2877 if (btv->audio_hook)
2878 btv->audio_hook(btv,&va,0);
2879 switch (bttv_ctls[i].id) { 2885 switch (bttv_ctls[i].id) {
2880 case V4L2_CID_AUDIO_VOLUME: 2886 case V4L2_CID_AUDIO_VOLUME:
2881 if (!(va.flags & VIDEO_AUDIO_VOLUME)) 2887 if (!(va.flags & VIDEO_AUDIO_VOLUME))
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c
index e20ff238e409..8c9f0f7cf467 100644
--- a/drivers/media/video/bt8xx/bttv-vbi.c
+++ b/drivers/media/video/bt8xx/bttv-vbi.c
@@ -184,7 +184,7 @@ void bttv_vbi_try_fmt(struct bttv_fh *fh, struct v4l2_format *f)
184 - tvnorm->vbistart[0]; 184 - tvnorm->vbistart[0];
185 count1 = (s64) f->fmt.vbi.start[1] + f->fmt.vbi.count[1] 185 count1 = (s64) f->fmt.vbi.start[1] + f->fmt.vbi.count[1]
186 - tvnorm->vbistart[1]; 186 - tvnorm->vbistart[1];
187 count = clamp (max (count0, count1), 1LL, (s64) VBI_MAXLINES); 187 count = clamp (max (count0, count1), (s64) 1, (s64) VBI_MAXLINES);
188 188
189 f->fmt.vbi.start[0] = tvnorm->vbistart[0]; 189 f->fmt.vbi.start[0] = tvnorm->vbistart[0];
190 f->fmt.vbi.start[1] = tvnorm->vbistart[1]; 190 f->fmt.vbi.start[1] = tvnorm->vbistart[1];
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 2227c5640c12..85d84e89d8f4 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -64,14 +64,13 @@ MODULE_LICENSE("GPL");
64MODULE_SUPPORTED_DEVICE("video"); 64MODULE_SUPPORTED_DEVICE("video");
65#endif 65#endif
66 66
67static unsigned short colorspace_conv = 0; 67static unsigned short colorspace_conv;
68module_param(colorspace_conv, ushort, 0444); 68module_param(colorspace_conv, ushort, 0444);
69MODULE_PARM_DESC(colorspace_conv, 69MODULE_PARM_DESC(colorspace_conv,
70 "\n<n> Colorspace conversion:" 70 " Colorspace conversion:"
71 "\n0 = disable" 71 "\n 0 = disable, 1 = enable"
72 "\n1 = enable" 72 "\n Default value is 0"
73 "\nDefault value is 0" 73 );
74 "\n");
75 74
76#define ABOUT "V4L-Driver for Vision CPiA based cameras" 75#define ABOUT "V4L-Driver for Vision CPiA based cameras"
77 76
@@ -4042,7 +4041,7 @@ static int __init cpia_init(void)
4042 "allowed, it is disabled by default now. Users should fix the " 4041 "allowed, it is disabled by default now. Users should fix the "
4043 "applications in case they don't work without conversion " 4042 "applications in case they don't work without conversion "
4044 "reenabled by setting the 'colorspace_conv' module " 4043 "reenabled by setting the 'colorspace_conv' module "
4045 "parameter to 1"); 4044 "parameter to 1\n");
4046 4045
4047#ifdef CONFIG_PROC_FS 4046#ifdef CONFIG_PROC_FS
4048 proc_cpia_create(); 4047 proc_cpia_create();
diff --git a/drivers/media/video/cpia2/cpia2.h b/drivers/media/video/cpia2/cpia2.h
index 8394283993f6..1764991b0ac9 100644
--- a/drivers/media/video/cpia2/cpia2.h
+++ b/drivers/media/video/cpia2/cpia2.h
@@ -456,7 +456,7 @@ int cpia2_init_camera(struct camera_data *cam);
456int cpia2_allocate_buffers(struct camera_data *cam); 456int cpia2_allocate_buffers(struct camera_data *cam);
457void cpia2_free_buffers(struct camera_data *cam); 457void cpia2_free_buffers(struct camera_data *cam);
458long cpia2_read(struct camera_data *cam, 458long cpia2_read(struct camera_data *cam,
459 char *buf, unsigned long count, int noblock); 459 char __user *buf, unsigned long count, int noblock);
460unsigned int cpia2_poll(struct camera_data *cam, 460unsigned int cpia2_poll(struct camera_data *cam,
461 struct file *filp, poll_table *wait); 461 struct file *filp, poll_table *wait);
462int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma); 462int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma);
diff --git a/drivers/media/video/cx25840/cx25840-audio.c b/drivers/media/video/cx25840/cx25840-audio.c
index a4540e858f21..9a4b813152e5 100644
--- a/drivers/media/video/cx25840/cx25840-audio.c
+++ b/drivers/media/video/cx25840/cx25840-audio.c
@@ -19,8 +19,9 @@
19#include <linux/videodev2.h> 19#include <linux/videodev2.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <media/v4l2-common.h> 21#include <media/v4l2-common.h>
22#include <media/cx25840.h>
22 23
23#include "cx25840.h" 24#include "cx25840-core.h"
24 25
25static int set_audclk_freq(struct i2c_client *client, u32 freq) 26static int set_audclk_freq(struct i2c_client *client, u32 freq)
26{ 27{
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index a65b3cc4bf03..a961bb2ab0fd 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -32,8 +32,9 @@
32#include <linux/videodev2.h> 32#include <linux/videodev2.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
35#include <media/cx25840.h>
35 36
36#include "cx25840.h" 37#include "cx25840-core.h"
37 38
38MODULE_DESCRIPTION("Conexant CX25840 audio/video decoder driver"); 39MODULE_DESCRIPTION("Conexant CX25840 audio/video decoder driver");
39MODULE_AUTHOR("Ulf Eklund, Chris Kennedy, Hans Verkuil, Tyler Trafford"); 40MODULE_AUTHOR("Ulf Eklund, Chris Kennedy, Hans Verkuil, Tyler Trafford");
@@ -668,6 +669,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
668{ 669{
669 struct cx25840_state *state = i2c_get_clientdata(client); 670 struct cx25840_state *state = i2c_get_clientdata(client);
670 struct v4l2_tuner *vt = arg; 671 struct v4l2_tuner *vt = arg;
672 struct v4l2_routing *route = arg;
671 673
672 switch (cmd) { 674 switch (cmd) {
673#ifdef CONFIG_VIDEO_ADV_DEBUG 675#ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -749,19 +751,21 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
749 state->radio = 1; 751 state->radio = 1;
750 break; 752 break;
751 753
752 case VIDIOC_G_INPUT: 754 case VIDIOC_INT_G_VIDEO_ROUTING:
753 *(int *)arg = state->vid_input; 755 route->input = state->vid_input;
756 route->output = 0;
754 break; 757 break;
755 758
756 case VIDIOC_S_INPUT: 759 case VIDIOC_INT_S_VIDEO_ROUTING:
757 return set_input(client, *(enum cx25840_video_input *)arg, state->aud_input); 760 return set_input(client, route->input, state->aud_input);
758 761
759 case VIDIOC_S_AUDIO: 762 case VIDIOC_INT_G_AUDIO_ROUTING:
760 { 763 route->input = state->aud_input;
761 struct v4l2_audio *input = arg; 764 route->output = 0;
765 break;
762 766
763 return set_input(client, state->vid_input, input->index); 767 case VIDIOC_INT_S_AUDIO_ROUTING:
764 } 768 return set_input(client, state->vid_input, route->input);
765 769
766 case VIDIOC_S_FREQUENCY: 770 case VIDIOC_S_FREQUENCY:
767 input_change(client); 771 input_change(client);
diff --git a/drivers/media/video/cx25840/cx25840.h b/drivers/media/video/cx25840/cx25840-core.h
index dd70664d1dd9..1736929fc204 100644
--- a/drivers/media/video/cx25840/cx25840.h
+++ b/drivers/media/video/cx25840/cx25840-core.h
@@ -1,4 +1,4 @@
1/* cx25840 API header 1/* cx25840 internal API header
2 * 2 *
3 * Copyright (C) 2003-2004 Chris Kennedy 3 * Copyright (C) 2003-2004 Chris Kennedy
4 * 4 *
@@ -17,8 +17,8 @@
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20#ifndef _CX25840_H_ 20#ifndef _CX25840_CORE_H_
21#define _CX25840_H_ 21#define _CX25840_CORE_H_
22 22
23 23
24#include <linux/videodev2.h> 24#include <linux/videodev2.h>
@@ -32,46 +32,6 @@
32 providing this information. */ 32 providing this information. */
33#define CX25840_CID_ENABLE_PVR150_WORKAROUND (V4L2_CID_PRIVATE_BASE+0) 33#define CX25840_CID_ENABLE_PVR150_WORKAROUND (V4L2_CID_PRIVATE_BASE+0)
34 34
35enum cx25840_video_input {
36 /* Composite video inputs In1-In8 */
37 CX25840_COMPOSITE1 = 1,
38 CX25840_COMPOSITE2,
39 CX25840_COMPOSITE3,
40 CX25840_COMPOSITE4,
41 CX25840_COMPOSITE5,
42 CX25840_COMPOSITE6,
43 CX25840_COMPOSITE7,
44 CX25840_COMPOSITE8,
45
46 /* S-Video inputs consist of one luma input (In1-In4) ORed with one
47 chroma input (In5-In8) */
48 CX25840_SVIDEO_LUMA1 = 0x10,
49 CX25840_SVIDEO_LUMA2 = 0x20,
50 CX25840_SVIDEO_LUMA3 = 0x30,
51 CX25840_SVIDEO_LUMA4 = 0x40,
52 CX25840_SVIDEO_CHROMA4 = 0x400,
53 CX25840_SVIDEO_CHROMA5 = 0x500,
54 CX25840_SVIDEO_CHROMA6 = 0x600,
55 CX25840_SVIDEO_CHROMA7 = 0x700,
56 CX25840_SVIDEO_CHROMA8 = 0x800,
57
58 /* S-Video aliases for common luma/chroma combinations */
59 CX25840_SVIDEO1 = 0x510,
60 CX25840_SVIDEO2 = 0x620,
61 CX25840_SVIDEO3 = 0x730,
62 CX25840_SVIDEO4 = 0x840,
63};
64
65enum cx25840_audio_input {
66 /* Audio inputs: serial or In4-In8 */
67 CX25840_AUDIO_SERIAL,
68 CX25840_AUDIO4 = 4,
69 CX25840_AUDIO5,
70 CX25840_AUDIO6,
71 CX25840_AUDIO7,
72 CX25840_AUDIO8,
73};
74
75struct cx25840_state { 35struct cx25840_state {
76 int pvr150_workaround; 36 int pvr150_workaround;
77 int radio; 37 int radio;
diff --git a/drivers/media/video/cx25840/cx25840-firmware.c b/drivers/media/video/cx25840/cx25840-firmware.c
index e1a7823d82cd..f59ced181c55 100644
--- a/drivers/media/video/cx25840/cx25840-firmware.c
+++ b/drivers/media/video/cx25840/cx25840-firmware.c
@@ -20,11 +20,22 @@
20#include <linux/i2c-algo-bit.h> 20#include <linux/i2c-algo-bit.h>
21#include <linux/firmware.h> 21#include <linux/firmware.h>
22#include <media/v4l2-common.h> 22#include <media/v4l2-common.h>
23#include <media/cx25840.h>
23 24
24#include "cx25840.h" 25#include "cx25840-core.h"
25 26
26#define FWFILE "v4l-cx25840.fw" 27#define FWFILE "v4l-cx25840.fw"
27#define FWSEND 1024 28
29/*
30 * Mike Isely <isely@pobox.com> - The FWSEND parameter controls the
31 * size of the firmware chunks sent down the I2C bus to the chip.
32 * Previously this had been set to 1024 but unfortunately some I2C
33 * implementations can't transfer data in such big gulps.
34 * Specifically, the pvrusb2 driver has a hard limit of around 60
35 * bytes, due to the encapsulation there of I2C traffic into USB
36 * messages. So we have to significantly reduce this parameter.
37 */
38#define FWSEND 48
28 39
29#define FWDEV(x) &((x)->adapter->dev) 40#define FWDEV(x) &((x)->adapter->dev)
30 41
diff --git a/drivers/media/video/cx25840/cx25840-vbi.c b/drivers/media/video/cx25840/cx25840-vbi.c
index e96fd1f1d6dc..57feca288d2b 100644
--- a/drivers/media/video/cx25840/cx25840-vbi.c
+++ b/drivers/media/video/cx25840/cx25840-vbi.c
@@ -19,8 +19,9 @@
19#include <linux/videodev2.h> 19#include <linux/videodev2.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <media/v4l2-common.h> 21#include <media/v4l2-common.h>
22#include <media/cx25840.h>
22 23
23#include "cx25840.h" 24#include "cx25840-core.h"
24 25
25static int odd_parity(u8 c) 26static int odd_parity(u8 c)
26{ 27{
@@ -151,7 +152,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
151 case VIDIOC_G_FMT: 152 case VIDIOC_G_FMT:
152 { 153 {
153 static u16 lcr2vbi[] = { 154 static u16 lcr2vbi[] = {
154 0, V4L2_SLICED_TELETEXT_PAL_B, 0, /* 1 */ 155 0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */
155 0, V4L2_SLICED_WSS_625, 0, /* 4 */ 156 0, V4L2_SLICED_WSS_625, 0, /* 4 */
156 V4L2_SLICED_CAPTION_525, /* 6 */ 157 V4L2_SLICED_CAPTION_525, /* 6 */
157 0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */ 158 0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */
@@ -231,7 +232,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
231 for (i = 7; i <= 23; i++) { 232 for (i = 7; i <= 23; i++) {
232 for (x = 0; x <= 1; x++) { 233 for (x = 0; x <= 1; x++) {
233 switch (svbi->service_lines[1-x][i]) { 234 switch (svbi->service_lines[1-x][i]) {
234 case V4L2_SLICED_TELETEXT_PAL_B: 235 case V4L2_SLICED_TELETEXT_B:
235 lcr[i] |= 1 << (4 * x); 236 lcr[i] |= 1 << (4 * x);
236 break; 237 break;
237 case V4L2_SLICED_WSS_625: 238 case V4L2_SLICED_WSS_625:
@@ -282,7 +283,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
282 283
283 switch (id2) { 284 switch (id2) {
284 case 1: 285 case 1:
285 id2 = V4L2_SLICED_TELETEXT_PAL_B; 286 id2 = V4L2_SLICED_TELETEXT_B;
286 break; 287 break;
287 case 4: 288 case 4:
288 id2 = V4L2_SLICED_WSS_625; 289 id2 = V4L2_SLICED_WSS_625;
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index ff0f72340d69..630273992a41 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -1,3 +1,7 @@
1config VIDEO_CX88_VP3054
2 tristate
3 depends on VIDEO_CX88_DVB && DVB_MT352
4
1config VIDEO_CX88 5config VIDEO_CX88
2 tristate "Conexant 2388x (bt878 successor) support" 6 tristate "Conexant 2388x (bt878 successor) support"
3 depends on VIDEO_DEV && PCI && I2C 7 depends on VIDEO_DEV && PCI && I2C
@@ -25,7 +29,7 @@ config VIDEO_CX88_ALSA
25 29
26 It only works with boards with function 01 enabled. 30 It only works with boards with function 01 enabled.
27 To check if your board supports, use lspci -n. 31 To check if your board supports, use lspci -n.
28 If supported, you should see 1471:8801 or 1471:8811 32 If supported, you should see 14f1:8801 or 14f1:8811
29 PCI device. 33 PCI device.
30 34
31 To compile this driver as a module, choose M here: the 35 To compile this driver as a module, choose M here: the
@@ -73,10 +77,11 @@ config VIDEO_CX88_DVB_MT352
73 This adds DVB-T support for cards based on the 77 This adds DVB-T support for cards based on the
74 Connexant 2388x chip and the MT352 demodulator. 78 Connexant 2388x chip and the MT352 demodulator.
75 79
76config VIDEO_CX88_VP3054 80config VIDEO_CX88_DVB_VP3054
77 tristate "VP-3054 Secondary I2C Bus Support" 81 bool "VP-3054 Secondary I2C Bus Support"
78 default m 82 default y
79 depends on DVB_MT352 83 depends on VIDEO_CX88_DVB_MT352
84 select VIDEO_CX88_VP3054
80 ---help--- 85 ---help---
81 This adds DVB-T support for cards based on the 86 This adds DVB-T support for cards based on the
82 Connexant 2388x chip and the MT352 demodulator, 87 Connexant 2388x chip and the MT352 demodulator,
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index f62fd706b45a..3ba3439db580 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -151,8 +151,8 @@ struct em28xx_board em28xx_boards[] = {
151 },{ 151 },{
152 .type = EM28XX_VMUX_SVIDEO, 152 .type = EM28XX_VMUX_SVIDEO,
153 .vmux = 2, 153 .vmux = 2,
154 .amux = MSP_INPUT(MSP_IN_SCART_1, MSP_IN_TUNER_1, 154 .amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
155 MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART), 155 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
156 }}, 156 }},
157 }, 157 },
158 [EM2820_BOARD_MSI_VOX_USB_2] = { 158 [EM2820_BOARD_MSI_VOX_USB_2] = {
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index dfba33d0fa61..ddc92cbb5276 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -222,7 +222,7 @@ static void video_mux(struct em28xx *dev, int index)
222 if (dev->i2s_speed) 222 if (dev->i2s_speed)
223 em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed); 223 em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed);
224 route.input = dev->ctl_ainput; 224 route.input = dev->ctl_ainput;
225 route.output = MSP_OUTPUT(MSP_OUT_SCART1_DA); 225 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
226 /* Note: this is msp3400 specific */ 226 /* Note: this is msp3400 specific */
227 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route); 227 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route);
228 ainput = EM28XX_AUDIO_SRC_TUNER; 228 ainput = EM28XX_AUDIO_SRC_TUNER;
@@ -1141,26 +1141,16 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
1141 case VIDIOC_G_TUNER: 1141 case VIDIOC_G_TUNER:
1142 { 1142 {
1143 struct v4l2_tuner *t = arg; 1143 struct v4l2_tuner *t = arg;
1144 int status = 0;
1145 1144
1146 if (0 != t->index) 1145 if (0 != t->index)
1147 return -EINVAL; 1146 return -EINVAL;
1148 1147
1149 memset(t, 0, sizeof(*t)); 1148 memset(t, 0, sizeof(*t));
1150 strcpy(t->name, "Tuner"); 1149 strcpy(t->name, "Tuner");
1151 t->type = V4L2_TUNER_ANALOG_TV;
1152 t->capability = V4L2_TUNER_CAP_NORM;
1153 t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */
1154/* t->signal = 0xffff;*/
1155/* em28xx_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/
1156 /* No way to get signal strength? */
1157 mutex_lock(&dev->lock); 1150 mutex_lock(&dev->lock);
1158 em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, 1151 /* let clients fill in the remainder of this struct */
1159 &status); 1152 em28xx_i2c_call_clients(dev, cmd, t);
1160 mutex_unlock(&dev->lock); 1153 mutex_unlock(&dev->lock);
1161 t->signal =
1162 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
1163
1164 em28xx_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x\n", t->signal, 1154 em28xx_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x\n", t->signal,
1165 t->afc); 1155 t->afc);
1166 return 0; 1156 return 0;
@@ -1168,26 +1158,13 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
1168 case VIDIOC_S_TUNER: 1158 case VIDIOC_S_TUNER:
1169 { 1159 {
1170 struct v4l2_tuner *t = arg; 1160 struct v4l2_tuner *t = arg;
1171 int status = 0;
1172 1161
1173 if (0 != t->index) 1162 if (0 != t->index)
1174 return -EINVAL; 1163 return -EINVAL;
1175 memset(t, 0, sizeof(*t));
1176 strcpy(t->name, "Tuner");
1177 t->type = V4L2_TUNER_ANALOG_TV;
1178 t->capability = V4L2_TUNER_CAP_NORM;
1179 t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */
1180/* t->signal = 0xffff; */
1181 /* No way to get signal strength? */
1182 mutex_lock(&dev->lock); 1164 mutex_lock(&dev->lock);
1183 em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, 1165 /* let clients handle this */
1184 &status); 1166 em28xx_i2c_call_clients(dev, cmd, t);
1185 mutex_unlock(&dev->lock); 1167 mutex_unlock(&dev->lock);
1186 t->signal =
1187 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
1188
1189 em28xx_videodbg("VIDIO_S_TUNER: signal=%x, afc=%x\n",
1190 t->signal, t->afc);
1191 return 0; 1168 return 0;
1192 } 1169 }
1193 case VIDIOC_G_FREQUENCY: 1170 case VIDIOC_G_FREQUENCY:
diff --git a/drivers/media/video/et61x251/Kconfig b/drivers/media/video/et61x251/Kconfig
new file mode 100644
index 000000000000..6c43a90c6569
--- /dev/null
+++ b/drivers/media/video/et61x251/Kconfig
@@ -0,0 +1,14 @@
1config USB_ET61X251
2 tristate "USB ET61X[12]51 PC Camera Controller support"
3 depends on USB && VIDEO_DEV
4 ---help---
5 Say Y here if you want support for cameras based on Etoms ET61X151
6 or ET61X251 PC Camera Controllers.
7
8 See <file:Documentation/video4linux/et61x251.txt> for more info.
9
10 This driver uses the Video For Linux API. You must say Y or M to
11 "Video For Linux" to use this driver.
12
13 To compile this driver as a module, choose M here: the
14 module will be called et61x251.
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 95bacf435414..7e66d83fe0ce 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -411,6 +411,9 @@ static int ir_probe(struct i2c_adapter *adap)
411 case I2C_HW_B_BT848: 411 case I2C_HW_B_BT848:
412 probe = probe_bttv; 412 probe = probe_bttv;
413 break; 413 break;
414 case I2C_HW_B_CX2341X:
415 probe = probe_bttv;
416 break;
414 case I2C_HW_SAA7134: 417 case I2C_HW_SAA7134:
415 probe = probe_saa7134; 418 probe = probe_saa7134;
416 break; 419 break;
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index c40e8ba9a2ea..b806999d6e0f 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -279,20 +279,8 @@ void msp_set_scart(struct i2c_client *client, int in, int out)
279 msp_write_dsp(client, 0x13, state->acb); 279 msp_write_dsp(client, 0x13, state->acb);
280 280
281 /* Sets I2S speed 0 = 1.024 Mbps, 1 = 2.048 Mbps */ 281 /* Sets I2S speed 0 = 1.024 Mbps, 1 = 2.048 Mbps */
282 msp_write_dem(client, 0x40, state->i2s_mode); 282 if (state->has_i2s_conf)
283} 283 msp_write_dem(client, 0x40, state->i2s_mode);
284
285void msp_set_mute(struct i2c_client *client)
286{
287 struct msp_state *state = i2c_get_clientdata(client);
288
289 v4l_dbg(1, msp_debug, client, "mute audio\n");
290 msp_write_dsp(client, 0x0000, 0);
291 msp_write_dsp(client, 0x0007, 1);
292 if (state->has_scart2_out_volume)
293 msp_write_dsp(client, 0x0040, 1);
294 if (state->has_headphones)
295 msp_write_dsp(client, 0x0006, 0);
296} 284}
297 285
298void msp_set_audio(struct i2c_client *client) 286void msp_set_audio(struct i2c_client *client)
@@ -300,17 +288,19 @@ void msp_set_audio(struct i2c_client *client)
300 struct msp_state *state = i2c_get_clientdata(client); 288 struct msp_state *state = i2c_get_clientdata(client);
301 int bal = 0, bass, treble, loudness; 289 int bal = 0, bass, treble, loudness;
302 int val = 0; 290 int val = 0;
291 int reallymuted = state->muted | state->scan_in_progress;
303 292
304 if (!state->muted) 293 if (!reallymuted)
305 val = (state->volume * 0x7f / 65535) << 8; 294 val = (state->volume * 0x7f / 65535) << 8;
306 295
307 v4l_dbg(1, msp_debug, client, "mute=%s volume=%d\n", 296 v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n",
308 state->muted ? "on" : "off", state->volume); 297 state->muted ? "on" : "off", state->scan_in_progress ? "yes" : "no",
298 state->volume);
309 299
310 msp_write_dsp(client, 0x0000, val); 300 msp_write_dsp(client, 0x0000, val);
311 msp_write_dsp(client, 0x0007, state->muted ? 0x1 : (val | 0x1)); 301 msp_write_dsp(client, 0x0007, reallymuted ? 0x1 : (val | 0x1));
312 if (state->has_scart2_out_volume) 302 if (state->has_scart2_out_volume)
313 msp_write_dsp(client, 0x0040, state->muted ? 0x1 : (val | 0x1)); 303 msp_write_dsp(client, 0x0040, reallymuted ? 0x1 : (val | 0x1));
314 if (state->has_headphones) 304 if (state->has_headphones)
315 msp_write_dsp(client, 0x0006, val); 305 msp_write_dsp(client, 0x0006, val);
316 if (!state->has_sound_processing) 306 if (!state->has_sound_processing)
@@ -346,7 +336,6 @@ static void msp_wake_thread(struct i2c_client *client)
346 336
347 if (NULL == state->kthread) 337 if (NULL == state->kthread)
348 return; 338 return;
349 msp_set_mute(client);
350 state->watch_stereo = 0; 339 state->watch_stereo = 0;
351 state->restart = 1; 340 state->restart = 1;
352 wake_up_interruptible(&state->wq); 341 wake_up_interruptible(&state->wq);
@@ -374,19 +363,15 @@ int msp_sleep(struct msp_state *state, int timeout)
374 363
375/* ------------------------------------------------------------------------ */ 364/* ------------------------------------------------------------------------ */
376 365
377static int msp_mode_v4l2_to_v4l1(int rxsubchans) 366static int msp_mode_v4l2_to_v4l1(int rxsubchans, int audmode)
378{ 367{
379 int mode = 0; 368 if (rxsubchans == V4L2_TUNER_SUB_MONO)
380 369 return VIDEO_SOUND_MONO;
381 if (rxsubchans & V4L2_TUNER_SUB_STEREO) 370 if (rxsubchans == V4L2_TUNER_SUB_STEREO)
382 mode |= VIDEO_SOUND_STEREO; 371 return VIDEO_SOUND_STEREO;
383 if (rxsubchans & V4L2_TUNER_SUB_LANG2) 372 if (audmode == V4L2_TUNER_MODE_LANG2)
384 mode |= VIDEO_SOUND_LANG2 | VIDEO_SOUND_STEREO; 373 return VIDEO_SOUND_LANG2;
385 if (rxsubchans & V4L2_TUNER_SUB_LANG1) 374 return VIDEO_SOUND_LANG1;
386 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_STEREO;
387 if (mode == 0)
388 mode |= VIDEO_SOUND_MONO;
389 return mode;
390} 375}
391 376
392static int msp_mode_v4l1_to_v4l2(int mode) 377static int msp_mode_v4l1_to_v4l2(int mode)
@@ -605,7 +590,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
605 break; 590 break;
606 if (state->opmode == OPMODE_AUTOSELECT) 591 if (state->opmode == OPMODE_AUTOSELECT)
607 msp_detect_stereo(client); 592 msp_detect_stereo(client);
608 va->mode = msp_mode_v4l2_to_v4l1(state->rxsubchans); 593 va->mode = msp_mode_v4l2_to_v4l1(state->rxsubchans, state->audmode);
609 break; 594 break;
610 } 595 }
611 596
@@ -620,7 +605,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
620 state->treble = va->treble; 605 state->treble = va->treble;
621 msp_set_audio(client); 606 msp_set_audio(client);
622 607
623 if (va->mode != 0 && state->radio == 0) { 608 if (va->mode != 0 && state->radio == 0 &&
609 state->audmode != msp_mode_v4l1_to_v4l2(va->mode)) {
624 state->audmode = msp_mode_v4l1_to_v4l2(va->mode); 610 state->audmode = msp_mode_v4l1_to_v4l2(va->mode);
625 msp_set_audmode(client); 611 msp_set_audmode(client);
626 } 612 }
@@ -687,21 +673,23 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
687 int sc_in = rt->input & 0x7; 673 int sc_in = rt->input & 0x7;
688 int sc1_out = rt->output & 0xf; 674 int sc1_out = rt->output & 0xf;
689 int sc2_out = (rt->output >> 4) & 0xf; 675 int sc2_out = (rt->output >> 4) & 0xf;
690 u16 val; 676 u16 val, reg;
691 677
678 if (state->routing.input == rt->input &&
679 state->routing.output == rt->output)
680 break;
692 state->routing = *rt; 681 state->routing = *rt;
693 if (state->opmode == OPMODE_AUTOSELECT) {
694 val = msp_read_dem(client, 0x30) & ~0x100;
695 msp_write_dem(client, 0x30, val | (tuner ? 0x100 : 0));
696 } else {
697 val = msp_read_dem(client, 0xbb) & ~0x100;
698 msp_write_dem(client, 0xbb, val | (tuner ? 0x100 : 0));
699 }
700 msp_set_scart(client, sc_in, 0); 682 msp_set_scart(client, sc_in, 0);
701 msp_set_scart(client, sc1_out, 1); 683 msp_set_scart(client, sc1_out, 1);
702 msp_set_scart(client, sc2_out, 2); 684 msp_set_scart(client, sc2_out, 2);
703 msp_set_audmode(client); 685 msp_set_audmode(client);
704 msp_wake_thread(client); 686 reg = (state->opmode == OPMODE_AUTOSELECT) ? 0x30 : 0xbb;
687 val = msp_read_dem(client, reg);
688 if (tuner != ((val >> 8) & 1)) {
689 msp_write_dem(client, reg, (val & ~0x100) | (tuner << 8));
690 /* wake thread when a new tuner input is chosen */
691 msp_wake_thread(client);
692 }
705 break; 693 break;
706 } 694 }
707 695
@@ -715,7 +703,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
715 msp_detect_stereo(client); 703 msp_detect_stereo(client);
716 vt->audmode = state->audmode; 704 vt->audmode = state->audmode;
717 vt->rxsubchans = state->rxsubchans; 705 vt->rxsubchans = state->rxsubchans;
718 vt->capability = V4L2_TUNER_CAP_STEREO | 706 vt->capability |= V4L2_TUNER_CAP_STEREO |
719 V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; 707 V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
720 break; 708 break;
721 } 709 }
@@ -726,6 +714,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
726 714
727 if (state->radio) /* TODO: add mono/stereo support for radio */ 715 if (state->radio) /* TODO: add mono/stereo support for radio */
728 break; 716 break;
717 if (state->audmode == vt->audmode)
718 break;
729 state->audmode = vt->audmode; 719 state->audmode = vt->audmode;
730 /* only set audmode */ 720 /* only set audmode */
731 msp_set_audmode(client); 721 msp_set_audmode(client);
@@ -887,7 +877,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
887 877
888 memset(state, 0, sizeof(*state)); 878 memset(state, 0, sizeof(*state));
889 state->v4l2_std = V4L2_STD_NTSC; 879 state->v4l2_std = V4L2_STD_NTSC;
890 state->audmode = V4L2_TUNER_MODE_LANG1; 880 state->audmode = V4L2_TUNER_MODE_STEREO;
891 state->volume = 58880; /* 0db gain */ 881 state->volume = 58880; /* 0db gain */
892 state->balance = 32768; /* 0db gain */ 882 state->balance = 32768; /* 0db gain */
893 state->bass = 32768; 883 state->bass = 32768;
@@ -931,13 +921,16 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
931 state->has_radio = msp_revision >= 'G'; 921 state->has_radio = msp_revision >= 'G';
932 /* Has headphones output: not for stripped down products */ 922 /* Has headphones output: not for stripped down products */
933 state->has_headphones = msp_prod_lo < 5; 923 state->has_headphones = msp_prod_lo < 5;
924 /* Has scart2 input: not in stripped down products of the '3' family */
925 state->has_scart2 = msp_family >= 4 || msp_prod_lo < 7;
926 /* Has scart3 input: not in stripped down products of the '3' family */
927 state->has_scart3 = msp_family >= 4 || msp_prod_lo < 5;
934 /* Has scart4 input: not in pre D revisions, not in stripped D revs */ 928 /* Has scart4 input: not in pre D revisions, not in stripped D revs */
935 state->has_scart4 = msp_family >= 4 || (msp_revision >= 'D' && msp_prod_lo < 5); 929 state->has_scart4 = msp_family >= 4 || (msp_revision >= 'D' && msp_prod_lo < 5);
936 /* Has scart2 and scart3 inputs and scart2 output: not in stripped 930 /* Has scart2 output: not in stripped down products of the '3' family */
937 down products of the '3' family */ 931 state->has_scart2_out = msp_family >= 4 || msp_prod_lo < 5;
938 state->has_scart23_in_scart2_out = msp_family >= 4 || msp_prod_lo < 5;
939 /* Has scart2 a volume control? Not in pre-D revisions. */ 932 /* Has scart2 a volume control? Not in pre-D revisions. */
940 state->has_scart2_out_volume = msp_revision > 'C' && state->has_scart23_in_scart2_out; 933 state->has_scart2_out_volume = msp_revision > 'C' && state->has_scart2_out;
941 /* Has a configurable i2s out? */ 934 /* Has a configurable i2s out? */
942 state->has_i2s_conf = msp_revision >= 'G' && msp_prod_lo < 7; 935 state->has_i2s_conf = msp_revision >= 'G' && msp_prod_lo < 7;
943 /* Has subwoofer output: not in pre-D revs and not in stripped down products */ 936 /* Has subwoofer output: not in pre-D revs and not in stripped down products */
diff --git a/drivers/media/video/msp3400-driver.h b/drivers/media/video/msp3400-driver.h
index 1940748bb633..4e451049013d 100644
--- a/drivers/media/video/msp3400-driver.h
+++ b/drivers/media/video/msp3400-driver.h
@@ -54,8 +54,10 @@ struct msp_state {
54 u8 has_radio; 54 u8 has_radio;
55 u8 has_headphones; 55 u8 has_headphones;
56 u8 has_ntsc_jp_d_k3; 56 u8 has_ntsc_jp_d_k3;
57 u8 has_scart2;
58 u8 has_scart3;
57 u8 has_scart4; 59 u8 has_scart4;
58 u8 has_scart23_in_scart2_out; 60 u8 has_scart2_out;
59 u8 has_scart2_out_volume; 61 u8 has_scart2_out_volume;
60 u8 has_i2s_conf; 62 u8 has_i2s_conf;
61 u8 has_subwoofer; 63 u8 has_subwoofer;
@@ -83,6 +85,7 @@ struct msp_state {
83 int volume, muted; 85 int volume, muted;
84 int balance, loudness; 86 int balance, loudness;
85 int bass, treble; 87 int bass, treble;
88 int scan_in_progress;
86 89
87 /* thread */ 90 /* thread */
88 struct task_struct *kthread; 91 struct task_struct *kthread;
@@ -98,7 +101,6 @@ int msp_read_dem(struct i2c_client *client, int addr);
98int msp_read_dsp(struct i2c_client *client, int addr); 101int msp_read_dsp(struct i2c_client *client, int addr);
99int msp_reset(struct i2c_client *client); 102int msp_reset(struct i2c_client *client);
100void msp_set_scart(struct i2c_client *client, int in, int out); 103void msp_set_scart(struct i2c_client *client, int in, int out);
101void msp_set_mute(struct i2c_client *client);
102void msp_set_audio(struct i2c_client *client); 104void msp_set_audio(struct i2c_client *client);
103int msp_sleep(struct msp_state *state, int timeout); 105int msp_sleep(struct msp_state *state, int timeout);
104 106
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index c3984ea9ca07..633a10213789 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -170,7 +170,7 @@ static void msp_set_source(struct i2c_client *client, u16 src)
170 msp_write_dsp(client, 0x000a, src); 170 msp_write_dsp(client, 0x000a, src);
171 msp_write_dsp(client, 0x000b, src); 171 msp_write_dsp(client, 0x000b, src);
172 msp_write_dsp(client, 0x000c, src); 172 msp_write_dsp(client, 0x000c, src);
173 if (state->has_scart23_in_scart2_out) 173 if (state->has_scart2_out)
174 msp_write_dsp(client, 0x0041, src); 174 msp_write_dsp(client, 0x0041, src);
175} 175}
176 176
@@ -228,6 +228,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
228 char *modestr = (state->audmode >= 0 && state->audmode < 5) ? 228 char *modestr = (state->audmode >= 0 && state->audmode < 5) ?
229 strmode[state->audmode] : "unknown"; 229 strmode[state->audmode] : "unknown";
230 int src = 0; /* channel source: FM/AM, nicam or SCART */ 230 int src = 0; /* channel source: FM/AM, nicam or SCART */
231 int audmode = state->audmode;
231 232
232 if (state->opmode == OPMODE_AUTOSELECT) { 233 if (state->opmode == OPMODE_AUTOSELECT) {
233 /* this method would break everything, let's make sure 234 /* this method would break everything, let's make sure
@@ -239,11 +240,29 @@ static void msp3400c_set_audmode(struct i2c_client *client)
239 return; 240 return;
240 } 241 }
241 242
243 /* Note: for the C and D revs no NTSC stereo + SAP is possible as
244 the hardware does not support SAP. So the rxsubchans combination
245 of STEREO | LANG2 does not occur. */
246
247 /* switch to mono if only mono is available */
248 if (state->rxsubchans == V4L2_TUNER_SUB_MONO)
249 audmode = V4L2_TUNER_MODE_MONO;
250 /* if bilingual */
251 else if (state->rxsubchans & V4L2_TUNER_SUB_LANG2) {
252 /* and mono or stereo, then fallback to lang1 */
253 if (audmode == V4L2_TUNER_MODE_MONO ||
254 audmode == V4L2_TUNER_MODE_STEREO)
255 audmode = V4L2_TUNER_MODE_LANG1;
256 }
257 /* if stereo, and audmode is not mono, then switch to stereo */
258 else if (audmode != V4L2_TUNER_MODE_MONO)
259 audmode = V4L2_TUNER_MODE_STEREO;
260
242 /* switch demodulator */ 261 /* switch demodulator */
243 switch (state->mode) { 262 switch (state->mode) {
244 case MSP_MODE_FM_TERRA: 263 case MSP_MODE_FM_TERRA:
245 v4l_dbg(1, msp_debug, client, "FM set_audmode: %s\n", modestr); 264 v4l_dbg(1, msp_debug, client, "FM set_audmode: %s\n", modestr);
246 switch (state->audmode) { 265 switch (audmode) {
247 case V4L2_TUNER_MODE_STEREO: 266 case V4L2_TUNER_MODE_STEREO:
248 msp_write_dsp(client, 0x000e, 0x3001); 267 msp_write_dsp(client, 0x000e, 0x3001);
249 break; 268 break;
@@ -257,7 +276,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
257 break; 276 break;
258 case MSP_MODE_FM_SAT: 277 case MSP_MODE_FM_SAT:
259 v4l_dbg(1, msp_debug, client, "SAT set_audmode: %s\n", modestr); 278 v4l_dbg(1, msp_debug, client, "SAT set_audmode: %s\n", modestr);
260 switch (state->audmode) { 279 switch (audmode) {
261 case V4L2_TUNER_MODE_MONO: 280 case V4L2_TUNER_MODE_MONO:
262 msp3400c_set_carrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); 281 msp3400c_set_carrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
263 break; 282 break;
@@ -296,7 +315,8 @@ static void msp3400c_set_audmode(struct i2c_client *client)
296 } 315 }
297 316
298 /* switch audio */ 317 /* switch audio */
299 switch (state->audmode) { 318 v4l_dbg(1, msp_debug, client, "set audmode %d\n", audmode);
319 switch (audmode) {
300 case V4L2_TUNER_MODE_STEREO: 320 case V4L2_TUNER_MODE_STEREO:
301 case V4L2_TUNER_MODE_LANG1_LANG2: 321 case V4L2_TUNER_MODE_LANG1_LANG2:
302 src |= 0x0020; 322 src |= 0x0020;
@@ -314,10 +334,6 @@ static void msp3400c_set_audmode(struct i2c_client *client)
314 src = 0x0030; 334 src = 0x0030;
315 break; 335 break;
316 case V4L2_TUNER_MODE_LANG1: 336 case V4L2_TUNER_MODE_LANG1:
317 /* switch to stereo for stereo transmission, otherwise
318 keep first language */
319 if (state->rxsubchans & V4L2_TUNER_SUB_STEREO)
320 src |= 0x0020;
321 break; 337 break;
322 case V4L2_TUNER_MODE_LANG2: 338 case V4L2_TUNER_MODE_LANG2:
323 src |= 0x0010; 339 src |= 0x0010;
@@ -367,7 +383,7 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
367 if (val > 32767) 383 if (val > 32767)
368 val -= 65536; 384 val -= 65536;
369 v4l_dbg(2, msp_debug, client, "stereo detect register: %d\n", val); 385 v4l_dbg(2, msp_debug, client, "stereo detect register: %d\n", val);
370 if (val > 4096) { 386 if (val > 8192) {
371 rxsubchans = V4L2_TUNER_SUB_STEREO; 387 rxsubchans = V4L2_TUNER_SUB_STEREO;
372 } else if (val < -4096) { 388 } else if (val < -4096) {
373 rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; 389 rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
@@ -464,19 +480,22 @@ int msp3400c_thread(void *data)
464 if (state->radio || MSP_MODE_EXTERN == state->mode) { 480 if (state->radio || MSP_MODE_EXTERN == state->mode) {
465 /* no carrier scan, just unmute */ 481 /* no carrier scan, just unmute */
466 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n"); 482 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
483 state->scan_in_progress = 0;
467 msp_set_audio(client); 484 msp_set_audio(client);
468 continue; 485 continue;
469 } 486 }
470 487
471 /* mute */ 488 /* mute audio */
472 msp_set_mute(client); 489 state->scan_in_progress = 1;
490 msp_set_audio(client);
491
473 msp3400c_set_mode(client, MSP_MODE_AM_DETECT); 492 msp3400c_set_mode(client, MSP_MODE_AM_DETECT);
474 val1 = val2 = 0; 493 val1 = val2 = 0;
475 max1 = max2 = -1; 494 max1 = max2 = -1;
476 state->watch_stereo = 0; 495 state->watch_stereo = 0;
477 state->nicam_on = 0; 496 state->nicam_on = 0;
478 497
479 /* some time for the tuner to sync */ 498 /* wait for tuner to settle down after a channel change */
480 if (msp_sleep(state, 200)) 499 if (msp_sleep(state, 200))
481 goto restart; 500 goto restart;
482 501
@@ -552,7 +571,6 @@ int msp3400c_thread(void *data)
552 /* B/G NICAM */ 571 /* B/G NICAM */
553 state->second = msp3400c_carrier_detect_55[max2].cdo; 572 state->second = msp3400c_carrier_detect_55[max2].cdo;
554 msp3400c_set_mode(client, MSP_MODE_FM_NICAM1); 573 msp3400c_set_mode(client, MSP_MODE_FM_NICAM1);
555 msp3400c_set_carrier(client, state->second, state->main);
556 state->nicam_on = 1; 574 state->nicam_on = 1;
557 state->watch_stereo = 1; 575 state->watch_stereo = 1;
558 } else { 576 } else {
@@ -563,7 +581,6 @@ int msp3400c_thread(void *data)
563 /* PAL I NICAM */ 581 /* PAL I NICAM */
564 state->second = MSP_CARRIER(6.552); 582 state->second = MSP_CARRIER(6.552);
565 msp3400c_set_mode(client, MSP_MODE_FM_NICAM2); 583 msp3400c_set_mode(client, MSP_MODE_FM_NICAM2);
566 msp3400c_set_carrier(client, state->second, state->main);
567 state->nicam_on = 1; 584 state->nicam_on = 1;
568 state->watch_stereo = 1; 585 state->watch_stereo = 1;
569 break; 586 break;
@@ -577,13 +594,11 @@ int msp3400c_thread(void *data)
577 /* L NICAM or AM-mono */ 594 /* L NICAM or AM-mono */
578 state->second = msp3400c_carrier_detect_65[max2].cdo; 595 state->second = msp3400c_carrier_detect_65[max2].cdo;
579 msp3400c_set_mode(client, MSP_MODE_AM_NICAM); 596 msp3400c_set_mode(client, MSP_MODE_AM_NICAM);
580 msp3400c_set_carrier(client, state->second, state->main);
581 state->watch_stereo = 1; 597 state->watch_stereo = 1;
582 } else if (max2 == 0 && state->has_nicam) { 598 } else if (max2 == 0 && state->has_nicam) {
583 /* D/K NICAM */ 599 /* D/K NICAM */
584 state->second = msp3400c_carrier_detect_65[max2].cdo; 600 state->second = msp3400c_carrier_detect_65[max2].cdo;
585 msp3400c_set_mode(client, MSP_MODE_FM_NICAM1); 601 msp3400c_set_mode(client, MSP_MODE_FM_NICAM1);
586 msp3400c_set_carrier(client, state->second, state->main);
587 state->nicam_on = 1; 602 state->nicam_on = 1;
588 state->watch_stereo = 1; 603 state->watch_stereo = 1;
589 } else { 604 } else {
@@ -595,25 +610,25 @@ int msp3400c_thread(void *data)
595 no_second: 610 no_second:
596 state->second = msp3400c_carrier_detect_main[max1].cdo; 611 state->second = msp3400c_carrier_detect_main[max1].cdo;
597 msp3400c_set_mode(client, MSP_MODE_FM_TERRA); 612 msp3400c_set_mode(client, MSP_MODE_FM_TERRA);
598 msp3400c_set_carrier(client, state->second, state->main);
599 state->rxsubchans = V4L2_TUNER_SUB_MONO;
600 break; 613 break;
601 } 614 }
615 msp3400c_set_carrier(client, state->second, state->main);
602 616
603 /* unmute */ 617 /* unmute */
604 msp_set_audio(client); 618 state->scan_in_progress = 0;
605 msp3400c_set_audmode(client); 619 msp3400c_set_audmode(client);
620 msp_set_audio(client);
606 621
607 if (msp_debug) 622 if (msp_debug)
608 msp3400c_print_mode(client); 623 msp3400c_print_mode(client);
609 624
610 /* monitor tv audio mode, the first time don't wait 625 /* monitor tv audio mode, the first time don't wait
611 so long to get a quick stereo/bilingual result */ 626 so long to get a quick stereo/bilingual result */
612 if (msp_sleep(state, 1000)) 627 count = 3;
613 goto restart;
614 while (state->watch_stereo) { 628 while (state->watch_stereo) {
615 if (msp_sleep(state, 5000)) 629 if (msp_sleep(state, count ? 1000 : 5000))
616 goto restart; 630 goto restart;
631 if (count) count--;
617 watch_stereo(client); 632 watch_stereo(client);
618 } 633 }
619 } 634 }
@@ -626,7 +641,7 @@ int msp3410d_thread(void *data)
626{ 641{
627 struct i2c_client *client = data; 642 struct i2c_client *client = data;
628 struct msp_state *state = i2c_get_clientdata(client); 643 struct msp_state *state = i2c_get_clientdata(client);
629 int val, i, std; 644 int val, i, std, count;
630 645
631 v4l_dbg(1, msp_debug, client, "msp3410 daemon started\n"); 646 v4l_dbg(1, msp_debug, client, "msp3410 daemon started\n");
632 647
@@ -644,16 +659,14 @@ int msp3410d_thread(void *data)
644 if (state->mode == MSP_MODE_EXTERN) { 659 if (state->mode == MSP_MODE_EXTERN) {
645 /* no carrier scan needed, just unmute */ 660 /* no carrier scan needed, just unmute */
646 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n"); 661 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
662 state->scan_in_progress = 0;
647 msp_set_audio(client); 663 msp_set_audio(client);
648 continue; 664 continue;
649 } 665 }
650 666
651 /* put into sane state (and mute) */ 667 /* mute audio */
652 msp_reset(client); 668 state->scan_in_progress = 1;
653 669 msp_set_audio(client);
654 /* some time for the tuner to sync */
655 if (msp_sleep(state,200))
656 goto restart;
657 670
658 /* start autodetect. Note: autodetect is not supported for 671 /* start autodetect. Note: autodetect is not supported for
659 NTSC-M and radio, hence we force the standard in those cases. */ 672 NTSC-M and radio, hence we force the standard in those cases. */
@@ -664,6 +677,10 @@ int msp3410d_thread(void *data)
664 state->watch_stereo = 0; 677 state->watch_stereo = 0;
665 state->nicam_on = 0; 678 state->nicam_on = 0;
666 679
680 /* wait for tuner to settle down after a channel change */
681 if (msp_sleep(state, 200))
682 goto restart;
683
667 if (msp_debug) 684 if (msp_debug)
668 v4l_dbg(2, msp_debug, client, "setting standard: %s (0x%04x)\n", 685 v4l_dbg(2, msp_debug, client, "setting standard: %s (0x%04x)\n",
669 msp_standard_std_name(std), std); 686 msp_standard_std_name(std), std);
@@ -693,6 +710,7 @@ int msp3410d_thread(void *data)
693 state->main = msp_stdlist[i].main; 710 state->main = msp_stdlist[i].main;
694 state->second = msp_stdlist[i].second; 711 state->second = msp_stdlist[i].second;
695 state->std = val; 712 state->std = val;
713 state->rxsubchans = V4L2_TUNER_SUB_MONO;
696 714
697 if (msp_amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) && 715 if (msp_amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) &&
698 (val != 0x0009)) { 716 (val != 0x0009)) {
@@ -714,20 +732,17 @@ int msp3410d_thread(void *data)
714 else 732 else
715 state->mode = MSP_MODE_FM_NICAM1; 733 state->mode = MSP_MODE_FM_NICAM1;
716 /* just turn on stereo */ 734 /* just turn on stereo */
717 state->rxsubchans = V4L2_TUNER_SUB_STEREO;
718 state->nicam_on = 1; 735 state->nicam_on = 1;
719 state->watch_stereo = 1; 736 state->watch_stereo = 1;
720 break; 737 break;
721 case 0x0009: 738 case 0x0009:
722 state->mode = MSP_MODE_AM_NICAM; 739 state->mode = MSP_MODE_AM_NICAM;
723 state->rxsubchans = V4L2_TUNER_SUB_MONO;
724 state->nicam_on = 1; 740 state->nicam_on = 1;
725 state->watch_stereo = 1; 741 state->watch_stereo = 1;
726 break; 742 break;
727 case 0x0020: /* BTSC */ 743 case 0x0020: /* BTSC */
728 /* The pre-'G' models only have BTSC-mono */ 744 /* The pre-'G' models only have BTSC-mono */
729 state->mode = MSP_MODE_BTSC; 745 state->mode = MSP_MODE_BTSC;
730 state->rxsubchans = V4L2_TUNER_SUB_MONO;
731 break; 746 break;
732 case 0x0040: /* FM radio */ 747 case 0x0040: /* FM radio */
733 state->mode = MSP_MODE_FM_RADIO; 748 state->mode = MSP_MODE_FM_RADIO;
@@ -737,15 +752,12 @@ int msp3410d_thread(void *data)
737 msp3400c_set_mode(client, MSP_MODE_FM_RADIO); 752 msp3400c_set_mode(client, MSP_MODE_FM_RADIO);
738 msp3400c_set_carrier(client, MSP_CARRIER(10.7), 753 msp3400c_set_carrier(client, MSP_CARRIER(10.7),
739 MSP_CARRIER(10.7)); 754 MSP_CARRIER(10.7));
740 /* scart routing (this doesn't belong here I think) */
741 msp_set_scart(client,SCART_IN2,0);
742 break; 755 break;
743 case 0x0002: 756 case 0x0002:
744 case 0x0003: 757 case 0x0003:
745 case 0x0004: 758 case 0x0004:
746 case 0x0005: 759 case 0x0005:
747 state->mode = MSP_MODE_FM_TERRA; 760 state->mode = MSP_MODE_FM_TERRA;
748 state->rxsubchans = V4L2_TUNER_SUB_MONO;
749 state->watch_stereo = 1; 761 state->watch_stereo = 1;
750 break; 762 break;
751 } 763 }
@@ -759,20 +771,19 @@ int msp3410d_thread(void *data)
759 if (state->has_i2s_conf) 771 if (state->has_i2s_conf)
760 msp_write_dem(client, 0x40, state->i2s_mode); 772 msp_write_dem(client, 0x40, state->i2s_mode);
761 773
762 /* unmute, restore misc registers */ 774 /* unmute */
763 msp_set_audio(client);
764
765 msp_write_dsp(client, 0x13, state->acb);
766 msp3400c_set_audmode(client); 775 msp3400c_set_audmode(client);
776 state->scan_in_progress = 0;
777 msp_set_audio(client);
767 778
768 /* monitor tv audio mode, the first time don't wait 779 /* monitor tv audio mode, the first time don't wait
769 so long to get a quick stereo/bilingual result */ 780 so long to get a quick stereo/bilingual result */
770 if (msp_sleep(state, 1000)) 781 count = 3;
771 goto restart;
772 while (state->watch_stereo) { 782 while (state->watch_stereo) {
773 watch_stereo(client); 783 if (msp_sleep(state, count ? 1000 : 5000))
774 if (msp_sleep(state, 5000))
775 goto restart; 784 goto restart;
785 if (count) count--;
786 watch_stereo(client);
776 } 787 }
777 } 788 }
778 v4l_dbg(1, msp_debug, client, "thread: exit\n"); 789 v4l_dbg(1, msp_debug, client, "thread: exit\n");
@@ -829,27 +840,27 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
829 source = 0; /* mono only */ 840 source = 0; /* mono only */
830 matrix = 0x30; 841 matrix = 0x30;
831 break; 842 break;
832 case V4L2_TUNER_MODE_LANG1:
833 source = 3; /* stereo or A */
834 matrix = 0x00;
835 break;
836 case V4L2_TUNER_MODE_LANG2: 843 case V4L2_TUNER_MODE_LANG2:
837 source = 4; /* stereo or B */ 844 source = 4; /* stereo or B */
838 matrix = 0x10; 845 matrix = 0x10;
839 break; 846 break;
840 case V4L2_TUNER_MODE_STEREO:
841 case V4L2_TUNER_MODE_LANG1_LANG2: 847 case V4L2_TUNER_MODE_LANG1_LANG2:
842 default:
843 source = 1; /* stereo or A|B */ 848 source = 1; /* stereo or A|B */
844 matrix = 0x20; 849 matrix = 0x20;
845 break; 850 break;
851 case V4L2_TUNER_MODE_STEREO:
852 case V4L2_TUNER_MODE_LANG1:
853 default:
854 source = 3; /* stereo or A */
855 matrix = 0x00;
856 break;
846 } 857 }
847 858
848 if (in == MSP_DSP_OUT_TUNER) 859 if (in == MSP_DSP_IN_TUNER)
849 source = (source << 8) | 0x20; 860 source = (source << 8) | 0x20;
850 /* the msp34x2g puts the MAIN_AVC, MAIN and AUX sources in 12, 13, 14 861 /* the msp34x2g puts the MAIN_AVC, MAIN and AUX sources in 12, 13, 14
851 instead of 11, 12, 13. So we add one for that msp version. */ 862 instead of 11, 12, 13. So we add one for that msp version. */
852 else if (in >= MSP_DSP_OUT_MAIN_AVC && state->has_dolby_pro_logic) 863 else if (in >= MSP_DSP_IN_MAIN_AVC && state->has_dolby_pro_logic)
853 source = ((in + 1) << 8) | matrix; 864 source = ((in + 1) << 8) | matrix;
854 else 865 else
855 source = (in << 8) | matrix; 866 source = (in << 8) | matrix;
@@ -869,7 +880,7 @@ static void msp34xxg_set_sources(struct i2c_client *client)
869 msp34xxg_set_source(client, 0x000c, (in >> 4) & 0xf); 880 msp34xxg_set_source(client, 0x000c, (in >> 4) & 0xf);
870 msp34xxg_set_source(client, 0x0009, (in >> 8) & 0xf); 881 msp34xxg_set_source(client, 0x0009, (in >> 8) & 0xf);
871 msp34xxg_set_source(client, 0x000a, (in >> 12) & 0xf); 882 msp34xxg_set_source(client, 0x000a, (in >> 12) & 0xf);
872 if (state->has_scart23_in_scart2_out) 883 if (state->has_scart2_out)
873 msp34xxg_set_source(client, 0x0041, (in >> 16) & 0xf); 884 msp34xxg_set_source(client, 0x0041, (in >> 16) & 0xf);
874 msp34xxg_set_source(client, 0x000b, (in >> 20) & 0xf); 885 msp34xxg_set_source(client, 0x000b, (in >> 20) & 0xf);
875} 886}
@@ -887,10 +898,6 @@ static void msp34xxg_reset(struct i2c_client *client)
887 898
888 msp_reset(client); 899 msp_reset(client);
889 900
890 /* make sure that input/output is muted (paranoid mode) */
891 /* ACB, mute DSP input, mute SCART 1 */
892 msp_write_dsp(client, 0x13, 0x0f20);
893
894 if (state->has_i2s_conf) 901 if (state->has_i2s_conf)
895 msp_write_dem(client, 0x40, state->i2s_mode); 902 msp_write_dem(client, 0x40, state->i2s_mode);
896 903
@@ -1028,7 +1035,7 @@ static void msp34xxg_set_audmode(struct i2c_client *client)
1028 1035
1029 if (state->std == 0x20) { 1036 if (state->std == 0x20) {
1030 if ((state->rxsubchans & V4L2_TUNER_SUB_SAP) && 1037 if ((state->rxsubchans & V4L2_TUNER_SUB_SAP) &&
1031 (state->audmode == V4L2_TUNER_MODE_STEREO || 1038 (state->audmode == V4L2_TUNER_MODE_LANG1_LANG2 ||
1032 state->audmode == V4L2_TUNER_MODE_LANG2)) { 1039 state->audmode == V4L2_TUNER_MODE_LANG2)) {
1033 msp_write_dem(client, 0x20, 0x21); 1040 msp_write_dem(client, 0x20, 0x21);
1034 } else { 1041 } else {
diff --git a/drivers/media/video/pwc/Kconfig b/drivers/media/video/pwc/Kconfig
new file mode 100644
index 000000000000..86376556f108
--- /dev/null
+++ b/drivers/media/video/pwc/Kconfig
@@ -0,0 +1,28 @@
1config USB_PWC
2 tristate "USB Philips Cameras"
3 depends on USB && VIDEO_DEV
4 ---help---
5 Say Y or M here if you want to use one of these Philips & OEM
6 webcams:
7 * Philips PCA645, PCA646
8 * Philips PCVC675, PCVC680, PCVC690
9 * Philips PCVC720/40, PCVC730, PCVC740, PCVC750
10 * Askey VC010
11 * Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro'
12 and 'Orbit'/'Sphere'
13 * Samsung MPC-C10, MPC-C30
14 * Creative Webcam 5, Pro Ex
15 * SOTEC Afina Eye
16 * Visionite VCS-UC300, VCS-UM100
17
18 The PCA635, PCVC665 and PCVC720/20 are not supported by this driver
19 and never will be, but the 665 and 720/20 are supported by other
20 drivers.
21
22 See <file:Documentation/usb/philips.txt> for more information and
23 installation instructions.
24
25 The built-in microphone is enabled by selecting USB Audio support.
26
27 To compile this driver as a module, choose M here: the
28 module will be called pwc.
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index b05015282601..dceebc0b1250 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -40,6 +40,7 @@
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/videodev2.h> 41#include <linux/videodev2.h>
42#include <media/v4l2-common.h> 42#include <media/v4l2-common.h>
43#include <media/saa7115.h>
43#include <asm/div64.h> 44#include <asm/div64.h>
44 45
45MODULE_DESCRIPTION("Philips SAA7113/SAA7114/SAA7115 video decoder driver"); 46MODULE_DESCRIPTION("Philips SAA7113/SAA7114/SAA7115 video decoder driver");
@@ -53,7 +54,7 @@ module_param(debug, bool, 0644);
53MODULE_PARM_DESC(debug, "Debug level (0-1)"); 54MODULE_PARM_DESC(debug, "Debug level (0-1)");
54 55
55static unsigned short normal_i2c[] = { 56static unsigned short normal_i2c[] = {
56 0x4a >>1, 0x48 >>1, /* SAA7113 */ 57 0x4a >> 1, 0x48 >> 1, /* SAA7113 */
57 0x42 >> 1, 0x40 >> 1, /* SAA7114 and SAA7115 */ 58 0x42 >> 1, 0x40 >> 1, /* SAA7114 and SAA7115 */
58 I2C_CLIENT_END }; 59 I2C_CLIENT_END };
59 60
@@ -722,16 +723,16 @@ static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
722 100 reserved NTSC-Japan (3.58MHz) 723 100 reserved NTSC-Japan (3.58MHz)
723 */ 724 */
724 if (state->ident == V4L2_IDENT_SAA7113) { 725 if (state->ident == V4L2_IDENT_SAA7113) {
725 u8 reg = saa7115_read(client, 0x0e) & 0x8f; 726 u8 reg = saa7115_read(client, 0x0e) & 0x8f;
726 727
727 if (std == V4L2_STD_PAL_M) { 728 if (std == V4L2_STD_PAL_M) {
728 reg|=0x30; 729 reg |= 0x30;
729 } else if (std == V4L2_STD_PAL_N) { 730 } else if (std == V4L2_STD_PAL_N) {
730 reg|=0x20; 731 reg |= 0x20;
731 } else if (std == V4L2_STD_PAL_60) { 732 } else if (std == V4L2_STD_PAL_60) {
732 reg|=0x10; 733 reg |= 0x10;
733 } else if (std == V4L2_STD_NTSC_M_JP) { 734 } else if (std == V4L2_STD_NTSC_M_JP) {
734 reg|=0x40; 735 reg |= 0x40;
735 } 736 }
736 saa7115_write(client, 0x0e, reg); 737 saa7115_write(client, 0x0e, reg);
737 } 738 }
@@ -811,7 +812,7 @@ static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_fo
811 u8 lcr[24]; 812 u8 lcr[24];
812 int i, x; 813 int i, x;
813 814
814 /* saa7113/71144 doesn't yet support VBI */ 815 /* saa7113/7114 doesn't yet support VBI */
815 if (state->ident != V4L2_IDENT_SAA7115) 816 if (state->ident != V4L2_IDENT_SAA7115)
816 return; 817 return;
817 818
@@ -851,7 +852,7 @@ static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_fo
851 case 0: 852 case 0:
852 lcr[i] |= 0xf << (4 * x); 853 lcr[i] |= 0xf << (4 * x);
853 break; 854 break;
854 case V4L2_SLICED_TELETEXT_PAL_B: 855 case V4L2_SLICED_TELETEXT_B:
855 lcr[i] |= 1 << (4 * x); 856 lcr[i] |= 1 << (4 * x);
856 break; 857 break;
857 case V4L2_SLICED_CAPTION_525: 858 case V4L2_SLICED_CAPTION_525:
@@ -880,7 +881,7 @@ static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_fo
880static int saa7115_get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) 881static int saa7115_get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
881{ 882{
882 static u16 lcr2vbi[] = { 883 static u16 lcr2vbi[] = {
883 0, V4L2_SLICED_TELETEXT_PAL_B, 0, /* 1 */ 884 0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */
884 0, V4L2_SLICED_CAPTION_525, /* 4 */ 885 0, V4L2_SLICED_CAPTION_525, /* 4 */
885 V4L2_SLICED_WSS_625, 0, /* 5 */ 886 V4L2_SLICED_WSS_625, 0, /* 5 */
886 V4L2_SLICED_VPS, 0, 0, 0, 0, /* 7 */ 887 V4L2_SLICED_VPS, 0, 0, 0, 0, /* 7 */
@@ -1045,7 +1046,7 @@ static void saa7115_decode_vbi_line(struct i2c_client *client,
1045 /* decode payloads */ 1046 /* decode payloads */
1046 switch (id2) { 1047 switch (id2) {
1047 case 1: 1048 case 1:
1048 vbi->type = V4L2_SLICED_TELETEXT_PAL_B; 1049 vbi->type = V4L2_SLICED_TELETEXT_B;
1049 break; 1050 break;
1050 case 4: 1051 case 4:
1051 if (!saa7115_odd_parity(p[0]) || !saa7115_odd_parity(p[1])) 1052 if (!saa7115_odd_parity(p[0]) || !saa7115_odd_parity(p[1]))
@@ -1180,6 +1181,46 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1180 state->radio = 1; 1181 state->radio = 1;
1181 break; 1182 break;
1182 1183
1184 case VIDIOC_INT_G_VIDEO_ROUTING:
1185 {
1186 struct v4l2_routing *route = arg;
1187
1188 route->input = state->input;
1189 route->output = 0;
1190 break;
1191 }
1192
1193 case VIDIOC_INT_S_VIDEO_ROUTING:
1194 {
1195 struct v4l2_routing *route = arg;
1196
1197 v4l_dbg(1, debug, client, "decoder set input %d\n", route->input);
1198 /* saa7113 does not have these inputs */
1199 if (state->ident == V4L2_IDENT_SAA7113 &&
1200 (route->input == SAA7115_COMPOSITE4 ||
1201 route->input == SAA7115_COMPOSITE5)) {
1202 return -EINVAL;
1203 }
1204 if (route->input > SAA7115_SVIDEO3)
1205 return -EINVAL;
1206 if (state->input == route->input)
1207 break;
1208 v4l_dbg(1, debug, client, "now setting %s input\n",
1209 (route->input >= SAA7115_SVIDEO0) ? "S-Video" : "Composite");
1210 state->input = route->input;
1211
1212 /* select mode */
1213 saa7115_write(client, 0x02,
1214 (saa7115_read(client, 0x02) & 0xf0) |
1215 state->input);
1216
1217 /* bypass chrominance trap for S-Video modes */
1218 saa7115_write(client, 0x09,
1219 (saa7115_read(client, 0x09) & 0x7f) |
1220 (state->input >= SAA7115_SVIDEO0 ? 0x80 : 0x0));
1221 break;
1222 }
1223
1183 case VIDIOC_G_INPUT: 1224 case VIDIOC_G_INPUT:
1184 *(int *)arg = state->input; 1225 *(int *)arg = state->input;
1185 break; 1226 break;
@@ -1321,7 +1362,7 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1321 1362
1322 saa7115_write(client, 0, 5); 1363 saa7115_write(client, 0, 5);
1323 chip_id = saa7115_read(client, 0) & 0x0f; 1364 chip_id = saa7115_read(client, 0) & 0x0f;
1324 if (chip_id <3 && chip_id > 5) { 1365 if (chip_id < 3 && chip_id > 5) {
1325 v4l_dbg(1, debug, client, "saa7115 not found\n"); 1366 v4l_dbg(1, debug, client, "saa7115 not found\n");
1326 kfree(client); 1367 kfree(client);
1327 return 0; 1368 return 0;
@@ -1360,7 +1401,7 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1360 v4l_dbg(1, debug, client, "writing init values\n"); 1401 v4l_dbg(1, debug, client, "writing init values\n");
1361 1402
1362 /* init to 60hz/48khz */ 1403 /* init to 60hz/48khz */
1363 if (state->ident==V4L2_IDENT_SAA7113) 1404 if (state->ident == V4L2_IDENT_SAA7113)
1364 saa7115_writeregs(client, saa7113_init_auto_input); 1405 saa7115_writeregs(client, saa7113_init_auto_input);
1365 else 1406 else
1366 saa7115_writeregs(client, saa7115_init_auto_input); 1407 saa7115_writeregs(client, saa7115_init_auto_input);
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index 992c71774f30..133f9e5252fe 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -54,6 +54,7 @@
54#include <linux/i2c.h> 54#include <linux/i2c.h>
55#include <linux/videodev2.h> 55#include <linux/videodev2.h>
56#include <media/v4l2-common.h> 56#include <media/v4l2-common.h>
57#include <media/saa7127.h>
57 58
58static int debug = 0; 59static int debug = 0;
59static int test_image = 0; 60static int test_image = 0;
@@ -222,22 +223,6 @@ static struct i2c_reg_value saa7127_init_config_50hz[] = {
222 { 0, 0 } 223 { 0, 0 }
223}; 224};
224 225
225/* Enumeration for the Supported input types */
226enum saa7127_input_type {
227 SAA7127_INPUT_TYPE_NORMAL,
228 SAA7127_INPUT_TYPE_TEST_IMAGE
229};
230
231/* Enumeration for the Supported Output signal types */
232enum saa7127_output_type {
233 SAA7127_OUTPUT_TYPE_BOTH,
234 SAA7127_OUTPUT_TYPE_COMPOSITE,
235 SAA7127_OUTPUT_TYPE_SVIDEO,
236 SAA7127_OUTPUT_TYPE_RGB,
237 SAA7127_OUTPUT_TYPE_YUV_C,
238 SAA7127_OUTPUT_TYPE_YUV_V
239};
240
241/* 226/*
242 ********************************************************************** 227 **********************************************************************
243 * 228 *
@@ -561,7 +546,7 @@ static int saa7127_command(struct i2c_client *client,
561{ 546{
562 struct saa7127_state *state = i2c_get_clientdata(client); 547 struct saa7127_state *state = i2c_get_clientdata(client);
563 struct v4l2_format *fmt = arg; 548 struct v4l2_format *fmt = arg;
564 int *iarg = arg; 549 struct v4l2_routing *route = arg;
565 550
566 switch (cmd) { 551 switch (cmd) {
567 case VIDIOC_S_STD: 552 case VIDIOC_S_STD:
@@ -573,15 +558,23 @@ static int saa7127_command(struct i2c_client *client,
573 *(v4l2_std_id *)arg = state->std; 558 *(v4l2_std_id *)arg = state->std;
574 break; 559 break;
575 560
576 case VIDIOC_S_INPUT: 561 case VIDIOC_INT_G_VIDEO_ROUTING:
577 if (state->input_type == *iarg) 562 route->input = state->input_type;
578 break; 563 route->output = state->output_type;
579 return saa7127_set_input_type(client, *iarg); 564 break;
580 565
581 case VIDIOC_S_OUTPUT: 566 case VIDIOC_INT_S_VIDEO_ROUTING:
582 if (state->output_type == *iarg) 567 {
583 break; 568 int rc = 0;
584 return saa7127_set_output_type(client, *iarg); 569
570 if (state->input_type != route->input) {
571 rc = saa7127_set_input_type(client, route->input);
572 }
573 if (rc == 0 && state->output_type != route->output) {
574 rc = saa7127_set_output_type(client, route->output);
575 }
576 return rc;
577 }
585 578
586 case VIDIOC_STREAMON: 579 case VIDIOC_STREAMON:
587 case VIDIOC_STREAMOFF: 580 case VIDIOC_STREAMOFF:
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 86671a43e769..e1c1805df1fb 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -39,6 +39,7 @@ config VIDEO_SAA7134_DVB
39 tristate "DVB/ATSC Support for saa7134 based TV cards" 39 tristate "DVB/ATSC Support for saa7134 based TV cards"
40 depends on VIDEO_SAA7134 && DVB_CORE 40 depends on VIDEO_SAA7134 && DVB_CORE
41 select VIDEO_BUF_DVB 41 select VIDEO_BUF_DVB
42 select FW_LOADER
42 ---help--- 43 ---help---
43 This adds support for DVB cards based on the 44 This adds support for DVB cards based on the
44 Philips saa7134 chip. 45 Philips saa7134 chip.
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index fdd7f48f3b76..e666a4465ca4 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -208,7 +208,7 @@ struct saa7134_board saa7134_boards[] = {
208 [SAA7134_BOARD_FLYTVPLATINUM_FM] = { 208 [SAA7134_BOARD_FLYTVPLATINUM_FM] = {
209 /* LifeView FlyTV Platinum FM (LR214WF) */ 209 /* LifeView FlyTV Platinum FM (LR214WF) */
210 /* "Peter Missel <peter.missel@onlinehome.de> */ 210 /* "Peter Missel <peter.missel@onlinehome.de> */
211 .name = "LifeView FlyTV Platinum FM", 211 .name = "LifeView FlyTV Platinum FM / Gold",
212 .audio_clock = 0x00200000, 212 .audio_clock = 0x00200000,
213 .tuner_type = TUNER_PHILIPS_TDA8290, 213 .tuner_type = TUNER_PHILIPS_TDA8290,
214 .radio_type = UNSET, 214 .radio_type = UNSET,
@@ -2660,7 +2660,7 @@ struct saa7134_board saa7134_boards[] = {
2660 .mpeg = SAA7134_MPEG_DVB, 2660 .mpeg = SAA7134_MPEG_DVB,
2661 .inputs = {{ 2661 .inputs = {{
2662 .name = name_comp1, 2662 .name = name_comp1,
2663 .vmux = 0, 2663 .vmux = 1,
2664 .amux = LINE1, 2664 .amux = LINE1,
2665 },{ 2665 },{
2666 .name = name_svideo, 2666 .name = name_svideo,
@@ -2671,7 +2671,7 @@ struct saa7134_board saa7134_boards[] = {
2671 [SAA7134_BOARD_FLYDVBT_LR301] = { 2671 [SAA7134_BOARD_FLYDVBT_LR301] = {
2672 /* LifeView FlyDVB-T */ 2672 /* LifeView FlyDVB-T */
2673 /* Giampiero Giancipoli <gianci@libero.it> */ 2673 /* Giampiero Giancipoli <gianci@libero.it> */
2674 .name = "LifeView FlyDVB-T", 2674 .name = "LifeView FlyDVB-T / Genius VideoWonder DVB-T",
2675 .audio_clock = 0x00200000, 2675 .audio_clock = 0x00200000,
2676 .tuner_type = TUNER_ABSENT, 2676 .tuner_type = TUNER_ABSENT,
2677 .radio_type = UNSET, 2677 .radio_type = UNSET,
@@ -2808,6 +2808,40 @@ struct saa7134_board saa7134_boards[] = {
2808 .tuner_addr = ADDR_UNSET, 2808 .tuner_addr = ADDR_UNSET,
2809 .radio_addr = ADDR_UNSET, 2809 .radio_addr = ADDR_UNSET,
2810 }, 2810 },
2811 [SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS] = {
2812 .name = "LifeView FlyDVB-T Hybrid Cardbus",
2813 .audio_clock = 0x00200000,
2814 .tuner_type = TUNER_PHILIPS_TDA8290,
2815 .radio_type = UNSET,
2816 .tuner_addr = ADDR_UNSET,
2817 .radio_addr = ADDR_UNSET,
2818 .mpeg = SAA7134_MPEG_DVB,
2819 .gpiomask = 0x00600000, /* Bit 21 0=Radio, Bit 22 0=TV */
2820 .inputs = {{
2821 .name = name_tv,
2822 .vmux = 1,
2823 .amux = TV,
2824 .gpio = 0x200000, /* GPIO21=High for TV input */
2825 .tv = 1,
2826 },{
2827 .name = name_svideo, /* S-Video signal on S-Video input */
2828 .vmux = 8,
2829 .amux = LINE2,
2830 },{
2831 .name = name_comp1, /* Composite signal on S-Video input */
2832 .vmux = 0,
2833 .amux = LINE2,
2834 },{
2835 .name = name_comp2, /* Composite input */
2836 .vmux = 3,
2837 .amux = LINE2,
2838 }},
2839 .radio = {
2840 .name = name_radio,
2841 .amux = TV,
2842 .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */
2843 },
2844 },
2811}; 2845};
2812 2846
2813const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 2847const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -3333,6 +3367,30 @@ struct pci_device_id saa7134_pci_tbl[] = {
3333 .subdevice = 0x0005, 3367 .subdevice = 0x0005,
3334 .driver_data = SAA7134_BOARD_MD7134_BRIDGE_2, 3368 .driver_data = SAA7134_BOARD_MD7134_BRIDGE_2,
3335 },{ 3369 },{
3370 .vendor = PCI_VENDOR_ID_PHILIPS,
3371 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
3372 .subvendor = 0x1489,
3373 .subdevice = 0x0301,
3374 .driver_data = SAA7134_BOARD_FLYDVBT_LR301,
3375 },{
3376 .vendor = PCI_VENDOR_ID_PHILIPS,
3377 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3378 .subvendor = 0x5168, /* Animation Technologies (LifeView) */
3379 .subdevice = 0x0304,
3380 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM,
3381 },{
3382 .vendor = PCI_VENDOR_ID_PHILIPS,
3383 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3384 .subvendor = 0x5168,
3385 .subdevice = 0x3306,
3386 .driver_data = SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS,
3387 },{
3388 .vendor = PCI_VENDOR_ID_PHILIPS,
3389 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3390 .subvendor = 0x5168,
3391 .subdevice = 0x3502, /* whats the difference to 0x3306 ?*/
3392 .driver_data = SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS,
3393 },{
3336 /* --- boards without eeprom + subsystem ID --- */ 3394 /* --- boards without eeprom + subsystem ID --- */
3337 .vendor = PCI_VENDOR_ID_PHILIPS, 3395 .vendor = PCI_VENDOR_ID_PHILIPS,
3338 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 3396 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -3462,6 +3520,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3462 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x06); 3520 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x06);
3463 break; 3521 break;
3464 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 3522 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
3523 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
3465 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08); 3524 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08);
3466 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00); 3525 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00);
3467 break; 3526 break;
@@ -3633,6 +3692,7 @@ int saa7134_board_init2(struct saa7134_dev *dev)
3633 } 3692 }
3634 break; 3693 break;
3635 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 3694 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
3695 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
3636 /* make the tda10046 find its eeprom */ 3696 /* make the tda10046 find its eeprom */
3637 { 3697 {
3638 u8 data[] = { 0x3c, 0x33, 0x62}; 3698 u8 data[] = { 0x3c, 0x33, 0x62};
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 86cfdb8514cb..222a36c38917 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -1064,6 +1064,10 @@ static int dvb_init(struct saa7134_dev *dev)
1064 dev->dvb.frontend = tda10046_attach(&tevion_dvbt220rf_config, 1064 dev->dvb.frontend = tda10046_attach(&tevion_dvbt220rf_config,
1065 &dev->i2c_adap); 1065 &dev->i2c_adap);
1066 break; 1066 break;
1067 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1068 dev->dvb.frontend = tda10046_attach(&ads_tech_duo_config,
1069 &dev->i2c_adap);
1070 break;
1067#endif 1071#endif
1068#ifdef HAVE_NXT200X 1072#ifdef HAVE_NXT200X
1069 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1073 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 31ba293854c1..353af3a8b766 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -220,6 +220,7 @@ struct saa7134_format {
220#define SAA7134_BOARD_AVERMEDIA_A169_B 91 220#define SAA7134_BOARD_AVERMEDIA_A169_B 91
221#define SAA7134_BOARD_AVERMEDIA_A169_B1 92 221#define SAA7134_BOARD_AVERMEDIA_A169_B1 92
222#define SAA7134_BOARD_MD7134_BRIDGE_2 93 222#define SAA7134_BOARD_MD7134_BRIDGE_2 93
223#define SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS 94
223 224
224#define SAA7134_MAXBOARDS 8 225#define SAA7134_MAXBOARDS 8
225#define SAA7134_INPUT_MAX 8 226#define SAA7134_INPUT_MAX 8
diff --git a/drivers/media/video/sn9c102/Kconfig b/drivers/media/video/sn9c102/Kconfig
new file mode 100644
index 000000000000..55f2bc11964b
--- /dev/null
+++ b/drivers/media/video/sn9c102/Kconfig
@@ -0,0 +1,11 @@
1config USB_SN9C102
2 tristate "USB SN9C10x PC Camera Controller support"
3 depends on USB && VIDEO_DEV
4 ---help---
5 Say Y here if you want support for cameras based on SONiX SN9C101,
6 SN9C102 or SN9C103 PC Camera Controllers.
7
8 See <file:Documentation/video4linux/sn9c102.txt> for more info.
9
10 To compile this driver as a module, choose M here: the
11 module will be called sn9c102.
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index df195c905366..1013b4de89a2 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -401,7 +401,7 @@ static void tuner_status(struct i2c_client *client)
401 } 401 }
402 tuner_info("Tuner mode: %s\n", p); 402 tuner_info("Tuner mode: %s\n", p);
403 tuner_info("Frequency: %lu.%02lu MHz\n", freq, freq_fraction); 403 tuner_info("Frequency: %lu.%02lu MHz\n", freq, freq_fraction);
404 tuner_info("Standard: 0x%08llx\n", t->std); 404 tuner_info("Standard: 0x%08lx\n", (unsigned long)t->std);
405 if (t->mode != V4L2_TUNER_RADIO) 405 if (t->mode != V4L2_TUNER_RADIO)
406 return; 406 return;
407 if (t->has_signal) { 407 if (t->has_signal) {
@@ -558,10 +558,10 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode,
558 558
559static inline int check_v4l2(struct tuner *t) 559static inline int check_v4l2(struct tuner *t)
560{ 560{
561 if (t->using_v4l2) { 561 /* bttv still uses both v4l1 and v4l2 calls to the tuner (v4l2 for
562 tuner_dbg ("ignore v4l1 call\n"); 562 TV, v4l1 for radio), until that is fixed this code is disabled.
563 return EINVAL; 563 Otherwise the radio (v4l1) wouldn't tune after using the TV (v4l2)
564 } 564 first. */
565 return 0; 565 return 0;
566} 566}
567 567
@@ -744,6 +744,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
744 switch_v4l2(); 744 switch_v4l2();
745 745
746 tuner->type = t->mode; 746 tuner->type = t->mode;
747 if (t->mode == V4L2_TUNER_ANALOG_TV)
748 tuner->capability |= V4L2_TUNER_CAP_NORM;
747 if (t->mode != V4L2_TUNER_RADIO) { 749 if (t->mode != V4L2_TUNER_RADIO) {
748 tuner->rangelow = tv_range[0] * 16; 750 tuner->rangelow = tv_range[0] * 16;
749 tuner->rangehigh = tv_range[1] * 16; 751 tuner->rangehigh = tv_range[1] * 16;
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 356bff455ad1..c2b756107548 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -1706,21 +1706,6 @@ static int chip_command(struct i2c_client *client,
1706 break; 1706 break;
1707 } 1707 }
1708 1708
1709 case VIDIOC_S_AUDIO:
1710 {
1711 struct v4l2_audio *sarg = arg;
1712
1713 if (!(desc->flags & CHIP_HAS_INPUTSEL) || sarg->index >= 4)
1714 return -EINVAL;
1715 /* There are four inputs: tuner, radio, extern and intern. */
1716 chip->input = sarg->index;
1717 if (chip->muted)
1718 break;
1719 chip_write_masked(chip, desc->inputreg,
1720 desc->inputmap[chip->input], desc->inputmask);
1721 break;
1722 }
1723
1724 case VIDIOC_S_TUNER: 1709 case VIDIOC_S_TUNER:
1725 { 1710 {
1726 struct v4l2_tuner *vt = arg; 1711 struct v4l2_tuner *vt = arg;
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index e0d2ff83fc91..431c3e2f6c42 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -757,9 +757,9 @@ tveeprom_detect_client(struct i2c_adapter *adapter,
757static int 757static int
758tveeprom_attach_adapter (struct i2c_adapter *adapter) 758tveeprom_attach_adapter (struct i2c_adapter *adapter)
759{ 759{
760 if (adapter->id != I2C_HW_B_BT848) 760 if (adapter->class & I2C_CLASS_TV_ANALOG)
761 return 0; 761 return i2c_probe(adapter, &addr_data, tveeprom_detect_client);
762 return i2c_probe(adapter, &addr_data, tveeprom_detect_client); 762 return 0;
763} 763}
764 764
765static int 765static int
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index 69d0fe159f4d..dab4973bcf82 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -53,7 +53,7 @@ static struct v4l2_queryctrl tvp5150_qctrl[] = {
53 .minimum = 0, 53 .minimum = 0,
54 .maximum = 255, 54 .maximum = 255,
55 .step = 1, 55 .step = 1,
56 .default_value = 0, 56 .default_value = 128,
57 .flags = 0, 57 .flags = 0,
58 }, { 58 }, {
59 .id = V4L2_CID_CONTRAST, 59 .id = V4L2_CID_CONTRAST,
@@ -62,7 +62,7 @@ static struct v4l2_queryctrl tvp5150_qctrl[] = {
62 .minimum = 0, 62 .minimum = 0,
63 .maximum = 255, 63 .maximum = 255,
64 .step = 0x1, 64 .step = 0x1,
65 .default_value = 0x10, 65 .default_value = 128,
66 .flags = 0, 66 .flags = 0,
67 }, { 67 }, {
68 .id = V4L2_CID_SATURATION, 68 .id = V4L2_CID_SATURATION,
@@ -71,7 +71,7 @@ static struct v4l2_queryctrl tvp5150_qctrl[] = {
71 .minimum = 0, 71 .minimum = 0,
72 .maximum = 255, 72 .maximum = 255,
73 .step = 0x1, 73 .step = 0x1,
74 .default_value = 0x10, 74 .default_value = 128,
75 .flags = 0, 75 .flags = 0,
76 }, { 76 }, {
77 .id = V4L2_CID_HUE, 77 .id = V4L2_CID_HUE,
@@ -80,7 +80,7 @@ static struct v4l2_queryctrl tvp5150_qctrl[] = {
80 .minimum = -128, 80 .minimum = -128,
81 .maximum = 127, 81 .maximum = 127,
82 .step = 0x1, 82 .step = 0x1,
83 .default_value = 0x10, 83 .default_value = 0,
84 .flags = 0, 84 .flags = 0,
85 } 85 }
86}; 86};
@@ -500,16 +500,21 @@ struct i2c_vbi_ram_value {
500 500
501static struct i2c_vbi_ram_value vbi_ram_default[] = 501static struct i2c_vbi_ram_value vbi_ram_default[] =
502{ 502{
503 /* FIXME: Current api doesn't handle all VBI types, those not
504 yet supported are placed under #if 0 */
505#if 0
503 {0x010, /* Teletext, SECAM, WST System A */ 506 {0x010, /* Teletext, SECAM, WST System A */
504 {V4L2_SLICED_TELETEXT_SECAM,6,23,1}, 507 {V4L2_SLICED_TELETEXT_SECAM,6,23,1},
505 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x26, 508 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x26,
506 0xe6, 0xb4, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00 } 509 0xe6, 0xb4, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00 }
507 }, 510 },
511#endif
508 {0x030, /* Teletext, PAL, WST System B */ 512 {0x030, /* Teletext, PAL, WST System B */
509 {V4L2_SLICED_TELETEXT_PAL_B,6,22,1}, 513 {V4L2_SLICED_TELETEXT_B,6,22,1},
510 { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x2b, 514 { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x2b,
511 0xa6, 0x72, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00 } 515 0xa6, 0x72, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00 }
512 }, 516 },
517#if 0
513 {0x050, /* Teletext, PAL, WST System C */ 518 {0x050, /* Teletext, PAL, WST System C */
514 {V4L2_SLICED_TELETEXT_PAL_C,6,22,1}, 519 {V4L2_SLICED_TELETEXT_PAL_C,6,22,1},
515 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22, 520 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
@@ -535,6 +540,7 @@ static struct i2c_vbi_ram_value vbi_ram_default[] =
535 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02, 540 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
536 0xa6, 0x7b, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 } 541 0xa6, 0x7b, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
537 }, 542 },
543#endif
538 {0x0f0, /* Closed Caption, NTSC */ 544 {0x0f0, /* Closed Caption, NTSC */
539 {V4L2_SLICED_CAPTION_525,21,21,1}, 545 {V4L2_SLICED_CAPTION_525,21,21,1},
540 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02, 546 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
@@ -545,6 +551,7 @@ static struct i2c_vbi_ram_value vbi_ram_default[] =
545 { 0x5b, 0x55, 0xc5, 0xff, 0x00, 0x71, 0x6e, 0x42, 551 { 0x5b, 0x55, 0xc5, 0xff, 0x00, 0x71, 0x6e, 0x42,
546 0xa6, 0xcd, 0x0f, 0x00, 0x00, 0x00, 0x3a, 0x00 } 552 0xa6, 0xcd, 0x0f, 0x00, 0x00, 0x00, 0x3a, 0x00 }
547 }, 553 },
554#if 0
548 {0x130, /* Wide Screen Signal, NTSC C */ 555 {0x130, /* Wide Screen Signal, NTSC C */
549 {V4L2_SLICED_WSS_525,20,20,1}, 556 {V4L2_SLICED_WSS_525,20,20,1},
550 { 0x38, 0x00, 0x3f, 0x00, 0x00, 0x71, 0x6e, 0x43, 557 { 0x38, 0x00, 0x3f, 0x00, 0x00, 0x71, 0x6e, 0x43,
@@ -560,6 +567,7 @@ static struct i2c_vbi_ram_value vbi_ram_default[] =
560 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49, 567 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
561 0x69, 0x94, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 } 568 0x69, 0x94, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
562 }, 569 },
570#endif
563 {0x190, /* Video Program System (VPS), PAL */ 571 {0x190, /* Video Program System (VPS), PAL */
564 {V4L2_SLICED_VPS,16,16,0}, 572 {V4L2_SLICED_VPS,16,16,0},
565 { 0xaa, 0xaa, 0xff, 0xff, 0xba, 0xce, 0x2b, 0x0d, 573 { 0xaa, 0xaa, 0xff, 0xff, 0xba, 0xce, 0x2b, 0x0d,
@@ -850,7 +858,6 @@ static int tvp5150_command(struct i2c_client *c,
850 858
851 case 0: 859 case 0:
852 case VIDIOC_INT_RESET: 860 case VIDIOC_INT_RESET:
853 case DECODER_INIT:
854 tvp5150_reset(c); 861 tvp5150_reset(c);
855 break; 862 break;
856 case VIDIOC_S_STD: 863 case VIDIOC_S_STD:
@@ -949,99 +956,15 @@ static int tvp5150_command(struct i2c_client *c,
949#endif 956#endif
950 957
951 case VIDIOC_LOG_STATUS: 958 case VIDIOC_LOG_STATUS:
952 case DECODER_DUMP:
953 dump_reg(c); 959 dump_reg(c);
954 break; 960 break;
955 961
956 case DECODER_GET_CAPABILITIES: 962 case VIDIOC_G_TUNER:
957 { 963 {
958 struct video_decoder_capability *cap = arg; 964 struct v4l2_tuner *vt = arg;
959 965 int status = tvp5150_read(c, 0x88);
960 cap->flags = VIDEO_DECODER_PAL |
961 VIDEO_DECODER_NTSC |
962 VIDEO_DECODER_SECAM |
963 VIDEO_DECODER_AUTO | VIDEO_DECODER_CCIR;
964 cap->inputs = 3;
965 cap->outputs = 1;
966 break;
967 }
968 case DECODER_GET_STATUS:
969 {
970 int *iarg = arg;
971 int status;
972 int res=0;
973 status = tvp5150_read(c, 0x88);
974 if(status&0x08){
975 res |= DECODER_STATUS_COLOR;
976 }
977 if(status&0x04 && status&0x02){
978 res |= DECODER_STATUS_GOOD;
979 }
980 *iarg=res;
981 break;
982 }
983
984 case DECODER_SET_GPIO:
985 break;
986
987 case DECODER_SET_VBI_BYPASS:
988 break;
989
990 case DECODER_SET_NORM:
991 {
992 int *iarg = arg;
993
994 switch (*iarg) {
995
996 case VIDEO_MODE_NTSC:
997 break;
998
999 case VIDEO_MODE_PAL:
1000 break;
1001
1002 case VIDEO_MODE_SECAM:
1003 break;
1004
1005 case VIDEO_MODE_AUTO:
1006 break;
1007
1008 default:
1009 return -EINVAL;
1010
1011 }
1012 decoder->norm = *iarg;
1013 break;
1014 }
1015 case DECODER_SET_INPUT:
1016 {
1017 int *iarg = arg;
1018 if (*iarg < 0 || *iarg > 3) {
1019 return -EINVAL;
1020 }
1021
1022 decoder->input = *iarg;
1023 tvp5150_selmux(c, decoder->input);
1024
1025 break;
1026 }
1027 case DECODER_SET_OUTPUT:
1028 {
1029 int *iarg = arg;
1030
1031 /* not much choice of outputs */
1032 if (*iarg != 0) {
1033 return -EINVAL;
1034 }
1035 break;
1036 }
1037 case DECODER_ENABLE_OUTPUT:
1038 {
1039 int *iarg = arg;
1040
1041 decoder->enable = (*iarg != 0);
1042
1043 tvp5150_selmux(c, decoder->input);
1044 966
967 vt->signal = ((status & 0x04) && (status & 0x02)) ? 0xffff : 0x0;
1045 break; 968 break;
1046 } 969 }
1047 case VIDIOC_QUERYCTRL: 970 case VIDIOC_QUERYCTRL:
@@ -1087,35 +1010,6 @@ static int tvp5150_command(struct i2c_client *c,
1087 return -EINVAL; 1010 return -EINVAL;
1088 } 1011 }
1089 1012
1090 case DECODER_SET_PICTURE:
1091 {
1092 struct video_picture *pic = arg;
1093 if (decoder->bright != pic->brightness) {
1094 /* We want 0 to 255 we get 0-65535 */
1095 decoder->bright = pic->brightness;
1096 tvp5150_write(c, TVP5150_BRIGHT_CTL,
1097 decoder->bright >> 8);
1098 }
1099 if (decoder->contrast != pic->contrast) {
1100 /* We want 0 to 255 we get 0-65535 */
1101 decoder->contrast = pic->contrast;
1102 tvp5150_write(c, TVP5150_CONTRAST_CTL,
1103 decoder->contrast >> 8);
1104 }
1105 if (decoder->sat != pic->colour) {
1106 /* We want 0 to 255 we get 0-65535 */
1107 decoder->sat = pic->colour;
1108 tvp5150_write(c, TVP5150_SATURATION_CTL,
1109 decoder->contrast >> 8);
1110 }
1111 if (decoder->hue != pic->hue) {
1112 /* We want -128 to 127 we get 0-65535 */
1113 decoder->hue = pic->hue;
1114 tvp5150_write(c, TVP5150_HUE_CTL,
1115 (decoder->hue - 32768) >> 8);
1116 }
1117 break;
1118 }
1119 default: 1013 default:
1120 return -EINVAL; 1014 return -EINVAL;
1121 } 1015 }
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c
new file mode 100644
index 000000000000..fc52201d607e
--- /dev/null
+++ b/drivers/media/video/upd64031a.c
@@ -0,0 +1,286 @@
1/*
2 * upd64031A - NEC Electronics Ghost Reduction for NTSC in Japan
3 *
4 * 2003 by T.Adachi <tadachi@tadachi-net.com>
5 * 2003 by Takeru KOMORIYA <komoriya@paken.org>
6 * 2006 by Hans Verkuil <hverkuil@xs4all.nl>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23
24#include <linux/version.h>
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/i2c.h>
28#include <linux/videodev2.h>
29#include <media/v4l2-common.h>
30#include <media/upd64031a.h>
31
32// --------------------- read registers functions define -----------------------
33
34/* bit masks */
35#define GR_MODE_MASK 0xc0
36#define DIRECT_3DYCS_CONNECT_MASK 0xc0
37#define SYNC_CIRCUIT_MASK 0xa0
38
39// -----------------------------------------------------------------------------
40
41MODULE_DESCRIPTION("uPD64031A driver");
42MODULE_AUTHOR("T. Adachi, Takeru KOMORIYA, Hans Verkuil");
43MODULE_LICENSE("GPL");
44
45static int debug = 0;
46module_param(debug, int, 0644);
47
48MODULE_PARM_DESC(debug, "Debug level (0-1)");
49
50static unsigned short normal_i2c[] = { 0x24 >> 1, 0x26 >> 1, I2C_CLIENT_END };
51
52
53I2C_CLIENT_INSMOD;
54
55enum {
56 R00 = 0, R01, R02, R03, R04,
57 R05, R06, R07, R08, R09,
58 R0A, R0B, R0C, R0D, R0E, R0F,
59 /* unused registers
60 R10, R11, R12, R13, R14,
61 R15, R16, R17,
62 */
63 TOT_REGS
64};
65
66struct upd64031a_state {
67 u8 regs[TOT_REGS];
68 u8 gr_mode;
69 u8 direct_3dycs_connect;
70 u8 ext_comp_sync;
71 u8 ext_vert_sync;
72};
73
74static u8 upd64031a_init[] = {
75 0x00, 0xb8, 0x48, 0xd2, 0xe6,
76 0x03, 0x10, 0x0b, 0xaf, 0x7f,
77 0x00, 0x00, 0x1d, 0x5e, 0x00,
78 0xd0
79};
80
81/* ------------------------------------------------------------------------ */
82
83static u8 upd64031a_read(struct i2c_client *client, u8 reg)
84{
85 u8 buf[2];
86
87 if (reg >= sizeof(buf))
88 return 0xff;
89 i2c_master_recv(client, buf, 2);
90 return buf[reg];
91}
92
93/* ------------------------------------------------------------------------ */
94
95static void upd64031a_write(struct i2c_client *client, u8 reg, u8 val)
96{
97 u8 buf[2];
98
99 buf[0] = reg;
100 buf[1] = val;
101 v4l_dbg(1, debug, client, "writing reg addr: %02X val: %02X\n", reg, val);
102 if (i2c_master_send(client, buf, 2) != 2)
103 v4l_err(client, "I/O error write 0x%02x/0x%02x\n", reg, val);
104}
105
106/* ------------------------------------------------------------------------ */
107
108/* The input changed due to new input or channel changed */
109static void upd64031a_change(struct i2c_client *client)
110{
111 struct upd64031a_state *state = i2c_get_clientdata(client);
112 u8 reg = state->regs[R00];
113
114 v4l_dbg(1, debug, client, "changed input or channel\n");
115 upd64031a_write(client, R00, reg | 0x10);
116 upd64031a_write(client, R00, reg & ~0x10);
117}
118
119/* ------------------------------------------------------------------------ */
120
121static int upd64031a_command(struct i2c_client *client, unsigned int cmd, void *arg)
122{
123 struct upd64031a_state *state = i2c_get_clientdata(client);
124 struct v4l2_routing *route = arg;
125
126 switch (cmd) {
127 case VIDIOC_S_FREQUENCY:
128 upd64031a_change(client);
129 break;
130
131 case VIDIOC_INT_G_VIDEO_ROUTING:
132 route->input = (state->gr_mode >> 6) |
133 (state->direct_3dycs_connect >> 4) |
134 (state->ext_comp_sync >> 1) |
135 (state->ext_vert_sync >> 2);
136 route->output = 0;
137 break;
138
139 case VIDIOC_INT_S_VIDEO_ROUTING:
140 {
141 u8 r00, r05, r08;
142
143 state->gr_mode = (route->input & 3) << 6;
144 state->direct_3dycs_connect = (route->input & 0xc) << 4;
145 state->ext_comp_sync = (route->input & UPD64031A_COMPOSITE_EXTERNAL) << 1;
146 state->ext_vert_sync = (route->input & UPD64031A_VERTICAL_EXTERNAL) << 2;
147 r00 = (state->regs[R00] & ~GR_MODE_MASK) | state->gr_mode;
148 r05 = (state->regs[R00] & ~SYNC_CIRCUIT_MASK) |
149 state->ext_comp_sync | state->ext_vert_sync;
150 r08 = (state->regs[R08] & ~DIRECT_3DYCS_CONNECT_MASK) |
151 state->direct_3dycs_connect;
152 upd64031a_write(client, R00, r00);
153 upd64031a_write(client, R05, r05);
154 upd64031a_write(client, R08, r08);
155 upd64031a_change(client);
156 break;
157 }
158
159 case VIDIOC_LOG_STATUS:
160 v4l_info(client, "Status: SA00=0x%02x SA01=0x%02x\n",
161 upd64031a_read(client, 0), upd64031a_read(client, 1));
162 break;
163
164#ifdef CONFIG_VIDEO_ADV_DEBUG
165 case VIDIOC_INT_G_REGISTER:
166 {
167 struct v4l2_register *reg = arg;
168
169 if (reg->i2c_id != I2C_DRIVERID_UPD64031A)
170 return -EINVAL;
171 reg->val = upd64031a_read(client, reg->reg & 0xff);
172 break;
173 }
174
175 case VIDIOC_INT_S_REGISTER:
176 {
177 struct v4l2_register *reg = arg;
178 u8 addr = reg->reg & 0xff;
179 u8 val = reg->val & 0xff;
180
181 if (reg->i2c_id != I2C_DRIVERID_UPD64031A)
182 return -EINVAL;
183 if (!capable(CAP_SYS_ADMIN))
184 return -EPERM;
185 upd64031a_write(client, addr, val);
186 break;
187 }
188#endif
189
190 default:
191 break;
192 }
193 return 0;
194}
195
196/* ------------------------------------------------------------------------ */
197
198/* i2c implementation */
199
200static struct i2c_driver i2c_driver;
201
202static int upd64031a_attach(struct i2c_adapter *adapter, int address, int kind)
203{
204 struct i2c_client *client;
205 struct upd64031a_state *state;
206 int i;
207
208 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
209 return 0;
210
211 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
212 if (client == NULL) {
213 return -ENOMEM;
214 }
215
216 client->addr = address;
217 client->adapter = adapter;
218 client->driver = &i2c_driver;
219 snprintf(client->name, sizeof(client->name) - 1, "uPD64031A");
220
221 v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name);
222
223 state = kmalloc(sizeof(struct upd64031a_state), GFP_KERNEL);
224 if (state == NULL) {
225 kfree(client);
226 return -ENOMEM;
227 }
228 i2c_set_clientdata(client, state);
229 memcpy(state->regs, upd64031a_init, sizeof(state->regs));
230 state->gr_mode = UPD64031A_GR_ON << 6;
231 state->direct_3dycs_connect = UPD64031A_3DYCS_COMPOSITE << 4;
232 state->ext_comp_sync = state->ext_vert_sync = 0;
233 for (i = 0; i < TOT_REGS; i++) {
234 upd64031a_write(client, i, state->regs[i]);
235 }
236
237 i2c_attach_client(client);
238
239 return 0;
240}
241
242static int upd64031a_probe(struct i2c_adapter *adapter)
243{
244 if (adapter->class & I2C_CLASS_TV_ANALOG)
245 return i2c_probe(adapter, &addr_data, upd64031a_attach);
246 return 0;
247}
248
249static int upd64031a_detach(struct i2c_client *client)
250{
251 int err;
252
253 err = i2c_detach_client(client);
254 if (err)
255 return err;
256
257 kfree(client);
258 return 0;
259}
260
261/* ----------------------------------------------------------------------- */
262
263/* i2c implementation */
264static struct i2c_driver i2c_driver = {
265 .driver = {
266 .name = "upd64031a",
267 },
268 .id = I2C_DRIVERID_UPD64031A,
269 .attach_adapter = upd64031a_probe,
270 .detach_client = upd64031a_detach,
271 .command = upd64031a_command,
272};
273
274
275static int __init upd64031a_init_module(void)
276{
277 return i2c_add_driver(&i2c_driver);
278}
279
280static void __exit upd64031a_exit_module(void)
281{
282 i2c_del_driver(&i2c_driver);
283}
284
285module_init(upd64031a_init_module);
286module_exit(upd64031a_exit_module);
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c
new file mode 100644
index 000000000000..c3a7ffe5c267
--- /dev/null
+++ b/drivers/media/video/upd64083.c
@@ -0,0 +1,262 @@
1/*
2 * upd6408x - NEC Electronics 3-Dimensional Y/C separation driver
3 *
4 * 2003 by T.Adachi (tadachi@tadachi-net.com)
5 * 2003 by Takeru KOMORIYA <komoriya@paken.org>
6 * 2006 by Hans Verkuil <hverkuil@xs4all.nl>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#include <linux/version.h>
24#include <linux/module.h>
25#include <linux/kernel.h>
26#include <linux/i2c.h>
27#include <linux/videodev2.h>
28#include <media/v4l2-common.h>
29#include <media/upd64083.h>
30
31MODULE_DESCRIPTION("uPD64083 driver");
32MODULE_AUTHOR("T. Adachi, Takeru KOMORIYA, Hans Verkuil");
33MODULE_LICENSE("GPL");
34
35static int debug = 0;
36module_param(debug, bool, 0644);
37
38MODULE_PARM_DESC(debug, "Debug level (0-1)");
39
40static unsigned short normal_i2c[] = { 0xb8 >> 1, 0xba >> 1, I2C_CLIENT_END };
41
42
43I2C_CLIENT_INSMOD;
44
45enum {
46 R00 = 0, R01, R02, R03, R04,
47 R05, R06, R07, R08, R09,
48 R0A, R0B, R0C, R0D, R0E, R0F,
49 R10, R11, R12, R13, R14,
50 R15, R16,
51 TOT_REGS
52};
53
54struct upd64083_state {
55 u8 mode;
56 u8 ext_y_adc;
57 u8 regs[TOT_REGS];
58};
59
60/* Initial values when used in combination with the
61 NEC upd64031a ghost reduction chip. */
62static u8 upd64083_init[] = {
63 0x1f, 0x01, 0xa0, 0x2d, 0x29, /* we use EXCSS=0 */
64 0x36, 0xdd, 0x05, 0x56, 0x48,
65 0x00, 0x3a, 0xa0, 0x05, 0x08,
66 0x44, 0x60, 0x08, 0x52, 0xf8,
67 0x53, 0x60, 0x10
68};
69
70/* ------------------------------------------------------------------------ */
71
72static void upd64083_log_status(struct i2c_client *client)
73{
74 u8 buf[7];
75
76 i2c_master_recv(client, buf, 7);
77 v4l_info(client, "Status: SA00=%02x SA01=%02x SA02=%02x SA03=%02x "
78 "SA04=%02x SA05=%02x SA06=%02x\n",
79 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
80}
81
82/* ------------------------------------------------------------------------ */
83
84static void upd64083_write(struct i2c_client *client, u8 reg, u8 val)
85{
86 u8 buf[2];
87
88 buf[0] = reg;
89 buf[1] = val;
90 v4l_dbg(1, debug, client, "writing reg addr: %02x val: %02x\n", reg, val);
91 if (i2c_master_send(client, buf, 2) != 2)
92 v4l_err(client, "I/O error write 0x%02x/0x%02x\n", reg, val);
93}
94
95/* ------------------------------------------------------------------------ */
96
97#ifdef CONFIG_VIDEO_ADV_DEBUG
98static u8 upd64083_read(struct i2c_client *client, u8 reg)
99{
100 u8 buf[7];
101
102 if (reg >= sizeof(buf))
103 return 0xff;
104 i2c_master_recv(client, buf, sizeof(buf));
105 return buf[reg];
106}
107#endif
108
109/* ------------------------------------------------------------------------ */
110
111static int upd64083_command(struct i2c_client *client, unsigned int cmd, void *arg)
112{
113 struct upd64083_state *state = i2c_get_clientdata(client);
114 struct v4l2_routing *route = arg;
115
116 switch (cmd) {
117 case VIDIOC_INT_G_VIDEO_ROUTING:
118 route->input = (state->mode >> 6) | (state->ext_y_adc >> 3);
119 route->output = 0;
120 break;
121
122 case VIDIOC_INT_S_VIDEO_ROUTING:
123 {
124 u8 r00, r02;
125
126 if (route->input > 7 || (route->input & 6) == 6)
127 return -EINVAL;
128 state->mode = (route->input & 3) << 6;
129 state->ext_y_adc = (route->input & UPD64083_EXT_Y_ADC) << 3;
130 r00 = (state->regs[R00] & ~(3 << 6)) | state->mode;
131 r02 = (state->regs[R02] & ~(1 << 5)) | state->ext_y_adc;
132 upd64083_write(client, R00, r00);
133 upd64083_write(client, R02, r02);
134 break;
135 }
136
137 case VIDIOC_LOG_STATUS:
138 upd64083_log_status(client);
139 break;
140
141#ifdef CONFIG_VIDEO_ADV_DEBUG
142 case VIDIOC_INT_G_REGISTER:
143 {
144 struct v4l2_register *reg = arg;
145
146 if (reg->i2c_id != I2C_DRIVERID_UPD64083)
147 return -EINVAL;
148 reg->val = upd64083_read(client, reg->reg & 0xff);
149 break;
150 }
151
152 case VIDIOC_INT_S_REGISTER:
153 {
154 struct v4l2_register *reg = arg;
155 u8 addr = reg->reg & 0xff;
156 u8 val = reg->val & 0xff;
157
158 if (reg->i2c_id != I2C_DRIVERID_UPD64083)
159 return -EINVAL;
160 if (!capable(CAP_SYS_ADMIN))
161 return -EPERM;
162 upd64083_write(client, addr, val);
163 break;
164 }
165#endif
166 default:
167 break;
168 }
169
170 return 0;
171}
172
173/* ------------------------------------------------------------------------ */
174
175/* i2c implementation */
176
177static struct i2c_driver i2c_driver;
178
179static int upd64083_attach(struct i2c_adapter *adapter, int address, int kind)
180{
181 struct i2c_client *client;
182 struct upd64083_state *state;
183 int i;
184
185 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
186 return 0;
187
188 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
189 if (client == NULL) {
190 return -ENOMEM;
191 }
192
193 client->addr = address;
194 client->adapter = adapter;
195 client->driver = &i2c_driver;
196 snprintf(client->name, sizeof(client->name) - 1, "uPD64083");
197
198 v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name);
199
200 state = kmalloc(sizeof(struct upd64083_state), GFP_KERNEL);
201 if (state == NULL) {
202 kfree(client);
203 return -ENOMEM;
204 }
205 i2c_set_clientdata(client, state);
206 /* Initially assume that a ghost reduction chip is present */
207 state->mode = 0; /* YCS mode */
208 state->ext_y_adc = (1 << 5);
209 memcpy(state->regs, upd64083_init, TOT_REGS);
210 for (i = 0; i < TOT_REGS; i++) {
211 upd64083_write(client, i, state->regs[i]);
212 }
213 i2c_attach_client(client);
214
215 return 0;
216}
217
218static int upd64083_probe(struct i2c_adapter *adapter)
219{
220 if (adapter->class & I2C_CLASS_TV_ANALOG)
221 return i2c_probe(adapter, &addr_data, upd64083_attach);
222 return 0;
223}
224
225static int upd64083_detach(struct i2c_client *client)
226{
227 int err;
228
229 err = i2c_detach_client(client);
230 if (err)
231 return err;
232
233 kfree(client);
234 return 0;
235}
236
237/* ----------------------------------------------------------------------- */
238
239/* i2c implementation */
240static struct i2c_driver i2c_driver = {
241 .driver = {
242 .name = "upd64083",
243 },
244 .id = I2C_DRIVERID_UPD64083,
245 .attach_adapter = upd64083_probe,
246 .detach_client = upd64083_detach,
247 .command = upd64083_command,
248};
249
250
251static int __init upd64083_init_module(void)
252{
253 return i2c_add_driver(&i2c_driver);
254}
255
256static void __exit upd64083_exit_module(void)
257{
258 i2c_del_driver(&i2c_driver);
259}
260
261module_init(upd64083_init_module);
262module_exit(upd64083_exit_module);
diff --git a/drivers/media/video/usbvideo/Kconfig b/drivers/media/video/usbvideo/Kconfig
new file mode 100644
index 000000000000..08a5d20bb2c0
--- /dev/null
+++ b/drivers/media/video/usbvideo/Kconfig
@@ -0,0 +1,38 @@
1config VIDEO_USBVIDEO
2 tristate
3
4config USB_VICAM
5 tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)"
6 depends on USB && VIDEO_DEV && EXPERIMENTAL
7 select VIDEO_USBVIDEO
8 ---help---
9 Say Y here if you have 3com homeconnect camera (vicam).
10
11 To compile this driver as a module, choose M here: the
12 module will be called vicam.
13
14config USB_IBMCAM
15 tristate "USB IBM (Xirlink) C-it Camera support"
16 depends on USB && VIDEO_DEV
17 select VIDEO_USBVIDEO
18 ---help---
19 Say Y here if you want to connect a IBM "C-It" camera, also known as
20 "Xirlink PC Camera" to your computer's USB port.
21
22 To compile this driver as a module, choose M here: the
23 module will be called ibmcam.
24
25 This camera has several configuration options which
26 can be specified when you load the module. Read
27 <file:Documentation/video4linux/ibmcam.txt> to learn more.
28
29config USB_KONICAWC
30 tristate "USB Konica Webcam support"
31 depends on USB && VIDEO_DEV
32 select VIDEO_USBVIDEO
33 ---help---
34 Say Y here if you want support for webcams based on a Konica
35 chipset. This is known to work with the Intel YC76 webcam.
36
37 To compile this driver as a module, choose M here: the
38 module will be called konicawc.
diff --git a/drivers/media/video/usbvideo/Makefile b/drivers/media/video/usbvideo/Makefile
index ed410a5ee8c9..bb52eb8dc2f9 100644
--- a/drivers/media/video/usbvideo/Makefile
+++ b/drivers/media/video/usbvideo/Makefile
@@ -1,4 +1,4 @@
1obj-$(CONFIG_USB_IBMCAM) += ibmcam.o usbvideo.o ultracam.o 1obj-$(CONFIG_VIDEO_USBVIDEO) += usbvideo.o
2obj-$(CONFIG_USB_KONICAWC) += konicawc.o usbvideo.o 2obj-$(CONFIG_USB_IBMCAM) += ibmcam.o ultracam.o
3obj-$(CONFIG_USB_VICAM) += vicam.o usbvideo.o 3obj-$(CONFIG_USB_KONICAWC) += konicawc.o
4 4obj-$(CONFIG_USB_VICAM) += vicam.o
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 11a97f30b876..d330fa985bcc 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -317,6 +317,7 @@ static const char *v4l2_int_ioctls[] = {
317 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", 317 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
318 [_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG", 318 [_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG",
319 319
320 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
320 [_IOC_NR(VIDIOC_INT_S_REGISTER)] = "VIDIOC_INT_S_REGISTER", 321 [_IOC_NR(VIDIOC_INT_S_REGISTER)] = "VIDIOC_INT_S_REGISTER",
321 [_IOC_NR(VIDIOC_INT_G_REGISTER)] = "VIDIOC_INT_G_REGISTER", 322 [_IOC_NR(VIDIOC_INT_G_REGISTER)] = "VIDIOC_INT_G_REGISTER",
322 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET", 323 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
@@ -325,7 +326,12 @@ static const char *v4l2_int_ioctls[] = {
325 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA", 326 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
326 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA", 327 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
327 [_IOC_NR(VIDIOC_INT_G_CHIP_IDENT)] = "VIDIOC_INT_G_CHIP_IDENT", 328 [_IOC_NR(VIDIOC_INT_G_CHIP_IDENT)] = "VIDIOC_INT_G_CHIP_IDENT",
328 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ" 329 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
330 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
331 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
332 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
333 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
334 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING"
329}; 335};
330#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls) 336#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
331 337
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index d2ca0f08d0df..acc5ea936687 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -399,19 +399,25 @@ void videobuf_queue_pci(struct videobuf_queue* q)
399int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma) 399int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma)
400{ 400{
401 struct videobuf_queue q; 401 struct videobuf_queue q;
402 struct videobuf_queue_ops qops;
402 403
403 q.dev=pci; 404 q.dev=pci;
404 q.ops->vb_map_sg=(vb_map_sg_t *)pci_unmap_sg; 405 qops.vb_map_sg=(vb_map_sg_t *)pci_map_sg;
406 qops.vb_unmap_sg=(vb_map_sg_t *)pci_unmap_sg;
407 q.ops = &qops;
405 408
406 return (videobuf_dma_unmap(&q,dma)); 409 return (videobuf_dma_map(&q,dma));
407} 410}
408 411
409int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma) 412int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma)
410{ 413{
411 struct videobuf_queue q; 414 struct videobuf_queue q;
415 struct videobuf_queue_ops qops;
412 416
413 q.dev=pci; 417 q.dev=pci;
414 q.ops->vb_map_sg=(vb_map_sg_t *)pci_unmap_sg; 418 qops.vb_map_sg=(vb_map_sg_t *)pci_map_sg;
419 qops.vb_unmap_sg=(vb_map_sg_t *)pci_unmap_sg;
420 q.ops = &qops;
415 421
416 return (videobuf_dma_unmap(&q,dma)); 422 return (videobuf_dma_unmap(&q,dma));
417} 423}
@@ -923,7 +929,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
923 /* need to capture a new frame */ 929 /* need to capture a new frame */
924 retval = -ENOMEM; 930 retval = -ENOMEM;
925 q->read_buf = videobuf_alloc(q->msize); 931 q->read_buf = videobuf_alloc(q->msize);
926 dprintk(1,"video alloc=0x%08x\n",(unsigned int) q->read_buf); 932 dprintk(1,"video alloc=0x%p\n", q->read_buf);
927 if (NULL == q->read_buf) 933 if (NULL == q->read_buf)
928 goto done; 934 goto done;
929 q->read_buf->memory = V4L2_MEMORY_USERPTR; 935 q->read_buf->memory = V4L2_MEMORY_USERPTR;
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
new file mode 100644
index 000000000000..a9b59c35cd67
--- /dev/null
+++ b/drivers/media/video/wm8739.c
@@ -0,0 +1,355 @@
1/*
2 * wm8739
3 *
4 * Copyright (C) 2005 T. Adachi <tadachi@tadachi-net.com>
5 *
6 * Copyright (C) 2005 Hans Verkuil <hverkuil@xs4all.nl>
7 * - Cleanup
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/module.h>
25#include <linux/types.h>
26#include <linux/ioctl.h>
27#include <asm/uaccess.h>
28#include <linux/i2c.h>
29#include <linux/i2c-id.h>
30#include <linux/videodev.h>
31#include <media/v4l2-common.h>
32
33MODULE_DESCRIPTION("wm8739 driver");
34MODULE_AUTHOR("T. Adachi, Hans Verkuil");
35MODULE_LICENSE("GPL");
36
37static int debug = 0;
38static unsigned short normal_i2c[] = { 0x34 >> 1, 0x36 >> 1, I2C_CLIENT_END };
39
40module_param(debug, int, 0644);
41
42MODULE_PARM_DESC(debug, "Debug level (0-1)");
43
44
45I2C_CLIENT_INSMOD;
46
47/* ------------------------------------------------------------------------ */
48
49enum {
50 R0 = 0, R1,
51 R5 = 5, R6, R7, R8, R9, R15 = 15,
52 TOT_REGS
53};
54
55struct wm8739_state {
56 u32 clock_freq;
57 u8 muted;
58 u16 volume;
59 u16 balance;
60 u8 vol_l; /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */
61 u8 vol_r; /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */
62};
63
64/* ------------------------------------------------------------------------ */
65
66static int wm8739_write(struct i2c_client *client, int reg, u16 val)
67{
68 int i;
69
70 if (reg < 0 || reg >= TOT_REGS) {
71 v4l_err(client, "Invalid register R%d\n", reg);
72 return -1;
73 }
74
75 v4l_dbg(1, debug, client, "write: %02x %02x\n", reg, val);
76
77 for (i = 0; i < 3; i++) {
78 if (i2c_smbus_write_byte_data(client, (reg << 1) |
79 (val >> 8), val & 0xff) == 0) {
80 return 0;
81 }
82 }
83 v4l_err(client, "I2C: cannot write %03x to register R%d\n", val, reg);
84 return -1;
85}
86
87/* write regs to set audio volume etc */
88static void wm8739_set_audio(struct i2c_client *client)
89{
90 struct wm8739_state *state = i2c_get_clientdata(client);
91 u16 mute = state->muted ? 0x80 : 0;
92
93 /* Volume setting: bits 0-4, 0x1f = 12 dB, 0x00 = -34.5 dB
94 * Default setting: 0x17 = 0 dB
95 */
96 wm8739_write(client, R0, (state->vol_l & 0x1f) | mute);
97 wm8739_write(client, R1, (state->vol_r & 0x1f) | mute);
98}
99
100static int wm8739_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
101{
102 struct wm8739_state *state = i2c_get_clientdata(client);
103
104 switch (ctrl->id) {
105 case V4L2_CID_AUDIO_MUTE:
106 ctrl->value = state->muted;
107 break;
108
109 case V4L2_CID_AUDIO_VOLUME:
110 ctrl->value = state->volume;
111 break;
112
113 case V4L2_CID_AUDIO_BALANCE:
114 ctrl->value = state->balance;
115 break;
116
117 default:
118 return -EINVAL;
119 }
120 return 0;
121}
122
123static int wm8739_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
124{
125 struct wm8739_state *state = i2c_get_clientdata(client);
126 unsigned int work_l, work_r;
127
128 switch (ctrl->id) {
129 case V4L2_CID_AUDIO_MUTE:
130 state->muted = ctrl->value;
131 break;
132
133 case V4L2_CID_AUDIO_VOLUME:
134 state->volume = ctrl->value;
135 break;
136
137 case V4L2_CID_AUDIO_BALANCE:
138 state->balance = ctrl->value;
139 break;
140
141 default:
142 return -EINVAL;
143 }
144
145 /* normalize ( 65535 to 0 -> 31 to 0 (12dB to -34.5dB) ) */
146 work_l = (min(65536 - state->balance, 32768) * state->volume) / 32768;
147 work_r = (min(state->balance, (u16)32768) * state->volume) / 32768;
148
149 state->vol_l = (long)work_l * 31 / 65535;
150 state->vol_r = (long)work_r * 31 / 65535;
151
152 /* set audio volume etc. */
153 wm8739_set_audio(client);
154 return 0;
155}
156
157/* ------------------------------------------------------------------------ */
158
159static struct v4l2_queryctrl wm8739_qctrl[] = {
160 {
161 .id = V4L2_CID_AUDIO_VOLUME,
162 .name = "Volume",
163 .minimum = 0,
164 .maximum = 65535,
165 .step = 65535/100,
166 .default_value = 58880,
167 .flags = 0,
168 .type = V4L2_CTRL_TYPE_INTEGER,
169 },{
170 .id = V4L2_CID_AUDIO_MUTE,
171 .name = "Mute",
172 .minimum = 0,
173 .maximum = 1,
174 .step = 1,
175 .default_value = 1,
176 .flags = 0,
177 .type = V4L2_CTRL_TYPE_BOOLEAN,
178 },{
179 .id = V4L2_CID_AUDIO_BALANCE,
180 .name = "Balance",
181 .minimum = 0,
182 .maximum = 65535,
183 .step = 65535/100,
184 .default_value = 32768,
185 .flags = 0,
186 .type = V4L2_CTRL_TYPE_INTEGER,
187 }
188};
189
190/* ------------------------------------------------------------------------ */
191
192static int wm8739_command(struct i2c_client *client, unsigned int cmd, void *arg)
193{
194 struct wm8739_state *state = i2c_get_clientdata(client);
195
196 switch (cmd) {
197 case VIDIOC_INT_AUDIO_CLOCK_FREQ:
198 {
199 u32 audiofreq = *(u32 *)arg;
200
201 state->clock_freq = audiofreq;
202 wm8739_write(client, R9, 0x000); /* de-activate */
203 switch (audiofreq) {
204 case 44100:
205 wm8739_write(client, R8, 0x020); /* 256fps, fs=44.1k */
206 break;
207 case 48000:
208 wm8739_write(client, R8, 0x000); /* 256fps, fs=48k */
209 break;
210 case 32000:
211 wm8739_write(client, R8, 0x018); /* 256fps, fs=32k */
212 break;
213 default:
214 break;
215 }
216 wm8739_write(client, R9, 0x001); /* activate */
217 break;
218 }
219
220 case VIDIOC_G_CTRL:
221 return wm8739_get_ctrl(client, arg);
222
223 case VIDIOC_S_CTRL:
224 return wm8739_set_ctrl(client, arg);
225
226 case VIDIOC_QUERYCTRL:
227 {
228 struct v4l2_queryctrl *qc = arg;
229 int i;
230
231 for (i = 0; i < ARRAY_SIZE(wm8739_qctrl); i++)
232 if (qc->id && qc->id == wm8739_qctrl[i].id) {
233 memcpy(qc, &wm8739_qctrl[i], sizeof(*qc));
234 return 0;
235 }
236 return -EINVAL;
237 }
238
239 case VIDIOC_LOG_STATUS:
240 v4l_info(client, "Frequency: %u Hz\n", state->clock_freq);
241 v4l_info(client, "Volume L: %02x%s\n", state->vol_l & 0x1f,
242 state->muted ? " (muted)" : "");
243 v4l_info(client, "Volume R: %02x%s\n", state->vol_r & 0x1f,
244 state->muted ? " (muted)" : "");
245 break;
246
247 default:
248 return -EINVAL;
249 }
250
251 return 0;
252}
253
254/* ------------------------------------------------------------------------ */
255
256/* i2c implementation */
257
258static struct i2c_driver i2c_driver;
259
260static int wm8739_attach(struct i2c_adapter *adapter, int address, int kind)
261{
262 struct i2c_client *client;
263 struct wm8739_state *state;
264
265 /* Check if the adapter supports the needed features */
266 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
267 return 0;
268
269 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
270 if (client == NULL)
271 return -ENOMEM;
272
273 client->addr = address;
274 client->adapter = adapter;
275 client->driver = &i2c_driver;
276 snprintf(client->name, sizeof(client->name) - 1, "wm8739");
277
278 v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name);
279
280 state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL);
281 if (state == NULL) {
282 kfree(client);
283 return -ENOMEM;
284 }
285 state->vol_l = 0x17; /* 0dB */
286 state->vol_r = 0x17; /* 0dB */
287 state->muted = 0;
288 state->balance = 32768;
289 /* normalize (12dB(31) to -34.5dB(0) [0dB(23)] -> 65535 to 0) */
290 state->volume = ((long)state->vol_l + 1) * 65535 / 31;
291 state->clock_freq = 48000;
292 i2c_set_clientdata(client, state);
293
294 /* initialize wm8739 */
295 wm8739_write(client, R15, 0x00); /* reset */
296 wm8739_write(client, R5, 0x000); /* filter setting, high path, offet clear */
297 wm8739_write(client, R6, 0x000); /* ADC, OSC, Power Off mode Disable */
298 wm8739_write(client, R7, 0x049); /* Digital Audio interface format */
299 /* Enable Master mode */
300 /* 24 bit, MSB first/left justified */
301 wm8739_write(client, R8, 0x000); /* sampling control */
302 /* normal, 256fs, 48KHz sampling rate */
303 wm8739_write(client, R9, 0x001); /* activate */
304 wm8739_set_audio(client); /* set volume/mute */
305
306 i2c_attach_client(client);
307
308 return 0;
309}
310
311static int wm8739_probe(struct i2c_adapter *adapter)
312{
313 if (adapter->class & I2C_CLASS_TV_ANALOG)
314 return i2c_probe(adapter, &addr_data, wm8739_attach);
315 return 0;
316}
317
318static int wm8739_detach(struct i2c_client *client)
319{
320 int err;
321
322 err = i2c_detach_client(client);
323 if (err)
324 return err;
325
326 kfree(client);
327 return 0;
328}
329
330/* ----------------------------------------------------------------------- */
331
332/* i2c implementation */
333static struct i2c_driver i2c_driver = {
334 .driver = {
335 .name = "wm8739",
336 },
337 .id = I2C_DRIVERID_WM8739,
338 .attach_adapter = wm8739_probe,
339 .detach_client = wm8739_detach,
340 .command = wm8739_command,
341};
342
343
344static int __init wm8739_init_module(void)
345{
346 return i2c_add_driver(&i2c_driver);
347}
348
349static void __exit wm8739_cleanup_module(void)
350{
351 i2c_del_driver(&i2c_driver);
352}
353
354module_init(wm8739_init_module);
355module_exit(wm8739_cleanup_module);
diff --git a/drivers/media/video/zc0301/Kconfig b/drivers/media/video/zc0301/Kconfig
new file mode 100644
index 000000000000..c3bf886b80cd
--- /dev/null
+++ b/drivers/media/video/zc0301/Kconfig
@@ -0,0 +1,11 @@
1config USB_ZC0301
2 tristate "USB ZC0301 Image Processor and Control Chip support"
3 depends on USB && VIDEO_DEV
4 ---help---
5 Say Y here if you want support for cameras based on the ZC0301
6 Image Processor and Control Chip.
7
8 See <file:Documentation/video4linux/zc0301.txt> for more info.
9
10 To compile this driver as a module, choose M here: the
11 module will be called zc0301.