[PATCH 1/2][SRU][OEM-5.14] Revert "UBUNTU: SAUCE: ALSA: hda/cs8409: Schedule delayed work for jack detect on resume"

Chris Chiu chris.chiu at canonical.com
Tue Dec 14 13:38:28 UTC 2021


BugLink: https://bugs.launchpad.net/bugs/1954773

This reverts commit e3241734e283f7906d67ad81fb0f85a1fd661a67.

Signed-off-by: Chris Chiu <chris.chiu at canonical.com>
---
 sound/pci/hda/patch_cs8409.c | 79 +++++++-----------------------------
 sound/pci/hda/patch_cs8409.h |  1 -
 2 files changed, 15 insertions(+), 65 deletions(-)

diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c
index 88213e95f0b3..31ff11ab868e 100644
--- a/sound/pci/hda/patch_cs8409.c
+++ b/sound/pci/hda/patch_cs8409.c
@@ -634,30 +634,6 @@ static void cs42l42_run_jack_detect(struct sub_codec *cs42l42)
 	cs8409_i2c_write(cs42l42, 0x1120, 0xc0);
 }
 
-static void cs42l42_run_jack_detect_all(struct hda_codec *codec)
-{
-	struct cs8409_spec *spec = codec->spec;
-	struct sub_codec *cs42l42;
-	int i;
-
-	for (i = 0; i < spec->num_scodecs; i++) {
-		cs42l42 = spec->scodecs[i];
-		cs42l42_enable_jack_detect(cs42l42);
-		if (!cs42l42->hp_jack_in)
-			cs42l42_run_jack_detect(cs42l42);
-	}
-}
-
-/*
- * cs42l42_jack_detect_worker - Worker that retries jack detect
- */
-static void cs42l42_jack_detect_worker(struct work_struct *work)
-{
-	struct cs8409_spec *spec = container_of(work, struct cs8409_spec, jack_detect_work.work);
-
-	cs42l42_run_jack_detect_all(spec->codec);
-}
-
 static int cs42l42_handle_tip_sense(struct sub_codec *cs42l42, unsigned int reg_ts_status)
 {
 	int status_changed = 0;
@@ -773,6 +749,8 @@ static void cs42l42_resume(struct sub_codec *cs42l42)
 
 	if (cs42l42->full_scale_vol)
 		cs8409_i2c_write(cs42l42, 0x2001, 0x01);
+
+	cs42l42_enable_jack_detect(cs42l42);
 }
 
 #ifdef CONFIG_PM
@@ -822,7 +800,6 @@ static void cs8409_free(struct hda_codec *codec)
 
 	/* Cancel i2c clock disable timer, and disable clock if left enabled */
 	cancel_delayed_work_sync(&spec->i2c_clk_work);
-	cancel_delayed_work_sync(&spec->jack_detect_work);
 	cs8409_disable_i2c_clock(codec);
 
 	snd_hda_gen_free(codec);
@@ -886,7 +863,6 @@ static int cs8409_cs42l42_suspend(struct hda_codec *codec)
 
 	/* Cancel i2c clock disable timer, and disable clock if left enabled */
 	cancel_delayed_work_sync(&spec->i2c_clk_work);
-	cancel_delayed_work_sync(&spec->jack_detect_work);
 	cs8409_disable_i2c_clock(codec);
 
 	snd_hda_shutup_pins(codec);
@@ -994,8 +970,6 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
 		spec->scodecs[CS8409_CODEC0]->codec = codec;
 		codec->patch_ops = cs8409_cs42l42_patch_ops;
 
-		INIT_DELAYED_WORK(&spec->jack_detect_work, cs42l42_jack_detect_worker);
-
 		spec->gen.suppress_auto_mute = 1;
 		spec->gen.no_primary_hp = 1;
 		spec->gen.suppress_vmaster = 1;
@@ -1055,16 +1029,9 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
 	case HDA_FIXUP_ACT_INIT:
 		cs8409_cs42l42_hw_init(codec);
 		spec->init_done = 1;
-		if (spec->init_done && spec->build_ctrl_done) {
-			/* No point in running jack detect until we have fully resumed */
-			if (codec->core.dev.power.power_state.event != PM_EVENT_ON) {
-				codec_warn(codec, "Not ready to detect jack, deferring...\n");
-				schedule_delayed_work(&spec->jack_detect_work, msecs_to_jiffies(25));
-				return;
-			} else {
-				cs42l42_run_jack_detect_all(codec);
-			}
-		}
+		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:
 		spec->build_ctrl_done = 1;
@@ -1073,16 +1040,9 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
 		 * been already plugged in.
 		 * Run immediately after init.
 		 */
-		if (spec->init_done && spec->build_ctrl_done) {
-			/* No point in running jack detect until we have fully resumed */
-			if (codec->core.dev.power.power_state.event != PM_EVENT_ON) {
-				codec_warn(codec, "Not ready to detect jack, deferring...\n");
-				schedule_delayed_work(&spec->jack_detect_work, msecs_to_jiffies(25));
-				return;
-			} else {
-				cs42l42_run_jack_detect_all(codec);
-			}
-		}
+		if (spec->init_done && spec->build_ctrl_done
+			&& !spec->scodecs[CS8409_CODEC0]->hp_jack_in)
+			cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]);
 		break;
 	default:
 		break;
@@ -1218,6 +1178,7 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
 {
 	struct cs8409_spec *spec = codec->spec;
 	struct snd_kcontrol_new *kctrl;
+	int i;
 
 	switch (action) {
 	case HDA_FIXUP_ACT_PRE_PROBE:
@@ -1232,8 +1193,6 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
 		spec->scodecs[CS8409_CODEC1]->codec = codec;
 		spec->num_scodecs = 2;
 
-		INIT_DELAYED_WORK(&spec->jack_detect_work, cs42l42_jack_detect_worker);
-
 		codec->patch_ops = cs8409_dolphin_patch_ops;
 
 		/* GPIO 1,5 out, 0,4 in */
@@ -1278,13 +1237,9 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
 		dolphin_hw_init(codec);
 		spec->init_done = 1;
 		if (spec->init_done && spec->build_ctrl_done) {
-			/* No point in running jack detect until we have fully resumed */
-			if (codec->core.dev.power.power_state.event != PM_EVENT_ON) {
-				codec_warn(codec, "Not ready to detect jack, deferring...\n");
-				schedule_delayed_work(&spec->jack_detect_work, msecs_to_jiffies(25));
-				return;
-			} else {
-				cs42l42_run_jack_detect_all(codec);
+			for (i = 0; i < spec->num_scodecs; i++) {
+				if (!spec->scodecs[i]->hp_jack_in)
+					cs42l42_run_jack_detect(spec->scodecs[i]);
 			}
 		}
 		break;
@@ -1296,13 +1251,9 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
 		 * Run immediately after init.
 		 */
 		if (spec->init_done && spec->build_ctrl_done) {
-			/* No point in running jack detect until we have fully resumed */
-			if (codec->core.dev.power.power_state.event != PM_EVENT_ON) {
-				codec_warn(codec, "Not ready to detect jack, deferring...\n");
-				schedule_delayed_work(&spec->jack_detect_work, msecs_to_jiffies(25));
-				return;
-			} else {
-				cs42l42_run_jack_detect_all(codec);
+			for (i = 0; i < spec->num_scodecs; i++) {
+				if (!spec->scodecs[i]->hp_jack_in)
+					cs42l42_run_jack_detect(spec->scodecs[i]);
 			}
 		}
 		break;
diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h
index 632d3ec8322d..ade2b838590c 100644
--- a/sound/pci/hda/patch_cs8409.h
+++ b/sound/pci/hda/patch_cs8409.h
@@ -330,7 +330,6 @@ struct cs8409_spec {
 	unsigned int i2c_clck_enabled;
 	unsigned int dev_addr;
 	struct delayed_work i2c_clk_work;
-	struct delayed_work jack_detect_work;
 
 	unsigned int playback_started:1;
 	unsigned int capture_started:1;
-- 
2.25.1




More information about the kernel-team mailing list