Bluetooth Driver acts as interface between HCI core and TI Shared Transport Layer.
/drivers/bluetooth/Btwilink.c:
#include <linux/platform_device.h>
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/hci.h>
#include <linux/ti_wilink_st.h>
#include <linux/module.h>
#define DEBUG
#define VERSION "1.0"
#define MAX_BT_CHNL_IDS 3
#define BT_REGISTER_TIMEOUT 6000
struct ti_st {
struct hci_dev *hdev;
char reg_status;
long (*st_write) (struct sk_buff *);
struct completion wait_reg_completion;
};
struct ti_st - 模块操作结构体
@hdev: HCI 设备指针绑定到了蓝牙模块
@reg_status: ST 注册返回状态
@st_write: send_frame 用到的写函数
@wait_reg_completion - ti_st_open and st_reg_completion_cb之间的结束同步
static inline void ti_st_tx_complete(struct ti_st *hst, int pkt_type)
{
struct hci_dev *hdev = hst->hdev;
/* Update HCI stat counters */
switch (pkt_type) {
case HCI_COMMAND_PKT:
hdev->stat.cmd_tx++;
break;
case HCI_ACLDATA_PKT:
hdev->stat.acl_tx++;
break;
case HCI_SCODATA_PKT:
hdev->stat.sco_tx++;
break;
}
}
pocket ID (cmd,acl,sco)计数
static void st_reg_completion_cb(void *priv_data, char data)
{
struct ti_st *lhst = priv_data;
/* Save registration status for use in ti_st_open() */
lhst->reg_status = data;
/* complete the wait in ti_st_open() */
complete(&lhst->wait_reg_completion);
}
status.ti_st_open() 函数 会等待st_register() 返回的ST_PENDING信号
static long st_receive(void *priv_data, struct sk_buff *skb)
{
struct ti_st *lhst = priv_data;
int err;
if (!skb)
return -EFAULT;
if (!lhst) {
kfree_skb(skb);
return -EFAULT;
}
skb->dev = (void *) lhst->hdev