xref: /linux/drivers/leds/trigger/ledtrig-camera.c (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Camera Flash and Torch On/Off Trigger
4  *
5  * based on ledtrig-ide-disk.c
6  *
7  * Copyright 2013 Texas Instruments
8  *
9  * Author: Milo(Woogyom) Kim <milo.kim@ti.com>
10  */
11 
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/leds.h>
16 
17 DEFINE_LED_TRIGGER(ledtrig_flash);
18 DEFINE_LED_TRIGGER(ledtrig_torch);
19 
ledtrig_flash_ctrl(bool on)20 void ledtrig_flash_ctrl(bool on)
21 {
22 	enum led_brightness brt = on ? LED_FULL : LED_OFF;
23 
24 	led_trigger_event(ledtrig_flash, brt);
25 }
26 EXPORT_SYMBOL_GPL(ledtrig_flash_ctrl);
27 
ledtrig_torch_ctrl(bool on)28 void ledtrig_torch_ctrl(bool on)
29 {
30 	enum led_brightness brt = on ? LED_FULL : LED_OFF;
31 
32 	led_trigger_event(ledtrig_torch, brt);
33 }
34 EXPORT_SYMBOL_GPL(ledtrig_torch_ctrl);
35 
ledtrig_camera_init(void)36 static int __init ledtrig_camera_init(void)
37 {
38 	led_trigger_register_simple("flash", &ledtrig_flash);
39 	led_trigger_register_simple("torch", &ledtrig_torch);
40 	return 0;
41 }
42 module_init(ledtrig_camera_init);
43 
ledtrig_camera_exit(void)44 static void __exit ledtrig_camera_exit(void)
45 {
46 	led_trigger_unregister_simple(ledtrig_torch);
47 	led_trigger_unregister_simple(ledtrig_flash);
48 }
49 module_exit(ledtrig_camera_exit);
50 
51 MODULE_DESCRIPTION("LED Trigger for Camera Flash/Torch Control");
52 MODULE_AUTHOR("Milo Kim");
53 MODULE_LICENSE("GPL v2");
54