[ALSA] hda-codec - Minor rewrites
Modules: HDA Codec driver,HDA generic driver - Make bound controls global to all patches - Clean up analog patches (for the upcoming extension to AD1988) Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
committed by
Jaroslav Kysela
parent
b7027cc29e
commit
985be54ba8
@@ -820,6 +820,51 @@ int snd_hda_mixer_amp_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
|
||||
return change;
|
||||
}
|
||||
|
||||
/*
|
||||
* bound volume controls
|
||||
*
|
||||
* bind multiple volumes (# indices, from 0)
|
||||
*/
|
||||
|
||||
#define AMP_VAL_IDX_SHIFT 19
|
||||
#define AMP_VAL_IDX_MASK (0x0f<<19)
|
||||
|
||||
int snd_hda_mixer_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
|
||||
{
|
||||
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
||||
unsigned long pval;
|
||||
int err;
|
||||
|
||||
down(&codec->spdif_mutex); /* reuse spdif_mutex */
|
||||
pval = kcontrol->private_value;
|
||||
kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
|
||||
err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
|
||||
kcontrol->private_value = pval;
|
||||
up(&codec->spdif_mutex);
|
||||
return err;
|
||||
}
|
||||
|
||||
int snd_hda_mixer_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
|
||||
{
|
||||
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
||||
unsigned long pval;
|
||||
int i, indices, err = 0, change = 0;
|
||||
|
||||
down(&codec->spdif_mutex); /* reuse spdif_mutex */
|
||||
pval = kcontrol->private_value;
|
||||
indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
|
||||
for (i = 0; i < indices; i++) {
|
||||
kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT);
|
||||
err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
|
||||
if (err < 0)
|
||||
break;
|
||||
change |= err;
|
||||
}
|
||||
kcontrol->private_value = pval;
|
||||
up(&codec->spdif_mutex);
|
||||
return err < 0 ? err : change;
|
||||
}
|
||||
|
||||
/*
|
||||
* SPDIF out controls
|
||||
*/
|
||||
|
Reference in New Issue
Block a user