Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12560723rwl; Tue, 3 Jan 2023 16:51:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXsaKsWDNfxnEWC4p232ckGFzUT+OeazWohhD7w6wu8zaZw9J/4IFFENNhdD+V/WJMQPYDWD X-Received: by 2002:a05:6a20:4995:b0:aa:7eab:25a5 with SMTP id fs21-20020a056a20499500b000aa7eab25a5mr51326088pzb.34.1672793464197; Tue, 03 Jan 2023 16:51:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672793464; cv=none; d=google.com; s=arc-20160816; b=isbJCZPt8p9PHtsS/pacI9x/7EFTPE7X9LSko5Fs7dq3Gex5mxOX2tvb51w/A/DEBK MRyO3cuNJMxA47cFq/sGN0yg33MX6n3+MSWiFywg/DipQUNKuYOL8xPmjmi7MaOc2qgJ 3H5ov2TQGusuFkL03z72iYIYPpjxJJWHz/WO7st0m+DDnnFKaR8jvAj+9GlV8BMIGqKL b3Lq0a72UVr/Eu5vecuXXpW5gdI+egjgIBCtyq7D1O1ETEljw1SJFkcLLJhQpfG9evA8 YfvDlfDNi6tSLmVg5k7pWOJH1iOtCP5rpZ+77KYoRBq4ob4cBJ88aR0s/gaPKOWIlDNK arSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Hz13+EskcgyouK62xEU1xMVMi/1CsedMBb94vxwuakU=; b=XIxZcwY7HcfeNADqfFTkTWxzhRae+7fhW3nmocv5P2+BUseP2tEOEE/XG8UFc0C1SO WCeZ8jjeYmGDr7SXLrTCBcxu9kQe4z7A9ayfx3gSMwGoQu7ezIh2cdkgmAT8R0vs1fAd gvYR/UNAAvbLVtWFE69UuPaM2tkXNetwNvNwtZ9pyJeoJz8ZxgVNVrukNvsmIjgAuTBB 5425EvDrBlJVh6ZVFEALqfJUhBfFYkeeZuiSi8TiN4JZvxKrhTdJQumnrJPBN1+yJbhw njzbiT5e5X0CxC4tpvIH0RuectNhQtlIrGuToHkJ+Qw/4kZMphCrkgTY8oZfMfbgm3e2 Hovg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ena+ZaIA; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a630005000000b0049ceafec8f7si18748513pga.447.2023.01.03.16.50.50; Tue, 03 Jan 2023 16:51:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ena+ZaIA; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238795AbjADAl7 (ORCPT + 99 others); Tue, 3 Jan 2023 19:41:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238842AbjADAl4 (ORCPT ); Tue, 3 Jan 2023 19:41:56 -0500 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39E6016586 for ; Tue, 3 Jan 2023 16:41:54 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id x37so27032499ljq.1 for ; Tue, 03 Jan 2023 16:41:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Hz13+EskcgyouK62xEU1xMVMi/1CsedMBb94vxwuakU=; b=ena+ZaIAB98AUexhXo/VDihcmr9rIUSDojrT+hISAatTdCFWS4maJtWyfQins41TtT ODH4ogz0M6T1Gqx4yMFn1IDzjd6he2oKHsdairZitAPAGef24OIf/uhsR7uqpcnXQMg+ rUD9i1nWTRjhwVmgvBvCAOyMniruzdsCg4S+WW/2dHQFl3TjKmUeZY5rfZ5gTDPz5fvF w9YauGSpLyYQFeQpU93u06WsaVnBmlRc3wLbf9fQzZ9LxnVYgRXTrCBqPuubQAE8QpBF df4tJPhYjEH8k1iWAeoKSxFh7YEmK1XQj63PizyaFFWnT7Wlv1gsGAbqqnHZvXBi9lKp Uifw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Hz13+EskcgyouK62xEU1xMVMi/1CsedMBb94vxwuakU=; b=TnfGLCbz9YuiOfgLwBlhXPjuJGL80uWmNJ73JDkSmXbKJvNN4R2YW3FxSDtRCX9zIb WXT3RZcd0fLvc4+eK3Coy9ULc52/HUF9qjKfsuAzrSPnBrL4qyB7dvyuD89Os05EOfo5 sU87UkcTqdOugt50ywEjp7gLt5Uu49gijO017iRqrB1+/EY2vMJ60Le75Nmd4TLkQMO+ PLHclWs35PBwYYCQwTz63AZjpgqP1We6ZITWvMRk1zdyKvZVQ9qUI966CWjOh8WweSNs F+Sjz7y1DaivUejgOSB55pbG+mOzqgTCre+kkLFTSC8R0d87FGz2UVx8TjKzQp3aiZFC tFFw== X-Gm-Message-State: AFqh2kq3/GrtVGgTjoy/db2rbGno80kgZZ1T5a4sxr6R+ZoY21+VN1jn jVnEFyNw+Jg1EIFU+n6rcwxz4QjbK9G9ePM63xs= X-Received: by 2002:a2e:9d89:0:b0:27f:ee1b:770b with SMTP id c9-20020a2e9d89000000b0027fee1b770bmr388046ljj.65.1672792912493; Tue, 03 Jan 2023 16:41:52 -0800 (PST) MIME-Version: 1.0 References: <20221229155257.341327-1-abhay.maheshbhai.maheta@intel.com> <20221229155257.341327-6-abhay.maheshbhai.maheta@intel.com> In-Reply-To: <20221229155257.341327-6-abhay.maheshbhai.maheta@intel.com> From: Luiz Augusto von Dentz Date: Tue, 3 Jan 2023 16:41:40 -0800 Message-ID: Subject: Re: [PATCH BlueZ v3 5/6] client/player: Add support for Company ID, Vendor ID To: Abhay Maheta Cc: linux-bluetooth@vger.kernel.org, Abhay Maheta Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Abhay, On Thu, Dec 29, 2022 at 7:58 AM Abhay Maheta wrote: > > This adds support for Company ID and Vendor Codec ID in BAP profile. > This also adds handling of Vendor Specific Coding format for BAP > Profile. > > Now it allows to enter zero codec capabilities. > In order to register zero codec capabilities, 0 shall be > entered when prompted. > > [bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0xff > [/local/endpoint/ep2] Enter Capabilities: 0 > [/local/endpoint/ep2] Enter Company ID & Vendor ID: 0xaabbccdd Lets do this a little differently: [capabilities...] endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0xccdd:0xaabb So you can detect if the user has entered a tuble by parsing ':', if it does you assume the Codec to be 0xff and use the tuple entered as Vendor otherwise you must omit the Vendor, which means you need to have a exists callback that returns cid && vid. > [/local/endpoint/ep2] Auto Accept (yes/no): y I don't think it makes any sense to Auto Accept in case of vendor codecs since we don't have presets for them, except if you want to default to custom preset which the user can change. > [/local/endpoint/ep2] CIG (auto/value): a > [/local/endpoint/ep2] CIS (auto/value): a > Endpoint /local/endpoint/ep2 registered > --- > client/player.c | 131 +++++++++++++++++++++++++++++++++++++++++------- > 1 file changed, 114 insertions(+), 17 deletions(-) > > diff --git a/client/player.c b/client/player.c > index eba233329..ff1ff209c 100644 > --- a/client/player.c > +++ b/client/player.c > @@ -66,6 +66,8 @@ struct endpoint { > char *path; > char *uuid; > uint8_t codec; > + uint16_t cid; > + uint16_t vid; > struct iovec *caps; > bool auto_accept; > bool acquiring; > @@ -85,6 +87,7 @@ static GList *endpoints = NULL; > static GList *local_endpoints = NULL; > static GList *transports = NULL; > static struct queue *ios = NULL; > +static bool is_cid_available = FALSE; > > struct transport { > GDBusProxy *proxy; > @@ -1815,7 +1818,8 @@ static void endpoint_free(void *data) > struct endpoint *ep = data; > > if (ep->caps) { > - g_free(ep->caps->iov_base); > + if (ep->caps->iov_base) > + g_free(ep->caps->iov_base); > g_free(ep->caps); > } > > @@ -1865,10 +1869,32 @@ static gboolean endpoint_get_capabilities(const GDBusPropertyTable *property, > return TRUE; > } > > +static gboolean endpoint_get_cid(const GDBusPropertyTable *property, > + DBusMessageIter *iter, void *data) > +{ > + struct endpoint *ep = data; > + > + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &ep->cid); > + > + return TRUE; > +} > + > +static gboolean endpoint_get_vid(const GDBusPropertyTable *property, > + DBusMessageIter *iter, void *data) > +{ > + struct endpoint *ep = data; > + > + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &ep->vid); > + > + return TRUE; > +} > + > static const GDBusPropertyTable endpoint_properties[] = { > { "UUID", "s", endpoint_get_uuid, NULL, NULL }, > { "Codec", "y", endpoint_get_codec, NULL, NULL }, > { "Capabilities", "ay", endpoint_get_capabilities, NULL, NULL }, > + { "CompanyID", "q", endpoint_get_cid, NULL, NULL }, > + { "VendorCodecID", "q", endpoint_get_vid, NULL, NULL }, > { } > }; > > @@ -1886,12 +1912,20 @@ static void register_endpoint_setup(DBusMessageIter *iter, void *user_data) > > g_dbus_dict_append_entry(&dict, "Codec", DBUS_TYPE_BYTE, &ep->codec); > > - g_dbus_dict_append_basic_array(&dict, DBUS_TYPE_STRING, &key, > + g_dbus_dict_append_entry(&dict, "CompanyID", DBUS_TYPE_UINT16, > + &ep->cid); > + > + g_dbus_dict_append_entry(&dict, "VendorCodecID", DBUS_TYPE_UINT16, > + &ep->vid); > + > + if (ep->caps->iov_len) { > + g_dbus_dict_append_basic_array(&dict, DBUS_TYPE_STRING, &key, > DBUS_TYPE_BYTE, &ep->caps->iov_base, > ep->caps->iov_len); > > - bt_shell_printf("Capabilities:\n"); > - bt_shell_hexdump(ep->caps->iov_base, ep->caps->iov_len); > + bt_shell_printf("Capabilities:\n"); > + bt_shell_hexdump(ep->caps->iov_base, ep->caps->iov_len); > + } > > dbus_message_iter_close_container(iter, &dict); > } > @@ -1950,6 +1984,21 @@ fail: > > } > > +static void get_cid_vid(const char *input, uint32_t *id) > +{ > + char *endptr = NULL; > + int value; > + > + value = strtol(input, &endptr, 0); > + > + if (!endptr || (char)*endptr != (char)'\0' || value > UINT32_MAX) { > + bt_shell_printf("Invalid argument: %s\n", input); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + *id = (uint32_t)value; > +} > + > static void endpoint_cis(const char *input, void *user_data) > { > struct endpoint *ep = user_data; > @@ -2010,19 +2059,55 @@ static void endpoint_auto_accept(const char *input, void *user_data) > bt_shell_prompt_input(ep->path, "CIG (auto/value):", endpoint_cig, ep); > } > > +static void endpoint_set_id(const char *input, void *user_data) > +{ > + struct endpoint *ep = user_data; > + uint32_t val; > + > + get_cid_vid(input, &val); > + ep->cid = (uint16_t)(val & 0x0000ffff); > + ep->vid = (uint16_t)((val & 0xffff0000) >> 16); > + > + bt_shell_prompt_input(ep->path, "Auto Accept (yes/no):", > + endpoint_auto_accept, ep); > +} > + > +static void endpoint_set_parameters(struct endpoint *ep) > +{ > + if (!(strcasecmp(ep->uuid, PAC_SINK_UUID)) || > + !(strcasecmp(ep->uuid, PAC_SOURCE_UUID))) { > + if ((ep->codec == 0xff) && (is_cid_available == FALSE)) > + bt_shell_prompt_input(ep->path, > + "Enter Company ID & Vendor ID:", > + endpoint_set_id, ep); > + else > + bt_shell_prompt_input(ep->path, "Auto Accept (yes/no):", > + endpoint_auto_accept, ep); > + } else > + bt_shell_prompt_input(ep->path, "Auto Accept (yes/no):", > + endpoint_auto_accept, ep); > +} > + > static void endpoint_set_capabilities(const char *input, void *user_data) > { > struct endpoint *ep = user_data; > > - if (ep->caps) > + if (ep->caps && ep->caps->iov_base) { > g_free(ep->caps->iov_base); > - else > + ep->caps = g_new0(struct iovec, 1); > + } else > ep->caps = g_new0(struct iovec, 1); > > ep->caps->iov_base = str2bytearray((char *) input, &ep->caps->iov_len); > > - bt_shell_prompt_input(ep->path, "Auto Accept (yes/no):", > - endpoint_auto_accept, ep); > + if (ep->caps->iov_len == 0x01 && > + (*(uint8_t *)(ep->caps->iov_base)) == 0x00) { > + g_free(ep->caps->iov_base); > + ep->caps->iov_base = NULL; > + ep->caps->iov_len = 0x00; > + } > + > + endpoint_set_parameters(ep); > } > > static char *uuid_generator(const char *text, int state) > @@ -2073,13 +2158,13 @@ static void cmd_register_endpoint(int argc, char *argv[]) > ep = g_new0(struct endpoint, 1); > ep->uuid = g_strdup(argv[1]); > ep->codec = strtol(argv[2], &endptr, 0); > + ep->cid = 0x0000; > + ep->vid = 0x0000; > ep->path = g_strdup_printf("%s/ep%u", BLUEZ_MEDIA_ENDPOINT_PATH, > g_list_length(local_endpoints)); > local_endpoints = g_list_append(local_endpoints, ep); > > - if (argc > 3) > - endpoint_set_capabilities(argv[3], ep); > - else { > + if (argc == 3) { > const struct capabilities *cap; > > cap = find_capabilities(ep->uuid, ep->codec); > @@ -2089,13 +2174,25 @@ static void cmd_register_endpoint(int argc, char *argv[]) > > /* Copy capabilities */ > iov_append(&ep->caps, cap->data.iov_base, > - cap->data.iov_len); > + cap->data.iov_len); > > - bt_shell_prompt_input(ep->path, "Auto Accept (yes/no):", > - endpoint_auto_accept, ep); > + endpoint_set_parameters(ep); > } else > - bt_shell_prompt_input(ep->path, "Enter capabilities:", > - endpoint_set_capabilities, ep); > + bt_shell_prompt_input(ep->path, "Enter Capabilities:", > + endpoint_set_capabilities, ep); > + } else if (argc == 4) { > + endpoint_set_capabilities(argv[3], ep); > + } else if (argc == 5) { > + uint32_t val = 0; > + > + get_cid_vid(argv[4], &val); > + ep->cid = (uint16_t)(val & 0x0000ffff); > + ep->vid = (uint16_t)((val & 0xffff0000) >> 16); > + is_cid_available = TRUE; > + > + endpoint_set_capabilities(argv[3], ep); > + > + is_cid_available = FALSE; > } > } > > @@ -2638,7 +2735,7 @@ static const struct bt_shell_menu endpoint_menu = { > { "show", "", cmd_show_endpoint, > "Endpoint information", > endpoint_generator }, > - { "register", " [capabilities...]", > + { "register", " [capabilities...] [Company ID]", > cmd_register_endpoint, > "Register Endpoint", > uuid_generator }, > -- > 2.25.1 > -- Luiz Augusto von Dentz