Loading drivers/bluetooth/Kconfig +0 −8 Original line number Diff line number Diff line Loading @@ -55,14 +55,6 @@ config BT_HCIUART_BCSP Say Y here to compile support for HCI BCSP protocol. config BT_HCIUART_BCSP_TXCRC bool "Transmit CRC with every BCSP packet" depends on BT_HCIUART_BCSP help If you say Y here, a 16-bit CRC checksum will be transmitted along with every BCSP (BlueCore Serial Protocol) packet sent to the Bluetooth chip. This increases reliability, but slightly reduces efficiency. config BT_HCIBCM203X tristate "HCI BCM203x USB driver" depends on USB Loading drivers/bluetooth/bpa10x.c +3 −0 Original line number Diff line number Diff line Loading @@ -550,6 +550,9 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id * if (ignore) return -ENODEV; if (intf->cur_altsetting->desc.bInterfaceNumber > 0) return -ENODEV; data = kmalloc(sizeof(*data), GFP_KERNEL); if (!data) { BT_ERR("Can't allocate data structure"); Loading drivers/bluetooth/hci_bcsp.c +100 −60 Original line number Diff line number Diff line /* BlueCore Serial Protocol (BCSP) for Linux Bluetooth stack (BlueZ). Copyright 2002 by Fabrizio Gennari <fabrizio.gennari@philips.com> Based on hci_h4.c by Maxim Krasnyansky <maxk@qualcomm.com> ABCSP by Carl Orsborn <cjo@csr.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS SOFTWARE IS DISCLAIMED. * * Bluetooth HCI UART driver * * Copyright (C) 2002-2003 Fabrizio Gennari <fabrizio.gennari@philips.com> * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * $Id: hci_bcsp.c,v 1.2 2002/09/26 05:05:14 maxk Exp $ */ #define VERSION "0.2" #include <linux/config.h> #include <linux/module.h> Loading @@ -52,16 +44,56 @@ #include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> #include "hci_uart.h" #include "hci_bcsp.h" #ifndef CONFIG_BT_HCIUART_DEBUG #undef BT_DBG #define BT_DBG( A... ) #endif #define VERSION "0.3" static int txcrc = 1; static int hciextn = 1; #define BCSP_TXWINSIZE 4 #define BCSP_ACK_PKT 0x05 #define BCSP_LE_PKT 0x06 struct bcsp_struct { struct sk_buff_head unack; /* Unack'ed packets queue */ struct sk_buff_head rel; /* Reliable packets queue */ struct sk_buff_head unrel; /* Unreliable packets queue */ unsigned long rx_count; struct sk_buff *rx_skb; u8 rxseq_txack; /* rxseq == txack. */ u8 rxack; /* Last packet sent by us that the peer ack'ed */ struct timer_list tbcsp; enum { BCSP_W4_PKT_DELIMITER, BCSP_W4_PKT_START, BCSP_W4_BCSP_HDR, BCSP_W4_DATA, BCSP_W4_CRC } rx_state; enum { BCSP_ESCSTATE_NOESC, BCSP_ESCSTATE_ESC } rx_esc_state; u8 use_crc; u16 message_crc; u8 txack_req; /* Do we need to send ack's to the peer? */ /* Reliable packet sequence number - used to assign seq to each rel pkt. */ u8 msgq_txseq; }; /* ---- BCSP CRC calculation ---- */ /* Table for calculating CRC for polynomial 0x1021, LSB processed first, Loading Loading @@ -111,6 +143,7 @@ static u16 bcsp_crc_reverse(u16 crc) rev |= (crc & 1); crc = crc >> 1; } return (rev); } Loading @@ -119,6 +152,7 @@ static u16 bcsp_crc_reverse(u16 crc) static void bcsp_slip_msgdelim(struct sk_buff *skb) { const char pkt_delim = 0xc0; memcpy(skb_put(skb, 1), &pkt_delim, 1); } Loading Loading @@ -173,11 +207,8 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data, { struct sk_buff *nskb; u8 hdr[4], chan; int rel, i; #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC u16 BCSP_CRC_INIT(bcsp_txmsg_crc); #endif int rel, i; switch (pkt_type) { case HCI_ACLDATA_PKT: Loading Loading @@ -240,9 +271,9 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data, BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq); bcsp->msgq_txseq = ++(bcsp->msgq_txseq) & 0x07; } #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC if (bcsp->use_crc) hdr[0] |= 0x40; #endif hdr[1] = ((len << 4) & 0xff) | chan; hdr[2] = len >> 4; Loading @@ -251,25 +282,25 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data, /* Put BCSP header */ for (i = 0; i < 4; i++) { bcsp_slip_one_byte(nskb, hdr[i]); #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC if (bcsp->use_crc) bcsp_crc_update(&bcsp_txmsg_crc, hdr[i]); #endif } /* Put payload */ for (i = 0; i < len; i++) { bcsp_slip_one_byte(nskb, data[i]); #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC if (bcsp->use_crc) bcsp_crc_update(&bcsp_txmsg_crc, data[i]); #endif } #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC /* Put CRC */ if (bcsp->use_crc) { bcsp_txmsg_crc = bcsp_crc_reverse(bcsp_txmsg_crc); bcsp_slip_one_byte(nskb, (u8) ((bcsp_txmsg_crc >> 8) & 0x00ff)); bcsp_slip_one_byte(nskb, (u8) (bcsp_txmsg_crc & 0x00ff)); #endif } bcsp_slip_msgdelim(nskb); return nskb; Loading Loading @@ -317,7 +348,6 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu) spin_unlock_irqrestore(&bcsp->unack.lock, flags); /* We could not send a reliable packet, either because there are none or because there are too many unack'ed pkts. Did we receive any packets we have not acknowledged yet ? */ Loading Loading @@ -374,8 +404,10 @@ static void bcsp_pkt_cull(struct bcsp_struct *bcsp) kfree_skb(skb); skb = nskb; } if (bcsp->unack.qlen == 0) del_timer(&bcsp->tbcsp); spin_unlock_irqrestore(&bcsp->unack.lock, flags); if (i != pkts_to_be_removed) Loading Loading @@ -530,6 +562,7 @@ static inline void bcsp_complete_rx_pkt(struct hci_uart *hu) hci_recv_frame(bcsp->rx_skb); } bcsp->rx_state = BCSP_W4_PKT_DELIMITER; bcsp->rx_skb = NULL; } Loading Loading @@ -698,6 +731,9 @@ static int bcsp_open(struct hci_uart *hu) bcsp->rx_state = BCSP_W4_PKT_DELIMITER; if (txcrc) bcsp->use_crc = 1; return 0; } Loading Loading @@ -730,6 +766,7 @@ static struct hci_uart_proto bcsp = { int bcsp_init(void) { int err = hci_uart_register_proto(&bcsp); if (!err) BT_INFO("HCI BCSP protocol initialized"); else Loading @@ -743,5 +780,8 @@ int bcsp_deinit(void) return hci_uart_unregister_proto(&bcsp); } module_param(txcrc, bool, 0644); MODULE_PARM_DESC(txcrc, "Transmit CRC with every BCSP packet"); module_param(hciextn, bool, 0644); MODULE_PARM_DESC(hciextn, "Convert HCI Extensions into BCSP packets"); drivers/bluetooth/hci_bcsp.hdeleted 100644 → 0 +0 −70 Original line number Diff line number Diff line /* BlueCore Serial Protocol (BCSP) for Linux Bluetooth stack (BlueZ). Copyright 2002 by Fabrizio Gennari <fabrizio.gennari@philips.com> Based on hci_h4.c by Maxim Krasnyansky <maxk@qualcomm.com> ABCSP by Carl Orsborn <cjo@csr.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS SOFTWARE IS DISCLAIMED. */ /* * $Id: hci_bcsp.h,v 1.2 2002/09/26 05:05:14 maxk Exp $ */ #ifndef __HCI_BCSP_H__ #define __HCI_BCSP_H__ #define BCSP_TXWINSIZE 4 #define BCSP_ACK_PKT 0x05 #define BCSP_LE_PKT 0x06 struct bcsp_struct { struct sk_buff_head unack; /* Unack'ed packets queue */ struct sk_buff_head rel; /* Reliable packets queue */ struct sk_buff_head unrel; /* Unreliable packets queue */ unsigned long rx_count; struct sk_buff *rx_skb; u8 rxseq_txack; /* rxseq == txack. */ u8 rxack; /* Last packet sent by us that the peer ack'ed */ struct timer_list tbcsp; enum { BCSP_W4_PKT_DELIMITER, BCSP_W4_PKT_START, BCSP_W4_BCSP_HDR, BCSP_W4_DATA, BCSP_W4_CRC } rx_state; enum { BCSP_ESCSTATE_NOESC, BCSP_ESCSTATE_ESC } rx_esc_state; u16 message_crc; u8 txack_req; /* Do we need to send ack's to the peer? */ /* Reliable packet sequence number - used to assign seq to each rel pkt. */ u8 msgq_txseq; }; #endif /* __HCI_BCSP_H__ */ drivers/bluetooth/hci_h4.c +62 −39 Original line number Diff line number Diff line /* BlueZ - Bluetooth protocol stack for Linux Copyright (C) 2000-2001 Qualcomm Incorporated Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS SOFTWARE IS DISCLAIMED. */ /* * Bluetooth HCI UART(H4) protocol. * * $Id: hci_h4.c,v 1.3 2002/09/09 01:17:32 maxk Exp $ * Bluetooth HCI UART driver * * Copyright (C) 2000-2001 Qualcomm Incorporated * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #define VERSION "1.2" #include <linux/config.h> #include <linux/module.h> Loading @@ -51,14 +45,30 @@ #include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> #include "hci_uart.h" #include "hci_h4.h" #ifndef CONFIG_BT_HCIUART_DEBUG #undef BT_DBG #define BT_DBG( A... ) #endif #define VERSION "1.2" struct h4_struct { unsigned long rx_state; unsigned long rx_count; struct sk_buff *rx_skb; struct sk_buff_head txq; }; /* H4 receiver States */ #define H4_W4_PACKET_TYPE 0 #define H4_W4_EVENT_HDR 1 #define H4_W4_ACL_HDR 2 #define H4_W4_SCO_HDR 3 #define H4_W4_DATA 4 /* Initialize protocol */ static int h4_open(struct hci_uart *hu) { Loading @@ -69,6 +79,7 @@ static int h4_open(struct hci_uart *hu) h4 = kmalloc(sizeof(*h4), GFP_ATOMIC); if (!h4) return -ENOMEM; memset(h4, 0, sizeof(*h4)); skb_queue_head_init(&h4->txq); Loading @@ -83,7 +94,9 @@ static int h4_flush(struct hci_uart *hu) struct h4_struct *h4 = hu->priv; BT_DBG("hu %p", hu); skb_queue_purge(&h4->txq); return 0; } Loading @@ -91,16 +104,19 @@ static int h4_flush(struct hci_uart *hu) static int h4_close(struct hci_uart *hu) { struct h4_struct *h4 = hu->priv; hu->priv = NULL; BT_DBG("hu %p", hu); skb_queue_purge(&h4->txq); if (h4->rx_skb) kfree_skb(h4->rx_skb); hu->priv = NULL; kfree(h4); return 0; } Loading @@ -114,6 +130,7 @@ static int h4_enqueue(struct hci_uart *hu, struct sk_buff *skb) /* Prepend skb with frame type */ memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); skb_queue_tail(&h4->txq, skb); return 0; } Loading @@ -122,6 +139,7 @@ static inline int h4_check_data_len(struct h4_struct *h4, int len) register int room = skb_tailroom(h4->rx_skb); BT_DBG("len %d room %d", len, room); if (!len) { hci_recv_frame(h4->rx_skb); } else if (len > room) { Loading @@ -136,6 +154,7 @@ static inline int h4_check_data_len(struct h4_struct *h4, int len) h4->rx_state = H4_W4_PACKET_TYPE; h4->rx_skb = NULL; h4->rx_count = 0; return 0; } Loading Loading @@ -228,6 +247,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ptr++; count--; continue; }; ptr++; count--; /* Allocate packet */ Loading @@ -238,9 +258,11 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) h4->rx_count = 0; return 0; } h4->rx_skb->dev = (void *) hu->hdev; bt_cb(h4->rx_skb)->pkt_type = type; } return count; } Loading @@ -263,6 +285,7 @@ static struct hci_uart_proto h4p = { int h4_init(void) { int err = hci_uart_register_proto(&h4p); if (!err) BT_INFO("HCI H4 protocol initialized"); else Loading Loading
drivers/bluetooth/Kconfig +0 −8 Original line number Diff line number Diff line Loading @@ -55,14 +55,6 @@ config BT_HCIUART_BCSP Say Y here to compile support for HCI BCSP protocol. config BT_HCIUART_BCSP_TXCRC bool "Transmit CRC with every BCSP packet" depends on BT_HCIUART_BCSP help If you say Y here, a 16-bit CRC checksum will be transmitted along with every BCSP (BlueCore Serial Protocol) packet sent to the Bluetooth chip. This increases reliability, but slightly reduces efficiency. config BT_HCIBCM203X tristate "HCI BCM203x USB driver" depends on USB Loading
drivers/bluetooth/bpa10x.c +3 −0 Original line number Diff line number Diff line Loading @@ -550,6 +550,9 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id * if (ignore) return -ENODEV; if (intf->cur_altsetting->desc.bInterfaceNumber > 0) return -ENODEV; data = kmalloc(sizeof(*data), GFP_KERNEL); if (!data) { BT_ERR("Can't allocate data structure"); Loading
drivers/bluetooth/hci_bcsp.c +100 −60 Original line number Diff line number Diff line /* BlueCore Serial Protocol (BCSP) for Linux Bluetooth stack (BlueZ). Copyright 2002 by Fabrizio Gennari <fabrizio.gennari@philips.com> Based on hci_h4.c by Maxim Krasnyansky <maxk@qualcomm.com> ABCSP by Carl Orsborn <cjo@csr.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS SOFTWARE IS DISCLAIMED. * * Bluetooth HCI UART driver * * Copyright (C) 2002-2003 Fabrizio Gennari <fabrizio.gennari@philips.com> * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * $Id: hci_bcsp.c,v 1.2 2002/09/26 05:05:14 maxk Exp $ */ #define VERSION "0.2" #include <linux/config.h> #include <linux/module.h> Loading @@ -52,16 +44,56 @@ #include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> #include "hci_uart.h" #include "hci_bcsp.h" #ifndef CONFIG_BT_HCIUART_DEBUG #undef BT_DBG #define BT_DBG( A... ) #endif #define VERSION "0.3" static int txcrc = 1; static int hciextn = 1; #define BCSP_TXWINSIZE 4 #define BCSP_ACK_PKT 0x05 #define BCSP_LE_PKT 0x06 struct bcsp_struct { struct sk_buff_head unack; /* Unack'ed packets queue */ struct sk_buff_head rel; /* Reliable packets queue */ struct sk_buff_head unrel; /* Unreliable packets queue */ unsigned long rx_count; struct sk_buff *rx_skb; u8 rxseq_txack; /* rxseq == txack. */ u8 rxack; /* Last packet sent by us that the peer ack'ed */ struct timer_list tbcsp; enum { BCSP_W4_PKT_DELIMITER, BCSP_W4_PKT_START, BCSP_W4_BCSP_HDR, BCSP_W4_DATA, BCSP_W4_CRC } rx_state; enum { BCSP_ESCSTATE_NOESC, BCSP_ESCSTATE_ESC } rx_esc_state; u8 use_crc; u16 message_crc; u8 txack_req; /* Do we need to send ack's to the peer? */ /* Reliable packet sequence number - used to assign seq to each rel pkt. */ u8 msgq_txseq; }; /* ---- BCSP CRC calculation ---- */ /* Table for calculating CRC for polynomial 0x1021, LSB processed first, Loading Loading @@ -111,6 +143,7 @@ static u16 bcsp_crc_reverse(u16 crc) rev |= (crc & 1); crc = crc >> 1; } return (rev); } Loading @@ -119,6 +152,7 @@ static u16 bcsp_crc_reverse(u16 crc) static void bcsp_slip_msgdelim(struct sk_buff *skb) { const char pkt_delim = 0xc0; memcpy(skb_put(skb, 1), &pkt_delim, 1); } Loading Loading @@ -173,11 +207,8 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data, { struct sk_buff *nskb; u8 hdr[4], chan; int rel, i; #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC u16 BCSP_CRC_INIT(bcsp_txmsg_crc); #endif int rel, i; switch (pkt_type) { case HCI_ACLDATA_PKT: Loading Loading @@ -240,9 +271,9 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data, BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq); bcsp->msgq_txseq = ++(bcsp->msgq_txseq) & 0x07; } #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC if (bcsp->use_crc) hdr[0] |= 0x40; #endif hdr[1] = ((len << 4) & 0xff) | chan; hdr[2] = len >> 4; Loading @@ -251,25 +282,25 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data, /* Put BCSP header */ for (i = 0; i < 4; i++) { bcsp_slip_one_byte(nskb, hdr[i]); #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC if (bcsp->use_crc) bcsp_crc_update(&bcsp_txmsg_crc, hdr[i]); #endif } /* Put payload */ for (i = 0; i < len; i++) { bcsp_slip_one_byte(nskb, data[i]); #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC if (bcsp->use_crc) bcsp_crc_update(&bcsp_txmsg_crc, data[i]); #endif } #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC /* Put CRC */ if (bcsp->use_crc) { bcsp_txmsg_crc = bcsp_crc_reverse(bcsp_txmsg_crc); bcsp_slip_one_byte(nskb, (u8) ((bcsp_txmsg_crc >> 8) & 0x00ff)); bcsp_slip_one_byte(nskb, (u8) (bcsp_txmsg_crc & 0x00ff)); #endif } bcsp_slip_msgdelim(nskb); return nskb; Loading Loading @@ -317,7 +348,6 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu) spin_unlock_irqrestore(&bcsp->unack.lock, flags); /* We could not send a reliable packet, either because there are none or because there are too many unack'ed pkts. Did we receive any packets we have not acknowledged yet ? */ Loading Loading @@ -374,8 +404,10 @@ static void bcsp_pkt_cull(struct bcsp_struct *bcsp) kfree_skb(skb); skb = nskb; } if (bcsp->unack.qlen == 0) del_timer(&bcsp->tbcsp); spin_unlock_irqrestore(&bcsp->unack.lock, flags); if (i != pkts_to_be_removed) Loading Loading @@ -530,6 +562,7 @@ static inline void bcsp_complete_rx_pkt(struct hci_uart *hu) hci_recv_frame(bcsp->rx_skb); } bcsp->rx_state = BCSP_W4_PKT_DELIMITER; bcsp->rx_skb = NULL; } Loading Loading @@ -698,6 +731,9 @@ static int bcsp_open(struct hci_uart *hu) bcsp->rx_state = BCSP_W4_PKT_DELIMITER; if (txcrc) bcsp->use_crc = 1; return 0; } Loading Loading @@ -730,6 +766,7 @@ static struct hci_uart_proto bcsp = { int bcsp_init(void) { int err = hci_uart_register_proto(&bcsp); if (!err) BT_INFO("HCI BCSP protocol initialized"); else Loading @@ -743,5 +780,8 @@ int bcsp_deinit(void) return hci_uart_unregister_proto(&bcsp); } module_param(txcrc, bool, 0644); MODULE_PARM_DESC(txcrc, "Transmit CRC with every BCSP packet"); module_param(hciextn, bool, 0644); MODULE_PARM_DESC(hciextn, "Convert HCI Extensions into BCSP packets");
drivers/bluetooth/hci_bcsp.hdeleted 100644 → 0 +0 −70 Original line number Diff line number Diff line /* BlueCore Serial Protocol (BCSP) for Linux Bluetooth stack (BlueZ). Copyright 2002 by Fabrizio Gennari <fabrizio.gennari@philips.com> Based on hci_h4.c by Maxim Krasnyansky <maxk@qualcomm.com> ABCSP by Carl Orsborn <cjo@csr.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS SOFTWARE IS DISCLAIMED. */ /* * $Id: hci_bcsp.h,v 1.2 2002/09/26 05:05:14 maxk Exp $ */ #ifndef __HCI_BCSP_H__ #define __HCI_BCSP_H__ #define BCSP_TXWINSIZE 4 #define BCSP_ACK_PKT 0x05 #define BCSP_LE_PKT 0x06 struct bcsp_struct { struct sk_buff_head unack; /* Unack'ed packets queue */ struct sk_buff_head rel; /* Reliable packets queue */ struct sk_buff_head unrel; /* Unreliable packets queue */ unsigned long rx_count; struct sk_buff *rx_skb; u8 rxseq_txack; /* rxseq == txack. */ u8 rxack; /* Last packet sent by us that the peer ack'ed */ struct timer_list tbcsp; enum { BCSP_W4_PKT_DELIMITER, BCSP_W4_PKT_START, BCSP_W4_BCSP_HDR, BCSP_W4_DATA, BCSP_W4_CRC } rx_state; enum { BCSP_ESCSTATE_NOESC, BCSP_ESCSTATE_ESC } rx_esc_state; u16 message_crc; u8 txack_req; /* Do we need to send ack's to the peer? */ /* Reliable packet sequence number - used to assign seq to each rel pkt. */ u8 msgq_txseq; }; #endif /* __HCI_BCSP_H__ */
drivers/bluetooth/hci_h4.c +62 −39 Original line number Diff line number Diff line /* BlueZ - Bluetooth protocol stack for Linux Copyright (C) 2000-2001 Qualcomm Incorporated Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS SOFTWARE IS DISCLAIMED. */ /* * Bluetooth HCI UART(H4) protocol. * * $Id: hci_h4.c,v 1.3 2002/09/09 01:17:32 maxk Exp $ * Bluetooth HCI UART driver * * Copyright (C) 2000-2001 Qualcomm Incorporated * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #define VERSION "1.2" #include <linux/config.h> #include <linux/module.h> Loading @@ -51,14 +45,30 @@ #include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> #include "hci_uart.h" #include "hci_h4.h" #ifndef CONFIG_BT_HCIUART_DEBUG #undef BT_DBG #define BT_DBG( A... ) #endif #define VERSION "1.2" struct h4_struct { unsigned long rx_state; unsigned long rx_count; struct sk_buff *rx_skb; struct sk_buff_head txq; }; /* H4 receiver States */ #define H4_W4_PACKET_TYPE 0 #define H4_W4_EVENT_HDR 1 #define H4_W4_ACL_HDR 2 #define H4_W4_SCO_HDR 3 #define H4_W4_DATA 4 /* Initialize protocol */ static int h4_open(struct hci_uart *hu) { Loading @@ -69,6 +79,7 @@ static int h4_open(struct hci_uart *hu) h4 = kmalloc(sizeof(*h4), GFP_ATOMIC); if (!h4) return -ENOMEM; memset(h4, 0, sizeof(*h4)); skb_queue_head_init(&h4->txq); Loading @@ -83,7 +94,9 @@ static int h4_flush(struct hci_uart *hu) struct h4_struct *h4 = hu->priv; BT_DBG("hu %p", hu); skb_queue_purge(&h4->txq); return 0; } Loading @@ -91,16 +104,19 @@ static int h4_flush(struct hci_uart *hu) static int h4_close(struct hci_uart *hu) { struct h4_struct *h4 = hu->priv; hu->priv = NULL; BT_DBG("hu %p", hu); skb_queue_purge(&h4->txq); if (h4->rx_skb) kfree_skb(h4->rx_skb); hu->priv = NULL; kfree(h4); return 0; } Loading @@ -114,6 +130,7 @@ static int h4_enqueue(struct hci_uart *hu, struct sk_buff *skb) /* Prepend skb with frame type */ memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); skb_queue_tail(&h4->txq, skb); return 0; } Loading @@ -122,6 +139,7 @@ static inline int h4_check_data_len(struct h4_struct *h4, int len) register int room = skb_tailroom(h4->rx_skb); BT_DBG("len %d room %d", len, room); if (!len) { hci_recv_frame(h4->rx_skb); } else if (len > room) { Loading @@ -136,6 +154,7 @@ static inline int h4_check_data_len(struct h4_struct *h4, int len) h4->rx_state = H4_W4_PACKET_TYPE; h4->rx_skb = NULL; h4->rx_count = 0; return 0; } Loading Loading @@ -228,6 +247,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ptr++; count--; continue; }; ptr++; count--; /* Allocate packet */ Loading @@ -238,9 +258,11 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) h4->rx_count = 0; return 0; } h4->rx_skb->dev = (void *) hu->hdev; bt_cb(h4->rx_skb)->pkt_type = type; } return count; } Loading @@ -263,6 +285,7 @@ static struct hci_uart_proto h4p = { int h4_init(void) { int err = hci_uart_register_proto(&h4p); if (!err) BT_INFO("HCI H4 protocol initialized"); else Loading