Make DMI code store chassis type
Subsystems (3)
PATCH 1/1 Make DMI code store chassis type
The previous patch had a typo, so here's a fixed one. This patch stores the chassis type of the hardware, making it easier to determine whether a piece of hardware from a manufacturer is a laptop. This information is not 100% reliable - some vendors insert bogus values, but most of the big ones are fairly accurate.
arch/i386/kernel/dmi_scan.c +54 -1
@@ -30,6 +30,50 @@ static char * __init dmi_string(struct dreturn str; } +static char *__init dmi_chassis_type (struct dmi_header *dm,u8 s) +{ +char *str ="" ; +static const char *type[]={ +"Other" ,/* 0x01 */ +"Unknown" , +"Desktop" , +"Low Profile Desktop" , +"Pizza Box" , +"Mini Tower" , +"Tower" , +"Portable" , +"Laptop" , +"Notebook" , +"Hand Held" , +"Docking Station" , +"All In One" , +"Sub Notebook" , +"Space-saving" , +"Lunch Box" , +"Main Server Chassis" ,/* master.mif says System */ +"Expansion Chassis" , +"Sub Chassis" , +"Bus Expansion Chassis" , +"Peripheral Chassis" , +"RAID Chassis" , +"Rack Mount Chassis" , +"Sealed-case PC" , +"Multi-system" /* 0x19 */ + }; + +if (s>=0x01 && s<=0x19 ) { + str =alloc_bootmem (strlen (type[code-0x01 ])); +if (str !=NULL ) +strcpy (str, type[code-0x01 ]); +else +printk (KERN_ERR "dmi_chassis_type: out of memory.\n" ); + +return str; + } + +return NULL ; +} +/* * We have to be cautious here. We have seen BIOSes with DMI pointers * pointing to completely the wrong place for example
@@ -93,7 +137,11 @@ static void __init dmi_save_ident(structif (dmi_ident[slot])return ; - p =dmi_string (dm, d[string]); +if (slot ==DMI_CHASSIS_TYPE ) + p =dmi_chassis_type (string &0x7f ); +else + p =dmi_string (dm, d[string]); +if (p ==NULL )return ;
@@ -176,6 +224,11 @@ static void __init dmi_decode(struct dmidmi_save_ident (dm,DMI_BOARD_NAME ,5 );dmi_save_ident (dm,DMI_BOARD_VERSION ,6 );break ; +case 3 :/* Chassis Information */ +dmi_save_ident (dm,DMI_CHASSIS_VENDOR ,4 ); +dmi_save_ident (dm,DMI_CHASSIS_TYPE ,5 ); +break ; +case 10 :/* Onboard Devices Information */ dmi_save_devices (dm);break ;
include/linux/dmi.h +2 -0
@@ -15,6 +15,8 @@ enum dmi_field {DMI_BOARD_VENDOR ,DMI_BOARD_NAME ,DMI_BOARD_VERSION , +DMI_CHASSIS_VENDOR , +DMI_CHASSIS_TYPE , DMI_STRING_MAX, };
Signature · 1 line
Matthew Garrett | [email protected]
PATCH 1/1 Add HP laptop backlight brightness display
This patch hooks into the generic backlight framework and allows the brightness of HP 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.
drivers/video/backlight/Kconfig +7 -0
@@ -50,3 +50,10 @@ config BACKLIGHT_CORGI If you have a Sharp Zaurus SL-C7xx, say y to enable the backlight driver. +config BACKLIGHT_HP + tristate "HP Laptop Backlight Driver" + depends on BACKLIGHT_DEVICE && X86 + default n + help + Allows userspace applications to read the current screen brightness + on HP laptops
drivers/video/backlight/Makefile +1 -0
@@ -4,3 +4,4 @@ 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
drivers/video/backlight/hp_bl.c new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
Matthew Garrett | [email protected]
PATCH 1/1 Add Dell laptop backlight brightness display
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.
drivers/video/backlight/Kconfig +7 -0
@@ -50,3 +50,10 @@ config BACKLIGHT_CORGI If you have a Sharp Zaurus SL-C7xx, say y to enable the backlight driver. +config BACKLIGHT_HP + tristate "HP Laptop Backlight Driver" + depends on BACKLIGHT_DEVICE && X86 + default n + help + Allows userspace applications to read the current screen brightness + on HP laptops
drivers/video/backlight/Makefile +1 -0
@@ -4,3 +4,4 @@ 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
drivers/video/backlight/hp_bl.c new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
Matthew Garrett | [email protected]
PATCH RESEND 1/1 Add Dell laptop backlight brightness display
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.
drivers/video/backlight/Kconfig +9 -1
@@ -56,4 +56,12 @@ config BACKLIGHT_HP default n help Allows userspace applications to read the current screen brightness - on HP laptops + 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
drivers/video/backlight/Makefile +2 -1
@@ -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 +obj-$(CONFIG_BACKLIGHT_HP) += hp_bl.o +obj-$(CONFIG_BACKLIGHT_DELL) += dell_bl.o
drivers/video/backlight/dell_bl.c new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH] [RESEND] Add Dell laptop backlight brightness display
drivers/video/backlight/dell_bl.c line 88
Quoted 7 lines · Matthew Garrett
drivers/video/backlight/dell_bl.c new file +7
-0+static void __exit dellbl_exit(void) +{ + backlight_device_unregister(dell_backlight_device); +} + +module_init (hpbl_init); +module_exit (hpbl_exit);
This is not gonna work - dellbl_* vs hpbl_*
Signature · 1 line
Dmitry
Re: [PATCH] [RESEND] Add Dell laptop backlight brightness display
Quoted 1 line · Dmitry Torokhov
This is not gonna work - dellbl_* vs hpbl_*
Good point. Third time's the charm?
Signature · 1 line
Matthew Garrett | [email protected]
drivers/video/backlight/Kconfig +9 -1
@@ -56,4 +56,12 @@ config BACKLIGHT_HP default n help Allows userspace applications to read the current screen brightness - on HP laptops + 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
drivers/video/backlight/Makefile +2 -1
@@ -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 +obj-$(CONFIG_BACKLIGHT_HP) += hp_bl.o +obj-$(CONFIG_BACKLIGHT_DELL) += dell_bl.o
drivers/video/backlight/dell_bl.c new file +92 -0
92 lines not on this page · raw message
Re: [PATCH] [RESEND] Add Dell laptop backlight brightness display
On Tue, 2006-02-07 at 12:32 +0000, Matthew Garrett wrote:
+ /* 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 */
This is total abuse of the backlight class. The idea is that cat /sys/class/backlight/ccc/brightness returns the *current* backlight brightness. On AC power it should return the AC brightness value and on DC power return the DC value.
If you want to know the DC and AC values as stored in the BIOS they should be device specific attributes, not generic class ones.
I have a patch in the pipeline to change the backlight class slightly to provide both the user requested brightness and the current brightness as the two can differ (the Zaurus handhelds limit the backlight intensity on low power).
Richard
Re: [PATCH] [RESEND] Add Dell laptop backlight brightness display
Quoted 4 lines · Richard Purdie
This is total abuse of the backlight class. The idea is that cat
/sys/class/backlight/ccc/brightnessreturns the *current* backlight brightness. On AC power it should return the AC brightness value and on DC power return the DC value.
Unfortunately, the hardware doesn't seem to give us that option. There's no obvious way of determining whether we're on AC or DC from the kernel without doing very nasty things with ACPI and APM (userspace can work it out fairly easily).
Would you be open to adding generic support for displaying separate AC and DC brightnesses? Making it driver specific leaves the potential for inconsistencies.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH] [RESEND] Add Dell laptop backlight brightness display
Quoted 7 lines · Matthew Garrett
Quoted 4 lines · Richard Purdie
This is total abuse of the backlight class. The idea is that cat
/sys/class/backlight/ccc/brightnessreturns the *current* backlight brightness. On AC power it should return the AC brightness value and on DC power return the DC value.
Quoted 8 lines
Unfortunately, the hardware doesn't seem to give us that option. There's no obvious way of determining whether we're on AC or DC from the kernel without doing very nasty things with ACPI and APM (userspace can work it out fairly easily).
Would you be open to adding generic support for displaying separate AC and DC brightnesses? Making it driver specific leaves the potential for inconsistencies.
The problem is that AC or DC is not a generic property of backlights but specific to your problematic hardware case. You're going to have a to find a way to tell if its running on AC or not to report the right value in the manner the class requires.
I can't see how you plan to add "generic support for displaying separate AC and DC brightnesses" without destroying the point of the class (which for the brightness parameter is to display the current backlight brightness).
Richard
Re: [PATCH] [RESEND] Add Dell laptop backlight brightness display
Quoted 9 lines · Richard Purdie
Quoted 3 lines · Matthew Garrett
Would you be open to adding generic support for displaying separate AC and DC brightnesses? Making it driver specific leaves the potential for inconsistencies.
The problem is that AC or DC is not a generic property of backlights but specific to your problematic hardware case. You're going to have a to find a way to tell if its running on AC or not to report the right value in the manner the class requires.
Cases rather than case, sadly. Determining whether the hardware is on AC or not tends to be much more awkward than you'd think. On HPs, it seems to be done by making a specific call to the embedded controller. This is very model specific, whereas the brightness values aren't. It's also likely to go horribly wrong if the hardware is trying to access the embedded controller at the same time. Realistically, it's impossible without making the driver depend on ACPI and exporting acpi_ac_get_state from the ACPI layer, which would be a shame since the rest of the functionality isn't ACPI dependent at all.
Quoted 4 lines
I can't see how you plan to add "generic support for displaying separate AC and DC brightnesses" without destroying the point of the class (which for the brightness parameter is to display the current backlight brightness).
I think providing a consistent interface for what information we can provide is worthwhile.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH] [RESEND] Add Dell laptop backlight brightness display
Quoted 11 lines · Matthew Garrett
Quoted 9 lines · Richard Purdie
Quoted 3 lines · Matthew Garrett
Would you be open to adding generic support for displaying separate AC and DC brightnesses? Making it driver specific leaves the potential for inconsistencies.
The problem is that AC or DC is not a generic property of backlights but specific to your problematic hardware case. You're going to have a to find a way to tell if its running on AC or not to report the right value in the manner the class requires.
Quoted 4 lines
Realistically, it's impossible
without making the driver depend on ACPI and exportingacpi_ac_get_statefrom the ACPI layer, which would be a shame since the rest of the functionality isn't ACPI dependent at all.
If that's what's needed to give the correct behaviour, so be it. In an ideal world, we'd not need the dependency but it sounds unavoidable.
You can actually have a soft dependency where it could use the DC value unless ACPI is present in which case it would be more intelligent. The corgi_bl driver does this for the backlight limiting on low power.
Richard
Re: [PATCH] [RESEND] Add Dell laptop backlight brightness display
In reply to Matthew GarrettHi!
Quoted 11 lines · Matthew Garrett
Quoted 9 lines · Richard Purdie
Quoted 3 lines · Matthew Garrett
Would you be open to adding generic support for displaying separate AC and DC brightnesses? Making it driver specific leaves the potential for inconsistencies.
The problem is that AC or DC is not a generic property of backlights but specific to your problematic hardware case. You're going to have a to find a way to tell if its running on AC or not to report the right value in the manner the class requires.
Quoted 9 lines
Cases rather than case, sadly. Determining whether the hardware is on AC or not tends to be much more awkward than you'd think. On HPs, it seems to be done by making a specific call to the embedded controller. This is very model specific, whereas the brightness values aren't. It's also likely to go horribly wrong if the hardware is trying to access the embedded controller at the same time. Realistically, it's impossible without making the driver depend on ACPI and exporting
acpi_ac_get_statefrom the ACPI layer, which would be a shame since the rest of the functionality isn't ACPI dependent at all.
Depending on acpi does not seem that bad. And exporting acpi_ac_get_state is probably good idea for other reasons, too. (Look how powernow-k8 does it; it needs pretty reliable AC/DC info.)
Pavel
Signature · 1 line
Web maintainer for suspend.sf.net (www.sf.net/projects/suspend) wanted...
Re: [PATCH] Add HP laptop backlight brightness display
In reply to Matthew GarrettQuoted 4 lines · Matthew Garrett
drivers/video/backlight/Kconfig +0
-0
[...]
drivers/video/backlight/Makefile
Quoted 2 lines
\ No newline at end of file
drivers/video/backlight/Makefile +0
-0
Please don't do that, also for all the other files.
MfG, JBG
Signature · 4 lines
Jan-Benedict Glaw [email protected] . +49-172-7608481 _ O _ "Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O für einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));