ledtrig-camera.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #include <linux/module.h>
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/leds.h>
  19. DEFINE_LED_TRIGGER(ledtrig_flash);
  20. DEFINE_LED_TRIGGER(ledtrig_torch);
  21. void ledtrig_flash_ctrl(bool on)
  22. {
  23. enum led_brightness brt = on ? LED_FULL : LED_OFF;
  24. led_trigger_event(ledtrig_flash, brt);
  25. }
  26. EXPORT_SYMBOL_GPL(ledtrig_flash_ctrl);
  27. void ledtrig_torch_ctrl(bool on)
  28. {
  29. enum led_brightness brt = on ? LED_FULL : LED_OFF;
  30. led_trigger_event(ledtrig_torch, brt);
  31. }
  32. EXPORT_SYMBOL_GPL(ledtrig_torch_ctrl);
  33. static int __init ledtrig_camera_init(void)
  34. {
  35. led_trigger_register_simple("flash", &ledtrig_flash);
  36. led_trigger_register_simple("torch", &ledtrig_torch);
  37. return 0;
  38. }
  39. module_init(ledtrig_camera_init);
  40. static void __exit ledtrig_camera_exit(void)
  41. {
  42. led_trigger_unregister_simple(ledtrig_torch);
  43. led_trigger_unregister_simple(ledtrig_flash);
  44. }
  45. module_exit(ledtrig_camera_exit);
  46. MODULE_DESCRIPTION("LED Trigger for Camera Flash/Torch Control");
  47. MODULE_AUTHOR("Milo Kim");
  48. MODULE_LICENSE("GPL");