Skip to content
Browse files

first cut at moving the values to be between 0 and 7

  • Loading branch information...
1 parent 66973ab commit 886c2ee63d52a18ef076214e280d76d88fa5f597 @gregkh committed
Showing with 26 additions and 6 deletions.
  1. +26 −6 samsung-backlight.c
View
32 samsung-backlight.c
@@ -18,9 +18,21 @@
#include <linux/fb.h>
#include <linux/dmi.h>
-#define MAX_BRIGHT 0xff
+#define MAX_BRIGHT 0x07
#define OFFSET 0xf4
+/*
+ * HAL/gnome-display-manager really wants us to only set 8 different levels for
+ * the brightness control. And since 256 different levels seems a bit
+ * overkill, that's fine. So let's map the 256 values to 8 different ones:
+ *
+ * userspace 0 1 2 3 4 5 6 7
+ * hardware 0 31 63 95 127 159 191 255
+ *
+ * or hardware = (userspace * 32) - 1 iff userspace != 0
+ */
+
+
static int offset = OFFSET;
module_param(offset, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(offset, "The offset into the PCI device for the brightness control");
@@ -30,15 +42,23 @@ static struct backlight_device *backlight_device;
static u8 read_brightness(void)
{
- u8 brightness;
+ u8 kernel_brightness;
+ u8 user_brightness = 0;
- pci_read_config_byte(pci_device, offset, &brightness);
- return brightness;
+ pci_read_config_byte(pci_device, offset, &kernel_brightness);
+ if (kernel_brightness != 0)
+ user_brightness = kernel_brightness / 32;
+
+ return user_brightness;
}
-static void set_brightness(u8 brightness)
+static void set_brightness(u8 user_brightness)
{
- pci_write_config_byte(pci_device, offset, brightness);
+ u16 kernel_brightness = 0;
+
+ if (user_brightness != 0)
+ kernel_brightness = (user_brightness * 32) - 1;
+ pci_write_config_byte(pci_device, offset, (u8)kernel_brightness);
}
static int get_brightness(struct backlight_device *bd)

0 comments on commit 886c2ee

Please sign in to comment.
Something went wrong with that request. Please try again.