Skip to content

Commit

Permalink
ALSA: hda - make Cirrus codec use generic unsol event handler
Browse files Browse the repository at this point in the history
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
David Henningsson authored and Takashi Iwai committed Oct 8, 2012
1 parent 4e2d16d commit 5c2e4e0
Showing 1 changed file with 10 additions and 38 deletions.
48 changes: 10 additions & 38 deletions sound/pci/hda/patch_cirrus.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ static int build_digital_input(struct hda_codec *codec)
* HP/SPK/SPDIF
*/

static void cs_automute(struct hda_codec *codec)
static void cs_automute(struct hda_codec *codec, struct hda_jack_tbl *tbl)
{
struct cs_spec *spec = codec->spec;
struct auto_pin_cfg *cfg = &spec->autocfg;
Expand Down Expand Up @@ -973,7 +973,7 @@ static void cs_automute(struct hda_codec *codec)
* Switch max 3 inputs of a single ADC (nid 3)
*/

static void cs_automic(struct hda_codec *codec)
static void cs_automic(struct hda_codec *codec, struct hda_jack_tbl *tbl)
{
struct cs_spec *spec = codec->spec;
struct auto_pin_cfg *cfg = &spec->autocfg;
Expand Down Expand Up @@ -1035,7 +1035,7 @@ static void init_output(struct hda_codec *codec)
if (!cfg->speaker_outs)
continue;
if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
snd_hda_jack_detect_enable(codec, nid, HP_EVENT);
snd_hda_jack_detect_enable_callback(codec, nid, HP_EVENT, cs_automute);
spec->hp_detect = 1;
}
}
Expand All @@ -1046,7 +1046,7 @@ static void init_output(struct hda_codec *codec)

/* SPDIF is enabled on presence detect for CS421x */
if (spec->hp_detect || spec->spdif_detect)
cs_automute(codec);
cs_automute(codec, NULL);
}

static void init_input(struct hda_codec *codec)
Expand All @@ -1070,13 +1070,13 @@ static void init_input(struct hda_codec *codec)
AC_VERB_SET_AMP_GAIN_MUTE,
AMP_IN_MUTE(spec->adc_idx[i]));
if (spec->mic_detect && spec->automic_idx == i)
snd_hda_jack_detect_enable(codec, pin, MIC_EVENT);
snd_hda_jack_detect_enable_callback(codec, pin, MIC_EVENT, cs_automic);
}
/* CS420x has multiple ADC, CS421x has single ADC */
if (spec->vendor_nid == CS420X_VENDOR_NID) {
change_cur_input(codec, spec->cur_input, 1);
if (spec->mic_detect)
cs_automic(codec);
cs_automic(codec, NULL);

coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */
if (is_active_pin(codec, CS_DMIC2_PIN_NID))
Expand All @@ -1089,7 +1089,7 @@ static void init_input(struct hda_codec *codec)
cs_vendor_coef_set(codec, IDX_ADC_CFG, coef);
} else {
if (spec->mic_detect)
cs_automic(codec);
cs_automic(codec, NULL);
else {
spec->cur_adc = spec->adc_nid[spec->cur_input];
cs_update_input_select(codec);
Expand Down Expand Up @@ -1246,25 +1246,12 @@ static void cs_free(struct hda_codec *codec)
kfree(codec->spec);
}

static void cs_unsol_event(struct hda_codec *codec, unsigned int res)
{
switch (snd_hda_jack_get_action(codec, res >> 26)) {
case HP_EVENT:
cs_automute(codec);
break;
case MIC_EVENT:
cs_automic(codec);
break;
}
snd_hda_jack_report_sync(codec);
}

static const struct hda_codec_ops cs_patch_ops = {
.build_controls = cs_build_controls,
.build_pcms = cs_build_pcms,
.init = cs_init,
.free = cs_free,
.unsol_event = cs_unsol_event,
.unsol_event = snd_hda_jack_unsol_event,
};

static int cs_parse_auto_config(struct hda_codec *codec)
Expand Down Expand Up @@ -1674,7 +1661,7 @@ static void init_cs421x_digital(struct hda_codec *codec)
if (!cfg->speaker_outs)
continue;
if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
snd_hda_jack_detect_enable(codec, nid, SPDIF_EVENT);
snd_hda_jack_detect_enable_callback(codec, nid, SPDIF_EVENT, cs_automute);
spec->spdif_detect = 1;
}
}
Expand Down Expand Up @@ -1889,21 +1876,6 @@ static int cs421x_build_controls(struct hda_codec *codec)
return 0;
}

static void cs421x_unsol_event(struct hda_codec *codec, unsigned int res)
{
switch (snd_hda_jack_get_action(codec, res >> 26)) {
case HP_EVENT:
case SPDIF_EVENT:
cs_automute(codec);
break;

case MIC_EVENT:
cs_automic(codec);
break;
}
snd_hda_jack_report_sync(codec);
}

static int parse_cs421x_input(struct hda_codec *codec)
{
struct cs_spec *spec = codec->spec;
Expand Down Expand Up @@ -1977,7 +1949,7 @@ static struct hda_codec_ops cs421x_patch_ops = {
.build_pcms = cs_build_pcms,
.init = cs421x_init,
.free = cs_free,
.unsol_event = cs421x_unsol_event,
.unsol_event = snd_hda_jack_unsol_event,
#ifdef CONFIG_PM
.suspend = cs421x_suspend,
#endif
Expand Down

0 comments on commit 5c2e4e0

Please sign in to comment.