Permalink
Browse files

make value 0 actually show something.

  • Loading branch information...
gregkh committed Aug 20, 2009
1 parent 22e16dd commit cb0feb7ba6094ceb05505fee659e898709ae078e
Showing with 9 additions and 8 deletions.
  1. +9 −8 samsung-backlight.c
View
@@ -26,10 +26,14 @@
* 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 36 72 108 144 180 216 252
+ * userspace 0 1 2 3 4 5 6 7
+ * hardware 31 63 95 127 159 195 223 255
*
- * or hardware = (userspace * 36) - 1 iff userspace != 0
+ * or hardware = ((userspace + 1) * 32)-1
+ *
+ * Note, we keep value 0 at a positive value, otherwise the screen goes
+ * blank because HAL likes to set the backlight to 0 at startup when there is
+ * no power plugged in.
*/
@@ -46,18 +50,15 @@ static u8 read_brightness(void)
u8 user_brightness = 0;
pci_read_config_byte(pci_device, offset, &kernel_brightness);
- if (kernel_brightness != 0)
- user_brightness = kernel_brightness / 36;
-
+ user_brightness = ((kernel_brightness + 1) / 32) - 1;
return user_brightness;
}
static void set_brightness(u8 user_brightness)
{
u16 kernel_brightness = 0;
- if (user_brightness != 0)
- kernel_brightness = (user_brightness * 36) - 1;
+ kernel_brightness = ((user_brightness + 1) * 32) - 1;
pci_write_config_byte(pci_device, offset, (u8)kernel_brightness);
}

0 comments on commit cb0feb7

Please sign in to comment.