Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 1/4] ASoC: rt721-sdca: handle HID button read errors
@ 2026-11-01 11:00 Avi Weiss
  2026-11-01 11:00 ` [PATCH v2 2/4] ASoC: rt711-sdca: " Avi Weiss
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Avi Weiss @ 2026-11-01 11:00 UTC (permalink / raw)
  To: Mark Brown; +Cc: Oder Chiou, Liam Girdwood, linux-sound

rt_sdca_button_detect() returns zero when a regmap read fails,
so RT721 treats the error as a valid no-button result.

Return the original error and skip button reporting when a read
fails. Still report jack changes, and clear button state if the
headset is removed.

Fixes: bbca8e7050e0 ("ASoC: rt-sdw-common: Common functions for Realtek soundwire driver")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
Changes in v2:
- report jack state on button read failures even when SDCA_0 is clear, fixing the missed unplug identified during review of v1
- document negative error returns from rt_sdca_button_detect()

 sound/soc/codecs/rt-sdw-common.c |  6 +++++-
 sound/soc/codecs/rt721-sdca.c    | 11 +++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/rt-sdw-common.c b/sound/soc/codecs/rt-sdw-common.c
index ad61943ce75ff..2b24d6ac8f143 100644
--- a/sound/soc/codecs/rt-sdw-common.c
+++ b/sound/soc/codecs/rt-sdw-common.c
@@ -187,6 +187,7 @@ EXPORT_SYMBOL_GPL(rt_sdca_headset_detect);
  *
  * A button type will be returned regarding to buffer,
  * it returns zero if buffer cannot be recognized.
+ * A negative errno is returned if a register read fails.
  */
 int rt_sdca_button_detect(struct regmap *map, unsigned int entity_id,
 	unsigned int hid_buf_addr, unsigned int hid_id)
@@ -199,7 +200,7 @@ int rt_sdca_button_detect(struct regmap *map, unsigned int entity_id,
 	ret = regmap_read(map, SDW_SDCA_CTL(SDCA_NUM_HID, entity_id,
 			RT_SDCA_CTL_HIDTX_CURRENT_OWNER, 0), &owner);
 	if (ret < 0)
-		return 0;
+		return ret;
 
 	/* if owner is device then there is no button event from device */
 	if (owner == 1)
@@ -229,6 +230,9 @@ int rt_sdca_button_detect(struct regmap *map, unsigned int entity_id,
 			SDW_SDCA_CTL(SDCA_NUM_HID, entity_id,
 				RT_SDCA_CTL_HIDTX_CURRENT_OWNER, 0), 0x01);
 
+	if (ret < 0)
+		return ret;
+
 	return btn_type;
 }
 EXPORT_SYMBOL_GPL(rt_sdca_button_detect);
diff --git a/sound/soc/codecs/rt721-sdca.c b/sound/soc/codecs/rt721-sdca.c
index 9f567caecb70a..82ef8245474cb 100644
--- a/sound/soc/codecs/rt721-sdca.c
+++ b/sound/soc/codecs/rt721-sdca.c
@@ -248,6 +248,17 @@ static void rt721_sdca_jack_detect_handler(struct work_struct *work)
 					RT721_SDCA_ENT_HID01, RT721_BUF_ADDR_HID1,
 					RT721_SDCA_HID_ID);
 
+	if (btn_type < 0) {
+		unsigned int mask = SND_JACK_HEADSET;
+
+		if (rt721->jack_type != SND_JACK_HEADSET)
+			mask |= SND_JACK_BTN_0 | SND_JACK_BTN_1 |
+				SND_JACK_BTN_2 | SND_JACK_BTN_3;
+
+		snd_soc_jack_report(rt721->hs_jack, rt721->jack_type, mask);
+		return;
+	}
+
 	if (rt721->jack_type == 0)
 		btn_type = 0;
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-01 11:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-01 11:00 [PATCH v2 1/4] ASoC: rt721-sdca: handle HID button read errors Avi Weiss
2026-11-01 11:00 ` [PATCH v2 2/4] ASoC: rt711-sdca: " Avi Weiss
2026-11-01 11:08   ` sashiko-bot
2026-11-01 11:00 ` [PATCH v2 3/4] ASoC: rt712-sdca: " Avi Weiss
2026-11-01 11:01 ` [PATCH v2 4/4] ASoC: rt722-sdca: " Avi Weiss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox