aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/video4linux/CARDLIST.saa71341
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c78
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c856
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c9
-rw-r--r--drivers/media/video/saa7134/saa7134.h1
-rw-r--r--drivers/media/video/tda8290.c136
7 files changed, 617 insertions, 465 deletions
diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134
index a12246a9bf23..f18533f28e04 100644
--- a/Documentation/video4linux/CARDLIST.saa7134
+++ b/Documentation/video4linux/CARDLIST.saa7134
@@ -107,3 +107,4 @@
107106 -> Encore ENLTV [1131:2342,1131:2341,3016:2344] 107106 -> Encore ENLTV [1131:2342,1131:2341,3016:2344]
108107 -> Encore ENLTV-FM [1131:230f] 108107 -> Encore ENLTV-FM [1131:230f]
109108 -> Terratec Cinergy HT PCI [153b:1175] 109108 -> Terratec Cinergy HT PCI [153b:1175]
110109 -> Philips Tiger - S Reference design
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 4399d1371cc1..782832e7ed6d 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -2543,10 +2543,10 @@ struct saa7134_board saa7134_boards[] = {
2543 .name = "Philips Tiger reference design", 2543 .name = "Philips Tiger reference design",
2544 .audio_clock = 0x00187de7, 2544 .audio_clock = 0x00187de7,
2545 .tuner_type = TUNER_PHILIPS_TDA8290, 2545 .tuner_type = TUNER_PHILIPS_TDA8290,
2546 .tuner_config = 0,
2547 .radio_type = UNSET, 2546 .radio_type = UNSET,
2548 .tuner_addr = ADDR_UNSET, 2547 .tuner_addr = ADDR_UNSET,
2549 .radio_addr = ADDR_UNSET, 2548 .radio_addr = ADDR_UNSET,
2549 .tuner_config = 0,
2550 .mpeg = SAA7134_MPEG_DVB, 2550 .mpeg = SAA7134_MPEG_DVB,
2551 .gpiomask = 0x0200000, 2551 .gpiomask = 0x0200000,
2552 .inputs = {{ 2552 .inputs = {{
@@ -2625,7 +2625,7 @@ struct saa7134_board saa7134_boards[] = {
2625 }}, 2625 }},
2626 .radio = { 2626 .radio = {
2627 .name = name_radio, 2627 .name = name_radio,
2628 .amux = LINE1, 2628 .amux = TV,
2629 .gpio = 0x0200000, 2629 .gpio = 0x0200000,
2630 }, 2630 },
2631 }, 2631 },
@@ -3044,6 +3044,7 @@ struct saa7134_board saa7134_boards[] = {
3044 .radio_type = UNSET, 3044 .radio_type = UNSET,
3045 .tuner_addr = ADDR_UNSET, 3045 .tuner_addr = ADDR_UNSET,
3046 .radio_addr = ADDR_UNSET, 3046 .radio_addr = ADDR_UNSET,
3047 .tuner_config = 1,
3047 .mpeg = SAA7134_MPEG_DVB, 3048 .mpeg = SAA7134_MPEG_DVB,
3048 .gpiomask = 0x000200000, 3049 .gpiomask = 0x000200000,
3049 .inputs = {{ 3050 .inputs = {{
@@ -3290,6 +3291,36 @@ struct saa7134_board saa7134_boards[] = {
3290 .amux = LINE1, 3291 .amux = LINE1,
3291 }}, 3292 }},
3292 }, 3293 },
3294 [SAA7134_BOARD_PHILIPS_TIGER_S] = {
3295 .name = "Philips Tiger - S Reference design",
3296 .audio_clock = 0x00187de7,
3297 .tuner_type = TUNER_PHILIPS_TDA8290,
3298 .radio_type = UNSET,
3299 .tuner_addr = ADDR_UNSET,
3300 .radio_addr = ADDR_UNSET,
3301 .tuner_config = 2,
3302 .mpeg = SAA7134_MPEG_DVB,
3303 .gpiomask = 0x0200000,
3304 .inputs = {{
3305 .name = name_tv,
3306 .vmux = 1,
3307 .amux = TV,
3308 .tv = 1,
3309 },{
3310 .name = name_comp1,
3311 .vmux = 3,
3312 .amux = LINE1,
3313 },{
3314 .name = name_svideo,
3315 .vmux = 8,
3316 .amux = LINE1,
3317 }},
3318 .radio = {
3319 .name = name_radio,
3320 .amux = TV,
3321 .gpio = 0x0200000,
3322 },
3323 },
3293}; 3324};
3294 3325
3295const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 3326const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -4104,8 +4135,8 @@ int saa7134_board_init1(struct saa7134_dev *dev)
4104 break; 4135 break;
4105 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 4136 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
4106 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: 4137 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
4107 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08); 4138 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x08000000, 0x08000000);
4108 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00); 4139 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x08000000, 0x00000000);
4109 break; 4140 break;
4110 case SAA7134_BOARD_AVERMEDIA_CARDBUS: 4141 case SAA7134_BOARD_AVERMEDIA_CARDBUS:
4111 /* power-up tuner chip */ 4142 /* power-up tuner chip */
@@ -4168,6 +4199,8 @@ int saa7134_board_init2(struct saa7134_dev *dev)
4168 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; 4199 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
4169 tun_setup.type = dev->tuner_type; 4200 tun_setup.type = dev->tuner_type;
4170 tun_setup.addr = ADDR_UNSET; 4201 tun_setup.addr = ADDR_UNSET;
4202 tun_setup.config = 0;
4203 tun_setup.gpio_func = NULL;
4171 4204
4172 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR, &tun_setup); 4205 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR, &tun_setup);
4173 } 4206 }
@@ -4235,6 +4268,8 @@ int saa7134_board_init2(struct saa7134_dev *dev)
4235 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; 4268 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
4236 tun_setup.type = dev->tuner_type; 4269 tun_setup.type = dev->tuner_type;
4237 tun_setup.addr = ADDR_UNSET; 4270 tun_setup.addr = ADDR_UNSET;
4271 tun_setup.config = 0;
4272 tun_setup.gpio_func = NULL;
4238 4273
4239 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); 4274 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
4240 } 4275 }
@@ -4254,11 +4289,36 @@ int saa7134_board_init2(struct saa7134_dev *dev)
4254 tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV; 4289 tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
4255 tun_setup.type = dev->tuner_type; 4290 tun_setup.type = dev->tuner_type;
4256 tun_setup.addr = dev->tuner_addr; 4291 tun_setup.addr = dev->tuner_addr;
4292 tun_setup.config = 0;
4293 tun_setup.gpio_func = NULL;
4257 4294
4258 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); 4295 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
4259 } 4296 }
4260 break; 4297 break;
4261 case SAA7134_BOARD_PHILIPS_TIGER: 4298 case SAA7134_BOARD_PHILIPS_TIGER:
4299 case SAA7134_BOARD_PHILIPS_TIGER_S:
4300 {
4301 u8 data[] = { 0x3c, 0x33, 0x60};
4302 struct tuner_setup tun_setup;
4303 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
4304 if(dev->autodetected && (dev->eedata[0x49] == 0x50)) {
4305 dev->board = SAA7134_BOARD_PHILIPS_TIGER_S;
4306 printk(KERN_INFO "%s: Reconfigured board as %s\n",
4307 dev->name, saa7134_boards[dev->board].name);
4308 }
4309 if(dev->board == SAA7134_BOARD_PHILIPS_TIGER_S) {
4310 tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
4311 tun_setup.type = TUNER_PHILIPS_TDA8290;
4312 tun_setup.addr = 0x4b;
4313 tun_setup.config = 2;
4314 tun_setup.gpio_func = (tuner_gpio_func_t) saa7134_set_gpio;
4315
4316 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
4317 data[2] = 0x68;
4318 }
4319 i2c_transfer(&dev->i2c_adap, &msg, 1);
4320 }
4321 break;
4262 case SAA7134_BOARD_PINNACLE_PCTV_310i: 4322 case SAA7134_BOARD_PINNACLE_PCTV_310i:
4263 case SAA7134_BOARD_TEVION_DVBT_220RF: 4323 case SAA7134_BOARD_TEVION_DVBT_220RF:
4264 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 4324 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
@@ -4268,7 +4328,7 @@ int saa7134_board_init2(struct saa7134_dev *dev)
4268 * and configure firmware eeprom address 4328 * and configure firmware eeprom address
4269 */ 4329 */
4270 { 4330 {
4271 u8 data[] = { 0x3c, 0x33, 0x68}; 4331 u8 data[] = { 0x3c, 0x33, 0x60};
4272 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; 4332 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
4273 i2c_transfer(&dev->i2c_adap, &msg, 1); 4333 i2c_transfer(&dev->i2c_adap, &msg, 1);
4274 } 4334 }
@@ -4282,18 +4342,18 @@ int saa7134_board_init2(struct saa7134_dev *dev)
4282 break; 4342 break;
4283 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 4343 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
4284 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: 4344 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
4285 /* make the tda10046 find its eeprom */ 4345 /* initialize analog mode */
4286 { 4346 {
4287 u8 data[] = { 0x3c, 0x33, 0x62}; 4347 u8 data[] = { 0x3c, 0x33, 0x6a};
4288 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; 4348 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
4289 i2c_transfer(&dev->i2c_adap, &msg, 1); 4349 i2c_transfer(&dev->i2c_adap, &msg, 1);
4290 } 4350 }
4291 break; 4351 break;
4292 case SAA7134_BOARD_CINERGY_HT_PCMCIA: 4352 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
4293 case SAA7134_BOARD_CINERGY_HT_PCI: 4353 case SAA7134_BOARD_CINERGY_HT_PCI:
4294 /* make the tda10046 find its eeprom */ 4354 /* initialize analog mode */
4295 { 4355 {
4296 u8 data[] = { 0x3c, 0x33, 0x60}; 4356 u8 data[] = { 0x3c, 0x33, 0x68};
4297 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; 4357 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
4298 i2c_transfer(&dev->i2c_adap, &msg, 1); 4358 i2c_transfer(&dev->i2c_adap, &msg, 1);
4299 } 4359 }
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 2e0518bb9efd..8ed03d65a34e 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -1205,6 +1205,7 @@ module_exit(saa7134_fini);
1205 1205
1206/* ----------------------------------------------------------- */ 1206/* ----------------------------------------------------------- */
1207 1207
1208EXPORT_SYMBOL(saa7134_set_gpio);
1208EXPORT_SYMBOL(saa7134_i2c_call_clients); 1209EXPORT_SYMBOL(saa7134_i2c_call_clients);
1209EXPORT_SYMBOL(saa7134_devlist); 1210EXPORT_SYMBOL(saa7134_devlist);
1210EXPORT_SYMBOL(saa7134_boards); 1211EXPORT_SYMBOL(saa7134_boards);
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 6d148a7601ac..61a68c67c4ad 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -54,7 +54,17 @@ static int use_frontend = 0;
54module_param(use_frontend, int, 0644); 54module_param(use_frontend, int, 0644);
55MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)"); 55MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
56 56
57/* ------------------------------------------------------------------ */ 57static int debug = 0;
58module_param(debug, int, 0644);
59MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
60
61#define dprintk(fmt, arg...) if (debug) \
62 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg)
63
64/* ------------------------------------------------------------------
65 * mt352 based DVB-T cards
66 */
67
58static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on) 68static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
59{ 69{
60 u32 ok; 70 u32 ok;
@@ -185,10 +195,35 @@ static struct mt352_config avermedia_777 = {
185 .demod_init = mt352_aver777_init, 195 .demod_init = mt352_aver777_init,
186}; 196};
187 197
188/* ------------------------------------------------------------------ */ 198/* ==================================================================
189static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 199 * tda1004x based DVB-T cards, helper functions
200 */
201
202static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
203 const struct firmware **fw, char *name)
190{ 204{
191 struct saa7134_dev *dev = fe->dvb->priv; 205 struct saa7134_dev *dev = fe->dvb->priv;
206 return request_firmware(fw, name, &dev->pci->dev);
207}
208
209static void philips_tda1004x_set_board_name(struct dvb_frontend *fe, char *name)
210{
211 size_t len;
212
213 len = sizeof(fe->ops.info.name);
214 strncpy(fe->ops.info.name, name, len);
215 fe->ops.info.name[len - 1] = 0;
216}
217
218/* ------------------------------------------------------------------
219 * these tuners are tu1216, td1316(a)
220 */
221
222static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
223{
224 struct saa7134_dev *dev = fe->dvb->priv;
225 struct tda1004x_state *state = fe->demodulator_priv;
226 u8 addr = state->config->tuner_address;
192 u8 tuner_buf[4]; 227 u8 tuner_buf[4];
193 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len = 228 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
194 sizeof(tuner_buf) }; 229 sizeof(tuner_buf) };
@@ -263,15 +298,19 @@ static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_
263 298
264 if (fe->ops.i2c_gate_ctrl) 299 if (fe->ops.i2c_gate_ctrl)
265 fe->ops.i2c_gate_ctrl(fe, 1); 300 fe->ops.i2c_gate_ctrl(fe, 1);
266 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) 301 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
302 printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
267 return -EIO; 303 return -EIO;
304 }
268 msleep(1); 305 msleep(1);
269 return 0; 306 return 0;
270} 307}
271 308
272static int philips_tda6651_pll_init(u8 addr, struct dvb_frontend *fe) 309static int philips_tu1216_init(struct dvb_frontend *fe)
273{ 310{
274 struct saa7134_dev *dev = fe->dvb->priv; 311 struct saa7134_dev *dev = fe->dvb->priv;
312 struct tda1004x_state *state = fe->demodulator_priv;
313 u8 addr = state->config->tuner_address;
275 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab }; 314 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
276 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) }; 315 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
277 316
@@ -287,46 +326,17 @@ static int philips_tda6651_pll_init(u8 addr, struct dvb_frontend *fe)
287 326
288/* ------------------------------------------------------------------ */ 327/* ------------------------------------------------------------------ */
289 328
290static int philips_tu1216_tuner_60_init(struct dvb_frontend *fe)
291{
292 return philips_tda6651_pll_init(0x60, fe);
293}
294
295static int philips_tu1216_tuner_60_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
296{
297 return philips_tda6651_pll_set(0x60, fe, params);
298}
299
300static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
301 const struct firmware **fw, char *name)
302{
303 struct saa7134_dev *dev = fe->dvb->priv;
304 return request_firmware(fw, name, &dev->pci->dev);
305}
306
307static struct tda1004x_config philips_tu1216_60_config = { 329static struct tda1004x_config philips_tu1216_60_config = {
308
309 .demod_address = 0x8, 330 .demod_address = 0x8,
310 .invert = 1, 331 .invert = 1,
311 .invert_oclk = 0, 332 .invert_oclk = 0,
312 .xtal_freq = TDA10046_XTAL_4M, 333 .xtal_freq = TDA10046_XTAL_4M,
313 .agc_config = TDA10046_AGC_DEFAULT, 334 .agc_config = TDA10046_AGC_DEFAULT,
314 .if_freq = TDA10046_FREQ_3617, 335 .if_freq = TDA10046_FREQ_3617,
315 .request_firmware = philips_tda1004x_request_firmware, 336 .tuner_address = 0x60,
337 .request_firmware = philips_tda1004x_request_firmware
316}; 338};
317 339
318/* ------------------------------------------------------------------ */
319
320static int philips_tu1216_tuner_61_init(struct dvb_frontend *fe)
321{
322 return philips_tda6651_pll_init(0x61, fe);
323}
324
325static int philips_tu1216_tuner_61_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
326{
327 return philips_tda6651_pll_set(0x61, fe, params);
328}
329
330static struct tda1004x_config philips_tu1216_61_config = { 340static struct tda1004x_config philips_tu1216_61_config = {
331 341
332 .demod_address = 0x8, 342 .demod_address = 0x8,
@@ -335,7 +345,8 @@ static struct tda1004x_config philips_tu1216_61_config = {
335 .xtal_freq = TDA10046_XTAL_4M, 345 .xtal_freq = TDA10046_XTAL_4M,
336 .agc_config = TDA10046_AGC_DEFAULT, 346 .agc_config = TDA10046_AGC_DEFAULT,
337 .if_freq = TDA10046_FREQ_3617, 347 .if_freq = TDA10046_FREQ_3617,
338 .request_firmware = philips_tda1004x_request_firmware, 348 .tuner_address = 0x61,
349 .request_firmware = philips_tda1004x_request_firmware
339}; 350};
340 351
341/* ------------------------------------------------------------------ */ 352/* ------------------------------------------------------------------ */
@@ -343,24 +354,42 @@ static struct tda1004x_config philips_tu1216_61_config = {
343static int philips_td1316_tuner_init(struct dvb_frontend *fe) 354static int philips_td1316_tuner_init(struct dvb_frontend *fe)
344{ 355{
345 struct saa7134_dev *dev = fe->dvb->priv; 356 struct saa7134_dev *dev = fe->dvb->priv;
357 struct tda1004x_state *state = fe->demodulator_priv;
358 u8 addr = state->config->tuner_address;
346 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab }; 359 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
347 struct i2c_msg init_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) }; 360 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
348 361
349 /* setup PLL configuration */ 362 /* setup PLL configuration */
350 if (fe->ops.i2c_gate_ctrl) 363 if (fe->ops.i2c_gate_ctrl)
351 fe->ops.i2c_gate_ctrl(fe, 1); 364 fe->ops.i2c_gate_ctrl(fe, 1);
352 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1) 365 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
353 return -EIO; 366 return -EIO;
354 if (fe->ops.i2c_gate_ctrl)
355 fe->ops.i2c_gate_ctrl(fe, 0);
356 return 0; 367 return 0;
357} 368}
358 369
359static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 370static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
360{ 371{
361 return philips_tda6651_pll_set(0x61, fe, params); 372 return philips_tda6651_pll_set(fe, params);
373}
374
375static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
376{
377 struct saa7134_dev *dev = fe->dvb->priv;
378 struct tda1004x_state *state = fe->demodulator_priv;
379 u8 addr = state->config->tuner_address;
380 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
381 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
382
383 /* switch the tuner to analog mode */
384 if (fe->ops.i2c_gate_ctrl)
385 fe->ops.i2c_gate_ctrl(fe, 1);
386 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
387 return -EIO;
388 return 0;
362} 389}
363 390
391/* ------------------------------------------------------------------ */
392
364static int philips_europa_tuner_init(struct dvb_frontend *fe) 393static int philips_europa_tuner_init(struct dvb_frontend *fe)
365{ 394{
366 struct saa7134_dev *dev = fe->dvb->priv; 395 struct saa7134_dev *dev = fe->dvb->priv;
@@ -380,18 +409,14 @@ static int philips_europa_tuner_init(struct dvb_frontend *fe)
380static int philips_europa_tuner_sleep(struct dvb_frontend *fe) 409static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
381{ 410{
382 struct saa7134_dev *dev = fe->dvb->priv; 411 struct saa7134_dev *dev = fe->dvb->priv;
383 /* this message actually turns the tuner back to analog mode */
384 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
385 struct i2c_msg analog_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
386 412
387 i2c_transfer(&dev->i2c_adap, &analog_msg, 1); 413 static u8 msg[] = { 0x00, 0x14 };
388 msleep(1); 414 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
415
416 if (philips_td1316_tuner_sleep(fe))
417 return -EIO;
389 418
390 /* switch the board to analog mode */ 419 /* switch the board to analog mode */
391 analog_msg.addr = 0x43;
392 analog_msg.len = 0x02;
393 msg[0] = 0x00;
394 msg[1] = 0x14;
395 if (fe->ops.i2c_gate_ctrl) 420 if (fe->ops.i2c_gate_ctrl)
396 fe->ops.i2c_gate_ctrl(fe, 1); 421 fe->ops.i2c_gate_ctrl(fe, 1);
397 i2c_transfer(&dev->i2c_adap, &analog_msg, 1); 422 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
@@ -416,7 +441,8 @@ static struct tda1004x_config philips_europa_config = {
416 .xtal_freq = TDA10046_XTAL_4M, 441 .xtal_freq = TDA10046_XTAL_4M,
417 .agc_config = TDA10046_AGC_IFO_AUTO_POS, 442 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
418 .if_freq = TDA10046_FREQ_052, 443 .if_freq = TDA10046_FREQ_052,
419 .request_firmware = philips_tda1004x_request_firmware, 444 .tuner_address = 0x61,
445 .request_firmware = philips_tda1004x_request_firmware
420}; 446};
421 447
422/* ------------------------------------------------------------------ */ 448/* ------------------------------------------------------------------ */
@@ -424,9 +450,11 @@ static struct tda1004x_config philips_europa_config = {
424static int philips_fmd1216_tuner_init(struct dvb_frontend *fe) 450static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
425{ 451{
426 struct saa7134_dev *dev = fe->dvb->priv; 452 struct saa7134_dev *dev = fe->dvb->priv;
453 struct tda1004x_state *state = fe->demodulator_priv;
454 u8 addr = state->config->tuner_address;
427 /* this message is to set up ATC and ALC */ 455 /* this message is to set up ATC and ALC */
428 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 }; 456 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
429 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) }; 457 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
430 458
431 if (fe->ops.i2c_gate_ctrl) 459 if (fe->ops.i2c_gate_ctrl)
432 fe->ops.i2c_gate_ctrl(fe, 1); 460 fe->ops.i2c_gate_ctrl(fe, 1);
@@ -440,9 +468,11 @@ static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
440static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe) 468static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
441{ 469{
442 struct saa7134_dev *dev = fe->dvb->priv; 470 struct saa7134_dev *dev = fe->dvb->priv;
471 struct tda1004x_state *state = fe->demodulator_priv;
472 u8 addr = state->config->tuner_address;
443 /* this message actually turns the tuner back to analog mode */ 473 /* this message actually turns the tuner back to analog mode */
444 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 }; 474 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
445 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) }; 475 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
446 476
447 if (fe->ops.i2c_gate_ctrl) 477 if (fe->ops.i2c_gate_ctrl)
448 fe->ops.i2c_gate_ctrl(fe, 1); 478 fe->ops.i2c_gate_ctrl(fe, 1);
@@ -460,8 +490,10 @@ static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
460static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 490static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
461{ 491{
462 struct saa7134_dev *dev = fe->dvb->priv; 492 struct saa7134_dev *dev = fe->dvb->priv;
493 struct tda1004x_state *state = fe->demodulator_priv;
494 u8 addr = state->config->tuner_address;
463 u8 tuner_buf[4]; 495 u8 tuner_buf[4];
464 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len = 496 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
465 sizeof(tuner_buf) }; 497 sizeof(tuner_buf) };
466 int tuner_frequency = 0; 498 int tuner_frequency = 0;
467 int divider = 0; 499 int divider = 0;
@@ -536,8 +568,10 @@ static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_
536 568
537 if (fe->ops.i2c_gate_ctrl) 569 if (fe->ops.i2c_gate_ctrl)
538 fe->ops.i2c_gate_ctrl(fe, 1); 570 fe->ops.i2c_gate_ctrl(fe, 1);
539 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) 571 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
572 printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
540 return -EIO; 573 return -EIO;
574 }
541 return 0; 575 return 0;
542} 576}
543 577
@@ -548,9 +582,76 @@ static struct tda1004x_config medion_cardbus = {
548 .xtal_freq = TDA10046_XTAL_16M, 582 .xtal_freq = TDA10046_XTAL_16M,
549 .agc_config = TDA10046_AGC_IFO_AUTO_NEG, 583 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
550 .if_freq = TDA10046_FREQ_3613, 584 .if_freq = TDA10046_FREQ_3613,
551 .request_firmware = philips_tda1004x_request_firmware, 585 .tuner_address = 0x61,
586 .request_firmware = philips_tda1004x_request_firmware
552}; 587};
553 588
589/* ------------------------------------------------------------------
590 * tda 1004x based cards with philips silicon tuner
591 */
592
593static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
594{
595 struct saa7134_dev *dev = fe->dvb->priv;
596 struct tda1004x_state *state = fe->demodulator_priv;
597 u8 addr = state->config->i2c_gate;
598 u8 config = state->config->tuner_config;
599 u8 GP00_CF[] = {0x20, 0x01};
600 u8 GP00_LEV[] = {0x22, 0x00};
601
602 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
603 if (config) {
604 if (high) {
605 dprintk("setting LNA to high gain\n");
606 } else {
607 dprintk("setting LNA to low gain\n");
608 }
609 }
610 switch (config) {
611 case 0: /* no LNA */
612 break;
613 case 1: /* switch is GPIO 0 of tda8290 */
614 case 2:
615 /* turn Vsync off */
616 saa7134_set_gpio(dev, 22, 0);
617 GP00_LEV[1] = high ? 0 : 1;
618 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
619 printk("%s/dvb: could not access tda8290 at addr: 0x%02x\n",dev->name, addr << 1);
620 return;
621 }
622 msg.buf = GP00_LEV;
623 if (config == 2)
624 GP00_LEV[1] = high ? 1 : 0;
625 i2c_transfer(&dev->i2c_adap, &msg, 1);
626 break;
627 case 3: /* switch with GPIO of saa713x */
628 saa7134_set_gpio(dev, 22, high);
629 break;
630 }
631}
632
633static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
634{
635 struct saa7134_dev *dev = fe->dvb->priv;
636 struct tda1004x_state *state = fe->demodulator_priv;
637
638 u8 addr = state->config->i2c_gate;
639 static u8 tda8290_close[] = { 0x21, 0xc0};
640 static u8 tda8290_open[] = { 0x21, 0x80};
641 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
642 if (enable) {
643 tda8290_msg.buf = tda8290_close;
644 } else {
645 tda8290_msg.buf = tda8290_open;
646 }
647 if (i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1) != 1) {
648 printk("%s/dvb: could not access tda8290 I2C gate\n",dev->name);
649 return -EIO;
650 }
651 msleep(20);
652 return 0;
653}
654
554/* ------------------------------------------------------------------ */ 655/* ------------------------------------------------------------------ */
555 656
556struct tda827x_data { 657struct tda827x_data {
@@ -595,17 +696,14 @@ static struct tda827x_data tda827x_dvbt[] = {
595 { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0} 696 { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
596}; 697};
597 698
598static int philips_tda827x_tuner_init(struct dvb_frontend *fe) 699static int philips_tda827xo_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
599{
600 return 0;
601}
602
603static int philips_tda827x_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
604{ 700{
605 struct saa7134_dev *dev = fe->dvb->priv; 701 struct saa7134_dev *dev = fe->dvb->priv;
702 struct tda1004x_state *state = fe->demodulator_priv;
703 u8 addr = state->config->tuner_address;
606 u8 tuner_buf[14]; 704 u8 tuner_buf[14];
607 705
608 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf, 706 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,
609 .len = sizeof(tuner_buf) }; 707 .len = sizeof(tuner_buf) };
610 int i, tuner_freq, if_freq; 708 int i, tuner_freq, if_freq;
611 u32 N; 709 u32 N;
@@ -649,9 +747,10 @@ static int philips_tda827x_tuner_set_params(struct dvb_frontend *fe, struct dvb_
649 tuner_msg.len = 14; 747 tuner_msg.len = 14;
650 if (fe->ops.i2c_gate_ctrl) 748 if (fe->ops.i2c_gate_ctrl)
651 fe->ops.i2c_gate_ctrl(fe, 1); 749 fe->ops.i2c_gate_ctrl(fe, 1);
652 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) 750 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
751 printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
653 return -EIO; 752 return -EIO;
654 753 }
655 msleep(500); 754 msleep(500);
656 /* correct CP value */ 755 /* correct CP value */
657 tuner_buf[0] = 0x30; 756 tuner_buf[0] = 0x30;
@@ -664,11 +763,13 @@ static int philips_tda827x_tuner_set_params(struct dvb_frontend *fe, struct dvb_
664 return 0; 763 return 0;
665} 764}
666 765
667static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe) 766static int philips_tda827xo_tuner_sleep(struct dvb_frontend *fe)
668{ 767{
669 struct saa7134_dev *dev = fe->dvb->priv; 768 struct saa7134_dev *dev = fe->dvb->priv;
769 struct tda1004x_state *state = fe->demodulator_priv;
770 u8 addr = state->config->tuner_address;
670 static u8 tda827x_sleep[] = { 0x30, 0xd0}; 771 static u8 tda827x_sleep[] = { 0x30, 0xd0};
671 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep, 772 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827x_sleep,
672 .len = sizeof(tda827x_sleep) }; 773 .len = sizeof(tda827x_sleep) };
673 if (fe->ops.i2c_gate_ctrl) 774 if (fe->ops.i2c_gate_ctrl)
674 fe->ops.i2c_gate_ctrl(fe, 1); 775 fe->ops.i2c_gate_ctrl(fe, 1);
@@ -676,17 +777,6 @@ static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
676 return 0; 777 return 0;
677} 778}
678 779
679static struct tda1004x_config tda827x_lifeview_config = {
680 .demod_address = 0x08,
681 .invert = 1,
682 .invert_oclk = 0,
683 .xtal_freq = TDA10046_XTAL_16M,
684 .agc_config = TDA10046_AGC_TDA827X,
685 .gpio_config = TDA10046_GP11_I,
686 .if_freq = TDA10046_FREQ_045,
687 .request_firmware = philips_tda1004x_request_firmware,
688};
689
690/* ------------------------------------------------------------------ */ 780/* ------------------------------------------------------------------ */
691 781
692struct tda827xa_data { 782struct tda827xa_data {
@@ -727,17 +817,20 @@ static struct tda827xa_data tda827xa_dvbt[] = {
727 { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0}, 817 { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
728 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}}; 818 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}};
729 819
730 820static int philips_tda827xa_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
731static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
732{ 821{
733 struct saa7134_dev *dev = fe->dvb->priv; 822 struct saa7134_dev *dev = fe->dvb->priv;
734 u8 tuner_buf[14]; 823 struct tda1004x_state *state = fe->demodulator_priv;
735 unsigned char reg2[2]; 824 u8 addr = state->config->tuner_address;
825 u8 tuner_buf[10];
736 826
737 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf}; 827 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf};
738 int i, tuner_freq, if_freq; 828 int i, tuner_freq, if_freq;
739 u32 N; 829 u32 N;
740 830
831 philips_tda827x_lna_gain( fe, 1);
832 msleep(20);
833
741 switch (params->u.ofdm.bandwidth) { 834 switch (params->u.ofdm.bandwidth) {
742 case BANDWIDTH_6_MHZ: 835 case BANDWIDTH_6_MHZ:
743 if_freq = 4000000; 836 if_freq = 4000000;
@@ -767,45 +860,82 @@ static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb
767 tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) + 860 tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) +
768 tda827xa_dvbt[i].sbs; 861 tda827xa_dvbt[i].sbs;
769 tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4); 862 tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4);
770 tuner_buf[7] = 0x0c; 863 tuner_buf[7] = 0x1c;
771 tuner_buf[8] = 0x06; 864 tuner_buf[8] = 0x06;
772 tuner_buf[9] = 0x24; 865 tuner_buf[9] = 0x24;
773 tuner_buf[10] = 0xff; 866 tuner_buf[10] = 0x00;
774 tuner_buf[11] = 0x60; 867 msg.len = 11;
775 tuner_buf[12] = 0x00;
776 tuner_buf[13] = 0x39; // lpsel
777 msg.len = 14;
778 if (fe->ops.i2c_gate_ctrl) 868 if (fe->ops.i2c_gate_ctrl)
779 fe->ops.i2c_gate_ctrl(fe, 1); 869 fe->ops.i2c_gate_ctrl(fe, 1);
780 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) 870 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
871 printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
781 return -EIO; 872 return -EIO;
873 }
874 tuner_buf[0] = 0x90;
875 tuner_buf[1] = 0xff;
876 tuner_buf[2] = 0x60;
877 tuner_buf[3] = 0x00;
878 tuner_buf[4] = 0x59; // lpsel, for 6MHz + 2
879 msg.len = 5;
880 if (fe->ops.i2c_gate_ctrl)
881 fe->ops.i2c_gate_ctrl(fe, 1);
882 i2c_transfer(&dev->i2c_adap, &msg, 1);
782 883
783 msg.buf= reg2; 884 tuner_buf[0] = 0xa0;
885 tuner_buf[1] = 0x40;
784 msg.len = 2; 886 msg.len = 2;
785 reg2[0] = 0x60;
786 reg2[1] = 0x3c;
787 if (fe->ops.i2c_gate_ctrl) 887 if (fe->ops.i2c_gate_ctrl)
788 fe->ops.i2c_gate_ctrl(fe, 1); 888 fe->ops.i2c_gate_ctrl(fe, 1);
789 i2c_transfer(&dev->i2c_adap, &msg, 1); 889 i2c_transfer(&dev->i2c_adap, &msg, 1);
790 890
791 reg2[0] = 0xa0; 891 msleep(11);
792 reg2[1] = 0x40; 892 msg.flags = I2C_M_RD;
893 if (fe->ops.i2c_gate_ctrl)
894 fe->ops.i2c_gate_ctrl(fe, 1);
895 i2c_transfer(&dev->i2c_adap, &msg, 1);
896 msg.flags = 0;
897
898 tuner_buf[1] >>= 4;
899 dprintk("tda8275a AGC2 gain is: %d\n", tuner_buf[1]);
900 if ((tuner_buf[1]) < 2) {
901 philips_tda827x_lna_gain(fe, 0);
902 tuner_buf[0] = 0x60;
903 tuner_buf[1] = 0x0c;
904 if (fe->ops.i2c_gate_ctrl)
905 fe->ops.i2c_gate_ctrl(fe, 1);
906 i2c_transfer(&dev->i2c_adap, &msg, 1);
907 }
908
909 tuner_buf[0] = 0xc0;
910 tuner_buf[1] = 0x99; // lpsel, for 6MHz + 2
911 if (fe->ops.i2c_gate_ctrl)
912 fe->ops.i2c_gate_ctrl(fe, 1);
913 i2c_transfer(&dev->i2c_adap, &msg, 1);
914
915 tuner_buf[0] = 0x60;
916 tuner_buf[1] = 0x3c;
793 if (fe->ops.i2c_gate_ctrl) 917 if (fe->ops.i2c_gate_ctrl)
794 fe->ops.i2c_gate_ctrl(fe, 1); 918 fe->ops.i2c_gate_ctrl(fe, 1);
795 i2c_transfer(&dev->i2c_adap, &msg, 1); 919 i2c_transfer(&dev->i2c_adap, &msg, 1);
796 920
797 msleep(2);
798 /* correct CP value */ 921 /* correct CP value */
799 reg2[0] = 0x30; 922 tuner_buf[0] = 0x30;
800 reg2[1] = 0x10 + tda827xa_dvbt[i].scr; 923 tuner_buf[1] = 0x10 + tda827xa_dvbt[i].scr;
801 msg.len = 2; 924 if (fe->ops.i2c_gate_ctrl)
925 fe->ops.i2c_gate_ctrl(fe, 1);
926 i2c_transfer(&dev->i2c_adap, &msg, 1);
927
928 msleep(163);
929 tuner_buf[0] = 0xc0;
930 tuner_buf[1] = 0x39; // lpsel, for 6MHz + 2
802 if (fe->ops.i2c_gate_ctrl) 931 if (fe->ops.i2c_gate_ctrl)
803 fe->ops.i2c_gate_ctrl(fe, 1); 932 fe->ops.i2c_gate_ctrl(fe, 1);
804 i2c_transfer(&dev->i2c_adap, &msg, 1); 933 i2c_transfer(&dev->i2c_adap, &msg, 1);
805 934
806 msleep(550); 935 msleep(3);
807 reg2[0] = 0x50; 936 /* freeze AGC1 */
808 reg2[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4); 937 tuner_buf[0] = 0x50;
938 tuner_buf[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4);
809 if (fe->ops.i2c_gate_ctrl) 939 if (fe->ops.i2c_gate_ctrl)
810 fe->ops.i2c_gate_ctrl(fe, 1); 940 fe->ops.i2c_gate_ctrl(fe, 1);
811 i2c_transfer(&dev->i2c_adap, &msg, 1); 941 i2c_transfer(&dev->i2c_adap, &msg, 1);
@@ -814,9 +944,11 @@ static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb
814 944
815} 945}
816 946
817static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe) 947static int philips_tda827xa_tuner_sleep(struct dvb_frontend *fe)
818{ 948{
819 struct saa7134_dev *dev = fe->dvb->priv; 949 struct saa7134_dev *dev = fe->dvb->priv;
950 struct tda1004x_state *state = fe->demodulator_priv;
951 u8 addr = state->config->tuner_address;
820 static u8 tda827xa_sleep[] = { 0x30, 0x90}; 952 static u8 tda827xa_sleep[] = { 0x30, 0x90};
821 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep, 953 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep,
822 .len = sizeof(tda827xa_sleep) }; 954 .len = sizeof(tda827xa_sleep) };
@@ -828,60 +960,98 @@ static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe)
828 return 0; 960 return 0;
829} 961}
830 962
831/* ------------------------------------------------------------------ */ 963/* ------------------------------------------------------------------
964 * upper layer: distinguish the silicon tuner versions
965 */
832 966
833static int tda8290_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) 967static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
834{ 968{
835 struct saa7134_dev *dev = fe->dvb->priv; 969 struct saa7134_dev *dev = fe->dvb->priv;
836 static u8 tda8290_close[] = { 0x21, 0xc0}; 970 struct tda1004x_state *state = fe->demodulator_priv;
837 static u8 tda8290_open[] = { 0x21, 0x80}; 971 u8 addr = state->config->tuner_address;
838 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2}; 972 u8 data;
839 if (enable) { 973 struct i2c_msg tuner_msg = {.addr = addr,.flags = I2C_M_RD,.buf = &data, .len = 1};
840 tda8290_msg.buf = tda8290_close; 974 state->conf_probed = 0;
975 if (fe->ops.i2c_gate_ctrl)
976 fe->ops.i2c_gate_ctrl(fe, 1);
977 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
978 printk("%s/dvb: could not read from tuner at addr: 0x%02x\n",dev->name, addr << 1);
979 return -EIO;
980 }
981 if ((data & 0x3c) == 0) {
982 dprintk("tda827x tuner found\n");
983 state->conf_probed = 1;
841 } else { 984 } else {
842 tda8290_msg.buf = tda8290_open; 985 dprintk("tda827xa tuner found\n");
986 state->conf_probed = 2;
987 }
988 switch (state->config->antenna_switch) {
989 case 0: break;
990 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
991 saa7134_set_gpio(dev, 21, 0);
992 break;
993 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
994 saa7134_set_gpio(dev, 21, 1);
995 break;
843 } 996 }
844 if (i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1) != 1)
845 return -EIO;
846 msleep(20);
847 return 0; 997 return 0;
848} 998}
849 999
850/* ------------------------------------------------------------------ */ 1000static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
851
852static int philips_tiger_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
853{ 1001{
854 int ret; 1002 struct saa7134_dev *dev = fe->dvb->priv;
855 1003 struct tda1004x_state *state = fe->demodulator_priv;
856 ret = philips_tda827xa_pll_set(0x61, fe, params); 1004 switch (state->conf_probed) {
857 if (ret != 0) 1005 case 1: philips_tda827xo_tuner_sleep(fe);
858 return ret; 1006 break;
1007 case 2: philips_tda827xa_tuner_sleep(fe);
1008 break;
1009 default: dprintk("Huh? unknown tda827x version!\n");
1010 return -EIO;
1011 }
1012 switch (state->config->antenna_switch) {
1013 case 0: break;
1014 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
1015 saa7134_set_gpio(dev, 21, 1);
1016 break;
1017 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
1018 saa7134_set_gpio(dev, 21, 0);
1019 break;
1020 }
859 return 0; 1021 return 0;
860} 1022}
861 1023
862static int philips_tiger_tuner_init(struct dvb_frontend *fe) 1024static int philips_tda827x_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
863{ 1025{
864 struct saa7134_dev *dev = fe->dvb->priv; 1026 struct saa7134_dev *dev = fe->dvb->priv;
865 static u8 data[] = { 0x3c, 0x33, 0x6a}; 1027 struct tda1004x_state *state = fe->demodulator_priv;
866 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; 1028 switch (state->conf_probed) {
867 1029 case 1: philips_tda827xo_pll_set(fe, params);
868 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) 1030 break;
1031 case 2: philips_tda827xa_pll_set(fe, params);
1032 break;
1033 default: dprintk("Huh? unknown tda827x version!\n");
869 return -EIO; 1034 return -EIO;
1035 }
870 return 0; 1036 return 0;
871} 1037}
872 1038
873static int philips_tiger_tuner_sleep(struct dvb_frontend *fe) 1039static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf,
1040 char *board_name)
874{ 1041{
875 struct saa7134_dev *dev = fe->dvb->priv; 1042 dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
876 static u8 data[] = { 0x3c, 0x33, 0x68}; 1043 if (dev->dvb.frontend) {
877 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; 1044 if (tda_conf->i2c_gate)
878 1045 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
879 i2c_transfer(&dev->i2c_adap, &msg, 1); 1046 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
880 philips_tda827xa_tuner_sleep( 0x61, fe); 1047 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
881 return 0; 1048 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_pll_set;
1049 }
1050 philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
882} 1051}
883 1052
884static struct tda1004x_config philips_tiger_config = { 1053/* ------------------------------------------------------------------ */
1054static struct tda1004x_config tda827x_lifeview_config = {
885 .demod_address = 0x08, 1055 .demod_address = 0x08,
886 .invert = 1, 1056 .invert = 1,
887 .invert_oclk = 0, 1057 .invert_oclk = 0,
@@ -889,31 +1059,24 @@ static struct tda1004x_config philips_tiger_config = {
889 .agc_config = TDA10046_AGC_TDA827X, 1059 .agc_config = TDA10046_AGC_TDA827X,
890 .gpio_config = TDA10046_GP11_I, 1060 .gpio_config = TDA10046_GP11_I,
891 .if_freq = TDA10046_FREQ_045, 1061 .if_freq = TDA10046_FREQ_045,
892 .request_firmware = philips_tda1004x_request_firmware, 1062 .tuner_address = 0x60,
1063 .request_firmware = philips_tda1004x_request_firmware
893}; 1064};
894/* ------------------------------------------------------------------ */
895
896static int cinergy_ht_tuner_init(struct dvb_frontend *fe)
897{
898 struct saa7134_dev *dev = fe->dvb->priv;
899 static u8 data[] = { 0x3c, 0x33, 0x62};
900 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
901
902 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
903 return -EIO;
904 return 0;
905}
906
907static int cinergy_ht_tuner_sleep(struct dvb_frontend *fe)
908{
909 struct saa7134_dev *dev = fe->dvb->priv;
910 static u8 data[] = { 0x3c, 0x33, 0x60};
911 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
912 1065
913 i2c_transfer(&dev->i2c_adap, &msg, 1); 1066static struct tda1004x_config philips_tiger_config = {
914 philips_tda827xa_tuner_sleep( 0x61, fe); 1067 .demod_address = 0x08,
915 return 0; 1068 .invert = 1,
916} 1069 .invert_oclk = 0,
1070 .xtal_freq = TDA10046_XTAL_16M,
1071 .agc_config = TDA10046_AGC_TDA827X,
1072 .gpio_config = TDA10046_GP11_I,
1073 .if_freq = TDA10046_FREQ_045,
1074 .i2c_gate = 0x4b,
1075 .tuner_address = 0x61,
1076 .tuner_config = 0,
1077 .antenna_switch= 1,
1078 .request_firmware = philips_tda1004x_request_firmware
1079};
917 1080
918static struct tda1004x_config cinergy_ht_config = { 1081static struct tda1004x_config cinergy_ht_config = {
919 .demod_address = 0x08, 1082 .demod_address = 0x08,
@@ -923,10 +1086,40 @@ static struct tda1004x_config cinergy_ht_config = {
923 .agc_config = TDA10046_AGC_TDA827X, 1086 .agc_config = TDA10046_AGC_TDA827X,
924 .gpio_config = TDA10046_GP01_I, 1087 .gpio_config = TDA10046_GP01_I,
925 .if_freq = TDA10046_FREQ_045, 1088 .if_freq = TDA10046_FREQ_045,
926 .request_firmware = philips_tda1004x_request_firmware, 1089 .i2c_gate = 0x4b,
1090 .tuner_address = 0x61,
1091 .tuner_config = 0,
1092 .request_firmware = philips_tda1004x_request_firmware
927}; 1093};
928 1094
929/* ------------------------------------------------------------------ */ 1095static struct tda1004x_config cinergy_ht_pci_config = {
1096 .demod_address = 0x08,
1097 .invert = 1,
1098 .invert_oclk = 0,
1099 .xtal_freq = TDA10046_XTAL_16M,
1100 .agc_config = TDA10046_AGC_TDA827X,
1101 .gpio_config = TDA10046_GP01_I,
1102 .if_freq = TDA10046_FREQ_045,
1103 .i2c_gate = 0x4b,
1104 .tuner_address = 0x60,
1105 .tuner_config = 0,
1106 .request_firmware = philips_tda1004x_request_firmware
1107};
1108
1109static struct tda1004x_config philips_tiger_s_config = {
1110 .demod_address = 0x08,
1111 .invert = 1,
1112 .invert_oclk = 0,
1113 .xtal_freq = TDA10046_XTAL_16M,
1114 .agc_config = TDA10046_AGC_TDA827X,
1115 .gpio_config = TDA10046_GP01_I,
1116 .if_freq = TDA10046_FREQ_045,
1117 .i2c_gate = 0x4b,
1118 .tuner_address = 0x61,
1119 .tuner_config = 2,
1120 .antenna_switch= 1,
1121 .request_firmware = philips_tda1004x_request_firmware
1122};
930 1123
931static struct tda1004x_config pinnacle_pctv_310i_config = { 1124static struct tda1004x_config pinnacle_pctv_310i_config = {
932 .demod_address = 0x08, 1125 .demod_address = 0x08,
@@ -936,11 +1129,12 @@ static struct tda1004x_config pinnacle_pctv_310i_config = {
936 .agc_config = TDA10046_AGC_TDA827X, 1129 .agc_config = TDA10046_AGC_TDA827X,
937 .gpio_config = TDA10046_GP11_I, 1130 .gpio_config = TDA10046_GP11_I,
938 .if_freq = TDA10046_FREQ_045, 1131 .if_freq = TDA10046_FREQ_045,
939 .request_firmware = philips_tda1004x_request_firmware, 1132 .i2c_gate = 0x4b,
1133 .tuner_address = 0x61,
1134 .tuner_config = 1,
1135 .request_firmware = philips_tda1004x_request_firmware
940}; 1136};
941 1137
942/* ------------------------------------------------------------------ */
943
944static struct tda1004x_config hauppauge_hvr_1110_config = { 1138static struct tda1004x_config hauppauge_hvr_1110_config = {
945 .demod_address = 0x08, 1139 .demod_address = 0x08,
946 .invert = 1, 1140 .invert = 1,
@@ -949,11 +1143,11 @@ static struct tda1004x_config hauppauge_hvr_1110_config = {
949 .agc_config = TDA10046_AGC_TDA827X, 1143 .agc_config = TDA10046_AGC_TDA827X,
950 .gpio_config = TDA10046_GP11_I, 1144 .gpio_config = TDA10046_GP11_I,
951 .if_freq = TDA10046_FREQ_045, 1145 .if_freq = TDA10046_FREQ_045,
952 .request_firmware = philips_tda1004x_request_firmware, 1146 .i2c_gate = 0x4b,
1147 .tuner_address = 0x61,
1148 .request_firmware = philips_tda1004x_request_firmware
953}; 1149};
954 1150
955/* ------------------------------------------------------------------ */
956
957static struct tda1004x_config asus_p7131_dual_config = { 1151static struct tda1004x_config asus_p7131_dual_config = {
958 .demod_address = 0x08, 1152 .demod_address = 0x08,
959 .invert = 1, 1153 .invert = 1,
@@ -962,51 +1156,13 @@ static struct tda1004x_config asus_p7131_dual_config = {
962 .agc_config = TDA10046_AGC_TDA827X, 1156 .agc_config = TDA10046_AGC_TDA827X,
963 .gpio_config = TDA10046_GP11_I, 1157 .gpio_config = TDA10046_GP11_I,
964 .if_freq = TDA10046_FREQ_045, 1158 .if_freq = TDA10046_FREQ_045,
965 .request_firmware = philips_tda1004x_request_firmware, 1159 .i2c_gate = 0x4b,
1160 .tuner_address = 0x61,
1161 .tuner_config = 0,
1162 .antenna_switch= 2,
1163 .request_firmware = philips_tda1004x_request_firmware
966}; 1164};
967 1165
968static int asus_p7131_dual_tuner_init(struct dvb_frontend *fe)
969{
970 struct saa7134_dev *dev = fe->dvb->priv;
971 static u8 data[] = { 0x3c, 0x33, 0x6a};
972 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
973
974 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
975 return -EIO;
976 /* make sure the DVB-T antenna input is set */
977 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
978 return 0;
979}
980
981static int asus_p7131_dual_tuner_sleep(struct dvb_frontend *fe)
982{
983 struct saa7134_dev *dev = fe->dvb->priv;
984 static u8 data[] = { 0x3c, 0x33, 0x68};
985 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
986
987 i2c_transfer(&dev->i2c_adap, &msg, 1);
988 philips_tda827xa_tuner_sleep( 0x61, fe);
989 /* reset antenna inputs for analog usage */
990 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
991 return 0;
992}
993
994/* ------------------------------------------------------------------ */
995
996static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
997{
998 int ret;
999
1000 ret = philips_tda827xa_pll_set(0x60, fe, params);
1001 return ret;
1002}
1003
1004static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe)
1005{
1006 philips_tda827xa_tuner_sleep(0x60, fe);
1007 return 0;
1008}
1009
1010static struct tda1004x_config lifeview_trio_config = { 1166static struct tda1004x_config lifeview_trio_config = {
1011 .demod_address = 0x09, 1167 .demod_address = 0x09,
1012 .invert = 1, 1168 .invert = 1,
@@ -1015,125 +1171,82 @@ static struct tda1004x_config lifeview_trio_config = {
1015 .agc_config = TDA10046_AGC_TDA827X, 1171 .agc_config = TDA10046_AGC_TDA827X,
1016 .gpio_config = TDA10046_GP00_I, 1172 .gpio_config = TDA10046_GP00_I,
1017 .if_freq = TDA10046_FREQ_045, 1173 .if_freq = TDA10046_FREQ_045,
1018 .request_firmware = philips_tda1004x_request_firmware, 1174 .tuner_address = 0x60,
1175 .request_firmware = philips_tda1004x_request_firmware
1019}; 1176};
1020 1177
1021/* ------------------------------------------------------------------ */ 1178static struct tda1004x_config tevion_dvbt220rf_config = {
1022
1023static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1024{
1025 int ret;
1026
1027 ret = philips_tda827xa_pll_set(0x61, fe, params);
1028 return ret;
1029}
1030
1031static int ads_duo_tuner_init(struct dvb_frontend *fe)
1032{
1033 struct saa7134_dev *dev = fe->dvb->priv;
1034 /* route TDA8275a AGC input to the channel decoder */
1035 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60);
1036 return 0;
1037}
1038
1039static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
1040{
1041 struct saa7134_dev *dev = fe->dvb->priv;
1042 /* route TDA8275a AGC input to the analog IF chip*/
1043 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20);
1044 philips_tda827xa_tuner_sleep( 0x61, fe);
1045 return 0;
1046}
1047
1048static struct tda1004x_config ads_tech_duo_config = {
1049 .demod_address = 0x08, 1179 .demod_address = 0x08,
1050 .invert = 1, 1180 .invert = 1,
1051 .invert_oclk = 0, 1181 .invert_oclk = 0,
1052 .xtal_freq = TDA10046_XTAL_16M, 1182 .xtal_freq = TDA10046_XTAL_16M,
1053 .agc_config = TDA10046_AGC_TDA827X, 1183 .agc_config = TDA10046_AGC_TDA827X,
1054 .gpio_config = TDA10046_GP00_I, 1184 .gpio_config = TDA10046_GP11_I,
1055 .if_freq = TDA10046_FREQ_045, 1185 .if_freq = TDA10046_FREQ_045,
1056 .request_firmware = philips_tda1004x_request_firmware, 1186 .tuner_address = 0x60,
1187 .request_firmware = philips_tda1004x_request_firmware
1057}; 1188};
1058 1189
1059/* ------------------------------------------------------------------ */ 1190static struct tda1004x_config md8800_dvbt_config = {
1060
1061static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1062{
1063 int ret;
1064 ret = philips_tda827xa_pll_set(0x60, fe, params);
1065 return ret;
1066}
1067
1068static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe)
1069{
1070 philips_tda827xa_tuner_sleep( 0x61, fe);
1071 return 0;
1072}
1073
1074static struct tda1004x_config tevion_dvbt220rf_config = {
1075 .demod_address = 0x08, 1191 .demod_address = 0x08,
1076 .invert = 1, 1192 .invert = 1,
1077 .invert_oclk = 0, 1193 .invert_oclk = 0,
1078 .xtal_freq = TDA10046_XTAL_16M, 1194 .xtal_freq = TDA10046_XTAL_16M,
1079 .agc_config = TDA10046_AGC_TDA827X, 1195 .agc_config = TDA10046_AGC_TDA827X,
1080 .gpio_config = TDA10046_GP11_I, 1196 .gpio_config = TDA10046_GP01_I,
1081 .if_freq = TDA10046_FREQ_045, 1197 .if_freq = TDA10046_FREQ_045,
1082 .request_firmware = philips_tda1004x_request_firmware, 1198 .i2c_gate = 0x4b,
1199 .tuner_address = 0x60,
1200 .tuner_config = 0,
1201 .request_firmware = philips_tda1004x_request_firmware
1083}; 1202};
1084 1203
1085/* ------------------------------------------------------------------ */ 1204/* ------------------------------------------------------------------
1205 * special case: this card uses saa713x GPIO22 for the mode switch
1206 */
1086 1207
1087static int md8800_dvbt_analog_mode(struct dvb_frontend *fe) 1208static int ads_duo_tuner_init(struct dvb_frontend *fe)
1088{ 1209{
1089 struct saa7134_dev *dev = fe->dvb->priv; 1210 struct saa7134_dev *dev = fe->dvb->priv;
1090 static u8 data[] = { 0x3c, 0x33, 0x68}; 1211 philips_tda827x_tuner_init(fe);
1091 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; 1212 /* route TDA8275a AGC input to the channel decoder */
1092 1213 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0400000);
1093 i2c_transfer(&dev->i2c_adap, &msg, 1);
1094 philips_tda827xa_tuner_sleep( 0x61, fe);
1095 return 0; 1214 return 0;
1096} 1215}
1097 1216
1098static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 1217static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
1099{ 1218{
1100 int ret;
1101 struct saa7134_dev *dev = fe->dvb->priv; 1219 struct saa7134_dev *dev = fe->dvb->priv;
1102 static u8 tda8290_close[] = { 0x21, 0xc0}; 1220 /* route TDA8275a AGC input to the analog IF chip*/
1103 static u8 tda8290_open[] = { 0x21, 0x80}; 1221 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0400000);
1104 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2}; 1222 philips_tda827x_tuner_sleep(fe);
1105 /* close tda8290 i2c bridge */ 1223 return 0;
1106 tda8290_msg.buf = tda8290_close;
1107 ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1108 if (ret != 1)
1109 return -EIO;
1110 msleep(20);
1111 ret = philips_tda827xa_pll_set(0x60, fe, params);
1112 if (ret != 0)
1113 return ret;
1114 /* open tda8290 i2c bridge */
1115 tda8290_msg.buf = tda8290_open;
1116 i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1117 return ret;
1118} 1224}
1119 1225
1120static struct tda1004x_config md8800_dvbt_config = { 1226static struct tda1004x_config ads_tech_duo_config = {
1121 .demod_address = 0x08, 1227 .demod_address = 0x08,
1122 .invert = 1, 1228 .invert = 1,
1123 .invert_oclk = 0, 1229 .invert_oclk = 0,
1124 .xtal_freq = TDA10046_XTAL_16M, 1230 .xtal_freq = TDA10046_XTAL_16M,
1125 .agc_config = TDA10046_AGC_TDA827X, 1231 .agc_config = TDA10046_AGC_TDA827X,
1126 .gpio_config = TDA10046_GP11_I, 1232 .gpio_config = TDA10046_GP00_I,
1127 .if_freq = TDA10046_FREQ_045, 1233 .if_freq = TDA10046_FREQ_045,
1128 .request_firmware = philips_tda1004x_request_firmware, 1234 .tuner_address = 0x61,
1235 .request_firmware = philips_tda1004x_request_firmware
1129}; 1236};
1130 1237
1238/* ==================================================================
1239 * tda10086 based DVB-S cards, helper functions
1240 */
1241
1131static struct tda10086_config flydvbs = { 1242static struct tda10086_config flydvbs = {
1132 .demod_address = 0x0e, 1243 .demod_address = 0x0e,
1133 .invert = 0, 1244 .invert = 0,
1134}; 1245};
1135 1246
1136/* ------------------------------------------------------------------ */ 1247/* ==================================================================
1248 * nxt200x based ATSC cards, helper functions
1249 */
1137 1250
1138static struct nxt200x_config avertvhda180 = { 1251static struct nxt200x_config avertvhda180 = {
1139 .demod_address = 0x0a, 1252 .demod_address = 0x0a,
@@ -1153,10 +1266,13 @@ static struct nxt200x_config kworldatsc110 = {
1153 .set_pll_input = nxt200x_set_pll_input, 1266 .set_pll_input = nxt200x_set_pll_input,
1154}; 1267};
1155 1268
1156/* ------------------------------------------------------------------ */ 1269/* ==================================================================
1270 * Core code
1271 */
1157 1272
1158static int dvb_init(struct saa7134_dev *dev) 1273static int dvb_init(struct saa7134_dev *dev)
1159{ 1274{
1275 char *board_name;
1160 /* init struct videobuf_dvb */ 1276 /* init struct videobuf_dvb */
1161 dev->ts.nr_bufs = 32; 1277 dev->ts.nr_bufs = 32;
1162 dev->ts.nr_packets = 32*4; 1278 dev->ts.nr_packets = 32*4;
@@ -1194,6 +1310,7 @@ static int dvb_init(struct saa7134_dev *dev)
1194 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init; 1310 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1195 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep; 1311 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1196 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params; 1312 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1313 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Medion MD7134");
1197 } 1314 }
1198 break; 1315 break;
1199 case SAA7134_BOARD_PHILIPS_TOUGH: 1316 case SAA7134_BOARD_PHILIPS_TOUGH:
@@ -1201,42 +1318,16 @@ static int dvb_init(struct saa7134_dev *dev)
1201 &philips_tu1216_60_config, 1318 &philips_tu1216_60_config,
1202 &dev->i2c_adap); 1319 &dev->i2c_adap);
1203 if (dev->dvb.frontend) { 1320 if (dev->dvb.frontend) {
1204 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init; 1321 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1205 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params; 1322 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1323 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Philips TOUGH");
1206 } 1324 }
1207 break; 1325 break;
1208 case SAA7134_BOARD_FLYDVBTDUO: 1326 case SAA7134_BOARD_FLYDVBTDUO:
1209 dev->dvb.frontend = dvb_attach(tda10046_attach,
1210 &tda827x_lifeview_config,
1211 &dev->i2c_adap);
1212 if (dev->dvb.frontend) {
1213 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1214 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1215 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1216 }
1217 break;
1218 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: 1327 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1219 dev->dvb.frontend = dvb_attach(tda10046_attach, 1328 configure_tda827x_fe(dev, &tda827x_lifeview_config, "DVB-T Lifeview FlyDVB Duo");
1220 &tda827x_lifeview_config,
1221 &dev->i2c_adap);
1222 if (dev->dvb.frontend) {
1223 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1224 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1225 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1226 }
1227 break; 1329 break;
1228 case SAA7134_BOARD_PHILIPS_EUROPA: 1330 case SAA7134_BOARD_PHILIPS_EUROPA:
1229 dev->dvb.frontend = dvb_attach(tda10046_attach,
1230 &philips_europa_config,
1231 &dev->i2c_adap);
1232 if (dev->dvb.frontend) {
1233 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1234 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1235 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1236 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1237 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1238 }
1239 break;
1240 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1331 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1241 dev->dvb.frontend = dvb_attach(tda10046_attach, 1332 dev->dvb.frontend = dvb_attach(tda10046_attach,
1242 &philips_europa_config, 1333 &philips_europa_config,
@@ -1247,6 +1338,11 @@ static int dvb_init(struct saa7134_dev *dev)
1247 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; 1338 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1248 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; 1339 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1249 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; 1340 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1341 if (dev->board == SAA7134_BOARD_VIDEOMATE_DVBT_300)
1342 board_name = "DVB-T Compro VideoMate 300";
1343 else
1344 board_name = "DVB-T Philips Europa";
1345 philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
1250 } 1346 }
1251 break; 1347 break;
1252 case SAA7134_BOARD_VIDEOMATE_DVBT_200: 1348 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
@@ -1254,74 +1350,29 @@ static int dvb_init(struct saa7134_dev *dev)
1254 &philips_tu1216_61_config, 1350 &philips_tu1216_61_config,
1255 &dev->i2c_adap); 1351 &dev->i2c_adap);
1256 if (dev->dvb.frontend) { 1352 if (dev->dvb.frontend) {
1257 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init; 1353 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1258 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params; 1354 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1355 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Compro VideoMate 200");
1259 } 1356 }
1260 break; 1357 break;
1261 case SAA7134_BOARD_PHILIPS_TIGER: 1358 case SAA7134_BOARD_PHILIPS_TIGER:
1262 dev->dvb.frontend = dvb_attach(tda10046_attach, 1359 configure_tda827x_fe(dev, &philips_tiger_config, "DVB-T Philips Tiger");
1263 &philips_tiger_config,
1264 &dev->i2c_adap);
1265 if (dev->dvb.frontend) {
1266 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1267 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1268 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1269 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1270 }
1271 break; 1360 break;
1272 case SAA7134_BOARD_PINNACLE_PCTV_310i: 1361 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1273 dev->dvb.frontend = dvb_attach(tda10046_attach, 1362 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, "DVB-T Pinnacle PCTV 310i");
1274 &pinnacle_pctv_310i_config,
1275 &dev->i2c_adap);
1276 if (dev->dvb.frontend) {
1277 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1278 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1279 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1280 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1281 }
1282 break; 1363 break;
1283 case SAA7134_BOARD_HAUPPAUGE_HVR1110: 1364 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1284 dev->dvb.frontend = dvb_attach(tda10046_attach, 1365 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, "DVB-T Hauppauge HVR 1110");
1285 &hauppauge_hvr_1110_config,
1286 &dev->i2c_adap);
1287 if (dev->dvb.frontend) {
1288 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1289 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1290 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1291 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1292 }
1293 break; 1366 break;
1294 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 1367 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1295 dev->dvb.frontend = dvb_attach(tda10046_attach, 1368 configure_tda827x_fe(dev, &asus_p7131_dual_config, "DVB-T Asus P7137 Dual");
1296 &asus_p7131_dual_config,
1297 &dev->i2c_adap);
1298 if (dev->dvb.frontend) {
1299 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1300 dev->dvb.frontend->ops.tuner_ops.init = asus_p7131_dual_tuner_init;
1301 dev->dvb.frontend->ops.tuner_ops.sleep = asus_p7131_dual_tuner_sleep;
1302 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1303 }
1304 break; 1369 break;
1305 case SAA7134_BOARD_FLYDVBT_LR301: 1370 case SAA7134_BOARD_FLYDVBT_LR301:
1306 dev->dvb.frontend = dvb_attach(tda10046_attach, 1371 configure_tda827x_fe(dev, &tda827x_lifeview_config, "DVB-T Lifeview FlyDVBT LR301");
1307 &tda827x_lifeview_config,
1308 &dev->i2c_adap);
1309 if (dev->dvb.frontend) {
1310 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1311 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1312 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1313 }
1314 break; 1372 break;
1315 case SAA7134_BOARD_FLYDVB_TRIO: 1373 case SAA7134_BOARD_FLYDVB_TRIO:
1316 if(! use_frontend) { //terrestrial 1374 if(! use_frontend) { //terrestrial
1317 dev->dvb.frontend = dvb_attach(tda10046_attach, 1375 configure_tda827x_fe(dev, &lifeview_trio_config, NULL);
1318 &lifeview_trio_config,
1319 &dev->i2c_adap);
1320 if (dev->dvb.frontend) {
1321 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
1322 dev->dvb.frontend->ops.tuner_ops.set_params =
1323 lifeview_trio_tuner_set_params;
1324 }
1325 } else { //satellite 1376 } else { //satellite
1326 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); 1377 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1327 if (dev->dvb.frontend) { 1378 if (dev->dvb.frontend) {
@@ -1337,42 +1388,26 @@ static int dvb_init(struct saa7134_dev *dev)
1337 } 1388 }
1338 break; 1389 break;
1339 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 1390 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1391 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1340 dev->dvb.frontend = dvb_attach(tda10046_attach, 1392 dev->dvb.frontend = dvb_attach(tda10046_attach,
1341 &ads_tech_duo_config, 1393 &ads_tech_duo_config,
1342 &dev->i2c_adap); 1394 &dev->i2c_adap);
1343 if (dev->dvb.frontend) { 1395 if (dev->dvb.frontend) {
1344 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init; 1396 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1345 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep; 1397 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1346 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params; 1398 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_pll_set;
1399 if (dev->board == SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331)
1400 board_name = "DVB-T ADS DUO Cardbus PTV331";
1401 else
1402 board_name = "DVB-T Lifeview FlyDVT Cardbus";
1403 philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
1347 } 1404 }
1348 break; 1405 break;
1349 case SAA7134_BOARD_TEVION_DVBT_220RF: 1406 case SAA7134_BOARD_TEVION_DVBT_220RF:
1350 dev->dvb.frontend = dvb_attach(tda10046_attach, 1407 configure_tda827x_fe(dev, &tevion_dvbt220rf_config, "DVB-T Tevion 220RF");
1351 &tevion_dvbt220rf_config,
1352 &dev->i2c_adap);
1353 if (dev->dvb.frontend) {
1354 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
1355 dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
1356 }
1357 break;
1358 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1359 dev->dvb.frontend = dvb_attach(tda10046_attach,
1360 &ads_tech_duo_config,
1361 &dev->i2c_adap);
1362 if (dev->dvb.frontend) {
1363 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1364 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1365 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1366 }
1367 break; 1408 break;
1368 case SAA7134_BOARD_MEDION_MD8800_QUADRO: 1409 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1369 dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config, 1410 configure_tda827x_fe(dev, &md8800_dvbt_config, "DVB-T Medion MD8800");
1370 &dev->i2c_adap);
1371 if (dev->dvb.frontend) {
1372 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1373 dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
1374 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1375 }
1376 break; 1411 break;
1377 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1412 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1378 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, 1413 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
@@ -1413,6 +1448,7 @@ static int dvb_init(struct saa7134_dev *dev)
1413 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init; 1448 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1414 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep; 1449 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1415 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params; 1450 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1451 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVBT Asus Europa 2 Hybrid");
1416 } 1452 }
1417 break; 1453 break;
1418 case SAA7134_BOARD_VIDEOMATE_DVBT_200A: 1454 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
@@ -1422,31 +1458,17 @@ static int dvb_init(struct saa7134_dev *dev)
1422 if (dev->dvb.frontend) { 1458 if (dev->dvb.frontend) {
1423 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init; 1459 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1424 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; 1460 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1461 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVBT Compro Videomate 200a");
1425 } 1462 }
1426 break; 1463 break;
1427 case SAA7134_BOARD_CINERGY_HT_PCMCIA: 1464 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1428 dev->dvb.frontend = dvb_attach(tda10046_attach, 1465 configure_tda827x_fe(dev, &cinergy_ht_config, "DVB-T Terratec Cinergy HT Cardbus");
1429 &cinergy_ht_config,
1430 &dev->i2c_adap);
1431 if (dev->dvb.frontend) {
1432 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1433 dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init;
1434 dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep;
1435 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1436
1437 }
1438 break; 1466 break;
1439 case SAA7134_BOARD_CINERGY_HT_PCI: 1467 case SAA7134_BOARD_CINERGY_HT_PCI:
1440 dev->dvb.frontend = dvb_attach(tda10046_attach, 1468 configure_tda827x_fe(dev, &cinergy_ht_pci_config, "DVB-T Terratec Cinergy HT PCI");
1441 &cinergy_ht_config, 1469 break;
1442 &dev->i2c_adap); 1470 case SAA7134_BOARD_PHILIPS_TIGER_S:
1443 if (dev->dvb.frontend) { 1471 configure_tda827x_fe(dev, &philips_tiger_s_config, "DVB-T Philips Tiger S");
1444 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1445 dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init;
1446 dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep;
1447 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1448
1449 }
1450 break; 1472 break;
1451 default: 1473 default:
1452 printk("%s: Huh? unknown DVB card?\n",dev->name); 1474 printk("%s: Huh? unknown DVB card?\n",dev->name);
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index f2cb63053041..e1cb273e16bc 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -603,7 +603,14 @@ static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
603 saa_writeb(SAA7134_RAW_DATA_GAIN, 0x40); 603 saa_writeb(SAA7134_RAW_DATA_GAIN, 0x40);
604 saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80); 604 saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80);
605 605
606 saa7134_i2c_call_clients(dev,VIDIOC_S_STD,&norm->id); 606 /* only tell the tuner if this is a tv input */
607 if (card_in(dev,dev->ctl_input).tv) {
608 if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290)
609 && ((card(dev).tuner_config == 1)
610 || (card(dev).tuner_config == 2)))
611 saa7134_set_gpio(dev, 22, 5);
612 saa7134_i2c_call_clients(dev,VIDIOC_S_STD,&norm->id);
613 }
607} 614}
608 615
609static void video_mux(struct saa7134_dev *dev, int input) 616static void video_mux(struct saa7134_dev *dev, int input)
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 303c0806df91..b46265a97565 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -231,6 +231,7 @@ struct saa7134_format {
231#define SAA7134_BOARD_ENCORE_ENLTV 106 231#define SAA7134_BOARD_ENCORE_ENLTV 106
232#define SAA7134_BOARD_ENCORE_ENLTV_FM 107 232#define SAA7134_BOARD_ENCORE_ENLTV_FM 107
233#define SAA7134_BOARD_CINERGY_HT_PCI 108 233#define SAA7134_BOARD_CINERGY_HT_PCI 108
234#define SAA7134_BOARD_PHILIPS_TIGER_S 109
234 235
235#define SAA7134_MAXBOARDS 8 236#define SAA7134_MAXBOARDS 8
236#define SAA7134_INPUT_MAX 8 237#define SAA7134_INPUT_MAX 8
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c
index 027c8a074dfe..e6c3e6167191 100644
--- a/drivers/media/video/tda8290.c
+++ b/drivers/media/video/tda8290.c
@@ -192,14 +192,52 @@ static struct tda827xa_data tda827xa_analog[] = {
192 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0} /* End */ 192 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0} /* End */
193}; 193};
194 194
195static void tda827xa_lna_gain(struct i2c_client *c, int high)
196{
197 struct tuner *t = i2c_get_clientdata(c);
198 unsigned char buf[] = {0x22, 0x01};
199 int arg;
200 struct i2c_msg msg = {.addr = c->addr, .flags = 0, .buf = buf, .len = sizeof(buf)};
201 if (t->config) {
202 if (high)
203 tuner_dbg("setting LNA to high gain\n");
204 else
205 tuner_dbg("setting LNA to low gain\n");
206 }
207 switch (t->config) {
208 case 0: /* no LNA */
209 break;
210 case 1: /* switch is GPIO 0 of tda8290 */
211 case 2:
212 /* turn Vsync on */
213 if (t->std & V4L2_STD_MN)
214 arg = 5;
215 else
216 arg = 4;
217 if (t->gpio_func)
218 t->gpio_func(c->adapter->algo_data, 22, 5);
219 buf[1] = high ? 0 : 1;
220 if (t->config == 2)
221 buf[1] = high ? 1 : 0;
222 i2c_transfer(c->adapter, &msg, 1);
223 break;
224 case 3: /* switch with GPIO of saa713x */
225 if (t->gpio_func)
226 t->gpio_func(c->adapter->algo_data, 22, high);
227 break;
228 }
229}
230
195static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq) 231static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
196{ 232{
197 unsigned char tuner_reg[14]; 233 unsigned char tuner_reg[11];
198 unsigned char reg2[2];
199 u32 N; 234 u32 N;
200 int i; 235 int i;
201 struct tuner *t = i2c_get_clientdata(c); 236 struct tuner *t = i2c_get_clientdata(c);
202 struct i2c_msg msg = {.addr = t->tda827x_addr, .flags = 0}; 237 struct i2c_msg msg = {.addr = t->tda827x_addr, .flags = 0, .buf = tuner_reg};
238
239 tda827xa_lna_gain( c, 1);
240 msleep(10);
203 241
204 if (t->mode == V4L2_TUNER_RADIO) 242 if (t->mode == V4L2_TUNER_RADIO)
205 freq = freq / 1000; 243 freq = freq / 1000;
@@ -222,48 +260,58 @@ static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
222 tuner_reg[5] = (tda827xa_analog[i].spd << 5) + (tda827xa_analog[i].svco << 3) + 260 tuner_reg[5] = (tda827xa_analog[i].spd << 5) + (tda827xa_analog[i].svco << 3) +
223 tda827xa_analog[i].sbs; 261 tda827xa_analog[i].sbs;
224 tuner_reg[6] = 0x8b + (tda827xa_analog[i].gc3 << 4); 262 tuner_reg[6] = 0x8b + (tda827xa_analog[i].gc3 << 4);
225 tuner_reg[7] = 0x0c; 263 tuner_reg[7] = 0x1c;
226 tuner_reg[8] = 4; 264 tuner_reg[8] = 4;
227 tuner_reg[9] = 0x20; 265 tuner_reg[9] = 0x20;
228 tuner_reg[10] = 0xff; 266 tuner_reg[10] = 0x00;
229 tuner_reg[11] = 0xe0; 267 msg.len = 11;
230 tuner_reg[12] = 0; 268 i2c_transfer(c->adapter, &msg, 1);
231 tuner_reg[13] = 0x39 + (t->tda827x_lpsel << 1);
232 269
233 msg.buf = tuner_reg; 270 tuner_reg[0] = 0x90;
234 msg.len = 14; 271 tuner_reg[1] = 0xff;
272 tuner_reg[2] = 0xe0;
273 tuner_reg[3] = 0;
274 tuner_reg[4] = 0x99 + (t->tda827x_lpsel << 1);
275 msg.len = 5;
235 i2c_transfer(c->adapter, &msg, 1); 276 i2c_transfer(c->adapter, &msg, 1);
236 277
237 msg.buf= reg2; 278 tuner_reg[0] = 0xa0;
279 tuner_reg[1] = 0xc0;
238 msg.len = 2; 280 msg.len = 2;
239 reg2[0] = 0x60;
240 reg2[1] = 0x3c;
241 i2c_transfer(c->adapter, &msg, 1); 281 i2c_transfer(c->adapter, &msg, 1);
242 282
243 reg2[0] = 0xa0; 283 tuner_reg[0] = 0x30;
244 reg2[1] = 0xc0; 284 tuner_reg[1] = 0x10 + tda827xa_analog[i].scr;
245 i2c_transfer(c->adapter, &msg, 1); 285 i2c_transfer(c->adapter, &msg, 1);
246 286
247 msleep(2); 287 msg.flags = I2C_M_RD;
248 reg2[0] = 0x30; 288 i2c_transfer(c->adapter, &msg, 1);
249 reg2[1] = 0x10 + tda827xa_analog[i].scr; 289 msg.flags = 0;
290 tuner_reg[1] >>= 4;
291 tuner_dbg("AGC2 gain is: %d\n", tuner_reg[1]);
292 if (tuner_reg[1] < 1)
293 tda827xa_lna_gain( c, 0);
294
295 msleep(100);
296 tuner_reg[0] = 0x60;
297 tuner_reg[1] = 0x3c;
250 i2c_transfer(c->adapter, &msg, 1); 298 i2c_transfer(c->adapter, &msg, 1);
251 299
252 msleep(550); 300 msleep(163);
253 reg2[0] = 0x50; 301 tuner_reg[0] = 0x50;
254 reg2[1] = 0x8f + (tda827xa_analog[i].gc3 << 4); 302 tuner_reg[1] = 0x8f + (tda827xa_analog[i].gc3 << 4);
255 i2c_transfer(c->adapter, &msg, 1); 303 i2c_transfer(c->adapter, &msg, 1);
256 304
257 reg2[0] = 0x80; 305 tuner_reg[0] = 0x80;
258 reg2[1] = 0x28; 306 tuner_reg[1] = 0x28;
259 i2c_transfer(c->adapter, &msg, 1); 307 i2c_transfer(c->adapter, &msg, 1);
260 308
261 reg2[0] = 0xb0; 309 tuner_reg[0] = 0xb0;
262 reg2[1] = 0x01; 310 tuner_reg[1] = 0x01;
263 i2c_transfer(c->adapter, &msg, 1); 311 i2c_transfer(c->adapter, &msg, 1);
264 312
265 reg2[0] = 0xc0; 313 tuner_reg[0] = 0xc0;
266 reg2[1] = 0x19 + (t->tda827x_lpsel << 1); 314 tuner_reg[1] = 0x19 + (t->tda827x_lpsel << 1);
267 i2c_transfer(c->adapter, &msg, 1); 315 i2c_transfer(c->adapter, &msg, 1);
268} 316}
269 317
@@ -319,7 +367,9 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
319 unsigned char addr_pll_stat = 0x1b; 367 unsigned char addr_pll_stat = 0x1b;
320 unsigned char adc_sat, agc_stat, 368 unsigned char adc_sat, agc_stat,
321 pll_stat; 369 pll_stat;
370 int i;
322 371
372 tuner_dbg("tda827xa config is 0x%02x\n", t->config);
323 i2c_master_send(c, easy_mode, 2); 373 i2c_master_send(c, easy_mode, 2);
324 i2c_master_send(c, agc_out_on, 2); 374 i2c_master_send(c, agc_out_on, 2);
325 i2c_master_send(c, soft_reset, 2); 375 i2c_master_send(c, soft_reset, 2);
@@ -340,17 +390,22 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
340 tda827xa_tune(c, ifc, freq); 390 tda827xa_tune(c, ifc, freq);
341 else 391 else
342 tda827x_tune(c, ifc, freq); 392 tda827x_tune(c, ifc, freq);
393 for (i = 0; i < 3; i++) {
394 i2c_master_send(c, &addr_pll_stat, 1);
395 i2c_master_recv(c, &pll_stat, 1);
396 if (pll_stat & 0x80) {
397 i2c_master_send(c, &addr_adc_sat, 1);
398 i2c_master_recv(c, &adc_sat, 1);
399 i2c_master_send(c, &addr_agc_stat, 1);
400 i2c_master_recv(c, &agc_stat, 1);
401 tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat);
402 break;
403 } else {
404 tuner_dbg("tda8290 not locked, no signal?\n");
405 msleep(100);
406 }
407 }
343 /* adjust headroom resp. gain */ 408 /* adjust headroom resp. gain */
344 i2c_master_send(c, &addr_adc_sat, 1);
345 i2c_master_recv(c, &adc_sat, 1);
346 i2c_master_send(c, &addr_agc_stat, 1);
347 i2c_master_recv(c, &agc_stat, 1);
348 i2c_master_send(c, &addr_pll_stat, 1);
349 i2c_master_recv(c, &pll_stat, 1);
350 if (pll_stat & 0x80)
351 tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat);
352 else
353 tuner_dbg("tda8290 not locked, no signal?\n");
354 if ((agc_stat > 115) || (!(pll_stat & 0x80) && (adc_sat < 20))) { 409 if ((agc_stat > 115) || (!(pll_stat & 0x80) && (adc_sat < 20))) {
355 tuner_dbg("adjust gain, step 1. Agc: %d, ADC stat: %d, lock: %d\n", 410 tuner_dbg("adjust gain, step 1. Agc: %d, ADC stat: %d, lock: %d\n",
356 agc_stat, adc_sat, pll_stat & 0x80); 411 agc_stat, adc_sat, pll_stat & 0x80);
@@ -487,11 +542,16 @@ static void standby(struct i2c_client *c)
487 542
488static void tda8290_init_if(struct i2c_client *c) 543static void tda8290_init_if(struct i2c_client *c)
489{ 544{
545 struct tuner *t = i2c_get_clientdata(c);
490 unsigned char set_VS[] = { 0x30, 0x6F }; 546 unsigned char set_VS[] = { 0x30, 0x6F };
547 unsigned char set_GP00_CF[] = { 0x20, 0x01 };
491 unsigned char set_GP01_CF[] = { 0x20, 0x0B }; 548 unsigned char set_GP01_CF[] = { 0x20, 0x0B };
492 549
550 if ((t->config == 1) || (t->config == 2))
551 i2c_master_send(c, set_GP00_CF, 2);
552 else
553 i2c_master_send(c, set_GP01_CF, 2);
493 i2c_master_send(c, set_VS, 2); 554 i2c_master_send(c, set_VS, 2);
494 i2c_master_send(c, set_GP01_CF, 2);
495} 555}
496 556
497static void tda8290_init_tuner(struct i2c_client *c) 557static void tda8290_init_tuner(struct i2c_client *c)