Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-08-16 15:19:41 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2009-08-16 15:19:41 -0700
commitd0f808cfa420755ce65232029e5cdca8470ffb55 (patch)
tree9ad024056681bbab813d0609c067a9c649f6f05c
parentff4605772d942a3b6e70855563e2c67741a4680c (diff)
- patches.drivers/samsung-backlight-driver.patch: added N120 support
and some other devices that were integrated into the driver from upstream. suse-commit: 1ef4a05272f4f5fc5156f08ab7262fc454b95804
-rw-r--r--drivers/platform/x86/samsung-backlight.c119
1 files changed, 54 insertions, 65 deletions
diff --git a/drivers/platform/x86/samsung-backlight.c b/drivers/platform/x86/samsung-backlight.c
index accc20e30706..c4739b678a78 100644
--- a/drivers/platform/x86/samsung-backlight.c
+++ b/drivers/platform/x86/samsung-backlight.c
@@ -7,7 +7,6 @@
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
- *
*/
#include <linux/kernel.h>
@@ -21,23 +20,24 @@
#define MAX_BRIGHT 0xff
#define OFFSET 0xf4
+static int offset = OFFSET;
+module_param(offset, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(offset, "The offset into the PCI device for the brightness control");
+
static struct pci_dev *pci_device;
static struct backlight_device *backlight_device;
-static int offset = OFFSET;
-static u8 current_brightness;
-static void read_brightness(void)
+static u8 read_brightness(void)
{
- if (!pci_device)
- return;
- pci_read_config_byte(pci_device, offset, &current_brightness);
+ u8 brightness;
+
+ pci_read_config_byte(pci_device, offset, &brightness);
+ return brightness;
}
-static void set_brightness(void)
+static void set_brightness(u8 brightness)
{
- if (!pci_device)
- return;
- pci_write_config_byte(pci_device, offset, current_brightness);
+ pci_write_config_byte(pci_device, offset, brightness);
}
static int get_brightness(struct backlight_device *bd)
@@ -47,11 +47,7 @@ static int get_brightness(struct backlight_device *bd)
static int update_status(struct backlight_device *bd)
{
- if (!pci_device)
- return -ENODEV;
-
- current_brightness = bd->props.brightness;
- set_brightness();
+ set_brightness(bd->props.brightness);
return 0;
}
@@ -60,51 +56,7 @@ static struct backlight_ops backlight_ops = {
.update_status = update_status,
};
-static int find_video_card(void)
-{
- struct pci_dev *dev = NULL;
-
- while ((dev = pci_get_device(0x8086, 0x27ae, dev)) != NULL) {
- /*
- * Found one, so let's save it off and break
- * Note that the reference is still raised on
- * the PCI device here.
- */
- pci_device = dev;
- break;
- }
-
- if (!pci_device)
- return -ENODEV;
-
- /* create a backlight device to talk to this one */
- backlight_device = backlight_device_register("samsung",
- &pci_device->dev,
- NULL, &backlight_ops);
- if (IS_ERR(backlight_device))
- return PTR_ERR(backlight_device);
- read_brightness();
- backlight_device->props.max_brightness = MAX_BRIGHT;
- backlight_device->props.brightness = current_brightness;
- backlight_device->props.power = FB_BLANK_UNBLANK;
- backlight_update_status(backlight_device);
- return 0;
-}
-
-static void remove_video_card(void)
-{
- if (!pci_device)
- return;
-
- backlight_device_unregister(backlight_device);
- backlight_device = NULL;
-
- /* we are done with the PCI device, put it back */
- pci_dev_put(pci_device);
- pci_device = NULL;
-}
-
-static int dmi_check_cb(const struct dmi_system_id *id)
+static int __init dmi_check_cb(const struct dmi_system_id *id)
{
printk(KERN_INFO KBUILD_MODNAME ": found laptop model '%s'\n",
id->ident);
@@ -113,6 +65,15 @@ static int dmi_check_cb(const struct dmi_system_id *id)
static struct dmi_system_id __initdata samsung_dmi_table[] = {
{
+ .ident = "N120",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "N120"),
+ DMI_MATCH(DMI_BOARD_NAME, "N120"),
+ },
+ .callback = dmi_check_cb,
+ },
+ {
.ident = "N130",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
@@ -147,12 +108,41 @@ static int __init samsung_init(void)
if (!dmi_check_system(samsung_dmi_table))
return -ENODEV;
- return find_video_card();
+ /*
+ * The Samsung N120, N130, and NC10 use pci device id 0x27ae, while the
+ * NP-Q45 uses 0x2a02. 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) {
+ pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2a02, NULL);
+ if (!pci_device)
+ return -ENODEV;
+ }
+
+ /* create a backlight device to talk to this one */
+ backlight_device = backlight_device_register("samsung",
+ &pci_device->dev,
+ NULL, &backlight_ops);
+ if (IS_ERR(backlight_device)) {
+ pci_dev_put(pci_device);
+ return PTR_ERR(backlight_device);
+ }
+
+ backlight_device->props.max_brightness = MAX_BRIGHT;
+ backlight_device->props.brightness = read_brightness();
+ backlight_device->props.power = FB_BLANK_UNBLANK;
+ backlight_update_status(backlight_device);
+
+ return 0;
}
static void __exit samsung_exit(void)
{
- remove_video_card();
+ backlight_device_unregister(backlight_device);
+
+ /* we are done with the PCI device, put it back */
+ pci_dev_put(pci_device);
}
module_init(samsung_init);
@@ -161,8 +151,7 @@ module_exit(samsung_exit);
MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>");
MODULE_DESCRIPTION("Samsung Backlight driver");
MODULE_LICENSE("GPL");
-module_param(offset, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(offset, "The offset into the PCI device for the brightness control");
+MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnN120:*:rnN120:*");
MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnN130:*:rnN130:*");
MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnNC10:*:rnNC10:*");
MODULE_ALIAS("dmi:*:svnSAMSUNGELECTRONICSCO.,LTD.:pnSQ45S70S:*:rnSQ45S70S:*");