ledtrig-camera.c 1.3 KB

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