Skip to content

Commit

Permalink
Bluetooth support:
Browse files Browse the repository at this point in the history
Backported from 2.6.35 by fat-tire
  • Loading branch information
fattire authored and dalingrin committed May 10, 2011
1 parent 66cc5b6 commit 88ada0a
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 147 deletions.
2 changes: 1 addition & 1 deletion arch/arm/mach-omap2/board-evt1a.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct ti_st_plat_data wilink_pdata = {
.nshutdown_gpio = 60,
.dev_name = "/dev/ttyO1",
.flow_cntrl = 1,
.baud_rate = 115200 // was 3000000,
.baud_rate = 3000000,
};

static struct platform_device kim_wl127x_device = {
Expand Down
7 changes: 4 additions & 3 deletions include/net/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define HCI_NOTIFY_CONN_DEL 2
#define HCI_NOTIFY_VOICE_SETTING 3

/* HCI device types */
/* HCI bus types */
#define HCI_VIRTUAL 0
#define HCI_USB 1
#define HCI_PCCARD 2
Expand All @@ -53,8 +53,8 @@
#define HCI_SDIO 6

/* HCI controller types */
#define HCI_BREDR 0x00
#define HCI_80211 0x01
#define HCI_BREDR 0x00
#define HCI_80211 0x01

/* HCI device quirks */
enum {
Expand Down Expand Up @@ -1043,3 +1043,4 @@ struct hci_inquiry_req {
#define IREQ_CACHE_FLUSH 0x0001

#endif /* __HCI_H */

54 changes: 29 additions & 25 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
BlueZ - Bluetooth protocol stack for Linux
Copyright (C) 2000-2001 Qualcomm Incorporated
Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
Written 2000,2001 by Maxim Krasnyansky <[email protected]>
Expand Down Expand Up @@ -107,7 +107,7 @@ struct hci_dev {
unsigned long acl_last_tx;
unsigned long sco_last_tx;

struct workqueue_struct *workqueue;
struct workqueue_struct *workqueue;

struct tasklet_struct cmd_task;
struct tasklet_struct rx_task;
Expand Down Expand Up @@ -137,7 +137,7 @@ struct hci_dev {

atomic_t promisc;

struct dentry *debugfs;
struct dentry *debugfs;

struct device *parent;
struct device dev;
Expand Down Expand Up @@ -250,6 +250,7 @@ enum {
HCI_CONN_ENCRYPT_PEND,
HCI_CONN_RSWITCH_PEND,
HCI_CONN_MODE_CHANGE_PEND,
HCI_CONN_SCO_SETUP_PEND,
};

static inline void hci_conn_hash_init(struct hci_dev *hdev)
Expand Down Expand Up @@ -330,6 +331,7 @@ void hci_acl_connect(struct hci_conn *conn);
void hci_acl_disconn(struct hci_conn *conn, __u8 reason);
void hci_add_sco(struct hci_conn *conn, __u16 handle);
void hci_setup_sync(struct hci_conn *conn, __u16 handle);
void hci_sco_setup(struct hci_conn *conn, __u8 status);

struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type,
__u16 pkt_type, bdaddr_t *dst);
Expand Down Expand Up @@ -378,17 +380,17 @@ static inline void hci_conn_put(struct hci_conn *conn)
/* ----- HCI tasks ----- */
static inline void hci_sched_cmd(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->cmd_task);
tasklet_schedule(&hdev->cmd_task);
}

static inline void hci_sched_rx(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->rx_task);
tasklet_schedule(&hdev->rx_task);
}

static inline void hci_sched_tx(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->tx_task);
tasklet_schedule(&hdev->tx_task);
}

/* ----- HCI Devices ----- */
Expand Down Expand Up @@ -446,27 +448,28 @@ int hci_inquiry(void __user *arg);
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);

/* Receive frame from HCI drivers */
static inline int hci_recv_frame(struct sk_buff *skb)
{
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
if (!hdev || (!test_bit(HCI_UP, &hdev->flags)
&& !test_bit(HCI_INIT, &hdev->flags))) {
kfree_skb(skb);
return -ENXIO;
}

/* Incomming skb */
bt_cb(skb)->incoming = 1;

/* Time stamp */
__net_timestamp(skb);

/* Queue frame for rx task */
skb_queue_tail(&hdev->rx_q, skb);
hci_sched_rx(hdev);
return 0;
static inline int hci_recv_frame(struct sk_buff *skb)
{
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
if (!hdev || (!test_bit(HCI_UP, &hdev->flags)
&& !test_bit(HCI_INIT, &hdev->flags))) {
kfree_skb(skb);
return -ENXIO;
}

/* Incomming skb */
bt_cb(skb)->incoming = 1;

/* Time stamp */
__net_timestamp(skb);

/* Queue frame for rx task */
skb_queue_tail(&hdev->rx_q, skb);
hci_sched_rx(hdev);
return 0;
}

//int hci_recv_frame(struct sk_buff *skb);
int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count);

int hci_register_sysfs(struct hci_dev *hdev);
Expand Down Expand Up @@ -719,3 +722,4 @@ struct hci_sec_filter {
void hci_req_complete(struct hci_dev *hdev, int result);

#endif /* __HCI_CORE_H */

40 changes: 35 additions & 5 deletions net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
BlueZ - Bluetooth protocol stack for Linux
Copyright (C) 2000-2001 Qualcomm Incorporated
Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
Written 2000,2001 by Maxim Krasnyansky <[email protected]>
Expand Down Expand Up @@ -155,6 +155,27 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle)
hci_send_cmd(hdev, HCI_OP_SETUP_SYNC_CONN, sizeof(cp), &cp);
}

/* Device _must_ be locked */
void hci_sco_setup(struct hci_conn *conn, __u8 status)
{
struct hci_conn *sco = conn->link;

BT_DBG("%p", conn);

if (!sco)
return;

if (!status) {
if (lmp_esco_capable(conn->hdev))
hci_setup_sync(sco, conn->handle);
else
hci_add_sco(sco, conn->handle);
} else {
hci_proto_connect_cfm(sco, status);
hci_conn_del(sco);
}
}

static void hci_conn_timeout(unsigned long arg)
{
struct hci_conn *conn = (void *) arg;
Expand Down Expand Up @@ -369,6 +390,11 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type,
acl->sec_level = sec_level;
acl->auth_type = auth_type;
hci_acl_connect(acl);
} else {
if (acl->sec_level < sec_level)
acl->sec_level = sec_level;
if (acl->auth_type < auth_type)
acl->auth_type = auth_type;
}

if (type == ACL_LINK)
Expand All @@ -391,10 +417,13 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type,
acl->power_save = 1;
hci_conn_enter_active_mode(acl);

if (lmp_esco_capable(hdev))
hci_setup_sync(sco, acl->handle);
else
hci_add_sco(sco, acl->handle);
if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->pend)) {
/* defer SCO setup until mode change completed */
set_bit(HCI_CONN_SCO_SETUP_PEND, &acl->pend);
return sco;
}

hci_sco_setup(acl, 0x00);
}

return sco;
Expand Down Expand Up @@ -732,3 +761,4 @@ int hci_get_auth_info(struct hci_dev *hdev, void __user *arg)

return copy_to_user(arg, &req, sizeof(req)) ? -EFAULT : 0;
}

1 change: 0 additions & 1 deletion net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

/* Bluetooth HCI core. */

#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/kmod.h>
Expand Down
Loading

0 comments on commit 88ada0a

Please sign in to comment.