Search This Blog

Loading...

Popular Posts

Saturday, 26 November 2011

Enabling Samsung Laptop Backlight Support in Ubuntu 11.10

Is your Samsung Laptop brightness buttons not working? Yep, mine isn't too. The Kernel in Ubuntu 11.10 includes support for a number of Samsung Laptops thanks to the efforts of Greg Kroah and if you are interested in improving this I suggest filing bug reports to your distribution vendor or upstream.

What to do in the meantime...

Follow these steps to make your Samsung Laptop's brightness buttons work / or to test if the samsung-laptop.ko works with your Samsung Laptop.

Open a terminal,

mkdir samsung
cd samsung
wget http://dl.dropbox.com/u/16953763/Ubuntu%2011.10%20Samsung%20Laptop/Makefile
wget http://dl.dropbox.com/u/16953763/Ubuntu%2011.10%20Samsung%20Laptop/samsung-laptop.c
sudo dmidecode -s system-product-name

Make a note of the product name / model, mine is identified as R510/P510

gedit samsung-laptop.c

Add your Samsung model to the dmi table or modify one of the existing entries, scroll down to line 504, you will see the table starts with the N128.
{
.ident = "N128",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR,
"SAMSUNG ELECTRONICS CO., LTD."),
DMI_MATCH(DMI_PRODUCT_NAME, "N128"),
DMI_MATCH(DMI_BOARD_NAME, "N128"),
},
.callback = dmi_check_cb,
},

I am going to modify the N128 entry and replace the "N128" with my Laptop model, the R510/P510.

{
.ident = "R510/P510",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR,
"SAMSUNG ELECTRONICS CO., LTD."),
DMI_MATCH(DMI_PRODUCT_NAME, "R510/P510"),
DMI_MATCH(DMI_BOARD_NAME, "R510/P510"),
},
.callback = dmi_check_cb,
},

Once you have edited the samsung-laptop.c file, save and exit. Now build the samsung-laptop.ko module.

make

Your modified samsung-laptop.ko module should have compiled successfully. The next step is to replace the existing module.

sudo cp samsung-laptop.ko /lib/modules/$(uname -r)/kernel/drivers/platform/x86/
sudo depmod -a

The final step, add acpi_backlight=vendor to grub

sudo gedit /etc/default/grub

Modify the line,


GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"

Save and exit, then update grub.

sudo update-grub

Now reboot and test your Fn Brightness buttons.

20 comments:

  1. I got errors on some steps. Here's a copy:

    root@mike-X460:~/samsung# gedit samsung-laptop.c

    (gedit:1993): Gtk-WARNING **: Attempting to store changes into `/root/.local/share/recently-used.xbel', but failed: Failed to create file '/root/.local/share/recently-used.xbel.P7OQ5V': No such file or directory

    (gedit:1993): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: No such file or directory

    (gedit:1993): Gtk-WARNING **: Unknown property: GtkGrid.n-rows

    (gedit:1993): Gtk-WARNING **: Unknown property: GtkGrid.n-columns

    (gedit:1993): Gtk-WARNING **: Attempting to store changes into `/root/.local/share/recently-used.xbel', but failed: Failed to create file '/root/.local/share/recently-used.xbel.CBVV5V': No such file or directory

    (gedit:1993): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: No such file or directory

    (gedit:1993): Gtk-WARNING **: Attempting to store changes into `/root/.local/share/recently-used.xbel', but failed: Failed to create file '/root/.local/share/recently-used.xbel.GVLJ5V': No such file or directory

    (gedit:1993): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: No such file or directory
    root@mike-X460:~/samsung# make
    make -C /lib/modules/3.0.0-13-generic/build M=/root/samsung modules
    make[1]: Entering directory `/usr/src/linux-headers-3.0.0-13-generic'
    CC [M] /root/samsung/samsung-backlight.o
    /root/samsung/samsung-backlight.c: In function ‘sabi_exec_command’:
    /root/samsung/samsung-backlight.c:105:5: error: implicit declaration of function ‘msleep’ [-Werror=implicit-function-declaration]
    cc1: some warnings being treated as errors

    make[2]: *** [/root/samsung/samsung-backlight.o] Error 1
    make[1]: *** [_module_/root/samsung] Error 2
    make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-13-generic'
    make: *** [all] Error 2
    root@mike-X460:~/samsung#

    ReplyDelete
  2. Please disregard the Fedora post and start from the very beginning using this new post.

    It is designed for Ubuntu 11.10 and will work if you follow it to the letter.

    Even the Makefile and samsung-laptop.c file is different, so using the ones I posted in my Fedora guide will fail.

    And there is no need to be logged in as root.

    Regards, Adam

    ReplyDelete
  3. Not sure what has happened. I removed all the files in my samsung dir and re-executed your post and it all executed w/o errors (except that there was no pre-existing grub file so I just made a new one with that line in it, seemed to work). There's no control of the brighness and it no longer shows that I'm hitting the function keys (before, it showed them on screen earlier but would not adjust it.
    I think I may do a clean install of 11.10 and retry this.

    ReplyDelete
  4. I think a clean install of 11.10 sounds like a good idea, keep me posted.

    Regards, Adam

    ReplyDelete
  5. Ok, COMPLETELY clean install and it seems to act oddly as soon as I press fn-down arrow, it dims it one setting and seems to freeze up. I wind up hitting ctrl-alt-del to get its attention again. And after that the fn-down arrow no longer seems to do anything.

    Is there anything else I should do to that file except replace N128 with X460?

    ReplyDelete
  6. Can you post the output of

    sudo dmidecode -s system-product-name

    and does your laptop have nvidia or intel graphics?

    ReplyDelete
  7. X460

    intel

    running system update got rid of freezes but the fn key still does not adjust the brightness

    ReplyDelete
  8. :(

    The X460 is almost identical to my R510, so I would expect the steps to work.

    Adding X460 is all you need to do to the samsung-laptop.c file as illustrated above.

    I note you stated you updated your system, if the kernel was also updated you will need to reload the samsung-laptop.ko module.

    You can verify if the module has been loaded by typing in a terminal,

    lsmod | grep samsung

    if it displays samsung_laptop, the module was loaded.

    It is also important acpi_backlight was added to grub, and grub was updated.

    I can only suggest following the steps again to check if you missed anything.

    Regards Adam

    ReplyDelete
  9. It was loaded. Definitely odd behavior.

    Fn-down arrow registers ONE time but actually gets BRIGHTER. Makes the system so sluggish that I have to ctrl-alt-del to get it out of whatever it's stuck in, and then cancel out of the logout screen that brings up.

    Is the module definitely compatible with this model?

    ReplyDelete
  10. One last thing to try, add mem=3072M to your grub.

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor mem=3072M"

    Then sudo update-grub.

    If this works I will explain why.

    ReplyDelete
  11. I guess the module is not compatible with your laptop :(

    ReplyDelete
  12. Well thanks for trying. Know where any other modules to play with can be found?

    ReplyDelete
  13. Perhaps this may be of help, http://www.voria.org/forum/index.php

    https://launchpad.net/~voria/+archive/ppa

    ReplyDelete
  14. Thanks. I added his easy-slowdown-manager and his samsung-backlight and ... it works! I can now control the brightness with the Fn keys and it no longer semi/crashes the machine.

    ReplyDelete
  15. You rock! Thanks. This procedure works like a charm for the Samsung 300v-S03 laptop
    I also installed easy-slow-down-manager and samsing-backlight. It might be the combination.
    I suggest adding this repository: https://launchpad.net/~voria/+archive/ppa

    But this module change finally did the trick.

    The Fn brightness keys are working. Finally enjoying a seemless Ubuntu experience on the laptop.

    Cheers, Melle

    ReplyDelete
  16. Error: Location of the 'grub' file is:

    /etc/default/grub

    not /etc/default.grub

    ReplyDelete
  17. Thanks for spotting the typo error.

    ReplyDelete
  18. Thanks and God bless you and everyone involved in the project!... it worked like a charm :)

    ReplyDelete
  19. Worked perfectly with my 300V3A/300V4A/300V5A, thanks!

    ReplyDelete