Advertisement
Guest User

crbkpx_backlight

a guest
Apr 11th, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.48 KB | None | 0 0
  1. diff -uNr linux-3.9-rc6/drivers/leds/Kconfig linux-3.9-rc6-CrBkPx/drivers/leds/Kconfig
  2. --- linux-3.9-rc6/drivers/leds/Kconfig  2013-04-08 12:49:54.000000000 +0900
  3. +++ linux-3.9-rc6-CrBkPx/drivers/leds/Kconfig   2013-04-11 15:30:40.964012115 +0900
  4. @@ -24,6 +24,13 @@
  5.  
  6.  comment "LED drivers"
  7.  
  8. +config LEDS_CHROMEOS_KEYBOARD
  9. +   tristate "LED support for Chrome OS keyboards"
  10. +   depends on LEDS_CLASS && ACPI
  11. +   help
  12. +     This option enables support for the LEDs on Chrome OS keyboards.
  13. +     Say Y to enable keyboard LEDs on Chrome OS systems.
  14. +
  15.  config LEDS_88PM860X
  16.     tristate "LED Support for Marvell 88PM860x PMIC"
  17.     depends on LEDS_CLASS
  18. diff -uNr linux-3.9-rc6/drivers/leds/leds-chromeos-keyboard.c linux-3.9-rc6-CrBkPx/drivers/leds/leds-chromeos-keyboard.c
  19. --- linux-3.9-rc6/drivers/leds/leds-chromeos-keyboard.c 1970-01-01 09:00:00.000000000 +0900
  20. +++ linux-3.9-rc6-CrBkPx/drivers/leds/leds-chromeos-keyboard.c  2013-04-11 15:30:00.116013092 +0900
  21. @@ -0,0 +1,120 @@
  22. +/*
  23. + *  leds-chromeos-keyboard.c - Keyboard backlight LED driver for Chrome OS.
  24. + *
  25. + *  Copyright (C) 2012 Google, Inc.
  26. + *
  27. + *  This program is free software; you can redistribute it and/or modify
  28. + *  it under the terms of the GNU General Public License as published by
  29. + *  the Free Software Foundation; either version 2 of the License, or
  30. + *  (at your option) any later version.
  31. + *
  32. + *  This program is distributed in the hope that it will be useful,
  33. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  34. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  35. + *  GNU General Public License for more details.
  36. + *
  37. + *  You should have received a copy of the GNU General Public License
  38. + *  along with this program; if not, write to the Free Software
  39. + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  40. + *
  41. + */
  42. +
  43. +#include <linux/acpi.h>
  44. +#include <linux/leds.h>
  45. +#include <linux/delay.h>
  46. +#include <linux/err.h>
  47. +#include <linux/module.h>
  48. +#include <linux/init.h>
  49. +#include <linux/kernel.h>
  50. +#include <linux/platform_device.h>
  51. +#include <linux/slab.h>
  52. +
  53. +/* Keyboard LED ACPI Device must be defined in firmware */
  54. +#define ACPI_KEYBOARD_BACKLIGHT_DEVICE "\\_SB.KBLT"
  55. +#define ACPI_KEYBOARD_BACKLIGHT_READ   ACPI_KEYBOARD_BACKLIGHT_DEVICE ".KBQC"
  56. +#define ACPI_KEYBOARD_BACKLIGHT_WRITE  ACPI_KEYBOARD_BACKLIGHT_DEVICE ".KBCM"
  57. +
  58. +#define ACPI_KEYBOARD_BACKLIGHT_MAX        100
  59. +
  60. +static void keyboard_led_set_brightness(struct led_classdev *cdev,
  61. +   enum led_brightness brightness)
  62. +{
  63. +   union acpi_object param;
  64. +   struct acpi_object_list input;
  65. +   acpi_status status;
  66. +
  67. +   if (!(cdev->flags & LED_SUSPENDED))
  68. +       cdev->brightness = brightness;
  69. +
  70. +   param.type = ACPI_TYPE_INTEGER;
  71. +   param.integer.value = brightness;
  72. +   input.count = 1;
  73. +   input.pointer = &param;
  74. +
  75. +   status = acpi_evaluate_object(NULL, ACPI_KEYBOARD_BACKLIGHT_WRITE,
  76. +                     &input, NULL);
  77. +   if (ACPI_FAILURE(status))
  78. +       dev_err(cdev->dev, "Error setting keyboard LED value");
  79. +}
  80. +
  81. +static int keyboard_led_probe(struct platform_device *pdev)
  82. +{
  83. +   struct led_classdev *cdev;
  84. +   acpi_handle handle;
  85. +   acpi_status status;
  86. +   int ret;
  87. +
  88. +   /* Look for the keyboard LED ACPI Device */
  89. +   status = acpi_get_handle(ACPI_ROOT_OBJECT,
  90. +                ACPI_KEYBOARD_BACKLIGHT_DEVICE,
  91. +                &handle);
  92. +   if (ACPI_FAILURE(status)) {
  93. +       dev_err(&pdev->dev, "Unable fo find ACPI device %s\n",
  94. +           ACPI_KEYBOARD_BACKLIGHT_DEVICE);
  95. +       return -ENODEV;
  96. +   }
  97. +
  98. +   cdev = kzalloc(sizeof(struct led_classdev), GFP_KERNEL);
  99. +   if (!cdev)
  100. +       return -ENOMEM;
  101. +   cdev->name = "chromeos::kbd_backlight";
  102. +   cdev->brightness_set = keyboard_led_set_brightness;
  103. +   cdev->max_brightness = ACPI_KEYBOARD_BACKLIGHT_MAX;
  104. +   cdev->brightness = cdev->max_brightness;
  105. +   cdev->flags |= LED_CORE_SUSPENDRESUME;
  106. +
  107. +   ret = led_classdev_register(&pdev->dev, cdev);
  108. +   if (ret)
  109. +       goto err;
  110. +
  111. +   platform_set_drvdata(pdev, cdev);
  112. +   return 0;
  113. +err:
  114. +   kfree(cdev);
  115. +   return ret;
  116. +}
  117. +
  118. +static int keyboard_led_remove(struct platform_device *pdev)
  119. +{
  120. +   struct led_classdev *cdev = platform_get_drvdata(pdev);
  121. +
  122. +   platform_set_drvdata(pdev, NULL);
  123. +   kfree(cdev);
  124. +   return 0;
  125. +}
  126. +
  127. +static struct platform_driver keyboard_led_driver = {
  128. +   .driver     = {
  129. +       .name   = "chromeos-keyboard-leds",
  130. +       .owner  = THIS_MODULE,
  131. +   },
  132. +   .probe      = keyboard_led_probe,
  133. +   .remove     = keyboard_led_remove,
  134. +};
  135. +
  136. +module_platform_driver(keyboard_led_driver);
  137. +
  138. +MODULE_AUTHOR("Simon Que <sque@chromium.org>");
  139. +MODULE_DESCRIPTION("ChromeOS Keyboard LED Driver");
  140. +MODULE_LICENSE("GPL");
  141. +MODULE_ALIAS("platform:chromeos-keyboard-leds");
  142. diff -uNr linux-3.9-rc6/drivers/leds/Makefile linux-3.9-rc6-CrBkPx/drivers/leds/Makefile
  143. --- linux-3.9-rc6/drivers/leds/Makefile 2013-04-08 12:49:54.000000000 +0900
  144. +++ linux-3.9-rc6-CrBkPx/drivers/leds/Makefile  2013-04-11 15:31:06.124011514 +0900
  145. @@ -52,6 +52,7 @@
  146.  obj-$(CONFIG_LEDS_MAX8997)     += leds-max8997.o
  147.  obj-$(CONFIG_LEDS_LM355x)      += leds-lm355x.o
  148.  obj-$(CONFIG_LEDS_BLINKM)      += leds-blinkm.o
  149. +obj-$(CONFIG_LEDS_CHROMEOS_KEYBOARD)   += leds-chromeos-keyboard.o
  150.  
  151.  # LED SPI Drivers
  152.  obj-$(CONFIG_LEDS_DAC124S085)      += leds-dac124s085.o
  153. diff -uNr linux-3.9-rc6/drivers/tty/sysrq.c linux-3.9-rc6-CrBkPx/drivers/tty/sysrq.c
  154. --- linux-3.9-rc6/drivers/tty/sysrq.c   2013-04-08 12:49:54.000000000 +0900
  155. +++ linux-3.9-rc6-CrBkPx/drivers/tty/sysrq.c    2013-04-11 15:37:39.332002111 +0900
  156. @@ -693,6 +693,7 @@
  157.         }
  158.         break;
  159.  
  160. +   case KEY_F10:
  161.     case KEY_SYSRQ:
  162.         if (value == 1 && sysrq->alt != KEY_RESERVED) {
  163.             sysrq->active = true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement