client/player: Set number of channels based on locations
Luiz Augusto von Dentz
maintainerPATCH 1/2 client/player: Set number of channels based on locations
From: Luiz Augusto von Dentz <[email protected]>
This sets the number of channels based on the locations set rather than always hardcoding it to 3 which in certain case is incorrect and can lead for the same location to be configured multiple times.
--- client/player.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
client/player.c +16 -7
@@ -1140,10 +1140,9 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, .meta = _meta, \ } -#define LC3_DATA (_freq, _duration, _chan_count, _len_min, _len_max) \ +#define LC3_DATA (_freq, _duration, _len_min, _len_max) \ UTIL_IOV_INIT(0x03, LC3_FREQ, _freq, _freq >> 8, \ 0x02, LC3_DURATION, _duration, \ - 0x02, LC3_CHAN_COUNT, _chan_count, \ 0x05, LC3_FRAME_LEN, _len_min, _len_min >> 8, \ _len_max, _len_max >> 8)
@@ -1182,11 +1181,10 @@ static const struct capabilities {* * Frequencies: 8Khz 11Khz 16Khz 22Khz 24Khz 32Khz 44.1Khz 48Khz * Duration: 7.5 ms 10 ms -* Channel count: 3 * Frame length: 26-240 */ CODEC_CAPABILITIES ("pac_snk/lc3" ,PAC_SINK_UUID ,LC3_ID , -LC3_DATA (LC3_FREQ_ANY ,LC3_DURATION_ANY ,3u ,26 , +LC3_DATA (LC3_FREQ_ANY ,LC3_DURATION_ANY ,26 ,240 ), UTIL_IOV_INIT()),
@@ -1198,7 +1196,7 @@ static const struct capabilities {* Frame length: 26-240 */ CODEC_CAPABILITIES ("pac_src/lc3" ,PAC_SOURCE_UUID ,LC3_ID , -LC3_DATA (LC3_FREQ_ANY ,LC3_DURATION_ANY ,3u ,26 , +LC3_DATA (LC3_FREQ_ANY ,LC3_DURATION_ANY ,26 ,240 ), UTIL_IOV_INIT()),
@@ -1210,7 +1208,7 @@ static const struct capabilities {* Frame length: 26-240 */ CODEC_CAPABILITIES ("bcaa/lc3" ,BCAA_SERVICE_UUID ,LC3_ID , -LC3_DATA (LC3_FREQ_ANY ,LC3_DURATION_ANY ,3u ,26 , +LC3_DATA (LC3_FREQ_ANY ,LC3_DURATION_ANY ,26 ,240 ), UTIL_IOV_INIT()),
@@ -1222,7 +1220,7 @@ static const struct capabilities {* Frame length: 26-240 */ CODEC_CAPABILITIES ("baa/lc3" ,BAA_SERVICE_UUID ,LC3_ID , -LC3_DATA (LC3_FREQ_ANY ,LC3_DURATION_ANY ,3u ,26 , +LC3_DATA (LC3_FREQ_ANY ,LC3_DURATION_ANY ,26 ,240 ), UTIL_IOV_INIT()), };
@@ -3220,6 +3218,7 @@ static void endpoint_locations(const char *input, void *user_data)struct endpoint *ep = user_data;char *endptr =NULL ;int value; +uint8_t channels; value =strtol (input, &endptr,0 );
@@ -3230,6 +3229,10 @@ static void endpoint_locations(const char *input, void *user_data) ep->locations = value; +/* Update LC3_CHAN_COUNT based on the locations */ + channels =__builtin_popcount (value); +util_ltv_push (ep->caps,sizeof (channels),LC3_CHAN_COUNT , &channels); +bt_shell_prompt_input (ep->path,"Supported Context (value):" , endpoint_supported_context, ep); }
@@ -4186,6 +4189,8 @@ static const struct bt_shell_menu endpoint_menu = {static void endpoint_init_bcast (struct endpoint *ep) { +uint8_t channels; +if (!strcmp (ep->uuid,BAA_SERVICE_UUID )) { ep->locations =EP_SNK_LOCATIONS ; ep->supported_context =EP_SUPPORTED_SNK_CTXT ;
@@ -4193,6 +4198,10 @@ static void endpoint_init_bcast(struct endpoint *ep) ep->locations =EP_SRC_LOCATIONS ; ep->supported_context =EP_SUPPORTED_SRC_CTXT ; } + +/* Update LC3_CHAN_COUNT based on the locations */ + channels =__builtin_popcount (ep->locations); +util_ltv_push (ep->caps,sizeof (channels),LC3_CHAN_COUNT , &channels); }static void endpoint_init_ucast (struct endpoint *ep)
Signature · 1 line
2.45.2
Luiz Augusto von Dentz
maintainerPATCH 2/2 client/player: Add support to enter alternative preset
From: Luiz Augusto von Dentz <[email protected]>
This adds support for alternative preset to be entered so when auto accepting configuration a different preset can be selected following the order given to endpoint.presets.
--- client/player.c | 74 ++++++++++++++++++++++++++++++++++++++++++++---- src/shared/bap.c | 2 +- 2 files changed, 70 insertions(+), 6 deletions(-)
client/player.c +69 -5
@@ -1230,7 +1230,10 @@ struct codec_preset {const struct iovec data;struct bt_bap_qos qos;uint8_t target_latency; +uint32_t chan_alloc;bool custom; +bool alt; +struct codec_preset *alt_preset; };#define SBC_PRESET (_name, _data) \
@@ -1969,12 +1972,18 @@ static int parse_chan_alloc(DBusMessageIter *iter, uint32_t *location,if (*channels) *channels =__builtin_popcount (*location);return 0 ; + }else if (!strcasecmp (key,"Locations" )) { +if (var !=DBUS_TYPE_UINT32 ) +return -EINVAL ; +dbus_message_iter_get_basic (&value, location); +if (*channels) + *channels =__builtin_popcount (*location); }dbus_message_iter_next (iter); } -return -EINVAL ; +return *location ?0 : -EINVAL ; } static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep,
@@ -2010,6 +2019,24 @@ static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep,0x05 ,LC3_CONFIG_CHAN_ALLOC , location &0xff , location >> 8, location >> 16, location >> 24 }; +uint32_t chan_alloc =0 ; + +if (preset->chan_alloc & location) + chan_alloc = preset->chan_alloc & location; +else if (preset->alt_preset && + preset->alt_preset->chan_alloc & + location) { + chan_alloc = preset->alt_preset->chan_alloc & location; + preset = preset->alt_preset; + +/* Copy alternate capabilities */ +util_iov_free (cfg->caps,1 ); + cfg->caps =util_iov_dup (&preset->data,1 ); + cfg->target_latency = preset->target_latency; + } + +if (chan_alloc) +put_le32 (chan_alloc, &chan_alloc_ltv[2 ]);util_iov_append (cfg->caps, &chan_alloc_ltv,sizeof (chan_alloc_ltv));
@@ -2035,6 +2062,8 @@ static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep,dbus_message_iter_init_append (reply, &iter); +bt_shell_printf ("selecting %s...\n" , preset->name); +append_properties (&iter, cfg);free (cfg);
@@ -2098,8 +2127,6 @@ static DBusMessage *endpoint_select_properties(DBusConnection *conn,if (!reply)return NULL ; -bt_shell_printf ("Auto Accepting using %s...\n" , p->name); -return reply; }
@@ -4104,13 +4131,38 @@ static void print_presets(struct preset *preset)for (i =0 ; i < preset->num_presets; i++) { p = &preset->presets[i]; -bt_shell_printf ("%s%s\n" , p == preset->default_preset ? -"*" :"" , p->name); + +if (p == preset->default_preset) +bt_shell_printf ("*%s\n" , p->name); +else if (preset->default_preset && + p == preset->default_preset->alt_preset) +bt_shell_printf ("**%s\n" , p->name); +else +bt_shell_printf ("%s\n" , p->name); }queue_foreach (preset->custom, foreach_custom_preset_print, preset); } +static void custom_chan_alloc (const char *input,void *user_data) +{ +struct codec_preset *p = user_data; +char *endptr =NULL ; + + p->chan_alloc =strtol (input, &endptr,0 ); +if (!endptr || *endptr !='\0' ) { +bt_shell_printf ("Invalid argument: %s\n" , input); +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + } + +if (p->alt_preset) +bt_shell_prompt_input (p->alt_preset->name, +"Enter Channel Allocation: " , + custom_chan_alloc, p->alt_preset); +else +return bt_shell_noninteractive_quit (EXIT_SUCCESS ); +} +static void cmd_presets_endpoint (int argc,char *argv[]) {struct preset *preset;
@@ -4131,8 +4183,20 @@ static void cmd_presets_endpoint(int argc, char *argv[]) preset->default_preset = default_preset;if (argc >4 ) { +struct codec_preset *alt_preset;struct iovec *iov = (void *)&default_preset->data; +/* Check if and alternative preset was given */ + alt_preset =preset_find_name (preset, argv[4 ]); +if (alt_preset) { + default_preset->alt_preset = alt_preset; +bt_shell_prompt_input (default_preset->name, +"Enter Channel Allocation: " , + custom_chan_alloc, + default_preset); +return ; + } + iov->iov_base =str2bytearray (argv[4 ], &iov->iov_len);if (!iov->iov_base) { bt_shell_printf("Invalid configuration %s\n",
src/shared/bap.c +1 -1
@@ -5420,7 +5420,7 @@ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, selected++;/* Check if there are any channels left to select */ - map.count &= ~(map.count & rc->count); + map.count &= ~(map.count & rc->count);/* Check if there are any locations left to select */ map.location &= ~(map.location & rc->location);
Signature · 1 line
2.45.2
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=873055
---Test result---
Test Summary:
CheckPatch PASS 0.67 seconds GitLint PASS 0.43 seconds BuildEll PASS 24.65 seconds BluezMake PASS 1682.46 seconds MakeCheck PASS 13.35 seconds MakeDistcheck PASS 180.74 seconds CheckValgrind PASS 254.55 seconds CheckSmatch WARNING 358.83 seconds bluezmakeextell PASS 120.76 seconds IncrementalBuild PASS 3061.50 seconds ScanBuild PASS 1051.04 seconds
Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:src/shared/bap.c:288:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:288:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:288:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures
---
Regards,
Linux Bluetooth