public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] transport: Fix set volume failure with invalid device volume
@ 2026-03-09 11:18 Jinwang Li
  2026-03-09 12:28 ` [v3] " bluez.test.bot
  2026-03-09 14:00 ` [PATCH v3] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Jinwang Li @ 2026-03-09 11:18 UTC (permalink / raw)
  To: luiz.dentz, linux-bluetooth
  Cc: cheng.jiang, quic_chezhou, wei.deng, shuai.zhang, mengshi.wu,
	jinwang.li, Luiz Augusto von Dentz

When AVRCP is connected before AVDTP, an invalid device volume causes
the target to reject registration for the EVENT_VOLUME_CHANGED
notification, which breaks subsequent volume updates.

Fix this by initializing the volume to the maximum value in the AVRCP
target init path when it is invalid, allowing the controller to
subscribe to AVRCP_EVENT_VOLUME_CHANGED.

Fixes: fa7828bddd21 ("transport: Fix not being able to initialize volume properly")
Suggested-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Jinwang Li <jinwang.li@oss.qualcomm.com>
---
 profiles/audio/avrcp.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Changes from v2:
 - Initialize the volume in the AVRCP target init path instead of
   returning a fallback value from media_transport_get_a2dp_volume().
 - Set the volume to the maximum value only when it is still invalid,
   avoiding role-dependent behavior issues.
 - Link to v1
   https://lore.kernel.org/all/20260305083833.369358-1-jinwang.li@oss.qualcomm.com/

Changes from v1:
 - Return the max volume from media_transport_get_a2dp_volume()
   when there is no A2DP transport and the device volume is invalid.
 - Restore the default device volume in device_new().
 - Update the commit subject name.
 - Link to v1
   https://lore.kernel.org/all/20260122063640.310090-1-jinwang.li@oss.qualcomm.com/

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 724b46c59..326dfdab7 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -4296,9 +4296,16 @@ static void target_init(struct avrcp *session)
 	if (target->version < 0x0104)
 		return;
 
-	if (avrcp_volume_supported(target))
+	if (avrcp_volume_supported(target)) {
 		session->supported_events |=
 				(1 << AVRCP_EVENT_VOLUME_CHANGED);
+		/* Check if transport volume hasn't been initialized then set it
+		 * to max so it works properly if the controller attempts to
+		 * subscribe to AVRCP_EVENT_VOLUME_CHANGED.
+		 */
+		if (media_transport_get_a2dp_volume(session->dev) < 0)
+			media_transport_set_a2dp_volume(session->dev, 127);
+	}
 
 	session->supported_events |=
 				(1 << AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED) |
-- 
2.34.1


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

end of thread, other threads:[~2026-03-09 14:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 11:18 [PATCH v3] transport: Fix set volume failure with invalid device volume Jinwang Li
2026-03-09 12:28 ` [v3] " bluez.test.bot
2026-03-09 14:00 ` [PATCH v3] " patchwork-bot+bluetooth

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