From patchwork Tue Nov 29 20:45:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13059162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7A02C4332F for ; Tue, 29 Nov 2022 20:46:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235900AbiK2UqC (ORCPT ); Tue, 29 Nov 2022 15:46:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232970AbiK2UqA (ORCPT ); Tue, 29 Nov 2022 15:46:00 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A5072657A for ; Tue, 29 Nov 2022 12:45:59 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d18so3817486pls.4 for ; Tue, 29 Nov 2022 12:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=rIuN04fzi/QvqGgsYhrpXfuUt7W+BqBRJCjrS+p5YYk=; b=iIS4kkzvcBoxVff78BFcY/TwsdgCr+SA1YI2noHW5DTgxfF7vLB6gasNTfU6E9OtZ8 bSjV2AKmL7DPqDqce9lOZgiG9kP9PseLTjkoMV7zi2DIbf6gqNmAOQ2tcDhkcNlwHBQM Fye82Edb3s74nqDHL4LcEgWzVRw8nYNg4WSJD5897GpFfv2I8AKYA1I9YYwtW7yT8VCs yUjVu0714Zwm/luY3zrt39nX79ubmpvSkNZ5hykih/cXLpE5vcYIQNktW7UwH65aBcb4 r6q3Cxtd0dF8I8RpHO/YpN9NY1HgbcJa8cdxFogiw4gMANmKNwNtcABfPvyAw/pFfBDq PJKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rIuN04fzi/QvqGgsYhrpXfuUt7W+BqBRJCjrS+p5YYk=; b=qeH19kTUS+eQHQIfc224gci6lo6El4ssP05O8Nw37sRaoPmfP65NAg0Nb21Cxy3K2q uWHQ/XUY0k+ERzNy376n+AOAAmwjgPdfY66MDmDyIG4lDG1d7EwYNv5uOCIK/0LSFZBe 9cksbk0RiM3QU9FEzj7yLsxe8t3trsCAO+FGfDbVJntaRvozJiqH/O5SlmWsGNNuPpHz sONd1m0hZJV5Q+4BR1tAOSMyvNoqm6+v1IuqGngthK0zBiR4n0Sk22YszS+g4kIT7zcq 9IAronPWekKCZSibGDKLtiKqWBlCiSJFMLUjnRt0kIpQoyKpk2Q7wH7dfp6BoKnzo5VD 14ng== X-Gm-Message-State: ANoB5pkmKOfevY30w8PYSS1pw7j33DLgYYLGRxRqkBkkj/bT5toZHqhs 2J6cCxR14nB+dn/ESywNfSifxEsOsA77BA== X-Google-Smtp-Source: AA0mqf7W527+rOn/359y1zjNHOBSqnvnPmcYCkTbODDxoxfpGlJr3EWqC/XhnY6ggLMeqEhJ+VJfsw== X-Received: by 2002:a17:902:ce90:b0:186:ab02:664c with SMTP id f16-20020a170902ce9000b00186ab02664cmr40647183plg.49.1669754758447; Tue, 29 Nov 2022 12:45:58 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id i7-20020a17090332c700b001887e30b9ddsm11216214plr.257.2022.11.29.12.45.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 12:45:57 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/5] shared/bap: Fix not reading all instances of PAC Sinks/Sources Date: Tue, 29 Nov 2022 12:45:52 -0800 Message-Id: <20221129204556.1535821-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz Both PAC Sink and Source are allowed to have multiple instances: - The server wanted to support a smaller maximum transmission unit (ATT_MTU, as defined in Volume 3, Part F, Section 3.2.8 in [2]) size. Exposing all supported PAC records in a single Sink PAC characteristic would require the server to increase its supported Maximum Transmission Unit (MTU) size to a value the server considered excessive. - The server wanted to expose support for proprietary audio capabilities (such as vendor-specific audio codecs, as denoted by the Codec_ID parameter value) separately from support for non-vendor-specific audio capabilities and used separate Sink PAC characteristics to expose such support. - The server wanted to minimize the amount of data to be transferred, when sending notifications to a client that the Sink PAC characteristic value changed, by exposing the audio capabilities likely to change quicker than others in separate Sink PAC characteristics. --- src/shared/bap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 21aa8aa6c5ca..7a24824a71fc 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -2908,10 +2908,12 @@ static void foreach_pacs_char(struct gatt_db_attribute *attr, void *user_data) DBG(bap, "Sink PAC found: handle 0x%04x", value_handle); pacs = bap_get_pacs(bap); - if (!pacs || pacs->sink) + if (!pacs) return; - pacs->sink = attr; + if (!pacs->sink) + pacs->sink = attr; + bap_read_value(bap, value_handle, read_sink_pac, bap); } @@ -2919,10 +2921,12 @@ static void foreach_pacs_char(struct gatt_db_attribute *attr, void *user_data) DBG(bap, "Source PAC found: handle 0x%04x", value_handle); pacs = bap_get_pacs(bap); - if (!pacs || pacs->source) + if (!pacs) return; - pacs->source = attr; + if (!pacs->source) + pacs->source = attr; + bap_read_value(bap, value_handle, read_source_pac, NULL); } From patchwork Tue Nov 29 20:45:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13059163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EA52C433FE for ; Tue, 29 Nov 2022 20:46:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235908AbiK2UqC (ORCPT ); Tue, 29 Nov 2022 15:46:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234423AbiK2UqB (ORCPT ); Tue, 29 Nov 2022 15:46:01 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3E32264AE for ; Tue, 29 Nov 2022 12:46:00 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id q71so14124532pgq.8 for ; Tue, 29 Nov 2022 12:46:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3I4QWhGq5+m0mrFdydgsfIx9xuQMIkAkxU6vd+76M+8=; b=Yjxv9jEr2dO6GmAjU4TbBNCKWyMq2D/lg9uW0+35Q6e4c5tgesC5ojjtaN2WrPdoRe e7X9QzXyV9fLpQmseejIUqtnSMIdo90uT873cYtjxr4NAaFxO8ak9sEBKvt7ErA+rVu3 wKhqtMDUXYRaPQAqd4jVF+rSqmRJFFZmTjeN1s8AND2A4Or+qzsb/EZ51uhH6HLmYRsk 8L5b+a/AKvP6jp1v1CjboxsSEGiFlhj3fF0ZYUu8WVN9ggSOtPFlzxBU8evNQY8csJho l60XOlJkc9vj9Y3HrX8Ax6K1nV0Dz31LJsnDvL4QrxxSv22t3veo3L+fwtu/p02g0rPc Ac/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3I4QWhGq5+m0mrFdydgsfIx9xuQMIkAkxU6vd+76M+8=; b=R2GfKRha0n2x5nfiwtFoibH17z5viwxpPs7Ales34JfWTkXGROzYdTqMyBaSqhSx92 lCaQEU34Fr1UmVgqF3yef8OjG5SVzlQQso0YBlI3JJQknRsOY44NLtbiZSqCBiEr9Ifp HsQc8KMpQBqKa1regIAxrhKjvExzuNCOjN7Ocd0uKQ27ISAMx9B+DGxR6CGvTBZVNpMy JpFsbcpCVYiloftLNiQobDWFO+m9bgKOM6aR8JF7iAOZKiEEtfBSxa4GgnDQD/lcdTH2 dg/vIBATin2c6q7PF6WzsFJNkgFzWMxArYx1EaxCYNOj408iiS7c3ZMTmNYVPVs3NkDa iSpg== X-Gm-Message-State: ANoB5pmgpDVgz29FSnWYSK8W+rQf3K1377Q9VXa80FqbbPd4tJFAOa4C WXfirjRNISk+v7pJJUO9ho/LCwmxawk2Zg== X-Google-Smtp-Source: AA0mqf5I6KYsUA5YcCIEqvA19e0FwZCDDL12VP2FH1pqVkIWvMbbFU78C8iZd5oY5EJlYacC0D2bIw== X-Received: by 2002:a63:2251:0:b0:476:cb2a:b99b with SMTP id t17-20020a632251000000b00476cb2ab99bmr52075953pgm.436.1669754759741; Tue, 29 Nov 2022 12:45:59 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id i7-20020a17090332c700b001887e30b9ddsm11216214plr.257.2022.11.29.12.45.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 12:45:58 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/5] shared/bap: Fix initiating QoS and Enable procedures as server Date: Tue, 29 Nov 2022 12:45:53 -0800 Message-Id: <20221129204556.1535821-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221129204556.1535821-1-luiz.dentz@gmail.com> References: <20221129204556.1535821-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz According to Table 3.2: ASE state machine transition these procedures can only be initated by clients. --- src/shared/bap.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 7a24824a71fc..f4812a4b9f51 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -4166,14 +4166,12 @@ unsigned int bt_bap_stream_qos(struct bt_bap_stream *stream, struct bt_ascs_qos qos; struct bt_bap_req *req; - if (!bap_stream_valid(stream)) + /* Table 3.2: ASE state machine transition + * Initiating device - client Only + */ + if (!bap_stream_valid(stream) || !stream->client) return 0; - if (!stream->client) { - stream_qos(stream, data, NULL); - return 0; - } - memset(&qos, 0, sizeof(qos)); /* TODO: Figure out how to pass these values around */ @@ -4259,14 +4257,12 @@ unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream, { int ret; - if (!bap_stream_valid(stream)) + /* Table 3.2: ASE state machine transition + * Initiating device - client Only + */ + if (!bap_stream_valid(stream) || !stream->client) return 0; - if (!stream->client) { - stream_enable(stream, metadata, NULL); - return 0; - } - ret = bap_stream_metadata(stream, BT_ASCS_ENABLE, metadata, func, user_data); if (!ret || !enable_links) From patchwork Tue Nov 29 20:45:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13059165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B58F1C433FE for ; Tue, 29 Nov 2022 20:46:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236024AbiK2UqF (ORCPT ); Tue, 29 Nov 2022 15:46:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231151AbiK2UqD (ORCPT ); Tue, 29 Nov 2022 15:46:03 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D4E42657A for ; Tue, 29 Nov 2022 12:46:02 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id d6so14612780pll.7 for ; Tue, 29 Nov 2022 12:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1k8zd+KfEy7WTuqeSNRLiiy/z9BkiSBTCI8VPd94acI=; b=mtDG19cDGChLI2yW/yiOXg9FFrAB/k1Yw6oq+As18sMgEvOoRMoPgaIrmoXVbVg7TR 5TMDiz+l/wllDrf57dxac3pvmvvfgxdU6XOGmGA4TNIkFs5ERtP5WKI+SnQzYle+v1et ZeQyeoOjD2R+RkB4Vu+1iJy8jTy5EXbSBzZy9T/jMt74zEKWjw6Wzm1VdxdZW6iyqOW3 TeDeAhZVL2fOQxaJlPGtjsfTFXpUVZJueG6EPdwVq9Nfjh7OPWwf8gyA5+u4BL2hkFo5 3Kg01cpyXhvw6vmKjSJ/LiCG6TafpaedODSc4nE5fJnS5kuJaLlOxDvK55Sll3EGRjkx 4bLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1k8zd+KfEy7WTuqeSNRLiiy/z9BkiSBTCI8VPd94acI=; b=Fl6H+aaVFh4SzBYjeSvxPE/MeVMC4tb7X67BI67c94BJ9unQ58luJuIsQucYvpBAUH tm4GtAPJqLfQC3bX85ST+mq3posxFVwU+0XHkPTojFXDuxVXFgTBpC9ZQ5GBUkvWyxNg +YHoHzOxmT8Yi31TKUtvKqaPPa7EQQaEmvtC/LzFXPoqT5flnQDqftVDZDO2NOwkzHRt rT9YyliUMXV2yrhua9ZvNPYevAdHc/szTe6hCSnpCj/+8WE17GSzWDhmT4IdckGcgWYp KGakj8uxCF6ihJTAfNPrBBZgGUWhCoTh7LovkZ1zsmgiaflr6F81R9cTyBN8LT1k7Jzp UX7A== X-Gm-Message-State: ANoB5pnotMrCZ8MeSLXsJNwo29+ECPBUMp9eWGkLdeHL4MIleSQaj+Pk ERwCNGkzNzmGbuRgjz26xlAhYwDKiQrEHg== X-Google-Smtp-Source: AA0mqf4RnlZ/KtwJ3rHE7Dx7aAGiEuFbWA0GNH2Y/z3WoAtzaCmZH3/TxcxGcrdxUVDVaMDLbAbDwg== X-Received: by 2002:a17:903:240b:b0:186:9fc5:6c2c with SMTP id e11-20020a170903240b00b001869fc56c2cmr38789710plo.174.1669754760921; Tue, 29 Nov 2022 12:46:00 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id i7-20020a17090332c700b001887e30b9ddsm11216214plr.257.2022.11.29.12.45.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 12:46:00 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 3/5] client/player: Add support for custom preset Date: Tue, 29 Nov 2022 12:45:54 -0800 Message-Id: <20221129204556.1535821-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221129204556.1535821-1-luiz.dentz@gmail.com> References: <20221129204556.1535821-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds support for a custom preset which asks the user to enter its configuration: [bluetooth]# endpoint.presets 00002bc9-0000-1000-8000-00805f9b34fb custom [Codec] Enter frequency: 0x08 [Codec] Enter frame duration: 0x01 [Codec] Enter channel allocation: 0x00000003 [Codec] Enter frame length: 100 [QoS] Enter SDU Interval: 10000 [QoS] Enter Framing: 0x00 [QoS] Enter PHY: 2M [QoS] Enter Max SDU: 100 [QoS] Enter RTN: 2 [QoS] Enter Max Transport Latency: 20 [QoS] Enter Presentation Delay: 10000 --- client/player.c | 305 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 261 insertions(+), 44 deletions(-) diff --git a/client/player.c b/client/player.c index 51c10f8e0a23..952b01e8236b 100644 --- a/client/player.c +++ b/client/player.c @@ -1231,7 +1231,6 @@ struct codec_preset { const char *name; const struct iovec data; const struct codec_qos qos; - bool is_default; uint8_t latency; }; @@ -1241,13 +1240,6 @@ struct codec_preset { .data = _data, \ } -#define SBC_DEFAULT_PRESET(_name, _data) \ - { \ - .name = _name, \ - .data = _data, \ - .is_default = true, \ - } - static struct codec_preset sbc_presets[] = { /* Table 4.7: Recommended sets of SBC parameters in the SRC device * Other settings: Block length = 16, Allocation method = Loudness, @@ -1268,7 +1260,7 @@ static struct codec_preset sbc_presets[] = { CODEC_DATA(0x28, 0x15, 2, SBC_BITPOOL_HQ_MONO_44100)), SBC_PRESET("HQ_MONO_48", CODEC_DATA(0x18, 0x15, 2, SBC_BITPOOL_HQ_MONO_48000)), - SBC_DEFAULT_PRESET("HQ_STEREO_44_1", + SBC_PRESET("HQ_STEREO_44_1", CODEC_DATA(0x21, 0x15, 2, SBC_BITPOOL_HQ_JOINT_STEREO_44100)), SBC_PRESET("HQ_STEREO_48", CODEC_DATA(0x11, 0x15, 2, SBC_BITPOOL_HQ_JOINT_STEREO_48000)), @@ -1379,15 +1371,6 @@ static struct codec_preset sbc_presets[] = { .latency = 0x03, \ } -#define LC3_DEFAULT_PRESET(_name, _data, _qos) \ - { \ - .name = _name, \ - .data = _data, \ - .is_default = true, \ - .qos = _qos, \ - .latency = 0x02, \ - } - static struct codec_preset lc3_presets[] = { /* Table 4.43: QoS configuration support setting requirements */ LC3_PRESET("8_1_1", @@ -1399,7 +1382,7 @@ static struct codec_preset lc3_presets[] = { LC3_PRESET("16_1_1", LC3_PRESET_16KHZ(LC3_CONFIG_DURATION_7_5, 30u), LC3_7_5_UNFRAMED(30u, 2u, 8u, 40000u)), - LC3_DEFAULT_PRESET("16_2_1", + LC3_PRESET("16_2_1", LC3_PRESET_16KHZ(LC3_CONFIG_DURATION_10, 40u), LC3_10_UNFRAMED(40u, 2u, 10u, 40000u)), LC3_PRESET("24_1_1", @@ -1465,22 +1448,26 @@ static struct codec_preset lc3_presets[] = { LC3_10_UNFRAMED(155u, 23u, 60u, 40000u)), }; -#define PRESET(_uuid, _presets) \ +#define PRESET(_uuid, _presets, _default_index) \ { \ .uuid = _uuid, \ + .custom = { .name = "custom" }, \ + .default_preset = &_presets[_default_index], \ .presets = _presets, \ .num_presets = ARRAY_SIZE(_presets), \ } -static const struct preset { +static struct preset { const char *uuid; + struct codec_preset custom; + struct codec_preset *default_preset; struct codec_preset *presets; size_t num_presets; } presets[] = { - PRESET(A2DP_SOURCE_UUID, sbc_presets), - PRESET(A2DP_SINK_UUID, sbc_presets), - PRESET(PAC_SINK_UUID, lc3_presets), - PRESET(PAC_SOURCE_UUID, lc3_presets), + PRESET(A2DP_SOURCE_UUID, sbc_presets, 6), + PRESET(A2DP_SINK_UUID, sbc_presets, 6), + PRESET(PAC_SINK_UUID, lc3_presets, 3), + PRESET(PAC_SOURCE_UUID, lc3_presets, 3), }; static struct codec_preset *find_preset(const char *uuid, const char *name) @@ -1488,20 +1475,22 @@ static struct codec_preset *find_preset(const char *uuid, const char *name) size_t i; for (i = 0; i < ARRAY_SIZE(presets); i++) { - const struct preset *preset = &presets[i]; + struct preset *preset = &presets[i]; if (!strcasecmp(preset->uuid, uuid)) { size_t j; + if (!name) + return preset->default_preset; + else if (!strcmp(name, "custom")) + return &preset->custom; + for (j = 0; j < preset->num_presets; j++) { struct codec_preset *p; p = &preset->presets[j]; - if (!name) { - if (p->is_default) - return p; - } else if (!strcmp(p->name, name)) + if (!strcmp(p->name, name)) return p; } } @@ -1724,10 +1713,11 @@ done: static struct iovec *iov_append(struct iovec **iov, const void *data, size_t len) { - if (!*iov) { + if (!*iov) *iov = new0(struct iovec, 1); + + if (!((*iov)->iov_base)) (*iov)->iov_base = new0(uint8_t, UINT8_MAX); - } if (data && len) { memcpy((*iov)->iov_base + (*iov)->iov_len, data, len); @@ -2348,6 +2338,224 @@ fail: return bt_shell_noninteractive_quit(EXIT_FAILURE); } +static void custom_delay(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct codec_qos *qos = (void *)&p->qos; + char *endptr = NULL; + + qos->delay = strtol(input, &endptr, 0); + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void custom_latency(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct codec_qos *qos = (void *)&p->qos; + char *endptr = NULL; + + qos->latency = strtol(input, &endptr, 0); + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + bt_shell_prompt_input("QoS", "Enter Presentation Delay:", + custom_delay, user_data); +} + +static void custom_rtn(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct codec_qos *qos = (void *)&p->qos; + char *endptr = NULL; + + qos->rtn = strtol(input, &endptr, 0); + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + bt_shell_prompt_input("QoS", "Enter Max Transport Latency:", + custom_latency, user_data); +} + +static void custom_sdu(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct codec_qos *qos = (void *)&p->qos; + char *endptr = NULL; + + qos->sdu = strtol(input, &endptr, 0); + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + bt_shell_prompt_input("QoS", "Enter RTN:", custom_rtn, user_data); +} + +static void custom_phy(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct codec_qos *qos = (void *)&p->qos; + + if (!strcmp(input, "1M")) + qos->phy = "1M"; + else if (!strcmp(input, "2M")) + qos->phy = "2M"; + else { + char *endptr = NULL; + uint8_t phy = strtol(input, &endptr, 0); + + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + switch (phy) { + case 0x01: + qos->phy = "1M"; + break; + case 0x02: + qos->phy = "2M"; + break; + default: + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + } + + bt_shell_prompt_input("QoS", "Enter Max SDU:", custom_sdu, user_data); +} + +static void custom_framing(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct codec_qos *qos = (void *)&p->qos; + char *endptr = NULL; + + qos->framing = strtol(input, &endptr, 0); + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + bt_shell_prompt_input("QoS", "Enter PHY:", custom_phy, user_data); +} + +static void custom_interval(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct codec_qos *qos = (void *)&p->qos; + char *endptr = NULL; + + qos->interval = strtol(input, &endptr, 0); + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + bt_shell_prompt_input("QoS", "Enter Framing:", + custom_framing, user_data); +} + +static void custom_length(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct iovec *iov = (void *)&p->data; + uint8_t ltv[4] = { 0x03, LC3_CONFIG_FRAME_LEN }; + uint16_t len; + char *endptr = NULL; + + len = strtol(input, &endptr, 0); + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + ltv[2] = len; + ltv[3] = len >> 8; + + iov_append(&iov, ltv, sizeof(ltv)); + + bt_shell_prompt_input("QoS", "Enter SDU Interval:", + custom_interval, user_data); +} + +static void custom_location(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct iovec *iov = (void *)&p->data; + uint32_t location; + char *endptr = NULL; + + location = strtol(input, &endptr, 0); + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + /* Only add Channel Allocation if set */ + if (location) { + uint8_t ltv[6] = { 0x05, LC3_CONFIG_CHAN_ALLOC }; + + location = cpu_to_le32(location); + memcpy(<v[2], &location, sizeof(location)); + iov_append(&iov, ltv, sizeof(ltv)); + } + + bt_shell_prompt_input("Codec", "Enter frame length:", + custom_length, user_data); +} + +static void custom_duration(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct iovec *iov = (void *)&p->data; + uint8_t ltv[3] = { 0x02, LC3_CONFIG_DURATION, 0x00 }; + char *endptr = NULL; + + ltv[2] = strtol(input, &endptr, 0); + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + iov_append(&iov, ltv, sizeof(ltv)); + + bt_shell_prompt_input("Codec", "Enter channel allocation:", + custom_location, user_data); +} + +static void custom_frequency(const char *input, void *user_data) +{ + struct codec_preset *p = user_data; + struct iovec *iov = (void *)&p->data; + uint8_t ltv[3] = { 0x02, LC3_CONFIG_FREQ, 0x00 }; + char *endptr = NULL; + + ltv[2] = strtol(input, &endptr, 0); + if (!endptr || *endptr != '\0') { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + /* Reset iov to start over the codec configuration */ + free(iov->iov_base); + iov->iov_base = NULL; + iov->iov_len = 0; + iov_append(&iov, ltv, sizeof(ltv)); + + bt_shell_prompt_input("Codec", "Enter frame duration:", + custom_duration, user_data); +} + static void cmd_presets_endpoint(int argc, char *argv[]) { size_t i; @@ -2359,32 +2567,41 @@ static void cmd_presets_endpoint(int argc, char *argv[]) bt_shell_printf("Preset %s not found\n", argv[2]); return bt_shell_noninteractive_quit(EXIT_FAILURE); } - - default_preset->is_default = true; } for (i = 0; i < ARRAY_SIZE(presets); i++) { - const struct preset *preset = &presets[i]; + struct preset *preset = &presets[i]; if (!strcasecmp(preset->uuid, argv[1])) { size_t j; + struct codec_preset *p; + + if (default_preset) { + preset->default_preset = default_preset; + break; + } + + p = &preset->custom; + + bt_shell_printf("%s%s\n", p == preset->default_preset ? + "*" : "", p->name); for (j = 0; j < preset->num_presets; j++) { - struct codec_preset *p; - p = &preset->presets[j]; - if (default_preset && p != default_preset) - p->is_default = false; - - if (p->is_default) - bt_shell_printf("*%s\n", p->name); - else - bt_shell_printf("%s\n", p->name); + bt_shell_printf("%s%s\n", + p == preset->default_preset ? + "*" : "", p->name); } } } + if (default_preset && !strcmp(default_preset->name, "custom")) { + bt_shell_prompt_input("Codec", "Enter frequency:", + custom_frequency, default_preset); + return; + } + return bt_shell_noninteractive_quit(EXIT_SUCCESS); } From patchwork Tue Nov 29 20:45:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13059164 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6314C4332F for ; Tue, 29 Nov 2022 20:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235990AbiK2UqF (ORCPT ); Tue, 29 Nov 2022 15:46:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234423AbiK2UqD (ORCPT ); Tue, 29 Nov 2022 15:46:03 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3392527B34 for ; Tue, 29 Nov 2022 12:46:03 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id g10so14603476plo.11 for ; Tue, 29 Nov 2022 12:46:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uipxcqFe+9TjstR7zL9pYMpnpbO4FjPsAnDw9doWmUg=; b=VuzLwGHu7NelXnYVXfw/9BgA6ker3L+99AXnn6WiwY9eRc3SNVNsHBqf91Q3Td7f/M 3Fa3UeuCf1EgNvkNMuoX7TVhNHRx5NoW5WlAakA226BaP6q0wb75Mijo6/ey8pvTxkWO du0eu74Tz+fhCMLEte6Af+Gwr589zB9aQg0nvLRP2+1En9HmQ3xi8Q6wOCiCSDGQ3uPh zqOzl+ItnCx3YUaU2e1eO3vQaDiSralSqGkowu0LrpwDDBHmeW7m6SavdKXK/H3YObAN qWTEP9P8UDWEfcYNnW1pZxh4Gv3fOpY4Z9c8L6ElhR14rQflyGgHod8vswP7/oG5p7Kv 0f+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uipxcqFe+9TjstR7zL9pYMpnpbO4FjPsAnDw9doWmUg=; b=l3F3mjQrHcCyhH3b3o5khcXvpg23r/PMuHjSz/htn1NFYyGCN+1aJdIgs00dhi3hOh Of8DgmNTUkS6Pmw8mIafho7Eb/eLhyQAtiTKfEVsWRbAPf2Uvi7kooQb8plvUHMg3vXO +w+KYi9TOebDp7M2IdSQuboAFassqFt5geV80yitcmrIrYDdm68JnYxM/FezAnUDm5ZU r2uVJ5TM9ac99bt+UkXqUBxPvouf9tbOj53purm2pbqZv5ENL1VVdK9RI9VhY+ztj8S7 Lf4KjBOc9cLou/XcREew8iEplWqXdG2Mqy/fP3g8GKH80QN/t5/0khbex8ULLp3i5dtS rl7w== X-Gm-Message-State: ANoB5pmikA7RuR29b+FzKykqfSoAF+XrGpo8A6K90rMqip3ovqGU/V0E qRJIwsY77MOxU6U1E3eBxQQTHjZUpWABmQ== X-Google-Smtp-Source: AA0mqf7hjBMrL8YZazNgGgOR3omIM5fVv/6i+5PE6xhFtL/CQ7GKhx87CY+mL/6nKBGLVCNcbb84fg== X-Received: by 2002:a17:902:aa07:b0:186:a97d:6bcc with SMTP id be7-20020a170902aa0700b00186a97d6bccmr39301765plb.121.1669754762181; Tue, 29 Nov 2022 12:46:02 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id i7-20020a17090332c700b001887e30b9ddsm11216214plr.257.2022.11.29.12.46.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 12:46:01 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/5] bap: Fix not able to reconfigure Date: Tue, 29 Nov 2022 12:45:55 -0800 Message-Id: <20221129204556.1535821-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221129204556.1535821-1-luiz.dentz@gmail.com> References: <20221129204556.1535821-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz While attempting to configure QoS setting the request id is not reset to 0 when a response is received which prevents any the QoS to be reconfigured. --- profiles/audio/bap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 67aba3bd76d9..9cee9fd030da 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -366,6 +366,8 @@ static void qos_cb(struct bt_bap_stream *stream, uint8_t code, uint8_t reason, DBG("stream %p code 0x%02x reason 0x%02x", stream, code, reason); + ep->id = 0; + if (!ep->msg) return; From patchwork Tue Nov 29 20:45:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13059166 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAC82C4167B for ; Tue, 29 Nov 2022 20:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236031AbiK2UqH (ORCPT ); Tue, 29 Nov 2022 15:46:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235992AbiK2UqF (ORCPT ); Tue, 29 Nov 2022 15:46:05 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76AED2D750 for ; Tue, 29 Nov 2022 12:46:04 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id s196so14146084pgs.3 for ; Tue, 29 Nov 2022 12:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=CrUIIPrBTmjyCzYKfPEzVfSCr2e2mHMZ7ZkF84d/32s=; b=LJGbEhNHBXgz3Z00yyXf9eaIZScNuqmvgveZsbb6mZuvaUB++bUemzfOQV6Z+KA1ux ZHA+zdYisisfo14GmRkrdpNq8PmJlXh/Mt69I0rxMJpiYSlGicexEreqGE+8HRU/fG79 nWQpOIN1JfmFlg5GtwgyB0YG4Ku00su4TfW5hZSCibZqe+wwx+7hFTwr4LZncYIsxpeh axAyFwFp9xU9KQE8W8NH+BA2dCmuosKEfcQ9dh1YG4LI9BiRq2ZY9xfMFYL8lDFTFvXS +Mxrxa8sfbN30mZLSZerYyBAynwptcvlbuBeeNA6HU5LeFYZL2yG0mspST5thazUkZ4S yC/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CrUIIPrBTmjyCzYKfPEzVfSCr2e2mHMZ7ZkF84d/32s=; b=BMRAgDdAB2B6vrjn4OigmkQZO0TJhhPm28L5P34JolvqFjZo66rssO8rypGFFFrepQ J9HthT2fKWrQvHMcXXhycJGr17WkcFTyqIcnyunQTvrflUaJuEI42FuQEjZD5UZiwGcz SH+H7dg8NUg6kyGfeFfj5U1vBsfHLs5MCKtYOzs1r5Qyn4/xe1E5q88DHKX1gXkr3ahH hNnBwflWTXYdae+JCQzAiTxFxCcR3DdV8UYAMY01baULcXbaggyPRU4qRxwv2xDfpMDX pKv4dMdlU9DicNe9zN6CGyReoYaaOKCtu5K4QnZZjNSmXfpwjFIX6X6c9aH47INt/nNx RP5A== X-Gm-Message-State: ANoB5plxSXBdOnXPptjiSuWsABA72RBV8RVukQlpCbMbD3/gYvSpVeS1 ADvAZi8MwWh9L4tCUNVt0V2uxrlhIQhyYw== X-Google-Smtp-Source: AA0mqf627YRw/6klxq43+QuZZuKQttt8eW8dORVG4CtuUtbDlyIoUA8ZV+GaSLj82TydMuwhVwGhHQ== X-Received: by 2002:aa7:96d2:0:b0:574:2447:947d with SMTP id h18-20020aa796d2000000b005742447947dmr35929082pfq.32.1669754763418; Tue, 29 Nov 2022 12:46:03 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id i7-20020a17090332c700b001887e30b9ddsm11216214plr.257.2022.11.29.12.46.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 12:46:02 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 5/5] media: Fix crash when transport configuration changes Date: Tue, 29 Nov 2022 12:45:56 -0800 Message-Id: <20221129204556.1535821-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221129204556.1535821-1-luiz.dentz@gmail.com> References: <20221129204556.1535821-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz In case of BAP the same transport may be reconfigured multiple times which means it would appears multiple times on endpoint->transports leading to a crash when disconnecting as the code would attempt to destroy the same object multiple times. --- profiles/audio/media.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index c9328ab9bd6e..6947cf96392e 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1057,6 +1057,8 @@ static int pac_config(struct bt_bap_stream *stream, struct iovec *cfg, path = media_transport_get_path(transport); bt_bap_stream_set_user_data(stream, (void *)path); + endpoint->transports = g_slist_append(endpoint->transports, + transport); } msg = dbus_message_new_method_call(endpoint->sender, endpoint->path, @@ -1064,7 +1066,7 @@ static int pac_config(struct bt_bap_stream *stream, struct iovec *cfg, "SetConfiguration"); if (msg == NULL) { error("Couldn't allocate D-Bus message"); - media_transport_destroy(transport); + endpoint_remove_transport(endpoint, transport); return FALSE; } @@ -1073,8 +1075,6 @@ static int pac_config(struct bt_bap_stream *stream, struct iovec *cfg, data->cb = cb; data->user_data = user_data; - endpoint->transports = g_slist_append(endpoint->transports, transport); - dbus_message_iter_init_append(msg, &iter); path = media_transport_get_path(transport);