Hi Thomas, Please check if the attached patch helps? Regards, Alex. Thomas Bächler wrote: > Hello, > > After doing some research myself, I thought it was time to refer to this > list for advice. I am using a Lenovo 3000 N100 running Linux 2.6.23-rc4 > (x86_64). After loading the video kernel module, I can change the > brightness of my display between 0 and 100 by cat $level > > /sys/class/backlight/acpi_video0/brightness. > > However, when using the brightness keys on my keyboard, I can decrease > the brightness until 0, but I can never increase it over 42 again. > > I looked into the code and inserted a printk into the > acpi_video_get_next_level() function to print the min, max, > level_current, min_above and max_below values when I press the keys, as > well as the list of available levels. This is what I got: > > available levels: 100 57 0 14 28 43 57 71 86 100 > Pressing the decrease button: > min: 0, max: 100, level_current: 98, min_above: 100, max_below: 86 > min: 0, max: 100, level_current: 84, min_above: 86, max_below: 71 > min: 0, max: 100, level_current: 70, min_above: 71, max_below: 57 > min: 0, max: 100, level_current: 56, min_above: 57, max_below: 43 > min: 0, max: 100, level_current: 42, min_above: 43, max_below: 28 > min: 0, max: 100, level_current: 28, min_above: 43, max_below: 14 > min: 0, max: 100, level_current: 14, min_above: 28, max_below: 0 > Pressing the increase button: > min: 0, max: 100, level_current: 0, min_above: 14, max_below: 0 > min: 0, max: 100, level_current: 14, min_above: 28, max_below: 0 > min: 0, max: 100, level_current: 28, min_above: 43, max_below: 14 > min: 0, max: 100, level_current: 42, min_above: 43, max_below: 28 > min: 0, max: 100, level_current: 42, min_above: 43, max_below: 28 > min: 0, max: 100, level_current: 42, min_above: 43, max_below: 28 > > It seems like Linux thinks that the level 43 is supported (maybe because > my bios reported just that), but when it tries to set it to 43, it is > actually set to 42. The same seems to be the case for the other levels > above 43 as well. > > As I don't know anything about ACPI, I am stuck here. Any help would be > appreciated. > > - > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html >
ACPI: VIDEO: Adjust current level to closest available one. From: Alexey Starikovskiy <astarikovskiy@xxxxxxx> Signed-off-by: Alexey Starikovskiy <astarikovskiy@xxxxxxx> --- drivers/acpi/video.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 3c9bb85..63b1101 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1634,9 +1634,20 @@ static int acpi_video_get_next_level(struct acpi_video_device *device, u32 level_current, u32 event) { - int min, max, min_above, max_below, i, l; + int min, max, min_above, max_below, i, l, delta = 255; max = max_below = 0; min = min_above = 255; + /* Find closest level to level_current */ + for (i = 0; i < device->brightness->count; i++) { + l = device->brightness->levels[i]; + if (abs(l - level_current) < abs(delta)) { + delta = l - level_current; + if (!delta) + break; + } + } + /* Ajust level_current to closest available level */ + level_current += delta; for (i = 0; i < device->brightness->count; i++) { l = device->brightness->levels[i]; if (l < min)