Skip to content

Commit 424e531

Browse files
Stefan Bindingtiwai
authored andcommitted
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: Stefan Binding <[email protected]> Signed-off-by: Vitaly Rodionov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 2eaf163 commit 424e531

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

sound/pci/hda/patch_cs8409.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,8 @@ static void cs42l42_suspend(struct sub_codec *cs42l42)
784784
cs8409_i2c_write(cs42l42, 0x1102, 0x9C);
785785
cs42l42->suspended = 1;
786786
cs42l42->last_page = 0;
787+
cs42l42->hp_jack_in = 0;
788+
cs42l42->mic_jack_in = 0;
787789

788790
/* Put CS42L42 into Reset */
789791
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)
852854
struct cs8409_spec *spec = codec->spec;
853855
int i;
854856

857+
spec->init_done = 0;
858+
855859
cs8409_enable_ur(codec, 0);
856860

857861
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,
10251029
break;
10261030
case HDA_FIXUP_ACT_INIT:
10271031
cs8409_cs42l42_hw_init(codec);
1028-
fallthrough;
1032+
spec->init_done = 1;
1033+
if (spec->init_done && spec->build_ctrl_done
1034+
&& !spec->scodecs[CS8409_CODEC0]->hp_jack_in)
1035+
cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]);
1036+
break;
10291037
case HDA_FIXUP_ACT_BUILD:
1038+
spec->build_ctrl_done = 1;
10301039
/* Run jack auto detect first time on boot
10311040
* after controls have been added, to check if jack has
10321041
* been already plugged in.
10331042
* Run immediately after init.
10341043
*/
1035-
cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]);
1044+
if (spec->init_done && spec->build_ctrl_done
1045+
&& !spec->scodecs[CS8409_CODEC0]->hp_jack_in)
1046+
cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]);
10361047
break;
10371048
default:
10381049
break;
@@ -1223,16 +1234,27 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
12231234
break;
12241235
case HDA_FIXUP_ACT_INIT:
12251236
dolphin_hw_init(codec);
1226-
fallthrough;
1237+
spec->init_done = 1;
1238+
if (spec->init_done && spec->build_ctrl_done) {
1239+
for (i = 0; i < spec->num_scodecs; i++) {
1240+
if (!spec->scodecs[i]->hp_jack_in)
1241+
cs42l42_run_jack_detect(spec->scodecs[i]);
1242+
}
1243+
}
1244+
break;
12271245
case HDA_FIXUP_ACT_BUILD:
1246+
spec->build_ctrl_done = 1;
12281247
/* Run jack auto detect first time on boot
12291248
* after controls have been added, to check if jack has
12301249
* been already plugged in.
12311250
* Run immediately after init.
12321251
*/
1233-
for (i = 0; i < spec->num_scodecs; i++)
1234-
cs42l42_run_jack_detect(spec->scodecs[i]);
1235-
1252+
if (spec->init_done && spec->build_ctrl_done) {
1253+
for (i = 0; i < spec->num_scodecs; i++) {
1254+
if (!spec->scodecs[i]->hp_jack_in)
1255+
cs42l42_run_jack_detect(spec->scodecs[i]);
1256+
}
1257+
}
12361258
break;
12371259
default:
12381260
break;

sound/pci/hda/patch_cs8409.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ struct cs8409_spec {
333333

334334
unsigned int playback_started:1;
335335
unsigned int capture_started:1;
336+
unsigned int init_done:1;
337+
unsigned int build_ctrl_done:1;
336338

337339
/* verb exec op override */
338340
int (*exec_verb)(struct hdac_device *dev, unsigned int cmd, unsigned int flags,

0 commit comments

Comments
 (0)