Skip to content

Commit 8a56574

Browse files
makeshikartben
authored andcommitted
Bluetooth: AVRCP: Mask invalid bit in absolute volume
PTS may send absolute volume values with bit 7 set, which exceed the valid range. Instead of rejecting these values, mask the invalid bit to ensure compatibility. Signed-off-by: Make Shi <[email protected]>
1 parent d58782f commit 8a56574

File tree

1 file changed

+5
-8
lines changed
  • subsys/bluetooth/host/classic

1 file changed

+5
-8
lines changed

subsys/bluetooth/host/classic/avrcp.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,10 +1355,8 @@ static int process_set_absolute_volume_rsp(struct bt_avrcp *avrcp, uint8_t tid,
13551355
return BT_AVRCP_STATUS_INVALID_PARAMETER;
13561356
}
13571357
absolute_volume = net_buf_pull_u8(buf);
1358-
if (absolute_volume > BT_AVRCP_MAX_ABSOLUTE_VOLUME) {
1359-
LOG_ERR("Invalid absolute volume: %d", absolute_volume);
1360-
return BT_AVRCP_STATUS_INVALID_PARAMETER;
1361-
}
1358+
/* PTS may respond with bit 7 set in the absolute volume parameter invalid behavior */
1359+
absolute_volume &= BT_AVRCP_MAX_ABSOLUTE_VOLUME;
13621360

13631361
avrcp_ct_cb->set_absolute_volume(get_avrcp_ct(avrcp), tid, status, absolute_volume);
13641362
return BT_AVRCP_STATUS_OPERATION_COMPLETED;
@@ -2214,10 +2212,9 @@ static int process_set_absolute_volume_cmd(struct bt_avrcp *avrcp, uint8_t tid,
22142212
}
22152213

22162214
absolute_volume = net_buf_pull_u8(buf);
2217-
if (absolute_volume > BT_AVRCP_MAX_ABSOLUTE_VOLUME) {
2218-
LOG_ERR("Invalid absolute volume: %d", absolute_volume);
2219-
return BT_AVRCP_STATUS_INVALID_PARAMETER;
2220-
}
2215+
/* PTS may Set command with bit 7 set in the absolute volume parameter invalid behavior */
2216+
absolute_volume &= BT_AVRCP_MAX_ABSOLUTE_VOLUME;
2217+
22212218
avrcp_tg_cb->set_absolute_volume(get_avrcp_tg(avrcp), tid, absolute_volume);
22222219
return BT_AVRCP_STATUS_OPERATION_COMPLETED;
22232220
}

0 commit comments

Comments
 (0)