diff options
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-tvaudio.c')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-tvaudio.c | 121 |
1 files changed, 55 insertions, 66 deletions
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index 3617e7f7a410..eeafa5a71d2b 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: saa7134-tvaudio.c,v 1.25 2005/06/07 19:00:38 nsh Exp $ | 2 | * $Id: saa7134-tvaudio.c,v 1.30 2005/06/28 23:41:47 mkrufky Exp $ |
3 | * | 3 | * |
4 | * device driver for philips saa7134 based TV cards | 4 | * device driver for philips saa7134 based TV cards |
5 | * tv audio decoder (fm stereo, nicam, ...) | 5 | * tv audio decoder (fm stereo, nicam, ...) |
@@ -169,7 +169,7 @@ static void tvaudio_init(struct saa7134_dev *dev) | |||
169 | int clock = saa7134_boards[dev->board].audio_clock; | 169 | int clock = saa7134_boards[dev->board].audio_clock; |
170 | 170 | ||
171 | if (UNSET != audio_clock_override) | 171 | if (UNSET != audio_clock_override) |
172 | clock = audio_clock_override; | 172 | clock = audio_clock_override; |
173 | 173 | ||
174 | /* init all audio registers */ | 174 | /* init all audio registers */ |
175 | saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x00); | 175 | saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x00); |
@@ -219,14 +219,17 @@ static void mute_input_7134(struct saa7134_dev *dev) | |||
219 | in = dev->input; | 219 | in = dev->input; |
220 | mute = (dev->ctl_mute || | 220 | mute = (dev->ctl_mute || |
221 | (dev->automute && (&card(dev).radio) != in)); | 221 | (dev->automute && (&card(dev).radio) != in)); |
222 | if (PCI_DEVICE_ID_PHILIPS_SAA7130 == dev->pci->device && | 222 | if (card(dev).mute.name) { |
223 | card(dev).mute.name) { | 223 | /* |
224 | /* 7130 - we'll mute using some unconnected audio input */ | 224 | * 7130 - we'll mute using some unconnected audio input |
225 | * 7134 - we'll probably should switch external mux with gpio | ||
226 | */ | ||
225 | if (mute) | 227 | if (mute) |
226 | in = &card(dev).mute; | 228 | in = &card(dev).mute; |
227 | } | 229 | } |
230 | |||
228 | if (dev->hw_mute == mute && | 231 | if (dev->hw_mute == mute && |
229 | dev->hw_input == in) { | 232 | dev->hw_input == in) { |
230 | dprintk("mute/input: nothing to do [mute=%d,input=%s]\n", | 233 | dprintk("mute/input: nothing to do [mute=%d,input=%s]\n", |
231 | mute,in->name); | 234 | mute,in->name); |
232 | return; | 235 | return; |
@@ -260,6 +263,7 @@ static void mute_input_7134(struct saa7134_dev *dev) | |||
260 | /* switch gpio-connected external audio mux */ | 263 | /* switch gpio-connected external audio mux */ |
261 | if (0 == card(dev).gpiomask) | 264 | if (0 == card(dev).gpiomask) |
262 | return; | 265 | return; |
266 | |||
263 | mask = card(dev).gpiomask; | 267 | mask = card(dev).gpiomask; |
264 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); | 268 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); |
265 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio); | 269 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio); |
@@ -339,13 +343,8 @@ static int tvaudio_sleep(struct saa7134_dev *dev, int timeout) | |||
339 | set_current_state(TASK_INTERRUPTIBLE); | 343 | set_current_state(TASK_INTERRUPTIBLE); |
340 | schedule(); | 344 | schedule(); |
341 | } else { | 345 | } else { |
342 | #if 0 | ||
343 | /* hmm, that one doesn't return on wakeup ... */ | ||
344 | msleep_interruptible(timeout); | ||
345 | #else | ||
346 | set_current_state(TASK_INTERRUPTIBLE); | 346 | set_current_state(TASK_INTERRUPTIBLE); |
347 | schedule_timeout(msecs_to_jiffies(timeout)); | 347 | schedule_timeout(msecs_to_jiffies(timeout)); |
348 | #endif | ||
349 | } | 348 | } |
350 | } | 349 | } |
351 | remove_wait_queue(&dev->thread.wq, &wait); | 350 | remove_wait_queue(&dev->thread.wq, &wait); |
@@ -400,27 +399,10 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan) | |||
400 | return value; | 399 | return value; |
401 | } | 400 | } |
402 | 401 | ||
403 | #if 0 | ||
404 | static void sifdebug_dump_regs(struct saa7134_dev *dev) | ||
405 | { | ||
406 | print_regb(AUDIO_STATUS); | ||
407 | print_regb(IDENT_SIF); | ||
408 | print_regb(LEVEL_READOUT1); | ||
409 | print_regb(LEVEL_READOUT2); | ||
410 | print_regb(DCXO_IDENT_CTRL); | ||
411 | print_regb(DEMODULATOR); | ||
412 | print_regb(AGC_GAIN_SELECT); | ||
413 | print_regb(MONITOR_SELECT); | ||
414 | print_regb(FM_DEEMPHASIS); | ||
415 | print_regb(FM_DEMATRIX); | ||
416 | print_regb(SIF_SAMPLE_FREQ); | ||
417 | print_regb(ANALOG_IO_SELECT); | ||
418 | } | ||
419 | #endif | ||
420 | 402 | ||
421 | static int tvaudio_getstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *audio) | 403 | static int tvaudio_getstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *audio) |
422 | { | 404 | { |
423 | __u32 idp,nicam; | 405 | __u32 idp, nicam, nicam_status; |
424 | int retval = -1; | 406 | int retval = -1; |
425 | 407 | ||
426 | switch (audio->mode) { | 408 | switch (audio->mode) { |
@@ -442,18 +424,24 @@ static int tvaudio_getstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *au | |||
442 | break; | 424 | break; |
443 | case TVAUDIO_NICAM_FM: | 425 | case TVAUDIO_NICAM_FM: |
444 | case TVAUDIO_NICAM_AM: | 426 | case TVAUDIO_NICAM_AM: |
445 | nicam = saa_readb(SAA7134_NICAM_STATUS); | 427 | nicam = saa_readb(SAA7134_AUDIO_STATUS); |
446 | dprintk("getstereo: nicam=0x%x\n",nicam); | 428 | dprintk("getstereo: nicam=0x%x\n",nicam); |
447 | switch (nicam & 0x0b) { | 429 | if (nicam & 0x1) { |
448 | case 0x08: | 430 | nicam_status = saa_readb(SAA7134_NICAM_STATUS); |
449 | retval = V4L2_TUNER_SUB_MONO; | 431 | dprintk("getstereo: nicam_status=0x%x\n", nicam_status); |
450 | break; | 432 | |
451 | case 0x09: | 433 | switch (nicam_status & 0x03) { |
452 | retval = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; | 434 | case 0x01: |
453 | break; | 435 | retval = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; |
454 | case 0x0a: | 436 | break; |
455 | retval = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; | 437 | case 0x02: |
456 | break; | 438 | retval = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; |
439 | break; | ||
440 | default: | ||
441 | retval = V4L2_TUNER_SUB_MONO; | ||
442 | } | ||
443 | } else { | ||
444 | /* No nicam detected */ | ||
457 | } | 445 | } |
458 | break; | 446 | break; |
459 | } | 447 | } |
@@ -489,15 +477,15 @@ static int tvaudio_setstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *au | |||
489 | break; | 477 | break; |
490 | case TVAUDIO_FM_K_STEREO: | 478 | case TVAUDIO_FM_K_STEREO: |
491 | case TVAUDIO_FM_BG_STEREO: | 479 | case TVAUDIO_FM_BG_STEREO: |
480 | case TVAUDIO_NICAM_AM: | ||
481 | case TVAUDIO_NICAM_FM: | ||
492 | dprintk("setstereo [fm] => %s\n", | 482 | dprintk("setstereo [fm] => %s\n", |
493 | name[ mode % ARRAY_SIZE(name) ]); | 483 | name[ mode % ARRAY_SIZE(name) ]); |
494 | reg = fm[ mode % ARRAY_SIZE(fm) ]; | 484 | reg = fm[ mode % ARRAY_SIZE(fm) ]; |
495 | saa_writeb(SAA7134_FM_DEMATRIX, reg); | 485 | saa_writeb(SAA7134_FM_DEMATRIX, reg); |
496 | break; | 486 | break; |
497 | case TVAUDIO_FM_SAT_STEREO: | 487 | case TVAUDIO_FM_SAT_STEREO: |
498 | case TVAUDIO_NICAM_AM: | 488 | /* Not implemented */ |
499 | case TVAUDIO_NICAM_FM: | ||
500 | /* FIXME */ | ||
501 | break; | 489 | break; |
502 | } | 490 | } |
503 | return 0; | 491 | return 0; |
@@ -596,7 +584,7 @@ static int tvaudio_thread(void *data) | |||
596 | /* find the exact tv audio norm */ | 584 | /* find the exact tv audio norm */ |
597 | for (audio = UNSET, i = 0; i < TVAUDIO; i++) { | 585 | for (audio = UNSET, i = 0; i < TVAUDIO; i++) { |
598 | if (dev->tvnorm->id != UNSET && | 586 | if (dev->tvnorm->id != UNSET && |
599 | !(dev->tvnorm->id & tvaudio[i].std)) | 587 | !(dev->tvnorm->id & tvaudio[i].std)) |
600 | continue; | 588 | continue; |
601 | if (tvaudio[i].carr1 != carrier) | 589 | if (tvaudio[i].carr1 != carrier) |
602 | continue; | 590 | continue; |
@@ -703,24 +691,6 @@ static inline int saa_dsp_wait_bit(struct saa7134_dev *dev, int bit) | |||
703 | return 0; | 691 | return 0; |
704 | } | 692 | } |
705 | 693 | ||
706 | #if 0 | ||
707 | static int saa_dsp_readl(struct saa7134_dev *dev, int reg, u32 *value) | ||
708 | { | ||
709 | int err; | ||
710 | |||
711 | d2printk("dsp read reg 0x%x\n", reg<<2); | ||
712 | saa_readl(reg); | ||
713 | err = saa_dsp_wait_bit(dev,SAA7135_DSP_RWSTATE_RDB); | ||
714 | if (err < 0) | ||
715 | return err; | ||
716 | *value = saa_readl(reg); | ||
717 | d2printk("dsp read => 0x%06x\n", *value & 0xffffff); | ||
718 | err = saa_dsp_wait_bit(dev,SAA7135_DSP_RWSTATE_IDA); | ||
719 | if (err < 0) | ||
720 | return err; | ||
721 | return 0; | ||
722 | } | ||
723 | #endif | ||
724 | 694 | ||
725 | int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value) | 695 | int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value) |
726 | { | 696 | { |
@@ -753,31 +723,50 @@ static int getstereo_7133(struct saa7134_dev *dev) | |||
753 | static int mute_input_7133(struct saa7134_dev *dev) | 723 | static int mute_input_7133(struct saa7134_dev *dev) |
754 | { | 724 | { |
755 | u32 reg = 0; | 725 | u32 reg = 0; |
726 | u32 xbarin, xbarout; | ||
756 | int mask; | 727 | int mask; |
728 | struct saa7134_input *in; | ||
757 | 729 | ||
730 | /* Hac 0506 route OSS sound simultanously */ | ||
731 | xbarin = 0x03; | ||
758 | switch (dev->input->amux) { | 732 | switch (dev->input->amux) { |
759 | case TV: | 733 | case TV: |
760 | reg = 0x02; | 734 | reg = 0x02; |
735 | xbarin = 0; | ||
761 | break; | 736 | break; |
762 | case LINE1: | 737 | case LINE1: |
763 | reg = 0x00; | 738 | reg = 0x00; |
764 | break; | 739 | break; |
765 | case LINE2: | 740 | case LINE2: |
766 | case LINE2_LEFT: | 741 | case LINE2_LEFT: |
767 | reg = 0x01; | 742 | reg = 0x09; |
768 | break; | 743 | break; |
769 | } | 744 | } |
770 | if (dev->ctl_mute) | 745 | saa_dsp_writel(dev, 0x464 >> 2, xbarin); |
746 | if (dev->ctl_mute) { | ||
771 | reg = 0x07; | 747 | reg = 0x07; |
748 | xbarout = 0xbbbbbb; | ||
749 | } else | ||
750 | xbarout = 0xbbbb10; | ||
751 | saa_dsp_writel(dev, 0x46c >> 2, xbarout); | ||
752 | |||
772 | saa_writel(0x594 >> 2, reg); | 753 | saa_writel(0x594 >> 2, reg); |
773 | 754 | ||
755 | |||
774 | /* switch gpio-connected external audio mux */ | 756 | /* switch gpio-connected external audio mux */ |
775 | if (0 != card(dev).gpiomask) { | 757 | if (0 != card(dev).gpiomask) { |
776 | mask = card(dev).gpiomask; | 758 | mask = card(dev).gpiomask; |
759 | |||
760 | if (card(dev).mute.name && dev->ctl_mute) | ||
761 | in = &card(dev).mute; | ||
762 | else | ||
763 | in = dev->input; | ||
764 | |||
777 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); | 765 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); |
778 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, dev->input->gpio); | 766 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio); |
779 | saa7134_track_gpio(dev,dev->input->name); | 767 | saa7134_track_gpio(dev,in->name); |
780 | } | 768 | } |
769 | |||
781 | return 0; | 770 | return 0; |
782 | } | 771 | } |
783 | 772 | ||