From patchwork Sun Nov 12 16:00:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 743403 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B92614AA4 for ; Sun, 12 Nov 2023 16:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b="R4hwEyeh" Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA2BB2726 for ; Sun, 12 Nov 2023 08:00:15 -0800 (PST) Received: from monolith.lan (unknown [193.138.7.158]) (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 4SSy242yP8z49Q1r; Sun, 12 Nov 2023 18:00:07 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1699804813; 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; bh=3ddU2F39Yz3+abifU68xlt+o74WQz6fWioDl3MPSS0w=; b=R4hwEyehFZWDpbTo6xGmGXy9QPkinYm0TqavYW2liNixhIdm0/exg3CeC2UzYrUqVZw5Ya 6b7HyF+9NA16hs9GHJwp6fRp5dqz0tmSMaWH00DuEjeCfzROmckPi6g3jNigi8kRL3+lt0 Gg/ktZi7Rs0ATCrgeSs6TSRp5vFoAehEi9rtyQ1UtTAL1BO5Zs4s6+js6/ltQvaghyhMeq +SmKf0jcd2JFO2xyyWvNLefloXdJnJG0ATfsXsxlCy6qb38JPc4AIXs1BQL8xcbT+szlVr 3Bktm9fMOp6JGgkph5U/5gG8sSbaaHlRePT8HXloyx73m8xRNwtAX2aHGTX08Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1699804813; 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; bh=3ddU2F39Yz3+abifU68xlt+o74WQz6fWioDl3MPSS0w=; b=Eh0rjBUgCOiiiRo0zZXeMGA+I9rod5Es++vZdcTiXnnCJPeU2BB7lmH+U0amUOIs5IuBm5 mMIVJiWFy8doqvd7jRG3Ew5+XuHw65ujXQI928pq0qxLfqGZ3bP8odj3Ef+1qMc34r1u/h eSJiBQFOhl+fSxgFogfGPoap4DqAZSMoWeRZBMUb4OaQ1drTkiaevenigFHx5E9F4HSjSi aTpS74UV7f6Ufpg7fmp3gdryBWgRwVCzYKNr9+azi5G2qe9HNjQ3Keai5Hw///lDik6uDE Ba+ZJ+r3jAeLbD+WvQDkZQCYVr/oP2uKaIWYz0XzrEJs80gZ3K3WhB/Y9nldwA== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1699804813; a=rsa-sha256; cv=none; b=nWjrmhHtfEfWoMlxJGohSTFRzRjk1KQRnmvRrfKzg0mn2GKyUwpk+wzgf0JG/2WqjRCs0w vZ6R/dH3bmgdUSKjPb2CQolDlfPYoYPhZ98dABz3md/vSRVxKFimqeZ14ycAkL4eWM1jj2 eDXwsm2R2saPd7VxILgCsM1iCT8PHaxsgWAW/8nvcH1j59PWT26Wm5LDFYa1AIcWl6eDfk XTXg96dKBwOmDHxEvqmcX4T5/TXOOLLiEzJYl9EnTbMIxLs98L+H1DAo8OVzf0V06fk3aI sJETk7yHQ9L2Uo2ghw9dLnuG8nOUQxp+unLJCiGKbb4HqbGMOeg4f6xGbAwPwg== 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 1/4] shared/bap: add bt_bap_stream_config_update for updating QoS choice Date: Sun, 12 Nov 2023 18:00:02 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add bt_bap_stream_config_update for updating the QoS while in Codec Configured state. --- src/shared/bap.c | 18 ++++++++++++++++++ src/shared/bap.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index 13bbcf793..d90e39f7c 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -4600,6 +4600,24 @@ unsigned int bt_bap_stream_config(struct bt_bap_stream *stream, return 0; } +int bt_bap_stream_config_update(struct bt_bap_stream *stream, + struct bt_bap_qos *qos) +{ + if (!bap_stream_valid(stream)) + return -EINVAL; + + if (stream->ep->state != BT_BAP_STREAM_STATE_CONFIG) + return -EINVAL; + + switch (bt_bap_stream_get_type(stream)) { + case BT_BAP_STREAM_TYPE_UCAST: + stream->qos = *qos; + return 0; + } + + return -EINVAL; +} + static bool match_pac(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, void *user_data) { diff --git a/src/shared/bap.h b/src/shared/bap.h index 23edbf4c6..099c2edd0 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -255,6 +255,9 @@ unsigned int bt_bap_stream_config(struct bt_bap_stream *stream, bt_bap_stream_func_t func, void *user_data); +int bt_bap_stream_config_update(struct bt_bap_stream *stream, + struct bt_bap_qos *pqos); + unsigned int bt_bap_stream_qos(struct bt_bap_stream *stream, struct bt_bap_qos *qos, bt_bap_stream_func_t func, From patchwork Sun Nov 12 16:00:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 743402 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04CAD14ABA for ; Sun, 12 Nov 2023 16:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b="tQbLA+O/" Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B908F103 for ; Sun, 12 Nov 2023 08:00:15 -0800 (PST) Received: from monolith.lan (unknown [193.138.7.158]) (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 4SSy255pYYz49Q36; Sun, 12 Nov 2023 18:00:13 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1699804813; 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=9DfoCNBUtbS3pLQrARPLBiO/szoZxGBpmRfhr/IqJR4=; b=tQbLA+O/j1vy452qSiVTtMOvqAKhZgyBQcast1dsPSE/XTs20Y8HB3m3WrbZF3cCot22Yn 4jKvtCbRWoog4rBBkjG1RmrQZWkqOu74BumjoBsDLipJQkhLrsb3+536U4xjEnvH2G3z4p or7B9mRFcAqN7kkz9DT0FdkwBinTz3c166ruWdqMaCqOTsTAH9DJiIKMCMs4o3BZQUB6GN 1JQq0fURaO5oaODVd+ztl3vq2IS0abIrx2HxmfircrqEzkgpNiafLn0H7r3WBctZEt0RmN tyH4x087w8wpXWgi7B8l+1+2AAeXD1pKXzIpHedEiKYnV6Avu/zSHHRy06msjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1699804813; 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=9DfoCNBUtbS3pLQrARPLBiO/szoZxGBpmRfhr/IqJR4=; b=bPkIrsXtVESgplyfpqItiuZNMCUpz/6nJ1cLM0R+FEF2EY1m4DaXVn/rv5MWjpmwMKgkq2 KQJtmrMT0W/cU273egyn2jZL5BDcbpwH5Y08s/d+VnaUdRunvOxuimHCfp+vPPm3cdnOe0 QU23rgMjT+bHPiAjB00/pBbUbENERaXi4qP69k+jD6jTiV1m4e6KNyEJv4sGRoR72eysgR IR37xmAZg60tCrnu0nyVhBxMbaL9ayiDQosa1oLtnl4hAwWcAnSQ7vo6LNTtvhjG2DzS40 vztdBNCr873KGwVsOMCgSgjklOgSVgsQvmALnEaUJQM0g7Dpc3tlUpfu6a/Ijw== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1699804813; a=rsa-sha256; cv=none; b=dKGaXiJCph3UMOET6YQQvWs1i0AOwexR3Wp1bRs7lmIWVK6+Fie3NhfwRlF3z/rx8udlP2 Ip8Fl3RqPB+Jnj6hSMn2Idlw3KhfYnqy1X31oon9/dpXc5wxUpSesHW+ZVdX4c5PoopYRc gxGKDBvECqNjpIjQKDB4rNR8eQT05phwCTuYRHOsvbieSwfdWmnfHppgfiVVHn5LIxsTXS rpmSpr7qHFcmR2lQlDSTj/UsSan620vK9nFEcYHJ2UVGhmvB+IUhYIJTcrJb7+BOch/T7g Bf78IpWKlbmMseK7ConEp5+k2jPE3oIvyOz4siBOk79ViQ2E6QgIXcZKakQcNQ== 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: move bcast configure finish out from set_user_data Date: Sun, 12 Nov 2023 18:00:03 +0200 Message-ID: <4a7871ce4bffa5b39adcd4b710c0a225492ef267.1699802164.git.pav@iki.fi> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Creating transports for broadcast streams should not be a side effect of bt_bap_stream_set_user_data, but via a separate function. Move that to new function bt_bap_stream_bcast_configured. --- Notes: This might be something that should be done in bt_bap_stream_config(), however that is sometimes called when it appears creating transports is not intended. Possibly these calls should use bt_bap_stream_config_update instead. The broadcast setup logic probably can be cleaned up here, but I don't currently have a setup to test it, so this is minimal cleanup. src/shared/bap.c | 19 +++++++++++++++---- src/shared/bap.h | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index d90e39f7c..085a46216 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -1522,6 +1522,21 @@ static uint8_t stream_config(struct bt_bap_stream *stream, struct iovec *cc, return 0; } +int bt_bap_stream_bcast_configured(struct bt_bap_stream *stream) +{ + if (!stream) + return -EINVAL; + if (!stream->lpac->ops || !stream->lpac->ops->config) + return -EINVAL; + if (bt_bap_stream_get_type(stream) != BT_BAP_STREAM_TYPE_BCAST) + return -EINVAL; + + stream->lpac->ops->config(stream, stream->cc, &stream->qos, + ep_config_cb, stream->lpac->user_data); + + return 0; +} + static uint8_t ep_config(struct bt_bap_endpoint *ep, struct bt_bap *bap, struct bt_ascs_config *req, struct iovec *iov, struct iovec *rsp) @@ -4748,10 +4763,6 @@ bool bt_bap_stream_set_user_data(struct bt_bap_stream *stream, void *user_data) stream->user_data = user_data; - if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) - stream->lpac->ops->config(stream, stream->cc, &stream->qos, - ep_config_cb, stream->lpac->user_data); - return true; } diff --git a/src/shared/bap.h b/src/shared/bap.h index 099c2edd0..0f9ae27b7 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -263,6 +263,8 @@ unsigned int bt_bap_stream_qos(struct bt_bap_stream *stream, bt_bap_stream_func_t func, void *user_data); +int bt_bap_stream_bcast_configured(struct bt_bap_stream *stream); + unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream, bool enable_links, struct iovec *metadata, From patchwork Sun Nov 12 16:00:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 743523 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C686214AB8 for ; Sun, 12 Nov 2023 16:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b="IHiqEp42" Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA3932D46 for ; Sun, 12 Nov 2023 08:00:15 -0800 (PST) Received: from monolith.lan (unknown [193.138.7.158]) (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 4SSy256sMSz49Q3F; Sun, 12 Nov 2023 18:00:13 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1699804814; 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=lkHnfkzajncCjvIxAFoOmkNYt8GllDeiUV2HGDPsjxc=; b=IHiqEp423PSjb4aVnzBTJvtb450NZQE8xfX3C0cB3/1+HstjSDAk+dZOXkG1RDYv9xVCG2 btESNEZaED37t32lXyIvc3BvhnwkMpwcxxlgnJQS/UmMLosPkwGDNR81uP9Kf/bUJ2IOzK pibZ9JMnDT9KI0HFJNbE0vKhbF7VfGUP4HresOtu3s+t3g90x2TeO9JF0bxgpDhD44HMEC sidRKTKAo22x6cb3a504ThoOQd6K8roizt4qrkQXqUS60ECkttA8iqFBXAqxQXzHSnUfk4 v7rmgXGtVOatYG4xZAS8fn8rEzBknA1RF9m+RsDBDyGDN4w84rE4i7oaYL0FNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1699804814; 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=lkHnfkzajncCjvIxAFoOmkNYt8GllDeiUV2HGDPsjxc=; b=ZV3yoTugsTvE7C5OhvHVbmdaDaImF07ffJFbthLzLa8emiUnfWaOhNI+FWgDC3k//o2lsd zR10DV9qTeZOXGLGrL5ECjcPWMceLlNMS9v1qx8tZVfnmUMwmIuEHQuXCSkJ+ZDzQoVFH7 b3I08bOtsgXoLUiHfWig3c4NepX9ghK80y7MqbdBTlKIBFYQ14nQdyYziWhd3S17DXTt1o dsX6evvGdspuy1V6rdizOMsr5GI5ZC2umiXeiu7hELWLJJyaws5BeSfPQsseUCfMF/TgL3 uW+kCUDitjmDZxsTWXbgwpDRFjlxwCGu3GJTdqsp4d4esF/x3d0eq7qktQZWcQ== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1699804814; a=rsa-sha256; cv=none; b=SFmjeARQS6I7M3qErmZORql70jmcYec7nLY0mtMCMNUefFipjBoCXMyb7lGQ2guwWrDDOL ePxseUuFW1laL1uFBjDFiIEYy1iR/CP1Q8aYPohvscDbO8KCeruEaylqvwpU6/hwSGSIk5 BisxAD0C/ysDo5SRd+Q/N8djU4+uaW4WT+GDp920KQ+3EWBGtV7bSuzL0GBNKx1JH0hsUP Dct2Ixk3xJyHxwqgV4xskpmxT9aYs7Xn5yJPkvRvWCVf59Z5BqvLfazGcQclWERqbyn4s/ /3Ow20xHrJ53G4YQmvQw3d9Uc9ANaqBhDDZAPpUmNVV47So/i2tlITsH4lYmNQ== 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 3/4] bap: call explicitly bt_bap_stream_bcast_configured when needed Date: Sun, 12 Nov 2023 18:00:04 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Finishing bcast configuration is no longer a side effect of set_user_data. --- profiles/audio/bap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 780dff412..85532b1af 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -854,6 +854,7 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, } bt_bap_stream_set_user_data(ep->stream, ep->path); + bt_bap_stream_bcast_configured(ep->stream); if (ep->metadata && ep->metadata->iov_len) bt_bap_stream_metadata(ep->stream, ep->metadata, NULL, NULL); @@ -959,6 +960,7 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) data->listen_io = io; bt_bap_stream_set_user_data(ep->stream, ep->path); + bt_bap_stream_bcast_configured(ep->stream); fd = g_io_channel_unix_get_fd(io); @@ -1200,6 +1202,7 @@ static void bap_config(void *data, void *user_data) } bt_bap_stream_set_user_data(ep->stream, ep->path); + bt_bap_stream_bcast_configured(ep->stream); } static void select_cb(struct bt_bap_pac *pac, int err, struct iovec *caps, From patchwork Sun Nov 12 16:00:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 743522 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3822914ABC for ; Sun, 12 Nov 2023 16:00:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b="IAgkvRRn" Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA197270C for ; Sun, 12 Nov 2023 08:00:15 -0800 (PST) Received: from monolith.lan (unknown [193.138.7.158]) (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 4SSy260q5rz49Q7j; Sun, 12 Nov 2023 18:00:14 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1699804814; 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=SboCuILEitsKKZv2da7stJZC84zQez3mCufNSw1yIVw=; b=IAgkvRRnCI3pEbbU92EqnNk24J8M/L3k3I28wZ8e/EwKPK9LNnj21x9Q7Y/fi+KhmLZYEX O2JFLcX6hX4eOjh3AZ2Misq0SjI7vDrXNudVnULkRWs172fn6UASwvC12VwjNzWkv3ZqBI IyY0Gy7BujHwcSKscu24vQPYVkzIhBF27YRHJ+Y5QkznwGbaiNMpFgD+UTHiPkOHinJNfW q6RX0ZscB0WesU+go5HwqU77fbboRlrGZPvbJqSs/45nOejhDvxIB2J4vqjkBx6XuscNbk WetGVUbq5DarmyWD5GIElChui6/jjtXkJW/Z/Ty2+k462voMeKluJBQyD8FmdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1699804814; 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=SboCuILEitsKKZv2da7stJZC84zQez3mCufNSw1yIVw=; b=k2lHl+z4HMorqySrjDWeFrsptpEPvdeMGtGUAMyVnb9uyVmw/AeZ3jSzG3vTWmz8J6RpzJ VKhliiyGj7xdOXQHCiQQ/dvlgmeAyCPRcx02KughWgeAZAPNndtZyZquA4EBKfEdLNMEz1 zPxA7Q6fW528hCc/OvSwICutxk0g23o4kj1QVSgoF+HxLaUe0thxFqcfinIu5p9vkxEAnj FrH5vPfZuldP7pj8Kl2WFpigtGMcpWiZ/HIRFf1XTvWwiNp56NfcS3fNtJWsoL8NVD/VJt M5lX5rqCMxPFgomeQBZHeOprvj8Mvai9WvylQJAO2rPyDGnFa//7p5fufn8ZTw== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1699804814; a=rsa-sha256; cv=none; b=CqR4xg5a80dC6ljZMvXWl/vODrR3PN5vSuABlZu9TZO+OZNDdlBhfZR7tHe4Hx1FdimuOB hBRLo5CcDO/y016+jUAc3R4oWn4ikHARQFrjcKLdjEtwH2hzT8Xk8BWlqpdW69GVbL6tUF rpr0rKWNpinhMNISTlej73xBiAVAta0H6Y9vqKtpRc0YcEL2LXNbfV1PJvEUV4aEuI62bb tAWUGZpohWr+aS665d045T9tz1cMpl8Z8FYJ4V1ShFqiQV3rOMup0jlPDvcj8SoB3gjNfk pfE7ZI2CW4QSdy9SX/LkCYoySQz64JfqAwtlnO7b/Uq/mfIaXAsQZJPwrC9Asw== 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 4/4] bap: skip Config Codec when it is not needed Date: Sun, 12 Nov 2023 18:00:05 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If the ASE is in Codec Configured state and the configuration matches what we want, skip Config Codec and proceed directly to Config QoS. Combine the config setup in set_configuration with the one in bap_config. --- profiles/audio/bap.c | 137 +++++++++++++++++++++++++++---------------- 1 file changed, 86 insertions(+), 51 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 85532b1af..2c869e33c 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -99,6 +99,10 @@ struct bap_data { static struct queue *sessions; +static int ep_bap_config(struct bap_ep *ep); +static void bap_create_io(struct bap_data *data, struct bap_ep *ep, + struct bt_bap_stream *stream, int defer); + static bool bap_data_set_user_data(struct bap_data *data, void *user_data) { if (!data) @@ -837,25 +841,11 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return btd_error_invalid_args(msg); } - /* TODO: Check if stream capabilities match add support for Latency - * and PHY. - */ - if (!ep->stream) - ep->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, - ep->rpac, &ep->qos, ep->caps); - - ep->id = bt_bap_stream_config(ep->stream, &ep->qos, ep->caps, - config_cb, ep); - if (!ep->id) { + if (ep_bap_config(ep) < 0) { DBG("Unable to config stream"); - free(ep->caps); - ep->caps = NULL; return btd_error_invalid_args(msg); } - bt_bap_stream_set_user_data(ep->stream, ep->path); - bt_bap_stream_bcast_configured(ep->stream); - if (ep->metadata && ep->metadata->iov_len) bt_bap_stream_metadata(ep->stream, ep->metadata, NULL, NULL); @@ -1175,34 +1165,100 @@ static struct bap_ep *ep_register(struct btd_service *service, return ep; } -static void bap_config(void *data, void *user_data) +static int ep_bap_qos(struct bap_ep *ep) { - struct bap_ep *ep = data; + struct bap_data *data = ep->data; + struct bt_bap_stream *stream = ep->stream; + + if (ep->id) + return -EBUSY; + if (!stream || !ep->caps) + return -EINVAL; + + bap_create_io(data, ep, stream, true); + if (!ep->io) { + error("Unable to create io"); + goto fail; + } + + switch (bt_bap_stream_get_type(stream)) { + case BT_BAP_STREAM_TYPE_UCAST: + /* Wait QoS response to respond */ + ep->id = bt_bap_stream_qos(stream, &ep->qos, qos_cb, ep); + if (!ep->id) { + error("Failed to Configure QoS"); + goto fail; + } + break; + } + + return 0; + +fail: + bt_bap_stream_release(stream, NULL, NULL); + return -EIO; +} + +static void ep_clear_config(struct bap_ep *ep) +{ + util_iov_free(ep->caps, 1); + ep->caps = NULL; + util_iov_free(ep->metadata, 1); + ep->metadata = NULL; + memset(&ep->qos, 0, sizeof(ep->qos)); +} + +static int ep_bap_config(struct bap_ep *ep) +{ + struct iovec *caps; DBG("ep %p caps %p metadata %p", ep, ep->caps, ep->metadata); if (!ep->caps) - return; + return -EINVAL; + if (ep->id) + return -EBUSY; /* TODO: Check if stream capabilities match add support for Latency * and PHY. */ - if (!ep->stream) + if (!ep->stream) { ep->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, - ep->rpac, &ep->qos, ep->caps); + ep->rpac, NULL, NULL); + if (!ep->stream) + goto fail; + } + + bt_bap_stream_set_user_data(ep->stream, ep->path); + + /* Skip to QoS if reconfiguration not needed */ + caps = bt_bap_stream_get_config(ep->stream); + if (bt_bap_stream_get_type(ep->stream) == BT_BAP_STREAM_TYPE_UCAST && + bt_bap_stream_get_state(ep->stream) == BT_BAP_STREAM_STATE_CONFIG && + util_iov_memcmp(caps, ep->caps) == 0) { + DBG("ep %p stream %p no reconfig needed", ep, ep->stream); + bt_bap_stream_config_update(ep->stream, &ep->qos); + return ep_bap_qos(ep); + } ep->id = bt_bap_stream_config(ep->stream, &ep->qos, ep->caps, config_cb, ep); - if (!ep->id) { - DBG("Unable to config stream"); - util_iov_free(ep->caps, 1); - ep->caps = NULL; - util_iov_free(ep->metadata, 1); - ep->metadata = NULL; - } + if (!ep->id) + goto fail; - bt_bap_stream_set_user_data(ep->stream, ep->path); bt_bap_stream_bcast_configured(ep->stream); + + return 0; + +fail: + DBG("Unable to config stream"); + ep_clear_config(ep); + return -EIO; +} + +static void bap_config(void *data, void *user_data) +{ + ep_bap_config(data); } static void select_cb(struct bt_bap_pac *pac, int err, struct iovec *caps, @@ -1513,9 +1569,6 @@ static bool is_cig_busy(struct bap_data *data, uint8_t cig) return queue_find(sessions, cig_busy_session, &info); } -static void bap_create_io(struct bap_data *data, struct bap_ep *ep, - struct bt_bap_stream *stream, int defer); - static gboolean bap_io_recreate(void *user_data) { struct bap_ep *ep = user_data; @@ -1909,26 +1962,8 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, queue_remove(data->streams, stream); break; case BT_BAP_STREAM_STATE_CONFIG: - if (ep && !ep->id) { - bap_create_io(data, ep, stream, true); - if (!ep->io) { - error("Unable to create io"); - bt_bap_stream_release(stream, NULL, NULL); - return; - } - - if (bt_bap_stream_get_type(stream) == - BT_BAP_STREAM_TYPE_UCAST) { - /* Wait QoS response to respond */ - ep->id = bt_bap_stream_qos(stream, &ep->qos, - qos_cb, ep); - if (!ep->id) { - error("Failed to Configure QoS"); - bt_bap_stream_release(stream, - NULL, NULL); - } - } - } + if (ep) + ep_bap_qos(ep); break; case BT_BAP_STREAM_STATE_QOS: if (bt_bap_stream_get_type(stream) ==