Wistron laptop button driver
Subsystems (2)
Miloslav Trmac
maintainerPATCH 1/1 Wistron laptop button driver
Hello,
attached (as a patch against 2.6.13-git6) is a driver for laptop buttons on my Fujitsu-Siemens Amilo Pro V2000; it seems quite a few other laptops use the same interface (with differing sets of buttons).
Thanks,
Mirek
A driver for laptop buttons using an x86 BIOS interface that is apparently used on quite a few laptops and seems to be originating from Wistron.
This driver currently "knows" only about Fujitsu-Siemens Amilo Pro V2000 (i.e. it can detect the laptop using DMI and it contains the keycode->key meaning mapping for this laptop), adding other laptops should be easy.
In addition to reporting button presses to the input layer the driver also allows enabling/disabling the embedded wireless NIC (using the "Wifi" button); this is done using the same BIOS interface, so it seems only logical to keep the implementation together. Any flexibility possibly gained by allowing users to remap the function of the "Wifi" button is IMHO not worth it when weighted against the necessity to run an user-space daemon to convert button presses to wifi state changes.
drivers/input/misc/Kconfig renamed from linux-2.6.13/drivers/input/misc/Kconfig +10 -0
@@ -40,6 +40,16 @@ tristate "M68k Beeper support" depends on M68K +config INPUT_WISTRON_BTNS + tristate "x86 Wistron laptop button interface" + depends on X86 + help + Say Y here for support of Winstron laptop button interface, used on + laptops of various brands, including Acer and Fujitsu-Siemens. + + To compile this driver as a module, choose M here: the module will + be called wistron_btns. + config INPUT_UINPUT tristate "User level driver support" help
drivers/input/misc/Makefile renamed from linux-2.6.13/drivers/input/misc/Makefile +1 -0
@@ -9,4 +9,5 @@ obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o obj-$(CONFIG_INPUT_98SPKR) += 98spkr.o obj-$(CONFIG_INPUT_UINPUT) += uinput.o +obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
drivers/input/misc/wistron_btns.c renamed from linux-2.6.13/drivers/input/misc/wistron_btns.c +385 -0
385 lines not on this page · raw message
MAINTAINERS renamed from linux-2.6.13/MAINTAINERS +5 -0
@@ -2726,6 +2726,11 @@ L: [email protected] S: Maintained +WISTRON LAPTOP BUTTON DRIVER +P: Miloslav Trmac +M: [email protected] +S: Maintained + WL3501 WIRELESS PCMCIA CARD DRIVER P: Arnaldo Carvalho de Melo M: [email protected]
Quoted 13 lines · Miloslav Trmac
+static void
call_bios(struct regs *regs)
+{
+ unsigned long flags;
+
+preempt_disable();
+local_irq_save(flags);
+ asm volatile ("pushl %%ebp;"+ "movl %[data], %%ebp;" + "call *%[routine];" + "popl %%ebp" + : "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx) + : "0" (regs->eax), "1" (regs->ebx), "2" (regs->ecx),
Quoted 7 lines
+ [routine] "m" (
bios_entry_point),
+ [data] "m" (bios_data_map_base)
+ : "edx", "edi", "esi", "memory");
+local_irq_restore(flags);
+preempt_enable();
+}
+
(the preempt_disable/enable isn't needed - local_irq_save() will suffice)
gcc-2.95.x spits the dummy over this [routine] stuff. What compiler does this require?
Is it necessary to open-code the BIOS call in the driver? Does it make sense to have some library function to do this?
Miloslav Trmac
maintainerQuoted 16 lines · Andrew Morton
Quoted 14 lines · Miloslav Trmac
drivers/input/misc/wistron_btns.c renamed from linux-2.6.13/drivers/input/misc/wistron_btns.c +14
-0+static void call_bios (struct regs *regs) +{ +unsigned long flags; + +preempt_disable (); +local_irq_save (flags); + asmvolatile ("pushl %%ebp;" +"movl %[data], %%ebp;" +"call *%[routine];" +"popl %%ebp" + :"=a" (regs->eax),"=b" (regs->ebx),"=c" (regs->ecx) + :"0" (regs->eax),"1" (regs->ebx),"2" (regs->ecx), + [routine]"m" (bios_entry_point), + [data] "m" (bios_data_map_base)
Quoted 8 lines
drivers/input/misc/wistron_btns.c line 77
Quoted 5 lines
drivers/input/misc/wistron_btns.c renamed from linux-2.6.13/drivers/input/misc/wistron_btns.c +5
-0+ : "edx", "edi", "esi", "memory"); +local_irq_restore (flags); +preempt_enable (); +} +gcc-2.95.x spits the dummy over this [routine] stuff. What compiler does this require?
(info gcc) says gcc >= 3.1.
Quoted 2 lines
Is it necessary to open-code the BIOS call in the driver? Does it make sense to have some library function to do this?
A general library function (handling all registers) would have to be written in assembler because gcc has trouble allocating registers otherwise; considering that we should ideally avoid BIOS calls and that such a function wasn't needed in the last 14 years, I don't think it is worth the effort.
Mirek
drivers/input/misc/wistron_btns.c line 87
Quoted 10 lines · Miloslav Trmac
drivers/input/misc/wistron_btns.c renamed from linux-2.6.13/drivers/input/misc/wistron_btns.c +10
-0+static int __init map_bios (void ) +{ +static const unsigned char __initdata signature[] + = {0x42 ,0x21 ,0x55 ,0x30 }; + +void __iomem *base; +size_t offset; +uint32_t entry_point; + + base =ioremap (0xF0000 ,0x10000 );/* Can't fail */
How come? ioremap can return NULL if, for example, we run out of memory.
drivers/input/misc/wistron_btns.c line 92
Quoted 5 lines
drivers/input/misc/wistron_btns.c renamed from linux-2.6.13/drivers/input/misc/wistron_btns.c +5
-0+for (offset =0 ; offset <0x10000 ; offset +=0x10 ) { +if (check_signature (base + offset, signature, +sizeof (signature)) !=0 ) + goto found; + }
Pekka
Miloslav Trmac
maintainerQuoted 14 lines · Pekka Enberg
drivers/input/misc/wistron_btns.c line 87
Quoted 10 lines · Miloslav Trmac
drivers/input/misc/wistron_btns.c renamed from linux-2.6.13/drivers/input/misc/wistron_btns.c +10
-0+static int __init map_bios (void ) +{ +static const unsigned char __initdata signature[] + = {0x42 ,0x21 ,0x55 ,0x30 }; + +void __iomem *base; +size_t offset; +uint32_t entry_point; + + base =ioremap (0xF0000 ,0x10000 );/* Can't fail */ How come? ioremap can return NULL if, for example, we run out of memory.
Not with these values:
Quoted 5 lines
/* * Don't remap the low PCI/ISA area, it's always mapped.. */ if (phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS) return (void __iomem *) phys_to_virt(phys_addr);
Mirek
Miloslav Trmac
maintainerHello,
I'm not quite sure what has happened to the original patch, I hope it is in someone's input tree.
Nevertheless, attached is a patch to add support for Thorsten's hardware.
Thanks,
Mirek
Add buttons for AOpen/Wistron 1557/MS2141, as reported by Thorsten Leemhuis. The hardware has no usable DMI info, so add a module parameter.
drivers/input/misc/wistron_btns.c +41 -8
@@ -44,6 +44,10 @@module_param (force, bool,0 );MODULE_PARM_DESC (force,"Load even if computer is not in database" ); +static char *keymap_name;/* = NULL; */ +module_param_named (keymap, keymap_name, charp,0 ); +MODULE_PARM_DESC (keymap,"Keymap name, if it can't be autodetected" ); +/* BIOS interface implementation */ static void __iomem *bios_entry_point;/* BIOS routine entry point */
@@ -238,6 +242,19 @@ { KE_END, 0 } }; +static struct key_entry keymap_wistron_ms2141[] = { + {KE_KEY ,0x11 ,KEY_PROG1 }, + {KE_KEY ,0x12 ,KEY_PROG2 }, + {KE_WIFI ,0x30 ,0 }, + {KE_KEY ,0x22 ,KEY_REWIND }, + {KE_KEY ,0x23 ,KEY_FORWARD }, + {KE_KEY ,0x24 ,KEY_PLAYPAUSE }, + {KE_KEY ,0x25 ,KEY_STOPCD }, + {KE_KEY ,0x31 ,KEY_MAIL }, + {KE_KEY ,0x36 ,KEY_WWW }, + {KE_END ,0 } +}; +/* If your machine is not here (which is currently rather likely), please send a list of buttons and their key codes (reported when loading this module with force=1) and the output of dmidecode to $MODULE_AUTHOR. */
@@ -254,6 +271,27 @@ { 0, } }; +static int __init select_keymap (void ) +{ +if (keymap_name !=NULL ) { +if (strcmp (keymap_name,"1557/MS2141" ) ==0 ) + keymap = keymap_wistron_ms2141; +else { +printk (KERN_WARNING "wistron_btns: Keymap unknown\n" ); +return -EINVAL ; + } + } +dmi_check_system (dmi_ids); +if (keymap ==NULL ) { +if (force ==0 ) { +printk (KERN_WARNING "wistron_btns: System unknown\n" ); +return -ENODEV ; + } + keymap = keymap_empty; + } +return 0 ; +} +/* Input layer interface */ static struct input_dev input_dev = {
@@ -337,14 +375,9 @@ {int err; -dmi_check_system (dmi_ids); -if (keymap ==NULL ) { -if (force ==0 ) { -printk (KERN_WARNING "wistron_btns: System unknown\n" ); -return -ENODEV ; - } - keymap = keymap_empty; - } + err =select_keymap (); +if (err !=0 ) +return err; err =map_bios ();if (err !=0 )return err;