Permalink
Browse files

add trigger for Bluetooth LED

Signed-off-by: daveriess <dave@buglabs.net>
  • Loading branch information...
1 parent c8d8db7 commit 549ea1d0b4e821597107cba235ce017f1e534d44 daveriess committed Sep 29, 2010
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.31-omap1
-# Fri Sep 24 13:17:39 2010
+# Wed Sep 29 18:01:01 2010
#
CONFIG_ARM=y
CONFIG_HAVE_PWM=y
@@ -577,6 +577,7 @@ CONFIG_IP_NF_TARGET_MASQUERADE=m
# CONFIG_CAN is not set
# CONFIG_IRDA is not set
CONFIG_BT=y
+CONFIG_HCI_LED_TRIGGER=y
CONFIG_BT_L2CAP=y
CONFIG_BT_SCO=y
CONFIG_BT_RFCOMM=y
@@ -704,7 +704,7 @@ static struct omap_pwm_led_platform_data omap_pwm_led_gpt8 = {
.name = "omap3bug:blue:bt",
.intensity_timer = 8,
.blink_timer = 0,
- .default_trigger = "none",
+ .default_trigger = "hci0",
//.set_power = set_power(&omap_pwm_led_gpt92, 0),
};
@@ -148,6 +148,10 @@ struct hci_dev {
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);
+#ifdef CONFIG_HCI_LED_TRIGGER
+ struct led_trigger *hci_state_trig;
+ char *hci_state_trig_name;
+#endif
};
struct hci_conn {
View
@@ -30,6 +30,14 @@ menuconfig BT
utilities like hciconfig and hcid. These utilities and updates to
Bluetooth kernel modules are provided in the BlueZ packages.
For more information, see <http://www.bluez.org/>.
+config HCI_LED_TRIGGER
+ bool "Bluetooth LED trigger"
+ depends on BT
+ help
+ Creates a LED trigger that indicates the state of the hci subsystem.
+ LED's assigned to this trigger will be turned on when a bluetooth
+ connection is established. When all bluetooth devices have been
+ disconnected, the LED will be turned off.
config BT_L2CAP
tristate "L2CAP protocol support"
View
@@ -37,6 +37,7 @@
#include <linux/interrupt.h>
#include <linux/notifier.h>
#include <net/sock.h>
+#include <linux/leds.h>
#include <asm/system.h>
#include <asm/uaccess.h>
@@ -202,6 +203,10 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
BT_DBG("%s dst %s", hdev->name, batostr(dst));
+#ifdef CONFIG_HCI_LED_TRIGGER
+ led_trigger_event(hdev->hci_state_trig, LED_FULL);
+#endif
+
conn = kzalloc(sizeof(struct hci_conn), GFP_ATOMIC);
if (!conn)
return NULL;
@@ -292,6 +297,11 @@ int hci_conn_del(struct hci_conn *conn)
hci_dev_put(hdev);
+#ifdef CONFIG_HCI_LED_TRIGGER
+ if (!(hdev->conn_hash.acl_num + hdev->conn_hash.sco_num))
+ led_trigger_event(hdev->hci_state_trig, LED_OFF);
+#endif
+
return 0;
}
View
@@ -899,6 +899,14 @@ int hci_register_dev(struct hci_dev *hdev)
hdev->sniff_max_interval = 800;
hdev->sniff_min_interval = 80;
+#ifdef CONFIG_HCI_LED_TRIGGER
+ hdev->hci_state_trig_name = kasprintf(GFP_KERNEL, "%s", hdev->name);
+ if (!hdev->hci_state_trig_name)
+ printk(KERN_ERR "%p Unable to register LED trigger", hdev);
+ else
+ led_trigger_register_simple(hdev->hci_state_trig_name, &hdev->hci_state_trig);
+#endif
+
tasklet_init(&hdev->cmd_task, hci_cmd_task,(unsigned long) hdev);
tasklet_init(&hdev->rx_task, hci_rx_task, (unsigned long) hdev);
tasklet_init(&hdev->tx_task, hci_tx_task, (unsigned long) hdev);

0 comments on commit 549ea1d

Please sign in to comment.