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 17DEFINE_LED_TRIGGER(ledtrig_flash); 18DEFINE_LED_TRIGGER(ledtrig_torch); 19 20void 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} 26EXPORT_SYMBOL_GPL(ledtrig_flash_ctrl); 27 28void 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} 34EXPORT_SYMBOL_GPL(ledtrig_torch_ctrl); 35 36static 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} 42module_init(ledtrig_camera_init); 43 44static void __exit ledtrig_camera_exit(void) 45{ 46 led_trigger_unregister_simple(ledtrig_torch); 47 led_trigger_unregister_simple(ledtrig_flash); 48} 49module_exit(ledtrig_camera_exit); 50 51MODULE_DESCRIPTION("LED Trigger for Camera Flash/Torch Control"); 52MODULE_AUTHOR("Milo Kim"); 53MODULE_LICENSE("GPL v2"); 54