backlight.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2016 Google, Inc
  4. * Written by Simon Glass <sjg@chromium.org>
  5. */
  6. #ifndef _BACKLIGHT_H
  7. #define _BACKLIGHT_H
  8. enum {
  9. BACKLIGHT_MAX = 100,
  10. BACKLIGHT_MIN = 0,
  11. BACKLIGHT_OFF = -1,
  12. BACKLIGHT_DEFAULT = -2,
  13. };
  14. struct backlight_ops {
  15. /**
  16. * enable() - Enable a backlight
  17. *
  18. * @dev: Backlight device to enable
  19. * @return 0 if OK, -ve on error
  20. */
  21. int (*enable)(struct udevice *dev);
  22. /**
  23. * set_brightness - Set brightness
  24. *
  25. * @dev: Backlight device to update
  26. * @percent: Brightness value (0 to 100, or BACKLIGHT_... value)
  27. * @return 0 if OK, -ve on error
  28. */
  29. int (*set_brightness)(struct udevice *dev, int percent);
  30. };
  31. #define backlight_get_ops(dev) ((struct backlight_ops *)(dev)->driver->ops)
  32. /**
  33. * backlight_enable() - Enable a backlight
  34. *
  35. * @dev: Backlight device to enable
  36. * @return 0 if OK, -ve on error
  37. */
  38. int backlight_enable(struct udevice *dev);
  39. /**
  40. * backlight_set_brightness - Set brightness
  41. *
  42. * @dev: Backlight device to update
  43. * @percent: Brightness value (0 to 100, or BACKLIGHT_... value)
  44. * @return 0 if OK, -ve on error
  45. */
  46. int backlight_set_brightness(struct udevice *dev, int percent);
  47. #endif