/linux-joggler/joggler-backlight-control-3.2.patch

https://bitbucket.org/axil42/aur-mirror · Patch · 175 lines · 174 code · 1 blank · 0 comment · 0 complexity · 0bf4ed77ad915ecae5daf3c6ca0f6578 MD5 · raw file

  1. diff -Naur linux-3.2.orig/drivers/video/backlight/Kconfig linux-3.2-backlight/drivers/video/backlight/Kconfig
  2. --- linux-3.2.orig/drivers/video/backlight/Kconfig 2012-02-13 15:00:49.382700059 +0000
  3. +++ linux-3.2-backlight/drivers/video/backlight/Kconfig 2012-02-13 15:02:32.082017427 +0000
  4. @@ -322,6 +322,13 @@
  5. To compile this driver as a module, choose M here: the module will
  6. be called adp8870_bl.
  7. +config BACKLIGHT_OPENFRAME
  8. + tristate "Openframe Backlight Driver"
  9. + depends on BACKLIGHT_CLASS_DEVICE && PCI && X86
  10. + default n
  11. + help
  12. + If you have an OpenFrame device say Y to enable the
  13. + backlight driver.
  14. config BACKLIGHT_88PM860X
  15. tristate "Backlight Driver for 88PM8606 using WLED"
  16. depends on MFD_88PM860X
  17. diff -Naur linux-3.2.orig/drivers/video/backlight/Makefile linux-3.2-backlight/drivers/video/backlight/Makefile
  18. --- linux-3.2.orig/drivers/video/backlight/Makefile 2012-02-13 15:00:49.382700059 +0000
  19. +++ linux-3.2-backlight/drivers/video/backlight/Makefile 2012-02-13 15:03:09.561669670 +0000
  20. @@ -39,4 +39,4 @@
  21. obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o
  22. obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o
  23. obj-$(CONFIG_BACKLIGHT_AAT2870) += aat2870_bl.o
  24. -
  25. +obj-$(CONFIG_BACKLIGHT_OPENFRAME) += openframe_bl.o
  26. diff -Naur linux-3.2.orig/drivers/video/backlight/openframe_bl.c linux-3.2-backlight/drivers/video/backlight/openframe_bl.c
  27. --- linux-3.2.orig/drivers/video/backlight/openframe_bl.c 1970-01-01 01:00:00.000000000 +0100
  28. +++ linux-3.2-backlight/drivers/video/backlight/openframe_bl.c 2012-02-14 18:39:10.962773163 +0000
  29. @@ -0,0 +1,145 @@
  30. +/*
  31. + * Backlight Driver for Openframe devices
  32. + *
  33. + * Copyright (c) 2010 Andrew de Quincey
  34. + *
  35. + * Based onprogear_bl.c driver by Marcin Juszkiewicz
  36. + * <linux at hrw dot one dot pl>
  37. + *
  38. + * Based on Progear LCD driver by M Schacht
  39. + * <mschacht at alumni dot washington dot edu>
  40. + *
  41. + * Based on Sharp's Corgi Backlight Driver
  42. + * Based on Backlight Driver for HP Jornada 680
  43. + *
  44. + * This program is free software; you can redistribute it and/or modify
  45. + * it under the terms of the GNU General Public License version 2 as
  46. + * published by the Free Software Foundation.
  47. + *
  48. + */
  49. +
  50. +#include <linux/module.h>
  51. +#include <linux/kernel.h>
  52. +#include <linux/init.h>
  53. +#include <linux/platform_device.h>
  54. +#include <linux/mutex.h>
  55. +#include <linux/fb.h>
  56. +#include <linux/backlight.h>
  57. +#include <linux/pci.h>
  58. +
  59. +static struct pci_dev *gfx_dev = NULL;
  60. +static u32 *bl_baseptr = NULL;
  61. +
  62. +static int openframe_set_intensity(struct backlight_device *bd)
  63. +{
  64. + int intensity = bd->props.brightness;
  65. +
  66. + if (bd->props.power != FB_BLANK_UNBLANK)
  67. + intensity = 0;
  68. + if (bd->props.fb_blank != FB_BLANK_UNBLANK)
  69. + intensity = 0;
  70. +
  71. + *bl_baseptr = (intensity << 1) | 0x400000;
  72. +
  73. + return 0;
  74. +}
  75. +
  76. +static int openframe_get_intensity(struct backlight_device *bd)
  77. +{
  78. + int intensity;
  79. +
  80. + intensity = (*bl_baseptr >> 1) & 0x2f;
  81. +
  82. + return intensity;
  83. +}
  84. +
  85. +static struct backlight_ops openframe_ops = {
  86. + .get_brightness = openframe_get_intensity,
  87. + .update_status = openframe_set_intensity,
  88. +};
  89. +
  90. +static int openframe_probe(struct platform_device *pdev)
  91. +{
  92. + u32 temp;
  93. + struct backlight_device *openframe_backlight_device;
  94. + struct backlight_properties props;
  95. +
  96. + gfx_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x8108, NULL);
  97. + if (!gfx_dev) {
  98. + printk("Intel SCH Poulsbo graphics controller not found.\n");
  99. + return -ENODEV;
  100. + }
  101. +
  102. + pci_read_config_dword(gfx_dev, 16, &temp);
  103. + bl_baseptr = ioremap(temp + 0x61254, 4);
  104. +
  105. + memset(&props, 0, sizeof(struct backlight_properties));
  106. + props.power = FB_BLANK_UNBLANK;
  107. + props.brightness = 32;
  108. + props.max_brightness = 32;
  109. + props.type = BACKLIGHT_PLATFORM;
  110. +
  111. + openframe_backlight_device = backlight_device_register("openframe-bl",
  112. + &pdev->dev, NULL,
  113. + &openframe_ops,
  114. + &props);
  115. + if (IS_ERR(openframe_backlight_device)) {
  116. + iounmap(bl_baseptr);
  117. + pci_dev_put(gfx_dev);
  118. + return PTR_ERR(openframe_backlight_device);
  119. + }
  120. + platform_set_drvdata(pdev, openframe_backlight_device);
  121. + openframe_set_intensity(openframe_backlight_device);
  122. +
  123. + return 0;
  124. +}
  125. +
  126. +static int openframe_remove(struct platform_device *pdev)
  127. +{
  128. + struct backlight_device *bd = platform_get_drvdata(pdev);
  129. + backlight_device_unregister(bd);
  130. +
  131. + iounmap(bl_baseptr);
  132. + pci_dev_put(gfx_dev);
  133. +
  134. + return 0;
  135. +}
  136. +
  137. +static struct platform_driver openframe_driver = {
  138. + .probe = openframe_probe,
  139. + .remove = openframe_remove,
  140. + .driver = {
  141. + .name = "openframe-bl",
  142. + },
  143. +};
  144. +
  145. +static struct platform_device *openframe_device;
  146. +
  147. +static int __init openframe_init(void)
  148. +{
  149. + int ret = platform_driver_register(&openframe_driver);
  150. +
  151. + if (ret)
  152. + return ret;
  153. + openframe_device = platform_device_register_simple("openframe-bl", -1,
  154. + NULL, 0);
  155. + if (IS_ERR(openframe_device)) {
  156. + platform_driver_unregister(&openframe_driver);
  157. + return PTR_ERR(openframe_device);
  158. + }
  159. +
  160. + return 0;
  161. +}
  162. +
  163. +static void __exit openframe_exit(void)
  164. +{
  165. + platform_device_unregister(openframe_device);
  166. + platform_driver_unregister(&openframe_driver);
  167. +}
  168. +
  169. +module_init(openframe_init);
  170. +module_exit(openframe_exit);
  171. +
  172. +MODULE_AUTHOR("Andrew de Quincey <adq@lidskialf.net>");
  173. +MODULE_DESCRIPTION("Openframe Backlight Driver");
  174. +MODULE_LICENSE("GPL");