From: Simon Mikuda <simon.mikuda@streamunlimited.com>
To: linux-bluetooth@vger.kernel.org
Cc: Simon Mikuda <simon.mikuda@streamunlimited.com>
Subject: [PATCH BlueZ v2 2/2] avrcp: Check what the remote uses instead of its AVRCP version
Date: Wed, 25 Nov 2026 18:02:43 +0100 [thread overview]
Message-ID: <20261125170243.1649146-2-simon.mikuda@streamunlimited.com> (raw)
In-Reply-To: <20261125170243.1649146-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 a registration for EVENT_VOLUME_CHANGED
whenever the remote uses them, even when the supported events listed
for its version leave the event out: 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 | 35 +++++++++--------------------------
1 file changed, 9 insertions(+), 26 deletions(-)
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 0a28b0339..8e60ca670 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1623,8 +1623,11 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session,
if (len != 5)
goto err;
- /* Check if event is supported otherwise reject */
- if (!(session->supported_events & (1 << pdu->params[0])))
+ /* Check if event is supported otherwise reject, but a remote that
+ * registers for the volume uses it whatever version it reports
+ */
+ if (!(session->supported_events & (1 << pdu->params[0])) &&
+ pdu->params[0] != AVRCP_EVENT_VOLUME_CHANGED)
goto err;
switch (pdu->params[0]) {
@@ -1752,10 +1755,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 &&
@@ -1775,11 +1778,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);
@@ -3096,8 +3094,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 */
@@ -3149,9 +3146,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);
@@ -4385,9 +4379,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);
@@ -4431,14 +4422,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;
@@ -4849,10 +4834,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
next prev parent reply other threads:[~2026-11-25 17:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 17:02 [PATCH BlueZ v2 1/2] avrcp: Defer init until service discovery completes Simon Mikuda
2026-11-25 17:02 ` Simon Mikuda [this message]
2026-11-25 23:53 ` [BlueZ,v2,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=20261125170243.1649146-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