backlight.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * GMA500 Backlight Interface
  3. *
  4. * Copyright (c) 2009-2011, Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * Authors: Eric Knopp
  20. *
  21. */
  22. #include "psb_drv.h"
  23. #include "psb_intel_reg.h"
  24. #include "psb_intel_drv.h"
  25. #include "intel_bios.h"
  26. #include "power.h"
  27. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  28. static void do_gma_backlight_set(struct drm_device *dev)
  29. {
  30. struct drm_psb_private *dev_priv = dev->dev_private;
  31. backlight_update_status(dev_priv->backlight_device);
  32. }
  33. #endif
  34. void gma_backlight_enable(struct drm_device *dev)
  35. {
  36. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  37. struct drm_psb_private *dev_priv = dev->dev_private;
  38. dev_priv->backlight_enabled = true;
  39. if (dev_priv->backlight_device) {
  40. dev_priv->backlight_device->props.brightness = dev_priv->backlight_level;
  41. do_gma_backlight_set(dev);
  42. }
  43. #endif
  44. }
  45. void gma_backlight_disable(struct drm_device *dev)
  46. {
  47. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  48. struct drm_psb_private *dev_priv = dev->dev_private;
  49. dev_priv->backlight_enabled = false;
  50. if (dev_priv->backlight_device) {
  51. dev_priv->backlight_device->props.brightness = 0;
  52. do_gma_backlight_set(dev);
  53. }
  54. #endif
  55. }
  56. void gma_backlight_set(struct drm_device *dev, int v)
  57. {
  58. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  59. struct drm_psb_private *dev_priv = dev->dev_private;
  60. dev_priv->backlight_level = v;
  61. if (dev_priv->backlight_device && dev_priv->backlight_enabled) {
  62. dev_priv->backlight_device->props.brightness = v;
  63. do_gma_backlight_set(dev);
  64. }
  65. #endif
  66. }
  67. int gma_backlight_init(struct drm_device *dev)
  68. {
  69. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  70. struct drm_psb_private *dev_priv = dev->dev_private;
  71. dev_priv->backlight_enabled = true;
  72. return dev_priv->ops->backlight_init(dev);
  73. #else
  74. return 0;
  75. #endif
  76. }
  77. void gma_backlight_exit(struct drm_device *dev)
  78. {
  79. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  80. struct drm_psb_private *dev_priv = dev->dev_private;
  81. if (dev_priv->backlight_device) {
  82. dev_priv->backlight_device->props.brightness = 0;
  83. backlight_update_status(dev_priv->backlight_device);
  84. backlight_device_unregister(dev_priv->backlight_device);
  85. }
  86. #endif
  87. }