summaryrefslogtreecommitdiff
path: root/net-wireless/bluez
diff options
context:
space:
mode:
Diffstat (limited to 'net-wireless/bluez')
-rw-r--r--net-wireless/bluez/Manifest8
-rw-r--r--net-wireless/bluez/bluez-5.68.ebuild292
-rw-r--r--net-wireless/bluez/files/bluez-5.68-bap-dettach-io.patch101
-rw-r--r--net-wireless/bluez/files/bluez-5.68-bap-ebusy-fix.patch206
-rw-r--r--net-wireless/bluez/files/bluez-5.68-bap-nonzero.patch27
-rw-r--r--net-wireless/bluez/files/bluez-5.68-bap-resume.patch187
-rw-r--r--net-wireless/bluez/files/bluez-5.68-heap-use-after-free.patch41
-rw-r--r--net-wireless/bluez/files/bluez-5.68-monitor-decoding.patch45
8 files changed, 907 insertions, 0 deletions
diff --git a/net-wireless/bluez/Manifest b/net-wireless/bluez/Manifest
index 6f793941eb1e..5a01d351094e 100644
--- a/net-wireless/bluez/Manifest
+++ b/net-wireless/bluez/Manifest
@@ -5,7 +5,15 @@ AUX bluetooth-init.d-r5 313 BLAKE2B 6bad1b9a75de5927ab22a229d6ce18247b32a79b9940
AUX bluez-5.66-musl-max-input.patch 610 BLAKE2B dee1a911f763d590a486d3aa7bd0a3d9eae40d9c8cba5ea01eda59304c1a4a1939b84771626ce97f2943ba88c523eb59dee3876cedc850e8bebbdb3b7c0d9bbb SHA512 ceb21eb70c1afbea5e25d4009ea5100d506e05a83b5a39564d6db2abb26f39f1850282fbbcab8f978b592da9893e8f87ace49afb1dbe99161155ad55a84e81e0
AUX bluez-5.66-power-state-adapter-property.patch 1085 BLAKE2B 9d76822b8ab649eb322e9511b86d85b912d8a073f15c563b689ad57b12e1c1eb043ed1741b62364dfae3b4a100ad4fdce36e723103f231dd77bf070c4ae0be73 SHA512 df52b4d260e0de6de9ad4bc1201740b2bc37a537c96e2a22d4f8b698caf6fcea81eba1e8d7b152ad6a1237a51e06212e7cfdc429b9b7f7ff66d23a294cbc55e5
AUX bluez-5.66-transient-hostname-fix.patch 5163 BLAKE2B 6a0f63370634ec7bdc830d8bb26ca47f273194e4a5ebf3c7fc654371f520d117da5112e76b4939e96e0d56ede2a0663ae1414dc809b9315a8bac63045ed70867 SHA512 fe787ec5a2e77da7ca3483797b07b1c4d0dbc133d22095e8b6fb3361a79f7762284af265e3bee54e330e22b110ee95916ad1f4f1f37002af9fc7859b09d1bdd0
+AUX bluez-5.68-bap-dettach-io.patch 3472 BLAKE2B 424f55cc90e3b9f5045a3a3728929eccd4e2938701cfa217d82b9971ea2abec76eb1eb3ed9def74230b67ec9c3cb69b932543c7671ffa97fd52675f732460cf1 SHA512 a18750769207e479e10edf95469ae562e288ee1ac7b20ad826b1e3e1e9160daa2df388dcbb8d6889e258d36fd1ca47bef07fdffbeb89ea629f0902d66e5cd785
+AUX bluez-5.68-bap-ebusy-fix.patch 5827 BLAKE2B cf8d111897ea7d51da88e6680342870a72226c1e67fea8a95686331dc29447e1ab777b50db839904a366f2e320b3e69bb6e43a9f8de91366a414901d0242dbb2 SHA512 1134848a726acda5bee8f7816d41c2284f29eb61425d474e5d5fcbf660a788c0cc5d73a679e27a72b4a4be147e8970b02fc35023fd28badf59e587debc695fe3
+AUX bluez-5.68-bap-nonzero.patch 764 BLAKE2B ba4e0853888649564baa5294c8687a7180175c0a8b83ec48c8c6b2e06f45b1c83386bf429081b73276495d5579f464adb7ccc5d1c55ef9864499c018230dd303 SHA512 129fe6a611dd6a42b32033b3975fd197a0925d50ff1259fdbaa74b1f39135c8cf538a5211ad66a0a4b6621a6e2bf5e9be8a40060fcd8d8718e5b9009c297b008
+AUX bluez-5.68-bap-resume.patch 6137 BLAKE2B a5eecd7b50048a8e63da3f98a4f83a96ae4c652c4fe10af4bac9f8173d27d7e863481c50cac382c21921f1c08476b106bcb1bc694183c84a24b0ed664abb41c2 SHA512 587c654f5ec667fa7540f20bb8ce25877722ddfb9aa520dc4f1c7f349f7b795889d1d5f5601b03d82154b630b6c98a4d10b7220b1d5e934e0ecb68a9259d001c
+AUX bluez-5.68-heap-use-after-free.patch 1515 BLAKE2B 73ee23986e652827672ab026582d8718d3f04a6faeb15d5802599910f5ee7c905813829486f5fdb2e6f190cfb6980b2eca5e9c008d9d427a6fc010943af5f318 SHA512 0f78c442faeae693489c25822dfe3065d6dbe2449d42b27c3f0f56b83caadbcf66942470bc00d28ec324cc49c400799a0e1d1d90f45e734b385ca54e4c9e6dc3
+AUX bluez-5.68-monitor-decoding.patch 1333 BLAKE2B 138359842a39abe7ba7c9db674b043110f6549f2499d8e42ff3abbce9bdfe9402babedc6228a8ff413bab97c12e1c8e9251db7918bc2b741f9bf5824dcf73912 SHA512 c1cba4b278aa559b31c09c721dff28a6024af4877a520b729fbec61e1cefd2bb338fe9d2629fb64796ab2caab32a9dce53ec55eaa1754bb712050ce01abc813e
AUX bluez-udevadm-path-r1.patch 564 BLAKE2B 0b4dc12f55ab60d254aa3365baf35186a5913026dbfcbc3da41c113b3c423c81189b87016dabcb2c505b684cad376d10d10df9aa17558b8fd022928995931e0e SHA512 d9b0dd452258e425802cf5ad4980a77796be79e94bf6ce641927c5ab7ea1117ce6589063f3a0b96bf25e81303234279a09d58484fec49cfc6aa1db46f245f9c6
DIST bluez-5.66.tar.xz 2257288 BLAKE2B af1911cf590461a874daa16bedb8a021a3b2c2af3254360c035d2180e0f355372651bd41da342c26e6d9631d726dd08e0d6a83a22069333b94b6fce6d546718c SHA512 ed0994932687eacf27207867366671b323671f5d5199daf36ea5eff8f254f2bc99ef989ef7df9883b35c06f2af60452be8bad0a06109428a4717cf2b247b4865
+DIST bluez-5.68.tar.xz 2319788 BLAKE2B 3beca78fadef4d66df6f237b7460f6ac4bf001d80c856b599faa2cc1232c4342c7945eace5a6667009b9d19f2368f9841e608f07bc826b30ce9112c43dd7e316 SHA512 1805fb68923a5e098777b69835d7593396f8f2bbf52e1cfe58e7447621497a700b23389c79e96b2d663c611335f6ea9df11efe8aa75a8842f6b73105f66e799c
EBUILD bluez-5.66-r1.ebuild 9834 BLAKE2B c5994bd84c2e8c890095fe880f35862ed6ed4530ccac0e2c9a28c1652585c26d67f2bb48a416c2a395ac0d19b636e06ef3e69205688dfc43b72d70b6dde3afa9 SHA512 82e1adef5568185a948e8d8fac2d17bbe6bd95f7522bd932847755d1da64e90e02d24927c6b5116bde047c22426f0ac8277d08c9cbec77095ed55796044e8616
+EBUILD bluez-5.68.ebuild 9266 BLAKE2B c7472cae303705438e0463a45f45aa64ef0a1bf9f81cb71b1911084239ffd652051834979b1744dd8502a893919d792a114a7785d1eec391a1caaec32460c93a SHA512 462587eecf457f7b961804c1aeb41587900d38a4e9725b76891df29b5aa29d33872c056a9a7d5a965024ed22a9ce17cc9ca143ad0d976fbf769ff4f9e9a0de06
MISC metadata.xml 1099 BLAKE2B 75b6db1d43b75f9b22ce5fb6ec640e2e06b2f2575ff75441318a2076b8486ed7d81a62714540c61ab3a35198113538546b9aa71d05ef4cd7106c8a7f09c13029 SHA512 6e4a7bba7102b4850a938ba0f6feec9cd12488d4b440b19982751c2a742b33a565933fae3967080c060e5b5eb51d90268abc87a2c0a2efb7f4c773020c29462a
diff --git a/net-wireless/bluez/bluez-5.68.ebuild b/net-wireless/bluez/bluez-5.68.ebuild
new file mode 100644
index 000000000000..e1bfed36ea31
--- /dev/null
+++ b/net-wireless/bluez/bluez-5.68.ebuild
@@ -0,0 +1,292 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+PYTHON_COMPAT=( python3_{9..12} )
+
+inherit autotools linux-info python-single-r1 systemd udev multilib-minimal #readme.gentoo-r1
+
+DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
+HOMEPAGE="http://www.bluez.org"
+SRC_URI="https://www.kernel.org/pub/linux/bluetooth/${P}.tar.xz"
+
+LICENSE="GPL-2+ LGPL-2.1+"
+SLOT="0/3"
+KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 ~riscv ~x86"
+IUSE="btpclient cups doc debug deprecated extra-tools experimental +mesh midi +obex +readline selinux systemd test test-programs +udev"
+
+# Since this release all remaining extra-tools need readline support, but this could
+# change in the future, hence, this REQUIRED_USE constraint could be dropped
+# again in the future.
+# btpclient needs mesh, bug #790587
+REQUIRED_USE="
+ btpclient? ( mesh )
+ extra-tools? ( deprecated readline )
+ test? ( ${PYTHON_REQUIRED_USE} )
+ test-programs? ( ${PYTHON_REQUIRED_USE} )
+"
+
+TEST_DEPS="${PYTHON_DEPS}
+ $(python_gen_cond_dep '
+ >=dev-python/dbus-python-1[${PYTHON_USEDEP}]
+ dev-python/pygobject:3[${PYTHON_USEDEP}]
+ ')
+"
+BDEPEND="
+ dev-python/docutils
+ virtual/pkgconfig
+ test? ( ${TEST_DEPS} )
+"
+DEPEND="
+ >=dev-libs/glib-2.28:2[${MULTILIB_USEDEP}]
+ btpclient? ( >=dev-libs/ell-0.39 )
+ cups? ( net-print/cups:= )
+ mesh? (
+ >=dev-libs/ell-0.39
+ >=dev-libs/json-c-0.13:=
+ sys-libs/readline:0=
+ )
+ midi? ( media-libs/alsa-lib )
+ obex? ( dev-libs/libical:= )
+ readline? ( sys-libs/readline:0= )
+ systemd? ( sys-apps/systemd )
+ >=sys-apps/dbus-1.6:=
+ udev? ( >=virtual/udev-172 )
+"
+RDEPEND="${DEPEND}
+ selinux? ( sec-policy/selinux-bluetooth )
+ test-programs? ( ${TEST_DEPS} )
+"
+
+RESTRICT="!test? ( test )"
+
+PATCHES=(
+ # Try both udevadm paths to cover udev/systemd vs. eudev locations (#539844)
+ # http://www.spinics.net/lists/linux-bluetooth/msg58739.html
+ # https://bugs.gentoo.org/539844
+ # https://github.com/bluez/bluez/issues/268
+ "${FILESDIR}"/${PN}-udevadm-path-r1.patch
+
+ # Fedora patches
+ # https://lore.kernel.org/linux-bluetooth/20220901110719.176944-1-hadess@hadess.net/T/#m9c08d004cd5422783ee1d93154f42303bba9169f
+ "${FILESDIR}"/${PN}-5.66-power-state-adapter-property.patch
+
+ # Fixed in next release
+ "${FILESDIR}"/${P}-bap-resume.patch
+ "${FILESDIR}"/${P}-bap-nonzero.patch
+ "${FILESDIR}"/${P}-bap-dettach-io.patch
+ "${FILESDIR}"/${P}-bap-ebusy-fix.patch
+ "${FILESDIR}"/${P}-monitor-decoding.patch
+ "${FILESDIR}"/${P}-heap-use-after-free.patch
+)
+
+pkg_setup() {
+ # From http://www.linuxfromscratch.org/blfs/view/svn/general/bluez.html
+ # to prevent bugs like:
+ # https://bugzilla.kernel.org/show_bug.cgi?id=196621
+ CONFIG_CHECK="~NET ~BT ~BT_RFCOMM ~BT_RFCOMM_TTY ~BT_BNEP ~BT_BNEP_MC_FILTER
+ ~BT_BNEP_PROTO_FILTER ~BT_HIDP ~CRYPTO_USER_API_HASH ~CRYPTO_USER_API_SKCIPHER ~RFKILL"
+ # https://bugzilla.kernel.org/show_bug.cgi?id=196621
+ # https://bugzilla.kernel.org/show_bug.cgi?id=206815
+ if use mesh || use test; then
+ CONFIG_CHECK="${CONFIG_CHECK} ~CRYPTO_USER
+ ~CRYPTO_USER_API ~CRYPTO_USER_API_AEAD ~CRYPTO_AES ~CRYPTO_CCM ~CRYPTO_AEAD ~CRYPTO_CMAC
+ ~CRYPTO_MD5 ~CRYPTO_SHA1 ~KEY_DH_OPERATIONS"
+ fi
+ linux-info_pkg_setup
+
+ if use test || use test-programs; then
+ python-single-r1_pkg_setup
+ fi
+
+ if ! use udev; then
+ ewarn
+ ewarn "You are installing ${PN} with USE=-udev. This means various bluetooth"
+ ewarn "devices and adapters from Apple, Dell, Logitech etc. will not work,"
+ ewarn "and hid2hci will not be available."
+ ewarn
+ fi
+}
+
+src_prepare() {
+ default
+
+ # http://www.spinics.net/lists/linux-bluetooth/msg38490.html
+ if ! use systemd; then
+ eapply "${FILESDIR}"/0001-Allow-using-obexd-without-systemd-in-the-user-session-r2.patch
+ fi
+
+ eautoreconf
+
+ if use cups; then
+ # Only not .am to not need to run eautoreconf only because of this
+ sed -i \
+ -e "s:cupsdir = \$(libdir)/cups:cupsdir = $(cups-config --serverbin):" \
+ Makefile.{in,tools} || die
+ fi
+
+ multilib_copy_sources
+}
+
+multilib_src_configure() {
+ local myconf=(
+ # readline is automagic when client is enabled
+ # --enable-client always needs readline, bug #504038
+ # --enable-mesh is handled in the same way
+ ac_cv_header_readline_readline_h=$(multilib_native_usex readline)
+ ac_cv_header_readline_readline_h=$(multilib_native_usex mesh)
+ )
+
+ if ! multilib_is_native_abi; then
+ myconf+=(
+ # deps not used for the library
+ {DBUS,GLIB}_{CFLAGS,LIBS}=' '
+ )
+ fi
+
+ econf \
+ --localstatedir=/var \
+ --disable-android \
+ --enable-datafiles \
+ --enable-optimization \
+ $(use_enable debug) \
+ --enable-pie \
+ --enable-threads \
+ --enable-library \
+ --enable-tools \
+ --enable-manpages \
+ --enable-monitor \
+ --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
+ --with-systemduserunitdir="$(systemd_get_userunitdir)" \
+ $(multilib_native_use_enable btpclient) \
+ $(multilib_native_use_enable btpclient external-ell) \
+ $(multilib_native_use_enable cups) \
+ $(multilib_native_use_enable deprecated) \
+ $(multilib_native_use_enable experimental) \
+ $(multilib_native_use_enable mesh) \
+ $(multilib_native_use_enable mesh external-ell) \
+ $(multilib_native_use_enable midi) \
+ $(multilib_native_use_enable obex) \
+ $(multilib_native_use_enable readline client) \
+ $(multilib_native_use_enable systemd) \
+ $(multilib_native_use_enable test-programs test) \
+ $(multilib_native_use_enable udev) \
+ $(multilib_native_use_enable udev hid2hci) \
+ $(multilib_native_use_enable udev sixaxis)
+}
+
+multilib_src_compile() {
+ if multilib_is_native_abi; then
+ default
+ else
+ emake -f Makefile -f - libs \
+ <<<'libs: $(lib_LTLIBRARIES)'
+ fi
+}
+
+multilib_src_test() {
+ multilib_is_native_abi && default
+}
+
+multilib_src_install() {
+ if multilib_is_native_abi; then
+ emake DESTDIR="${D}" install
+
+ # Only install extra-tools when relevant USE flag is enabled
+ if use extra-tools; then
+ ewarn "Upstream doesn't support using this tools and their bugs are"
+ ewarn "likely to be ignored forever, also they can break without"
+ ewarn "previous announcement."
+ ewarn "Upstream also states all this tools are not really needed,"
+ ewarn "then, if you still need to rely on them, you must ask them"
+ ewarn "to either install that tool by default or add the needed"
+ ewarn "functionality to the existing 'official' tools."
+ ewarn "Please report this issues to:"
+ ewarn "http://www.bluez.org/development/lists/"
+
+ # Upstream doesn't install this, bug #524640
+ # http://permalink.gmane.org/gmane.linux.bluez.kernel/53115
+ # http://comments.gmane.org/gmane.linux.bluez.kernel/54564
+ dobin tools/btmgmt
+ # gatttool is only built with readline, bug #530776
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1141909
+ # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=720486
+ # https://bugs.archlinux.org/task/37686
+ dobin attrib/gatttool
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1699680
+ dobin tools/avinfo
+ fi
+
+ # Not installed by default after being built, bug #666756
+ use btpclient && dobin tools/btpclient
+
+ # Unittests are not that useful once installed, so make them optional
+ if use test-programs; then
+ # Drop python2 only test tools
+ # https://bugzilla.kernel.org/show_bug.cgi?id=206819
+ rm "${ED}"/usr/$(get_libdir)/bluez/test/simple-player || die
+ # https://bugzilla.kernel.org/show_bug.cgi?id=206821
+ rm "${ED}"/usr/$(get_libdir)/bluez/test/test-hfp || die
+ # https://bugzilla.kernel.org/show_bug.cgi?id=206823
+ rm "${ED}"/usr/$(get_libdir)/bluez/test/test-sap-server || die
+
+ python_fix_shebang "${ED}"/usr/$(get_libdir)/bluez/test
+
+ for i in $(find "${ED}"/usr/$(get_libdir)/bluez/test -maxdepth 1 -type f ! -name "*.*"); do
+ dosym "${i}" /usr/bin/bluez-"${i##*/}"
+ done
+ fi
+ else
+ emake DESTDIR="${D}" \
+ install-pkgincludeHEADERS \
+ install-libLTLIBRARIES \
+ install-pkgconfigDATA
+ fi
+}
+
+multilib_src_install_all() {
+ # We need to ensure obexd can be spawned automatically by systemd
+ # when user-session is enabled:
+ # http://marc.info/?l=linux-bluetooth&m=148096094716386&w=2
+ # https://bugs.gentoo.org/show_bug.cgi?id=577842
+ # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804908
+ # https://bugs.archlinux.org/task/45816
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1318441
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1389347
+ if use systemd; then
+ dosym obex.service /usr/lib/systemd/user/dbus-org.bluez.obex.service
+ fi
+
+ find "${D}" -name '*.la' -type f -delete || die
+
+ keepdir /var/lib/bluetooth
+
+ # Upstream don't want people to play with them
+ # But we keep installing them due to 'historical' reasons
+ insinto /etc/bluetooth
+ local d
+ for d in input network; do
+ doins profiles/${d}/${d}.conf
+ done
+ # Setup auto enable as Fedora does for allowing to use
+ # keyboards/mouse as soon as possible
+ sed -i 's/#\[Policy\]$/\[Policy\]/; s/#AutoEnable=false/AutoEnable=true/' src/main.conf || die
+ doins src/main.conf
+
+ newinitd "${FILESDIR}"/bluetooth-init.d-r5 bluetooth
+ newconfd "${FILESDIR}"/bluetooth-conf.d bluetooth
+
+ einstalldocs
+ use doc && dodoc doc/*.txt
+}
+
+pkg_postinst() {
+ use udev && udev_reload
+ systemd_reenable bluetooth.service
+
+ has_version net-dialup/ppp || elog "To use dial up networking you must install net-dialup/ppp"
+}
+
+pkg_postrm() {
+ use udev && udev_reload
+}
diff --git a/net-wireless/bluez/files/bluez-5.68-bap-dettach-io.patch b/net-wireless/bluez/files/bluez-5.68-bap-dettach-io.patch
new file mode 100644
index 000000000000..bb79fc42734b
--- /dev/null
+++ b/net-wireless/bluez/files/bluez-5.68-bap-dettach-io.patch
@@ -0,0 +1,101 @@
+From 7b10e72de6f41585f087e6fc338106b44d3e69c9 Mon Sep 17 00:00:00 2001
+From: Pauli Virtanen <pav@iki.fi>
+Date: Sun, 2 Jul 2023 21:43:04 +0300
+Subject: shared/bap: detach io for source ASEs only after Stop Ready
+
+The Client may terminate a CIS when sink is in QOS and source in
+Disabling states (BAP v1.0.1 Sec 5.6.5). It may also terminate it when
+Receiver Stop Ready has completed successfully (BAP v1.0.1 Sec 5.6.5.1).
+
+It appears Samsung Galaxy Buds2 Pro (R510XXUOAWA5) ignores the Receiver
+Stop Ready command if CIS is already disconnected, and then gets stuck
+in disabling state. It works if CIS is disconnected after Receiver Stop
+Ready.
+
+For better compatibility as client for this device, and since it
+shouldn't matter for us in which order we do it, disconnect CIS after
+completion of Receiver Stop Ready, instead of immediately in Disabling.
+
+We disconnect also if Receiver Stop Ready fails, given that
+disconnecting in Disabled state should be OK.
+
+Link: https://github.com/bluez/bluez/issues/516
+---
+ src/shared/bap.c | 33 +++++++++++++++------------------
+ 1 file changed, 15 insertions(+), 18 deletions(-)
+
+diff --git a/src/shared/bap.c b/src/shared/bap.c
+index a0f5a0ae3c..72ce67c086 100644
+--- a/src/shared/bap.c
++++ b/src/shared/bap.c
+@@ -1168,18 +1168,6 @@ static bool match_stream_io(const void *data, const void *user_data)
+ return stream->io == io;
+ }
+
+-static void stream_stop_disabling(void *data, void *user_data)
+-{
+- struct bt_bap_stream *stream = data;
+-
+- if (stream->io || stream->ep->state != BT_ASCS_ASE_STATE_DISABLING)
+- return;
+-
+- DBG(stream->bap, "stream %p", stream);
+-
+- bt_bap_stream_stop(stream, NULL, NULL);
+-}
+-
+ static bool bap_stream_io_detach(struct bt_bap_stream *stream)
+ {
+ struct bt_bap_stream *link;
+@@ -1198,9 +1186,6 @@ static bool bap_stream_io_detach(struct bt_bap_stream *stream)
+ /* Detach link if in QoS state */
+ if (link->ep->state == BT_ASCS_ASE_STATE_QOS)
+ bap_stream_io_detach(link);
+- } else {
+- /* Links without IO on disabling state shall be stopped. */
+- queue_foreach(stream->links, stream_stop_disabling, NULL);
+ }
+
+ stream_io_unref(io);
+@@ -1244,6 +1229,15 @@ static struct bt_bap *bt_bap_ref_safe(struct bt_bap *bap)
+ return bt_bap_ref(bap);
+ }
+
++static void stream_stop_complete(struct bt_bap_stream *stream, uint8_t code,
++ uint8_t reason, void *user_data)
++{
++ DBG(stream->bap, "stream %p stop 0x%02x 0x%02x", stream, code, reason);
++
++ if (stream->ep->state == BT_ASCS_ASE_STATE_DISABLING)
++ bap_stream_io_detach(stream);
++}
++
+ static void bap_stream_state_changed(struct bt_bap_stream *stream)
+ {
+ struct bt_bap *bap = stream->bap;
+@@ -1271,7 +1265,9 @@ static void bap_stream_state_changed(struct bt_bap_stream *stream)
+ bap_stream_update_io_links(stream);
+ break;
+ case BT_ASCS_ASE_STATE_DISABLING:
+- bap_stream_io_detach(stream);
++ /* As client, we detach after Receiver Stop Ready */
++ if (!stream->client)
++ bap_stream_io_detach(stream);
+ break;
+ case BT_ASCS_ASE_STATE_QOS:
+ if (stream->io && !stream->io->connecting)
+@@ -1305,8 +1301,9 @@ static void bap_stream_state_changed(struct bt_bap_stream *stream)
+ bt_bap_stream_start(stream, NULL, NULL);
+ break;
+ case BT_ASCS_ASE_STATE_DISABLING:
+- if (!bt_bap_stream_get_io(stream))
+- bt_bap_stream_stop(stream, NULL, NULL);
++ /* Send Stop Ready, and detach IO after remote replies */
++ if (stream->client)
++ bt_bap_stream_stop(stream, stream_stop_complete, NULL);
+ break;
+ }
+
+--
+cgit
+
diff --git a/net-wireless/bluez/files/bluez-5.68-bap-ebusy-fix.patch b/net-wireless/bluez/files/bluez-5.68-bap-ebusy-fix.patch
new file mode 100644
index 000000000000..72b875ba4b6f
--- /dev/null
+++ b/net-wireless/bluez/files/bluez-5.68-bap-ebusy-fix.patch
@@ -0,0 +1,206 @@
+From 8c3170190d6f626869f1f382138caf3a16030462 Mon Sep 17 00:00:00 2001
+From: Pauli Virtanen <pav@iki.fi>
+Date: Sun, 2 Jul 2023 21:43:05 +0300
+Subject: bap: wait for CIG to become configurable before recreating CIS
+
+ISO sockets cannot be reconnected before all sockets in the same CIG
+have been closed, if the CIG was previously active.
+
+Keep track which endpoints have active CIG, and postpone connecting CIS
+until their CIG is no longer active.
+
+This addresses getting EBUSY from connect() when multiple CIS in the
+same CIG move streaming -> qos at the same time, which disconnects CIS
+and recreates them. The EBUSY originates from COMMAND_DISALLOWED
+response to Set CIG Parameters.
+
+This requires the kernel side do the Disconnect CIS / Remove CIG / Set
+CIG Parameters HCI command steps in the right order, when all old
+sockets are closed first before connecting new ones.
+---
+ profiles/audio/bap.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 97 insertions(+), 10 deletions(-)
+
+diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
+index 8e2fc1556a..d7ce9e0389 100644
+--- a/profiles/audio/bap.c
++++ b/profiles/audio/bap.c
+@@ -68,6 +68,7 @@ struct bap_ep {
+ GIOChannel *io;
+ unsigned int io_id;
+ bool recreate;
++ bool cig_active;
+ struct iovec *caps;
+ struct iovec *metadata;
+ struct bt_bap_qos qos;
+@@ -525,6 +526,7 @@ static void bap_io_close(struct bap_ep *ep)
+
+ g_io_channel_unref(ep->io);
+ ep->io = NULL;
++ ep->cig_active = false;
+ }
+
+ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg,
+@@ -988,7 +990,7 @@ drop:
+ g_io_channel_shutdown(io, TRUE, NULL);
+ }
+
+-static void bap_accept_io(struct bap_data *data, struct bt_bap_stream *stream,
++static void bap_accept_io(struct bap_ep *ep, struct bt_bap_stream *stream,
+ int fd, int defer)
+ {
+ char c;
+@@ -1025,12 +1027,52 @@ static void bap_accept_io(struct bap_data *data, struct bt_bap_stream *stream,
+ }
+ }
+
++ ep->cig_active = true;
++
+ return;
+
+ fail:
+ close(fd);
+ }
+
++struct cig_busy_data {
++ struct btd_adapter *adapter;
++ uint8_t cig;
++};
++
++static bool cig_busy_ep(const void *data, const void *match_data)
++{
++ const struct bap_ep *ep = data;
++ const struct cig_busy_data *info = match_data;
++
++ return (ep->qos.ucast.cig_id == info->cig) && ep->cig_active;
++}
++
++static bool cig_busy_session(const void *data, const void *match_data)
++{
++ const struct bap_data *session = data;
++ const struct cig_busy_data *info = match_data;
++
++ if (device_get_adapter(session->device) != info->adapter)
++ return false;
++
++ return queue_find(session->snks, cig_busy_ep, match_data) ||
++ queue_find(session->srcs, cig_busy_ep, match_data);
++}
++
++static bool is_cig_busy(struct bap_data *data, uint8_t cig)
++{
++ struct cig_busy_data info;
++
++ if (cig == BT_ISO_QOS_CIG_UNSET)
++ return false;
++
++ info.adapter = device_get_adapter(data->device);
++ info.cig = 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);
+
+@@ -1047,6 +1089,48 @@ static gboolean bap_io_recreate(void *user_data)
+ return FALSE;
+ }
+
++static void recreate_cig_ep(void *data, void *match_data)
++{
++ struct bap_ep *ep = (struct bap_ep *)data;
++ struct cig_busy_data *info = match_data;
++
++ if (ep->qos.ucast.cig_id != info->cig || !ep->recreate || ep->io_id)
++ return;
++
++ ep->recreate = false;
++ ep->io_id = g_idle_add(bap_io_recreate, ep);
++}
++
++static void recreate_cig_session(void *data, void *match_data)
++{
++ struct bap_data *session = data;
++ struct cig_busy_data *info = match_data;
++
++ if (device_get_adapter(session->device) != info->adapter)
++ return;
++
++ queue_foreach(session->snks, recreate_cig_ep, match_data);
++ queue_foreach(session->srcs, recreate_cig_ep, match_data);
++}
++
++static void recreate_cig(struct bap_ep *ep)
++{
++ struct bap_data *data = ep->data;
++ struct cig_busy_data info;
++
++ info.adapter = device_get_adapter(data->device);
++ info.cig = ep->qos.ucast.cig_id;
++
++ DBG("adapter %p ep %p recreate CIG %d", info.adapter, ep, info.cig);
++
++ if (ep->qos.ucast.cig_id == BT_ISO_QOS_CIG_UNSET) {
++ recreate_cig_ep(ep, &info);
++ return;
++ }
++
++ queue_foreach(sessions, recreate_cig_session, &info);
++}
++
+ static gboolean bap_io_disconnected(GIOChannel *io, GIOCondition cond,
+ gpointer user_data)
+ {
+@@ -1059,10 +1143,8 @@ static gboolean bap_io_disconnected(GIOChannel *io, GIOCondition cond,
+ bap_io_close(ep);
+
+ /* Check if connecting recreate IO */
+- if (ep->recreate) {
+- ep->recreate = false;
+- ep->io_id = g_idle_add(bap_io_recreate, ep);
+- }
++ if (!is_cig_busy(ep->data, ep->qos.ucast.cig_id))
++ recreate_cig(ep);
+
+ return FALSE;
+ }
+@@ -1087,18 +1169,22 @@ static void bap_connect_io(struct bap_data *data, struct bap_ep *ep,
+ int fd;
+
+ /* If IO already set skip creating it again */
+- if (bt_bap_stream_get_io(stream))
++ if (bt_bap_stream_get_io(stream)) {
++ DBG("ep %p stream %p has existing io", ep, stream);
+ return;
++ }
+
+ if (bt_bap_stream_io_is_connecting(stream, &fd)) {
+- bap_accept_io(data, stream, fd, defer);
++ bap_accept_io(ep, stream, fd, defer);
+ return;
+ }
+
+- /* If IO channel still up wait for it to be disconnected and then
+- * recreate.
++ /* If IO channel still up or CIG is busy, wait for it to be
++ * disconnected and then recreate.
+ */
+- if (ep->io) {
++ if (ep->io || is_cig_busy(data, ep->qos.ucast.cig_id)) {
++ DBG("ep %p stream %p defer %s wait recreate", ep, stream,
++ defer ? "true" : "false");
+ ep->recreate = true;
+ return;
+ }
+@@ -1131,6 +1217,7 @@ static void bap_connect_io(struct bap_data *data, struct bap_ep *ep,
+ bap_io_disconnected, ep);
+
+ ep->io = io;
++ ep->cig_active = !defer;
+
+ bt_bap_stream_io_connecting(stream, g_io_channel_unix_get_fd(io));
+ }
+--
+cgit
+
diff --git a/net-wireless/bluez/files/bluez-5.68-bap-nonzero.patch b/net-wireless/bluez/files/bluez-5.68-bap-nonzero.patch
new file mode 100644
index 000000000000..3a7ddd3c6f2a
--- /dev/null
+++ b/net-wireless/bluez/files/bluez-5.68-bap-nonzero.patch
@@ -0,0 +1,27 @@
+From 8fd0c76b41d35e24e10e45fcf57262482cb978a2 Mon Sep 17 00:00:00 2001
+From: Pauli Virtanen <pav@iki.fi>
+Date: Sun, 2 Jul 2023 22:34:19 +0300
+Subject: shared/bap: use only nonzero req->id
+
+In bap_req_new, use same pattern as elsewhere to not use zero as
+a valid id.
+---
+ src/shared/bap.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/shared/bap.c b/src/shared/bap.c
+index cf5d810bba..a0f5a0ae3c 100644
+--- a/src/shared/bap.c
++++ b/src/shared/bap.c
+@@ -4306,7 +4306,7 @@ static struct bt_bap_req *bap_req_new(struct bt_bap_stream *stream,
+ static unsigned int id;
+
+ req = new0(struct bt_bap_req, 1);
+- req->id = ++id;
++ req->id = ++id ? id : ++id;
+ req->stream = stream;
+ req->op = op;
+ req->iov = util_iov_dup(iov, len);
+--
+cgit
+
diff --git a/net-wireless/bluez/files/bluez-5.68-bap-resume.patch b/net-wireless/bluez/files/bluez-5.68-bap-resume.patch
new file mode 100644
index 000000000000..fbc2eeda89cc
--- /dev/null
+++ b/net-wireless/bluez/files/bluez-5.68-bap-resume.patch
@@ -0,0 +1,187 @@
+From 466fce0209a3878512672159168943047a9e2323 Mon Sep 17 00:00:00 2001
+From: Pauli Virtanen <pav@iki.fi>
+Date: Sun, 2 Jul 2023 22:34:18 +0300
+Subject: transport: handle BAP Enabling state correctly when resuming
+
+If BAP stream is in Enabling state when transport acquire is attempted,
+we should wait for bap_state_changed to emit the completion event.
+
+transport->resume() is only called with new owner with no
+owner->pending, and shall return nonzero completion id on success.
+Currently if BAP stream is Enabling, it returns zero which fails the
+acquire operation.
+
+To fix this, return valid completion id in this case instead. Also keep
+track of the g_idle_add resume id, so that we don't try to give it to
+bt_bap_stream_cancel.
+
+Fixes sound server getting spurious Not Authorized errors when trying to
+acquire a pending transport. This can happen on BAP server: linked
+transports become pending when the first of the two enters Streaming. If
+sound server tries to acquire the other linked transport whose stream is
+still Enabling, the acquire fails (media_owner_free +
+btd_error_not_authorized).
+
+Log:
+===============================================================
+profiles/audio/transport.c:bap_state_changed() stream 0x25c2880: qos(2) -> enabling(3)
+...
+profiles/audio/transport.c:bap_state_changed() stream 0x25cc590: qos(2) -> enabling(3)
+...
+src/shared/bap.c:bap_stream_state_changed() stream 0x25cc590 dir 0x01: enabling -> streaming
+profiles/audio/bap.c:bap_state() stream 0x25cc590: enabling(3) -> streaming(4)
+profiles/audio/transport.c:bap_state_changed() stream 0x25cc590: enabling(3) -> streaming(4)
+/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/fd1: fd(36) ready
+profiles/audio/transport.c:transport_update_playing() /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/fd1 State=TRANSPORT_STATE_IDLE Playing=1
+profiles/audio/transport.c:transport_set_state() State changed /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/fd1: TRANSPORT_STATE_IDLE -> TRANSPORT_STATE_PENDING
+profiles/audio/transport.c:transport_set_state() State changed /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/fd0: TRANSPORT_STATE_IDLE -> TRANSPORT_STATE_PENDING
+profiles/audio/transport.c:media_owner_create() Owner created: sender=:1.1242
+profiles/audio/transport.c:media_owner_free() Owner :1.1242
+===============================================================
+---
+ profiles/audio/transport.c | 67 +++++++++++++++++++++++++++++++++++++---------
+ 1 file changed, 55 insertions(+), 12 deletions(-)
+
+diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
+index 77216e10b3..aa3a718b0f 100644
+--- a/profiles/audio/transport.c
++++ b/profiles/audio/transport.c
+@@ -86,6 +86,7 @@ struct bap_transport {
+ unsigned int state_id;
+ bool linked;
+ struct bt_bap_qos qos;
++ guint resume_id;
+ };
+
+ struct media_transport {
+@@ -1191,17 +1192,27 @@ static void bap_enable_complete(struct bt_bap_stream *stream,
+ media_transport_remove_owner(owner->transport);
+ }
+
+-static gboolean resume_complete(void *data)
++static void bap_resume_complete(struct media_transport *transport)
+ {
+- struct media_transport *transport = data;
++ struct bap_transport *bap = transport->data;
+ struct media_owner *owner = transport->owner;
+
++ DBG("stream %p owner %p resume complete", bap->stream, owner);
++
++ if (bap->resume_id) {
++ g_source_remove(bap->resume_id);
++ bap->resume_id = 0;
++ }
++
+ if (!owner)
+- return FALSE;
++ return;
++
++ if (owner->pending)
++ owner->pending->id = 0;
+
+ if (transport->fd < 0) {
+ media_transport_remove_owner(transport);
+- return FALSE;
++ return;
+ }
+
+ if (owner->pending) {
+@@ -1215,15 +1226,13 @@ static gboolean resume_complete(void *data)
+ DBUS_TYPE_INVALID);
+ if (!ret) {
+ media_transport_remove_owner(transport);
+- return FALSE;
++ return;
+ }
+ }
+
+ media_owner_remove(owner);
+
+ transport_set_state(transport, TRANSPORT_STATE_ACTIVE);
+-
+- return FALSE;
+ }
+
+ static void bap_update_links(const struct media_transport *transport);
+@@ -1306,6 +1315,32 @@ static void bap_update_qos(const struct media_transport *transport)
+ "Delay");
+ }
+
++static gboolean bap_resume_complete_cb(void *data)
++{
++ struct media_transport *transport = data;
++ struct bap_transport *bap = transport->data;
++
++ bap->resume_id = 0;
++ bap_resume_complete(transport);
++ return FALSE;
++}
++
++static gboolean bap_resume_wait_cb(void *data)
++{
++ struct media_transport *transport = data;
++ struct bap_transport *bap = transport->data;
++ struct media_owner *owner = transport->owner;
++
++ /* bap_state_changed will call completion callback when ready */
++ DBG("stream %p owner %p resume wait", bap->stream, owner);
++
++ bap->resume_id = 0;
++ if (owner && owner->pending)
++ owner->pending->id = 0;
++
++ return FALSE;
++}
++
+ static guint resume_bap(struct media_transport *transport,
+ struct media_owner *owner)
+ {
+@@ -1315,17 +1350,19 @@ static guint resume_bap(struct media_transport *transport,
+
+ if (!bap->stream)
+ return 0;
++ if (bap->resume_id)
++ return 0;
+
+ bap_update_links(transport);
+
+ switch (bt_bap_stream_get_state(bap->stream)) {
+ case BT_BAP_STREAM_STATE_ENABLING:
+ bap_enable_complete(bap->stream, 0x00, 0x00, owner);
+- if (owner->pending)
+- return owner->pending->id;
+- return 0;
++ bap->resume_id = g_idle_add(bap_resume_wait_cb, transport);
++ return bap->resume_id;
+ case BT_BAP_STREAM_STATE_STREAMING:
+- return g_idle_add(resume_complete, transport);
++ bap->resume_id = g_idle_add(bap_resume_complete_cb, transport);
++ return bap->resume_id;
+ }
+
+ meta = bt_bap_stream_get_metadata(bap->stream);
+@@ -1389,6 +1426,12 @@ static void cancel_bap(struct media_transport *transport, guint id)
+ {
+ struct bap_transport *bap = transport->data;
+
++ if (id == bap->resume_id && bap->resume_id) {
++ g_source_remove(bap->resume_id);
++ bap->resume_id = 0;
++ return;
++ }
++
+ if (!bap->stream)
+ return;
+
+@@ -1491,7 +1534,7 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state,
+ transport_update_playing(transport, TRUE);
+
+ done:
+- resume_complete(transport);
++ bap_resume_complete(transport);
+ }
+
+ static void bap_connecting(struct bt_bap_stream *stream, bool state, int fd,
+--
+cgit
+
diff --git a/net-wireless/bluez/files/bluez-5.68-heap-use-after-free.patch b/net-wireless/bluez/files/bluez-5.68-heap-use-after-free.patch
new file mode 100644
index 000000000000..3cc6733634a5
--- /dev/null
+++ b/net-wireless/bluez/files/bluez-5.68-heap-use-after-free.patch
@@ -0,0 +1,41 @@
+From b741460688925448807c7532fe96182e4d32ec42 Mon Sep 17 00:00:00 2001
+From: Vlad Pruteanu <vlad.pruteanu@nxp.com>
+Date: Tue, 4 Jul 2023 08:56:43 +0300
+Subject: plugins/admin: Fix heap-use-after-free when using 2 controllers
+
+This commit fixes the heap-use-after-free error when connecting 2
+controllers. When a controller is connected
+admin_policy_adapter_probe is called. If policy_data was already
+allocated it gets freed, if not, it only gets allocated. Eventually
+add_interface is called. Here policy_data is put in the "data" variable
+(specific for each controller) and the process_changes task is called
+with idle priority. This function ultimately accesses policy_data from
+the "data" variable.
+
+When Bluez crashes the flow is:
+1)first controller is attached
+2)admin_policy_adapter_probe is called and policy_data is allocated
+4)second controller is attached
+5)admin_policy_adapter_probe is called and policy_data is freed, then
+allocated again
+6)process_changes runs and the policy_data for the first controller is
+read, but it was already freed, thus the crash
+---
+ plugins/admin.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/plugins/admin.c b/plugins/admin.c
+index 68e9237d3f..16b74cfbf0 100644
+--- a/plugins/admin.c
++++ b/plugins/admin.c
+@@ -502,7 +502,6 @@ static int admin_policy_adapter_probe(struct btd_adapter *adapter)
+ if (policy_data) {
+ btd_warn(policy_data->adapter_id,
+ "Policy data already exists");
+- admin_policy_free(policy_data);
+ policy_data = NULL;
+ }
+
+--
+cgit
+
diff --git a/net-wireless/bluez/files/bluez-5.68-monitor-decoding.patch b/net-wireless/bluez/files/bluez-5.68-monitor-decoding.patch
new file mode 100644
index 000000000000..6d5c6306ccd3
--- /dev/null
+++ b/net-wireless/bluez/files/bluez-5.68-monitor-decoding.patch
@@ -0,0 +1,45 @@
+From f9557931ad361e08f1f1537ea670fedd1dd0138d Mon Sep 17 00:00:00 2001
+From: Claudia Draghicescu <claudia.rosu@nxp.com>
+Date: Tue, 4 Jul 2023 10:41:44 +0300
+Subject: monitor: Add decoding support for Sync Receiver events
+
+This commit adds decoding support for PA Sync Established,
+BIG Sync Established and BIG Sync Lost events.
+---
+ lib/mgmt.h | 3 +++
+ monitor/packet.c | 5 +++++
+ 2 files changed, 8 insertions(+)
+
+diff --git a/lib/mgmt.h b/lib/mgmt.h
+index 062fa02712..8f92b77315 100644
+--- a/lib/mgmt.h
++++ b/lib/mgmt.h
+@@ -1238,6 +1238,9 @@ static const char *mgmt_ev[] = {
+ "Advertisement Monitor Device Lost",
+ "Mesh Packet Found",
+ "Mesh Packet Complete",
++ "PA Sync Established",
++ "BIG Sync Established",
++ "BIG Sync Lost",
+ };
+
+ static const char *mgmt_status[] = {
+diff --git a/monitor/packet.c b/monitor/packet.c
+index a871c7f272..f2167fb52a 100644
+--- a/monitor/packet.c
++++ b/monitor/packet.c
+@@ -3093,6 +3093,11 @@ static const struct bitfield_data events_le_table[] = {
+ { 27, "LE Terminate BIG Complete" },
+ { 28, "LE BIG Sync Estabilished Complete" },
+ { 29, "LE BIG Sync Lost" },
++ { 30, "LE Request Peer SCA Complete"},
++ { 31, "LE Path Loss Threshold" },
++ { 32, "LE Transmit Power Reporting" },
++ { 33, "LE BIG Info Advertising Report" },
++ { 34, "LE Subrate Change" },
+ { }
+ };
+
+--
+cgit
+