Skip to content

Commit

Permalink
ALSA: hda - Set patch_ops before calling auto-parser
Browse files Browse the repository at this point in the history
... so that the parser code can overwrite some optional ops.  For
Realtek and others, it can be set solely in the spec allocator, so it
results in a good code cleanup, too.

With this change, we can finally remove the local stream_pm setup and
rely on the generic parser's automatic setting.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed May 29, 2015
1 parent 984a854 commit 225068a
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 91 deletions.
3 changes: 1 addition & 2 deletions sound/pci/hda/patch_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ static int ad198x_parse_auto_config(struct hda_codec *codec, bool indep_hp)
if (err < 0)
return err;

codec->patch_ops = ad198x_auto_patch_ops;

return 0;
}

Expand All @@ -223,6 +221,7 @@ static int alloc_ad_spec(struct hda_codec *codec)
return -ENOMEM;
codec->spec = spec;
snd_hda_gen_spec_init(&spec->gen);
codec->patch_ops = ad198x_auto_patch_ops;
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions sound/pci/hda/patch_ca0110.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static int patch_ca0110(struct hda_codec *codec)
return -ENOMEM;
snd_hda_gen_spec_init(spec);
codec->spec = spec;
codec->patch_ops = ca0110_patch_ops;

spec->multi_cap_vol = 1;
codec->bus->needs_damn_long_delay = 1;
Expand All @@ -71,8 +72,6 @@ static int patch_ca0110(struct hda_codec *codec)
if (err < 0)
goto error;

codec->patch_ops = ca0110_patch_ops;

return 0;

error:
Expand Down
8 changes: 4 additions & 4 deletions sound/pci/hda/patch_ca0132.c
Original file line number Diff line number Diff line change
Expand Up @@ -4709,6 +4709,10 @@ static int patch_ca0132(struct hda_codec *codec)
codec->spec = spec;
spec->codec = codec;

codec->patch_ops = ca0132_patch_ops;
codec->pcm_format_first = 1;
codec->no_sticky_stream = 1;

/* Detect codec quirk */
quirk = snd_pci_quirk_lookup(codec->bus->pci, ca0132_quirks);
if (quirk)
Expand Down Expand Up @@ -4737,10 +4741,6 @@ static int patch_ca0132(struct hda_codec *codec)
if (err < 0)
return err;

codec->patch_ops = ca0132_patch_ops;
codec->pcm_format_first = 1;
codec->no_sticky_stream = 1;

return 0;
}

Expand Down
12 changes: 5 additions & 7 deletions sound/pci/hda/patch_cirrus.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ static int patch_cs420x(struct hda_codec *codec)
if (!spec)
return -ENOMEM;

codec->patch_ops = cs_patch_ops;
spec->gen.automute_hook = cs_automute;
codec->single_adc_amp = 1;

Expand All @@ -595,8 +596,6 @@ static int patch_cs420x(struct hda_codec *codec)
if (err < 0)
goto error;

codec->patch_ops = cs_patch_ops;

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -738,6 +737,7 @@ static int patch_cs4208(struct hda_codec *codec)
if (!spec)
return -ENOMEM;

codec->patch_ops = cs_patch_ops;
spec->gen.automute_hook = cs_automute;
/* exclude NID 0x10 (HP) from output volumes due to different steps */
spec->gen.out_vol_mask = 1ULL << 0x10;
Expand All @@ -756,8 +756,6 @@ static int patch_cs4208(struct hda_codec *codec)
if (err < 0)
goto error;

codec->patch_ops = cs_patch_ops;

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -1150,6 +1148,7 @@ static int patch_cs4210(struct hda_codec *codec)
if (!spec)
return -ENOMEM;

codec->patch_ops = cs421x_patch_ops;
spec->gen.automute_hook = cs_automute;

snd_hda_pick_fixup(codec, cs421x_models, cs421x_fixup_tbl,
Expand All @@ -1167,8 +1166,6 @@ static int patch_cs4210(struct hda_codec *codec)
if (err < 0)
goto error;

codec->patch_ops = cs421x_patch_ops;

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand All @@ -1187,11 +1184,12 @@ static int patch_cs4213(struct hda_codec *codec)
if (!spec)
return -ENOMEM;

codec->patch_ops = cs421x_patch_ops;

err = cs421x_parse_auto_config(codec);
if (err < 0)
goto error;

codec->patch_ops = cs421x_patch_ops;
return 0;

error:
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/hda/patch_cmedia.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static int patch_cmi9880(struct hda_codec *codec)
return -ENOMEM;

codec->spec = spec;
codec->patch_ops = cmi_auto_patch_ops;
cfg = &spec->gen.autocfg;
snd_hda_gen_spec_init(&spec->gen);

Expand All @@ -67,7 +68,6 @@ static int patch_cmi9880(struct hda_codec *codec)
if (err < 0)
goto error;

codec->patch_ops = cmi_auto_patch_ops;
return 0;

error:
Expand All @@ -86,6 +86,7 @@ static int patch_cmi8888(struct hda_codec *codec)
return -ENOMEM;

codec->spec = spec;
codec->patch_ops = cmi_auto_patch_ops;
cfg = &spec->gen.autocfg;
snd_hda_gen_spec_init(&spec->gen);

Expand All @@ -112,7 +113,6 @@ static int patch_cmi8888(struct hda_codec *codec)
}
}

codec->patch_ops = cmi_auto_patch_ops;
return 0;

error:
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/hda/patch_conexant.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
return -ENOMEM;
snd_hda_gen_spec_init(&spec->gen);
codec->spec = spec;
codec->patch_ops = cx_auto_patch_ops;

cx_auto_parse_beep(codec);
cx_auto_parse_eapd(codec);
Expand Down Expand Up @@ -908,8 +909,6 @@ static int patch_conexant_auto(struct hda_codec *codec)
if (err < 0)
goto error;

codec->patch_ops = cx_auto_patch_ops;

/* Some laptops with Conexant chips show stalls in S3 resume,
* which falls into the single-cmd mode.
* Better to make reset, then.
Expand Down
61 changes: 23 additions & 38 deletions sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
codec->single_adc_amp = 1;
/* FIXME: do we need this for all Realtek codec models? */
codec->spdif_status_reset = 1;
codec->patch_ops = alc_patch_ops;

err = alc_codec_rename_from_preset(codec);
if (err < 0) {
Expand Down Expand Up @@ -1447,6 +1448,8 @@ static int patch_alc880(struct hda_codec *codec)
spec->gen.need_dac_fix = 1;
spec->gen.beep_nid = 0x01;

codec->patch_ops.unsol_event = alc880_unsol_event;

snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
alc880_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Expand All @@ -1459,10 +1462,6 @@ static int patch_alc880(struct hda_codec *codec)
if (!spec->gen.no_analog)
set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);

codec->patch_ops = alc_patch_ops;
codec->patch_ops.unsol_event = alc880_unsol_event;


snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -1699,6 +1698,8 @@ static int patch_alc260(struct hda_codec *codec)
spec->gen.prefer_hp_amp = 1;
spec->gen.beep_nid = 0x01;

spec->shutup = alc_eapd_shutup;

snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
alc260_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Expand All @@ -1711,9 +1712,6 @@ static int patch_alc260(struct hda_codec *codec)
if (!spec->gen.no_analog)
set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);

codec->patch_ops = alc_patch_ops;
spec->shutup = alc_eapd_shutup;

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -2298,8 +2296,6 @@ static int patch_alc882(struct hda_codec *codec)
if (!spec->gen.no_analog && spec->gen.beep_nid)
set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);

codec->patch_ops = alc_patch_ops;

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -2435,6 +2431,8 @@ static int patch_alc262(struct hda_codec *codec)
spec = codec->spec;
spec->gen.shared_mic_vref_pin = 0x18;

spec->shutup = alc_eapd_shutup;

#if 0
/* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
* under-run
Expand All @@ -2460,9 +2458,6 @@ static int patch_alc262(struct hda_codec *codec)
if (!spec->gen.no_analog && spec->gen.beep_nid)
set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);

codec->patch_ops = alc_patch_ops;
spec->shutup = alc_eapd_shutup;

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -2566,6 +2561,8 @@ static int patch_alc268(struct hda_codec *codec)
spec = codec->spec;
spec->gen.beep_nid = 0x01;

spec->shutup = alc_eapd_shutup;

snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);

Expand All @@ -2587,9 +2584,6 @@ static int patch_alc268(struct hda_codec *codec)
(0 << AC_AMPCAP_MUTE_SHIFT));
}

codec->patch_ops = alc_patch_ops;
spec->shutup = alc_eapd_shutup;

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -5672,6 +5666,12 @@ static int patch_alc269(struct hda_codec *codec)
if (codec->core.vendor_id != 0x10ec0292)
codec->power_save_node = 1;

#ifdef CONFIG_PM
codec->patch_ops.suspend = alc269_suspend;
codec->patch_ops.resume = alc269_resume;
#endif
spec->shutup = alc269_shutup;

snd_hda_pick_fixup(codec, alc269_fixup_models,
alc269_fixup_tbl, alc269_fixups);
snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
Expand Down Expand Up @@ -5768,15 +5768,6 @@ static int patch_alc269(struct hda_codec *codec)
if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid)
set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);

codec->patch_ops = alc_patch_ops;
codec->patch_ops.stream_pm = snd_hda_gen_stream_pm;
#ifdef CONFIG_PM
codec->patch_ops.suspend = alc269_suspend;
codec->patch_ops.resume = alc269_resume;
#endif
if (!spec->shutup)
spec->shutup = alc269_shutup;

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -5892,6 +5883,10 @@ static int patch_alc861(struct hda_codec *codec)
spec = codec->spec;
spec->gen.beep_nid = 0x23;

#ifdef CONFIG_PM
spec->power_hook = alc_power_eapd;
#endif

snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);

Expand All @@ -5903,11 +5898,6 @@ static int patch_alc861(struct hda_codec *codec)
if (!spec->gen.no_analog)
set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);

codec->patch_ops = alc_patch_ops;
#ifdef CONFIG_PM
spec->power_hook = alc_power_eapd;
#endif

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -5984,6 +5974,8 @@ static int patch_alc861vd(struct hda_codec *codec)
spec = codec->spec;
spec->gen.beep_nid = 0x23;

spec->shutup = alc_eapd_shutup;

snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);

Expand All @@ -5995,10 +5987,6 @@ static int patch_alc861vd(struct hda_codec *codec)
if (!spec->gen.no_analog)
set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);

codec->patch_ops = alc_patch_ops;

spec->shutup = alc_eapd_shutup;

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -6599,6 +6587,8 @@ static int patch_alc662(struct hda_codec *codec)

spec = codec->spec;

spec->shutup = alc_eapd_shutup;

/* handle multiple HPs as is */
spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;

Expand Down Expand Up @@ -6650,9 +6640,6 @@ static int patch_alc662(struct hda_codec *codec)
}
}

codec->patch_ops = alc_patch_ops;
spec->shutup = alc_eapd_shutup;

snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);

return 0;
Expand Down Expand Up @@ -6689,8 +6676,6 @@ static int patch_alc680(struct hda_codec *codec)
return err;
}

codec->patch_ops = alc_patch_ops;

return 0;
}

Expand Down
Loading

0 comments on commit 225068a

Please sign in to comment.