Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed brightness levels #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Currently supported:
* NF110/NF210/NF310
* N220
* N230
* N350
* R470/R420
* R528/R728

Not tested:

Expand All @@ -31,7 +34,7 @@ Have a similar problem, but need more information to add it (if you are owner of

## Installation

git clone https://xonatius@github.com/xonatius/samsung-backlight.git
git clone git://github.com/xonatius/samsung-backlight.git
cd samsung-backlight
make
sudo make install
Expand Down
51 changes: 41 additions & 10 deletions samsung-backlight.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Samsung N130, N220, N230 NC10, Np-Q45, R468/R418, X320/X420/X520, X360,
* R518, R510/P510, R410 and NF110/NF210/NF310 Laptop Backlight driver
* R518, R510/P510, R410, NF110/NF210/NF310, N350, R470/R420, R528/R728
* Laptop Backlight driver
*
* Copyright (C) 2011 Peter Savichev (proton) ([email protected])
* Copyright (C) 2010 xonatius ([email protected])
Expand Down Expand Up @@ -31,9 +32,9 @@
* 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 31 63 95 127 159 195 223 255
* hardware 3 39 75 111 147 183 219 255
*
* or hardware = ((userspace + 1) * 32)-1
* or hardware = (userspace * 36) + 3
*
* 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
Expand All @@ -54,15 +55,15 @@ static u8 read_brightness(void)
u8 user_brightness = 0;

pci_read_config_byte(pci_device, offset, &kernel_brightness);
user_brightness = ((kernel_brightness + 1) / 32) - 1;
user_brightness = (kernel_brightness - 3) / 36;
return user_brightness;
}

static void set_brightness(u8 user_brightness)
{
u16 kernel_brightness = 0;

kernel_brightness = ((user_brightness + 1) * 32) - 1;
kernel_brightness = (user_brightness * 36) + 3;
pci_write_config_byte(pci_device, offset, (u8)kernel_brightness);
}

Expand Down Expand Up @@ -207,7 +208,33 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
},
.callback = dmi_check_cb,
},

{
.ident = "N350",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
DMI_MATCH(DMI_PRODUCT_NAME, "N350"),
DMI_MATCH(DMI_BOARD_NAME, "N350"),
},
.callback = dmi_check_cb,
},
{
.ident = "R470/R420",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
DMI_MATCH(DMI_PRODUCT_NAME, "R470/R420"),
DMI_MATCH(DMI_BOARD_NAME, "R470/R420"),
},
.callback = dmi_check_cb,
},
{
.ident = "R528/R728",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
DMI_MATCH(DMI_PRODUCT_NAME, "R528/R728"),
DMI_MATCH(DMI_BOARD_NAME, "R528/R728"),
},
.callback = dmi_check_cb,
},
{ },
};

Expand All @@ -222,21 +249,22 @@ static int __init samsung_init(void)
/*
* The Samsung N120, N130, and NC10 use pci device id 0x27ae, while the
* NP-Q45 uses 0x2a02
* R410P, R468/R418, R518, R510/P510, X320/X420/X520 and X360 uses 0x2a42
* N220 and NF110/NF210/NF310 uses 0xa011
* R410P, R468/R418, R518, R510/P510, X320/X420/X520, X360, R470/R420
* and R528/R728 uses 0x2a42
* N220, NF110/NF210/NF310 and N350 uses 0xa011
* Odds are we might need to add more to the
* list over time...
*/
pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, 0x27ae, NULL);
if (!pci_device)
if (!pci_device)
pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2a02, NULL);
if (!pci_device)
pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2a42, NULL);
if (!pci_device)
pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, 0xa011, NULL);
if (!pci_device)
return -ENODEV;


/* create a backlight device to talk to this one */
backlight_device = backlight_device_register("samsung",
Expand Down Expand Up @@ -282,3 +310,6 @@ MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnR510/P510:*:rnR510/P510:*");
MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnNF110/NF210/NF310:*:rnNF110/NF210/NF310:*");
MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnN220:*:rnN220:*");
MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnN230:*:rnN230:*");
MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnN350:*:rnN350:*");
MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnR470/R420:*:rnR470/R420:*");
MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnR528/R728:*:rnR528/R728:*");