Linux bluetooth development
 help / color / mirror / Atom feed
From: Simon Mikuda <simon.mikuda@streamunlimited.com>
To: linux-bluetooth@vger.kernel.org
Cc: Simon Mikuda <simon.mikuda@streamunlimited.com>
Subject: [PATCH BlueZ 2/2] avrcp: Check what the remote uses instead of its AVRCP version
Date: Tue, 24 Nov 2026 14:39:54 +0100	[thread overview]
Message-ID: <20261124133954.4009535-2-simon.mikuda@streamunlimited.com> (raw)
In-Reply-To: <20261124133954.4009535-1-simon.mikuda@streamunlimited.com>

The version in the remote's SDP record does not tell which commands
it uses. Android phones such as the Nexus 6P show AVRCP 1.3 in their
controller record but set the absolute volume and register for
EVENT_VOLUME_CHANGED, and the Huawei Nova 7 registers for it without
a controller record that passes avrcp_volume_supported(). Both lose
absolute volume control.

Accept SetAbsoluteVolume and notify EVENT_VOLUME_CHANGED whenever the
remote uses them: the registration already tells whether to notify.
Ask any remote for its capabilities and register the events it
reports, connect browsing on the feature bit alone, and drop the
version checks before SetAddressedPlayer and player settings, which
exist only for players and settings the remote reported. Sending
SetAbsoluteVolume still requires category 2 when VolumeCategory is set.

Assisted-by: Claude:claude-opus-5-5
---
 profiles/audio/avrcp.c | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index f7c988ec0..b550c3b2a 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1740,10 +1740,10 @@ err:
 	return AVC_CTYPE_REJECTED;
 }
 
-/* SetAbsoluteVolume requires at least version 1.4 and a category-2 */
+/* SetAbsoluteVolume requires a category-2 */
 static bool avrcp_volume_supported(struct avrcp_data *data)
 {
-	if (!data || data->version < 0x0104)
+	if (!data)
 		return false;
 
 	if (btd_opts.avrcp.volume_category &&
@@ -1763,11 +1763,6 @@ static uint8_t avrcp_handle_set_absolute_volume(struct avrcp *session,
 	if (len != 1)
 		goto err;
 
-	if (!avrcp_volume_supported(session->target)) {
-		error("SetAbsoluteVolume not supported");
-		goto err;
-	}
-
 	volume = pdu->params[0] = pdu->params[0] & 0x7F;
 
 	media_transport_set_a2dp_volume(session->dev, volume);
@@ -3084,8 +3079,7 @@ static void avrcp_set_addressed_player(struct avrcp *session,
 static void set_addressed_player(struct avrcp *session,
 					struct avrcp_player *player)
 {
-	if (!player || !player->id || player->addressed ||
-				session->controller->version < 0x0104)
+	if (!player || !player->id || player->addressed)
 		return;
 
 	/* Set player as addressed */
@@ -3137,9 +3131,6 @@ static bool ct_set_setting(struct media_player *mp, const char *key,
 	if (session == NULL)
 		return false;
 
-	if (session->controller->version < 0x0103)
-		return false;
-
 	set_ct_player(session, player);
 
 	attr = attr_to_val(key);
@@ -4369,9 +4360,6 @@ static void target_init(struct avrcp *session)
 		media_transport_set_a2dp_volume(session->dev, init_volume);
 	}
 
-	if (target->version < 0x0104)
-		return;
-
 	/* Only check capabilities if controller is not supported */
 	if (session->controller == NULL)
 		avrcp_get_capabilities(session);
@@ -4415,14 +4403,8 @@ static void controller_init(struct avrcp *session)
 			return;
 	}
 
-	if (controller->version < 0x0103)
-		return;
-
 	avrcp_get_capabilities(session);
 
-	if (controller->version < 0x0104)
-		return;
-
 	if (!(controller->features & AVRCP_FEATURE_BROWSING))
 		return;
 
@@ -4837,10 +4819,8 @@ int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify)
 		return -ENOTCONN;
 
 	if (notify) {
-		if (!avrcp_volume_supported(session->target)) {
-			error("EVENT_VOLUME_CHANGED not supported");
+		if (!session->target)
 			return -ENOTSUP;
-		}
 		return avrcp_event(session, AVRCP_EVENT_VOLUME_CHANGED,
 								&volume);
 	}
-- 
2.43.0


  reply	other threads:[~2026-11-24 13:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 13:39 [PATCH BlueZ 1/2] avrcp: Defer init until service discovery completes Simon Mikuda
2026-11-24 13:39 ` Simon Mikuda [this message]
2026-11-24 16:15 ` Luiz Augusto von Dentz
2026-11-24 21:01 ` [BlueZ,1/2] " bluez.test.bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124133954.4009535-2-simon.mikuda@streamunlimited.com \
    --to=simon.mikuda@streamunlimited.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox