diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-04-06 08:44:59 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-04-07 18:48:21 +0200 |
commit | 79b8df9362e8bd1951e1fddbd65ca87af8df52c8 (patch) | |
tree | b34a614b874924bbdb49dddfacb5fe2636d3a484 /drivers/bluetooth/hci_uart.h | |
parent | Bluetooth: btbcm: Add firmware table for UART based devices (diff) | |
download | linux-79b8df9362e8bd1951e1fddbd65ca87af8df52c8.tar.xz linux-79b8df9362e8bd1951e1fddbd65ca87af8df52c8.zip |
Bluetooth: hci_uart: Provide generic H:4 receive framework
Future H:4 based UART drivers require custom packet types and custom
receive functions. To support this, extended the h4_recv_buf function
with a packet definition table.
For the default H:4 packets types of ACL data, SCO data and events,
provide helpers to reduce the amount of code duplication.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'drivers/bluetooth/hci_uart.h')
-rw-r--r-- | drivers/bluetooth/hci_uart.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index a3108abce5d3..d1fa6263f7c2 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h @@ -101,8 +101,39 @@ int hci_uart_init_ready(struct hci_uart *hu); int h4_init(void); int h4_deinit(void); +struct h4_recv_pkt { + u8 type; /* Packet type */ + u8 hlen; /* Header length */ + u8 loff; /* Data length offset in header */ + u8 lsize; /* Data length field size */ + u16 maxlen; /* Max overall packet length */ + int (*recv)(struct hci_dev *hdev, struct sk_buff *skb); +}; + +#define H4_RECV_ACL \ + .type = HCI_ACLDATA_PKT, \ + .hlen = HCI_ACL_HDR_SIZE, \ + .loff = 2, \ + .lsize = 2, \ + .maxlen = HCI_MAX_FRAME_SIZE \ + +#define H4_RECV_SCO \ + .type = HCI_SCODATA_PKT, \ + .hlen = HCI_SCO_HDR_SIZE, \ + .loff = 2, \ + .lsize = 1, \ + .maxlen = HCI_MAX_SCO_SIZE + +#define H4_RECV_EVENT \ + .type = HCI_EVENT_PKT, \ + .hlen = HCI_EVENT_HDR_SIZE, \ + .loff = 1, \ + .lsize = 1, \ + .maxlen = HCI_MAX_EVENT_SIZE + struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb, - const unsigned char *buffer, int count); + const unsigned char *buffer, int count, + const struct h4_recv_pkt *pkts, int pkts_count); #endif #ifdef CONFIG_BT_HCIUART_BCSP |