diff options
author | Kim, Milo <Milo.Kim@ti.com> | 2013-03-14 07:29:24 -0400 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-04-01 14:04:50 -0400 |
commit | 48a1d032c954b9b06c3adbf35ef4735dd70ab757 (patch) | |
tree | 1565df19ce741f9332e0a53cc9ef4881a389c002 /drivers/leds | |
parent | 39f7e08af3fd9ca1cb94a8270354afb2ea5cfcd3 (diff) |
leds: add camera LED triggers
Some LED devices support flash/torch functionality through the LED subsystem.
This patch enables direct LED trigger controls by the driver.
Flash on/off and torch on/off can be done simply by other driver space.
Two trigger APIs are added, ledtrig_flash_ctrl() and ledtrig_torch_ctrl().
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/trigger/Kconfig | 8 | ||||
-rw-r--r-- | drivers/leds/trigger/Makefile | 1 | ||||
-rw-r--r-- | drivers/leds/trigger/ledtrig-camera.c | 57 |
3 files changed, 66 insertions, 0 deletions
diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig index eaa286dc494e..49794b47b51c 100644 --- a/drivers/leds/trigger/Kconfig +++ b/drivers/leds/trigger/Kconfig | |||
@@ -100,4 +100,12 @@ config LEDS_TRIGGER_TRANSIENT | |||
100 | GPIO/PWM based hardware. | 100 | GPIO/PWM based hardware. |
101 | If unsure, say Y. | 101 | If unsure, say Y. |
102 | 102 | ||
103 | config LEDS_TRIGGER_CAMERA | ||
104 | tristate "LED Camera Flash/Torch Trigger" | ||
105 | depends on LEDS_TRIGGERS | ||
106 | help | ||
107 | This allows LEDs to be controlled as a camera flash/torch device. | ||
108 | This enables direct flash/torch on/off by the driver, kernel space. | ||
109 | If unsure, say Y. | ||
110 | |||
103 | endif # LEDS_TRIGGERS | 111 | endif # LEDS_TRIGGERS |
diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile index 554e46ee4c24..1abf48dacf7e 100644 --- a/drivers/leds/trigger/Makefile +++ b/drivers/leds/trigger/Makefile | |||
@@ -7,3 +7,4 @@ obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o | |||
7 | obj-$(CONFIG_LEDS_TRIGGER_CPU) += ledtrig-cpu.o | 7 | obj-$(CONFIG_LEDS_TRIGGER_CPU) += ledtrig-cpu.o |
8 | obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o | 8 | obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o |
9 | obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o | 9 | obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o |
10 | obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o | ||
diff --git a/drivers/leds/trigger/ledtrig-camera.c b/drivers/leds/trigger/ledtrig-camera.c new file mode 100644 index 000000000000..9bd73a8bad5c --- /dev/null +++ b/drivers/leds/trigger/ledtrig-camera.c | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | * Camera Flash and Torch On/Off Trigger | ||
3 | * | ||
4 | * based on ledtrig-ide-disk.c | ||
5 | * | ||
6 | * Copyright 2013 Texas Instruments | ||
7 | * | ||
8 | * Author: Milo(Woogyom) Kim <milo.kim@ti.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/leds.h> | ||
20 | |||
21 | DEFINE_LED_TRIGGER(ledtrig_flash); | ||
22 | DEFINE_LED_TRIGGER(ledtrig_torch); | ||
23 | |||
24 | void ledtrig_flash_ctrl(bool on) | ||
25 | { | ||
26 | enum led_brightness brt = on ? LED_FULL : LED_OFF; | ||
27 | |||
28 | led_trigger_event(ledtrig_flash, brt); | ||
29 | } | ||
30 | EXPORT_SYMBOL_GPL(ledtrig_flash_ctrl); | ||
31 | |||
32 | void ledtrig_torch_ctrl(bool on) | ||
33 | { | ||
34 | enum led_brightness brt = on ? LED_FULL : LED_OFF; | ||
35 | |||
36 | led_trigger_event(ledtrig_torch, brt); | ||
37 | } | ||
38 | EXPORT_SYMBOL_GPL(ledtrig_torch_ctrl); | ||
39 | |||
40 | static int __init ledtrig_camera_init(void) | ||
41 | { | ||
42 | led_trigger_register_simple("flash", &ledtrig_flash); | ||
43 | led_trigger_register_simple("torch", &ledtrig_torch); | ||
44 | return 0; | ||
45 | } | ||
46 | module_init(ledtrig_camera_init); | ||
47 | |||
48 | static void __exit ledtrig_camera_exit(void) | ||
49 | { | ||
50 | led_trigger_unregister_simple(ledtrig_torch); | ||
51 | led_trigger_unregister_simple(ledtrig_flash); | ||
52 | } | ||
53 | module_exit(ledtrig_camera_exit); | ||
54 | |||
55 | MODULE_DESCRIPTION("LED Trigger for Camera Flash/Torch Control"); | ||
56 | MODULE_AUTHOR("Milo Kim"); | ||
57 | MODULE_LICENSE("GPL"); | ||