aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/common/ir-common.c39
-rw-r--r--drivers/media/video/bt832.c50
-rw-r--r--drivers/media/video/bt832.h36
-rw-r--r--drivers/media/video/msp3400.c13
-rw-r--r--drivers/media/video/msp3400.h4
-rw-r--r--drivers/media/video/tda7432.c1
-rw-r--r--drivers/media/video/tda9875.c1
-rw-r--r--drivers/media/video/tda9887.c41
-rw-r--r--drivers/media/video/tuner-core.c212
-rw-r--r--drivers/media/video/tuner-simple.c52
-rw-r--r--drivers/media/video/tvaudio.c2
-rw-r--r--drivers/media/video/tvmixer.c4
-rw-r--r--include/media/audiochip.h4
-rw-r--r--include/media/id.h4
-rw-r--r--include/media/ir-common.h2
-rw-r--r--include/media/tuner.h23
16 files changed, 333 insertions, 155 deletions
diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c
index e5636ef181bb..4adb2843f8be 100644
--- a/drivers/media/common/ir-common.c
+++ b/drivers/media/common/ir-common.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ir-common.c,v 1.8 2005/02/22 12:28:40 kraxel Exp $ 2 * $Id: ir-common.c,v 1.10 2005/05/22 19:23:39 nsh Exp $
3 * 3 *
4 * some common structs and functions to handle infrared remotes via 4 * some common structs and functions to handle infrared remotes via
5 * input layer ... 5 * input layer ...
@@ -131,10 +131,10 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
131 [ 18 ] = KEY_KP0, 131 [ 18 ] = KEY_KP0,
132 132
133 [ 0 ] = KEY_POWER, 133 [ 0 ] = KEY_POWER,
134 [ 27 ] = KEY_LANGUAGE, //MTS button 134// [ 27 ] = MTS button
135 [ 2 ] = KEY_TUNER, // TV/FM 135 [ 2 ] = KEY_TUNER, // TV/FM
136 [ 30 ] = KEY_VIDEO, 136 [ 30 ] = KEY_VIDEO,
137 [ 22 ] = KEY_INFO, //display button 137// [ 22 ] = display button
138 [ 4 ] = KEY_VOLUMEUP, 138 [ 4 ] = KEY_VOLUMEUP,
139 [ 8 ] = KEY_VOLUMEDOWN, 139 [ 8 ] = KEY_VOLUMEDOWN,
140 [ 12 ] = KEY_CHANNELUP, 140 [ 12 ] = KEY_CHANNELUP,
@@ -142,7 +142,7 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
142 [ 3 ] = KEY_ZOOM, // fullscreen 142 [ 3 ] = KEY_ZOOM, // fullscreen
143 [ 31 ] = KEY_SUBTITLE, // closed caption/teletext 143 [ 31 ] = KEY_SUBTITLE, // closed caption/teletext
144 [ 32 ] = KEY_SLEEP, 144 [ 32 ] = KEY_SLEEP,
145 [ 41 ] = KEY_SEARCH, //boss key 145// [ 41 ] = boss key
146 [ 20 ] = KEY_MUTE, 146 [ 20 ] = KEY_MUTE,
147 [ 43 ] = KEY_RED, 147 [ 43 ] = KEY_RED,
148 [ 44 ] = KEY_GREEN, 148 [ 44 ] = KEY_GREEN,
@@ -150,17 +150,17 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
150 [ 46 ] = KEY_BLUE, 150 [ 46 ] = KEY_BLUE,
151 [ 24 ] = KEY_KPPLUS, //fine tune + 151 [ 24 ] = KEY_KPPLUS, //fine tune +
152 [ 25 ] = KEY_KPMINUS, //fine tune - 152 [ 25 ] = KEY_KPMINUS, //fine tune -
153 [ 42 ] = KEY_ANGLE, //picture in picture 153// [ 42 ] = picture in picture
154 [ 33 ] = KEY_KPDOT, 154 [ 33 ] = KEY_KPDOT,
155 [ 19 ] = KEY_KPENTER, 155 [ 19 ] = KEY_KPENTER,
156 [ 17 ] = KEY_AGAIN, //recall 156// [ 17 ] = recall
157 [ 34 ] = KEY_BACK, 157 [ 34 ] = KEY_BACK,
158 [ 35 ] = KEY_PLAYPAUSE, 158 [ 35 ] = KEY_PLAYPAUSE,
159 [ 36 ] = KEY_NEXT, 159 [ 36 ] = KEY_NEXT,
160 [ 37 ] = KEY_T, //time shifting 160// [ 37 ] = time shifting
161 [ 38 ] = KEY_STOP, 161 [ 38 ] = KEY_STOP,
162 [ 39 ] = KEY_RECORD, 162 [ 39 ] = KEY_RECORD
163 [ 40 ] = KEY_SHUFFLE //snapshot 163// [ 40 ] = snapshot
164}; 164};
165EXPORT_SYMBOL_GPL(ir_codes_winfast); 165EXPORT_SYMBOL_GPL(ir_codes_winfast);
166 166
@@ -184,18 +184,30 @@ IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE] = {
184 [ 0x07 ] = KEY_KP7, // 7 184 [ 0x07 ] = KEY_KP7, // 7
185 [ 0x08 ] = KEY_KP8, // 8 185 [ 0x08 ] = KEY_KP8, // 8
186 [ 0x09 ] = KEY_KP9, // 9 186 [ 0x09 ] = KEY_KP9, // 9
187 [ 0x0a ] = KEY_TEXT, // keypad asterisk as well
187 [ 0x0b ] = KEY_RED, // red button 188 [ 0x0b ] = KEY_RED, // red button
188 [ 0x0c ] = KEY_OPTION, // black key without text 189 [ 0x0c ] = KEY_RADIO, // radio
189 [ 0x0d ] = KEY_MENU, // menu 190 [ 0x0d ] = KEY_MENU, // menu
191 [ 0x0e ] = KEY_SUBTITLE, // also the # key
190 [ 0x0f ] = KEY_MUTE, // mute 192 [ 0x0f ] = KEY_MUTE, // mute
191 [ 0x10 ] = KEY_VOLUMEUP, // volume + 193 [ 0x10 ] = KEY_VOLUMEUP, // volume +
192 [ 0x11 ] = KEY_VOLUMEDOWN, // volume - 194 [ 0x11 ] = KEY_VOLUMEDOWN, // volume -
193 [ 0x1e ] = KEY_NEXT, // skip >| 195 [ 0x12 ] = KEY_PREVIOUS, // previous channel
196 [ 0x14 ] = KEY_UP, // up
197 [ 0x15 ] = KEY_DOWN, // down
198 [ 0x16 ] = KEY_LEFT, // left
199 [ 0x17 ] = KEY_RIGHT, // right
200 [ 0x18 ] = KEY_VIDEO, // Videos
201 [ 0x19 ] = KEY_AUDIO, // Music
202 [ 0x1a ] = KEY_MHP, // Pictures - presume this means "Multimedia Home Platform"- no "PICTURES" key in input.h
203 [ 0x1b ] = KEY_EPG, // Guide
204 [ 0x1c ] = KEY_TV, // TV
205 [ 0x1e ] = KEY_NEXTSONG, // skip >|
194 [ 0x1f ] = KEY_EXIT, // back/exit 206 [ 0x1f ] = KEY_EXIT, // back/exit
195 [ 0x20 ] = KEY_CHANNELUP, // channel / program + 207 [ 0x20 ] = KEY_CHANNELUP, // channel / program +
196 [ 0x21 ] = KEY_CHANNELDOWN, // channel / program - 208 [ 0x21 ] = KEY_CHANNELDOWN, // channel / program -
197 [ 0x22 ] = KEY_CHANNEL, // source (old black remote) 209 [ 0x22 ] = KEY_CHANNEL, // source (old black remote)
198 [ 0x24 ] = KEY_PREVIOUS, // replay |< 210 [ 0x24 ] = KEY_PREVIOUSSONG, // replay |<
199 [ 0x25 ] = KEY_ENTER, // OK 211 [ 0x25 ] = KEY_ENTER, // OK
200 [ 0x26 ] = KEY_SLEEP, // minimize (old black remote) 212 [ 0x26 ] = KEY_SLEEP, // minimize (old black remote)
201 [ 0x29 ] = KEY_BLUE, // blue key 213 [ 0x29 ] = KEY_BLUE, // blue key
@@ -412,3 +424,4 @@ EXPORT_SYMBOL_GPL(ir_decode_biphase);
412 * c-basic-offset: 8 424 * c-basic-offset: 8
413 * End: 425 * End:
414 */ 426 */
427
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c
index 07f72f64c5f7..3bb347d93b9b 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt832.c
@@ -6,7 +6,7 @@
6 It outputs an 8-bit 4:2:2 YUV or YCrCb video signal which can be directly 6 It outputs an 8-bit 4:2:2 YUV or YCrCb video signal which can be directly
7 connected to bt848/bt878 GPIO pins on this purpose. 7 connected to bt848/bt878 GPIO pins on this purpose.
8 (see: VLSI Vision Ltd. www.vvl.co.uk for camera datasheets) 8 (see: VLSI Vision Ltd. www.vvl.co.uk for camera datasheets)
9 9
10 Supported Cards: 10 Supported Cards:
11 - Pixelview Rev.4E: 0x8a 11 - Pixelview Rev.4E: 0x8a
12 GPIO 0x400000 toggles Bt832 RESET, and the chip changes to i2c 0x88 ! 12 GPIO 0x400000 toggles Bt832 RESET, and the chip changes to i2c 0x88 !
@@ -31,16 +31,16 @@
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33 33
34#include "id.h" 34#include <media/audiochip.h>
35#include "audiochip.h" 35#include <media/id.h>
36#include "bttv.h" 36#include "bttv.h"
37#include "bt832.h" 37#include "bt832.h"
38 38
39MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
40 40
41/* Addresses to scan */ 41/* Addresses to scan */
42static unsigned short normal_i2c[] = { I2C_BT832_ALT1>>1, I2C_BT832_ALT2>>1, 42static unsigned short normal_i2c[] = {I2C_CLIENT_END};
43 I2C_CLIENT_END }; 43static unsigned short normal_i2c_range[] = {I2C_BT832_ALT1>>1,I2C_BT832_ALT2>>1,I2C_CLIENT_END};
44I2C_CLIENT_INSMOD; 44I2C_CLIENT_INSMOD;
45 45
46/* ---------------------------------------------------------------------- */ 46/* ---------------------------------------------------------------------- */
@@ -95,7 +95,7 @@ int bt832_init(struct i2c_client *i2c_client_s)
95 95
96 buf=kmalloc(65,GFP_KERNEL); 96 buf=kmalloc(65,GFP_KERNEL);
97 bt832_hexdump(i2c_client_s,buf); 97 bt832_hexdump(i2c_client_s,buf);
98 98
99 if(buf[0x40] != 0x31) { 99 if(buf[0x40] != 0x31) {
100 printk("bt832: this i2c chip is no bt832 (id=%02x). Detaching.\n",buf[0x40]); 100 printk("bt832: this i2c chip is no bt832 (id=%02x). Detaching.\n",buf[0x40]);
101 kfree(buf); 101 kfree(buf);
@@ -135,7 +135,7 @@ int bt832_init(struct i2c_client *i2c_client_s)
135 buf[1]= 0x27 & (~0x01); // Default | !skip 135 buf[1]= 0x27 & (~0x01); // Default | !skip
136 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 136 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
137 printk("bt832: i2c i/o error EO: rc == %d (should be 2)\n",rc); 137 printk("bt832: i2c i/o error EO: rc == %d (should be 2)\n",rc);
138 138
139 bt832_hexdump(i2c_client_s,buf); 139 bt832_hexdump(i2c_client_s,buf);
140 140
141#if 0 141#if 0
@@ -168,8 +168,7 @@ int bt832_init(struct i2c_client *i2c_client_s)
168 168
169 169
170 170
171static int bt832_attach(struct i2c_adapter *adap, int addr, 171static int bt832_attach(struct i2c_adapter *adap, int addr, int kind)
172 unsigned short flags, int kind)
173{ 172{
174 struct bt832 *t; 173 struct bt832 *t;
175 174
@@ -184,27 +183,32 @@ static int bt832_attach(struct i2c_adapter *adap, int addr,
184 return -ENOMEM; 183 return -ENOMEM;
185 memset(t,0,sizeof(*t)); 184 memset(t,0,sizeof(*t));
186 t->client = client_template; 185 t->client = client_template;
187 t->client.data = t; 186 i2c_set_clientdata(&t->client, t);
188 i2c_attach_client(&t->client); 187 i2c_attach_client(&t->client);
189 188
190 if(! bt832_init(&t->client)) { 189 if(! bt832_init(&t->client)) {
191 bt832_detach(&t->client); 190 bt832_detach(&t->client);
192 return -1; 191 return -1;
193 } 192 }
194 193
195 return 0; 194 return 0;
196} 195}
197 196
198static int bt832_probe(struct i2c_adapter *adap) 197static int bt832_probe(struct i2c_adapter *adap)
199{ 198{
199#ifdef I2C_CLASS_TV_ANALOG
200 if (adap->class & I2C_CLASS_TV_ANALOG) 200 if (adap->class & I2C_CLASS_TV_ANALOG)
201 return i2c_probe(adap, &addr_data, bt832_attach); 201 return i2c_probe(adap, &addr_data, bt832_attach);
202#else
203 if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
204 return i2c_probe(adap, &addr_data, bt832_attach);
205#endif
202 return 0; 206 return 0;
203} 207}
204 208
205static int bt832_detach(struct i2c_client *client) 209static int bt832_detach(struct i2c_client *client)
206{ 210{
207 struct bt832 *t = (struct bt832*)client->data; 211 struct bt832 *t = i2c_get_clientdata(client);
208 212
209 printk("bt832: detach.\n"); 213 printk("bt832: detach.\n");
210 i2c_detach_client(client); 214 i2c_detach_client(client);
@@ -215,7 +219,7 @@ static int bt832_detach(struct i2c_client *client)
215static int 219static int
216bt832_command(struct i2c_client *client, unsigned int cmd, void *arg) 220bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
217{ 221{
218 struct bt832 *t = (struct bt832*)client->data; 222 struct bt832 *t = i2c_get_clientdata(client);
219 223
220 printk("bt832: command %x\n",cmd); 224 printk("bt832: command %x\n",cmd);
221 225
@@ -249,19 +253,18 @@ static struct i2c_driver driver = {
249}; 253};
250static struct i2c_client client_template = 254static struct i2c_client client_template =
251{ 255{
252 .name = "bt832", 256 I2C_DEVNAME("bt832"),
253 .flags = I2C_CLIENT_ALLOW_USE, 257 .flags = I2C_CLIENT_ALLOW_USE,
254 .driver = &driver, 258 .driver = &driver,
255}; 259};
256 260
257 261
258int bt832_init_module(void) 262static int __init bt832_init_module(void)
259{ 263{
260 i2c_add_driver(&driver); 264 return i2c_add_driver(&driver);
261 return 0;
262} 265}
263 266
264static void bt832_cleanup_module(void) 267static void __exit bt832_cleanup_module(void)
265{ 268{
266 i2c_del_driver(&driver); 269 i2c_del_driver(&driver);
267} 270}
@@ -269,3 +272,10 @@ static void bt832_cleanup_module(void)
269module_init(bt832_init_module); 272module_init(bt832_init_module);
270module_exit(bt832_cleanup_module); 273module_exit(bt832_cleanup_module);
271 274
275/*
276 * Overrides for Emacs so that we follow Linus's tabbing style.
277 * ---------------------------------------------------------------------------
278 * Local variables:
279 * c-basic-offset: 8
280 * End:
281 */
diff --git a/drivers/media/video/bt832.h b/drivers/media/video/bt832.h
index 7a98c06e0e34..9b6a8d2c96b5 100644
--- a/drivers/media/video/bt832.h
+++ b/drivers/media/video/bt832.h
@@ -1,6 +1,6 @@
1/* Bt832 CMOS Camera Video Processor (VP) 1/* Bt832 CMOS Camera Video Processor (VP)
2 2
3 The Bt832 CMOS Camera Video Processor chip connects a Quartsight CMOS 3 The Bt832 CMOS Camera Video Processor chip connects a Quartsight CMOS
4 color digital camera directly to video capture devices via an 8-bit, 4 color digital camera directly to video capture devices via an 8-bit,
5 4:2:2 YUV or YCrCb video interface. 5 4:2:2 YUV or YCrCb video interface.
6 6
@@ -85,7 +85,7 @@
85#define BT832_DEVICE_ID 63 85#define BT832_DEVICE_ID 63
86# define BT832_DEVICE_ID__31 0x31 // Bt832 has ID 0x31 86# define BT832_DEVICE_ID__31 0x31 // Bt832 has ID 0x31
87 87
88/* STMicroelectronivcs VV5404 camera module 88/* STMicroelectronivcs VV5404 camera module
89 i2c: 0x20: sensor address 89 i2c: 0x20: sensor address
90 i2c: 0xa0: eeprom for ccd defect map 90 i2c: 0xa0: eeprom for ccd defect map
91 */ 91 */
@@ -256,26 +256,26 @@ For the CCIR-601 standards, the sampling is based on a static orthogonal samplin
256//=========================================================================== 256//===========================================================================
257// Timing generator SRAM table values for CCIR601 720x480 NTSC 257// Timing generator SRAM table values for CCIR601 720x480 NTSC
258//=========================================================================== 258//===========================================================================
259// For NTSC CCIR656 259// For NTSC CCIR656
260BYTE BtCard::SRAMTable_NTSC[] = 260BYTE BtCard::SRAMTable_NTSC[] =
261{ 261{
262 // SRAM Timing Table for NTSC 262 // SRAM Timing Table for NTSC
263 0x0c, 0xc0, 0x00, 263 0x0c, 0xc0, 0x00,
264 0x00, 0x90, 0xc2, 264 0x00, 0x90, 0xc2,
265 0x03, 0x10, 0x03, 265 0x03, 0x10, 0x03,
266 0x06, 0x10, 0x34, 266 0x06, 0x10, 0x34,
267 0x12, 0x12, 0x65, 267 0x12, 0x12, 0x65,
268 0x02, 0x13, 0x24, 268 0x02, 0x13, 0x24,
269 0x19, 0x00, 0x24, 269 0x19, 0x00, 0x24,
270 0x39, 0x00, 0x96, 270 0x39, 0x00, 0x96,
271 0x59, 0x08, 0x93, 271 0x59, 0x08, 0x93,
272 0x83, 0x08, 0x97, 272 0x83, 0x08, 0x97,
273 0x03, 0x50, 0x30, 273 0x03, 0x50, 0x30,
274 0xc0, 0x40, 0x30, 274 0xc0, 0x40, 0x30,
275 0x86, 0x01, 0x01, 275 0x86, 0x01, 0x01,
276 0xa6, 0x0d, 0x62, 276 0xa6, 0x0d, 0x62,
277 0x03, 0x11, 0x61, 277 0x03, 0x11, 0x61,
278 0x05, 0x37, 0x30, 278 0x05, 0x37, 0x30,
279 0xac, 0x21, 0x50 279 0xac, 0x21, 0x50
280}; 280};
281 281
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index 09464d624a6b..05b83faa9a02 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -147,6 +147,7 @@ static unsigned short normal_i2c[] = {
147 I2C_MSP3400C_ALT >> 1, 147 I2C_MSP3400C_ALT >> 1,
148 I2C_CLIENT_END 148 I2C_CLIENT_END
149}; 149};
150static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END};
150I2C_CLIENT_INSMOD; 151I2C_CLIENT_INSMOD;
151 152
152/* ----------------------------------------------------------------------- */ 153/* ----------------------------------------------------------------------- */
@@ -735,7 +736,6 @@ static int msp34xx_sleep(struct msp3400c *msp, int timeout)
735{ 736{
736 DECLARE_WAITQUEUE(wait, current); 737 DECLARE_WAITQUEUE(wait, current);
737 738
738again:
739 add_wait_queue(&msp->wq, &wait); 739 add_wait_queue(&msp->wq, &wait);
740 if (!kthread_should_stop()) { 740 if (!kthread_should_stop()) {
741 if (timeout < 0) { 741 if (timeout < 0) {
@@ -751,12 +751,9 @@ again:
751#endif 751#endif
752 } 752 }
753 } 753 }
754 754 if (current->flags & PF_FREEZE)
755 refrigerator(PF_FREEZE);
755 remove_wait_queue(&msp->wq, &wait); 756 remove_wait_queue(&msp->wq, &wait);
756
757 if (try_to_freeze(PF_FREEZE))
758 goto again;
759
760 return msp->restart; 757 return msp->restart;
761} 758}
762 759
@@ -1436,7 +1433,7 @@ static int msp_detach(struct i2c_client *client);
1436static int msp_probe(struct i2c_adapter *adap); 1433static int msp_probe(struct i2c_adapter *adap);
1437static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg); 1434static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg);
1438 1435
1439static int msp_suspend(struct device * dev, pm_message_t state, u32 level); 1436static int msp_suspend(struct device * dev, u32 state, u32 level);
1440static int msp_resume(struct device * dev, u32 level); 1437static int msp_resume(struct device * dev, u32 level);
1441 1438
1442static void msp_wake_thread(struct i2c_client *client); 1439static void msp_wake_thread(struct i2c_client *client);
@@ -1841,7 +1838,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
1841 return 0; 1838 return 0;
1842} 1839}
1843 1840
1844static int msp_suspend(struct device * dev, pm_message_t state, u32 level) 1841static int msp_suspend(struct device * dev, u32 state, u32 level)
1845{ 1842{
1846 struct i2c_client *c = container_of(dev, struct i2c_client, dev); 1843 struct i2c_client *c = container_of(dev, struct i2c_client, dev);
1847 1844
diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h
index d70a954e13aa..023f33056a4f 100644
--- a/drivers/media/video/msp3400.h
+++ b/drivers/media/video/msp3400.h
@@ -1,3 +1,7 @@
1/*
2 * $Id: msp3400.h,v 1.3 2005/06/12 04:19:19 mchehab Exp $
3 */
4
1#ifndef MSP3400_H 5#ifndef MSP3400_H
2#define MSP3400_H 6#define MSP3400_H
3 7
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index 07ba6d3ed08c..376a4a439e9b 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -74,6 +74,7 @@ static unsigned short normal_i2c[] = {
74 I2C_TDA7432 >> 1, 74 I2C_TDA7432 >> 1,
75 I2C_CLIENT_END, 75 I2C_CLIENT_END,
76}; 76};
77static unsigned short normal_i2c_range[] = { I2C_CLIENT_END, I2C_CLIENT_END };
77I2C_CLIENT_INSMOD; 78I2C_CLIENT_INSMOD;
78 79
79/* Structure of address and subaddresses for the tda7432 */ 80/* Structure of address and subaddresses for the tda7432 */
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index 97b113e070f3..4f1114c033a1 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -44,6 +44,7 @@ static unsigned short normal_i2c[] = {
44 I2C_TDA9875 >> 1, 44 I2C_TDA9875 >> 1,
45 I2C_CLIENT_END 45 I2C_CLIENT_END
46}; 46};
47static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
47I2C_CLIENT_INSMOD; 48I2C_CLIENT_INSMOD;
48 49
49/* This is a superset of the TDA9875 */ 50/* This is a superset of the TDA9875 */
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index 7e6e6dd966a2..33d6ee6cde48 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -33,6 +33,7 @@ static unsigned short normal_i2c[] = {
33 0x96 >>1, 33 0x96 >>1,
34 I2C_CLIENT_END, 34 I2C_CLIENT_END,
35}; 35};
36static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END};
36I2C_CLIENT_INSMOD; 37I2C_CLIENT_INSMOD;
37 38
38/* insmod options */ 39/* insmod options */
@@ -53,6 +54,7 @@ struct tda9887 {
53 unsigned int config; 54 unsigned int config;
54 unsigned int pinnacle_id; 55 unsigned int pinnacle_id;
55 unsigned int using_v4l2; 56 unsigned int using_v4l2;
57 unsigned int radio_mode;
56}; 58};
57 59
58struct tvnorm { 60struct tvnorm {
@@ -212,12 +214,22 @@ static struct tvnorm tvnorms[] = {
212 } 214 }
213}; 215};
214 216
215static struct tvnorm radio = { 217static struct tvnorm radio_stereo = {
216 .name = "radio", 218 .name = "Radio Stereo",
219 .b = ( cFmRadio |
220 cQSS ),
221 .c = ( cDeemphasisOFF |
222 cAudioGain6 ),
223 .e = ( cAudioIF_5_5 |
224 cRadioIF_38_90 ),
225};
226
227static struct tvnorm radio_mono = {
228 .name = "Radio Mono",
217 .b = ( cFmRadio | 229 .b = ( cFmRadio |
218 cQSS ), 230 cQSS ),
219 .c = ( cDeemphasisON | 231 .c = ( cDeemphasisON |
220 cDeemphasis50 ), 232 cDeemphasis50),
221 .e = ( cAudioIF_5_5 | 233 .e = ( cAudioIF_5_5 |
222 cRadioIF_38_90 ), 234 cRadioIF_38_90 ),
223}; 235};
@@ -354,7 +366,10 @@ static int tda9887_set_tvnorm(struct tda9887 *t, char *buf)
354 int i; 366 int i;
355 367
356 if (t->radio) { 368 if (t->radio) {
357 norm = &radio; 369 if (t->radio_mode == V4L2_TUNER_MODE_MONO)
370 norm = &radio_mono;
371 else
372 norm = &radio_stereo;
358 } else { 373 } else {
359 for (i = 0; i < ARRAY_SIZE(tvnorms); i++) { 374 for (i = 0; i < ARRAY_SIZE(tvnorms); i++) {
360 if (tvnorms[i].std & t->std) { 375 if (tvnorms[i].std & t->std) {
@@ -545,11 +560,14 @@ static int tda9887_configure(struct tda9887 *t)
545 560
546 memset(buf,0,sizeof(buf)); 561 memset(buf,0,sizeof(buf));
547 tda9887_set_tvnorm(t,buf); 562 tda9887_set_tvnorm(t,buf);
563
548 buf[1] |= cOutputPort1Inactive; 564 buf[1] |= cOutputPort1Inactive;
549 buf[1] |= cOutputPort2Inactive; 565 buf[1] |= cOutputPort2Inactive;
566
550 if (UNSET != t->pinnacle_id) { 567 if (UNSET != t->pinnacle_id) {
551 tda9887_set_pinnacle(t,buf); 568 tda9887_set_pinnacle(t,buf);
552 } 569 }
570
553 tda9887_set_config(t,buf); 571 tda9887_set_config(t,buf);
554 tda9887_set_insmod(t,buf); 572 tda9887_set_insmod(t,buf);
555 573
@@ -592,9 +610,12 @@ static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind)
592 if (NULL == (t = kmalloc(sizeof(*t), GFP_KERNEL))) 610 if (NULL == (t = kmalloc(sizeof(*t), GFP_KERNEL)))
593 return -ENOMEM; 611 return -ENOMEM;
594 memset(t,0,sizeof(*t)); 612 memset(t,0,sizeof(*t));
613
595 t->client = client_template; 614 t->client = client_template;
596 t->std = 0; 615 t->std = 0;
597 t->pinnacle_id = UNSET; 616 t->pinnacle_id = UNSET;
617 t->radio_mode = V4L2_TUNER_MODE_STEREO;
618
598 i2c_set_clientdata(&t->client, t); 619 i2c_set_clientdata(&t->client, t);
599 i2c_attach_client(&t->client); 620 i2c_attach_client(&t->client);
600 621
@@ -733,6 +754,16 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
733 } 754 }
734 break; 755 break;
735 } 756 }
757 case VIDIOC_S_TUNER:
758 {
759 struct v4l2_tuner* tuner = arg;
760
761 if (t->radio) {
762 t->radio_mode = tuner->audmode;
763 tda9887_configure (t);
764 }
765 break;
766 }
736 default: 767 default:
737 /* nothing */ 768 /* nothing */
738 break; 769 break;
@@ -740,7 +771,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
740 return 0; 771 return 0;
741} 772}
742 773
743static int tda9887_suspend(struct device * dev, pm_message_t state, u32 level) 774static int tda9887_suspend(struct device * dev, u32 state, u32 level)
744{ 775{
745 dprintk("tda9887: suspend\n"); 776 dprintk("tda9887: suspend\n");
746 return 0; 777 return 0;
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 71423ae3b4dd..ba13bfadb523 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: tuner-core.c,v 1.7 2005/05/30 02:02:47 mchehab Exp $ 2 * $Id: tuner-core.c,v 1.15 2005/06/12 01:36:14 mchehab Exp $
3 * 3 *
4 * i2c tv tuner chip device driver 4 * i2c tv tuner chip device driver
5 * core core, i.e. kernel interfaces, registering and so on 5 * core core, i.e. kernel interfaces, registering and so on
@@ -26,15 +26,17 @@
26/* 26/*
27 * comment line bellow to return to old behavor, where only one I2C device is supported 27 * comment line bellow to return to old behavor, where only one I2C device is supported
28 */ 28 */
29/* #define CONFIG_TUNER_MULTI_I2C */ 29#define CONFIG_TUNER_MULTI_I2C /**/
30 30
31#define UNSET (-1U) 31#define UNSET (-1U)
32 32
33/* standard i2c insmod options */ 33/* standard i2c insmod options */
34static unsigned short normal_i2c[] = { 34static unsigned short normal_i2c[] = {
35 0x4b, /* tda8290 */ 35 0x4b, /* tda8290 */
36 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 36 I2C_CLIENT_END
37 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 37};
38static unsigned short normal_i2c_range[] = {
39 0x60, 0x6f,
38 I2C_CLIENT_END 40 I2C_CLIENT_END
39}; 41};
40I2C_CLIENT_INSMOD; 42I2C_CLIENT_INSMOD;
@@ -59,7 +61,7 @@ MODULE_LICENSE("GPL");
59 61
60static int this_adap; 62static int this_adap;
61#ifdef CONFIG_TUNER_MULTI_I2C 63#ifdef CONFIG_TUNER_MULTI_I2C
62static unsigned short tv_tuner, radio_tuner; 64static unsigned short first_tuner, tv_tuner, radio_tuner;
63#endif 65#endif
64 66
65static struct i2c_driver driver; 67static struct i2c_driver driver;
@@ -67,7 +69,7 @@ static struct i2c_client client_template;
67 69
68/* ---------------------------------------------------------------------- */ 70/* ---------------------------------------------------------------------- */
69 71
70// Set tuner frequency, freq in Units of 62.5kHz = 1/16MHz 72/* Set tuner frequency, freq in Units of 62.5kHz = 1/16MHz */
71static void set_tv_freq(struct i2c_client *c, unsigned int freq) 73static void set_tv_freq(struct i2c_client *c, unsigned int freq)
72{ 74{
73 struct tuner *t = i2c_get_clientdata(c); 75 struct tuner *t = i2c_get_clientdata(c);
@@ -81,14 +83,26 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
81 return; 83 return;
82 } 84 }
83 if (freq < tv_range[0]*16 || freq > tv_range[1]*16) { 85 if (freq < tv_range[0]*16 || freq > tv_range[1]*16) {
84 /* FIXME: better do that chip-specific, but 86
85 right now we don't have that in the config 87 if (freq >= tv_range[0]*16364 && freq <= tv_range[1]*16384) {
86 struct and this way is still better than no 88 /* V4L2_TUNER_CAP_LOW frequency */
87 check at all */ 89
88 tuner_info("TV freq (%d.%02d) out of range (%d-%d)\n", 90 tuner_dbg("V4L2_TUNER_CAP_LOW freq selected for TV. Tuners yet doesn't support converting it to valid freq.\n");
89 freq/16,freq%16*100/16,tv_range[0],tv_range[1]); 91
90 return; 92 t->tv_freq(c,freq>>10);
93
94 return;
95 } else {
96 /* FIXME: better do that chip-specific, but
97 right now we don't have that in the config
98 struct and this way is still better than no
99 check at all */
100 tuner_info("TV freq (%d.%02d) out of range (%d-%d)\n",
101 freq/16,freq%16*100/16,tv_range[0],tv_range[1]);
102 return;
103 }
91 } 104 }
105 tuner_dbg("62.5 Khz freq step selected for TV.\n");
92 t->tv_freq(c,freq); 106 t->tv_freq(c,freq);
93} 107}
94 108
@@ -105,11 +119,29 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
105 return; 119 return;
106 } 120 }
107 if (freq < radio_range[0]*16 || freq > radio_range[1]*16) { 121 if (freq < radio_range[0]*16 || freq > radio_range[1]*16) {
108 tuner_info("radio freq (%d.%02d) out of range (%d-%d)\n", 122 if (freq >= tv_range[0]*16364 && freq <= tv_range[1]*16384) {
123 /* V4L2_TUNER_CAP_LOW frequency */
124 if (t->type == TUNER_TEA5767) {
125 tuner_info("radio freq step 62.5Hz (%d.%06d)\n",(freq>>14),freq%(1<<14)*10000);
126 t->radio_freq(c,freq>>10);
127 return;
128 }
129
130 tuner_dbg("V4L2_TUNER_CAP_LOW freq selected for Radio. Tuners yet doesn't support converting it to valid freq.\n");
131
132 tuner_info("radio freq (%d.%06d)\n",(freq>>14),freq%(1<<14)*10000);
133
134 t->radio_freq(c,freq>>10);
135 return;
136
137 } else {
138 tuner_info("radio freq (%d.%02d) out of range (%d-%d)\n",
109 freq/16,freq%16*100/16, 139 freq/16,freq%16*100/16,
110 radio_range[0],radio_range[1]); 140 radio_range[0],radio_range[1]);
111 return; 141 return;
142 }
112 } 143 }
144 tuner_dbg("62.5 Khz freq step selected for Radio.\n");
113 t->radio_freq(c,freq); 145 t->radio_freq(c,freq);
114} 146}
115 147
@@ -133,34 +165,13 @@ static void set_freq(struct i2c_client *c, unsigned long freq)
133 t->freq = freq; 165 t->freq = freq;
134} 166}
135 167
136#ifdef CONFIG_TUNER_MULTI_I2C
137static void set_addr(struct i2c_client *c, struct tuner_addr *tun_addr)
138{
139 struct tuner *t = i2c_get_clientdata(c);
140
141 switch (tun_addr->type) {
142 case V4L2_TUNER_RADIO:
143 radio_tuner=tun_addr->addr;
144 tuner_dbg("radio tuner set to I2C address 0x%02x\n",radio_tuner<<1);
145
146 break;
147 default:
148 tv_tuner=tun_addr->addr;
149 tuner_dbg("TV tuner set to I2C address 0x%02x\n",tv_tuner<<1);
150 break;
151 }
152}
153#else
154#define set_addr(c,tun_addr) \
155 tuner_warn("It is recommended to enable CONFIG_TUNER_MULTI_I2C for this card.\n");
156#endif
157
158static void set_type(struct i2c_client *c, unsigned int type) 168static void set_type(struct i2c_client *c, unsigned int type)
159{ 169{
160 struct tuner *t = i2c_get_clientdata(c); 170 struct tuner *t = i2c_get_clientdata(c);
161 171
172 tuner_dbg ("I2C addr 0x%02x with type %d\n",c->addr<<1,type);
162 /* sanity check */ 173 /* sanity check */
163 if (type == UNSET || type == TUNER_ABSENT) 174 if (type == UNSET || type == TUNER_ABSENT)
164 return; 175 return;
165 if (type >= tuner_count) 176 if (type >= tuner_count)
166 return; 177 return;
@@ -175,6 +186,7 @@ static void set_type(struct i2c_client *c, unsigned int type)
175 return; 186 return;
176 187
177 t->initialized = 1; 188 t->initialized = 1;
189
178 t->type = type; 190 t->type = type;
179 switch (t->type) { 191 switch (t->type) {
180 case TUNER_MT2032: 192 case TUNER_MT2032:
@@ -189,6 +201,53 @@ static void set_type(struct i2c_client *c, unsigned int type)
189 } 201 }
190} 202}
191 203
204#ifdef CONFIG_TUNER_MULTI_I2C
205#define CHECK_ADDR(tp,cmd,tun) if (client->addr!=tp) { \
206 return 0; } else \
207 tuner_info ("Cmd %s accepted to "tun"\n",cmd);
208#define CHECK_MODE(cmd) if (t->mode == V4L2_TUNER_RADIO) { \
209 CHECK_ADDR(radio_tuner,cmd,"radio") } else \
210 { CHECK_ADDR(tv_tuner,cmd,"TV"); }
211#else
212#define CHECK_ADDR(tp,cmd,tun) tuner_info ("Cmd %s accepted to "tun"\n",cmd);
213#define CHECK_MODE(cmd) tuner_info ("Cmd %s accepted\n",cmd);
214#endif
215
216#ifdef CONFIG_TUNER_MULTI_I2C
217
218static void set_addr(struct i2c_client *c, struct tuner_addr *tun_addr)
219{
220 /* ADDR_UNSET defaults to first available tuner */
221 if ( tun_addr->addr == ADDR_UNSET ) {
222 if (first_tuner != c->addr)
223 return;
224 switch (tun_addr->v4l2_tuner) {
225 case V4L2_TUNER_RADIO:
226 radio_tuner=c->addr;
227 break;
228 default:
229 tv_tuner=c->addr;
230 break;
231 }
232 } else {
233 /* Sets tuner to its configured value */
234 switch (tun_addr->v4l2_tuner) {
235 case V4L2_TUNER_RADIO:
236 radio_tuner=tun_addr->addr;
237 if ( tun_addr->addr == c->addr ) set_type(c,tun_addr->type);
238 return;
239 default:
240 tv_tuner=tun_addr->addr;
241 if ( tun_addr->addr == c->addr ) set_type(c,tun_addr->type);
242 return;
243 }
244 }
245 set_type(c,tun_addr->type);
246}
247#else
248#define set_addr(c,tun_addr) set_type(c,(tun_addr)->type)
249#endif
250
192static char pal[] = "-"; 251static char pal[] = "-";
193module_param_string(pal, pal, sizeof(pal), 0644); 252module_param_string(pal, pal, sizeof(pal), 0644);
194 253
@@ -233,6 +292,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
233#else 292#else
234 /* by default, first I2C card is both tv and radio tuner */ 293 /* by default, first I2C card is both tv and radio tuner */
235 if (this_adap == 0) { 294 if (this_adap == 0) {
295 first_tuner = addr;
236 tv_tuner = addr; 296 tv_tuner = addr;
237 radio_tuner = addr; 297 radio_tuner = addr;
238 } 298 }
@@ -249,11 +309,12 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
249 memcpy(&t->i2c,&client_template,sizeof(struct i2c_client)); 309 memcpy(&t->i2c,&client_template,sizeof(struct i2c_client));
250 i2c_set_clientdata(&t->i2c, t); 310 i2c_set_clientdata(&t->i2c, t);
251 t->type = UNSET; 311 t->type = UNSET;
252 t->radio_if2 = 10700*1000; // 10.7MHz - FM radio 312 t->radio_if2 = 10700*1000; /* 10.7MHz - FM radio */
253 313
254 i2c_attach_client(&t->i2c); 314 i2c_attach_client(&t->i2c);
255 tuner_info("chip found @ 0x%x (%s)\n", 315 tuner_info("chip found @ 0x%x (%s)\n",
256 addr << 1, adap->name); 316 addr << 1, adap->name);
317
257 set_type(&t->i2c, t->type); 318 set_type(&t->i2c, t->type);
258 return 0; 319 return 0;
259} 320}
@@ -261,12 +322,14 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
261static int tuner_probe(struct i2c_adapter *adap) 322static int tuner_probe(struct i2c_adapter *adap)
262{ 323{
263 if (0 != addr) { 324 if (0 != addr) {
264 normal_i2c[0] = addr; 325 normal_i2c[0] = addr;
265 normal_i2c[1] = I2C_CLIENT_END; 326 normal_i2c_range[0] = addr;
327 normal_i2c_range[1] = addr;
266 } 328 }
267 this_adap = 0; 329 this_adap = 0;
268 330
269#ifdef CONFIG_TUNER_MULTI_I2C 331#ifdef CONFIG_TUNER_MULTI_I2C
332 first_tuner = 0;
270 tv_tuner = 0; 333 tv_tuner = 0;
271 radio_tuner = 0; 334 radio_tuner = 0;
272#endif 335#endif
@@ -298,17 +361,6 @@ static int tuner_detach(struct i2c_client *client)
298 tuner_info("ignore v4l1 call\n"); \ 361 tuner_info("ignore v4l1 call\n"); \
299 return 0; } 362 return 0; }
300 363
301#ifdef CONFIG_TUNER_MULTI_I2C
302#define CHECK_ADDR(tp,cmd) if (client->addr!=tp) { \
303 tuner_info ("Cmd %s to addr 0x%02x rejected.\n",cmd,client->addr<<1); \
304 return 0; }
305#define CHECK_MODE(cmd) if (t->mode == V4L2_TUNER_RADIO) { \
306 CHECK_ADDR(radio_tuner,cmd) } else { CHECK_ADDR(tv_tuner,cmd); }
307#else
308#define CHECK_ADDR(tp,cmd)
309#define CHECK_MODE(cmd)
310#endif
311
312static int 364static int
313tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) 365tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
314{ 366{
@@ -320,19 +372,19 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
320 case TUNER_SET_TYPE: 372 case TUNER_SET_TYPE:
321 set_type(client,*iarg); 373 set_type(client,*iarg);
322 break; 374 break;
323 case TUNER_SET_ADDR: 375 case TUNER_SET_TYPE_ADDR:
324 set_addr(client,(struct tuner_addr *)arg); 376 set_addr(client,(struct tuner_addr *)arg);
325 break; 377 break;
326 case AUDC_SET_RADIO: 378 case AUDC_SET_RADIO:
327 CHECK_ADDR(radio_tuner,"AUDC_SET_RADIO"); 379 t->mode = V4L2_TUNER_RADIO;
380 CHECK_ADDR(tv_tuner,"AUDC_SET_RADIO","TV");
328 381
329 if (V4L2_TUNER_RADIO != t->mode) { 382 if (V4L2_TUNER_RADIO != t->mode) {
330 set_tv_freq(client,400 * 16); 383 set_tv_freq(client,400 * 16);
331 t->mode = V4L2_TUNER_RADIO;
332 } 384 }
333 break; 385 break;
334 case AUDC_CONFIG_PINNACLE: 386 case AUDC_CONFIG_PINNACLE:
335 CHECK_ADDR(tv_tuner,"AUDC_CONFIG_PINNACLE"); 387 CHECK_ADDR(tv_tuner,"AUDC_CONFIG_PINNACLE","TV");
336 switch (*iarg) { 388 switch (*iarg) {
337 case 2: 389 case 2:
338 tuner_dbg("pinnacle pal\n"); 390 tuner_dbg("pinnacle pal\n");
@@ -360,9 +412,10 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
360 }; 412 };
361 struct video_channel *vc = arg; 413 struct video_channel *vc = arg;
362 414
363 CHECK_ADDR(tv_tuner,"VIDIOCSCHAN");
364 CHECK_V4L2; 415 CHECK_V4L2;
365 t->mode = V4L2_TUNER_ANALOG_TV; 416 t->mode = V4L2_TUNER_ANALOG_TV;
417 CHECK_ADDR(tv_tuner,"VIDIOCSCHAN","TV");
418
366 if (vc->norm < ARRAY_SIZE(map)) 419 if (vc->norm < ARRAY_SIZE(map))
367 t->std = map[vc->norm]; 420 t->std = map[vc->norm];
368 tuner_fixup_std(t); 421 tuner_fixup_std(t);
@@ -383,17 +436,27 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
383 { 436 {
384 struct video_tuner *vt = arg; 437 struct video_tuner *vt = arg;
385 438
386 CHECK_ADDR(radio_tuner,"VIDIOCGTUNER:"); 439 CHECK_ADDR(radio_tuner,"VIDIOCGTUNER","radio");
387 CHECK_V4L2; 440 CHECK_V4L2;
388 if (V4L2_TUNER_RADIO == t->mode && t->has_signal) 441 if (V4L2_TUNER_RADIO == t->mode) {
389 vt->signal = t->has_signal(client); 442 if (t->has_signal)
443 vt->signal = t->has_signal(client);
444 if (t->is_stereo) {
445 if (t->is_stereo(client))
446 vt-> flags |= VIDEO_TUNER_STEREO_ON;
447 else
448 vt-> flags &= 0xffff ^ VIDEO_TUNER_STEREO_ON;
449 }
450 vt->flags |= V4L2_TUNER_CAP_LOW; /* Allow freqs at 62.5 Hz */
451 }
452
390 return 0; 453 return 0;
391 } 454 }
392 case VIDIOCGAUDIO: 455 case VIDIOCGAUDIO:
393 { 456 {
394 struct video_audio *va = arg; 457 struct video_audio *va = arg;
395 458
396 CHECK_ADDR(radio_tuner,"VIDIOCGAUDIO"); 459 CHECK_ADDR(radio_tuner,"VIDIOCGAUDIO","radio");
397 CHECK_V4L2; 460 CHECK_V4L2;
398 if (V4L2_TUNER_RADIO == t->mode && t->is_stereo) 461 if (V4L2_TUNER_RADIO == t->mode && t->is_stereo)
399 va->mode = t->is_stereo(client) 462 va->mode = t->is_stereo(client)
@@ -406,9 +469,10 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
406 { 469 {
407 v4l2_std_id *id = arg; 470 v4l2_std_id *id = arg;
408 471
409 CHECK_ADDR(tv_tuner,"VIDIOC_S_STD");
410 SWITCH_V4L2; 472 SWITCH_V4L2;
411 t->mode = V4L2_TUNER_ANALOG_TV; 473 t->mode = V4L2_TUNER_ANALOG_TV;
474 CHECK_ADDR(tv_tuner,"VIDIOC_S_STD","TV");
475
412 t->std = *id; 476 t->std = *id;
413 tuner_fixup_std(t); 477 tuner_fixup_std(t);
414 if (t->freq) 478 if (t->freq)
@@ -444,13 +508,27 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
444 508
445 CHECK_MODE("VIDIOC_G_TUNER"); 509 CHECK_MODE("VIDIOC_G_TUNER");
446 SWITCH_V4L2; 510 SWITCH_V4L2;
447 if (V4L2_TUNER_RADIO == t->mode && t->has_signal) 511 if (V4L2_TUNER_RADIO == t->mode) {
448 tuner->signal = t->has_signal(client); 512 if (t->has_signal)
513 tuner -> signal = t->has_signal(client);
514 if (t->is_stereo) {
515 if (t->is_stereo(client)) {
516 tuner -> capability |= V4L2_TUNER_CAP_STEREO;
517 tuner -> rxsubchans |= V4L2_TUNER_SUB_STEREO;
518 } else {
519 tuner -> rxsubchans &= 0xffff ^ V4L2_TUNER_SUB_STEREO;
520 }
521 }
522 }
523 /* Wow to deal with V4L2_TUNER_CAP_LOW ? For now, it accepts from low at 62.5KHz step to high at 62.5 Hz */
449 tuner->rangelow = tv_range[0] * 16; 524 tuner->rangelow = tv_range[0] * 16;
450 tuner->rangehigh = tv_range[1] * 16; 525// tuner->rangehigh = tv_range[1] * 16;
526// tuner->rangelow = tv_range[0] * 16384;
527 tuner->rangehigh = tv_range[1] * 16384;
451 break; 528 break;
452 } 529 }
453 default: 530 default:
531 tuner_dbg ("Unimplemented IOCTL 0x%08x called to tuner.\n", cmd);
454 /* nothing */ 532 /* nothing */
455 break; 533 break;
456 } 534 }
@@ -458,7 +536,7 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
458 return 0; 536 return 0;
459} 537}
460 538
461static int tuner_suspend(struct device * dev, pm_message_t state, u32 level) 539static int tuner_suspend(struct device * dev, u32 state, u32 level)
462{ 540{
463 struct i2c_client *c = container_of(dev, struct i2c_client, dev); 541 struct i2c_client *c = container_of(dev, struct i2c_client, dev);
464 struct tuner *t = i2c_get_clientdata(c); 542 struct tuner *t = i2c_get_clientdata(c);
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index 866f18dc5b58..539f30557317 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: tuner-simple.c,v 1.14 2005/05/30 02:02:47 mchehab Exp $ 2 * $Id: tuner-simple.c,v 1.21 2005/06/10 19:53:26 nsh Exp $
3 * 3 *
4 * i2c tv tuner chip device driver 4 * i2c tv tuner chip device driver
5 * controls all those simple 4-control-bytes style tuners. 5 * controls all those simple 4-control-bytes style tuners.
@@ -220,7 +220,17 @@ static struct tunertype tuners[] = {
220 220
221 { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC, 221 { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC,
222 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, 222 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732},
223 { "Tena TNF9533-D/IF", LGINNOTEK, PAL,
224 16*160.25, 16*464.25, 0x01,0x02,0x08,0x8e,623},
225
226 /*
227 * This entry is for TEA5767 FM radio only chip used on several boards
228 * w/TV tuner
229 */
230 { TEA5767_TUNER_NAME, Philips, RADIO,
231 -1, -1, 0, 0, 0, TEA5767_LOW_LO_32768,0},
223}; 232};
233
224unsigned const int tuner_count = ARRAY_SIZE(tuners); 234unsigned const int tuner_count = ARRAY_SIZE(tuners);
225 235
226/* ---------------------------------------------------------------------- */ 236/* ---------------------------------------------------------------------- */
@@ -231,6 +241,7 @@ static int tuner_getstatus(struct i2c_client *c)
231 241
232 if (1 != i2c_master_recv(c,&byte,1)) 242 if (1 != i2c_master_recv(c,&byte,1))
233 return 0; 243 return 0;
244
234 return byte; 245 return byte;
235} 246}
236 247
@@ -239,17 +250,33 @@ static int tuner_getstatus(struct i2c_client *c)
239#define TUNER_MODE 0x38 250#define TUNER_MODE 0x38
240#define TUNER_AFC 0x07 251#define TUNER_AFC 0x07
241 252
242#define TUNER_STEREO 0x10 /* radio mode */ 253#define TUNER_STEREO 0x10 /* radio mode */
243#define TUNER_SIGNAL 0x07 /* radio mode */ 254#define TUNER_STEREO_MK3 0x04 /* radio mode */
255#define TUNER_SIGNAL 0x07 /* radio mode */
244 256
245static int tuner_signal(struct i2c_client *c) 257static int tuner_signal(struct i2c_client *c)
246{ 258{
247 return (tuner_getstatus(c) & TUNER_SIGNAL)<<13; 259 return (tuner_getstatus(c) & TUNER_SIGNAL) << 13;
248} 260}
249 261
250static int tuner_stereo(struct i2c_client *c) 262static int tuner_stereo(struct i2c_client *c)
251{ 263{
252 return (tuner_getstatus (c) & TUNER_STEREO); 264 int stereo, status;
265 struct tuner *t = i2c_get_clientdata(c);
266
267 status = tuner_getstatus (c);
268
269 switch (t->type) {
270 case TUNER_PHILIPS_FM1216ME_MK3:
271 case TUNER_PHILIPS_FM1236_MK3:
272 case TUNER_PHILIPS_FM1256_IH3:
273 stereo = ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
274 break;
275 default:
276 stereo = status & TUNER_STEREO;
277 }
278
279 return stereo;
253} 280}
254 281
255#if 0 /* unused */ 282#if 0 /* unused */
@@ -432,6 +459,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
432 buffer[2] = tun->config; 459 buffer[2] = tun->config;
433 460
434 switch (t->type) { 461 switch (t->type) {
462 case TUNER_TENA_9533_DI:
435 case TUNER_YMEC_TVF_5533MF: 463 case TUNER_YMEC_TVF_5533MF:
436 464
437 /*These values are empirically determinated */ 465 /*These values are empirically determinated */
@@ -473,20 +501,6 @@ int default_tuner_init(struct i2c_client *c)
473 t->type, tuners[t->type].name); 501 t->type, tuners[t->type].name);
474 strlcpy(c->name, tuners[t->type].name, sizeof(c->name)); 502 strlcpy(c->name, tuners[t->type].name, sizeof(c->name));
475 503
476 switch (t->type) {
477 case TUNER_YMEC_TVF_5533MF:
478 {
479 struct tuner_addr tun_addr = { V4L2_TUNER_ANALOG_TV, 0xc2>>1 };
480
481 if (c->driver->command) {
482 c->driver->command(c, TUNER_SET_ADDR, &tun_addr);
483 } else {
484 tuner_warn("Couldn't set TV tuner I2C address to 0x%02x\n",tun_addr.addr<<1);
485 }
486 break;
487 }
488 }
489
490 t->tv_freq = default_set_tv_freq; 504 t->tv_freq = default_set_tv_freq;
491 t->radio_freq = default_set_radio_freq; 505 t->radio_freq = default_set_radio_freq;
492 t->has_signal = tuner_signal; 506 t->has_signal = tuner_signal;
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 41b635e0d3c6..6f5828a9b80c 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -148,6 +148,7 @@ static unsigned short normal_i2c[] = {
148 I2C_TDA9874 >> 1, 148 I2C_TDA9874 >> 1,
149 I2C_PIC16C54 >> 1, 149 I2C_PIC16C54 >> 1,
150 I2C_CLIENT_END }; 150 I2C_CLIENT_END };
151static unsigned short normal_i2c_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
151I2C_CLIENT_INSMOD; 152I2C_CLIENT_INSMOD;
152 153
153static struct i2c_driver driver; 154static struct i2c_driver driver;
@@ -285,7 +286,6 @@ static int chip_thread(void *data)
285 schedule(); 286 schedule();
286 } 287 }
287 remove_wait_queue(&chip->wq, &wait); 288 remove_wait_queue(&chip->wq, &wait);
288 try_to_freeze(PF_FREEZE);
289 if (chip->done || signal_pending(current)) 289 if (chip->done || signal_pending(current))
290 break; 290 break;
291 dprintk("%s: thread wakeup\n", i2c_clientname(&chip->c)); 291 dprintk("%s: thread wakeup\n", i2c_clientname(&chip->c));
diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c
index eafd7061b310..51b99cdbf29e 100644
--- a/drivers/media/video/tvmixer.c
+++ b/drivers/media/video/tvmixer.c
@@ -1,3 +1,7 @@
1/*
2 * $Id: tvmixer.c,v 1.8 2005/06/12 04:19:19 mchehab Exp $
3 */
4
1#include <linux/module.h> 5#include <linux/module.h>
2#include <linux/moduleparam.h> 6#include <linux/moduleparam.h>
3#include <linux/kernel.h> 7#include <linux/kernel.h>
diff --git a/include/media/audiochip.h b/include/media/audiochip.h
index d3e9e30608dc..f345a61c3bdb 100644
--- a/include/media/audiochip.h
+++ b/include/media/audiochip.h
@@ -1,3 +1,7 @@
1/*
2 * $Id: audiochip.h,v 1.3 2005/06/12 04:19:19 mchehab Exp $
3 */
4
1#ifndef AUDIOCHIP_H 5#ifndef AUDIOCHIP_H
2#define AUDIOCHIP_H 6#define AUDIOCHIP_H
3 7
diff --git a/include/media/id.h b/include/media/id.h
index 1b0320dc8f73..a39a6423914b 100644
--- a/include/media/id.h
+++ b/include/media/id.h
@@ -1,3 +1,7 @@
1/*
2 * $Id: id.h,v 1.4 2005/06/12 04:19:19 mchehab Exp $
3 */
4
1/* FIXME: this temporarely, until these are included in linux/i2c-id.h */ 5/* FIXME: this temporarely, until these are included in linux/i2c-id.h */
2 6
3/* drivers */ 7/* drivers */
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index b5fa6c585e2d..698670547f16 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ir-common.h,v 1.8 2005/02/22 12:28:40 kraxel Exp $ 2 * $Id: ir-common.h,v 1.9 2005/05/15 19:01:26 mchehab Exp $
3 * 3 *
4 * some common structs and functions to handle infrared remotes via 4 * some common structs and functions to handle infrared remotes via
5 * input layer ... 5 * input layer ...
diff --git a/include/media/tuner.h b/include/media/tuner.h
index cb75f4809c4d..2dd8310901e8 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -25,6 +25,8 @@
25 25
26#include "id.h" 26#include "id.h"
27 27
28#define ADDR_UNSET (255)
29
28#define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */ 30#define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */
29#define TUNER_PHILIPS_PAL_I 1 31#define TUNER_PHILIPS_PAL_I 1
30#define TUNER_PHILIPS_NTSC 2 32#define TUNER_PHILIPS_NTSC 2
@@ -100,6 +102,11 @@
100 102
101#define TUNER_YMEC_TVF_8531MF 58 103#define TUNER_YMEC_TVF_8531MF 58
102#define TUNER_YMEC_TVF_5533MF 59 /* Pixelview Pro Ultra NTSC */ 104#define TUNER_YMEC_TVF_5533MF 59 /* Pixelview Pro Ultra NTSC */
105#define TUNER_THOMSON_DTT7611 60
106#define TUNER_TENA_9533_DI 61
107#define TUNER_TEA5767 62 /* Only FM Radio Tuner */
108
109#define TEA5767_TUNER_NAME "Philips TEA5767HN FM Radio"
103 110
104#define TUNER_THOMSON_DTT7611 60 111#define TUNER_THOMSON_DTT7611 60
105 112
@@ -109,6 +116,7 @@
109#define NTSC 3 116#define NTSC 3
110#define SECAM 4 117#define SECAM 4
111#define ATSC 5 118#define ATSC 5
119#define RADIO 6
112 120
113#define NoTuner 0 121#define NoTuner 0
114#define Philips 1 122#define Philips 1
@@ -124,9 +132,17 @@
124#define TCL 11 132#define TCL 11
125#define THOMSON 12 133#define THOMSON 12
126 134
135enum v4l_radio_tuner {
136 TEA5767_LOW_LO_32768 = 0,
137 TEA5767_HIGH_LO_32768 = 1,
138 TEA5767_LOW_LO_13MHz = 2,
139 TEA5767_HIGH_LO_13MHz = 3,
140};
141
142
127#define TUNER_SET_TYPE _IOW('t',1,int) /* set tuner type */ 143#define TUNER_SET_TYPE _IOW('t',1,int) /* set tuner type */
128#define TUNER_SET_TVFREQ _IOW('t',2,int) /* set tv freq */ 144#define TUNER_SET_TVFREQ _IOW('t',2,int) /* set tv freq */
129#define TUNER_SET_ADDR _IOW('T',3,int) /* Chooses tuner I2C address */ 145#define TUNER_SET_TYPE_ADDR _IOW('T',3,int) /* set tuner type and I2C addr */
130 146
131#define TDA9887_SET_CONFIG _IOW('t',5,int) 147#define TDA9887_SET_CONFIG _IOW('t',5,int)
132 148
@@ -151,8 +167,9 @@
151#define I2C_ADDR_TDA8275 0x61 167#define I2C_ADDR_TDA8275 0x61
152 168
153struct tuner_addr { 169struct tuner_addr {
154 enum v4l2_tuner_type type; 170 enum v4l2_tuner_type v4l2_tuner;
155 unsigned short addr; 171 unsigned int type;
172 unsigned short addr;
156}; 173};
157 174
158struct tuner { 175struct tuner {