diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-24 10:20:12 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-28 18:22:46 -0500 |
commit | 32f6f3ac5468bbbe0263d29daa16f38d04c2274f (patch) | |
tree | 4407034928a0df429175387a77ad30c00089039a /drivers/media/video/tm6000 | |
parent | 75f064f220bde2fab9e932b27eee8372b65372c9 (diff) |
[media] tm6000: Fix tm6010 audio standard selection
A V4L2 standards mask may contain several standards. A more restricted
mask with just one standard is used when user needs to bind to an specific
standard that can't be auto-detect among a more generic mask.
So, Improve the autodetection logic to detect the correct audio standard
most of the time.
Based on a patch made by Dmitri Belimov <d.belimov@gmail.com>.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/tm6000')
-rw-r--r-- | drivers/media/video/tm6000/tm6000-core.c | 5 | ||||
-rw-r--r-- | drivers/media/video/tm6000/tm6000-stds.c | 89 |
2 files changed, 40 insertions, 54 deletions
diff --git a/drivers/media/video/tm6000/tm6000-core.c b/drivers/media/video/tm6000/tm6000-core.c index 9783616a0da2..55d097eaadd8 100644 --- a/drivers/media/video/tm6000/tm6000-core.c +++ b/drivers/media/video/tm6000/tm6000-core.c | |||
@@ -696,11 +696,13 @@ int tm6000_set_audio_rinput(struct tm6000_core *dev) | |||
696 | if (dev->dev_type == TM6010) { | 696 | if (dev->dev_type == TM6010) { |
697 | /* Audio crossbar setting, default SIF1 */ | 697 | /* Audio crossbar setting, default SIF1 */ |
698 | u8 areg_f0; | 698 | u8 areg_f0; |
699 | u8 areg_07 = 0x10; | ||
699 | 700 | ||
700 | switch (dev->rinput.amux) { | 701 | switch (dev->rinput.amux) { |
701 | case TM6000_AMUX_SIF1: | 702 | case TM6000_AMUX_SIF1: |
702 | case TM6000_AMUX_SIF2: | 703 | case TM6000_AMUX_SIF2: |
703 | areg_f0 = 0x03; | 704 | areg_f0 = 0x03; |
705 | areg_07 = 0x30; | ||
704 | break; | 706 | break; |
705 | case TM6000_AMUX_ADC1: | 707 | case TM6000_AMUX_ADC1: |
706 | areg_f0 = 0x00; | 708 | areg_f0 = 0x00; |
@@ -720,6 +722,9 @@ int tm6000_set_audio_rinput(struct tm6000_core *dev) | |||
720 | /* Set audio input crossbar */ | 722 | /* Set audio input crossbar */ |
721 | tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, | 723 | tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, |
722 | areg_f0, 0x0f); | 724 | areg_f0, 0x0f); |
725 | /* Mux overflow workaround */ | ||
726 | tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL, | ||
727 | areg_07, 0xf0); | ||
723 | } else { | 728 | } else { |
724 | u8 areg_eb; | 729 | u8 areg_eb; |
725 | /* Audio setting, default LINE1 */ | 730 | /* Audio setting, default LINE1 */ |
diff --git a/drivers/media/video/tm6000/tm6000-stds.c b/drivers/media/video/tm6000/tm6000-stds.c index 9a4145dc3d87..9dc0831d813f 100644 --- a/drivers/media/video/tm6000/tm6000-stds.c +++ b/drivers/media/video/tm6000/tm6000-stds.c | |||
@@ -361,82 +361,51 @@ static int tm6000_set_audio_std(struct tm6000_core *dev) | |||
361 | return 0; | 361 | return 0; |
362 | } | 362 | } |
363 | 363 | ||
364 | switch (tm6010_a_mode) { | 364 | /* |
365 | * STD/MN shouldn't be affected by tm6010_a_mode, as there's just one | ||
366 | * audio standard for each V4L2_STD type. | ||
367 | */ | ||
368 | if ((dev->norm & V4L2_STD_NTSC) == V4L2_STD_NTSC_M_KR) { | ||
369 | areg_05 |= 0x04; | ||
370 | } else if ((dev->norm & V4L2_STD_NTSC) == V4L2_STD_NTSC_M_JP) { | ||
371 | areg_05 |= 0x43; | ||
372 | } else if (dev->norm & V4L2_STD_MN) { | ||
373 | areg_05 |= 0x22; | ||
374 | } else switch (tm6010_a_mode) { | ||
365 | /* auto */ | 375 | /* auto */ |
366 | case 0: | 376 | case 0: |
367 | switch (dev->norm) { | 377 | if ((dev->norm & V4L2_STD_SECAM) == V4L2_STD_SECAM_L) |
368 | case V4L2_STD_NTSC_M_KR: | ||
369 | areg_05 |= 0x00; | 378 | areg_05 |= 0x00; |
370 | break; | 379 | else /* Other PAL/SECAM standards */ |
371 | case V4L2_STD_NTSC_M_JP: | ||
372 | areg_05 |= 0x40; | ||
373 | break; | ||
374 | case V4L2_STD_NTSC_M: | ||
375 | case V4L2_STD_PAL_M: | ||
376 | case V4L2_STD_PAL_N: | ||
377 | areg_05 |= 0x20; | ||
378 | break; | ||
379 | case V4L2_STD_PAL_Nc: | ||
380 | areg_05 |= 0x60; | ||
381 | break; | ||
382 | case V4L2_STD_SECAM_L: | ||
383 | areg_05 |= 0x00; | ||
384 | break; | ||
385 | case V4L2_STD_DK: | ||
386 | areg_05 |= 0x10; | 380 | areg_05 |= 0x10; |
387 | break; | ||
388 | } | ||
389 | break; | 381 | break; |
390 | /* A2 */ | 382 | /* A2 */ |
391 | case 1: | 383 | case 1: |
392 | switch (dev->norm) { | 384 | if (dev->norm & V4L2_STD_DK) |
393 | case V4L2_STD_B: | ||
394 | case V4L2_STD_GH: | ||
395 | areg_05 = 0x05; | ||
396 | break; | ||
397 | case V4L2_STD_DK: | ||
398 | areg_05 = 0x09; | 385 | areg_05 = 0x09; |
399 | break; | 386 | else |
400 | } | 387 | areg_05 = 0x05; |
401 | break; | 388 | break; |
402 | /* NICAM */ | 389 | /* NICAM */ |
403 | case 2: | 390 | case 2: |
404 | switch (dev->norm) { | 391 | if (dev->norm & V4L2_STD_DK) { |
405 | case V4L2_STD_B: | ||
406 | case V4L2_STD_GH: | ||
407 | areg_05 = 0x07; | ||
408 | break; | ||
409 | case V4L2_STD_DK: | ||
410 | areg_05 = 0x06; | 392 | areg_05 = 0x06; |
411 | break; | 393 | } else if (dev->norm & V4L2_STD_PAL_I) { |
412 | case V4L2_STD_PAL_I: | ||
413 | areg_05 = 0x08; | 394 | areg_05 = 0x08; |
414 | break; | 395 | } else if (dev->norm & V4L2_STD_SECAM_L) { |
415 | case V4L2_STD_SECAM_L: | ||
416 | areg_05 = 0x0a; | 396 | areg_05 = 0x0a; |
417 | areg_02 = 0x02; | 397 | areg_02 = 0x02; |
418 | break; | 398 | } else { |
399 | areg_05 = 0x07; | ||
419 | } | 400 | } |
420 | nicam_flag = 1; | 401 | nicam_flag = 1; |
421 | break; | 402 | break; |
422 | /* other */ | 403 | /* other */ |
423 | case 3: | 404 | case 3: |
424 | switch (dev->norm) { | 405 | if (dev->norm & V4L2_STD_DK) { |
425 | /* DK3_A2 */ | ||
426 | case V4L2_STD_DK: | ||
427 | areg_05 = 0x0b; | 406 | areg_05 = 0x0b; |
428 | break; | 407 | } else { |
429 | /* Korea */ | ||
430 | case V4L2_STD_NTSC_M_KR: | ||
431 | areg_05 = 0x04; | ||
432 | break; | ||
433 | /* EIAJ */ | ||
434 | case V4L2_STD_NTSC_M_JP: | ||
435 | areg_05 = 0x03; | ||
436 | break; | ||
437 | default: | ||
438 | areg_05 = 0x02; | 408 | areg_05 = 0x02; |
439 | break; | ||
440 | } | 409 | } |
441 | break; | 410 | break; |
442 | } | 411 | } |
@@ -557,10 +526,16 @@ int tm6000_set_standard(struct tm6000_core *dev) | |||
557 | case TM6000_AMUX_ADC1: | 526 | case TM6000_AMUX_ADC1: |
558 | tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, | 527 | tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, |
559 | 0x00, 0x0f); | 528 | 0x00, 0x0f); |
529 | /* Mux overflow workaround */ | ||
530 | tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL, | ||
531 | 0x10, 0xf0); | ||
560 | break; | 532 | break; |
561 | case TM6000_AMUX_ADC2: | 533 | case TM6000_AMUX_ADC2: |
562 | tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, | 534 | tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, |
563 | 0x08, 0x0f); | 535 | 0x08, 0x0f); |
536 | /* Mux overflow workaround */ | ||
537 | tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL, | ||
538 | 0x10, 0xf0); | ||
564 | break; | 539 | break; |
565 | case TM6000_AMUX_SIF1: | 540 | case TM6000_AMUX_SIF1: |
566 | reg_08_e2 |= 0x02; | 541 | reg_08_e2 |= 0x02; |
@@ -570,6 +545,9 @@ int tm6000_set_standard(struct tm6000_core *dev) | |||
570 | tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3); | 545 | tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3); |
571 | tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, | 546 | tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, |
572 | 0x02, 0x0f); | 547 | 0x02, 0x0f); |
548 | /* Mux overflow workaround */ | ||
549 | tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL, | ||
550 | 0x30, 0xf0); | ||
573 | break; | 551 | break; |
574 | case TM6000_AMUX_SIF2: | 552 | case TM6000_AMUX_SIF2: |
575 | reg_08_e2 |= 0x02; | 553 | reg_08_e2 |= 0x02; |
@@ -579,6 +557,9 @@ int tm6000_set_standard(struct tm6000_core *dev) | |||
579 | tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf7); | 557 | tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf7); |
580 | tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, | 558 | tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, |
581 | 0x02, 0x0f); | 559 | 0x02, 0x0f); |
560 | /* Mux overflow workaround */ | ||
561 | tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL, | ||
562 | 0x30, 0xf0); | ||
582 | break; | 563 | break; |
583 | default: | 564 | default: |
584 | break; | 565 | break; |