diff options
author | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2005-07-12 16:58:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-12 19:01:06 -0400 |
commit | f7ce3cc67052de63a29bad90110640b687d12058 (patch) | |
tree | f3978eb08434d0e87b2467949bd22513c3535416 /drivers/media/video/tuner-simple.c | |
parent | ebe4c6fa535b0410e58e9c8352320896d07e2efb (diff) |
[PATCH] v4l: I2C Tuner
- Fixed a trouble on tuner-core that generates erros on computers with more
than one TV card.
- Rename tuner structures fields.
- Tail spaces removed.
- I2C cleanups and converged to a basic reference structure.
- Removed unused structures.
- Fix setting frequency on tda8290.
- Added code for TEA5767 autodetection.
- Standby mode support implemented. It is used to disable
a non used tuner. Currenlty implemented on tea5767.
- New macro: set_type disables other tuner when changing mode.
- Some cleanups.
- Use 50 kHz step when tunning radio for most tuners to improve precision.
Signed-off-by: Fabien Perrot <perrot1983@yahoo.fr>
Signed-off-by: Michael Krufky <mkrufky@m1k.net>
Signed-off-By: Nickolay V. Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/video/tuner-simple.c')
-rw-r--r-- | drivers/media/video/tuner-simple.c | 85 |
1 files changed, 36 insertions, 49 deletions
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index c39ed6226ee0..a3f8e83f5314 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: tuner-simple.c,v 1.31 2005/06/21 16:02:25 mkrufky Exp $ | 2 | * $Id: tuner-simple.c,v 1.39 2005/07/07 01:49:30 mkrufky Exp $ |
3 | * | 3 | * |
4 | * i2c tv tuner chip device driver | 4 | * i2c tv tuner chip device driver |
5 | * controls all those simple 4-control-bytes style tuners. | 5 | * controls all those simple 4-control-bytes style tuners. |
@@ -54,6 +54,27 @@ | |||
54 | #define PHILIPS_MF_SET_PAL_L 0x03 // France | 54 | #define PHILIPS_MF_SET_PAL_L 0x03 // France |
55 | #define PHILIPS_MF_SET_PAL_L2 0x02 // L' | 55 | #define PHILIPS_MF_SET_PAL_L2 0x02 // L' |
56 | 56 | ||
57 | /* Control byte */ | ||
58 | |||
59 | #define TUNER_RATIO_MASK 0x06 /* Bit cb1:cb2 */ | ||
60 | #define TUNER_RATIO_SELECT_50 0x00 | ||
61 | #define TUNER_RATIO_SELECT_32 0x02 | ||
62 | #define TUNER_RATIO_SELECT_166 0x04 | ||
63 | #define TUNER_RATIO_SELECT_62 0x06 | ||
64 | |||
65 | #define TUNER_CHARGE_PUMP 0x40 /* Bit cb6 */ | ||
66 | |||
67 | /* Status byte */ | ||
68 | |||
69 | #define TUNER_POR 0x80 | ||
70 | #define TUNER_FL 0x40 | ||
71 | #define TUNER_MODE 0x38 | ||
72 | #define TUNER_AFC 0x07 | ||
73 | #define TUNER_SIGNAL 0x07 | ||
74 | #define TUNER_STEREO 0x10 | ||
75 | |||
76 | #define TUNER_PLL_LOCKED 0x40 | ||
77 | #define TUNER_STEREO_MK3 0x04 | ||
57 | 78 | ||
58 | /* ---------------------------------------------------------------------- */ | 79 | /* ---------------------------------------------------------------------- */ |
59 | 80 | ||
@@ -211,21 +232,17 @@ static struct tunertype tuners[] = { | |||
211 | 16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 }, | 232 | 16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 }, |
212 | { "Philips FQ1236A MK4", Philips, NTSC, | 233 | { "Philips FQ1236A MK4", Philips, NTSC, |
213 | 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 }, | 234 | 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 }, |
214 | 235 | { "Ymec TVision TVF-8531MF/8831MF/8731MF", Philips, NTSC, | |
215 | /* Should work for TVF8531MF, TVF8831MF, TVF8731MF */ | ||
216 | { "Ymec TVision TVF-8531MF", Philips, NTSC, | ||
217 | 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732}, | 236 | 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732}, |
218 | { "Ymec TVision TVF-5533MF", Philips, NTSC, | 237 | { "Ymec TVision TVF-5533MF", Philips, NTSC, |
219 | 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732}, | 238 | 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732}, |
239 | |||
220 | { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC, | 240 | { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC, |
221 | 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, | 241 | 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, |
222 | /* Should work for TNF9533-D/IF, TNF9533-B/DF */ | 242 | { "Tena TNF9533-D/IF/TNF9533-B/DF", Philips, PAL, |
223 | { "Tena TNF9533-D/IF", Philips, PAL, | ||
224 | 16*160.25,16*464.25,0x01,0x02,0x04,0x8e,623}, | 243 | 16*160.25,16*464.25,0x01,0x02,0x04,0x8e,623}, |
225 | 244 | { "Philips TEA5767HN FM Radio", Philips, RADIO, | |
226 | /* This entry is for TEA5767 FM radio only chip used on several boards w/TV tuner */ | 245 | /* see tea5767.c for details */}, |
227 | { TEA5767_TUNER_NAME, Philips, RADIO, | ||
228 | -1, -1, 0, 0, 0, TEA5767_LOW_LO_32768,0}, | ||
229 | { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL, | 246 | { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL, |
230 | 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 }, | 247 | 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 }, |
231 | }; | 248 | }; |
@@ -244,15 +261,6 @@ static int tuner_getstatus(struct i2c_client *c) | |||
244 | return byte; | 261 | return byte; |
245 | } | 262 | } |
246 | 263 | ||
247 | #define TUNER_POR 0x80 | ||
248 | #define TUNER_FL 0x40 | ||
249 | #define TUNER_MODE 0x38 | ||
250 | #define TUNER_AFC 0x07 | ||
251 | |||
252 | #define TUNER_STEREO 0x10 /* radio mode */ | ||
253 | #define TUNER_STEREO_MK3 0x04 /* radio mode */ | ||
254 | #define TUNER_SIGNAL 0x07 /* radio mode */ | ||
255 | |||
256 | static int tuner_signal(struct i2c_client *c) | 264 | static int tuner_signal(struct i2c_client *c) |
257 | { | 265 | { |
258 | return (tuner_getstatus(c) & TUNER_SIGNAL) << 13; | 266 | return (tuner_getstatus(c) & TUNER_SIGNAL) << 13; |
@@ -278,22 +286,6 @@ static int tuner_stereo(struct i2c_client *c) | |||
278 | return stereo; | 286 | return stereo; |
279 | } | 287 | } |
280 | 288 | ||
281 | #if 0 /* unused */ | ||
282 | static int tuner_islocked (struct i2c_client *c) | ||
283 | { | ||
284 | return (tuner_getstatus (c) & TUNER_FL); | ||
285 | } | ||
286 | |||
287 | static int tuner_afcstatus (struct i2c_client *c) | ||
288 | { | ||
289 | return (tuner_getstatus (c) & TUNER_AFC) - 2; | ||
290 | } | ||
291 | |||
292 | static int tuner_mode (struct i2c_client *c) | ||
293 | { | ||
294 | return (tuner_getstatus (c) & TUNER_MODE) >> 3; | ||
295 | } | ||
296 | #endif | ||
297 | 289 | ||
298 | /* ---------------------------------------------------------------------- */ | 290 | /* ---------------------------------------------------------------------- */ |
299 | 291 | ||
@@ -376,7 +368,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
376 | 368 | ||
377 | case TUNER_MICROTUNE_4042FI5: | 369 | case TUNER_MICROTUNE_4042FI5: |
378 | /* Set the charge pump for fast tuning */ | 370 | /* Set the charge pump for fast tuning */ |
379 | tun->config |= 0x40; | 371 | tun->config |= TUNER_CHARGE_PUMP; |
380 | break; | 372 | break; |
381 | } | 373 | } |
382 | 374 | ||
@@ -425,14 +417,13 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
425 | tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc); | 417 | tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc); |
426 | break; | 418 | break; |
427 | } | 419 | } |
428 | /* bit 6 is PLL locked indicator */ | 420 | if (status_byte & TUNER_PLL_LOCKED) |
429 | if (status_byte & 0x40) | ||
430 | break; | 421 | break; |
431 | udelay(10); | 422 | udelay(10); |
432 | } | 423 | } |
433 | 424 | ||
434 | /* Set the charge pump for optimized phase noise figure */ | 425 | /* Set the charge pump for optimized phase noise figure */ |
435 | tun->config &= ~0x40; | 426 | tun->config &= ~TUNER_CHARGE_PUMP; |
436 | buffer[0] = (div>>8) & 0x7f; | 427 | buffer[0] = (div>>8) & 0x7f; |
437 | buffer[1] = div & 0xff; | 428 | buffer[1] = div & 0xff; |
438 | buffer[2] = tun->config; | 429 | buffer[2] = tun->config; |
@@ -453,26 +444,22 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) | |||
453 | unsigned div; | 444 | unsigned div; |
454 | int rc; | 445 | int rc; |
455 | 446 | ||
456 | tun=&tuners[t->type]; | 447 | tun = &tuners[t->type]; |
457 | div = (freq / 1000) + (int)(16*10.7); | 448 | div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */ |
458 | buffer[2] = tun->config; | 449 | buffer[2] = (tun->config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */ |
459 | 450 | ||
460 | switch (t->type) { | 451 | switch (t->type) { |
461 | case TUNER_TENA_9533_DI: | 452 | case TUNER_TENA_9533_DI: |
462 | case TUNER_YMEC_TVF_5533MF: | 453 | case TUNER_YMEC_TVF_5533MF: |
463 | /*These values are empirically determinated */ | 454 | tuner_dbg ("This tuner doesn't have FM. Most cards has a TEA5767 for FM\n"); |
464 | div = (freq * 122) / 16000 - 20; | 455 | return; |
465 | buffer[2] = 0x88; /* could be also 0x80 */ | ||
466 | buffer[3] = 0x19; /* could be also 0x10, 0x18, 0x99 */ | ||
467 | break; | ||
468 | case TUNER_PHILIPS_FM1216ME_MK3: | 456 | case TUNER_PHILIPS_FM1216ME_MK3: |
469 | case TUNER_PHILIPS_FM1236_MK3: | 457 | case TUNER_PHILIPS_FM1236_MK3: |
470 | case TUNER_PHILIPS_FMD1216ME_MK3: | 458 | case TUNER_PHILIPS_FMD1216ME_MK3: |
471 | buffer[3] = 0x19; | 459 | buffer[3] = 0x19; |
472 | break; | 460 | break; |
473 | case TUNER_PHILIPS_FM1256_IH3: | 461 | case TUNER_PHILIPS_FM1256_IH3: |
474 | div = (20 * freq) / 16000 + 333 * 2; | 462 | div = (20 * freq) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */ |
475 | buffer[2] = 0x80; | ||
476 | buffer[3] = 0x19; | 463 | buffer[3] = 0x19; |
477 | break; | 464 | break; |
478 | case TUNER_LG_PAL_FM: | 465 | case TUNER_LG_PAL_FM: |