backlight.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Intel Cherryview/VLV display-engine panel backlight.
  2. *
  3. * The internal panel's PWM lives in the graphics MMIO BAR, not on the
  4. * Chrome EC: BLC_PWM_CTL2 enables it and BLC_PWM_CTL holds the period and
  5. * duty cycle. The HP Chromebook 11 G5 (google/setzer, Braswell) VBT
  6. * declares PWM controller 0, 200 Hz, active high.
  7. */
  8. #ifndef BACKLIGHT_H
  9. #define BACKLIGHT_H
  10. struct backlight_status {
  11. int present;
  12. int level; /* percent, 5..100 */
  13. int enabled;
  14. unsigned int pipe; /* 0 = A, 1 = B */
  15. unsigned int period; /* raw PWM period from BLC_PWM_CTL */
  16. unsigned int duty; /* raw duty from BLC_PWM_CTL */
  17. unsigned int bar; /* graphics MMIO BAR0 base */
  18. unsigned int ctl2[2]; /* raw BLC_PWM_CTL2 for pipes A and B */
  19. unsigned int ctl[2]; /* raw BLC_PWM_CTL for pipes A and B */
  20. };
  21. /* Called from gpu_init() for the active Intel adapter; no-op elsewhere. */
  22. void backlight_init(unsigned int bus, unsigned int dev, unsigned int device_id);
  23. int backlight_present(void);
  24. /* Current brightness in percent, or -1 when no panel PWM was found. */
  25. int backlight_percent(void);
  26. /* Monotonic change counter, bumped by every successful set/step. The WM
  27. * uses it to pop the brightness OSD without polling the registers. */
  28. unsigned int backlight_seq(void);
  29. /* Clamped to 5..100. */
  30. void backlight_set_percent(int percent);
  31. /* Step by 10 percent; dir > 0 is brighter. */
  32. void backlight_step(int dir);
  33. /* Fill the status snapshot used by the `backlight` command. */
  34. int backlight_status(struct backlight_status *out);
  35. #endif