Commit ee6e365e authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Generalize EAPD inversion check in patch_analog.c

Add a flag to spec field so that the EAPD inversion can be checked
outside the relevant control callbacks.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d11f74c6
......@@ -72,7 +72,8 @@ struct ad198x_spec {
hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
unsigned int jack_present :1;
unsigned int inv_jack_detect:1;
unsigned int inv_jack_detect:1; /* inverted jack-detection */
unsigned int inv_eapd:1; /* inverted EAPD implementation */
#ifdef CONFIG_SND_HDA_POWER_SAVE
struct hda_loopback_check loopback;
......@@ -458,7 +459,7 @@ static struct hda_codec_ops ad198x_patch_ops = {
/*
* EAPD control
* the private value = nid | (invert << 8)
* the private value = nid
*/
#define ad198x_eapd_info snd_ctl_boolean_mono_info
......@@ -467,8 +468,7 @@ static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct ad198x_spec *spec = codec->spec;
int invert = (kcontrol->private_value >> 8) & 1;
if (invert)
if (spec->inv_eapd)
ucontrol->value.integer.value[0] = ! spec->cur_eapd;
else
ucontrol->value.integer.value[0] = spec->cur_eapd;
......@@ -480,11 +480,10 @@ static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct ad198x_spec *spec = codec->spec;
int invert = (kcontrol->private_value >> 8) & 1;
hda_nid_t nid = kcontrol->private_value & 0xff;
unsigned int eapd;
eapd = !!ucontrol->value.integer.value[0];
if (invert)
if (spec->inv_eapd)
eapd = !eapd;
if (eapd == spec->cur_eapd)
return 0;
......@@ -705,7 +704,7 @@ static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
.info = ad198x_eapd_info,
.get = ad198x_eapd_get,
.put = ad198x_eapd_put,
.private_value = 0x1b | (1 << 8), /* port-D, inversed */
.private_value = 0x1b, /* port-D */
},
{ } /* end */
};
......@@ -1074,6 +1073,7 @@ static int patch_ad1986a(struct hda_codec *codec)
spec->loopback.amplist = ad1986a_loopbacks;
#endif
spec->vmaster_nid = 0x1b;
spec->inv_eapd = 1; /* AD1986A has the inverted EAPD implementation */
codec->patch_ops = ad198x_patch_ops;
......@@ -2124,7 +2124,7 @@ static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
.info = ad198x_eapd_info,
.get = ad198x_eapd_get,
.put = ad198x_eapd_put,
.private_value = 0x12 | (1 << 8), /* port-D, inversed */
.private_value = 0x12, /* port-D */
},
{ } /* end */
......@@ -3065,6 +3065,7 @@ static int patch_ad1988(struct hda_codec *codec)
spec->input_mux = &ad1988_laptop_capture_source;
spec->num_mixers = 1;
spec->mixers[0] = ad1988_laptop_mixers;
spec->inv_eapd = 1; /* inverted EAPD */
spec->num_init_verbs = 1;
spec->init_verbs[0] = ad1988_laptop_init_verbs;
if (board_config == AD1988_LAPTOP_DIG)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment