summaryrefslogtreecommitdiff
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-08-10 17:11:07 +0200
committerJaroslav Kysela <perex@perex.cz>2007-10-16 15:58:43 +0200
commit47fd830acf0b6b5bc75db55d0f2cc64f59a23b5f (patch)
tree920b7e2cdce7120ff96417d74b911c3d5b95c21b /sound/pci/hda/hda_codec.c
parent82beb8fd365afe3891b277c46425083f13e23c56 (diff)
[ALSA] hda-codec - add snd_hda_codec_stereo() function
Added snd_hda_codec_amp_stereo() function that changes both of stereo channels with the same mask and value bits. It simplifies most of amp-handling codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 1d31da47bc9b..043529308676 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -842,6 +842,19 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
return 1;
}
+/*
+ * update the AMP stereo with the same mask and value
+ */
+int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
+ int direction, int idx, int mask, int val)
+{
+ int ch, ret = 0;
+ for (ch = 0; ch < 2; ch++)
+ ret |= snd_hda_codec_amp_update(codec, nid, ch, direction,
+ idx, mask, val);
+ return ret;
+}
+
#ifdef CONFIG_PM
/* resume the all amp commands from the cache */
void snd_hda_codec_resume_amp(struct hda_codec *codec)
@@ -913,9 +926,11 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
long *valp = ucontrol->value.integer.value;
if (chs & 1)
- *valp++ = snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x7f;
+ *valp++ = snd_hda_codec_amp_read(codec, nid, 0, dir, idx)
+ & HDA_AMP_VOLMASK;
if (chs & 2)
- *valp = snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x7f;
+ *valp = snd_hda_codec_amp_read(codec, nid, 1, dir, idx)
+ & HDA_AMP_VOLMASK;
return 0;
}
@@ -992,10 +1007,10 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
if (chs & 1)
*valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) &
- 0x80) ? 0 : 1;
+ HDA_AMP_MUTE) ? 0 : 1;
if (chs & 2)
*valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) &
- 0x80) ? 0 : 1;
+ HDA_AMP_MUTE) ? 0 : 1;
return 0;
}
@@ -1012,12 +1027,14 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
if (chs & 1) {
change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
- 0x80, *valp ? 0 : 0x80);
+ HDA_AMP_MUTE,
+ *valp ? 0 : HDA_AMP_MUTE);
valp++;
}
if (chs & 2)
change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx,
- 0x80, *valp ? 0 : 0x80);
+ HDA_AMP_MUTE,
+ *valp ? 0 : HDA_AMP_MUTE);
return change;
}
@@ -1318,12 +1335,9 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,
val & 0xff);
/* unmute amp switch (if any) */
if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
- (val & AC_DIG1_ENABLE)) {
- snd_hda_codec_amp_update(codec, nid, 0, HDA_OUTPUT, 0,
- 0x80, 0x00);
- snd_hda_codec_amp_update(codec, nid, 1, HDA_OUTPUT, 0,
- 0x80, 0x00);
- }
+ (val & AC_DIG1_ENABLE))
+ snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
+ HDA_AMP_MUTE, 0);
}
mutex_unlock(&codec->spdif_mutex);
return change;