From f93c4dece004b2ab0a3e54361f6f11b3b380bbb1 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 12 May 2020 13:34:31 -0700 Subject: [PATCH] Bluetooth: userchan: Add support for ISO packets This adds supports for ISO packets so then can be transmitted and received with userchan driver. Signed-off-by: Luiz Augusto von Dentz --- drivers/bluetooth/hci/userchan.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/hci/userchan.c b/drivers/bluetooth/hci/userchan.c index 8901f7c54a2..7039bdfa75c 100644 --- a/drivers/bluetooth/hci/userchan.c +++ b/drivers/bluetooth/hci/userchan.c @@ -46,6 +46,7 @@ struct sockaddr_hci { #define H4_ACL 0x02 #define H4_SCO 0x03 #define H4_EVT 0x04 +#define H4_ISO 0x05 static K_KERNEL_STACK_DEFINE(rx_thread_stack, CONFIG_ARCH_POSIX_RECOMMENDED_STACK_SIZE); @@ -57,11 +58,21 @@ static int bt_dev_index = -1; static struct net_buf *get_rx(const uint8_t *buf) { - if (buf[0] == H4_EVT) { + switch (buf[0]) { + case H4_EVT: return bt_buf_get_evt(buf[1], false, K_FOREVER); + case H4_ACL: + return bt_buf_get_rx(BT_BUF_ACL_IN, K_FOREVER); + case H4_ISO: + if (IS_ENABLED(CONFIG_BT_ISO)) { + return bt_buf_get_rx(BT_BUF_ISO_IN, K_FOREVER); + } + __fallthrough; + default: + BT_ERR("Unknown packet type: %u", buf[0]); } - return bt_buf_get_rx(BT_BUF_ACL_IN, K_FOREVER); + return NULL; } static bool uc_ready(void) @@ -131,6 +142,12 @@ static int uc_send(struct net_buf *buf) case BT_BUF_CMD: net_buf_push_u8(buf, H4_CMD); break; + case BT_BUF_ISO_OUT: + if (IS_ENABLED(CONFIG_BT_ISO)) { + net_buf_push_u8(buf, H4_ISO); + break; + } + __fallthrough; default: BT_ERR("Unknown buffer type"); return -EINVAL;