aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/tda827x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/tda827x.c')
-rw-r--r--drivers/media/dvb/frontends/tda827x.c61
1 files changed, 56 insertions, 5 deletions
diff --git a/drivers/media/dvb/frontends/tda827x.c b/drivers/media/dvb/frontends/tda827x.c
index 6de1aea02d51..8329d33b517a 100644
--- a/drivers/media/dvb/frontends/tda827x.c
+++ b/drivers/media/dvb/frontends/tda827x.c
@@ -38,10 +38,57 @@ struct tda827x_priv {
38 int i2c_addr; 38 int i2c_addr;
39 struct i2c_adapter *i2c_adap; 39 struct i2c_adapter *i2c_adap;
40 struct tda827x_config *cfg; 40 struct tda827x_config *cfg;
41
42 unsigned int sgIF;
43 unsigned char lpsel;
44
41 u32 frequency; 45 u32 frequency;
42 u32 bandwidth; 46 u32 bandwidth;
43}; 47};
44 48
49static void tda827x_set_std(struct dvb_frontend *fe,
50 struct analog_parameters *params)
51{
52 struct tda827x_priv *priv = fe->tuner_priv;
53 char *mode;
54
55 priv->lpsel = 0;
56 if (params->std & V4L2_STD_MN) {
57 priv->sgIF = 92;
58 priv->lpsel = 1;
59 mode = "MN";
60 } else if (params->std & V4L2_STD_B) {
61 priv->sgIF = 108;
62 mode = "B";
63 } else if (params->std & V4L2_STD_GH) {
64 priv->sgIF = 124;
65 mode = "GH";
66 } else if (params->std & V4L2_STD_PAL_I) {
67 priv->sgIF = 124;
68 mode = "I";
69 } else if (params->std & V4L2_STD_DK) {
70 priv->sgIF = 124;
71 mode = "DK";
72 } else if (params->std & V4L2_STD_SECAM_L) {
73 priv->sgIF = 124;
74 mode = "L";
75 } else if (params->std & V4L2_STD_SECAM_LC) {
76 priv->sgIF = 20;
77 mode = "LC";
78 } else {
79 priv->sgIF = 124;
80 mode = "xx";
81 }
82
83 if (params->mode == V4L2_TUNER_RADIO)
84 priv->sgIF = 88; /* if frequency is 5.5 MHz */
85
86 dprintk("setting tda827x to system %s\n", mode);
87}
88
89
90/* ------------------------------------------------------------------ */
91
45struct tda827x_data { 92struct tda827x_data {
46 u32 lomax; 93 u32 lomax;
47 u8 spd; 94 u8 spd;
@@ -189,10 +236,12 @@ static int tda827xo_set_analog_params(struct dvb_frontend *fe,
189 struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0 }; 236 struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0 };
190 unsigned int freq = params->frequency; 237 unsigned int freq = params->frequency;
191 238
239 tda827x_set_std(fe, params);
240
192 if (params->mode == V4L2_TUNER_RADIO) 241 if (params->mode == V4L2_TUNER_RADIO)
193 freq = freq / 1000; 242 freq = freq / 1000;
194 243
195 N = freq + priv->cfg->sgIF; 244 N = freq + priv->sgIF;
196 245
197 i = 0; 246 i = 0;
198 while (tda827x_table[i].lomax < N * 62500) { 247 while (tda827x_table[i].lomax < N * 62500) {
@@ -207,7 +256,7 @@ static int tda827xo_set_analog_params(struct dvb_frontend *fe,
207 tuner_reg[1] = (unsigned char)(N>>8); 256 tuner_reg[1] = (unsigned char)(N>>8);
208 tuner_reg[2] = (unsigned char) N; 257 tuner_reg[2] = (unsigned char) N;
209 tuner_reg[3] = 0x40; 258 tuner_reg[3] = 0x40;
210 tuner_reg[4] = 0x52 + (priv->cfg->tda827x_lpsel << 5); 259 tuner_reg[4] = 0x52 + (priv->lpsel << 5);
211 tuner_reg[5] = (tda827x_table[i].spd << 6) + 260 tuner_reg[5] = (tda827x_table[i].spd << 6) +
212 (tda827x_table[i].div1p5 << 5) + 261 (tda827x_table[i].div1p5 << 5) +
213 (tda827x_table[i].bs << 3) + tda827x_table[i].bp; 262 (tda827x_table[i].bs << 3) + tda827x_table[i].bp;
@@ -550,13 +599,15 @@ static int tda827xa_set_analog_params(struct dvb_frontend *fe,
550 .buf = tuner_reg, .len = sizeof(tuner_reg) }; 599 .buf = tuner_reg, .len = sizeof(tuner_reg) };
551 unsigned int freq = params->frequency; 600 unsigned int freq = params->frequency;
552 601
602 tda827x_set_std(fe, params);
603
553 tda827xa_lna_gain(fe, 1, params); 604 tda827xa_lna_gain(fe, 1, params);
554 msleep(10); 605 msleep(10);
555 606
556 if (params->mode == V4L2_TUNER_RADIO) 607 if (params->mode == V4L2_TUNER_RADIO)
557 freq = freq / 1000; 608 freq = freq / 1000;
558 609
559 N = freq + priv->cfg->sgIF; 610 N = freq + priv->sgIF;
560 611
561 i = 0; 612 i = 0;
562 while (tda827xa_analog[i].lomax < N * 62500) { 613 while (tda827xa_analog[i].lomax < N * 62500) {
@@ -587,7 +638,7 @@ static int tda827xa_set_analog_params(struct dvb_frontend *fe,
587 tuner_reg[1] = 0xff; 638 tuner_reg[1] = 0xff;
588 tuner_reg[2] = 0xe0; 639 tuner_reg[2] = 0xe0;
589 tuner_reg[3] = 0; 640 tuner_reg[3] = 0;
590 tuner_reg[4] = 0x99 + (priv->cfg->tda827x_lpsel << 1); 641 tuner_reg[4] = 0x99 + (priv->lpsel << 1);
591 msg.len = 5; 642 msg.len = 5;
592 i2c_transfer(priv->i2c_adap, &msg, 1); 643 i2c_transfer(priv->i2c_adap, &msg, 1);
593 644
@@ -627,7 +678,7 @@ static int tda827xa_set_analog_params(struct dvb_frontend *fe,
627 i2c_transfer(priv->i2c_adap, &msg, 1); 678 i2c_transfer(priv->i2c_adap, &msg, 1);
628 679
629 tuner_reg[0] = 0xc0; 680 tuner_reg[0] = 0xc0;
630 tuner_reg[1] = 0x19 + (priv->cfg->tda827x_lpsel << 1); 681 tuner_reg[1] = 0x19 + (priv->lpsel << 1);
631 i2c_transfer(priv->i2c_adap, &msg, 1); 682 i2c_transfer(priv->i2c_adap, &msg, 1);
632 683
633 priv->frequency = freq * 62500; 684 priv->frequency = freq * 62500;