Driver for reading HP laptop LCD brightness
RFC PATCH 1/1 Driver for reading HP laptop LCD brightness
The attached patch provides a sysfs mechanism for reading the LCD brightness on HP laptops. Since there's no clean way to determine whether a machine is a laptop or not from within the kernel (this information is in the DMI tables, but we don't currently export the chassis field), it does nothing until userspace has enabled it.
Right now, I'm looking for comments on how to integrate it sensibly - leaving it under drivers/misc and registering it as a platform device /works/, but isn't terribly clean.
Patch is against the Ubuntu kernel tree, so the Makefile and Kconfig hunks may need a tiny bit of massaging.
drivers/misc/Kconfig +7 -0
@@ -28,6 +28,13 @@ config IBM_ASM If unsure, say N. +config HPLCD + tristate "Device driver HP LCD brightness" + depends on X86 && EXPERIMENTAL + default n + ---help--- + Provides a sysfs interface to read the screen brightness on HP laptops + config AVERATEC_5100P tristate "Device driver for Averatec 5100P SW Switch" depends on X86 && EXPERIMENTAL
drivers/misc/Makefile +1 -0
@@ -3,6 +3,7 @@ # obj- := misc.o # Dummy rule to force built-in.o to be made +obj-$(CONFIG_HPLCD) += hplcd.o obj-$(CONFIG_IBM_ASM) += ibmasm/ obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/ obj-$(CONFIG_AVERATEC_5100P) += av5100.o
drivers/misc/hplcd.c new file +159 -0
159 lines not on this page · raw message
Signature · 1 line
Matthew Garrett | [email protected]
drivers/misc/hplcd.c line 78
Quoted 11 lines · Matthew Garrett
drivers/misc/hplcd.c new file +11
-0+if (enable==0 ) { +return snprintf (buf,PAGE_SIZE ,"NA\n" ); + } + +disable_irq (8 ); + +outb (0x97 ,0x72 ); + value =inb (0x73 ); + +enable_irq (8 ); +
disable_irq() and enable_irq() are really really evil. Are you sure you need these? To me on first sight it looks like a bug (think of shared interrupts for example), can you explain what you are trying to achieve with these?
Greetings,
Arjan van de Ven
Quoted 4 lines · Arjan van de Ven
disable_irq()andenable_irq()are really really evil. Are you sure you need these? To me on first sight it looks like a bug (think of shared interrupts for example), can you explain what you are trying to achieve with these?
We're talking to the hardware directly. There's a potential race where the BIOS will try to access the cmos at the same time, with potentially interesting results (We set the address we want to read with the outb. The BIOS runs, outbs its own address, and then reads. We then read from the address the BIOS was looking at, rather than what we were looking at).
On all the hardware this will run on, IRQ 8 is the RTC. I don't believe it can share interrupts.
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 7 lines · Matthew Garrett
Quoted 4 lines · Arjan van de Ven
disable_irq()andenable_irq()are really really evil. Are you sure you need these? To me on first sight it looks like a bug (think of shared interrupts for example), can you explain what you are trying to achieve with these?
Quoted 6 lines
We're talking to the hardware directly. There's a potential race where the BIOS will try to access the cmos at the same time, with potentially interesting results (We set the address we want to read with the outb. The BIOS runs, outbs its own address, and then reads. We then read from the address the BIOS was looking at, rather than what we were looking at).
.. and just disabling interrupts isn't going to work? Ok sure there is an SMP issue, but a spinlock ought to be able to fix that properly, instead of something this evil....
Quoted 3 lines · Arjan van de Ven
.. and just disabling interrupts isn't going to work? Ok sure there is an SMP issue, but a spinlock ought to be able to fix that properly, instead of something this evil....
How do we get the BIOS to respect kernel spinlocks? (On the other hand, there ought to be a spinlock there to deal with concurrent access in any case, I guess)
Signature · 1 line
Matthew Garrett | [email protected]
Hi!
Quoted 5 lines
The attached patch provides a sysfs mechanism for reading the LCD brightness on HP laptops. Since there's no clean way to determine whether a machine is a laptop or not from within the kernel (this information is in the DMI tables, but we don't currently export the chassis field), it does nothing until userspace has enabled it.
Can you fix the DMI code to export chasis, then?
Quoted 3 lines
Right now, I'm looking for comments on how to integrate it sensibly - leaving it under
drivers/miscand registering it as a platform device /works/, but isn't terribly clean.
Lots of handhelds ave brightness settings, and it is *very* important there. Perhaps you could use same interface?
Pavel
Signature · 1 line
Thanks, Sharp!