]> git.hungrycats.org Git - linux/commitdiff
[Bluetooth] Add notify callback for host drivers
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 5 Mar 2004 18:43:26 +0000 (19:43 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 5 Mar 2004 18:43:26 +0000 (19:43 +0100)
This patch adds a notification callback to the hci_dev structure which
is used by the HCI core to tell the driver about connection creation
and clearing. It also notifies about changed voice setting.

include/net/bluetooth/hci.h
include/net/bluetooth/hci_core.h
net/bluetooth/hci_conn.c
net/bluetooth/hci_event.c

index 6f235638a7acdb58752e69e5b8e761f7acf49b8e..7edb678be31fa487ba365619c1c9e4a6c410bdb9 100644 (file)
 #define HCI_MAX_FRAME_SIZE     (HCI_MAX_ACL_SIZE + 4)
 
 /* HCI dev events */
-#define HCI_DEV_REG    1
-#define HCI_DEV_UNREG   2
-#define HCI_DEV_UP     3
-#define HCI_DEV_DOWN   4
-#define HCI_DEV_SUSPEND 5
-#define HCI_DEV_RESUME  6
+#define HCI_DEV_REG                    1
+#define HCI_DEV_UNREG                  2
+#define HCI_DEV_UP                     3
+#define HCI_DEV_DOWN                   4
+#define HCI_DEV_SUSPEND                        5
+#define HCI_DEV_RESUME                 6
+
+/* HCI notify events */
+#define HCI_NOTIFY_CONN_ADD            1
+#define HCI_NOTIFY_CONN_DEL            2
+#define HCI_NOTIFY_VOICE_SETTING       3
 
 /* HCI device types */
 #define HCI_VHCI       0
 #define HCI_USB                1
 #define HCI_PCCARD     2
-#define HCI_UART       3
-#define HCI_RS232      4
+#define HCI_UART       3
+#define HCI_RS232      4
 #define HCI_PCI                5
 
 /* HCI device quirks */
@@ -95,24 +100,24 @@ enum {
 #define HCIINQUIRY     _IOR('H', 240, int)
 
 /* HCI timeouts */
-#define HCI_CONN_TIMEOUT       (HZ * 40)
-#define HCI_DISCONN_TIMEOUT    (HZ * 2)
+#define HCI_CONN_TIMEOUT       (HZ * 40)
+#define HCI_DISCONN_TIMEOUT    (HZ * 2)
 #define HCI_CONN_IDLE_TIMEOUT  (HZ * 60)
 
 /* HCI Packet types */
 #define HCI_COMMAND_PKT                0x01
-#define HCI_ACLDATA_PKT        0x02
-#define HCI_SCODATA_PKT        0x03
+#define HCI_ACLDATA_PKT                0x02
+#define HCI_SCODATA_PKT                0x03
 #define HCI_EVENT_PKT          0x04
 #define HCI_UNKNOWN_PKT                0xff
 
 /* HCI Packet types */
-#define HCI_DM1        0x0008
-#define HCI_DM3        0x0400
-#define HCI_DM5        0x4000
-#define HCI_DH1        0x0010
-#define HCI_DH3        0x0800
-#define HCI_DH5        0x8000
+#define HCI_DM1                0x0008
+#define HCI_DM3                0x0400
+#define HCI_DM5                0x4000
+#define HCI_DH1                0x0010
+#define HCI_DH3                0x0800
+#define HCI_DH5                0x8000
 
 #define HCI_HV1                0x0020
 #define HCI_HV2                0x0040
index 9e1278484a50e21c2ba61a2cfd64c8db0ee5d28e..faddd520a69c4048f1783483d3087fa33df35d73 100644 (file)
@@ -130,6 +130,7 @@ struct hci_dev {
        int (*flush)(struct hci_dev *hdev);
        int (*send)(struct sk_buff *skb);
        void (*destruct)(struct hci_dev *hdev);
+       void (*notify)(struct hci_dev *hdev, unsigned int evt);
        int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg);
 };
 
index 56b0bc52eefb90ba591dd2234cf46caf05a7258d..962ce3a3485ec9caf2533b96efeddc483b9e7d80 100644 (file)
@@ -170,6 +170,9 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
        hci_conn_hash_add(hdev, conn);
        tasklet_enable(&hdev->tx_task);
 
+       if (hdev->notify)
+               hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
+
        return conn;
 }
 
@@ -196,6 +199,9 @@ int hci_conn_del(struct hci_conn *conn)
                hdev->acl_cnt += conn->sent;
        }
 
+       if (hdev->notify)
+               hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
+
        tasklet_disable(&hdev->tx_task);
        hci_conn_hash_del(hdev, conn);
        tasklet_enable(&hdev->tx_task);
index 4a9037f65956a600c6972ff29c59930999e3b176..d7355f4a453749904500c27fe74baacfca301dd3 100644 (file)
@@ -232,6 +232,9 @@ static void hci_cc_host_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb
                        hdev->voice_setting = setting;
 
                        BT_DBG("%s: voice setting 0x%04x", hdev->name, setting);
+
+                       if (hdev->notify)
+                               hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
                }
                break;
 
@@ -247,6 +250,9 @@ static void hci_cc_host_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb
                        hdev->voice_setting = setting;
 
                        BT_DBG("%s: voice setting 0x%04x", hdev->name, setting);
+
+                       if (hdev->notify)
+                               hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
                }
                hci_req_complete(hdev, status);
                break;