Skip to content

Commit

Permalink
ALSA: hda - Generalize EAPD inversion check in patch_analog.c
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Takashi Iwai committed Dec 8, 2009
1 parent d11f74c commit ee6e365
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions sound/pci/hda/patch_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 */
};
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ee6e365

Please sign in to comment.