Home > Techy Geeky~ > HOWTO: Make brightness control Fn keys work correctly on HP DV2000 with Ubuntu 7.04(Feisty)

HOWTO: Make brightness control Fn keys work correctly on HP DV2000 with Ubuntu 7.04(Feisty)

Problem:
I’ve a hp dv2210us (one of the dv2000z series) laptop with feisty installed. Almost everything works fine, except that it is not easy to adjust the brightness easily. Fn keys don’t work, no slider in Gnome Power Manager. The only way to adjust the brightness is "sudo echo" a correct value to /proc/acpi/video/VGA/LCD/brightness, which is quite inconvenient. More precisely, the Fn keys may sometimes turn the screen to either brightest or dimmest. A careful study shows that the problem resides in the kernel module "video". Whenever the keys are pressed, the module will try to adjust the brightness as well as trigger a signal might be caught by acpi daemon. However, for some reason that I don’t know, the module cannot adjust the brightness correctly on my laptop.

Solution:
The idea is to adjust the brightness through acpi daemon rather than the kernel module. So what we are going to do is to modify the kernel module a bit and add some small scripts to the acpi daemon. Here we go. I hope this howto may help those who have the similar problems.

************Please remember to do the backup before any modification and file replacements.********

1. Install the source package
sudo apt-get install linux-source-2.6.20
cd /usr/src
sudo tar xvjf linux-source-2.6.20.tar.bz2

2. Modify the kernel module.
cd /usr/src/linux-source-2.6.20/drivers/acpi
sudo gedit video.c
**find the code block below:

case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
acpi_video_switch_brightness(video_device, event);
acpi_bus_generate_event(device, event, 0);
break;
default:

**edit this part according to below:

case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
acpi_video_switch_brightness(video_device, event);

acpi_bus_generate_event(device, event, 0);
break;
case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */

case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
acpi_bus_generate_event(device, event, 0);
break;
default:


Save and quit.

3. Recompile and replace the kernel module
cd /usr/src/linux-source-2.6.20/drivers/acpi
sudo gedit makevideo
write the following code into the newly created file.

KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

Save and quit.
sudo make -f makevideo
sudo cp video.ko /lib/modules/`uname -r`/kernel/drivers/acpi/

4. Add acpi events
cd /etc/acpi/events
sudo gedit hp-brightness-up
write the following contents into the newly created file:

event=video LCD 00000086 00000000
action=/etc/acpi/hpbrightnessup.sh

Save and quit.
sudo gedit hp-brightness-down (same as before)

event=video LCD 00000087 00000000
action=/etc/acpi/hpbrightnessdown.sh

Save and quit.

5. Add new acpi scripts to adjust the brightness
cd /etc/acpi
cat /proc/acpi/video/VGA/LCD/brightness
please pay attention to the output of levels.
mine is : "levels: 100 60 20 28 36 44 52 60 68 76 84 92 100"
if yours is different you may have to change the numbers in the following scripts.
sudo gedit hpbrightnessup.sh

#!/bin/sh

value="`cat /proc/acpi/video/VGA/LCD/brightness | grep current: | awk ‘{print $2;}’`"
if [ $value -eq 0 ]
then
value=92
fi
if [ $value -ge 92 ]
then
value=92
else
value=`expr $value + 8`
fi
echo $value > /proc/acpi/video/VGA/LCD/brightness

Save and quit.
sudo gedit hpbrightnessdown.sh

#!/bin/sh
value="`cat /proc/acpi/video/VGA/LCD/brightness | grep current: | awk ‘{print $2;}’`"
echo $value
if [ $value -eq 0 ]
then
value=92
fi
if [ $value -le 20 ]
then
value=20
else
value=`expr $value – 8`
fi
echo $value > /proc/acpi/video/VGA/LCD/brightness

Save and quit.
sudo chmod +x hpbrightness*.sh

6. Done
You may find the Fn keys work correctly after rebooting the computer.
I wish I made everything clear here, however, if any questions, plz let me know.

Advertisements
Categories: Techy Geeky~
  1. Atomic
    July 14, 2007 at 5:17 pm

    It seems every day you are fighting with Linux…..

  2. Jiasheng
    July 14, 2007 at 6:25 pm

    well, not really.  I’ve done this long ago and here is just a summary of the steps to help others as well as remind myself.

  3. wenwen
    July 15, 2007 at 1:08 pm

    欧只看的懂最上面两段~
     

  4. MK
    July 17, 2007 at 1:02 pm

    还是我的老本好,除了A卡的驱动其他都很好。。。反正我也不用CF

  5. Lei
    July 17, 2007 at 5:25 pm

    汗,真能搞。。。还好我用的是ThinkPad。。。

  6. 兜兜
    August 27, 2007 at 12:45 am

    来寻mm。。。 

  7. 兔子
    August 29, 2007 at 5:19 am

     ……看不懂

  8. Unknown
    September 7, 2008 at 5:05 am

    Hi,Do you need advertising displays, digital signages, advertising player and LCD displays? Please go Here:www.amberdigital.com.hk(Amberdigital).we have explored and developed the international market with professionalism. We have built a widespread marketing network, and set up a capable management team dedicated to provide beyond-expectation services to our customers.
    amberdigital Contact Us
    E-mail:sstar@netvigator.com
    website:www.amberdigital.com.hk
    alibaba:amberdigital.en.alibaba.com[dafiffbcgdigga]

  9. apple
    March 25, 2010 at 8:23 am

    你好 我的笔记本也是不能调节亮度 能向你请教一下UBUNTU 9.10下怎么使用ACPI DAMEON吗 请加我qq 877099871 顺便和你做个朋友 你大几了?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: