aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 57b5a0a83c8d..0dbeeaf6113a 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -821,6 +821,51 @@ int snd_hda_mixer_amp_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
821} 821}
822 822
823/* 823/*
824 * bound volume controls
825 *
826 * bind multiple volumes (# indices, from 0)
827 */
828
829#define AMP_VAL_IDX_SHIFT 19
830#define AMP_VAL_IDX_MASK (0x0f<<19)
831
832int snd_hda_mixer_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
833{
834 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
835 unsigned long pval;
836 int err;
837
838 down(&codec->spdif_mutex); /* reuse spdif_mutex */
839 pval = kcontrol->private_value;
840 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
841 err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
842 kcontrol->private_value = pval;
843 up(&codec->spdif_mutex);
844 return err;
845}
846
847int snd_hda_mixer_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
848{
849 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
850 unsigned long pval;
851 int i, indices, err = 0, change = 0;
852
853 down(&codec->spdif_mutex); /* reuse spdif_mutex */
854 pval = kcontrol->private_value;
855 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
856 for (i = 0; i < indices; i++) {
857 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT);
858 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
859 if (err < 0)
860 break;
861 change |= err;
862 }
863 kcontrol->private_value = pval;
864 up(&codec->spdif_mutex);
865 return err < 0 ? err : change;
866}
867
868/*
824 * SPDIF out controls 869 * SPDIF out controls
825 */ 870 */
826 871