Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1802080rdh; Sat, 28 Oct 2023 07:42:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4gH1uYGCXPhF8jZKMP31ArvrAYQIUXbNqy9FpK4e5oEohgTN7fIAREmoOQl5cAKdgse5C X-Received: by 2002:a05:6a20:7483:b0:16b:e46e:1246 with SMTP id p3-20020a056a20748300b0016be46e1246mr6638920pzd.30.1698504166360; Sat, 28 Oct 2023 07:42:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698504166; cv=pass; d=google.com; s=arc-20160816; b=YuBpGcKRQjZIloDlgzXSbVRhydMfDUo5f9IYf8eSUFFSgsUE8FSD4JmcVMb6fa5Pd/ M5bYfbthSSjBOwMiVIaU+L7GqIt26QM7N+bFAivdhLXhL3ILqg0ypzae0OoZRCksOwNN FpJvsp2xnhSxAwe/7f37q8gvEqpKlQmZWDsbf/HNFK+iqyR7YHUrmaCKaD0DSFEYpxCw T/hEU4yEDYco1euKiHVcUFu6XTeOV3CwlKrMvER3FZX+TjI9dUqoRETb1f7TSwj8ovei y/O48R/DV6m0d9kB9YSADvWTNVSGaS3s8Y+uvG5Mx+rf6If696qjZ1jZ80xCMxJX71eJ /4aQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=82Pvx/CWmqLa+M7kmnpR+VTuTlcjdGYixQptc74mRdU=; fh=ExGhjNQEFJgRqHmYATVc5UXZbS7abAmaHDitrfHKOuE=; b=InnMbuRzSlBA4Af/mPPIdmTzl9HjOte/txE8aRRmhzj1DIhq9vTN8iHGc/Y+4bESCc un58lvenazVCC48Yz8JKik2OSs6L0z05oVP1eKF+keC+IKbOdRVX7LfLMoCu1p/eaY0i g8Yxz8MBBdNhp6xI/9Ib2aCHXQNkSO2VPJ14TZB4p+zCWsk37BrLV81EB5u+Aq8CBylz fUmElzW/bpx+fefCJD/pseOz0cXmX18aAqmnvEWv3g6zV/FKocdm+6jDVaRgta5BQzXa 9zSOmdIUkjzJX3TFShbQ7KVKAEeG8M+fjvjOKEOfICP5t6Z4AsYxNkuM7AmlmfEBrk0h aCiw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b=URVJ95tN; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id s17-20020a656911000000b00584b2a790absi2497163pgq.821.2023.10.28.07.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 07:42:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b=URVJ95tN; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5ED5880942F1; Sat, 28 Oct 2023 07:42:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229492AbjJ1Ojl (ORCPT + 99 others); Sat, 28 Oct 2023 10:39:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbjJ1Ojk (ORCPT ); Sat, 28 Oct 2023 10:39:40 -0400 Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 181EDF0 for ; Sat, 28 Oct 2023 07:39:37 -0700 (PDT) Received: from monolith.lan (unknown [185.77.218.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4SHhxy4tWZz49Q4M; Sat, 28 Oct 2023 17:39:34 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1698503974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=82Pvx/CWmqLa+M7kmnpR+VTuTlcjdGYixQptc74mRdU=; b=URVJ95tNWCvXW+5ag3BHIuVjQ38pwrWrTq69zgk+2lfHmA7cZu6OUdDPEb8h9O1tj1DpSn Gn+McweMjJGC0ubF/IkpyA4iU0Lvuz1lULVSSJqxvCLjkDSPVS39WI+RjjCyqpcS2FhNyI hxiIUY/4i/gn0u0Vpldvf5iqng0K4SzuLkh6lOWBDf9QyBRhjIIThJ4s6BTO4hlyJWrZ6k eteizI3FiXxKlM5UsLJjN9bPFQdBp7X2GMHrGEQqT71MYz/Np64H3M2ciojWJd1EZja2Hh Gp75YY52GvTqVKRxn6Cpi4MPjF4mqTv5qMUiJZIh3CjhsE/DauVVZnU8C3og/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1698503974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=82Pvx/CWmqLa+M7kmnpR+VTuTlcjdGYixQptc74mRdU=; b=Gyu1vecPlH6MXDhmNq7+TzNmkgU1cvlWmFy68KpLOmMsVLyCo86tc1DVPOh9e+0kvTeVVq LJWNvTNj4IwimBUKhYKAFke8Y5kakqvtpOX3Sh/4cwPlrDdBgoZkdmvISqcZCzJ+LCZE3h 33HKtRvZsxTIABJ/ndgAGGyH48kQq9hKif7JL/kwe0bx2iYbJesbps1rTQiGioET/hdzIR DCsrZjZjRNeDk02aXiG6rcm7KTI/tesO3JF5cCsw9UuE9uenegj7q/MA0z5TJjN0/mU2sn X6ayVf0+lXOTd3c70E87cW2jX/s+jJVekoNWjhHcHuVywG7KedvQc5LAzlqHsg== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1698503974; a=rsa-sha256; cv=none; b=MsLxW2hjE4ZKUCHNlXciHC7rUSFG8VWp8AH5JvKFqbGeFCzANaYrIB3n9bjXsnNs9OEmQZ dNunanRj8Vr6Pp6VVjzkIzqePYfaDNFkC6UNxt6XqNvUuRoy/BedORcALIfdftkKJ9SO8v ijzWU7wLyVfHUc/4Ix6J2alozVZQQRZN/ZXoUodkCPGcvrDspdieKzcQ2plYN++UYKd/Ll 0JirbZ1s7vaG4vL+rmBRQO7xpxtg3F3CnkIBzAoTFhTbev5tHVsikF1tDJOjqzXoN7VSzS 4kzjvak4rAtFsCflF6HV6XHCi/BDrSJSFAgTRuCydRoviCXTWz6w8c9+z6VaJA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ 2/4] shared/bap: rename PAC op select -> select_codec, add select_qos Date: Sat, 28 Oct 2023 17:39:27 +0300 Message-ID: <2cbda517f3818b68bc3e2e44328116e76b9bb3b7.1698503903.git.pav@iki.fi> X-Mailer: git-send-email 2.41.0 In-Reply-To: <6f03ad1eaaa00f84db8cd6a4a4b88ee83078951d.1698503903.git.pav@iki.fi> References: <6f03ad1eaaa00f84db8cd6a4a4b88ee83078951d.1698503903.git.pav@iki.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 28 Oct 2023 07:42:43 -0700 (PDT) The BAP Unicast Client stream configuration flow has two steps, Config Codec and Config QoS. Previously both the ASE Codec & QoS configuration was obtained from the local PAC via bt_bap_pac_ops.select, but the information what the BAP Server supports becomes available only after Config Codec completes successfully. So the single-step configuration doesn't work out correctly in the API. Split out the QoS configuration to a separate PAC operation. Rename "select" to "select_codec", and add select_qos and bt_bap_stream_select_qos for the QoS configuration step. Also add bt_bap_stream_get_lpac/rpac, which will be needed in the QoS configuration callback. --- src/shared/bap.c | 37 ++++++++++++++++++++++++++++++++----- src/shared/bap.h | 23 +++++++++++++++++------ 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 13bbcf793..6155b8640 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -4617,17 +4617,34 @@ static bool match_pac(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, return false; } -int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, - bt_bap_pac_select_t func, void *user_data) +int bt_bap_select_codec(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, + bt_bap_pac_select_codec_t func, void *user_data) { if (!lpac || !rpac || !func) return -EINVAL; - if (!lpac->ops || !lpac->ops->select) + if (!lpac->ops || !lpac->ops->select_codec) return -EOPNOTSUPP; - lpac->ops->select(lpac, rpac, &rpac->qos, - func, user_data, lpac->user_data); + lpac->ops->select_codec(lpac, rpac, func, user_data, lpac->user_data); + + return 0; +} + +int bt_bap_stream_select_qos(struct bt_bap_stream *stream, + bt_bap_pac_select_qos_t func, void *user_data) +{ + struct bt_bap_pac *lpac = stream->lpac; + struct bt_bap_pac *rpac = stream->rpac; + + if (!lpac || !rpac || !func) + return -EINVAL; + + if (!lpac->ops || !lpac->ops->select_qos) + return -EOPNOTSUPP; + + lpac->ops->select_qos(stream, &rpac->qos, func, user_data, + lpac->user_data); return 0; } @@ -5124,6 +5141,16 @@ uint32_t bt_bap_stream_get_location(struct bt_bap_stream *stream) return stream->bap->ldb->pacs->source_loc_value; } +struct bt_bap_pac *bt_bap_stream_get_lpac(struct bt_bap_stream *stream) +{ + return stream->lpac; +} + +struct bt_bap_pac *bt_bap_stream_get_rpac(struct bt_bap_stream *stream) +{ + return stream->rpac; +} + struct iovec *bt_bap_stream_get_config(struct bt_bap_stream *stream) { if (!stream) diff --git a/src/shared/bap.h b/src/shared/bap.h index 23edbf4c6..d8fae0ef8 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -104,12 +104,15 @@ typedef void (*bt_bap_pac_func_t)(struct bt_bap_pac *pac, void *user_data); typedef bool (*bt_bap_pac_foreach_t)(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, void *user_data); -typedef void (*bt_bap_pac_select_t)(struct bt_bap_pac *pac, int err, +typedef void (*bt_bap_pac_select_codec_t)(struct bt_bap_pac *pac, int err, struct iovec *caps, struct iovec *metadata, struct bt_bap_qos *qos, void *user_data); typedef void (*bt_bap_pac_config_t)(struct bt_bap_stream *stream, int err); +typedef void (*bt_bap_pac_select_qos_t)(struct bt_bap_stream *stream, + int err, struct bt_bap_qos *qos, + void *user_data); typedef void (*bt_bap_state_func_t)(struct bt_bap_stream *stream, uint8_t old_state, uint8_t new_state, void *user_data); @@ -150,9 +153,12 @@ struct bt_bap_pac *bt_bap_add_pac(struct gatt_db *db, const char *name, struct iovec *metadata); struct bt_bap_pac_ops { - int (*select)(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, - struct bt_bap_pac_qos *qos, - bt_bap_pac_select_t cb, void *cb_data, void *user_data); + int (*select_codec)(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, + bt_bap_pac_select_codec_t cb, void *cb_data, + void *user_data); + int (*select_qos)(struct bt_bap_stream *stream, + struct bt_bap_pac_qos *qos, bt_bap_pac_select_qos_t cb, + void *cb_data, void *user_data); int (*config)(struct bt_bap_stream *stream, struct iovec *cfg, struct bt_bap_qos *qos, bt_bap_pac_config_t cb, void *user_data); @@ -233,8 +239,8 @@ void bt_bap_pac_set_user_data(struct bt_bap_pac *pac, void *user_data); void *bt_bap_pac_get_user_data(struct bt_bap_pac *pac); /* Stream related functions */ -int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, - bt_bap_pac_select_t func, void *user_data); +int bt_bap_select_codec(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, + bt_bap_pac_select_codec_t func, void *user_data); struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, struct bt_bap_pac *lpac, @@ -249,6 +255,9 @@ bool bt_bap_stream_set_user_data(struct bt_bap_stream *stream, void *user_data); void *bt_bap_stream_get_user_data(struct bt_bap_stream *stream); +int bt_bap_stream_select_qos(struct bt_bap_stream *stream, + bt_bap_pac_select_qos_t func, void *user_data); + unsigned int bt_bap_stream_config(struct bt_bap_stream *stream, struct bt_bap_qos *pqos, struct iovec *data, @@ -293,6 +302,8 @@ uint32_t bt_bap_stream_get_location(struct bt_bap_stream *stream); struct iovec *bt_bap_stream_get_config(struct bt_bap_stream *stream); struct bt_bap_qos *bt_bap_stream_get_qos(struct bt_bap_stream *stream); struct iovec *bt_bap_stream_get_metadata(struct bt_bap_stream *stream); +struct bt_bap_pac *bt_bap_stream_get_lpac(struct bt_bap_stream *stream); +struct bt_bap_pac *bt_bap_stream_get_rpac(struct bt_bap_stream *stream); struct io *bt_bap_stream_get_io(struct bt_bap_stream *stream); bool bt_bap_match_bcast_sink_stream(const void *data, const void *user_data); -- 2.41.0