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: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2009-12-08 17:23:33 +01:00
parent d11f74c62f
commit ee6e365e30
1 changed files with 9 additions and 8 deletions

View File

@ -72,7 +72,8 @@ struct ad198x_spec {
hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
unsigned int jack_present :1; 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 #ifdef CONFIG_SND_HDA_POWER_SAVE
struct hda_loopback_check loopback; struct hda_loopback_check loopback;
@ -458,7 +459,7 @@ static struct hda_codec_ops ad198x_patch_ops = {
/* /*
* EAPD control * EAPD control
* the private value = nid | (invert << 8) * the private value = nid
*/ */
#define ad198x_eapd_info snd_ctl_boolean_mono_info #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 hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct ad198x_spec *spec = codec->spec; struct ad198x_spec *spec = codec->spec;
int invert = (kcontrol->private_value >> 8) & 1; if (spec->inv_eapd)
if (invert)
ucontrol->value.integer.value[0] = ! spec->cur_eapd; ucontrol->value.integer.value[0] = ! spec->cur_eapd;
else else
ucontrol->value.integer.value[0] = spec->cur_eapd; 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 hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct ad198x_spec *spec = codec->spec; struct ad198x_spec *spec = codec->spec;
int invert = (kcontrol->private_value >> 8) & 1;
hda_nid_t nid = kcontrol->private_value & 0xff; hda_nid_t nid = kcontrol->private_value & 0xff;
unsigned int eapd; unsigned int eapd;
eapd = !!ucontrol->value.integer.value[0]; eapd = !!ucontrol->value.integer.value[0];
if (invert) if (spec->inv_eapd)
eapd = !eapd; eapd = !eapd;
if (eapd == spec->cur_eapd) if (eapd == spec->cur_eapd)
return 0; return 0;
@ -705,7 +704,7 @@ static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
.info = ad198x_eapd_info, .info = ad198x_eapd_info,
.get = ad198x_eapd_get, .get = ad198x_eapd_get,
.put = ad198x_eapd_put, .put = ad198x_eapd_put,
.private_value = 0x1b | (1 << 8), /* port-D, inversed */ .private_value = 0x1b, /* port-D */
}, },
{ } /* end */ { } /* end */
}; };
@ -1074,6 +1073,7 @@ static int patch_ad1986a(struct hda_codec *codec)
spec->loopback.amplist = ad1986a_loopbacks; spec->loopback.amplist = ad1986a_loopbacks;
#endif #endif
spec->vmaster_nid = 0x1b; spec->vmaster_nid = 0x1b;
spec->inv_eapd = 1; /* AD1986A has the inverted EAPD implementation */
codec->patch_ops = ad198x_patch_ops; codec->patch_ops = ad198x_patch_ops;
@ -2124,7 +2124,7 @@ static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
.info = ad198x_eapd_info, .info = ad198x_eapd_info,
.get = ad198x_eapd_get, .get = ad198x_eapd_get,
.put = ad198x_eapd_put, .put = ad198x_eapd_put,
.private_value = 0x12 | (1 << 8), /* port-D, inversed */ .private_value = 0x12, /* port-D */
}, },
{ } /* end */ { } /* end */
@ -3065,6 +3065,7 @@ static int patch_ad1988(struct hda_codec *codec)
spec->input_mux = &ad1988_laptop_capture_source; spec->input_mux = &ad1988_laptop_capture_source;
spec->num_mixers = 1; spec->num_mixers = 1;
spec->mixers[0] = ad1988_laptop_mixers; spec->mixers[0] = ad1988_laptop_mixers;
spec->inv_eapd = 1; /* inverted EAPD */
spec->num_init_verbs = 1; spec->num_init_verbs = 1;
spec->init_verbs[0] = ad1988_laptop_init_verbs; spec->init_verbs[0] = ad1988_laptop_init_verbs;
if (board_config == AD1988_LAPTOP_DIG) if (board_config == AD1988_LAPTOP_DIG)