diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-08-25 18:08:45 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:01:05 -0500 |
commit | 746d9732dbd5b95c3ba36230e2814fa2c391a311 (patch) | |
tree | bb63bc3eeea67bedd6b92727280ea8a35d5656b5 /drivers/media | |
parent | de3fe21ba2fdc0733ad4e555b95121baeba7fcd5 (diff) |
V4L/DVB (6433): Move all tda8275/8275a tuning code from tda8290 module into tda827x module
Add analog tuning support to tda827x dvb_frontend tuner module.
Convert tda8290 module back to native tuner interface.
The tda8290 analog demodulator will be handled the same way as tda9887.
The tuner.ko module (tuner-core) will pass commands to tda8290 via the
tuner_operations interface. tda8290 will communicate with tda827x via
the dvb_frontend interface, while passing a pointer to a private data
structure.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/Kconfig | 1 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/tda827x.c | 307 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/tda827x.h | 10 | ||||
-rw-r--r-- | drivers/media/video/tda8290.c | 566 | ||||
-rw-r--r-- | drivers/media/video/tda8290.h | 30 | ||||
-rw-r--r-- | drivers/media/video/tuner-core.c | 16 |
6 files changed, 423 insertions, 507 deletions
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index dfb52592451f..d363d0cae38b 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig | |||
@@ -107,6 +107,7 @@ config TUNER_MT20XX | |||
107 | config TUNER_TDA8290 | 107 | config TUNER_TDA8290 |
108 | tristate "TDA 8290+8275(a) tuner combo" | 108 | tristate "TDA 8290+8275(a) tuner combo" |
109 | depends on I2C | 109 | depends on I2C |
110 | select DVB_TDA827X | ||
110 | default m if VIDEO_TUNER_CUSTOMIZE | 111 | default m if VIDEO_TUNER_CUSTOMIZE |
111 | help | 112 | help |
112 | Say Y here to include support for Philips TDA8290+8275(a) tuner. | 113 | Say Y here to include support for Philips TDA8290+8275(a) tuner. |
diff --git a/drivers/media/dvb/frontends/tda827x.c b/drivers/media/dvb/frontends/tda827x.c index 256fc4bf500b..3c71f07a6d2c 100644 --- a/drivers/media/dvb/frontends/tda827x.c +++ b/drivers/media/dvb/frontends/tda827x.c | |||
@@ -19,12 +19,16 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/dvb/frontend.h> | ||
23 | #include <asm/types.h> | 22 | #include <asm/types.h> |
23 | #include <linux/dvb/frontend.h> | ||
24 | #include <linux/videodev2.h> | ||
24 | 25 | ||
25 | #include "tda827x.h" | 26 | #include "tda827x.h" |
26 | 27 | ||
27 | static int debug = 0; | 28 | static int debug = 0; |
29 | module_param(debug, int, 0644); | ||
30 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | ||
31 | |||
28 | #define dprintk(args...) \ | 32 | #define dprintk(args...) \ |
29 | do { \ | 33 | do { \ |
30 | if (debug) printk(KERN_DEBUG "tda827x: " args); \ | 34 | if (debug) printk(KERN_DEBUG "tda827x: " args); \ |
@@ -48,7 +52,7 @@ struct tda827x_data { | |||
48 | u8 div1p5; | 52 | u8 div1p5; |
49 | }; | 53 | }; |
50 | 54 | ||
51 | static const struct tda827x_data tda827x_dvbt[] = { | 55 | static const struct tda827x_data tda827x_table[] = { |
52 | { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1}, | 56 | { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1}, |
53 | { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1}, | 57 | { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1}, |
54 | { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0}, | 58 | { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0}, |
@@ -106,21 +110,22 @@ static int tda827xo_set_params(struct dvb_frontend *fe, | |||
106 | tuner_freq = params->frequency + if_freq; | 110 | tuner_freq = params->frequency + if_freq; |
107 | 111 | ||
108 | i = 0; | 112 | i = 0; |
109 | while (tda827x_dvbt[i].lomax < tuner_freq) { | 113 | while (tda827x_table[i].lomax < tuner_freq) { |
110 | if(tda827x_dvbt[i + 1].lomax == 0) | 114 | if (tda827x_table[i + 1].lomax == 0) |
111 | break; | 115 | break; |
112 | i++; | 116 | i++; |
113 | } | 117 | } |
114 | 118 | ||
115 | N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2); | 119 | N = ((tuner_freq + 125000) / 250000) << (tda827x_table[i].spd + 2); |
116 | buf[0] = 0; | 120 | buf[0] = 0; |
117 | buf[1] = (N>>8) | 0x40; | 121 | buf[1] = (N>>8) | 0x40; |
118 | buf[2] = N & 0xff; | 122 | buf[2] = N & 0xff; |
119 | buf[3] = 0; | 123 | buf[3] = 0; |
120 | buf[4] = 0x52; | 124 | buf[4] = 0x52; |
121 | buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) + | 125 | buf[5] = (tda827x_table[i].spd << 6) + (tda827x_table[i].div1p5 << 5) + |
122 | (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp; | 126 | (tda827x_table[i].bs << 3) + |
123 | buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f; | 127 | tda827x_table[i].bp; |
128 | buf[6] = (tda827x_table[i].gc3 << 4) + 0x8f; | ||
124 | buf[7] = 0xbf; | 129 | buf[7] = 0xbf; |
125 | buf[8] = 0x2a; | 130 | buf[8] = 0x2a; |
126 | buf[9] = 0x05; | 131 | buf[9] = 0x05; |
@@ -140,7 +145,7 @@ static int tda827xo_set_params(struct dvb_frontend *fe, | |||
140 | msleep(500); | 145 | msleep(500); |
141 | /* correct CP value */ | 146 | /* correct CP value */ |
142 | buf[0] = 0x30; | 147 | buf[0] = 0x30; |
143 | buf[1] = 0x50 + tda827x_dvbt[i].cp; | 148 | buf[1] = 0x50 + tda827x_table[i].cp; |
144 | msg.len = 2; | 149 | msg.len = 2; |
145 | 150 | ||
146 | if (fe->ops.i2c_gate_ctrl) | 151 | if (fe->ops.i2c_gate_ctrl) |
@@ -173,6 +178,100 @@ static int tda827xo_sleep(struct dvb_frontend *fe) | |||
173 | 178 | ||
174 | /* ------------------------------------------------------------------ */ | 179 | /* ------------------------------------------------------------------ */ |
175 | 180 | ||
181 | static int tda827xo_set_analog_params(struct dvb_frontend *fe, | ||
182 | struct analog_parameters *params) | ||
183 | { | ||
184 | unsigned char tuner_reg[8]; | ||
185 | unsigned char reg2[2]; | ||
186 | u32 N; | ||
187 | int i; | ||
188 | struct tda827x_priv *priv = fe->tuner_priv; | ||
189 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0 }; | ||
190 | unsigned int freq = params->frequency; | ||
191 | |||
192 | if (params->mode == V4L2_TUNER_RADIO) | ||
193 | freq = freq / 1000; | ||
194 | |||
195 | N = freq + priv->cfg->sgIF; | ||
196 | |||
197 | i = 0; | ||
198 | while (tda827x_table[i].lomax < N * 62500) { | ||
199 | if (tda827x_table[i + 1].lomax == 0) | ||
200 | break; | ||
201 | i++; | ||
202 | } | ||
203 | |||
204 | N = N << tda827x_table[i].spd; | ||
205 | |||
206 | tuner_reg[0] = 0; | ||
207 | tuner_reg[1] = (unsigned char)(N>>8); | ||
208 | tuner_reg[2] = (unsigned char) N; | ||
209 | tuner_reg[3] = 0x40; | ||
210 | tuner_reg[4] = 0x52 + (priv->cfg->tda827x_lpsel << 5); | ||
211 | tuner_reg[5] = (tda827x_table[i].spd << 6) + | ||
212 | (tda827x_table[i].div1p5 << 5) + | ||
213 | (tda827x_table[i].bs << 3) + tda827x_table[i].bp; | ||
214 | tuner_reg[6] = 0x8f + (tda827x_table[i].gc3 << 4); | ||
215 | tuner_reg[7] = 0x8f; | ||
216 | |||
217 | msg.buf = tuner_reg; | ||
218 | msg.len = 8; | ||
219 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
220 | |||
221 | msg.buf = reg2; | ||
222 | msg.len = 2; | ||
223 | reg2[0] = 0x80; | ||
224 | reg2[1] = 0; | ||
225 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
226 | |||
227 | reg2[0] = 0x60; | ||
228 | reg2[1] = 0xbf; | ||
229 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
230 | |||
231 | reg2[0] = 0x30; | ||
232 | reg2[1] = tuner_reg[4] + 0x80; | ||
233 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
234 | |||
235 | msleep(1); | ||
236 | reg2[0] = 0x30; | ||
237 | reg2[1] = tuner_reg[4] + 4; | ||
238 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
239 | |||
240 | msleep(1); | ||
241 | reg2[0] = 0x30; | ||
242 | reg2[1] = tuner_reg[4]; | ||
243 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
244 | |||
245 | msleep(550); | ||
246 | reg2[0] = 0x30; | ||
247 | reg2[1] = (tuner_reg[4] & 0xfc) + tda827x_table[i].cp; | ||
248 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
249 | |||
250 | reg2[0] = 0x60; | ||
251 | reg2[1] = 0x3f; | ||
252 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
253 | |||
254 | reg2[0] = 0x80; | ||
255 | reg2[1] = 0x08; /* Vsync en */ | ||
256 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
257 | |||
258 | priv->frequency = freq * 62500; | ||
259 | |||
260 | return 0; | ||
261 | } | ||
262 | |||
263 | static void tda827xo_agcf(struct dvb_frontend *fe) | ||
264 | { | ||
265 | struct tda827x_priv *priv = fe->tuner_priv; | ||
266 | unsigned char data[] = { 0x80, 0x0c }; | ||
267 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | ||
268 | .buf = data, .len = 2}; | ||
269 | |||
270 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
271 | } | ||
272 | |||
273 | /* ------------------------------------------------------------------ */ | ||
274 | |||
176 | struct tda827xa_data { | 275 | struct tda827xa_data { |
177 | u32 lomax; | 276 | u32 lomax; |
178 | u8 svco; | 277 | u8 svco; |
@@ -212,6 +311,35 @@ static const struct tda827xa_data tda827xa_dvbt[] = { | |||
212 | { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0} | 311 | { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0} |
213 | }; | 312 | }; |
214 | 313 | ||
314 | static struct tda827xa_data tda827xa_analog[] = { | ||
315 | { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 3}, | ||
316 | { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3}, | ||
317 | { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3}, | ||
318 | { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3}, | ||
319 | { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1}, | ||
320 | { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, | ||
321 | { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, | ||
322 | { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, | ||
323 | { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, | ||
324 | { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1}, | ||
325 | { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 3}, | ||
326 | { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 3}, | ||
327 | { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1}, | ||
328 | { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 3}, | ||
329 | { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 3}, | ||
330 | { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1}, | ||
331 | { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1}, | ||
332 | { .lomax = 554000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1}, | ||
333 | { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, | ||
334 | { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, | ||
335 | { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, | ||
336 | { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, | ||
337 | { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, | ||
338 | { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, | ||
339 | { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0}, | ||
340 | { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0} | ||
341 | }; | ||
342 | |||
215 | static int tda827xa_set_params(struct dvb_frontend *fe, | 343 | static int tda827xa_set_params(struct dvb_frontend *fe, |
216 | struct dvb_frontend_parameters *params) | 344 | struct dvb_frontend_parameters *params) |
217 | { | 345 | { |
@@ -368,6 +496,156 @@ static int tda827xa_sleep(struct dvb_frontend *fe) | |||
368 | return 0; | 496 | return 0; |
369 | } | 497 | } |
370 | 498 | ||
499 | /* ------------------------------------------------------------------ */ | ||
500 | |||
501 | static void tda827xa_lna_gain(struct dvb_frontend *fe, int high, | ||
502 | struct analog_parameters *params) | ||
503 | { | ||
504 | struct tda827x_priv *priv = fe->tuner_priv; | ||
505 | unsigned char buf[] = {0x22, 0x01}; | ||
506 | int arg; | ||
507 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | ||
508 | .buf = buf, .len = sizeof(buf) }; | ||
509 | |||
510 | if (priv->cfg->config) { | ||
511 | if (high) | ||
512 | dprintk("setting LNA to high gain\n"); | ||
513 | else | ||
514 | dprintk("setting LNA to low gain\n"); | ||
515 | } | ||
516 | switch (*priv->cfg->config) { | ||
517 | case 0: /* no LNA */ | ||
518 | break; | ||
519 | case 1: /* switch is GPIO 0 of tda8290 */ | ||
520 | case 2: | ||
521 | /* turn Vsync on */ | ||
522 | if (params->std & V4L2_STD_MN) | ||
523 | arg = 1; | ||
524 | else | ||
525 | arg = 0; | ||
526 | if (priv->cfg->tuner_callback) | ||
527 | priv->cfg->tuner_callback(priv->i2c_adap->algo_data, | ||
528 | 1, arg); | ||
529 | buf[1] = high ? 0 : 1; | ||
530 | if (*priv->cfg->config == 2) | ||
531 | buf[1] = high ? 1 : 0; | ||
532 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
533 | break; | ||
534 | case 3: /* switch with GPIO of saa713x */ | ||
535 | if (priv->cfg->tuner_callback) | ||
536 | priv->cfg->tuner_callback(priv->i2c_adap->algo_data, | ||
537 | 0, high); | ||
538 | break; | ||
539 | } | ||
540 | } | ||
541 | |||
542 | static int tda827xa_set_analog_params(struct dvb_frontend *fe, | ||
543 | struct analog_parameters *params) | ||
544 | { | ||
545 | unsigned char tuner_reg[11]; | ||
546 | u32 N; | ||
547 | int i; | ||
548 | struct tda827x_priv *priv = fe->tuner_priv; | ||
549 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | ||
550 | .buf = tuner_reg, .len = sizeof(tuner_reg) }; | ||
551 | unsigned int freq = params->frequency; | ||
552 | |||
553 | tda827xa_lna_gain(fe, 1, params); | ||
554 | msleep(10); | ||
555 | |||
556 | if (params->mode == V4L2_TUNER_RADIO) | ||
557 | freq = freq / 1000; | ||
558 | |||
559 | N = freq + priv->cfg->sgIF; | ||
560 | |||
561 | i = 0; | ||
562 | while (tda827xa_analog[i].lomax < N * 62500) { | ||
563 | if (tda827xa_analog[i + 1].lomax == 0) | ||
564 | break; | ||
565 | i++; | ||
566 | } | ||
567 | |||
568 | N = N << tda827xa_analog[i].spd; | ||
569 | |||
570 | tuner_reg[0] = 0; | ||
571 | tuner_reg[1] = (unsigned char)(N>>8); | ||
572 | tuner_reg[2] = (unsigned char) N; | ||
573 | tuner_reg[3] = 0; | ||
574 | tuner_reg[4] = 0x16; | ||
575 | tuner_reg[5] = (tda827xa_analog[i].spd << 5) + | ||
576 | (tda827xa_analog[i].svco << 3) + | ||
577 | tda827xa_analog[i].sbs; | ||
578 | tuner_reg[6] = 0x8b + (tda827xa_analog[i].gc3 << 4); | ||
579 | tuner_reg[7] = 0x1c; | ||
580 | tuner_reg[8] = 4; | ||
581 | tuner_reg[9] = 0x20; | ||
582 | tuner_reg[10] = 0x00; | ||
583 | msg.len = 11; | ||
584 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
585 | |||
586 | tuner_reg[0] = 0x90; | ||
587 | tuner_reg[1] = 0xff; | ||
588 | tuner_reg[2] = 0xe0; | ||
589 | tuner_reg[3] = 0; | ||
590 | tuner_reg[4] = 0x99 + (priv->cfg->tda827x_lpsel << 1); | ||
591 | msg.len = 5; | ||
592 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
593 | |||
594 | tuner_reg[0] = 0xa0; | ||
595 | tuner_reg[1] = 0xc0; | ||
596 | msg.len = 2; | ||
597 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
598 | |||
599 | tuner_reg[0] = 0x30; | ||
600 | tuner_reg[1] = 0x10 + tda827xa_analog[i].scr; | ||
601 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
602 | |||
603 | msg.flags = I2C_M_RD; | ||
604 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
605 | msg.flags = 0; | ||
606 | tuner_reg[1] >>= 4; | ||
607 | dprintk("AGC2 gain is: %d\n", tuner_reg[1]); | ||
608 | if (tuner_reg[1] < 1) | ||
609 | tda827xa_lna_gain(fe, 0, params); | ||
610 | |||
611 | msleep(100); | ||
612 | tuner_reg[0] = 0x60; | ||
613 | tuner_reg[1] = 0x3c; | ||
614 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
615 | |||
616 | msleep(163); | ||
617 | tuner_reg[0] = 0x50; | ||
618 | tuner_reg[1] = 0x8f + (tda827xa_analog[i].gc3 << 4); | ||
619 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
620 | |||
621 | tuner_reg[0] = 0x80; | ||
622 | tuner_reg[1] = 0x28; | ||
623 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
624 | |||
625 | tuner_reg[0] = 0xb0; | ||
626 | tuner_reg[1] = 0x01; | ||
627 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
628 | |||
629 | tuner_reg[0] = 0xc0; | ||
630 | tuner_reg[1] = 0x19 + (priv->cfg->tda827x_lpsel << 1); | ||
631 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
632 | |||
633 | priv->frequency = freq * 62500; | ||
634 | |||
635 | return 0; | ||
636 | } | ||
637 | |||
638 | static void tda827xa_agcf(struct dvb_frontend *fe) | ||
639 | { | ||
640 | struct tda827x_priv *priv = fe->tuner_priv; | ||
641 | unsigned char data[] = {0x80, 0x2c}; | ||
642 | struct i2c_msg msg = {.addr = priv->i2c_addr, .flags = 0, | ||
643 | .buf = data, .len = 2}; | ||
644 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
645 | } | ||
646 | |||
647 | /* ------------------------------------------------------------------ */ | ||
648 | |||
371 | static int tda827x_release(struct dvb_frontend *fe) | 649 | static int tda827x_release(struct dvb_frontend *fe) |
372 | { | 650 | { |
373 | kfree(fe->tuner_priv); | 651 | kfree(fe->tuner_priv); |
@@ -430,6 +708,7 @@ static struct dvb_tuner_ops tda827xo_tuner_ops = { | |||
430 | .init = tda827x_initial_init, | 708 | .init = tda827x_initial_init, |
431 | .sleep = tda827x_initial_sleep, | 709 | .sleep = tda827x_initial_sleep, |
432 | .set_params = tda827xo_set_params, | 710 | .set_params = tda827xo_set_params, |
711 | .set_analog_params = tda827xo_set_analog_params, | ||
433 | .get_frequency = tda827x_get_frequency, | 712 | .get_frequency = tda827x_get_frequency, |
434 | .get_bandwidth = tda827x_get_bandwidth, | 713 | .get_bandwidth = tda827x_get_bandwidth, |
435 | }; | 714 | }; |
@@ -445,6 +724,7 @@ static struct dvb_tuner_ops tda827xa_tuner_ops = { | |||
445 | .init = tda827x_init, | 724 | .init = tda827x_init, |
446 | .sleep = tda827xa_sleep, | 725 | .sleep = tda827xa_sleep, |
447 | .set_params = tda827xa_set_params, | 726 | .set_params = tda827xa_set_params, |
727 | .set_analog_params = tda827xa_set_analog_params, | ||
448 | .get_frequency = tda827x_get_frequency, | 728 | .get_frequency = tda827x_get_frequency, |
449 | .get_bandwidth = tda827x_get_bandwidth, | 729 | .get_bandwidth = tda827x_get_bandwidth, |
450 | }; | 730 | }; |
@@ -465,9 +745,11 @@ static int tda827x_probe_version(struct dvb_frontend *fe) | |||
465 | dprintk("tda827x tuner found\n"); | 745 | dprintk("tda827x tuner found\n"); |
466 | fe->ops.tuner_ops.init = tda827x_init; | 746 | fe->ops.tuner_ops.init = tda827x_init; |
467 | fe->ops.tuner_ops.sleep = tda827xo_sleep; | 747 | fe->ops.tuner_ops.sleep = tda827xo_sleep; |
748 | priv->cfg->agcf = tda827xo_agcf; | ||
468 | } else { | 749 | } else { |
469 | dprintk("tda827xa tuner found\n"); | 750 | dprintk("tda827xa tuner found\n"); |
470 | memcpy(&fe->ops.tuner_ops, &tda827xa_tuner_ops, sizeof(struct dvb_tuner_ops)); | 751 | memcpy(&fe->ops.tuner_ops, &tda827xa_tuner_ops, sizeof(struct dvb_tuner_ops)); |
752 | priv->cfg->agcf = tda827xa_agcf; | ||
471 | } | 753 | } |
472 | return 0; | 754 | return 0; |
473 | } | 755 | } |
@@ -487,17 +769,14 @@ struct dvb_frontend *tda827x_attach(struct dvb_frontend *fe, int addr, | |||
487 | priv->i2c_adap = i2c; | 769 | priv->i2c_adap = i2c; |
488 | priv->cfg = cfg; | 770 | priv->cfg = cfg; |
489 | memcpy(&fe->ops.tuner_ops, &tda827xo_tuner_ops, sizeof(struct dvb_tuner_ops)); | 771 | memcpy(&fe->ops.tuner_ops, &tda827xo_tuner_ops, sizeof(struct dvb_tuner_ops)); |
490 | |||
491 | fe->tuner_priv = priv; | 772 | fe->tuner_priv = priv; |
492 | 773 | ||
774 | dprintk("type set to %s\n", fe->ops.tuner_ops.info.name); | ||
775 | |||
493 | return fe; | 776 | return fe; |
494 | } | 777 | } |
495 | |||
496 | EXPORT_SYMBOL(tda827x_attach); | 778 | EXPORT_SYMBOL(tda827x_attach); |
497 | 779 | ||
498 | module_param(debug, int, 0644); | ||
499 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | ||
500 | |||
501 | MODULE_DESCRIPTION("DVB TDA827x driver"); | 780 | MODULE_DESCRIPTION("DVB TDA827x driver"); |
502 | MODULE_AUTHOR("Hartmut Hackmann <hartmut.hackmann@t-online.de>"); | 781 | MODULE_AUTHOR("Hartmut Hackmann <hartmut.hackmann@t-online.de>"); |
503 | MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>"); | 782 | MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>"); |
diff --git a/drivers/media/dvb/frontends/tda827x.h b/drivers/media/dvb/frontends/tda827x.h index 69e8263d6d59..06626f7af614 100644 --- a/drivers/media/dvb/frontends/tda827x.h +++ b/drivers/media/dvb/frontends/tda827x.h | |||
@@ -29,9 +29,19 @@ | |||
29 | 29 | ||
30 | struct tda827x_config | 30 | struct tda827x_config |
31 | { | 31 | { |
32 | /* saa7134 - provided callbacks */ | ||
32 | void (*lna_gain) (struct dvb_frontend *fe, int high); | 33 | void (*lna_gain) (struct dvb_frontend *fe, int high); |
33 | int (*init) (struct dvb_frontend *fe); | 34 | int (*init) (struct dvb_frontend *fe); |
34 | int (*sleep) (struct dvb_frontend *fe); | 35 | int (*sleep) (struct dvb_frontend *fe); |
36 | |||
37 | /* interface to tda829x driver */ | ||
38 | unsigned char tda827x_lpsel; | ||
39 | unsigned int sgIF; | ||
40 | |||
41 | unsigned int *config; | ||
42 | int (*tuner_callback) (void *dev, int command, int arg); | ||
43 | |||
44 | void (*agcf)(struct dvb_frontend *fe); | ||
35 | }; | 45 | }; |
36 | 46 | ||
37 | 47 | ||
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c index 0e5cf459d3ed..5d30cbcd7361 100644 --- a/drivers/media/video/tda8290.c +++ b/drivers/media/video/tda8290.c | |||
@@ -23,11 +23,11 @@ | |||
23 | #include <linux/i2c.h> | 23 | #include <linux/i2c.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/videodev.h> | 25 | #include <linux/videodev.h> |
26 | #include "tuner-i2c.h" | ||
27 | #include "tda8290.h" | 26 | #include "tda8290.h" |
27 | #include "tda827x.h" | ||
28 | 28 | ||
29 | static int debug = 0; | 29 | static int tuner_debug = 0; |
30 | module_param(debug, int, 0644); | 30 | module_param_named(debug, tuner_debug, int, 0644); |
31 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 31 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
32 | 32 | ||
33 | #define PREFIX "tda8290 " | 33 | #define PREFIX "tda8290 " |
@@ -38,332 +38,18 @@ struct tda8290_priv { | |||
38 | struct tuner_i2c_props i2c_props; | 38 | struct tuner_i2c_props i2c_props; |
39 | 39 | ||
40 | unsigned char tda8290_easy_mode; | 40 | unsigned char tda8290_easy_mode; |
41 | unsigned char tda827x_lpsel; | 41 | |
42 | unsigned char tda827x_addr; | 42 | unsigned char tda827x_addr; |
43 | unsigned char tda827x_ver; | 43 | unsigned char tda827x_ver; |
44 | unsigned int sgIF; | ||
45 | |||
46 | u32 frequency; | ||
47 | |||
48 | unsigned int *lna_cfg; | ||
49 | int (*tuner_callback) (void *dev, int command,int arg); | ||
50 | }; | ||
51 | |||
52 | /* ---------------------------------------------------------------------- */ | ||
53 | |||
54 | struct tda827x_data { | ||
55 | u32 lomax; | ||
56 | u8 spd; | ||
57 | u8 bs; | ||
58 | u8 bp; | ||
59 | u8 cp; | ||
60 | u8 gc3; | ||
61 | u8 div1p5; | ||
62 | }; | ||
63 | 44 | ||
64 | /* Note lomax entry is lo / 62500 */ | 45 | struct tda827x_config cfg; |
65 | |||
66 | static struct tda827x_data tda827x_analog[] = { | ||
67 | { .lomax = 992, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1}, /* 62 MHz */ | ||
68 | { .lomax = 1056, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1}, /* 66 MHz */ | ||
69 | { .lomax = 1216, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0}, /* 76 MHz */ | ||
70 | { .lomax = 1344, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0}, /* 84 MHz */ | ||
71 | { .lomax = 1488, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 93 MHz */ | ||
72 | { .lomax = 1568, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 98 MHz */ | ||
73 | { .lomax = 1744, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 109 MHz */ | ||
74 | { .lomax = 1968, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 123 MHz */ | ||
75 | { .lomax = 2128, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 133 MHz */ | ||
76 | { .lomax = 2416, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 151 MHz */ | ||
77 | { .lomax = 2464, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 154 MHz */ | ||
78 | { .lomax = 2896, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0}, /* 181 MHz */ | ||
79 | { .lomax = 2960, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 185 MHz */ | ||
80 | { .lomax = 3472, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 217 MHz */ | ||
81 | { .lomax = 3904, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 244 MHz */ | ||
82 | { .lomax = 4240, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 265 MHz */ | ||
83 | { .lomax = 4832, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 302 MHz */ | ||
84 | { .lomax = 5184, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 324 MHz */ | ||
85 | { .lomax = 5920, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 370 MHz */ | ||
86 | { .lomax = 7264, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 454 MHz */ | ||
87 | { .lomax = 7888, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 493 MHz */ | ||
88 | { .lomax = 8480, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 530 MHz */ | ||
89 | { .lomax = 8864, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 554 MHz */ | ||
90 | { .lomax = 9664, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0}, /* 604 MHz */ | ||
91 | { .lomax = 11088, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0}, /* 696 MHz */ | ||
92 | { .lomax = 11840, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0}, /* 740 MHz */ | ||
93 | { .lomax = 13120, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0}, /* 820 MHz */ | ||
94 | { .lomax = 13840, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0}, /* 865 MHz */ | ||
95 | { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0} /* End */ | ||
96 | }; | 46 | }; |
97 | 47 | ||
98 | static void tda827x_set_analog_params(struct dvb_frontend *fe, | ||
99 | struct analog_parameters *params) | ||
100 | { | ||
101 | unsigned char tuner_reg[8]; | ||
102 | unsigned char reg2[2]; | ||
103 | u32 N; | ||
104 | int i; | ||
105 | struct tda8290_priv *priv = fe->tuner_priv; | ||
106 | struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags = 0}; | ||
107 | unsigned int freq = params->frequency; | ||
108 | |||
109 | if (params->mode == V4L2_TUNER_RADIO) | ||
110 | freq = freq / 1000; | ||
111 | |||
112 | N = freq + priv->sgIF; | ||
113 | i = 0; | ||
114 | while (tda827x_analog[i].lomax < N) { | ||
115 | if(tda827x_analog[i + 1].lomax == 0) | ||
116 | break; | ||
117 | i++; | ||
118 | } | ||
119 | |||
120 | N = N << tda827x_analog[i].spd; | ||
121 | |||
122 | tuner_reg[0] = 0; | ||
123 | tuner_reg[1] = (unsigned char)(N>>8); | ||
124 | tuner_reg[2] = (unsigned char) N; | ||
125 | tuner_reg[3] = 0x40; | ||
126 | tuner_reg[4] = 0x52 + (priv->tda827x_lpsel << 5); | ||
127 | tuner_reg[5] = (tda827x_analog[i].spd << 6) + (tda827x_analog[i].div1p5 <<5) + | ||
128 | (tda827x_analog[i].bs <<3) + tda827x_analog[i].bp; | ||
129 | tuner_reg[6] = 0x8f + (tda827x_analog[i].gc3 << 4); | ||
130 | tuner_reg[7] = 0x8f; | ||
131 | |||
132 | msg.buf = tuner_reg; | ||
133 | msg.len = 8; | ||
134 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
135 | |||
136 | msg.buf= reg2; | ||
137 | msg.len = 2; | ||
138 | reg2[0] = 0x80; | ||
139 | reg2[1] = 0; | ||
140 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
141 | |||
142 | reg2[0] = 0x60; | ||
143 | reg2[1] = 0xbf; | ||
144 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
145 | |||
146 | reg2[0] = 0x30; | ||
147 | reg2[1] = tuner_reg[4] + 0x80; | ||
148 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
149 | |||
150 | msleep(1); | ||
151 | reg2[0] = 0x30; | ||
152 | reg2[1] = tuner_reg[4] + 4; | ||
153 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
154 | |||
155 | msleep(1); | ||
156 | reg2[0] = 0x30; | ||
157 | reg2[1] = tuner_reg[4]; | ||
158 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
159 | |||
160 | msleep(550); | ||
161 | reg2[0] = 0x30; | ||
162 | reg2[1] = (tuner_reg[4] & 0xfc) + tda827x_analog[i].cp ; | ||
163 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
164 | |||
165 | reg2[0] = 0x60; | ||
166 | reg2[1] = 0x3f; | ||
167 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
168 | |||
169 | reg2[0] = 0x80; | ||
170 | reg2[1] = 0x08; // Vsync en | ||
171 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
172 | } | ||
173 | |||
174 | static void tda827x_agcf(struct dvb_frontend *fe) | ||
175 | { | ||
176 | struct tda8290_priv *priv = fe->tuner_priv; | ||
177 | unsigned char data[] = {0x80, 0x0c}; | ||
178 | struct i2c_msg msg = {.addr = priv->tda827x_addr, .buf = data, | ||
179 | .flags = 0, .len = 2}; | ||
180 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
181 | } | ||
182 | |||
183 | /* ---------------------------------------------------------------------- */ | ||
184 | |||
185 | struct tda827xa_data { | ||
186 | u32 lomax; | ||
187 | u8 svco; | ||
188 | u8 spd; | ||
189 | u8 scr; | ||
190 | u8 sbs; | ||
191 | u8 gc3; | ||
192 | }; | ||
193 | |||
194 | static struct tda827xa_data tda827xa_analog[] = { | ||
195 | { .lomax = 910, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 3}, /* 56.875 MHz */ | ||
196 | { .lomax = 1076, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3}, /* 67.25 MHz */ | ||
197 | { .lomax = 1300, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3}, /* 81.25 MHz */ | ||
198 | { .lomax = 1560, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3}, /* 97.5 MHz */ | ||
199 | { .lomax = 1820, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1}, /* 113.75 MHz */ | ||
200 | { .lomax = 2152, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, /* 134.5 MHz */ | ||
201 | { .lomax = 2464, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, /* 154 MHz */ | ||
202 | { .lomax = 2600, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, /* 162.5 MHz */ | ||
203 | { .lomax = 2928, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, /* 183 MHz */ | ||
204 | { .lomax = 3120, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1}, /* 195 MHz */ | ||
205 | { .lomax = 3640, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 3}, /* 227.5 MHz */ | ||
206 | { .lomax = 4304, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 3}, /* 269 MHz */ | ||
207 | { .lomax = 5200, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1}, /* 325 MHz */ | ||
208 | { .lomax = 6240, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 3}, /* 390 MHz */ | ||
209 | { .lomax = 7280, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 3}, /* 455 MHz */ | ||
210 | { .lomax = 8320, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1}, /* 520 MHz */ | ||
211 | { .lomax = 8608, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1}, /* 538 MHz */ | ||
212 | { .lomax = 8864, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1}, /* 554 MHz */ | ||
213 | { .lomax = 9920, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, /* 620 MHz */ | ||
214 | { .lomax = 10400, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, /* 650 MHz */ | ||
215 | { .lomax = 11200, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, /* 700 MHz */ | ||
216 | { .lomax = 12480, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, /* 780 MHz */ | ||
217 | { .lomax = 13120, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, /* 820 MHz */ | ||
218 | { .lomax = 13920, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, /* 870 MHz */ | ||
219 | { .lomax = 14576, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0}, /* 911 MHz */ | ||
220 | { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0} /* End */ | ||
221 | }; | ||
222 | |||
223 | static void tda827xa_lna_gain(struct dvb_frontend *fe, int high, | ||
224 | struct analog_parameters *params) | ||
225 | { | ||
226 | struct tda8290_priv *priv = fe->tuner_priv; | ||
227 | unsigned char buf[] = {0x22, 0x01}; | ||
228 | int arg; | ||
229 | struct i2c_msg msg = {.addr = priv->i2c_props.addr, .flags = 0, .buf = buf, .len = sizeof(buf)}; | ||
230 | |||
231 | if ((priv->lna_cfg == NULL) || (priv->tuner_callback == NULL)) | ||
232 | return; | ||
233 | |||
234 | if (*priv->lna_cfg) { | ||
235 | if (high) | ||
236 | tuner_dbg("setting LNA to high gain\n"); | ||
237 | else | ||
238 | tuner_dbg("setting LNA to low gain\n"); | ||
239 | } | ||
240 | switch (*priv->lna_cfg) { | ||
241 | case 0: /* no LNA */ | ||
242 | break; | ||
243 | case 1: /* switch is GPIO 0 of tda8290 */ | ||
244 | case 2: | ||
245 | /* turn Vsync on */ | ||
246 | if (params->std & V4L2_STD_MN) | ||
247 | arg = 1; | ||
248 | else | ||
249 | arg = 0; | ||
250 | if (priv->tuner_callback) | ||
251 | priv->tuner_callback(priv->i2c_props.adap->algo_data, 1, arg); | ||
252 | buf[1] = high ? 0 : 1; | ||
253 | if (*priv->lna_cfg == 2) | ||
254 | buf[1] = high ? 1 : 0; | ||
255 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
256 | break; | ||
257 | case 3: /* switch with GPIO of saa713x */ | ||
258 | if (priv->tuner_callback) | ||
259 | priv->tuner_callback(priv->i2c_props.adap->algo_data, 0, high); | ||
260 | break; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | static void tda827xa_set_analog_params(struct dvb_frontend *fe, | ||
265 | struct analog_parameters *params) | ||
266 | { | ||
267 | unsigned char tuner_reg[11]; | ||
268 | u32 N; | ||
269 | int i; | ||
270 | struct tda8290_priv *priv = fe->tuner_priv; | ||
271 | struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags = 0, .buf = tuner_reg}; | ||
272 | unsigned int freq = params->frequency; | ||
273 | |||
274 | tda827xa_lna_gain(fe, 1, params); | ||
275 | msleep(10); | ||
276 | |||
277 | if (params->mode == V4L2_TUNER_RADIO) | ||
278 | freq = freq / 1000; | ||
279 | |||
280 | N = freq + priv->sgIF; | ||
281 | i = 0; | ||
282 | while (tda827xa_analog[i].lomax < N) { | ||
283 | if(tda827xa_analog[i + 1].lomax == 0) | ||
284 | break; | ||
285 | i++; | ||
286 | } | ||
287 | |||
288 | N = N << tda827xa_analog[i].spd; | ||
289 | |||
290 | tuner_reg[0] = 0; | ||
291 | tuner_reg[1] = (unsigned char)(N>>8); | ||
292 | tuner_reg[2] = (unsigned char) N; | ||
293 | tuner_reg[3] = 0; | ||
294 | tuner_reg[4] = 0x16; | ||
295 | tuner_reg[5] = (tda827xa_analog[i].spd << 5) + (tda827xa_analog[i].svco << 3) + | ||
296 | tda827xa_analog[i].sbs; | ||
297 | tuner_reg[6] = 0x8b + (tda827xa_analog[i].gc3 << 4); | ||
298 | tuner_reg[7] = 0x1c; | ||
299 | tuner_reg[8] = 4; | ||
300 | tuner_reg[9] = 0x20; | ||
301 | tuner_reg[10] = 0x00; | ||
302 | msg.len = 11; | ||
303 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
304 | |||
305 | tuner_reg[0] = 0x90; | ||
306 | tuner_reg[1] = 0xff; | ||
307 | tuner_reg[2] = 0xe0; | ||
308 | tuner_reg[3] = 0; | ||
309 | tuner_reg[4] = 0x99 + (priv->tda827x_lpsel << 1); | ||
310 | msg.len = 5; | ||
311 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
312 | |||
313 | tuner_reg[0] = 0xa0; | ||
314 | tuner_reg[1] = 0xc0; | ||
315 | msg.len = 2; | ||
316 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
317 | |||
318 | tuner_reg[0] = 0x30; | ||
319 | tuner_reg[1] = 0x10 + tda827xa_analog[i].scr; | ||
320 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
321 | |||
322 | msg.flags = I2C_M_RD; | ||
323 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
324 | msg.flags = 0; | ||
325 | tuner_reg[1] >>= 4; | ||
326 | tuner_dbg("AGC2 gain is: %d\n", tuner_reg[1]); | ||
327 | if (tuner_reg[1] < 1) | ||
328 | tda827xa_lna_gain(fe, 0, params); | ||
329 | |||
330 | msleep(100); | ||
331 | tuner_reg[0] = 0x60; | ||
332 | tuner_reg[1] = 0x3c; | ||
333 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
334 | |||
335 | msleep(163); | ||
336 | tuner_reg[0] = 0x50; | ||
337 | tuner_reg[1] = 0x8f + (tda827xa_analog[i].gc3 << 4); | ||
338 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
339 | |||
340 | tuner_reg[0] = 0x80; | ||
341 | tuner_reg[1] = 0x28; | ||
342 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
343 | |||
344 | tuner_reg[0] = 0xb0; | ||
345 | tuner_reg[1] = 0x01; | ||
346 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
347 | |||
348 | tuner_reg[0] = 0xc0; | ||
349 | tuner_reg[1] = 0x19 + (priv->tda827x_lpsel << 1); | ||
350 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
351 | } | ||
352 | |||
353 | static void tda827xa_agcf(struct dvb_frontend *fe) | ||
354 | { | ||
355 | struct tda8290_priv *priv = fe->tuner_priv; | ||
356 | unsigned char data[] = {0x80, 0x2c}; | ||
357 | struct i2c_msg msg = {.addr = priv->tda827x_addr, .buf = data, | ||
358 | .flags = 0, .len = 2}; | ||
359 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
360 | } | ||
361 | |||
362 | /*---------------------------------------------------------------------*/ | 48 | /*---------------------------------------------------------------------*/ |
363 | 49 | ||
364 | static void tda8290_i2c_bridge(struct dvb_frontend *fe, int close) | 50 | static void tda8290_i2c_bridge(struct tuner *t, int close) |
365 | { | 51 | { |
366 | struct tda8290_priv *priv = fe->tuner_priv; | 52 | struct tda8290_priv *priv = t->priv; |
367 | 53 | ||
368 | unsigned char enable[2] = { 0x21, 0xC0 }; | 54 | unsigned char enable[2] = { 0x21, 0xC0 }; |
369 | unsigned char disable[2] = { 0x21, 0x00 }; | 55 | unsigned char disable[2] = { 0x21, 0x00 }; |
@@ -381,58 +67,56 @@ static void tda8290_i2c_bridge(struct dvb_frontend *fe, int close) | |||
381 | 67 | ||
382 | /*---------------------------------------------------------------------*/ | 68 | /*---------------------------------------------------------------------*/ |
383 | 69 | ||
384 | static void set_audio(struct dvb_frontend *fe, | 70 | static void set_audio(struct tuner *t) |
385 | struct analog_parameters *params) | ||
386 | { | 71 | { |
387 | struct tda8290_priv *priv = fe->tuner_priv; | 72 | struct tda8290_priv *priv = t->priv; |
388 | char* mode; | 73 | char* mode; |
389 | 74 | ||
390 | priv->tda827x_lpsel = 0; | 75 | priv->cfg.tda827x_lpsel = 0; |
391 | if (params->std & V4L2_STD_MN) { | 76 | if (t->std & V4L2_STD_MN) { |
392 | priv->sgIF = 92; | 77 | priv->cfg.sgIF = 92; |
393 | priv->tda8290_easy_mode = 0x01; | 78 | priv->tda8290_easy_mode = 0x01; |
394 | priv->tda827x_lpsel = 1; | 79 | priv->cfg.tda827x_lpsel = 1; |
395 | mode = "MN"; | 80 | mode = "MN"; |
396 | } else if (params->std & V4L2_STD_B) { | 81 | } else if (t->std & V4L2_STD_B) { |
397 | priv->sgIF = 108; | 82 | priv->cfg.sgIF = 108; |
398 | priv->tda8290_easy_mode = 0x02; | 83 | priv->tda8290_easy_mode = 0x02; |
399 | mode = "B"; | 84 | mode = "B"; |
400 | } else if (params->std & V4L2_STD_GH) { | 85 | } else if (t->std & V4L2_STD_GH) { |
401 | priv->sgIF = 124; | 86 | priv->cfg.sgIF = 124; |
402 | priv->tda8290_easy_mode = 0x04; | 87 | priv->tda8290_easy_mode = 0x04; |
403 | mode = "GH"; | 88 | mode = "GH"; |
404 | } else if (params->std & V4L2_STD_PAL_I) { | 89 | } else if (t->std & V4L2_STD_PAL_I) { |
405 | priv->sgIF = 124; | 90 | priv->cfg.sgIF = 124; |
406 | priv->tda8290_easy_mode = 0x08; | 91 | priv->tda8290_easy_mode = 0x08; |
407 | mode = "I"; | 92 | mode = "I"; |
408 | } else if (params->std & V4L2_STD_DK) { | 93 | } else if (t->std & V4L2_STD_DK) { |
409 | priv->sgIF = 124; | 94 | priv->cfg.sgIF = 124; |
410 | priv->tda8290_easy_mode = 0x10; | 95 | priv->tda8290_easy_mode = 0x10; |
411 | mode = "DK"; | 96 | mode = "DK"; |
412 | } else if (params->std & V4L2_STD_SECAM_L) { | 97 | } else if (t->std & V4L2_STD_SECAM_L) { |
413 | priv->sgIF = 124; | 98 | priv->cfg.sgIF = 124; |
414 | priv->tda8290_easy_mode = 0x20; | 99 | priv->tda8290_easy_mode = 0x20; |
415 | mode = "L"; | 100 | mode = "L"; |
416 | } else if (params->std & V4L2_STD_SECAM_LC) { | 101 | } else if (t->std & V4L2_STD_SECAM_LC) { |
417 | priv->sgIF = 20; | 102 | priv->cfg.sgIF = 20; |
418 | priv->tda8290_easy_mode = 0x40; | 103 | priv->tda8290_easy_mode = 0x40; |
419 | mode = "LC"; | 104 | mode = "LC"; |
420 | } else { | 105 | } else { |
421 | priv->sgIF = 124; | 106 | priv->cfg.sgIF = 124; |
422 | priv->tda8290_easy_mode = 0x10; | 107 | priv->tda8290_easy_mode = 0x10; |
423 | mode = "xx"; | 108 | mode = "xx"; |
424 | } | 109 | } |
425 | 110 | ||
426 | if (params->mode == V4L2_TUNER_RADIO) | 111 | if (t->mode == V4L2_TUNER_RADIO) |
427 | priv->sgIF = 88; /* if frequency is 5.5 MHz */ | 112 | priv->cfg.sgIF = 88; /* if frequency is 5.5 MHz */ |
428 | 113 | ||
429 | tuner_dbg("setting tda8290 to system %s\n", mode); | 114 | tuner_dbg("setting tda8290 to system %s\n", mode); |
430 | } | 115 | } |
431 | 116 | ||
432 | static int tda8290_set_params(struct dvb_frontend *fe, | 117 | static void tda8290_set_freq(struct tuner *t, unsigned int freq) |
433 | struct analog_parameters *params) | ||
434 | { | 118 | { |
435 | struct tda8290_priv *priv = fe->tuner_priv; | 119 | struct tda8290_priv *priv = t->priv; |
436 | unsigned char soft_reset[] = { 0x00, 0x00 }; | 120 | unsigned char soft_reset[] = { 0x00, 0x00 }; |
437 | unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; | 121 | unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; |
438 | unsigned char expert_mode[] = { 0x01, 0x80 }; | 122 | unsigned char expert_mode[] = { 0x01, 0x80 }; |
@@ -455,10 +139,16 @@ static int tda8290_set_params(struct dvb_frontend *fe, | |||
455 | pll_stat; | 139 | pll_stat; |
456 | int i; | 140 | int i; |
457 | 141 | ||
458 | set_audio(fe, params); | 142 | struct analog_parameters params = { |
143 | .frequency = freq, | ||
144 | .mode = t->mode, | ||
145 | .audmode = t->audmode, | ||
146 | .std = t->std | ||
147 | }; | ||
148 | |||
149 | set_audio(t); | ||
459 | 150 | ||
460 | if (priv->lna_cfg) | 151 | tuner_dbg("tda827xa config is 0x%02x\n", t->config); |
461 | tuner_dbg("tda827xa config is 0x%02x\n", *priv->lna_cfg); | ||
462 | tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); | 152 | tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); |
463 | tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2); | 153 | tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2); |
464 | tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2); | 154 | tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2); |
@@ -474,11 +164,11 @@ static int tda8290_set_params(struct dvb_frontend *fe, | |||
474 | tuner_i2c_xfer_send(&priv->i2c_props, adc_head_6, 2); | 164 | tuner_i2c_xfer_send(&priv->i2c_props, adc_head_6, 2); |
475 | tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2); | 165 | tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2); |
476 | 166 | ||
477 | tda8290_i2c_bridge(fe, 1); | 167 | tda8290_i2c_bridge(t, 1); |
478 | if (priv->tda827x_ver != 0) | 168 | |
479 | tda827xa_set_analog_params(fe, params); | 169 | if (t->fe.ops.tuner_ops.set_analog_params) |
480 | else | 170 | t->fe.ops.tuner_ops.set_analog_params(&t->fe, ¶ms); |
481 | tda827x_set_analog_params(fe, params); | 171 | |
482 | for (i = 0; i < 3; i++) { | 172 | for (i = 0; i < 3; i++) { |
483 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); | 173 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); |
484 | tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); | 174 | tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); |
@@ -507,10 +197,8 @@ static int tda8290_set_params(struct dvb_frontend *fe, | |||
507 | if ((agc_stat > 115) || !(pll_stat & 0x80)) { | 197 | if ((agc_stat > 115) || !(pll_stat & 0x80)) { |
508 | tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", | 198 | tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", |
509 | agc_stat, pll_stat & 0x80); | 199 | agc_stat, pll_stat & 0x80); |
510 | if (priv->tda827x_ver != 0) | 200 | if (priv->cfg.agcf) |
511 | tda827xa_agcf(fe); | 201 | priv->cfg.agcf(&t->fe); |
512 | else | ||
513 | tda827x_agcf(fe); | ||
514 | msleep(100); | 202 | msleep(100); |
515 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); | 203 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); |
516 | tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); | 204 | tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); |
@@ -539,94 +227,61 @@ static int tda8290_set_params(struct dvb_frontend *fe, | |||
539 | } | 227 | } |
540 | } | 228 | } |
541 | 229 | ||
542 | tda8290_i2c_bridge(fe, 0); | 230 | tda8290_i2c_bridge(t, 0); |
543 | tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2); | 231 | tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2); |
544 | |||
545 | priv->frequency = (V4L2_TUNER_RADIO == params->mode) ? | ||
546 | params->frequency * 125 / 2 : params->frequency * 62500; | ||
547 | |||
548 | return 0; | ||
549 | } | 232 | } |
550 | 233 | ||
551 | /*---------------------------------------------------------------------*/ | 234 | /*---------------------------------------------------------------------*/ |
552 | 235 | ||
553 | static int tda8290_has_signal(struct dvb_frontend *fe) | 236 | static int tda8290_has_signal(struct tuner *t) |
554 | { | 237 | { |
555 | struct tda8290_priv *priv = fe->tuner_priv; | 238 | struct tda8290_priv *priv = t->priv; |
556 | int ret; | ||
557 | 239 | ||
558 | unsigned char i2c_get_afc[1] = { 0x1B }; | 240 | unsigned char i2c_get_afc[1] = { 0x1B }; |
559 | unsigned char afc = 0; | 241 | unsigned char afc = 0; |
560 | 242 | ||
561 | /* for now, report based on afc status */ | ||
562 | tuner_i2c_xfer_send(&priv->i2c_props, i2c_get_afc, ARRAY_SIZE(i2c_get_afc)); | 243 | tuner_i2c_xfer_send(&priv->i2c_props, i2c_get_afc, ARRAY_SIZE(i2c_get_afc)); |
563 | tuner_i2c_xfer_recv(&priv->i2c_props, &afc, 1); | 244 | tuner_i2c_xfer_recv(&priv->i2c_props, &afc, 1); |
564 | 245 | return (afc & 0x80)? 65535:0; | |
565 | ret = (afc & 0x80) ? 65535 : 0; | ||
566 | |||
567 | tuner_dbg("AFC status: %d\n", ret); | ||
568 | |||
569 | return ret; | ||
570 | } | ||
571 | |||
572 | static int tda8290_get_status(struct dvb_frontend *fe, u32 *status) | ||
573 | { | ||
574 | *status = 0; | ||
575 | |||
576 | if (tda8290_has_signal(fe)) | ||
577 | *status = TUNER_STATUS_LOCKED; | ||
578 | |||
579 | return 0; | ||
580 | } | ||
581 | |||
582 | static int tda8290_get_rf_strength(struct dvb_frontend *fe, u16 *strength) | ||
583 | { | ||
584 | *strength = tda8290_has_signal(fe); | ||
585 | |||
586 | return 0; | ||
587 | } | 246 | } |
588 | 247 | ||
589 | /*---------------------------------------------------------------------*/ | 248 | /*---------------------------------------------------------------------*/ |
590 | 249 | ||
591 | static int tda8290_standby(struct dvb_frontend *fe) | 250 | static void tda8290_standby(struct tuner *t) |
592 | { | 251 | { |
593 | struct tda8290_priv *priv = fe->tuner_priv; | 252 | struct tda8290_priv *priv = t->priv; |
594 | unsigned char cb1[] = { 0x30, 0xD0 }; | 253 | unsigned char cb1[] = { 0x30, 0xD0 }; |
595 | unsigned char tda8290_standby[] = { 0x00, 0x02 }; | 254 | unsigned char tda8290_standby[] = { 0x00, 0x02 }; |
596 | unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; | 255 | unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; |
597 | struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; | 256 | struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; |
598 | 257 | ||
599 | tda8290_i2c_bridge(fe, 1); | 258 | tda8290_i2c_bridge(t, 1); |
600 | if (priv->tda827x_ver != 0) | 259 | if (priv->tda827x_ver != 0) |
601 | cb1[1] = 0x90; | 260 | cb1[1] = 0x90; |
602 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | 261 | i2c_transfer(priv->i2c_props.adap, &msg, 1); |
603 | tda8290_i2c_bridge(fe, 0); | 262 | tda8290_i2c_bridge(t, 0); |
604 | tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2); | 263 | tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2); |
605 | tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2); | 264 | tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2); |
606 | |||
607 | return 0; | ||
608 | } | 265 | } |
609 | 266 | ||
610 | 267 | static void tda8290_init_if(struct tuner *t) | |
611 | static void tda8290_init_if(struct dvb_frontend *fe) | ||
612 | { | 268 | { |
613 | struct tda8290_priv *priv = fe->tuner_priv; | 269 | struct tda8290_priv *priv = t->priv; |
614 | 270 | ||
615 | unsigned char set_VS[] = { 0x30, 0x6F }; | 271 | unsigned char set_VS[] = { 0x30, 0x6F }; |
616 | unsigned char set_GP00_CF[] = { 0x20, 0x01 }; | 272 | unsigned char set_GP00_CF[] = { 0x20, 0x01 }; |
617 | unsigned char set_GP01_CF[] = { 0x20, 0x0B }; | 273 | unsigned char set_GP01_CF[] = { 0x20, 0x0B }; |
618 | 274 | ||
619 | if ((priv->lna_cfg) && | 275 | if ((t->config == 1) || (t->config == 2)) |
620 | ((*priv->lna_cfg == 1) || (*priv->lna_cfg == 2))) | ||
621 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2); | 276 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2); |
622 | else | 277 | else |
623 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2); | 278 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2); |
624 | tuner_i2c_xfer_send(&priv->i2c_props, set_VS, 2); | 279 | tuner_i2c_xfer_send(&priv->i2c_props, set_VS, 2); |
625 | } | 280 | } |
626 | 281 | ||
627 | static void tda8290_init_tuner(struct dvb_frontend *fe) | 282 | static void tda8290_init_tuner(struct tuner *t) |
628 | { | 283 | { |
629 | struct tda8290_priv *priv = fe->tuner_priv; | 284 | struct tda8290_priv *priv = t->priv; |
630 | unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, | 285 | unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, |
631 | 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; | 286 | 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; |
632 | unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, | 287 | unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, |
@@ -636,41 +291,31 @@ static void tda8290_init_tuner(struct dvb_frontend *fe) | |||
636 | if (priv->tda827x_ver != 0) | 291 | if (priv->tda827x_ver != 0) |
637 | msg.buf = tda8275a_init; | 292 | msg.buf = tda8275a_init; |
638 | 293 | ||
639 | tda8290_i2c_bridge(fe, 1); | 294 | tda8290_i2c_bridge(t, 1); |
640 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | 295 | i2c_transfer(priv->i2c_props.adap, &msg, 1); |
641 | tda8290_i2c_bridge(fe, 0); | 296 | tda8290_i2c_bridge(t, 0); |
642 | } | 297 | } |
643 | 298 | ||
644 | /*---------------------------------------------------------------------*/ | 299 | /*---------------------------------------------------------------------*/ |
645 | 300 | ||
646 | static int tda8290_release(struct dvb_frontend *fe) | 301 | static void tda8290_release(struct tuner *t) |
647 | { | 302 | { |
648 | kfree(fe->tuner_priv); | 303 | if (t->fe.ops.tuner_ops.release) |
649 | fe->tuner_priv = NULL; | 304 | t->fe.ops.tuner_ops.release(&t->fe); |
650 | |||
651 | return 0; | ||
652 | } | ||
653 | 305 | ||
654 | static int tda8290_get_frequency(struct dvb_frontend *fe, u32 *frequency) | 306 | kfree(t->priv); |
655 | { | 307 | t->priv = NULL; |
656 | struct tda8290_priv *priv = fe->tuner_priv; | ||
657 | *frequency = priv->frequency; | ||
658 | return 0; | ||
659 | } | 308 | } |
660 | 309 | ||
661 | static struct dvb_tuner_ops tda8290_tuner_ops = { | 310 | static struct tuner_operations tda8290_tuner_ops = { |
662 | .sleep = tda8290_standby, | 311 | .set_tv_freq = tda8290_set_freq, |
663 | .set_analog_params = tda8290_set_params, | 312 | .set_radio_freq = tda8290_set_freq, |
664 | .release = tda8290_release, | 313 | .has_signal = tda8290_has_signal, |
665 | .get_frequency = tda8290_get_frequency, | 314 | .standby = tda8290_standby, |
666 | .get_status = tda8290_get_status, | 315 | .release = tda8290_release, |
667 | .get_rf_strength = tda8290_get_rf_strength, | ||
668 | }; | 316 | }; |
669 | 317 | ||
670 | struct dvb_frontend *tda8290_attach(struct dvb_frontend *fe, | 318 | int tda8290_attach(struct tuner *t) |
671 | struct i2c_adapter* i2c_adap, | ||
672 | u8 i2c_addr, | ||
673 | struct tda8290_config *cfg) | ||
674 | { | 319 | { |
675 | struct tda8290_priv *priv = NULL; | 320 | struct tda8290_priv *priv = NULL; |
676 | u8 data; | 321 | u8 data; |
@@ -680,17 +325,15 @@ struct dvb_frontend *tda8290_attach(struct dvb_frontend *fe, | |||
680 | 325 | ||
681 | priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL); | 326 | priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL); |
682 | if (priv == NULL) | 327 | if (priv == NULL) |
683 | return NULL; | 328 | return -ENOMEM; |
684 | fe->tuner_priv = priv; | 329 | t->priv = priv; |
685 | 330 | ||
686 | priv->i2c_props.addr = i2c_addr; | 331 | priv->i2c_props.addr = t->i2c.addr; |
687 | priv->i2c_props.adap = i2c_adap; | 332 | priv->i2c_props.adap = t->i2c.adapter; |
688 | if (cfg) { | 333 | priv->cfg.config = &t->config; |
689 | priv->lna_cfg = cfg->lna_cfg; | 334 | priv->cfg.tuner_callback = t->tuner_callback; |
690 | priv->tuner_callback = cfg->tuner_callback; | ||
691 | } | ||
692 | 335 | ||
693 | tda8290_i2c_bridge(fe, 1); | 336 | tda8290_i2c_bridge(t, 1); |
694 | /* probe for tuner chip */ | 337 | /* probe for tuner chip */ |
695 | tuners_found = 0; | 338 | tuners_found = 0; |
696 | tuner_addrs = 0; | 339 | tuner_addrs = 0; |
@@ -706,7 +349,7 @@ struct dvb_frontend *tda8290_attach(struct dvb_frontend *fe, | |||
706 | behind the bridge and we choose the highest address that doesn't | 349 | behind the bridge and we choose the highest address that doesn't |
707 | give a response now | 350 | give a response now |
708 | */ | 351 | */ |
709 | tda8290_i2c_bridge(fe, 0); | 352 | tda8290_i2c_bridge(t, 0); |
710 | if(tuners_found > 1) | 353 | if(tuners_found > 1) |
711 | for (i = 0; i < tuners_found; i++) { | 354 | for (i = 0; i < tuners_found; i++) { |
712 | msg.addr = tuner_addrs & 0xff; | 355 | msg.addr = tuner_addrs & 0xff; |
@@ -727,42 +370,45 @@ struct dvb_frontend *tda8290_attach(struct dvb_frontend *fe, | |||
727 | priv->tda827x_addr = tuner_addrs; | 370 | priv->tda827x_addr = tuner_addrs; |
728 | msg.addr = tuner_addrs; | 371 | msg.addr = tuner_addrs; |
729 | 372 | ||
730 | tda8290_i2c_bridge(fe, 1); | 373 | tda8290_i2c_bridge(t, 1); |
374 | |||
731 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); | 375 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); |
732 | if( ret != 1) | 376 | if( ret != 1) |
733 | tuner_warn("TDA827x access failed!\n"); | 377 | tuner_warn("TDA827x access failed!\n"); |
734 | 378 | ||
735 | memcpy(&fe->ops.tuner_ops, &tda8290_tuner_ops, | ||
736 | sizeof(struct dvb_tuner_ops)); | ||
737 | |||
738 | if ((data & 0x3c) == 0) { | 379 | if ((data & 0x3c) == 0) { |
739 | strlcpy(fe->ops.tuner_ops.info.name, "tda8290+75", | 380 | strlcpy(t->i2c.name, "tda8290+75", sizeof(t->i2c.name)); |
740 | sizeof(fe->ops.tuner_ops.info.name)); | ||
741 | fe->ops.tuner_ops.info.frequency_min = 55000000; | ||
742 | fe->ops.tuner_ops.info.frequency_max = 860000000; | ||
743 | fe->ops.tuner_ops.info.frequency_step = 250000; | ||
744 | priv->tda827x_ver = 0; | 381 | priv->tda827x_ver = 0; |
745 | } else { | 382 | } else { |
746 | strlcpy(fe->ops.tuner_ops.info.name, "tda8290+75a", | 383 | strlcpy(t->i2c.name, "tda8290+75a", sizeof(t->i2c.name)); |
747 | sizeof(fe->ops.tuner_ops.info.name)); | ||
748 | fe->ops.tuner_ops.info.frequency_min = 44000000; | ||
749 | fe->ops.tuner_ops.info.frequency_max = 906000000; | ||
750 | fe->ops.tuner_ops.info.frequency_step = 62500; | ||
751 | priv->tda827x_ver = 2; | 384 | priv->tda827x_ver = 2; |
752 | } | 385 | } |
386 | tda827x_attach(&t->fe, priv->tda827x_addr, | ||
387 | priv->i2c_props.adap, &priv->cfg); | ||
388 | |||
389 | /* FIXME: tda827x module doesn't probe the tuner until | ||
390 | * tda827x_initial_sleep is called | ||
391 | */ | ||
392 | if (t->fe.ops.tuner_ops.sleep) | ||
393 | t->fe.ops.tuner_ops.sleep(&t->fe); | ||
753 | 394 | ||
754 | priv->tda827x_lpsel = 0; | 395 | memcpy(&t->ops, &tda8290_tuner_ops, sizeof(struct tuner_operations)); |
755 | 396 | ||
756 | tda8290_init_tuner(fe); | 397 | tuner_info("type set to %s\n", t->i2c.name); |
757 | tda8290_init_if(fe); | 398 | |
758 | return fe; | 399 | priv->cfg.tda827x_lpsel = 0; |
400 | t->mode = V4L2_TUNER_ANALOG_TV; | ||
401 | |||
402 | tda8290_init_tuner(t); | ||
403 | tda8290_init_if(t); | ||
404 | return 0; | ||
759 | } | 405 | } |
760 | 406 | ||
761 | int tda8290_probe(struct i2c_adapter* i2c_adap, u8 i2c_addr) | 407 | int tda8290_probe(struct tuner *t) |
762 | { | 408 | { |
763 | struct tuner_i2c_props i2c_props = { | 409 | struct tuner_i2c_props i2c_props = { |
764 | .adap = i2c_adap, | 410 | .adap = t->i2c.adapter, |
765 | .addr = i2c_addr | 411 | .addr = t->i2c.addr |
766 | }; | 412 | }; |
767 | 413 | ||
768 | unsigned char soft_reset[] = { 0x00, 0x00 }; | 414 | unsigned char soft_reset[] = { 0x00, 0x00 }; |
diff --git a/drivers/media/video/tda8290.h b/drivers/media/video/tda8290.h index 107b24b05aa1..9b63e62b3a0f 100644 --- a/drivers/media/video/tda8290.h +++ b/drivers/media/video/tda8290.h | |||
@@ -18,36 +18,24 @@ | |||
18 | #define __TDA8290_H__ | 18 | #define __TDA8290_H__ |
19 | 19 | ||
20 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
21 | #include "dvb_frontend.h" | 21 | #include "tuner-driver.h" |
22 | |||
23 | struct tda8290_config | ||
24 | { | ||
25 | unsigned int *lna_cfg; | ||
26 | int (*tuner_callback) (void *dev, int command,int arg); | ||
27 | }; | ||
28 | 22 | ||
29 | #if defined(CONFIG_TUNER_TDA8290) || (defined(CONFIG_TUNER_TDA8290_MODULE) && defined(MODULE)) | 23 | #if defined(CONFIG_TUNER_TDA8290) || (defined(CONFIG_TUNER_TDA8290_MODULE) && defined(MODULE)) |
30 | extern int tda8290_probe(struct i2c_adapter* i2c_adap, u8 i2c_addr); | 24 | extern int tda8290_probe(struct tuner *t); |
31 | 25 | ||
32 | extern struct dvb_frontend *tda8290_attach(struct dvb_frontend *fe, | 26 | extern int tda8290_attach(struct tuner *t); |
33 | struct i2c_adapter* i2c_adap, | ||
34 | u8 i2c_addr, | ||
35 | struct tda8290_config *cfg); | ||
36 | #else | 27 | #else |
37 | static inline int tda8290_probe(struct i2c_adapter* i2c_adap, u8 i2c_addr) | 28 | static inline int tda8290_probe(struct tuner *t) |
38 | { | 29 | { |
39 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", | 30 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); |
40 | __FUNCTION__); | ||
41 | return -EINVAL; | 31 | return -EINVAL; |
42 | } | 32 | } |
43 | 33 | ||
44 | static inline struct dvb_frontend *tda8290_attach(struct dvb_frontend *fe, | 34 | static inline int tda8290_attach(struct tuner *t) |
45 | struct i2c_adapter* i2c_adap, | ||
46 | u8 i2c_addr, | ||
47 | struct tda8290_config *cfg) | ||
48 | { | 35 | { |
49 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 36 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", |
50 | return NULL; | 37 | __FUNCTION__); |
38 | return -EINVAL; | ||
51 | } | 39 | } |
52 | #endif | 40 | #endif |
53 | 41 | ||
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 13112732ed2c..99558c708ae7 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -220,15 +220,6 @@ static void tuner_i2c_address_check(struct tuner *t) | |||
220 | tuner_warn("====================== WARNING! ======================\n"); | 220 | tuner_warn("====================== WARNING! ======================\n"); |
221 | } | 221 | } |
222 | 222 | ||
223 | static void attach_tda8290(struct tuner *t) | ||
224 | { | ||
225 | struct tda8290_config cfg = { | ||
226 | .lna_cfg = &t->config, | ||
227 | .tuner_callback = t->tuner_callback | ||
228 | }; | ||
229 | tda8290_attach(&t->fe, t->i2c.adapter, t->i2c.addr, &cfg); | ||
230 | } | ||
231 | |||
232 | static void attach_simple_tuner(struct tuner *t) | 223 | static void attach_simple_tuner(struct tuner *t) |
233 | { | 224 | { |
234 | struct simple_tuner_config cfg = { | 225 | struct simple_tuner_config cfg = { |
@@ -284,7 +275,7 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
284 | break; | 275 | break; |
285 | case TUNER_PHILIPS_TDA8290: | 276 | case TUNER_PHILIPS_TDA8290: |
286 | { | 277 | { |
287 | attach_tda8290(t); | 278 | tda8290_attach(t); |
288 | break; | 279 | break; |
289 | } | 280 | } |
290 | case TUNER_TEA5767: | 281 | case TUNER_TEA5767: |
@@ -343,7 +334,8 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
343 | break; | 334 | break; |
344 | } | 335 | } |
345 | 336 | ||
346 | if (fe_tuner_ops->set_analog_params) { | 337 | if ((fe_tuner_ops->set_analog_params) && |
338 | ((NULL == t->ops.set_tv_freq) && (NULL == t->ops.set_radio_freq))) { | ||
347 | strlcpy(t->i2c.name, fe_tuner_ops->info.name, sizeof(t->i2c.name)); | 339 | strlcpy(t->i2c.name, fe_tuner_ops->info.name, sizeof(t->i2c.name)); |
348 | 340 | ||
349 | t->ops.set_tv_freq = fe_set_freq; | 341 | t->ops.set_tv_freq = fe_set_freq; |
@@ -624,7 +616,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) | |||
624 | case 0x4b: | 616 | case 0x4b: |
625 | /* If chip is not tda8290, don't register. | 617 | /* If chip is not tda8290, don't register. |
626 | since it can be tda9887*/ | 618 | since it can be tda9887*/ |
627 | if (tda8290_probe(t->i2c.adapter, t->i2c.addr) == 0) { | 619 | if (tda8290_probe(t) == 0) { |
628 | tuner_dbg("chip at addr %x is a tda8290\n", addr); | 620 | tuner_dbg("chip at addr %x is a tda8290\n", addr); |
629 | } else { | 621 | } else { |
630 | /* Default is being tda9887 */ | 622 | /* Default is being tda9887 */ |