Skip to content

Commit 3a53034

Browse files
committed
Bluetooth: Remove USB H4 mode support
This non-standard feature never had any proper host side implementation (e.g. it was never upstreamed to BlueZ), and since it comes with notable maintenance overhead it's fair to just remove it. The mode was also the only user of the vendor extension feature of the HCI raw API, so that's also removed in the same go. Signed-off-by: Johan Hedberg <[email protected]>
1 parent 7a2a1ba commit 3a53034

File tree

7 files changed

+13
-303
lines changed

7 files changed

+13
-303
lines changed

include/zephyr/bluetooth/buf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void bt_buf_rx_freed_cb_set(bt_buf_rx_freed_cb_t cb);
171171
* @param type Type of buffer. BT_BUF_CMD or BT_BUF_ACL_OUT.
172172
* @param timeout Non-negative waiting period to obtain a buffer or one of the
173173
* special values K_NO_WAIT and K_FOREVER.
174-
* @param data Initial data to append to buffer.
174+
* @param data Initial data to append to buffer. This is optional and can be NULL.
175175
* @param size Initial data size.
176176
* @return A new buffer.
177177
*/

include/zephyr/bluetooth/hci_raw.h

-81
Original file line numberDiff line numberDiff line change
@@ -38,87 +38,6 @@ extern "C" {
3838
*/
3939
int bt_send(struct net_buf *buf);
4040

41-
enum {
42-
/** Passthrough mode
43-
*
44-
* While in this mode the buffers are passed as is between the stack
45-
* and the driver.
46-
*/
47-
BT_HCI_RAW_MODE_PASSTHROUGH = 0x00,
48-
49-
/** H:4 mode
50-
*
51-
* While in this mode H:4 headers will added into the buffers
52-
* according to the buffer type when coming from the stack and will be
53-
* removed and used to set the buffer type.
54-
*/
55-
BT_HCI_RAW_MODE_H4 = 0x01,
56-
};
57-
58-
/** @brief Set Bluetooth RAW channel mode
59-
*
60-
* Set access mode of Bluetooth RAW channel.
61-
*
62-
* @param mode Access mode.
63-
*
64-
* @return Zero on success or (negative) error code otherwise.
65-
*/
66-
int bt_hci_raw_set_mode(uint8_t mode);
67-
68-
/** @brief Get Bluetooth RAW channel mode
69-
*
70-
* Get access mode of Bluetooth RAW channel.
71-
*
72-
* @return Access mode.
73-
*/
74-
uint8_t bt_hci_raw_get_mode(void);
75-
76-
#define BT_HCI_ERR_EXT_HANDLED 0xff
77-
78-
/** Helper macro to define a command extension
79-
*
80-
* @param _op Opcode of the command.
81-
* @param _min_len Minimal length of the command.
82-
* @param _func Handler function to be called.
83-
*/
84-
#define BT_HCI_RAW_CMD_EXT(_op, _min_len, _func) \
85-
{ \
86-
.op = _op, \
87-
.min_len = _min_len, \
88-
.func = _func, \
89-
}
90-
91-
struct bt_hci_raw_cmd_ext {
92-
/** Opcode of the command */
93-
uint16_t op;
94-
95-
/** Minimal length of the command */
96-
size_t min_len;
97-
98-
/** Handler function.
99-
*
100-
* Handler function to be called when a command is intercepted.
101-
*
102-
* @param buf Buffer containing the command.
103-
*
104-
* @return HCI Status code or BT_HCI_ERR_EXT_HANDLED if command has
105-
* been handled already and a response has been sent as oppose to
106-
* BT_HCI_ERR_SUCCESS which just indicates that the command can be
107-
* sent to the controller to be processed.
108-
*/
109-
uint8_t (*func)(struct net_buf *buf);
110-
};
111-
112-
/** @brief Register Bluetooth RAW command extension table
113-
*
114-
* Register Bluetooth RAW channel command extension table, opcodes in this
115-
* table are intercepted to sent to the handler function.
116-
*
117-
* @param cmds Pointer to the command extension table.
118-
* @param size Size of the command extension table.
119-
*/
120-
void bt_hci_raw_cmd_ext_register(struct bt_hci_raw_cmd_ext *cmds, size_t size);
121-
12241
/** @brief Enable Bluetooth RAW channel:
12342
*
12443
* Enable Bluetooth RAW HCI channel.

samples/bluetooth/hci_usb/prj.conf

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ CONFIG_BT_HCI_RAW=y
44
CONFIG_USB_DEVICE_STACK=y
55
CONFIG_USB_DEVICE_PID=0x000B
66
CONFIG_USB_DEVICE_BLUETOOTH=y
7-
CONFIG_USB_DEVICE_BLUETOOTH_VS_H4=n
87
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
98

109
# We dont want any console or CDC ACM that may cause BlueZ to not detect hci_usb

subsys/bluetooth/controller/hci/hci.c

-14
Original file line numberDiff line numberDiff line change
@@ -5051,12 +5051,6 @@ static void vs_read_supported_commands(struct net_buf *buf,
50515051
/* Write Tx Power, Read Tx Power */
50525052
rp->commands[1] |= BIT(5) | BIT(6);
50535053
#endif /* CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL */
5054-
#if defined(CONFIG_USB_DEVICE_BLUETOOTH_VS_H4)
5055-
/* Read Supported USB Transport Modes */
5056-
rp->commands[1] |= BIT(7);
5057-
/* Set USB Transport Mode */
5058-
rp->commands[2] |= BIT(0);
5059-
#endif /* USB_DEVICE_BLUETOOTH_VS_H4 */
50605054
}
50615055

50625056
static void vs_read_supported_features(struct net_buf *buf,
@@ -5699,14 +5693,6 @@ int hci_vendor_cmd_handle_common(uint16_t ocf, struct net_buf *cmd,
56995693
vs_read_supported_features(cmd, evt);
57005694
break;
57015695

5702-
#if defined(CONFIG_USB_DEVICE_BLUETOOTH_VS_H4)
5703-
case BT_OCF(BT_HCI_OP_VS_READ_USB_TRANSPORT_MODE):
5704-
break;
5705-
case BT_OCF(BT_HCI_OP_VS_SET_USB_TRANSPORT_MODE):
5706-
reset(cmd, evt);
5707-
break;
5708-
#endif /* CONFIG_USB_DEVICE_BLUETOOTH_VS_H4 */
5709-
57105696
case BT_OCF(BT_HCI_OP_VS_READ_BUILD_INFO):
57115697
vs_read_build_info(cmd, evt);
57125698
break;

subsys/bluetooth/host/hci_raw.c

+3-106
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ BUILD_ASSERT(IS_ENABLED(CONFIG_ZTEST), "Missing DT chosen property for HCI");
7676
struct bt_dev_raw bt_dev = {
7777
.hci = BT_HCI_DEV,
7878
};
79-
struct bt_hci_raw_cmd_ext *cmd_ext;
80-
static size_t cmd_ext_size;
8179

8280
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
8381
{
@@ -172,121 +170,20 @@ int bt_hci_recv(const struct device *dev, struct net_buf *buf)
172170
return 0;
173171
}
174172

175-
static void bt_cmd_complete_ext(uint16_t op, uint8_t status)
176-
{
177-
struct net_buf *buf;
178-
struct bt_hci_evt_cc_status *cc;
179-
180-
if (status == BT_HCI_ERR_EXT_HANDLED) {
181-
return;
182-
}
183-
184-
buf = bt_hci_cmd_complete_create(op, sizeof(*cc));
185-
cc = net_buf_add(buf, sizeof(*cc));
186-
cc->status = status;
187-
188-
bt_hci_recv(bt_dev.hci, buf);
189-
}
190-
191-
static uint8_t bt_send_ext(struct net_buf *buf)
192-
{
193-
struct bt_hci_cmd_hdr *hdr;
194-
struct net_buf_simple_state state;
195-
int i;
196-
uint16_t op;
197-
uint8_t status;
198-
199-
status = BT_HCI_ERR_SUCCESS;
200-
201-
if (!cmd_ext) {
202-
return status;
203-
}
204-
205-
net_buf_simple_save(&buf->b, &state);
206-
207-
if (buf->len < sizeof(*hdr)) {
208-
LOG_ERR("No HCI Command header");
209-
return BT_HCI_ERR_INVALID_PARAM;
210-
}
211-
212-
hdr = net_buf_pull_mem(buf, sizeof(*hdr));
213-
if (buf->len < hdr->param_len) {
214-
LOG_ERR("Invalid HCI CMD packet length");
215-
return BT_HCI_ERR_INVALID_PARAM;
216-
}
217-
218-
op = sys_le16_to_cpu(hdr->opcode);
219-
220-
for (i = 0; i < cmd_ext_size; i++) {
221-
struct bt_hci_raw_cmd_ext *cmd = &cmd_ext[i];
222-
223-
if (cmd->op == op) {
224-
if (buf->len < cmd->min_len) {
225-
status = BT_HCI_ERR_INVALID_PARAM;
226-
} else {
227-
status = cmd->func(buf);
228-
}
229-
230-
break;
231-
}
232-
}
233-
234-
if (status) {
235-
bt_cmd_complete_ext(op, status);
236-
return status;
237-
}
238-
239-
net_buf_simple_restore(&buf->b, &state);
240-
241-
return status;
242-
}
243-
244173
int bt_send(struct net_buf *buf)
245174
{
246-
uint8_t type = bt_buf_get_type(buf);
247-
248-
LOG_DBG("buf %p type %u len %u", buf, type, buf->len);
249-
250175
if (buf->len == 0) {
251176
return BT_HCI_ERR_INVALID_PARAM;
252177
}
253178

254-
bt_monitor_send(bt_monitor_opcode(type, BT_MONITOR_TX), buf->data, buf->len);
255-
256-
if (IS_ENABLED(CONFIG_BT_HCI_RAW_CMD_EXT) && type == BT_BUF_CMD) {
257-
uint8_t status;
258-
259-
status = bt_send_ext(buf);
260-
if (status) {
261-
return status;
262-
}
263-
}
179+
LOG_DBG("buf %p type %u len %u", buf, buf->data[0], buf->len);
264180

265-
/* Put back the type byte */
266-
bt_buf_set_type(buf, type);
181+
bt_monitor_send(bt_monitor_opcode(buf->data[0], BT_MONITOR_TX),
182+
buf->data + 1, buf->len - 1);
267183

268184
return bt_hci_send(bt_dev.hci, buf);
269185
}
270186

271-
int bt_hci_raw_set_mode(uint8_t mode)
272-
{
273-
LOG_DBG("mode %u", mode);
274-
return 0;
275-
}
276-
277-
uint8_t bt_hci_raw_get_mode(void)
278-
{
279-
return BT_HCI_RAW_MODE_H4;
280-
}
281-
282-
void bt_hci_raw_cmd_ext_register(struct bt_hci_raw_cmd_ext *cmds, size_t size)
283-
{
284-
if (IS_ENABLED(CONFIG_BT_HCI_RAW_CMD_EXT)) {
285-
cmd_ext = cmds;
286-
cmd_ext_size = size;
287-
}
288-
}
289-
290187
int bt_enable_raw(struct k_fifo *rx_queue)
291188
{
292189
int err;

subsys/usb/device/class/Kconfig.bt

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
# Copyright (c) 2016 Wind River Systems, Inc.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
menuconfig USB_DEVICE_BLUETOOTH
4+
config USB_DEVICE_BLUETOOTH
55
bool "USB Bluetooth Device Class support"
66
select BT
77
select BT_HCI_RAW
88
help
99
USB Bluetooth device class support
10-
11-
config USB_DEVICE_BLUETOOTH_VS_H4
12-
bool "USB Bluetooth H4 vendor command"
13-
depends on USB_DEVICE_BLUETOOTH
14-
select BT_HCI_RAW_H4
15-
select BT_HCI_RAW_CMD_EXT
16-
help
17-
Enables vendor command to switch to H:4 transport using the bulk
18-
endpoint.

0 commit comments

Comments
 (0)