diff mbox series

[v1] ASoC: codecs: ES8326: Adjust buttons

Message ID 20240814060921.2521-1-zhangyi@everest-semi.com (mailing list archive)
State New, archived
Headers show
Series [v1] ASoC: codecs: ES8326: Adjust buttons | expand

Commit Message

Zhang Yi Aug. 14, 2024, 6:09 a.m. UTC
To adapt to chrome, we have adjusted the buttons to match the system.

Signed-off-by: Zhang Yi <zhangyi@everest-semi.com>
---
 sound/soc/codecs/es8326.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c
index d5362b3be484..cf22d3b745d5 100755
--- a/sound/soc/codecs/es8326.c
+++ b/sound/soc/codecs/es8326.c
@@ -752,6 +752,16 @@  static void es8326_jack_button_handler(struct work_struct *work)
 	static int button_to_report, press_count;
 	static int prev_button, cur_button;
 
+#if IS_ENABLED(CONFIG_SND_SOC_MT8188_MT6359)
+	const int hs_keys[] = {
+		SND_JACK_BTN_0, SND_JACK_BTN_2, SND_JACK_BTN_3
+	};
+#else
+	const int hs_keys[] = {
+		SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2
+	};
+#endif
+
 	if (!(es8326->jack->status & SND_JACK_HEADSET)) /* Jack unplugged */
 		return;
 
@@ -760,16 +770,16 @@  static void es8326_jack_button_handler(struct work_struct *work)
 	switch (iface) {
 	case 0x93:
 		/* pause button detected */
-		cur_button = SND_JACK_BTN_0;
+		cur_button = hs_keys[0];
 		break;
 	case 0x6f:
 	case 0x4b:
 		/* button volume up */
-		cur_button = SND_JACK_BTN_1;
+		cur_button = hs_keys[1];
 		break;
 	case 0x27:
 		/* button volume down */
-		cur_button = SND_JACK_BTN_2;
+		cur_button = hs_keys[2];
 		break;
 	case 0x1e:
 	case 0xe2:
@@ -785,7 +795,7 @@  static void es8326_jack_button_handler(struct work_struct *work)
 		if (press_count > 3) {
 			/* report a press every 120ms */
 			snd_soc_jack_report(es8326->jack, cur_button,
-					SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2);
+				SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3);
 			press_count = 0;
 		}
 		button_to_report = cur_button;
@@ -800,9 +810,9 @@  static void es8326_jack_button_handler(struct work_struct *work)
 		/* released or no pressed */
 		if (button_to_report != 0) {
 			snd_soc_jack_report(es8326->jack, button_to_report,
-				    SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2);
+				SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3);
 			snd_soc_jack_report(es8326->jack, 0,
-				    SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2);
+				SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3);
 			button_to_report = 0;
 		}
 		es8326_disable_micbias(es8326->component);
@@ -845,7 +855,7 @@  static void es8326_jack_detect_handler(struct work_struct *work)
 		if (es8326->jack->status & SND_JACK_HEADPHONE) {
 			dev_dbg(comp->dev, "Report hp remove event\n");
 			snd_soc_jack_report(es8326->jack, 0,
-				    SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2);
+				SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3);
 			snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET);
 			/* mute adc when mic path switch */
 			regmap_write(es8326->regmap, ES8326_ADC1_SRC, 0x44);