aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorHartmut Hackmann <hartmut.hackmann@t-online.de>2008-04-22 13:46:08 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:07:52 -0400
commit7bff4b4d3ad2b9ff42b4087f409076035af1d165 (patch)
treecfa75f91fbd30b8b36f70d7056639ee031d2a7ed /drivers/media/dvb
parent5823b3a63c7661272ea7fef7635955e2a50d17eb (diff)
V4L/DVB (7393): tda827x: fixed support of tuners with LNA
Tuner refactoring broke support of tuners with LNA configurations 1 and 2 for both, analog TV and DVB-T. Additionally, this patch initializes the saa713x gpios defined by the gpiomask at driver init to avoid undefined stated at dvb. Signed-off-by: Hartmut Hackmann <hartmut.hackmann@t-online.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/frontends/tda1004x.h1
-rw-r--r--drivers/media/dvb/frontends/tda827x.c163
-rw-r--r--drivers/media/dvb/frontends/tda827x.h4
3 files changed, 86 insertions, 82 deletions
diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h
index abae84350142..ebb2c5f5a261 100644
--- a/drivers/media/dvb/frontends/tda1004x.h
+++ b/drivers/media/dvb/frontends/tda1004x.h
@@ -94,7 +94,6 @@ struct tda1004x_config
94 94
95 /* slave address and configuration of the tuner */ 95 /* slave address and configuration of the tuner */
96 u8 tuner_address; 96 u8 tuner_address;
97 u8 tuner_config;
98 u8 antenna_switch; 97 u8 antenna_switch;
99 98
100 /* if the board uses another I2c Bridge (tda8290), its address */ 99 /* if the board uses another I2c Bridge (tda8290), its address */
diff --git a/drivers/media/dvb/frontends/tda827x.c b/drivers/media/dvb/frontends/tda827x.c
index 967ac8b28efd..d30d2c9094d9 100644
--- a/drivers/media/dvb/frontends/tda827x.c
+++ b/drivers/media/dvb/frontends/tda827x.c
@@ -142,7 +142,7 @@ static int tda827xo_set_params(struct dvb_frontend *fe,
142 int i, tuner_freq, if_freq; 142 int i, tuner_freq, if_freq;
143 u32 N; 143 u32 N;
144 144
145 dprintk("%s:\n", __FUNCTION__); 145 dprintk("%s:\n", __func__);
146 switch (params->u.ofdm.bandwidth) { 146 switch (params->u.ofdm.bandwidth) {
147 case BANDWIDTH_6_MHZ: 147 case BANDWIDTH_6_MHZ:
148 if_freq = 4000000; 148 if_freq = 4000000;
@@ -186,7 +186,7 @@ static int tda827xo_set_params(struct dvb_frontend *fe,
186 fe->ops.i2c_gate_ctrl(fe, 1); 186 fe->ops.i2c_gate_ctrl(fe, 1);
187 if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) { 187 if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) {
188 printk("%s: could not write to tuner at addr: 0x%02x\n", 188 printk("%s: could not write to tuner at addr: 0x%02x\n",
189 __FUNCTION__, priv->i2c_addr << 1); 189 __func__, priv->i2c_addr << 1);
190 return -EIO; 190 return -EIO;
191 } 191 }
192 msleep(500); 192 msleep(500);
@@ -212,7 +212,7 @@ static int tda827xo_sleep(struct dvb_frontend *fe)
212 struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, 212 struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0,
213 .buf = buf, .len = sizeof(buf) }; 213 .buf = buf, .len = sizeof(buf) };
214 214
215 dprintk("%s:\n", __FUNCTION__); 215 dprintk("%s:\n", __func__);
216 if (fe->ops.i2c_gate_ctrl) 216 if (fe->ops.i2c_gate_ctrl)
217 fe->ops.i2c_gate_ctrl(fe, 1); 217 fe->ops.i2c_gate_ctrl(fe, 1);
218 i2c_transfer(priv->i2c_adap, &msg, 1); 218 i2c_transfer(priv->i2c_adap, &msg, 1);
@@ -389,6 +389,79 @@ static struct tda827xa_data tda827xa_analog[] = {
389 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0} 389 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}
390}; 390};
391 391
392static int tda827xa_sleep(struct dvb_frontend *fe)
393{
394 struct tda827x_priv *priv = fe->tuner_priv;
395 static u8 buf[] = { 0x30, 0x90 };
396 struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0,
397 .buf = buf, .len = sizeof(buf) };
398
399 dprintk("%s:\n", __func__);
400 if (fe->ops.i2c_gate_ctrl)
401 fe->ops.i2c_gate_ctrl(fe, 1);
402
403 i2c_transfer(priv->i2c_adap, &msg, 1);
404
405 if (fe->ops.i2c_gate_ctrl)
406 fe->ops.i2c_gate_ctrl(fe, 0);
407
408 if (priv->cfg && priv->cfg->sleep)
409 priv->cfg->sleep(fe);
410
411 return 0;
412}
413
414static void tda827xa_lna_gain(struct dvb_frontend *fe, int high,
415 struct analog_parameters *params)
416{
417 struct tda827x_priv *priv = fe->tuner_priv;
418 unsigned char buf[] = {0x22, 0x01};
419 int arg;
420 int gp_func;
421 struct i2c_msg msg = { .addr = priv->cfg->switch_addr, .flags = 0,
422 .buf = buf, .len = sizeof(buf) };
423
424 if (NULL == priv->cfg) {
425 dprintk("tda827x_config not defined, cannot set LNA gain!\n");
426 return;
427 }
428 if (priv->cfg->config) {
429 if (high)
430 dprintk("setting LNA to high gain\n");
431 else
432 dprintk("setting LNA to low gain\n");
433 }
434 switch (priv->cfg->config) {
435 case 0: /* no LNA */
436 break;
437 case 1: /* switch is GPIO 0 of tda8290 */
438 case 2:
439 if (params == NULL) {
440 gp_func = 0;
441 arg = 0;
442 } else {
443 /* turn Vsync on */
444 gp_func = 1;
445 if (params->std & V4L2_STD_MN)
446 arg = 1;
447 else
448 arg = 0;
449 }
450 if (priv->cfg->tuner_callback)
451 priv->cfg->tuner_callback(priv->i2c_adap->algo_data,
452 gp_func, arg);
453 buf[1] = high ? 0 : 1;
454 if (priv->cfg->config == 2)
455 buf[1] = high ? 1 : 0;
456 i2c_transfer(priv->i2c_adap, &msg, 1);
457 break;
458 case 3: /* switch with GPIO of saa713x */
459 if (priv->cfg->tuner_callback)
460 priv->cfg->tuner_callback(priv->i2c_adap->algo_data, 0, high);
461 break;
462 }
463}
464
392static int tda827xa_set_params(struct dvb_frontend *fe, 465static int tda827xa_set_params(struct dvb_frontend *fe,
393 struct dvb_frontend_parameters *params) 466 struct dvb_frontend_parameters *params)
394{ 467{
@@ -401,9 +474,9 @@ static int tda827xa_set_params(struct dvb_frontend *fe,
401 int i, tuner_freq, if_freq; 474 int i, tuner_freq, if_freq;
402 u32 N; 475 u32 N;
403 476
404 dprintk("%s:\n", __FUNCTION__); 477 dprintk("%s:\n", __func__);
405 if (priv->cfg && priv->cfg->lna_gain) 478
406 priv->cfg->lna_gain(fe, 1); 479 tda827xa_lna_gain(fe, 1, NULL);
407 msleep(20); 480 msleep(20);
408 481
409 switch (params->u.ofdm.bandwidth) { 482 switch (params->u.ofdm.bandwidth) {
@@ -444,7 +517,7 @@ static int tda827xa_set_params(struct dvb_frontend *fe,
444 fe->ops.i2c_gate_ctrl(fe, 1); 517 fe->ops.i2c_gate_ctrl(fe, 1);
445 if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) { 518 if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) {
446 printk("%s: could not write to tuner at addr: 0x%02x\n", 519 printk("%s: could not write to tuner at addr: 0x%02x\n",
447 __FUNCTION__, priv->i2c_addr << 1); 520 __func__, priv->i2c_addr << 1);
448 return -EIO; 521 return -EIO;
449 } 522 }
450 buf[0] = 0x90; 523 buf[0] = 0x90;
@@ -474,8 +547,7 @@ static int tda827xa_set_params(struct dvb_frontend *fe,
474 buf[1] >>= 4; 547 buf[1] >>= 4;
475 dprintk("tda8275a AGC2 gain is: %d\n", buf[1]); 548 dprintk("tda8275a AGC2 gain is: %d\n", buf[1]);
476 if ((buf[1]) < 2) { 549 if ((buf[1]) < 2) {
477 if (priv->cfg && priv->cfg->lna_gain) 550 tda827xa_lna_gain(fe, 0, NULL);
478 priv->cfg->lna_gain(fe, 0);
479 buf[0] = 0x60; 551 buf[0] = 0x60;
480 buf[1] = 0x0c; 552 buf[1] = 0x0c;
481 if (fe->ops.i2c_gate_ctrl) 553 if (fe->ops.i2c_gate_ctrl)
@@ -523,73 +595,6 @@ static int tda827xa_set_params(struct dvb_frontend *fe,
523 return 0; 595 return 0;
524} 596}
525 597
526static int tda827xa_sleep(struct dvb_frontend *fe)
527{
528 struct tda827x_priv *priv = fe->tuner_priv;
529 static u8 buf[] = { 0x30, 0x90 };
530 struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0,
531 .buf = buf, .len = sizeof(buf) };
532
533 dprintk("%s:\n", __FUNCTION__);
534 if (fe->ops.i2c_gate_ctrl)
535 fe->ops.i2c_gate_ctrl(fe, 1);
536
537 i2c_transfer(priv->i2c_adap, &msg, 1);
538
539 if (fe->ops.i2c_gate_ctrl)
540 fe->ops.i2c_gate_ctrl(fe, 0);
541
542 if (priv->cfg && priv->cfg->sleep)
543 priv->cfg->sleep(fe);
544
545 return 0;
546}
547
548/* ------------------------------------------------------------------ */
549
550static void tda827xa_lna_gain(struct dvb_frontend *fe, int high,
551 struct analog_parameters *params)
552{
553 struct tda827x_priv *priv = fe->tuner_priv;
554 unsigned char buf[] = {0x22, 0x01};
555 int arg;
556 struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0,
557 .buf = buf, .len = sizeof(buf) };
558
559 if (NULL == priv->cfg) {
560 dprintk("tda827x_config not defined, cannot set LNA gain!\n");
561 return;
562 }
563
564 if (priv->cfg->config) {
565 if (high)
566 dprintk("setting LNA to high gain\n");
567 else
568 dprintk("setting LNA to low gain\n");
569 }
570 switch (*priv->cfg->config) {
571 case 0: /* no LNA */
572 break;
573 case 1: /* switch is GPIO 0 of tda8290 */
574 case 2:
575 /* turn Vsync on */
576 if (params->std & V4L2_STD_MN)
577 arg = 1;
578 else
579 arg = 0;
580 if (priv->cfg->tuner_callback)
581 priv->cfg->tuner_callback(priv, 1, arg);
582 buf[1] = high ? 0 : 1;
583 if (*priv->cfg->config == 2)
584 buf[1] = high ? 1 : 0;
585 i2c_transfer(priv->i2c_adap, &msg, 1);
586 break;
587 case 3: /* switch with GPIO of saa713x */
588 if (priv->cfg->tuner_callback)
589 priv->cfg->tuner_callback(priv, 0, high);
590 break;
591 }
592}
593 598
594static int tda827xa_set_analog_params(struct dvb_frontend *fe, 599static int tda827xa_set_analog_params(struct dvb_frontend *fe,
595 struct analog_parameters *params) 600 struct analog_parameters *params)
@@ -724,7 +729,7 @@ static int tda827x_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
724static int tda827x_init(struct dvb_frontend *fe) 729static int tda827x_init(struct dvb_frontend *fe)
725{ 730{
726 struct tda827x_priv *priv = fe->tuner_priv; 731 struct tda827x_priv *priv = fe->tuner_priv;
727 dprintk("%s:\n", __FUNCTION__); 732 dprintk("%s:\n", __func__);
728 if (priv->cfg && priv->cfg->init) 733 if (priv->cfg && priv->cfg->init)
729 priv->cfg->init(fe); 734 priv->cfg->init(fe);
730 735
@@ -792,7 +797,7 @@ static int tda827x_probe_version(struct dvb_frontend *fe)
792 fe->ops.i2c_gate_ctrl(fe, 1); 797 fe->ops.i2c_gate_ctrl(fe, 1);
793 if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) { 798 if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) {
794 printk("%s: could not read from tuner at addr: 0x%02x\n", 799 printk("%s: could not read from tuner at addr: 0x%02x\n",
795 __FUNCTION__, msg.addr << 1); 800 __func__, msg.addr << 1);
796 return -EIO; 801 return -EIO;
797 } 802 }
798 if ((data & 0x3c) == 0) { 803 if ((data & 0x3c) == 0) {
@@ -816,7 +821,7 @@ struct dvb_frontend *tda827x_attach(struct dvb_frontend *fe, int addr,
816{ 821{
817 struct tda827x_priv *priv = NULL; 822 struct tda827x_priv *priv = NULL;
818 823
819 dprintk("%s:\n", __FUNCTION__); 824 dprintk("%s:\n", __func__);
820 priv = kzalloc(sizeof(struct tda827x_priv), GFP_KERNEL); 825 priv = kzalloc(sizeof(struct tda827x_priv), GFP_KERNEL);
821 if (priv == NULL) 826 if (priv == NULL)
822 return NULL; 827 return NULL;
diff --git a/drivers/media/dvb/frontends/tda827x.h b/drivers/media/dvb/frontends/tda827x.h
index 92eb65b4012b..cd3032f985cd 100644
--- a/drivers/media/dvb/frontends/tda827x.h
+++ b/drivers/media/dvb/frontends/tda827x.h
@@ -30,12 +30,12 @@
30struct tda827x_config 30struct tda827x_config
31{ 31{
32 /* saa7134 - provided callbacks */ 32 /* saa7134 - provided callbacks */
33 void (*lna_gain) (struct dvb_frontend *fe, int high);
34 int (*init) (struct dvb_frontend *fe); 33 int (*init) (struct dvb_frontend *fe);
35 int (*sleep) (struct dvb_frontend *fe); 34 int (*sleep) (struct dvb_frontend *fe);
36 35
37 /* interface to tda829x driver */ 36 /* interface to tda829x driver */
38 unsigned int *config; 37 unsigned int config;
38 int switch_addr;
39 int (*tuner_callback) (void *dev, int command, int arg); 39 int (*tuner_callback) (void *dev, int command, int arg);
40 40
41 void (*agcf)(struct dvb_frontend *fe); 41 void (*agcf)(struct dvb_frontend *fe);