linux/drivers/leds/trigger/ledtrig-camera.c
<<
>>
Prefs
   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
  21DEFINE_LED_TRIGGER(ledtrig_flash);
  22DEFINE_LED_TRIGGER(ledtrig_torch);
  23
  24void 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}
  30EXPORT_SYMBOL_GPL(ledtrig_flash_ctrl);
  31
  32void 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}
  38EXPORT_SYMBOL_GPL(ledtrig_torch_ctrl);
  39
  40static 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}
  46module_init(ledtrig_camera_init);
  47
  48static void __exit ledtrig_camera_exit(void)
  49{
  50        led_trigger_unregister_simple(ledtrig_torch);
  51        led_trigger_unregister_simple(ledtrig_flash);
  52}
  53module_exit(ledtrig_camera_exit);
  54
  55MODULE_DESCRIPTION("LED Trigger for Camera Flash/Torch Control");
  56MODULE_AUTHOR("Milo Kim");
  57MODULE_LICENSE("GPL");
  58