Resend: This time I've actually included the correct patch.
This patch hooks into the generic backlight framework and allows the
brightness of Dell laptop displays to be read. The AC and DC values are
separate, but the framework currently provides no mechanism for them to
be provided separately and there's no straightforward way for the driver
to know if the system is on battery or not. As a result, I've put the AC
brightness in the top 16 bits of the returned value, with the DC
brightness in the bottom 16.
This patch requires my earlier patch to allow checking against the DMI
chassis type and should be applied after the HP backlight patch.
Signed-Off-By: Matthew Garrett <[email protected]>
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index e4f84eb..0f83183 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -56,4 +56,12 @@ config BACKLIGHT_HP
default n
help
Allows userspace applications to read the current screen brightness
- on HP laptops
\ No newline at end of file
+ on HP laptops
+
+config BACKLIGHT_DELL
+ tristate "Dell Laptop Backlight Driver"
+ depends on BACKLIGHT_DEVICE && X86
+ default n
+ help
+ Allows userspace applications to read the current screen brightness
+ on Dell laptops
\ No newline at end of file
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 93ac108..f337f01 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -4,4 +4,5 @@ obj-$(CONFIG_LCD_CLASS_DEVICE) += lc
obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o
obj-$(CONFIG_SHARP_LOCOMO) += locomolcd.o
-obj-$(CONFIG_BACKLIGHT_HP) += hp_bl.o
\ No newline at end of file
+obj-$(CONFIG_BACKLIGHT_HP) += hp_bl.o
+obj-$(CONFIG_BACKLIGHT_DELL) += dell_bl.o
\ No newline at end of file
diff --git a/drivers/video/backlight/dell_bl.c b/drivers/video/backlight/dell_bl.c
new file mode 100644
index 0000000..a97a4b8
--- /dev/null
+++ b/drivers/video/backlight/dell_bl.c
@@ -0,0 +1,92 @@
+/*
+ * Backlight Driver for Dell laptops
+ *
+ * Copyright (c) 2006 Matthew Garrett
+ *
+ * Based on corgi_bl.c, Copyright (c) 2004-2005 Richard Purdie
+ *
+ * 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/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/fb.h>
+#include <linux/backlight.h>
+#include <linux/dmi.h>
+#include <linux/nvram.h>
+
+static struct backlight_properties dellbl_data;
+
+static struct dmi_system_id __initdata delllcd_device_table[] = {
+ {
+ .ident = "Dell",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_CHASSIS_TYPE, "Portable"),
+ },
+ },
+ { }
+};
+
+
+static int dellbl_get_intensity(struct backlight_device *bd)
+{
+ /* The backlight interface doesn't give us a means of providing
+ more than one brightness value, so we put the AC value in the
+ top bits of the brightness and the DC value in the bottom bits */
+
+ int value;
+ int combined;
+
+ value = nvram_read_byte(0x53);
+
+ value &= 0xf0; // Brightness is in the upper 4 bits
+ combined = value << 12;
+
+ value = nvram_read_byte(0x16);
+
+ outb(0x99, 0x72);
+ value = inb(0x73);
+
+ value &= 0x0f; // Brightness is in the lower 4 bits
+ combined |= value;
+
+ return combined;
+}
+
+static struct backlight_properties dellbl_data = {
+ .owner = THIS_MODULE,
+ .get_brightness = dellbl_get_intensity,
+ .max_brightness = 0xe,
+};
+
+static struct backlight_device *dell_backlight_device;
+
+static int __init dellbl_init(void)
+{
+ if (!dmi_check_system(delllcd_device_table))
+ return -ENODEV;
+
+ dell_backlight_device = backlight_device_register ("dell-bl",
+ NULL, &dellbl_data);
+ if (IS_ERR (dell_backlight_device))
+ return PTR_ERR (dell_backlight_device);
+
+ return 0;
+}
+
+static void __exit dellbl_exit(void)
+{
+ backlight_device_unregister(dell_backlight_device);
+}
+
+module_init(hpbl_init);
+module_exit(hpbl_exit);
+
+MODULE_AUTHOR("Matthew Garrett <[email protected]>");
+MODULE_DESCRIPTION("Dell Backlight Driver");
+MODULE_LICENSE("GPL");
--
Matthew Garrett | [email protected]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]