From patchwork Thu Apr 11 20:03:02 2024 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: 13626531 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72F2A205E11 for ; Thu, 11 Apr 2024 20:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712865790; cv=none; b=Sm7r47NN0PaA1EzZ2NwOu8hLkcO6FFYRAQIyRZr7sJjxkJiTwFzx4T2+HbT+FQPF7hpAsZH9bOzA2o5HH1H7nFR1JdkepMdO1yTrbWgkb4rRwQXN0+GTO03UOBj1507DpT5BtHB97/b4/YI6Lqt2Ja0217oJl18sQmr6eVpmYvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712865790; c=relaxed/simple; bh=2zd2aErHG1lZPkrmYGGNWy8rR9E2GG4suFCJDjI8SaE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=N0HpxaPSVXM63LSzNpD83k/y/i/BW0jA7OQ3An/aPl38e6tCzJad47iMsA04d1NQaLIeFydu2q5lXG5qSuTw/xZF+BiOHhcjuJhz5TPt3/GBdfXWpta2wje7y/Qvy2TGShJjYDe9nbPUPFYmrUbrxFgy2lWNKA+dfH4vXnC4W/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q9M7ZKk5; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q9M7ZKk5" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3c3aeef1385so99937b6e.3 for ; Thu, 11 Apr 2024 13:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712865787; x=1713470587; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=+hANOqpWi5mccCXObOolBPcIhoSeVd6fCezYfr1BhRY=; b=Q9M7ZKk5DQl6Gm703zjtwpIeCfFnN2j7pzhh1bdGu4DjEm85Nn1m7L5u4ApVnGV3ES 0VxKAzjm/EYA4K706fbOe0mogxOJr4L0ig118hx3V/tX81IoUVibQL3x8HrBumTfu95/ uatJIes7ayd/K9/AIOZ299BrdHSF5D8Fi+lcQ5UdlhBUaLDbrPvdBiu3MPfTlR+oKozn BS9nYRlCR/vNt8WLTfkHZ0NSB3Uoo1mlaCikBb67Zx4B23h/N3Xb921gtHULsEzWOkJs IdrT0xZ434gjfXA8hh7Eumel9vnjbeWvJDQPBcALyjhwuxklmSwYC0ET2vbYrPnu07y9 bd9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712865787; x=1713470587; 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=+hANOqpWi5mccCXObOolBPcIhoSeVd6fCezYfr1BhRY=; b=PIhojlzph3eEnAZGDfnpwPxJbZKDSrE8AGUaTBUC5ECdiCI2jYMGvhPoGuzN1T1r0r oOhDTAg3N2LYGUfPVobyfsIChl56NfQfKS6ni5R3gaYxhq2zhL9Kh5uVTjcOPOXCPfR+ 9No/B3gFmnttdhktvXPMQx1q3WRpooGcaVX54ZB6+WHObitx4bGosv02NU//Oe+da45S CJP8w1sBJ4Om6xhGFA4qeMn1Ckw/zGxjsXoOo+we0euW6/x2x0XjUDR0N36EndgIWhM8 werJEsjg4q4hZJ8hU4xMz3HLRkd/X15WQrO+iyo1NB2lcjV46RBNn3qX762cm8NU/tfF r+0w== X-Gm-Message-State: AOJu0YwcJWM9UhIjdg799XWmDOCtOF4Ce4lapZ4qnGkwouq8wHlVjF2Z 68zt+92DZEzIEioORslgwUV76olKVIFFriBMDE7hFh2FMnnmZn8yjCfJDg== X-Google-Smtp-Source: AGHT+IFtoXe/JDVRycB7lxZydUtF79qRWyzDkTXMg5ERwvzwpZtCdjAOrlvntGQakl0xz7c/FPig4g== X-Received: by 2002:a05:6808:1b22:b0:3c6:efac:56e8 with SMTP id bx34-20020a0568081b2200b003c6efac56e8mr595371oib.48.1712865787454; Thu, 11 Apr 2024 13:03:07 -0700 (PDT) Received: from lvondent-mobl4.. (107-146-107-067.biz.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id da2-20020a056130230200b007e6b31e535asm268110uab.29.2024.04.11.13.03.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 13:03:06 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 1/4] shared/bap: Fix not updating location Date: Thu, 11 Apr 2024 16:03:02 -0400 Message-ID: <20240411200305.183703-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz Fix not updating map.location when selecting. --- src/shared/bap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index f553096dfcc6..b452461ac715 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -5163,12 +5163,10 @@ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, /* Check if there are any channels left to select */ map.count &= ~(map.count & rc->count); - if (!map.count) - break; - /* Check if there are any locations left to select */ map.location &= ~(map.location & rc->location); - if (!map.location) + + if (!map.count || !map.location) break; /* Check if device require AC*(i) settings */ From patchwork Thu Apr 11 20:03:03 2024 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: 13626532 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6CCD205E11 for ; Thu, 11 Apr 2024 20:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712865793; cv=none; b=pIvukcxjfVNjaCdSv9/rpHlOEik9c/8KxBjTXcwGM+Fm76fnMyCQecUKWPtYViJSiJWYgFHoNj2YawEfRHElpaYzufReNVLi94O2uhoziyhBePU1bcz3J0JCovUwCEHIEirlXkae2sCdb7ixj/z727BMkwDWGsTyl+yOfHiYtX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712865793; c=relaxed/simple; bh=LMFPVJf139a0wduO1eF0t+hakDsuenH9PZx5QV3puXg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SIl42f8gPdlcJulMLdibZwd4dfAD7xlGl6a45pt+w0acFcbFuQgERX+px/o/TMKVeDXsDimymULjMUslDZBtl9ZpILZ8FVqg0uZ5r/hXBuKuMRScwfmYsFKcHDoDBTx/JMaZh5BYWHE3uvFYT3yfOscXC6Lpq1komZSmH/Lvq8U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fR8xp3qk; arc=none smtp.client-ip=209.85.167.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fR8xp3qk" Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3c5d5de746cso59958b6e.0 for ; Thu, 11 Apr 2024 13:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712865790; x=1713470590; darn=vger.kernel.org; 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=LIvfY2P2js/Mn1HiN2qEldVKoXzkLk9p7C/LKB+J86c=; b=fR8xp3qkHKCk/JV48BT3A7mjghMpUUh4MGfpcPjM+j7R5DRkcxhUmMk6zvowqpvvCJ ZjgWZTdA+O6l780Y24dpZqhnfOoD17L0RNcqRxKwsjGUNZLLl2mRCp7io9AAqeRxQDqo PwOrKic7uNC/pKzFcpi1UMZDPvwUWqku65D1Oam4yFZdEEY/CtzRKzdPmTNqKNDXsvN6 A91pZzK+oP1pyIJ83vdUGVz9kbhWRaypET1OGeECoLIxVPIFbv5WiozIPWgc1lJWF6Co KzezziCgzKtXsczsky/F+6n+dgzFsBMDGWJ6x10BOgLFfKlbeSRuI5gGxXziEtWwk1lg 0Tnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712865790; x=1713470590; 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=LIvfY2P2js/Mn1HiN2qEldVKoXzkLk9p7C/LKB+J86c=; b=SUzQOgopUqsQ67b/bJYI+faEH8QU5vUB+fL3p5YIUtT/Fh6Yos3QLff5nQnnGLznpc Kr3DklCI57I30/E5TTVbfbJsLMTVZJYZGj96PLh8X6R97FSCE4WRgHSGBTATxqGuqNc7 ORdQtWaWWKEdwnhrd37aDHETGAMAlzGZJOmrdBC+xbEVgHT9HDzJs/xcqO0rFMy9J8IL 5J3p+E4JyGOzX0KfSOeuV93wm7Mj5DDgcNG5hrGP5Pj4ynYgUDyVl8ANRIOA4sFSotsZ RBVsFyMxe9dbvfmkpjXWwjHsXck+i7NXR4CAxkGMiwCX9d76iCBzqzV+GQQb2yeJ0R2T 0Gyg== X-Gm-Message-State: AOJu0YyvR8v4aNV6lp8Xip1GOulXIHMxXGUkCawhPtEOUWOaK+Cwr9Ov 9OzuAhbAIpqChx/27evtdFxkJ3hPx1whm/6IppmOAlLWOwS8Mb2wCj1imA== X-Google-Smtp-Source: AGHT+IH5W63EMhuyJnBVf+j4ClPFs8CBfRFevIeBsT7qBJ+ZHjTaDYMK/ppsgAhn+mNni++FEuIFXA== X-Received: by 2002:a05:6808:5d2:b0:3c5:fcf4:2216 with SMTP id d18-20020a05680805d200b003c5fcf42216mr668025oij.13.1712865789882; Thu, 11 Apr 2024 13:03:09 -0700 (PDT) Received: from lvondent-mobl4.. (107-146-107-067.biz.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id da2-20020a056130230200b007e6b31e535asm268110uab.29.2024.04.11.13.03.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 13:03:08 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 2/4] shared/bap: Make bt_bap_select fallback in case of no channel allocation Date: Thu, 11 Apr 2024 16:03:03 -0400 Message-ID: <20240411200305.183703-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411200305.183703-1-luiz.dentz@gmail.com> References: <20240411200305.183703-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz If channel allocation could not be matched attempt to call .select without a channel allocation as the device might require a different matching algorithm. Fixes: https://github.com/bluez/bluez/issues/793 --- src/shared/bap.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index b452461ac715..cc1fa1ffbe32 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -5116,6 +5116,7 @@ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, void *user_data) { const struct queue_entry *lchan, *rchan; + int selected = 0; if (!lpac || !rpac || !func) return -EINVAL; @@ -5158,8 +5159,7 @@ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, rc->location, &rpac->qos, func, user_data, lpac->user_data); - if (count) - (*count)++; + selected++; /* Check if there are any channels left to select */ map.count &= ~(map.count & rc->count); @@ -5175,6 +5175,16 @@ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, } } + /* Fallback to no channel allocation since none could be matched. */ + if (!selected) { + lpac->ops->select(lpac, rpac, 0, &rpac->qos, func, user_data, + lpac->user_data); + selected++; + } + + if (count) + *count += selected; + return 0; } From patchwork Thu Apr 11 20:03:04 2024 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: 13626533 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8815B205E11 for ; Thu, 11 Apr 2024 20:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712865795; cv=none; b=i4hQF+x1A4rbf303vSd2UHRjAOfUfi2uGgfMCkhC3SEoccWgT85u2msP77iR+Ng4yDDDM4A7W2v+vauSh3LjIAyE+2ZK0YOnPh4c3XRFO8oK6FWO7nT3YFPoNKVNBO1dD+E4BfyF4q+jX88FfXfP9P3jX/uVDdlRM8RwsPQt4RQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712865795; c=relaxed/simple; bh=dtAPDI39QCjupB+FxpLOoqWcJaGUTH+LY0xeHsBvIv4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V/0CmV/FIm94eWVA8RFHhIYTpFQdl1+DR84Dr/rYFGKEEgeir6taQvdBPLHmckK+otdo+MieAxpITJYxAyQGpXV79Tch+RQZ1hVuw6POzy56pUGIMRUnHo6uivQJ0LiHzlPawU20f9eAj2yqYoyS9MR/6LmpIXmyJXgPR0LdKog= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dhrkjGBO; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dhrkjGBO" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6eb5511088aso169373a34.2 for ; Thu, 11 Apr 2024 13:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712865792; x=1713470592; darn=vger.kernel.org; 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=2fuv8XoZVaViKeL+r9IEV453m08ChD5Kn+dw5wsZl58=; b=dhrkjGBOsEUTaAJOiPI2iStczpsX/wvH28OUDuqVVvrjSOmTRY4cezdMrAxqIEqiF2 SEInJthUxggSA+fJwlvqM6QDvDMHY6sIW6u8OxsAkT+GpkIxPhciRIV28TvNU/n8UMEF 5D/+d+RLbOcjE70HtL73bgURmD26VaMl3y/7zCABORCpHsH/AAITJa7G5Wx+dpY13vVv GU9rwKnbuHQsdK7oRX8O81MXO++b1fNckbMFJbkvlAyw8z3I94IYPqJ+ml/IyLkc5IbC Py8JDyc4LpS3j2vjNqjk3fW5gi90DuA4bSimWkeSOiVE0wtNx7SbsZI94cnRa313uiWv v1Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712865792; x=1713470592; 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=2fuv8XoZVaViKeL+r9IEV453m08ChD5Kn+dw5wsZl58=; b=coyWZ0irSLMolNR5bLWh0jhLynRDeRD4WdeVjfkPYGLHB8qM81HHOIp2y4LXhlHmbj Ly9trawUZB0362zpJrAVV40+t6R4MfbDQYp5XUgx3UzQiJgULCUlC/fSAe2vhjEQfR1y 6hzHh3K5JjvSMzBSc/W5hdCy+lCHu/W+YEdxYGKqw+Nn1dAuK/WWY4IuFSBsWdTPKRdq fwiudrHehojM6HhgUav/+/JdNaLRJVXVUnW7Qs7V4yDp3g5UP+ANi1wSxQc9TrTtzsOE d5SdQ6kN+/jqEDIdZ7Kdi0Doi7am1KsDWrcp2Y/AH0nCsclJhVcLjHv8KSdaq4gGS0ke TuPQ== X-Gm-Message-State: AOJu0YzYG6i4dDrtyoqO7UyA4AGzUVTKkT2vzYqcKN9Xk28IzIUBBkWT 1D6reBsU/jVRj3pRrfftrRXbtr7vVps36Xc5qCxI5KQv+h2PEi6YBlpbTQ== X-Google-Smtp-Source: AGHT+IHw4OYdGLlqc/SVRpEEV4imaWb97N/xEaPzotTajAUs6woHRzVMUKkGV8OAebhy6ZbuW2hUKw== X-Received: by 2002:a05:6808:212a:b0:3c3:d315:e769 with SMTP id r42-20020a056808212a00b003c3d315e769mr656028oiw.43.1712865792184; Thu, 11 Apr 2024 13:03:12 -0700 (PDT) Received: from lvondent-mobl4.. (107-146-107-067.biz.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id da2-20020a056130230200b007e6b31e535asm268110uab.29.2024.04.11.13.03.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 13:03:10 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 3/4] shared/bap: Fix not resuming reading attributes Date: Thu, 11 Apr 2024 16:03:04 -0400 Message-ID: <20240411200305.183703-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411200305.183703-1-luiz.dentz@gmail.com> References: <20240411200305.183703-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz If there is an unexpected disconnect and some attributes values where left uninitialized this attempts to resume reading them once a new session is attached. --- src/shared/bap.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index cc1fa1ffbe32..5fee7b4c54ca 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -4703,6 +4703,18 @@ clone: } } + /* Resume reading sink locations if supported */ + if (pacs->sink && pacs->sink_loc && !pacs->sink_loc_value) { + if (gatt_db_attribute_get_char_data(pacs->sink_loc, + NULL, &value_handle, + NULL, NULL, NULL)) { + bt_gatt_client_read_value(bap->client, + value_handle, + read_sink_pac_loc, + bap, NULL); + } + } + /* Resume reading sources if supported */ if (pacs->source && queue_isempty(bap->rdb->sources)) { if (gatt_db_attribute_get_char_data(pacs->source, @@ -4715,6 +4727,48 @@ clone: } } + /* Resume reading source locations if supported */ + if (pacs->source && pacs->source_loc && + !pacs->source_loc_value) { + if (gatt_db_attribute_get_char_data(pacs->source_loc, + NULL, &value_handle, + NULL, NULL, NULL)) { + bt_gatt_client_read_value(bap->client, + value_handle, + read_source_pac_loc, + bap, NULL); + } + } + + /* Resume reading supported contexts if supported */ + if (pacs->sink && pacs->supported_context && + !pacs->supported_sink_context_value && + !pacs->supported_source_context_value) { + if (gatt_db_attribute_get_char_data( + pacs->supported_context, + NULL, &value_handle, + NULL, NULL, NULL)) { + bt_gatt_client_read_value(bap->client, + value_handle, + read_pac_supported_context, + bap, NULL); + } + } + + /* Resume reading contexts if supported */ + if (pacs->sink && pacs->context && + !pacs->sink_context_value && + !pacs->source_context_value) { + if (gatt_db_attribute_get_char_data(pacs->context, + NULL, &value_handle, + NULL, NULL, NULL)) { + bt_gatt_client_read_value(bap->client, + value_handle, + read_pac_context, + bap, NULL); + } + } + queue_foreach(bap->remote_eps, bap_endpoint_foreach, bap); bap_cp_attach(bap); From patchwork Thu Apr 11 20:03:05 2024 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: 13626534 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70DEB17C69 for ; Thu, 11 Apr 2024 20:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712865797; cv=none; b=T8n0wsU1eGhiSh0oZmSKox8dlTHJwY2xkgAJQliQWmzKUg8eUwy2Uxr49MZWwqQNnlIiWloJ2/voBYJFSRhZhe52BPo12wJ3jhpZXbHwrUpEwA2rjiZxG7+1YMQSQGLA8OktwuYZ3sS4ohdiEwkhE5jK3d9ShY4A62Y1/ekmxc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712865797; c=relaxed/simple; bh=zxNvGco3OGDblWGo67VcK+hd9R/qtkasd5Tc6mcJ+3U=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q5OBDO3st1qgBTyzNAOC/DV83jt1NWgQMQCbHJv/mcl5EJKrSOOImwgKPYha4FZIPCIR1P3ef9A32e+HUrS20PYA+NxYvtDZl8SN5WZ6CduGJ5jBuxJ0ID1Mv+msTrEdujMBGQW26LVdtjtiqyA5nfyWX8MEWHAwqihtixZqJCU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cM6q8b/4; arc=none smtp.client-ip=209.85.167.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cM6q8b/4" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3c60adf3474so104088b6e.1 for ; Thu, 11 Apr 2024 13:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712865795; x=1713470595; darn=vger.kernel.org; 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=LSdJwN6sd4qzAZQcyujWTL3olcKLXCX3cO2D2vPIsn0=; b=cM6q8b/4pKLdGSuYf0jrm2ABvnY5lzTpBAeMOGl1mMOsiOxjPHcGhYH0zqLipq+77o ZA8YWeKAP6LoHdzfpo/rlFWsm1U29cBEdf64HxGsBvtiKdws/WtCMnCQP7vphmLje6Wo diJnLrq5Mp9NXiHgxQhvcaMJAn40mOVsr35fvLCjxotLHlAcAj1fU+Fp5qGOQNNKVtRn k8ckGonXBKc1TmKjrt/3ZwI2l0wr7auvUQyB/2VlMtmG1wgmE4F39wRbWMuTv/82L/0g ARkUVel4xg4a/gb7z8ntACNtCy0ybEGkoEU63uSg/AQRMO58uDSq9z+gv9zC61L8Qmwq rP5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712865795; x=1713470595; 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=LSdJwN6sd4qzAZQcyujWTL3olcKLXCX3cO2D2vPIsn0=; b=SCZAVGdMeAyCLXklyUMFdz0zGzhxA08yFT6AV8Gr4QtREV7eo6tPQT1p2uFWcLTKiZ tYiCWsYvvS+C3lvQClex2pUAdASmK+3hyEx922H7cXkZ3I2YdFyKcVRWyDUcy+q66bLP v+TaUiIhGMEAjfcbtzBaQGx0H7Z0gg++jG9QVd2Nip2hFWTrND/hutPNGsJJsaumtYvI 5NFz3FiT9ovOF0gc3O42jnkap71APVt/vbFS5bBUMCcvgABHbZiH7VfyqZyMwAp+6/Jc nLYoa0ZHDWtNDaEFzkYTCFPyBi7uibQBVsI0gnM8Lo+tCXqRIQ/2J4wqJWlf70wCIenC B+ow== X-Gm-Message-State: AOJu0YxRCqsSBLuWebPPfcq0xAKrBQAT0VA63VY/bhwVQaE/qqNotIBI ph9Gb6vsogexuq/6znM/GScZfmXtYRA6iWX0EWOYJhpj3LHqDju0xq7d3Q== X-Google-Smtp-Source: AGHT+IEsDlP5sL65NZP4hBh8L/atK41N78yQ8ptv2/trkfJBQILXW58oZiYga2dRP2P1zmbIjtw2mA== X-Received: by 2002:a05:6808:4396:b0:3c6:64e:a9ec with SMTP id dz22-20020a056808439600b003c6064ea9ecmr654363oib.58.1712865794820; Thu, 11 Apr 2024 13:03:14 -0700 (PDT) Received: from lvondent-mobl4.. (107-146-107-067.biz.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id da2-20020a056130230200b007e6b31e535asm268110uab.29.2024.04.11.13.03.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 13:03:13 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 4/4] bap: Update properties of endpoints Date: Thu, 11 Apr 2024 16:03:05 -0400 Message-ID: <20240411200305.183703-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411200305.183703-1-luiz.dentz@gmail.com> References: <20240411200305.183703-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz If a MediaEndpoint if found during registration stage attempt to check and update properties since they may have been updated at later stage when a session has been attached. --- profiles/audio/bap.c | 48 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index db0af7e7cba5..30049f0fb3a7 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -92,6 +92,9 @@ struct bap_ep { struct bap_data *data; struct bt_bap_pac *lpac; struct bt_bap_pac *rpac; + uint32_t locations; + uint16_t supported_context; + uint16_t context; struct queue *setups; }; @@ -376,9 +379,10 @@ static gboolean get_locations(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { struct bap_ep *ep = data; - uint32_t locations = bt_bap_pac_get_locations(ep->rpac); - dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &locations); + ep->locations = bt_bap_pac_get_locations(ep->rpac); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &ep->locations); return TRUE; } @@ -387,9 +391,11 @@ static gboolean get_supported_context(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { struct bap_ep *ep = data; - uint16_t context = bt_bap_pac_get_supported_context(ep->rpac); - dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &context); + ep->supported_context = bt_bap_pac_get_supported_context(ep->rpac); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &ep->supported_context); return TRUE; } @@ -398,9 +404,10 @@ static gboolean get_context(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { struct bap_ep *ep = data; - uint16_t context = bt_bap_pac_get_context(ep->rpac); - dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &context); + ep->context = bt_bap_pac_get_context(ep->rpac); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &ep->context); return TRUE; } @@ -1261,6 +1268,31 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, return ep; } +static void ep_update_properties(struct bap_ep *ep) +{ + if (!ep->rpac) + return; + + if (ep->locations != bt_bap_pac_get_locations(ep->rpac)) + g_dbus_emit_property_changed(btd_get_dbus_connection(), + ep->path, + MEDIA_ENDPOINT_INTERFACE, + "Locations"); + + if (ep->supported_context != + bt_bap_pac_get_supported_context(ep->rpac)) + g_dbus_emit_property_changed(btd_get_dbus_connection(), + ep->path, + MEDIA_ENDPOINT_INTERFACE, + "SupportedContext"); + + if (ep->context != bt_bap_pac_get_context(ep->rpac)) + g_dbus_emit_property_changed(btd_get_dbus_connection(), + ep->path, + MEDIA_ENDPOINT_INTERFACE, + "Context"); +} + static struct bap_ep *ep_register(struct btd_service *service, struct bt_bap_pac *lpac, struct bt_bap_pac *rpac) @@ -1289,8 +1321,10 @@ static struct bap_ep *ep_register(struct btd_service *service, } ep = queue_find(queue, match_ep, &match); - if (ep) + if (ep) { + ep_update_properties(ep); return ep; + } ep = new0(struct bap_ep, 1); ep->data = data;