Commit 424e531b authored by Stefan Binding's avatar Stefan Binding Committed by Takashi Iwai

ALSA: hda/cs8409: Ensure Type Detection is only run on startup when necessary

Type Detection should only be run after init and when the controls have been
built. There is no need to run it multiple times.
Signed-off-by: default avatarStefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: default avatarVitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210827110252.5361-1-vitalyr@opensource.cirrus.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 2eaf1635
...@@ -784,6 +784,8 @@ static void cs42l42_suspend(struct sub_codec *cs42l42) ...@@ -784,6 +784,8 @@ static void cs42l42_suspend(struct sub_codec *cs42l42)
cs8409_i2c_write(cs42l42, 0x1102, 0x9C); cs8409_i2c_write(cs42l42, 0x1102, 0x9C);
cs42l42->suspended = 1; cs42l42->suspended = 1;
cs42l42->last_page = 0; cs42l42->last_page = 0;
cs42l42->hp_jack_in = 0;
cs42l42->mic_jack_in = 0;
/* Put CS42L42 into Reset */ /* Put CS42L42 into Reset */
gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0); gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0);
...@@ -852,6 +854,8 @@ static int cs8409_cs42l42_suspend(struct hda_codec *codec) ...@@ -852,6 +854,8 @@ static int cs8409_cs42l42_suspend(struct hda_codec *codec)
struct cs8409_spec *spec = codec->spec; struct cs8409_spec *spec = codec->spec;
int i; int i;
spec->init_done = 0;
cs8409_enable_ur(codec, 0); cs8409_enable_ur(codec, 0);
for (i = 0; i < spec->num_scodecs; i++) for (i = 0; i < spec->num_scodecs; i++)
...@@ -1025,14 +1029,21 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix, ...@@ -1025,14 +1029,21 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
break; break;
case HDA_FIXUP_ACT_INIT: case HDA_FIXUP_ACT_INIT:
cs8409_cs42l42_hw_init(codec); cs8409_cs42l42_hw_init(codec);
fallthrough; spec->init_done = 1;
if (spec->init_done && spec->build_ctrl_done
&& !spec->scodecs[CS8409_CODEC0]->hp_jack_in)
cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]);
break;
case HDA_FIXUP_ACT_BUILD: case HDA_FIXUP_ACT_BUILD:
spec->build_ctrl_done = 1;
/* Run jack auto detect first time on boot /* Run jack auto detect first time on boot
* after controls have been added, to check if jack has * after controls have been added, to check if jack has
* been already plugged in. * been already plugged in.
* Run immediately after init. * Run immediately after init.
*/ */
cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]); if (spec->init_done && spec->build_ctrl_done
&& !spec->scodecs[CS8409_CODEC0]->hp_jack_in)
cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]);
break; break;
default: default:
break; break;
...@@ -1223,16 +1234,27 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac ...@@ -1223,16 +1234,27 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
break; break;
case HDA_FIXUP_ACT_INIT: case HDA_FIXUP_ACT_INIT:
dolphin_hw_init(codec); dolphin_hw_init(codec);
fallthrough; spec->init_done = 1;
if (spec->init_done && spec->build_ctrl_done) {
for (i = 0; i < spec->num_scodecs; i++) {
if (!spec->scodecs[i]->hp_jack_in)
cs42l42_run_jack_detect(spec->scodecs[i]);
}
}
break;
case HDA_FIXUP_ACT_BUILD: case HDA_FIXUP_ACT_BUILD:
spec->build_ctrl_done = 1;
/* Run jack auto detect first time on boot /* Run jack auto detect first time on boot
* after controls have been added, to check if jack has * after controls have been added, to check if jack has
* been already plugged in. * been already plugged in.
* Run immediately after init. * Run immediately after init.
*/ */
for (i = 0; i < spec->num_scodecs; i++) if (spec->init_done && spec->build_ctrl_done) {
cs42l42_run_jack_detect(spec->scodecs[i]); for (i = 0; i < spec->num_scodecs; i++) {
if (!spec->scodecs[i]->hp_jack_in)
cs42l42_run_jack_detect(spec->scodecs[i]);
}
}
break; break;
default: default:
break; break;
......
...@@ -333,6 +333,8 @@ struct cs8409_spec { ...@@ -333,6 +333,8 @@ struct cs8409_spec {
unsigned int playback_started:1; unsigned int playback_started:1;
unsigned int capture_started:1; unsigned int capture_started:1;
unsigned int init_done:1;
unsigned int build_ctrl_done:1;
/* verb exec op override */ /* verb exec op override */
int (*exec_verb)(struct hdac_device *dev, unsigned int cmd, unsigned int flags, int (*exec_verb)(struct hdac_device *dev, unsigned int cmd, unsigned int flags,
......
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