Dell laptop backlight driver
Subsystems (2)
PATCH 1/1 Dell laptop backlight driver
Hello,
this driver implements backlight control on Dell laptops which use SMI for changing brightness levels.
The driver is INCOMPLETE since it is unable to probe some required parameters in order to perform backlight control. Such parameters are found in a Dell proprietary DMI table which should be parsed. For now external tools may be used to find these parameters by hand. So if you intend to try this out, FIRST write your laptop model parameters correctly inside the source code as explained in Documentation/dell-laptop.txt.
Parts of this driver may also be used to provide additional functionalities similarly to the drivers/misc/*-laptop.c drivers.
regards,
jacopo antonello
******************************* diff follows
Documentation/dell-laptop.txt +105 -0
@@ -0,0 +1,105 @@ +This driver is EXPERIMENTAL, use it at YOUR OWN RISK. + +BEFORE TRYING THIS DRIVER OUT: +You MUST FILL IN your laptop parameters in the source code. This +driver is not capable of probing these parameters on its own. + +The parameters involved are: +- IO Port address +- IO command code +- Location + +These parameters depend (hopefully) on the model of your laptop. Such information +is found in a private Dell DMI table. You may use dmidecode or libsmbios' dumpCmos +(http://linux.dell.com/libsmbios/download/libsmbios/). The latter is best since +it DECODES COMPLETELY Dell's tokens. + +******************************************************* WITH LIBSMBIOS +root@here:~# dumpCmos | grep 0x007d +and you will get a line like the following... +DMI type 0xda Handle 0xda00 CmdIO Port 0x00b2 CmdIO Code 0x0d Type 0x007d Location 0x0000 value 0000 + +open dell-laptop.c and write the parameters accordingly under the probe_smi_params() +function + +static int probe_smi_params(void) +{ + /* + * these should be probed by parsing Dell's CMOS table (dmi type 0xda) + */ + smi_params.cmdio_port = 0x00b2; /* libsmbios' dumpCmos CmdIO Port */ + smi_params.cmdio_code = 0x0d; /* libsmbios' dumpCmos CmdIO Code */ + smi_params.backlight_location = 0; /* set to dumpCmos Location */ + smi_params.backlight_value = 0; /* set to dumpCmos Value (unused for backlight) */ + + return 0; +} +********************************************************************** + +******************************************************* WITH DMIDECODE +(this is HAND parsing!!) +dmidecode & look for table type 218 + +Handle 0xDA00, DMI type 218, 125 bytes +OEM-specific Type + Header and Data: + DA 7D 00 DA B2 00 0D 5F 0F 37 40 7D 00 00 00 00 + 00 7E 00 02 00 00 00 40 00 04 00 01 00 41 00 04 + 00 00 00 90 00 05 00 00 00 91 00 05 00 01 00 92 + 00 05 00 02 00 45 01 45 01 01 00 44 01 44 01 00 + 00 00 80 00 80 01 00 00 A0 00 A0 01 00 05 80 05 + 80 01 00 76 01 76 01 01 00 75 01 75 01 01 00 01 + F0 01 F0 00 00 02 F0 02 F0 00 00 03 F0 03 F0 00 + 00 04 F0 04 F0 00 00 FF FF 00 00 00 00 + +now you have: +1 byte DA (table type) +1 byte 7D (table size) +2 bytes 00 DA (handle) +2 bytes B2 00 (cmdio port address (swapped) ) +1 byte 0D (cmdio code) +4 bytes 5F 0F 37 40 (supported commands ?) + +after that you have triplets terminated by FF FF 00 00 00 00 +in the form (type, location, value) + +type | loc | val +7D 00|00 00|00 00 +7E 00|02 00|00 00 +40 00|04 00|01 00 +41 00|04 00|00 00 +90 00|05 00|00 00 +91 00|05 00|01 00 +92 00|05 00|02 00 +45 01|45 01|01 00 +44 01|44 01|00 00 +00 80|00 80|01 00 +00 A0|00 A0|01 00 +05 80|05 80|01 00 +76 01|76 01|01 00 +75 01|75 01|01 00 +01 F0|01 F0|00 00 +02 F0|02 F0|00 00 +03 F0|03 F0|00 00 +04 F0|04 F0|00 00 +end +FF FF|00 00|00 00 + +you can read the Location field in type 0x007d (swapped 7D 00) + +then modify dell-laptop.c accordingly (remember to swap the lsb with the msb +n the port address also!) + +static int probe_smi_params(void) +{ + /* + * these should be probed by parsing Dell's CMOS table (dmi type 0xda) + */ + smi_params.cmdio_port = 0x00b2; /* libsmbios' dumpCmos CmdIO Port */ + smi_params.cmdio_code = 0x0d; /* libsmbios' dumpCmos CmdIO Code */ + smi_params.backlight_location = 0; /* set to dumpCmos Location */ + smi_params.backlight_value = 0; /* set to dumpCmos Value (unused for backlight) */ + + return 0; +} +**********************************************************************
drivers/misc/Makefile +0 -0
@@ -15,3 +15,4 @@ obj-$(CONFIG_SGI_IOC4) += ioc4.o
obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o
obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o
obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o
+obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
drivers/misc/dell-laptop.h +116 -0
116 lines not on this page · raw message
drivers/misc/dell-laptop.c +649 -0
649 lines not on this page · raw message
drivers/misc/Kconfig +0 -0
@@ -130,6 +130,21 @@ config MSI_LAPTOP
If you have an MSI S270 laptop, say Y or M here.
+config DELL_LAPTOP
+ tristate "Dell Laptop Extras (EXPERIMENTAL)"
+ depends on X86
+ depends on EXPERIMENTAL
+ depends on BACKLIGHT_CLASS_DEVICE
+ ---help---
+ This driver implements LCD backlight control for Dell laptops. BEFORE + using this driver, please fill in your laptop model parameters as described + in dell-laptop.txt. Using this driver without doing this operation + may have UNPREDICTABLE effects on your laptop. You have been warned!
+
+ Just read <file:Documentation/dell-laptop.txt> first.
+
+ If you have a Dell laptop, say Y or M here.
+
config SONY_LAPTOP
tristate "Sony Laptop Extras" depends on X86 && ACPI
Quoted 12 lines · On Sun, Oct 28, 2007 at 05:12:37PM +0100, [email protected] wrote:
Hello,
this driver implements backlight control on Dell laptops which use SMI for changing brightness levels.The driver is INCOMPLETE since it is unable to probe some required parameters
in order to perform backlight control. Such parameters are found in a Dell proprietary DMI table which should be parsed. For now external tools may be used to find these parameters by hand. So if you intend to try this out, FIRST write your laptop model parameters correctly inside the source code as explained inDocumentation/dell-laptop.txt.
Quoted 2 lines
Parts of this driver may also be used to provide additional functionalities similarly to the
drivers/misc/*-laptop.cdrivers.
Why is this better done in the kernel rather than in userspace with libsmbios as you've noted?
Signature · 3 lines
Matt Domsch Linux Technology Strategist, Dell Office of the CTO linux.dell.com & www.dell.com/linux
Quoted 12 lines · Matt Domsch
Quoted 11 lines · On Sun, Oct 28, 2007 at 05:12:37PM +0100, [email protected] wrote:
Hello,
this driver implements backlight control on Dell laptops which use SMI for changing brightness levels.The driver is INCOMPLETE since it is unable to probe some required parameters in order to perform backlight control. Such parameters are found in a Dell proprietary DMI table which should be parsed. For now external tools may be used to find these parameters by hand. So if you intend to try this out, FIRST write your laptop model parameters correctly inside the source code as explained in
Documentation/dell-laptop.txt.
Quoted 6 lines
Quoted 2 lines
Parts of this driver may also be used to provide additional functionalities similarly to the
drivers/misc/*-laptop.cdrivers.Why is this better done in the kernel rather than in userspace with libsmbios as you've noted?
I had to do a kernelspace driver for controlling the backlight. This was part of a college project assignment. In order for it to be valid for an operating system course, it had to be in kernelspace (not Unix programming) :).
As i mentioned that can be done in userspace and it IS sensible to do so. I know that the code which was already written for Dell implied a userspace approach, but i simply had no choice.
I also don't expect this driver to become mainstream, but since i have written it, other people might want to have a look at it.
Finally i really don't think there's any sensible way of implementing Linux LCD Backlight Abstraction relying on a userspace application. That would mean the kernel calling userspace code to change the brightness, then this latter code would again call the kernel to trigger a SMI and so on. That's just not a good design. I think a userspace solution implies choosing NOT to implement the LCD Abstraction. Causing Dell laptops to be treated differently from other machines (as they are not compliant with Linux's own interface).
jacopo
Quoted 28 lines · On Sun, Oct 28, 2007 at 07:06:23PM +0100, [email protected] wrote:
Quoted 14 lines · Matt Domsch
Quoted 13 lines · On Sun, Oct 28, 2007 at 05:12:37PM +0100, [email protected] wrote:
Hello,
this driver implements backlight control on Dell laptops which use SMI for changing brightness levels.The driver is INCOMPLETE since it is unable to probe some required parameters
in order to perform backlight control. Such parameters are found in a Dell proprietary DMI table which should be parsed. For now external tools may be
used to find these parameters by hand. So if you intend to try this out, FIRST write your laptop model parameters correctly inside the source code as explained inDocumentation/dell-laptop.txt.Quoted 7 lines
Quoted 3 lines
Parts of this driver may also be used to provide additional functionalities
similarly to thedrivers/misc/*-laptop.cdrivers.Why is this better done in the kernel rather than in userspace with libsmbios as you've noted?
I had to do a kernelspace driver for controlling the backlight. This was part of a college project assignment. In order for it to be valid for an operating system course, it had to be in kernelspace (not Unix programming) :).
Quoted 6 lines
As i mentioned that can be done in userspace and it IS sensible to do so. I know that the code which was already written for Dell implied a userspace approach, but i simply had no choice.
I also don't expect this driver to become mainstream, but since i have written it, other people might want to have a look at it.
OK, that's fair.
Quoted 8 lines
Finally i really don't think there's any sensible way of implementing Linux LCD Backlight Abstraction relying on a userspace application. That would mean the kernel calling userspace code to change the brightness, then this latter code would again call the kernel to trigger a SMI and so on. That's just not a good design. I think a userspace solution implies choosing NOT to implement the LCD Abstraction. Causing Dell laptops to be treated differently from other machines (as they are not compliant with Linux's own interface).
I've had this discussion on lkml before. Short story is, until Dell laptops implement the ACPI methods that the backlight API expects, the only sane way to do it is to let libsmbios handle it. Moving the fairly large and complex libsmbios into the kernel isn't a good idea (imho).
Signature · 3 lines
Matt Domsch Linux Technology Strategist, Dell Office of the CTO linux.dell.com & www.dell.com/linux
Fixed style.
jacopo
Documentation/dell-laptop.txt +107 -0
@@ -0,0 +1,107 @@ +This driver is EXPERIMENTAL, use it at YOUR OWN RISK. + +BEFORE TRYING THIS DRIVER OUT: +You MUST FILL IN your laptop parameters in the source code. This +driver is not capable of probing these parameters on its own. + +The parameters involved are: +- IO Port address +- IO command code +- Location + +These parameters depend (hopefully) on the model of your laptop. +Such information is found in a private Dell DMI table. You may +use dmidecode or libsmbios' dumpCmos +(http://linux.dell.com/libsmbios/download/libsmbios/). The +latter is best since it DECODES COMPLETELY Dell's tokens. + +******************************************************* WITH LIBSMBIOS +root@here:~# dumpCmos | grep 0x007d +and you will get a line like the following... +DMI type 0xda Handle 0xda00 CmdIO Port 0x00b2 CmdIO Code 0x0d \ + Type 0x007d Location 0x0000 value 0000 + +open dell-laptop.c and write the parameters accordingly under +the probe_smi_params() function + +static int probe_smi_params(void) +{ + /* + * these should be probed by parsing Dell's CMOS table (type 0xda) + */ + smi_params.cmdio_port = 0x00b2; /* dumpCmos CmdIO Port */ + smi_params.cmdio_code = 0x0d; /* dumpCmos CmdIO Code */ + smi_params.backlight_location = 0; /* dumpCmos Location */ + smi_params.backlight_value = 0; /* dumpCmos Value (unused) */ + + return 0; +} +********************************************************************** + +******************************************************* WITH DMIDECODE +(this is HAND parsing!!) +dmidecode & look for table type 218 + +Handle 0xDA00, DMI type 218, 125 bytes +OEM-specific Type + Header and Data: + DA 7D 00 DA B2 00 0D 5F 0F 37 40 7D 00 00 00 00 + 00 7E 00 02 00 00 00 40 00 04 00 01 00 41 00 04 + 00 00 00 90 00 05 00 00 00 91 00 05 00 01 00 92 + 00 05 00 02 00 45 01 45 01 01 00 44 01 44 01 00 + 00 00 80 00 80 01 00 00 A0 00 A0 01 00 05 80 05 + 80 01 00 76 01 76 01 01 00 75 01 75 01 01 00 01 + F0 01 F0 00 00 02 F0 02 F0 00 00 03 F0 03 F0 00 + 00 04 F0 04 F0 00 00 FF FF 00 00 00 00 + +now you have: +1 byte DA (table type) +1 byte 7D (table size) +2 bytes 00 DA (handle) +2 bytes B2 00 (cmdio port address (swapped) ) +1 byte 0D (cmdio code) +4 bytes 5F 0F 37 40 (supported commands ?) + +after that you have triplets terminated by FF FF 00 00 00 00 +in the form (type, location, value) + +type | loc | val +7D 00|00 00|00 00 +7E 00|02 00|00 00 +40 00|04 00|01 00 +41 00|04 00|00 00 +90 00|05 00|00 00 +91 00|05 00|01 00 +92 00|05 00|02 00 +45 01|45 01|01 00 +44 01|44 01|00 00 +00 80|00 80|01 00 +00 A0|00 A0|01 00 +05 80|05 80|01 00 +76 01|76 01|01 00 +75 01|75 01|01 00 +01 F0|01 F0|00 00 +02 F0|02 F0|00 00 +03 F0|03 F0|00 00 +04 F0|04 F0|00 00 +end +FF FF|00 00|00 00 + +you can read the Location field in type 0x007d (swapped 7D 00) + +then modify dell-laptop.c accordingly (remember to swap the lsb +with the msb in the port address also!) + +static int probe_smi_params(void) +{ + /* + * these should be probed by parsing Dell's CMOS table (type 0xda) + */ + smi_params.cmdio_port = 0x00b2; /* dumpCmos CmdIO Port */ + smi_params.cmdio_code = 0x0d; /* dumpCmos CmdIO Code */ + smi_params.backlight_location = 0; /* dumpCmos Location */ + smi_params.backlight_value = 0; /* dumpCmos Value (unused) */ + + return 0; +} +**********************************************************************
drivers/misc/Makefile +0 -0
@@ -15,3 +15,4 @@ obj-$(CONFIG_SGI_IOC4) += ioc4.o
obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o
obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o
obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o
+obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
drivers/misc/dell-laptop.h +117 -0
117 lines not on this page · raw message
drivers/misc/dell-laptop.c +683 -0
683 lines not on this page · raw message
drivers/misc/Kconfig +0 -0
@@ -130,6 +130,21 @@ config MSI_LAPTOP
If you have an MSI S270 laptop, say Y or M here.
+config DELL_LAPTOP
+ tristate "Dell Laptop Extras (EXPERIMENTAL)"
+ depends on X86
+ depends on EXPERIMENTAL
+ depends on BACKLIGHT_CLASS_DEVICE
+ ---help---
+ This driver implements LCD backlight control for Dell laptops. BEFORE + using this driver, please fill in your laptop model parameters as described + in dell-laptop.txt. Using this driver without doing this operation + may have UNPREDICTABLE effects on your laptop. You have been warned!
+
+ Just read <file:Documentation/dell-laptop.txt> first.
+
+ If you have a Dell laptop, say Y or M here.
+
config SONY_LAPTOP
tristate "Sony Laptop Extras" depends on X86 && ACPI
Quoted 43 lines · Matt Domsch
Quoted 23 lines · On Sun, Oct 28, 2007 at 07:06:23PM +0100, [email protected] wrote:
Quoted 12 lines · Matt Domsch
Quoted 11 lines · On Sun, Oct 28, 2007 at 05:12:37PM +0100, [email protected] wrote:
Hello,
this driver implements backlight control on Dell laptops which use SMI for changing brightness levels.The driver is INCOMPLETE since it is unable to probe some required parameters in order to perform backlight control. Such parameters are found in a Dell proprietary DMI table which should be parsed. For now external tools may be used to find these parameters by hand. So if you intend to try this out, FIRST write your laptop model parameters correctly inside the source code as explained in
Documentation/dell-laptop.txt.Quoted 5 lines
Quoted 2 lines
Parts of this driver may also be used to provide additional functionalities similarly to the
drivers/misc/*-laptop.cdrivers.Why is this better done in the kernel rather than in userspace with libsmbios as you've noted?
I had to do a kernelspace driver for controlling the backlight. This was part of a college project assignment. In order for it to be valid for an operating system course, it had to be in kernelspace (not Unix programming) :).
Quoted 6 lines
As i mentioned that can be done in userspace and it IS sensible to do so. I know that the code which was already written for Dell implied a userspace approach, but i simply had no choice.
I also don't expect this driver to become mainstream, but since i have written it, other people might want to have a look at it.
OK, that's fair.
Quoted 8 lines
Finally i really don't think there's any sensible way of implementing Linux LCD Backlight Abstraction relying on a userspace application. That would mean the kernel calling userspace code to change the brightness, then this latter code would again call the kernel to trigger a SMI and so on. That's just not a good design. I think a userspace solution implies choosing NOT to implement the LCD Abstraction. Causing Dell laptops to be treated differently from other machines (as they are not compliant with Linux's own interface).
Quoted 8 lines
I've had this discussion on lkml before. Short story is, until Dell laptops implement the ACPI methods that the backlight API expects, the only sane way to do it is to let libsmbios handle it. Moving the fairly large and complex libsmbios into the kernel isn't a good idea (imho).
I agree. The problem is that Dell's DMI tables are not defined in the SMBIOS standard. Thus getting the parameters required for the backlight control (io port, io code, location) needs to be dealt with specifically.
Plus DMI is not as comprehensively supported as ACPI is under Linux.
I think reading Dell's tables to find out backlight parameters in kernelspace is possible. Unfortunately it would require a significant amount of brand new code to be written. And i'm not sure it is worth the effort. Libsmbios is big and complex because it is written in proficient C++ with lots of OO abstraction. It is also portable. But the task accomplished is simple in principle.
jacopo
Quoted 5 lines · Matt Domsch
I've had this discussion on lkml before. Short story is, until Dell laptops implement the ACPI methods that the backlight API expects, the only sane way to do it is to let libsmbios handle it. Moving the fairly large and complex libsmbios into the kernel isn't a good idea (imho).
My understanding was that the current range supported the ACPI methods.
Signature · 1 line
Matthew Garrett | [email protected]
Hi!
Quoted 11 lines
Quoted 11 lines
this driver implements backlight control on Dell laptops which use SMI for changing brightness levels.
The driver is INCOMPLETE since it is unable to probe some required parameters
in order to perform backlight control. Such parameters are found in a Dell proprietary DMI table which should be parsed. For now external tools may be used to find these parameters by hand. So if you intend to try this out, FIRST write your laptop model parameters correctly inside the source code as explained inDocumentation/dell-laptop.txt.
Quoted 5 lines
Quoted 2 lines
Parts of this driver may also be used to provide additional functionalities similarly to the
drivers/misc/*-laptop.cdrivers.Why is this better done in the kernel rather than in userspace with libsmbios as you've noted?
Well, keeping the same interface as other notebooks has some advantages... and means that kernel does its job - hw abstraction.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html