Commit f5662e1c authored by David Henningsson's avatar David Henningsson Committed by Takashi Iwai

ALSA: hda - Refactor quirk picking and change quirk priority

Previously, calling one quirk function first and another later
would make the latter one take priority, this is now changed
to make the former take priority.

By adding two special values for fixup_id we can also get rid of the
fixup_forced flag.
Signed-off-by: default avatarDavid Henningsson <david.henningsson@canonical.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 9dc12862
...@@ -854,7 +854,7 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec, ...@@ -854,7 +854,7 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec,
{ {
const struct snd_hda_pin_quirk *pq; const struct snd_hda_pin_quirk *pq;
if (codec->fixup_forced) if (codec->fixup_id != HDA_FIXUP_ID_NOT_SET)
return; return;
for (pq = pin_quirk; pq->subvendor; pq++) { for (pq = pin_quirk; pq->subvendor; pq++) {
...@@ -880,14 +880,17 @@ void snd_hda_pick_fixup(struct hda_codec *codec, ...@@ -880,14 +880,17 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
const struct hda_fixup *fixlist) const struct hda_fixup *fixlist)
{ {
const struct snd_pci_quirk *q; const struct snd_pci_quirk *q;
int id = -1; int id = HDA_FIXUP_ID_NOT_SET;
const char *name = NULL; const char *name = NULL;
if (codec->fixup_id != HDA_FIXUP_ID_NOT_SET)
return;
/* when model=nofixup is given, don't pick up any fixups */ /* when model=nofixup is given, don't pick up any fixups */
if (codec->modelname && !strcmp(codec->modelname, "nofixup")) { if (codec->modelname && !strcmp(codec->modelname, "nofixup")) {
codec->fixup_list = NULL; codec->fixup_list = NULL;
codec->fixup_id = -1; codec->fixup_name = NULL;
codec->fixup_forced = 1; codec->fixup_id = HDA_FIXUP_ID_NO_FIXUP;
return; return;
} }
...@@ -897,13 +900,12 @@ void snd_hda_pick_fixup(struct hda_codec *codec, ...@@ -897,13 +900,12 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
codec->fixup_id = models->id; codec->fixup_id = models->id;
codec->fixup_name = models->name; codec->fixup_name = models->name;
codec->fixup_list = fixlist; codec->fixup_list = fixlist;
codec->fixup_forced = 1;
return; return;
} }
models++; models++;
} }
} }
if (id < 0 && quirk) { if (quirk) {
q = snd_pci_quirk_lookup(codec->bus->pci, quirk); q = snd_pci_quirk_lookup(codec->bus->pci, quirk);
if (q) { if (q) {
id = q->value; id = q->value;
...@@ -927,7 +929,6 @@ void snd_hda_pick_fixup(struct hda_codec *codec, ...@@ -927,7 +929,6 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
} }
} }
codec->fixup_forced = 0;
codec->fixup_id = id; codec->fixup_id = id;
if (id >= 0) { if (id >= 0) {
codec->fixup_list = fixlist; codec->fixup_list = fixlist;
......
...@@ -1476,6 +1476,7 @@ int snd_hda_codec_new(struct hda_bus *bus, ...@@ -1476,6 +1476,7 @@ int snd_hda_codec_new(struct hda_bus *bus,
INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work); INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work);
codec->depop_delay = -1; codec->depop_delay = -1;
codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
#ifdef CONFIG_PM #ifdef CONFIG_PM
spin_lock_init(&codec->power_lock); spin_lock_init(&codec->power_lock);
......
...@@ -402,7 +402,6 @@ struct hda_codec { ...@@ -402,7 +402,6 @@ struct hda_codec {
/* fix-up list */ /* fix-up list */
int fixup_id; int fixup_id;
unsigned int fixup_forced:1; /* fixup explicitly set by user */
const struct hda_fixup *fixup_list; const struct hda_fixup *fixup_list;
const char *fixup_name; const char *fixup_name;
......
...@@ -438,6 +438,8 @@ struct snd_hda_pin_quirk { ...@@ -438,6 +438,8 @@ struct snd_hda_pin_quirk {
#endif #endif
#define HDA_FIXUP_ID_NOT_SET -1
#define HDA_FIXUP_ID_NO_FIXUP -2
/* fixup types */ /* fixup types */
enum { enum {
......
...@@ -657,8 +657,10 @@ static void cs4208_fixup_mac(struct hda_codec *codec, ...@@ -657,8 +657,10 @@ static void cs4208_fixup_mac(struct hda_codec *codec,
{ {
if (action != HDA_FIXUP_ACT_PRE_PROBE) if (action != HDA_FIXUP_ACT_PRE_PROBE)
return; return;
codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
snd_hda_pick_fixup(codec, NULL, cs4208_mac_fixup_tbl, cs4208_fixups); snd_hda_pick_fixup(codec, NULL, cs4208_mac_fixup_tbl, cs4208_fixups);
if (codec->fixup_id < 0 || codec->fixup_id == CS4208_MAC_AUTO) if (codec->fixup_id == HDA_FIXUP_ID_NOT_SET)
codec->fixup_id = CS4208_GPIO0; /* default fixup */ codec->fixup_id = CS4208_GPIO0; /* default fixup */
snd_hda_apply_fixup(codec, action); snd_hda_apply_fixup(codec, action);
} }
......
...@@ -3449,9 +3449,11 @@ static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec, ...@@ -3449,9 +3449,11 @@ static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
{ {
if (action != HDA_FIXUP_ACT_PRE_PROBE) if (action != HDA_FIXUP_ACT_PRE_PROBE)
return; return;
codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl, snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
stac922x_fixups); stac922x_fixups);
if (codec->fixup_id != STAC_INTEL_MAC_AUTO) if (codec->fixup_id != HDA_FIXUP_ID_NOT_SET)
snd_hda_apply_fixup(codec, action); snd_hda_apply_fixup(codec, action);
} }
......
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