[PATCH v1] ASoC: codecs: ES8326: Adjust buttons
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 --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);
On Wed, Aug 14, 2024 at 02:09:21PM +0800, Zhang Yi wrote:
To adapt to chrome, we have adjusted the buttons to match the system.
This needs a bit more of a commit log explaining what's going on.
+#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
This will remap the buttons no matter what system we're running on so while it's a bit better it's still going to cause issues. We could use a per board approach like this but it needs to be at runtime, based on the machine compatible rather than a build time selection.
The support for this device was added in e794a894427b1d ("ASoC: mediatek: mt8188-mt6359: add es8326 support") which was added in v6.8 so this would also be a potential issue in mainline, given that this is likely only used by Chromebooks and didn't make it to a LTS yet we could possibly give it a go but we might have to revert.
participants (1)
-
Mark Brown
-
Zhang Yi