diff options
Diffstat (limited to 'drivers/media/video/cx88/cx88-alsa.c')
-rw-r--r-- | drivers/media/video/cx88/cx88-alsa.c | 99 |
1 files changed, 12 insertions, 87 deletions
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c index 4aaa47c0eabf..54b7fcd469a8 100644 --- a/drivers/media/video/cx88/cx88-alsa.c +++ b/drivers/media/video/cx88/cx88-alsa.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <sound/control.h> | 40 | #include <sound/control.h> |
41 | #include <sound/initval.h> | 41 | #include <sound/initval.h> |
42 | #include <sound/tlv.h> | 42 | #include <sound/tlv.h> |
43 | #include <media/wm8775.h> | ||
44 | 43 | ||
45 | #include "cx88.h" | 44 | #include "cx88.h" |
46 | #include "cx88-reg.h" | 45 | #include "cx88-reg.h" |
@@ -587,47 +586,26 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol, | |||
587 | int left, right, v, b; | 586 | int left, right, v, b; |
588 | int changed = 0; | 587 | int changed = 0; |
589 | u32 old; | 588 | u32 old; |
590 | struct v4l2_control client_ctl; | ||
591 | |||
592 | /* Pass volume & balance onto any WM8775 */ | ||
593 | if (value->value.integer.value[0] >= value->value.integer.value[1]) { | ||
594 | v = value->value.integer.value[0] << 10; | ||
595 | b = value->value.integer.value[0] ? | ||
596 | (0x8000 * value->value.integer.value[1]) / value->value.integer.value[0] : | ||
597 | 0x8000; | ||
598 | } else { | ||
599 | v = value->value.integer.value[1] << 10; | ||
600 | b = value->value.integer.value[1] ? | ||
601 | 0xffff - (0x8000 * value->value.integer.value[0]) / value->value.integer.value[1] : | ||
602 | 0x8000; | ||
603 | } | ||
604 | client_ctl.value = v; | ||
605 | client_ctl.id = V4L2_CID_AUDIO_VOLUME; | ||
606 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
607 | |||
608 | client_ctl.value = b; | ||
609 | client_ctl.id = V4L2_CID_AUDIO_BALANCE; | ||
610 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
611 | 589 | ||
612 | left = value->value.integer.value[0] & 0x3f; | 590 | left = value->value.integer.value[0] & 0x3f; |
613 | right = value->value.integer.value[1] & 0x3f; | 591 | right = value->value.integer.value[1] & 0x3f; |
614 | b = right - left; | 592 | b = right - left; |
615 | if (b < 0) { | 593 | if (b < 0) { |
616 | v = 0x3f - left; | 594 | v = 0x3f - left; |
617 | b = (-b) | 0x40; | 595 | b = (-b) | 0x40; |
618 | } else { | 596 | } else { |
619 | v = 0x3f - right; | 597 | v = 0x3f - right; |
620 | } | 598 | } |
621 | /* Do we really know this will always be called with IRQs on? */ | 599 | /* Do we really know this will always be called with IRQs on? */ |
622 | spin_lock_irq(&chip->reg_lock); | 600 | spin_lock_irq(&chip->reg_lock); |
623 | old = cx_read(AUD_VOL_CTL); | 601 | old = cx_read(AUD_VOL_CTL); |
624 | if (v != (old & 0x3f)) { | 602 | if (v != (old & 0x3f)) { |
625 | cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, (old & ~0x3f) | v); | 603 | cx_write(AUD_VOL_CTL, (old & ~0x3f) | v); |
626 | changed = 1; | 604 | changed = 1; |
627 | } | 605 | } |
628 | if ((cx_read(AUD_BAL_CTL) & 0x7f) != b) { | 606 | if (cx_read(AUD_BAL_CTL) != b) { |
629 | cx_write(AUD_BAL_CTL, b); | 607 | cx_write(AUD_BAL_CTL, b); |
630 | changed = 1; | 608 | changed = 1; |
631 | } | 609 | } |
632 | spin_unlock_irq(&chip->reg_lock); | 610 | spin_unlock_irq(&chip->reg_lock); |
633 | 611 | ||
@@ -640,7 +618,7 @@ static const struct snd_kcontrol_new snd_cx88_volume = { | |||
640 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 618 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
641 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | 619 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
642 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, | 620 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, |
643 | .name = "Analog-TV Volume", | 621 | .name = "Playback Volume", |
644 | .info = snd_cx88_volume_info, | 622 | .info = snd_cx88_volume_info, |
645 | .get = snd_cx88_volume_get, | 623 | .get = snd_cx88_volume_get, |
646 | .put = snd_cx88_volume_put, | 624 | .put = snd_cx88_volume_put, |
@@ -671,14 +649,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, | |||
671 | vol = cx_read(AUD_VOL_CTL); | 649 | vol = cx_read(AUD_VOL_CTL); |
672 | if (value->value.integer.value[0] != !(vol & bit)) { | 650 | if (value->value.integer.value[0] != !(vol & bit)) { |
673 | vol ^= bit; | 651 | vol ^= bit; |
674 | cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol); | 652 | cx_write(AUD_VOL_CTL, vol); |
675 | /* Pass mute onto any WM8775 */ | ||
676 | if ((1<<6) == bit) { | ||
677 | struct v4l2_control client_ctl; | ||
678 | client_ctl.value = 0 != (vol & bit); | ||
679 | client_ctl.id = V4L2_CID_AUDIO_MUTE; | ||
680 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
681 | } | ||
682 | ret = 1; | 653 | ret = 1; |
683 | } | 654 | } |
684 | spin_unlock_irq(&chip->reg_lock); | 655 | spin_unlock_irq(&chip->reg_lock); |
@@ -687,7 +658,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, | |||
687 | 658 | ||
688 | static const struct snd_kcontrol_new snd_cx88_dac_switch = { | 659 | static const struct snd_kcontrol_new snd_cx88_dac_switch = { |
689 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 660 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
690 | .name = "Audio-Out Switch", | 661 | .name = "Playback Switch", |
691 | .info = snd_ctl_boolean_mono_info, | 662 | .info = snd_ctl_boolean_mono_info, |
692 | .get = snd_cx88_switch_get, | 663 | .get = snd_cx88_switch_get, |
693 | .put = snd_cx88_switch_put, | 664 | .put = snd_cx88_switch_put, |
@@ -696,49 +667,13 @@ static const struct snd_kcontrol_new snd_cx88_dac_switch = { | |||
696 | 667 | ||
697 | static const struct snd_kcontrol_new snd_cx88_source_switch = { | 668 | static const struct snd_kcontrol_new snd_cx88_source_switch = { |
698 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 669 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
699 | .name = "Analog-TV Switch", | 670 | .name = "Capture Switch", |
700 | .info = snd_ctl_boolean_mono_info, | 671 | .info = snd_ctl_boolean_mono_info, |
701 | .get = snd_cx88_switch_get, | 672 | .get = snd_cx88_switch_get, |
702 | .put = snd_cx88_switch_put, | 673 | .put = snd_cx88_switch_put, |
703 | .private_value = (1<<6), | 674 | .private_value = (1<<6), |
704 | }; | 675 | }; |
705 | 676 | ||
706 | static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol, | ||
707 | struct snd_ctl_elem_value *value) | ||
708 | { | ||
709 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); | ||
710 | struct cx88_core *core = chip->core; | ||
711 | struct v4l2_control client_ctl; | ||
712 | |||
713 | client_ctl.id = V4L2_CID_AUDIO_LOUDNESS; | ||
714 | call_hw(core, WM8775_GID, core, g_ctrl, &client_ctl); | ||
715 | value->value.integer.value[0] = client_ctl.value ? 1 : 0; | ||
716 | |||
717 | return 0; | ||
718 | } | ||
719 | |||
720 | static int snd_cx88_alc_put(struct snd_kcontrol *kcontrol, | ||
721 | struct snd_ctl_elem_value *value) | ||
722 | { | ||
723 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); | ||
724 | struct cx88_core *core = chip->core; | ||
725 | struct v4l2_control client_ctl; | ||
726 | |||
727 | client_ctl.value = 0 != value->value.integer.value[0]; | ||
728 | client_ctl.id = V4L2_CID_AUDIO_LOUDNESS; | ||
729 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
730 | |||
731 | return 0; | ||
732 | } | ||
733 | |||
734 | static struct snd_kcontrol_new snd_cx88_alc_switch = { | ||
735 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
736 | .name = "Line-In ALC Switch", | ||
737 | .info = snd_ctl_boolean_mono_info, | ||
738 | .get = snd_cx88_alc_get, | ||
739 | .put = snd_cx88_alc_put, | ||
740 | }; | ||
741 | |||
742 | /**************************************************************************** | 677 | /**************************************************************************** |
743 | Basic Flow for Sound Devices | 678 | Basic Flow for Sound Devices |
744 | ****************************************************************************/ | 679 | ****************************************************************************/ |
@@ -860,7 +795,6 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci, | |||
860 | { | 795 | { |
861 | struct snd_card *card; | 796 | struct snd_card *card; |
862 | snd_cx88_card_t *chip; | 797 | snd_cx88_card_t *chip; |
863 | struct v4l2_subdev *sd; | ||
864 | int err; | 798 | int err; |
865 | 799 | ||
866 | if (devno >= SNDRV_CARDS) | 800 | if (devno >= SNDRV_CARDS) |
@@ -896,15 +830,6 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci, | |||
896 | if (err < 0) | 830 | if (err < 0) |
897 | goto error; | 831 | goto error; |
898 | 832 | ||
899 | /* If there's a wm8775 then add a Line-In ALC switch */ | ||
900 | list_for_each_entry(sd, &chip->core->v4l2_dev.subdevs, list) { | ||
901 | if (WM8775_GID == sd->grp_id) { | ||
902 | snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, | ||
903 | chip)); | ||
904 | break; | ||
905 | } | ||
906 | } | ||
907 | |||
908 | strcpy (card->driver, "CX88x"); | 833 | strcpy (card->driver, "CX88x"); |
909 | sprintf(card->shortname, "Conexant CX%x", pci->device); | 834 | sprintf(card->shortname, "Conexant CX%x", pci->device); |
910 | sprintf(card->longname, "%s at %#llx", | 835 | sprintf(card->longname, "%s at %#llx", |