sony-laptop for 2.6.23 (updated)
Subsystems (2)
cover sony-laptop for 2.6.23 (updated)
Hi Len,
These patches a targeted to 2.6.23.
I updated the previous series with a couple more patches one of which fixes a bug present in 2.6.22 and that I'll push to the stable maintainers. Important changes include the scancode enabling work done by Richard Hughes and support for some recent vaio models.
Many thanks
--- drivers/misc/sony-laptop.c | 312 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 252 insertions(+), 60 deletions(-)
Signature · 2 lines
mattia :wq
PATCH 1/7 sony-laptop: add new SNC handlers
- lid state: GLID
- indicator lamp: GILS/SILS
- multimedia bass gain: GMGB/CMGB
--- drivers/misc/sony-laptop.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
drivers/misc/sony-laptop.c +14 -0
@@ -487,6 +487,14 @@ SNC_HANDLE_NAMES(audiopower_set, "AZPW");SNC_HANDLE_NAMES (lanpower_get,"GLNP" );SNC_HANDLE_NAMES (lanpower_set,"LNPW" ); +SNC_HANDLE_NAMES (lidstate_get,"GLID" ); + +SNC_HANDLE_NAMES (indicatorlamp_get,"GILS" ); +SNC_HANDLE_NAMES (indicatorlamp_set,"SILS" ); + +SNC_HANDLE_NAMES (gainbass_get,"GMGB" ); +SNC_HANDLE_NAMES (gainbass_set,"CMGB" ); +SNC_HANDLE_NAMES (PID_get,"GPID" );SNC_HANDLE_NAMES (CTR_get,"GCTR" );
@@ -507,6 +515,12 @@ static struct sony_nc_value sony_nc_values[] = { boolean_validate, 0),SNC_HANDLE (lanpower, snc_lanpower_get, snc_lanpower_set, boolean_validate,1 ), +SNC_HANDLE (lidstate, snc_lidstate_get,NULL , + boolean_validate,0 ), +SNC_HANDLE (indicatorlamp, snc_indicatorlamp_get, snc_indicatorlamp_set, + boolean_validate,0 ), +SNC_HANDLE (gainbass, snc_gainbass_get, snc_gainbass_set, + boolean_validate,0 ),/* unknown methods */ SNC_HANDLE (PID , snc_PID_get,NULL ,NULL ,1 ), SNC_HANDLE(CTR, snc_CTR_get, snc_CTR_set, NULL, 1),
Signature · 1 line
1.5.2.3
PATCH 2/7 sony-laptop: map wireless switch events to KEY_WLAN
--- drivers/misc/sony-laptop.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/misc/sony-laptop.c +2 -0
@@ -177,6 +177,8 @@ static struct { { SONYPI_EVENT_BACK_PRESSED, KEY_BACK }, { SONYPI_EVENT_HELP_PRESSED, KEY_HELP }, { SONYPI_EVENT_ZOOM_PRESSED, KEY_ZOOM }, + { SONYPI_EVENT_WIRELESS_ON, KEY_WLAN }, + { SONYPI_EVENT_WIRELESS_OFF, KEY_WLAN }, { SONYPI_EVENT_THUMBPHRASE_PRESSED, BTN_THUMB }, { 0, 0 }, };
Signature · 1 line
1.5.2.3
PATCH 3/7 Add support for recent Vaios Fn keys (C series for now)
Recent Vaios (C, AR, N, FE) need some special initialization sequence to enable Fn keys interrupts through the Embedded Controller. Moreover Fn keys have to be decoded internally using ACPI methods to get the key code.
Thus a new DMI table to add SNC init time callbacks and new mappings for model-specific key code to generic sony-laptop code have been added.
--- drivers/misc/sony-laptop.c | 107 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 104 insertions(+), 3 deletions(-)
drivers/misc/sony-laptop.c +104 -3
@@ -705,13 +705,107 @@ static struct backlight_ops sony_backlight_ops = { };/* +* New SNC-only Vaios event mapping to driver known keys +*/ +struct sony_nc_event { +u8 data; +u8 event; +}; + +static struct sony_nc_event *sony_nc_events; + +/* Vaio C* --maybe also FE*, N* and AR* ?-- special init sequence +* for Fn keys +*/ +static int sony_nc_C_enable (struct dmi_system_id *id) +{ +int result =0 ; + + printk(KERN_NOTICE DRV_PFX "detected %s\n", id->ident); + + sony_nc_events = id->driver_data; + +if (acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0x4 , &result) <0 + ||acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x2 , &result) <0 + ||acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0x10 , &result) <0 + ||acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x0 , &result) <0 + ||acpi_callsetfunc (sony_nc_acpi_handle,"SN03" ,0x2 , &result) <0 + ||acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x101 , &result) <0 ) { + printk(KERN_WARNING DRV_PFX "failed to initialize SNC, some " + "functionalities may be missing\n"); +return 1 ; + } +return 0 ; +} + +static struct sony_nc_event sony_C_events[] = { + {0x81 ,SONYPI_EVENT_FNKEY_F1 }, + {0x01 ,SONYPI_EVENT_FNKEY_RELEASED }, + {0x85 ,SONYPI_EVENT_FNKEY_F5 }, + {0x05 ,SONYPI_EVENT_FNKEY_RELEASED }, + {0x86 ,SONYPI_EVENT_FNKEY_F6 }, + {0x06 ,SONYPI_EVENT_FNKEY_RELEASED }, + {0x87 ,SONYPI_EVENT_FNKEY_F7 }, + {0x07 ,SONYPI_EVENT_FNKEY_RELEASED }, + {0x8A ,SONYPI_EVENT_FNKEY_F10 }, + {0x0A ,SONYPI_EVENT_FNKEY_RELEASED }, + {0x8C ,SONYPI_EVENT_FNKEY_F12 }, + {0x0C ,SONYPI_EVENT_FNKEY_RELEASED }, + {0 ,0 }, +}; + +/* SNC-only model map */ +struct dmi_system_id sony_nc_ids[] = { + { + .ident ="Sony Vaio C Series" , + .callback = sony_nc_C_enable, + .driver_data = sony_C_events, + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Sony Corporation" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"VGN-C" ), + }, + }, + { } +}; + +/* * ACPI callbacks */ static void sony_acpi_notify (acpi_handle handle,u32 event,void *data) { -dprintk ("sony_acpi_notify, event: %d\n" , event); -sony_laptop_report_input_event (event); -acpi_bus_generate_event (sony_nc_acpi_device,1 , event); +struct sony_nc_event *evmap; +u32 ev = event; +int result; + +if (ev ==0x92 ) { +/* read the key pressed from EC.GECR +* A call to SN07 with 0x0202 will do it as well respecting +* the current protocol on different OSes +* +* Note: the path for GECR may be +* \_SB.PCI0.LPCB.EC (C, FE, AR, N and friends) +* \_SB.PCI0.PIB.EC0 (VGN-FR notifications are sent directly, no GECR) +* +* TODO: we may want to do the same for the older GHKE -need +* dmi list- so this snippet may become one more callback. +*/ +if (acpi_callsetfunc (handle,"SN07" ,0x0202 , &result) <0 ) +dprintk ("sony_acpi_notify, unable to decode event 0x%.2x\n" , ev); +else + ev = result &0xFF ; + } + +if (sony_nc_events) +for (evmap = sony_nc_events; evmap->event; evmap++) { +if (evmap->data == ev) { + ev = evmap->event; +break ; + } + } + +dprintk ("sony_acpi_notify, event: 0x%.2x\n" , ev); +sony_laptop_report_input_event (ev); +acpi_bus_generate_event (sony_nc_acpi_device,1 , ev); } static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
@@ -748,6 +842,10 @@ static int sony_nc_resume(struct acpi_device *device)break ; } } + +/* re-initialize models with specific requirements */ +dmi_check_system (sony_nc_ids); +return 0 ; }
@@ -811,6 +909,9 @@ static int sony_nc_add(struct acpi_device *device) } +/* initialize models with specific requirements */ +dmi_check_system (sony_nc_ids); + result =sony_pf_add ();if (result) goto outbacklight;
Signature · 1 line
1.5.2.3
PATCH 4/7 Invoke _INI for SNC devices that provide it
--- drivers/misc/sony-laptop.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-)
drivers/misc/sony-laptop.c +19 -1
@@ -864,6 +864,15 @@ static int sony_nc_add(struct acpi_device *device) sony_nc_acpi_handle = device->handle; +/* read device status */ + result =acpi_bus_get_status (device); +/* bail IFF the above call was successful and the device is not present */ +if (!result && !device->status.present) { +dprintk ("Device not present\n" ); + result = -ENODEV ; + goto outwalk; + } +if (debug) { status =acpi_walk_namespace (ACPI_TYPE_METHOD , sony_nc_acpi_handle,1 , sony_walk_callback,NULL ,NULL );
@@ -874,6 +883,15 @@ static int sony_nc_add(struct acpi_device *device) } } +/* try to _INI the device if such method exists (ACPI spec 3.0-6.5.1 +* should be respected as we already checked for the device presence above */ +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,METHOD_NAME__INI , &handle))) { +dprintk ("Invoking _INI\n" ); +if (ACPI_FAILURE (acpi_evaluate_object (sony_nc_acpi_handle,METHOD_NAME__INI , +NULL ,NULL ))) +dprintk ("_INI Method failed\n" ); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input ();if (result) {
@@ -886,7 +904,7 @@ static int sony_nc_add(struct acpi_device *device)ACPI_DEVICE_NOTIFY , sony_acpi_notify, NULL);if (ACPI_FAILURE (status)) { - printk(KERN_WARNING DRV_PFX "unable to install notify handler\n"); + printk(KERN_WARNING DRV_PFX "unable to install notify handler (%u)\n", status); result = -ENODEV ; goto outinput; }
Signature · 1 line
1.5.2.3
PATCH 5/7 Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
From: Richard Hughes <[email protected]>
--- drivers/misc/sony-laptop.c | 134 +++++++++++++++++++++++++++---------------- 1 files changed, 84 insertions(+), 50 deletions(-)
drivers/misc/sony-laptop.c +84 -50
@@ -143,44 +143,69 @@ struct sony_laptop_keypress { };/* Correspondance table between sonypi events and input layer events */ -static struct { -int sonypiev; -int inputev; -} sony_laptop_inputkeys[] = { - {SONYPI_EVENT_CAPTURE_PRESSED ,KEY_CAMERA }, - {SONYPI_EVENT_FNKEY_ONLY ,KEY_FN }, - {SONYPI_EVENT_FNKEY_ESC ,KEY_FN_ESC }, - {SONYPI_EVENT_FNKEY_F1 ,KEY_FN_F1 }, - {SONYPI_EVENT_FNKEY_F2 ,KEY_FN_F2 }, - {SONYPI_EVENT_FNKEY_F3 ,KEY_FN_F3 }, - {SONYPI_EVENT_FNKEY_F4 ,KEY_FN_F4 }, - {SONYPI_EVENT_FNKEY_F5 ,KEY_FN_F5 }, - {SONYPI_EVENT_FNKEY_F6 ,KEY_FN_F6 }, - {SONYPI_EVENT_FNKEY_F7 ,KEY_FN_F7 }, - {SONYPI_EVENT_FNKEY_F8 ,KEY_FN_F8 }, - {SONYPI_EVENT_FNKEY_F9 ,KEY_FN_F9 }, - {SONYPI_EVENT_FNKEY_F10 ,KEY_FN_F10 }, - {SONYPI_EVENT_FNKEY_F11 ,KEY_FN_F11 }, - {SONYPI_EVENT_FNKEY_F12 ,KEY_FN_F12 }, - {SONYPI_EVENT_FNKEY_1 ,KEY_FN_1 }, - {SONYPI_EVENT_FNKEY_2 ,KEY_FN_2 }, - {SONYPI_EVENT_FNKEY_D ,KEY_FN_D }, - {SONYPI_EVENT_FNKEY_E ,KEY_FN_E }, - {SONYPI_EVENT_FNKEY_F ,KEY_FN_F }, - {SONYPI_EVENT_FNKEY_S ,KEY_FN_S }, - {SONYPI_EVENT_FNKEY_B ,KEY_FN_B }, - {SONYPI_EVENT_BLUETOOTH_PRESSED ,KEY_BLUE }, - {SONYPI_EVENT_BLUETOOTH_ON ,KEY_BLUE }, - {SONYPI_EVENT_PKEY_P1 ,KEY_PROG1 }, - {SONYPI_EVENT_PKEY_P2 ,KEY_PROG2 }, - {SONYPI_EVENT_PKEY_P3 ,KEY_PROG3 }, - {SONYPI_EVENT_BACK_PRESSED ,KEY_BACK }, - {SONYPI_EVENT_HELP_PRESSED ,KEY_HELP }, - {SONYPI_EVENT_ZOOM_PRESSED ,KEY_ZOOM }, - {SONYPI_EVENT_WIRELESS_ON ,KEY_WLAN }, - {SONYPI_EVENT_WIRELESS_OFF ,KEY_WLAN }, - {SONYPI_EVENT_THUMBPHRASE_PRESSED ,BTN_THUMB }, - {0 ,0 }, +static int sony_laptop_input_keycode_map[] = { +KEY_RESERVED ,/* no event... */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_DOWN */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_UP */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_UP_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_RELEASED */ +KEY_CAMERA ,/* SONYPI_EVENT_CAPTURE_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_CAPTURE_RELEASED */ +KEY_RESERVED ,/* SONYPI_EVENT_CAPTURE_PARTIALPRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_CAPTURE_PARTIALRELEASED */ +KEY_FN_ESC ,/* SONYPI_EVENT_FNKEY_ESC */ +KEY_FN_F1 ,/* SONYPI_EVENT_FNKEY_F1 */ +KEY_FN_F2 ,/* SONYPI_EVENT_FNKEY_F2 */ +KEY_FN_F3 ,/* SONYPI_EVENT_FNKEY_F3 */ +KEY_FN_F4 ,/* SONYPI_EVENT_FNKEY_F4 */ +KEY_FN_F5 ,/* SONYPI_EVENT_FNKEY_F5 */ +KEY_FN_F6 ,/* SONYPI_EVENT_FNKEY_F6 */ +KEY_FN_F7 ,/* SONYPI_EVENT_FNKEY_F7 */ +KEY_FN_F8 ,/* SONYPI_EVENT_FNKEY_F8 */ +KEY_FN_F9 ,/* SONYPI_EVENT_FNKEY_F9 */ +KEY_FN_F10 ,/* SONYPI_EVENT_FNKEY_F10 */ +KEY_FN_F11 ,/* SONYPI_EVENT_FNKEY_F11 */ +KEY_FN_F12 ,/* SONYPI_EVENT_FNKEY_F12 */ +KEY_FN_F1 ,/* SONYPI_EVENT_FNKEY_1 */ +KEY_FN_F2 ,/* SONYPI_EVENT_FNKEY_2 */ +KEY_FN_D ,/* SONYPI_EVENT_FNKEY_D */ +KEY_FN_E ,/* SONYPI_EVENT_FNKEY_E */ +KEY_FN_F ,/* SONYPI_EVENT_FNKEY_F */ +KEY_FN_S ,/* SONYPI_EVENT_FNKEY_S */ +KEY_FN_B ,/* SONYPI_EVENT_FNKEY_B */ +KEY_BLUE ,/* SONYPI_EVENT_BLUETOOTH_PRESSED */ +KEY_PROG1 ,/* SONYPI_EVENT_PKEY_P1 */ +KEY_PROG2 ,/* SONYPI_EVENT_PKEY_P2 */ +KEY_PROG3 ,/* SONYPI_EVENT_PKEY_P3 */ +KEY_BACK ,/* SONYPI_EVENT_BACK_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_LID_CLOSED */ +KEY_RESERVED ,/* SONYPI_EVENT_LID_OPENED */ +KEY_BLUE ,/* SONYPI_EVENT_BLUETOOTH_ON */ +KEY_BLUE ,/* SONYPI_EVENT_BLUETOOTH_OFF */ +KEY_HELP ,/* SONYPI_EVENT_HELP_PRESSED */ +KEY_FN ,/* SONYPI_EVENT_FNKEY_ONLY */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_FAST_DOWN */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_FAST_UP */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_VFAST_DOWN */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_VFAST_UP */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */ +KEY_ZOOM ,/* SONYPI_EVENT_ZOOM_PRESSED */ +BTN_THUMB ,/* SONYPI_EVENT_THUMBPHRASE_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_MEYE_FACE */ +KEY_RESERVED ,/* SONYPI_EVENT_MEYE_OPPOSITE */ +KEY_RESERVED ,/* SONYPI_EVENT_MEMORYSTICK_INSERT */ +KEY_RESERVED ,/* SONYPI_EVENT_MEMORYSTICK_EJECT */ +KEY_RESERVED ,/* SONYPI_EVENT_ANYBUTTON_RELEASED */ +KEY_RESERVED ,/* SONYPI_EVENT_BATTERY_INSERT */ +KEY_RESERVED ,/* SONYPI_EVENT_BATTERY_REMOVE */ +KEY_RESERVED ,/* SONYPI_EVENT_FNKEY_RELEASED */ +KEY_WLAN ,/* SONYPI_EVENT_WIRELESS_ON */ +KEY_WLAN ,/* SONYPI_EVENT_WIRELESS_OFF */ };/* release buttons after a short delay if pressed */
@@ -204,7 +229,6 @@ static void sony_laptop_report_input_event(u8 event)struct input_dev *jog_dev = sony_laptop_input.jog_dev;struct input_dev *key_dev = sony_laptop_input.key_dev;struct sony_laptop_keypress kp = {NULL }; -int i;if (event ==SONYPI_EVENT_FNKEY_RELEASED ) {/* Nothing, not all VAIOs generate this event */
@@ -233,17 +257,20 @@ static void sony_laptop_report_input_event(u8 event)break ;default : -for (i =0 ; sony_laptop_inputkeys[i].sonypiev; i++) -if (event == sony_laptop_inputkeys[i].sonypiev) { - kp.dev = key_dev; - kp.key = sony_laptop_inputkeys[i].inputev; -break ; - } +if (event >ARRAY_SIZE (sony_laptop_input_keycode_map)) { +dprintk ("sony_laptop_report_input_event, event not known: %d\n" , event); +break ; + } + kp.key = sony_laptop_input_keycode_map[event]; +if (kp.key !=KEY_UNKNOWN ) + kp.dev = key_dev;break ; }if (kp.dev) {input_report_key (kp.dev, kp.key,1 ); +/* we emit the scancode so we can always remap the key */ +input_event (kp.dev,EV_MSC ,MSC_SCAN , event);input_sync (kp.dev);kfifo_put (sony_laptop_input.fifo, (unsigned char *)&kp,sizeof (kp));
@@ -298,11 +325,18 @@ static int sony_laptop_setup_input(void) key_dev->id.vendor =PCI_VENDOR_ID_SONY ;/* Initialize the Input Drivers: special keys */ - key_dev->evbit[0 ] =BIT (EV_KEY ); -for (i =0 ; sony_laptop_inputkeys[i].sonypiev; i++) -if (sony_laptop_inputkeys[i].inputev) -set_bit (sony_laptop_inputkeys[i].inputev, - key_dev->keybit); +set_bit (EV_KEY , key_dev->evbit); +set_bit (EV_MSC , key_dev->evbit); +set_bit (MSC_SCAN , key_dev->mscbit); + key_dev->keycodesize =sizeof (sony_laptop_input_keycode_map[0 ]); + key_dev->keycodemax =ARRAY_SIZE (sony_laptop_input_keycode_map); + key_dev->keycode = &sony_laptop_input_keycode_map; +for (i =0 ; i <ARRAY_SIZE (sony_laptop_input_keycode_map); i++) { +if (sony_laptop_input_keycode_map[i] !=KEY_RESERVED ) { +set_bit (sony_laptop_input_keycode_map[i], + key_dev->keybit); + } + } error =input_register_device (key_dev);if (error)
Signature · 1 line
1.5.2.3
PATCH 6/7 Add Vaio FE to the special init sequence
The Vaio FE series uses the same sequence as Vaio C series
--- drivers/misc/sony-laptop.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/misc/sony-laptop.c +9 -0
@@ -791,6 +791,15 @@ static struct sony_nc_event sony_C_events[] = {/* SNC-only model map */ struct dmi_system_id sony_nc_ids[] = { { + .ident ="Sony Vaio FE Series" , + .callback = sony_nc_C_enable, + .driver_data = sony_C_events, + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Sony Corporation" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"VGN-FE" ), + }, + }, + { .ident ="Sony Vaio C Series" , .callback = sony_nc_C_enable, .driver_data = sony_C_events,
Signature · 1 line
1.5.2.3
PATCH 7/7 Fix event reading in sony-laptop
The rewritten event reading code from sonypi was absolutely wrong, this patche makes things functional for type2 and type1 models.
--- drivers/misc/sony-laptop.c | 30 ++++++++++++++++++++++-------- 1 files changed, 22 insertions(+), 8 deletions(-)
drivers/misc/sony-laptop.c +22 -8
@@ -1086,7 +1086,9 @@ static struct acpi_driver sony_nc_driver = {#define SONYPI_DEVICE_TYPE2 0x00000002#define SONYPI_DEVICE_TYPE3 0x00000004 -#define SONY_PIC_EV_MASK 0xff +#define SONYPI_TYPE1_OFFSET 0x04 +#define SONYPI_TYPE2_OFFSET 0x12 +#define SONYPI_TYPE3_OFFSET 0x12struct sony_pic_ioport {struct acpi_resource_io io;
@@ -1100,6 +1102,7 @@ struct sony_pic_irq {struct sony_pic_dev {int model; +u16 evport_offset;u8 camera_power;u8 bluetooth_power;u8 wwan_power;
@@ -2176,20 +2179,17 @@ end:static irqreturn_t sony_pic_irq (int irq,void *dev_id) {int i, j; -u32 port_val =0 ;u8 ev =0 ;u8 data_mask =0 ;u8 device_event =0 ;struct sony_pic_dev *dev = (struct sony_pic_dev *) dev_id; -acpi_os_read_port (dev->cur_ioport->io.minimum, &port_val, - dev->cur_ioport->io.address_length); - ev = port_val &SONY_PIC_EV_MASK ; - data_mask =0xff & (port_val >> (dev->cur_ioport->io.address_length -8 )); + ev =inb_p (dev->cur_ioport->io.minimum); + data_mask =inb_p (dev->cur_ioport->io.minimum + dev->evport_offset); -dprintk ("event (0x%.8x [%.2x] [%.2x]) at port 0x%.4x\n" , - port_val, ev, data_mask, dev->cur_ioport->io.minimum); +dprintk ("event ([%.2x] [%.2x]) at port 0x%.4x(+0x%.2x)\n" , + ev, data_mask, dev->cur_ioport->io.minimum, dev->evport_offset);if (ev ==0x00 || ev ==0xff )return IRQ_HANDLED ;
@@ -2280,6 +2280,20 @@ static int sony_pic_add(struct acpi_device *device) spic_dev.model =sony_pic_detect_device_type ();mutex_init (&spic_dev.lock); +/* model specific characteristics */ +switch (spic_dev.model) { +case SONYPI_DEVICE_TYPE1 : + spic_dev.evport_offset =SONYPI_TYPE1_OFFSET ; +break ; +case SONYPI_DEVICE_TYPE3 : + spic_dev.evport_offset =SONYPI_TYPE3_OFFSET ; +break ; +case SONYPI_DEVICE_TYPE2 : +default : + spic_dev.evport_offset =SONYPI_TYPE2_OFFSET ; +break ; + } +/* read _PRS resources */ result =sony_pic_possible_resources (device);if (result) {
Signature · 1 line
1.5.2.3
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
In reply to Mattia Dongilidrivers/misc/sony-laptop.c static void sony_laptop_report_input_event(u8 event) · line 273
Quoted 2 lines · Mattia Dongili
drivers/misc/sony-laptop.c +2
-0+/* we emit the scancode so we can always remap the key */ +input_event (kp.dev,EV_MSC ,MSC_SCAN , event);
As I said to Henrique, I don't think this is the right solution. We know what these keys do - we should send the appropriate keycode, rather than asking userspace to remap it.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 7 lines · Matthew Garrett
drivers/misc/sony-laptop.c static void sony_laptop_report_input_event(u8 event) · line 273
Quoted 2 lines · Mattia Dongili
drivers/misc/sony-laptop.c +2
-0+/* we emit the scancode so we can always remap the key */ +input_event (kp.dev,EV_MSC ,MSC_SCAN , event);As I said to Henrique, I don't think this is the right solution. We know what these keys do - we should send the appropriate keycode, rather than asking userspace to remap it.
We don't - the decal on FnF2 changes between different models, and I'm sure others are the same.
Richard.
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 11 lines · Richard Hughes
Quoted 7 lines · Matthew Garrett
drivers/misc/sony-laptop.c static void sony_laptop_report_input_event(u8 event) · line 273
Quoted 2 lines · Mattia Dongili
drivers/misc/sony-laptop.c +2
-0+/* we emit the scancode so we can always remap the key */ +input_event (kp.dev,EV_MSC ,MSC_SCAN , event);As I said to Henrique, I don't think this is the right solution. We know what these keys do - we should send the appropriate keycode, rather than asking userspace to remap it.
We don't - the decal on FnF2 changes between different models, and I'm sure others are the same.
That's fine, we have information that lets us distinguish between models.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 3 lines · Matthew Garrett
That's fine, we have information that lets us distinguish between models.
Yes, but the consensus I seemed to get from previous mails was that the matching quirks should be done in userspace where possible. The current FDI thing lets a user edit a simple text xml file and stuff just works. I'm not sure asking user to compile custom kernel modules to test out new keymaps is feasible, at least for the majority of linux users.
Richard.
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 10 lines · Richard Hughes
Quoted 3 lines · Matthew Garrett
That's fine, we have information that lets us distinguish between models.
Yes, but the consensus I seemed to get from previous mails was that the matching quirks should be done in userspace where possible. The current FDI thing lets a user edit a simple text xml file and stuff just works. I'm not sure asking user to compile custom kernel modules to test out new keymaps is feasible, at least for the majority of linux users.
That doesn't match what the kernel currently does. It's still possible to send the custom scancode (unless I'm entirely misreading this) and remap if the user genuinely does have a weird keymap, so all you're doing is moving small tables from one part of disk to the other - they'll be flagged __initdata, so there's no runtime overhead. On the other hand, you get the advantage that the keys just work.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
In reply to Richard HughesQuoted 4 lines · Richard Hughes
Quoted 3 lines · Matthew Garrett
That's fine, we have information that lets us distinguish between models.
Well, I don't think we have all, at least I don't and anyway it's nice to have some way to add new models that doesn't require waiting for a new kernel to be available.
Quoted 5 lines
Yes, but the consensus I seemed to get from previous mails was that the matching quirks should be done in userspace where possible. The current FDI thing lets a user edit a simple text xml file and stuff just works. I'm not sure asking user to compile custom kernel modules to test out new keymaps is feasible, at least for the majority of linux users.
Yep, I agree.
Signature · 2 lines
mattia :wq!
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 9 lines · Mattia Dongili
Quoted 4 lines · Richard Hughes
Quoted 3 lines · Matthew Garrett
That's fine, we have information that lets us distinguish between models.
Well, I don't think we have all, at least I don't and anyway it's nice to have some way to add new models that doesn't require waiting for a new kernel to be available.
They can still be overridden in exactly the same way - it's just a question of sending useful defaults on most machines. If a user finds that the defaults don't work they can still be remapped via hal, but the aim should be for that to be unnecessary where possible.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 7 lines · Matthew Garrett
Quoted 6 lines · Mattia Dongili
Quoted 4 lines · Richard Hughes
Quoted 3 lines · Matthew Garrett
That's fine, we have information that lets us distinguish between models.
Quoted 9 lines
Quoted 3 lines
Well, I don't think we have all, at least I don't and anyway it's nice to have some way to add new models that doesn't require waiting for a new kernel to be available.
They can still be overridden in exactly the same way - it's just a question of sending useful defaults on most machines. If a user finds that the defaults don't work they can still be remapped via hal, but the aim should be for that to be unnecessary where possible.
I guess it all depends on how well HAL updates will be integrated with distributions and whether users update kernels more often than the rest of the system. For example I am still using FC 3 (I was going to upgrade to 7 but I guess it won't happen until 8 is released ;) ) so for me kernel is better ;)
I think we should continue adding keymaps to kernel until everyone is using HAL's facilities to load keymaps and then stop. Does this make sense?
Signature · 1 line
Dmitry
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 4 lines · Dmitry Torokhov
I think we should continue adding keymaps to kernel until everyone is using HAL's facilities to load keymaps and then stop. Does this make sense?
I don't think so. The whole idea of hal-info is that we can update a 14k noarch package every week if needed, that will work on pretty much any hal version.
I'm not sure people running FC3 systems are going to be running git kernels for new keymaps.
Richard.
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 6 lines · Richard Hughes
Quoted 4 lines · Dmitry Torokhov
I think we should continue adding keymaps to kernel until everyone is using HAL's facilities to load keymaps and then stop. Does this make sense?
Quoted 7 lines
I don't think so. The whole idea of hal-info is that we can update a 14k noarch package every week if needed, that will work on pretty much any hal version.
I'm not sure people running FC3 systems are going to be running git kernels for new keymaps.
What distributions cirrently use the new HAL facilities? I am not saying that we want support FC3 but what about FC6, FC7? Ubuntu, Debian?
Signature · 1 line
Dmitry
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 3 lines · Dmitry Torokhov
What distributions cirrently use the new HAL facilities? I am not saying that we want support FC3 but what about FC6, FC7? Ubuntu, Debian?
Currently Fedora and RHEL 5.1 but I believe ubuntu has plans for gutsy. Basically if you use a new HAL (>=0.5.9), you have to use hal-info. Distro's will have to comply :-)
Richard.
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
In reply to Richard HughesQuoted 6 lines · Richard Hughes
Quoted 4 lines · Dmitry Torokhov
I think we should continue adding keymaps to kernel until everyone is using HAL's facilities to load keymaps and then stop. Does this make sense?
Quoted 6 lines
I don't think so. The whole idea of hal-info is that we can update a 14k noarch package every week if needed, that will work on pretty much any hal version.
I'm not sure people running FC3 systems are going to be running git kernels for new keymaps.
This isn't an either/or situation. If you have a hal keymap then the system will still work. The question is what to do in the absence of hal. The kernel can either provide sane defaults (that might be wrong in a couple of cases) or it can provide keys that are pretty much guaranteed to do nothing. I think doing our best to make things work even if hal isn't there is sensible - if hal /is/ there, we've lost nothing.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 14 lines · Matthew Garrett
Quoted 6 lines · Richard Hughes
Quoted 4 lines · Dmitry Torokhov
I think we should continue adding keymaps to kernel until everyone is using HAL's facilities to load keymaps and then stop. Does this make sense?
Quoted 6 lines
I don't think so. The whole idea of hal-info is that we can update a 14k noarch package every week if needed, that will work on pretty much any hal version.
I'm not sure people running FC3 systems are going to be running git kernels for new keymaps.
Quoted 8 lines
This isn't an either/or situation. If you have a hal keymap then the system will still work. The question is what to do in the absence of hal. The kernel can either provide sane defaults (that might be wrong in a couple of cases) or it can provide keys that are pretty much guaranteed to do nothing. I think doing our best to make things work even if hal isn't there is sensible - if hal /is/ there, we've lost nothing.
There is burden in maintaining the same data in 2 different places (kernel/HAL). I think pretty soon everyone will be using never HAL (like everyone uses udev) and we can stop adding keymaps into kernel. But for now if we want to support not so outdated distributions we can add keymaps to the kernel drivers.
Signature · 1 line
Dmitry
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
In reply to Matthew GarrettQuoted 7 lines · Matthew Garrett
This isn't an either/or situation. If you have a hal keymap then the system will still work. The question is what to do in the absence of hal. The kernel can either provide sane defaults (that might be wrong in a couple of cases) or it can provide keys that are pretty much guaranteed to do nothing. I think doing our best to make things work even if hal isn't there is sensible - if hal /is/ there, we've lost nothing.
The only reason we set the keys to KEY_UNKNOWN is so we still emit acpi events (and not change the interface) if we are using an old HAL to not break stuff like acpid and tpd.
We could just do:
* emit acpi event _and_ input event if we probably know the button
* just emit input events (for known keys) and just don't emit any acpi events at all
Richard.
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 9 lines · Richard Hughes
Quoted 7 lines · Matthew Garrett
This isn't an either/or situation. If you have a hal keymap then the system will still work. The question is what to do in the absence of hal. The kernel can either provide sane defaults (that might be wrong in a couple of cases) or it can provide keys that are pretty much guaranteed to do nothing. I think doing our best to make things work even if hal isn't there is sensible - if hal /is/ there, we've lost nothing.
Quoted 3 lines
The only reason we set the keys to
KEY_UNKNOWNis so we still emit acpi events (and not change the interface) if we are using an old HAL to not break stuff like acpid and tpd.
I was thinking more of the ones that are just flagged as KEY_FN_F1 at the moment.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
In reply to Matthew GarrettQuoted 7 lines · Matthew Garrett
Quoted 6 lines · Mattia Dongili
Quoted 4 lines · Richard Hughes
Quoted 3 lines · Matthew Garrett
That's fine, we have information that lets us distinguish between models.
Quoted 8 lines
Quoted 3 lines
Well, I don't think we have all, at least I don't and anyway it's nice to have some way to add new models that doesn't require waiting for a new kernel to be available.
They can still be overridden in exactly the same way - it's just a question of sending useful defaults on most machines. If a user finds that the defaults don't work they can still be remapped via hal, but the aim should be for that to be unnecessary where possible.
BTW, isn't backward compatibility an issue here? How do input devices deal with changes in keycodes they send?
Signature · 2 lines
mattia :wq!
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
In reply to Mattia DongiliHi Mattia,
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 153
Quoted 8 lines · Mattia Dongili
drivers/misc/sony-laptop.c +8
-0+static int sony_laptop_input_keycode_map[] = { +KEY_RESERVED ,/* no event... */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_DOWN */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_UP */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_UP_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_RELEASED */
Jogdial events are never passed through key_dev, do they? If so then we should not allow remapping them as it is pointless. EVCSKEYCODE shoudl return -EINVAL wehn trying to remap them.
Quoted 15 lines
drivers/misc/sony-laptop.c +15
-0+KEY_CAMERA ,/* SONYPI_EVENT_CAPTURE_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_CAPTURE_RELEASED */ +KEY_RESERVED ,/* SONYPI_EVENT_CAPTURE_PARTIALPRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_CAPTURE_PARTIALRELEASED */ +KEY_FN_ESC ,/* SONYPI_EVENT_FNKEY_ESC */ +KEY_FN_F1 ,/* SONYPI_EVENT_FNKEY_F1 */ +KEY_FN_F2 ,/* SONYPI_EVENT_FNKEY_F2 */ +KEY_FN_F3 ,/* SONYPI_EVENT_FNKEY_F3 */ +KEY_FN_F4 ,/* SONYPI_EVENT_FNKEY_F4 */ +KEY_FN_F5 ,/* SONYPI_EVENT_FNKEY_F5 */ +KEY_FN_F6 ,/* SONYPI_EVENT_FNKEY_F6 */ +KEY_FN_F7 ,/* SONYPI_EVENT_FNKEY_F7 */ +KEY_FN_F8 ,/* SONYPI_EVENT_FNKEY_F8 */ +KEY_FN_F9 ,/* SONYPI_EVENT_FNKEY_F9 */ + KEY_FN_F10, /* SONYPI_EVENT_FNKEY_F10 */
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 178
Quoted 10 lines
drivers/misc/sony-laptop.c +10
-0+KEY_FN_F11 ,/* SONYPI_EVENT_FNKEY_F11 */ +KEY_FN_F12 ,/* SONYPI_EVENT_FNKEY_F12 */ +KEY_FN_F1 ,/* SONYPI_EVENT_FNKEY_1 */ +KEY_FN_F2 ,/* SONYPI_EVENT_FNKEY_2 */ +KEY_FN_D ,/* SONYPI_EVENT_FNKEY_D */ +KEY_FN_E ,/* SONYPI_EVENT_FNKEY_E */ +KEY_FN_F ,/* SONYPI_EVENT_FNKEY_F */ +KEY_FN_S ,/* SONYPI_EVENT_FNKEY_S */ +KEY_FN_B ,/* SONYPI_EVENT_FNKEY_B */ + KEY_BLUE, /* SONYPI_EVENT_BLUETOOTH_PRESSED */
KEY_BLUE is a blue-colored key on some Remote Controls. You want KEY_BLUETOOTH here.
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 184
Quoted 6 lines
drivers/misc/sony-laptop.c +6
-0+KEY_PROG1 ,/* SONYPI_EVENT_PKEY_P1 */ +KEY_PROG2 ,/* SONYPI_EVENT_PKEY_P2 */ +KEY_PROG3 ,/* SONYPI_EVENT_PKEY_P3 */ +KEY_BACK ,/* SONYPI_EVENT_BACK_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_LID_CLOSED */ + KEY_RESERVED, /* SONYPI_EVENT_LID_OPENED */
EV_SW/SW_LID unless LID events are delivered through ACPI (in which case we should hide these events completely).
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 186
Quoted 2 lines
drivers/misc/sony-laptop.c +2
-0+KEY_BLUE ,/* SONYPI_EVENT_BLUETOOTH_ON */ + KEY_BLUE, /* SONYPI_EVENT_BLUETOOTH_OFF */
KEY_BLUETOOTH.
Quoted 10 lines
drivers/misc/sony-laptop.c +10
-0+KEY_HELP ,/* SONYPI_EVENT_HELP_PRESSED */ +KEY_FN ,/* SONYPI_EVENT_FNKEY_ONLY */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_FAST_DOWN */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_FAST_UP */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_VFAST_DOWN */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_VFAST_UP */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */ + KEY_RESERVED, /* SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 206
Quoted 10 lines
drivers/misc/sony-laptop.c +10
-0+KEY_ZOOM ,/* SONYPI_EVENT_ZOOM_PRESSED */ +BTN_THUMB ,/* SONYPI_EVENT_THUMBPHRASE_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_MEYE_FACE */ +KEY_RESERVED ,/* SONYPI_EVENT_MEYE_OPPOSITE */ +KEY_RESERVED ,/* SONYPI_EVENT_MEMORYSTICK_INSERT */ +KEY_RESERVED ,/* SONYPI_EVENT_MEMORYSTICK_EJECT */ +KEY_RESERVED ,/* SONYPI_EVENT_ANYBUTTON_RELEASED */ +KEY_RESERVED ,/* SONYPI_EVENT_BATTERY_INSERT */ +KEY_RESERVED ,/* SONYPI_EVENT_BATTERY_REMOVE */ + KEY_RESERVED, /* SONYPI_EVENT_FNKEY_RELEASED */
Do we really want let userspace remap this event?
Quoted 27 lines
drivers/misc/sony-laptop.c +6
-7+KEY_WLAN ,/* SONYPI_EVENT_WIRELESS_ON */ + KEY_WLAN, /* SONYPI_EVENT_WIRELESS_OFF */ };/* release buttons after a short delay if pressed */ @@ -204,7 +229,6 @@ static void sony_laptop_report_input_event(u8 event)struct input_dev *jog_dev = sony_laptop_input.jog_dev;struct input_dev *key_dev = sony_laptop_input.key_dev;struct sony_laptop_keypress kp = {NULL }; -int i;if (event ==SONYPI_EVENT_FNKEY_RELEASED ) {/* Nothing, not all VAIOs generate this event */ @@ -233,17 +257,20 @@ static void sony_laptop_report_input_event(u8 event)break ;default : -for (i =0 ; sony_laptop_inputkeys[i].sonypiev; i++) -if (event == sony_laptop_inputkeys[i].sonypiev) { - kp.dev = key_dev; - kp.key = sony_laptop_inputkeys[i].inputev; -break ; - } +if (event >ARRAY_SIZE (sony_laptop_input_keycode_map)) { +dprintk ("sony_laptop_report_input_event, event not known: %d\n" , event); +break ; + }
drivers/misc/sony-laptop.c static void sony_laptop_report_input_event(u8 event) · line 273
Quoted 10 lines
drivers/misc/sony-laptop.c +5
-0+ kp.key = sony_laptop_input_keycode_map[event]; +if (kp.key !=KEY_UNKNOWN ) + kp.dev = key_dev;break ; }if (kp.dev) {input_report_key (kp.dev, kp.key,1 ); +/* we emit the scancode so we can always remap the key */ +input_event (kp.dev,EV_MSC ,MSC_SCAN , event);
Looks like whitespace damage here...
Signature · 1 line
Dmitry
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Quoted 12 lines · Dmitry Torokhov
Hi Mattia,
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 153
Quoted 8 lines · Mattia Dongili
drivers/misc/sony-laptop.c +8
-0+static int sony_laptop_input_keycode_map[] = { +KEY_RESERVED ,/* no event... */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_DOWN */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_UP */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_UP_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_RELEASED */
Quoted 3 lines
Jogdial events are never passed through
key_dev, do they? If so then we should not allow remapping them as it is pointless. EVCSKEYCODE shoudl return-EINVALwehn trying to remap them.
yes, JOG events are going to the other input_dev.
...
Quoted 5 lines
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 184
Quoted 2 lines
drivers/misc/sony-laptop.c +2
-0+KEY_RESERVED ,/* SONYPI_EVENT_LID_CLOSED */ + KEY_RESERVED, /* SONYPI_EVENT_LID_OPENED */EV_SW/SW_LID unless LID events are delivered through ACPI (in which case we should hide these events completely).
every event except jogdial's is also being delivered through ACPI. Will hide these from input then.
...
Quoted 3 lines
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 205
Quoted 3 lines
drivers/misc/sony-laptop.c +3
-0+KEY_RESERVED ,/* SONYPI_EVENT_ANYBUTTON_RELEASED */ +KEY_RESERVED ,/* SONYPI_EVENT_BATTERY_INSERT */ + KEY_RESERVED, /* SONYPI_EVENT_BATTERY_REMOVE */
ACPI only stuff as well?
Quoted 3 lines
Quoted 1 line
+
KEY_RESERVED, /*SONYPI_EVENT_FNKEY_RELEASED*/Do we really want let userspace remap this event?
hehehe, no, I don't think so.
Thanks for the comments
Signature · 2 lines
mattia :wq!
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
Hi,
the following is the only way I could think of to hide some events as per Dmitry suggestions while still using the default {set,get}keycode implementation.
Unfortunately I don't have enough time to put more work in the sony-laptop module right now.
I'll send an updated patch series later (tomorrow?).
commit 20c3d84c721706fd0893ba5f73c1b4f1c231322b
Author: Richard Hughes <[email protected]> Date: Fri Jul 20 01:41:57 2007 +0900
Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
drivers/misc/sony-laptop.c +140 -50
@@ -142,45 +142,124 @@ struct sony_laptop_keypress {int key; }; -/* Correspondance table between sonypi events and input layer events */ -static struct { -int sonypiev; -int inputev; -} sony_laptop_inputkeys[] = { - {SONYPI_EVENT_CAPTURE_PRESSED ,KEY_CAMERA }, - {SONYPI_EVENT_FNKEY_ONLY ,KEY_FN }, - {SONYPI_EVENT_FNKEY_ESC ,KEY_FN_ESC }, - {SONYPI_EVENT_FNKEY_F1 ,KEY_FN_F1 }, - {SONYPI_EVENT_FNKEY_F2 ,KEY_FN_F2 }, - {SONYPI_EVENT_FNKEY_F3 ,KEY_FN_F3 }, - {SONYPI_EVENT_FNKEY_F4 ,KEY_FN_F4 }, - {SONYPI_EVENT_FNKEY_F5 ,KEY_FN_F5 }, - {SONYPI_EVENT_FNKEY_F6 ,KEY_FN_F6 }, - {SONYPI_EVENT_FNKEY_F7 ,KEY_FN_F7 }, - {SONYPI_EVENT_FNKEY_F8 ,KEY_FN_F8 }, - {SONYPI_EVENT_FNKEY_F9 ,KEY_FN_F9 }, - {SONYPI_EVENT_FNKEY_F10 ,KEY_FN_F10 }, - {SONYPI_EVENT_FNKEY_F11 ,KEY_FN_F11 }, - {SONYPI_EVENT_FNKEY_F12 ,KEY_FN_F12 }, - {SONYPI_EVENT_FNKEY_1 ,KEY_FN_1 }, - {SONYPI_EVENT_FNKEY_2 ,KEY_FN_2 }, - {SONYPI_EVENT_FNKEY_D ,KEY_FN_D }, - {SONYPI_EVENT_FNKEY_E ,KEY_FN_E }, - {SONYPI_EVENT_FNKEY_F ,KEY_FN_F }, - {SONYPI_EVENT_FNKEY_S ,KEY_FN_S }, - {SONYPI_EVENT_FNKEY_B ,KEY_FN_B }, - {SONYPI_EVENT_BLUETOOTH_PRESSED ,KEY_BLUE }, - {SONYPI_EVENT_BLUETOOTH_ON ,KEY_BLUE }, - {SONYPI_EVENT_PKEY_P1 ,KEY_PROG1 }, - {SONYPI_EVENT_PKEY_P2 ,KEY_PROG2 }, - {SONYPI_EVENT_PKEY_P3 ,KEY_PROG3 }, - {SONYPI_EVENT_BACK_PRESSED ,KEY_BACK }, - {SONYPI_EVENT_HELP_PRESSED ,KEY_HELP }, - {SONYPI_EVENT_ZOOM_PRESSED ,KEY_ZOOM }, - {SONYPI_EVENT_WIRELESS_ON ,KEY_WLAN }, - {SONYPI_EVENT_WIRELESS_OFF ,KEY_WLAN }, - {SONYPI_EVENT_THUMBPHRASE_PRESSED ,BTN_THUMB }, - {0 ,0 }, +/* Correspondance table between sonypi events +* and input layer indexes in the keymap +*/ +static int sony_laptop_input_index[] = { +-1 ,/* no event */ +-1 ,/* SONYPI_EVENT_JOGDIAL_DOWN */ +-1 ,/* SONYPI_EVENT_JOGDIAL_UP */ +-1 ,/* SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */ +-1 ,/* SONYPI_EVENT_JOGDIAL_UP_PRESSED */ +-1 ,/* SONYPI_EVENT_JOGDIAL_PRESSED */ +-1 ,/* SONYPI_EVENT_JOGDIAL_RELEASED */ +0 ,/* SONYPI_EVENT_CAPTURE_PRESSED */ +1 ,/* SONYPI_EVENT_CAPTURE_RELEASED */ +2 ,/* SONYPI_EVENT_CAPTURE_PARTIALPRESSED */ +3 ,/* SONYPI_EVENT_CAPTURE_PARTIALRELEASED */ +4 ,/* SONYPI_EVENT_FNKEY_ESC */ +5 ,/* SONYPI_EVENT_FNKEY_F1 */ +6 ,/* SONYPI_EVENT_FNKEY_F2 */ +7 ,/* SONYPI_EVENT_FNKEY_F3 */ +8 ,/* SONYPI_EVENT_FNKEY_F4 */ +9 ,/* SONYPI_EVENT_FNKEY_F5 */ +10 ,/* SONYPI_EVENT_FNKEY_F6 */ +11 ,/* SONYPI_EVENT_FNKEY_F7 */ +12 ,/* SONYPI_EVENT_FNKEY_F8 */ +13 ,/* SONYPI_EVENT_FNKEY_F9 */ +14 ,/* SONYPI_EVENT_FNKEY_F10 */ +15 ,/* SONYPI_EVENT_FNKEY_F11 */ +16 ,/* SONYPI_EVENT_FNKEY_F12 */ +17 ,/* SONYPI_EVENT_FNKEY_1 */ +18 ,/* SONYPI_EVENT_FNKEY_2 */ +19 ,/* SONYPI_EVENT_FNKEY_D */ +20 ,/* SONYPI_EVENT_FNKEY_E */ +21 ,/* SONYPI_EVENT_FNKEY_F */ +22 ,/* SONYPI_EVENT_FNKEY_S */ +23 ,/* SONYPI_EVENT_FNKEY_B */ +24 ,/* SONYPI_EVENT_BLUETOOTH_PRESSED */ +25 ,/* SONYPI_EVENT_PKEY_P1 */ +26 ,/* SONYPI_EVENT_PKEY_P2 */ +27 ,/* SONYPI_EVENT_PKEY_P3 */ +28 ,/* SONYPI_EVENT_BACK_PRESSED */ +-1 ,/* SONYPI_EVENT_LID_CLOSED */ +-1 ,/* SONYPI_EVENT_LID_OPENED */ +29 ,/* SONYPI_EVENT_BLUETOOTH_ON */ +30 ,/* SONYPI_EVENT_BLUETOOTH_OFF */ +31 ,/* SONYPI_EVENT_HELP_PRESSED */ +32 ,/* SONYPI_EVENT_FNKEY_ONLY */ +33 ,/* SONYPI_EVENT_JOGDIAL_FAST_DOWN */ +34 ,/* SONYPI_EVENT_JOGDIAL_FAST_UP */ +35 ,/* SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */ +36 ,/* SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */ +37 ,/* SONYPI_EVENT_JOGDIAL_VFAST_DOWN */ +38 ,/* SONYPI_EVENT_JOGDIAL_VFAST_UP */ +39 ,/* SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */ +40 ,/* SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */ +41 ,/* SONYPI_EVENT_ZOOM_PRESSED */ +42 ,/* SONYPI_EVENT_THUMBPHRASE_PRESSED */ +43 ,/* SONYPI_EVENT_MEYE_FACE */ +44 ,/* SONYPI_EVENT_MEYE_OPPOSITE */ +45 ,/* SONYPI_EVENT_MEMORYSTICK_INSERT */ +46 ,/* SONYPI_EVENT_MEMORYSTICK_EJECT */ +-1 ,/* SONYPI_EVENT_ANYBUTTON_RELEASED */ +-1 ,/* SONYPI_EVENT_BATTERY_INSERT */ +-1 ,/* SONYPI_EVENT_BATTERY_REMOVE */ +-1 ,/* SONYPI_EVENT_FNKEY_RELEASED */ +47 ,/* SONYPI_EVENT_WIRELESS_ON */ +48 ,/* SONYPI_EVENT_WIRELESS_OFF */ +}; + +static int sony_laptop_input_keycode_map[] = { +KEY_CAMERA ,/* 0 SONYPI_EVENT_CAPTURE_PRESSED */ +KEY_RESERVED ,/* 1 SONYPI_EVENT_CAPTURE_RELEASED */ +KEY_RESERVED ,/* 2 SONYPI_EVENT_CAPTURE_PARTIALPRESSED */ +KEY_RESERVED ,/* 3 SONYPI_EVENT_CAPTURE_PARTIALRELEASED */ +KEY_FN_ESC ,/* 4 SONYPI_EVENT_FNKEY_ESC */ +KEY_FN_F1 ,/* 5 SONYPI_EVENT_FNKEY_F1 */ +KEY_FN_F2 ,/* 6 SONYPI_EVENT_FNKEY_F2 */ +KEY_FN_F3 ,/* 7 SONYPI_EVENT_FNKEY_F3 */ +KEY_FN_F4 ,/* 8 SONYPI_EVENT_FNKEY_F4 */ +KEY_FN_F5 ,/* 9 SONYPI_EVENT_FNKEY_F5 */ +KEY_FN_F6 ,/* 10 SONYPI_EVENT_FNKEY_F6 */ +KEY_FN_F7 ,/* 11 SONYPI_EVENT_FNKEY_F7 */ +KEY_FN_F8 ,/* 12 SONYPI_EVENT_FNKEY_F8 */ +KEY_FN_F9 ,/* 13 SONYPI_EVENT_FNKEY_F9 */ +KEY_FN_F10 ,/* 14 SONYPI_EVENT_FNKEY_F10 */ +KEY_FN_F11 ,/* 15 SONYPI_EVENT_FNKEY_F11 */ +KEY_FN_F12 ,/* 16 SONYPI_EVENT_FNKEY_F12 */ +KEY_FN_F1 ,/* 17 SONYPI_EVENT_FNKEY_1 */ +KEY_FN_F2 ,/* 18 SONYPI_EVENT_FNKEY_2 */ +KEY_FN_D ,/* 19 SONYPI_EVENT_FNKEY_D */ +KEY_FN_E ,/* 20 SONYPI_EVENT_FNKEY_E */ +KEY_FN_F ,/* 21 SONYPI_EVENT_FNKEY_F */ +KEY_FN_S ,/* 22 SONYPI_EVENT_FNKEY_S */ +KEY_FN_B ,/* 23 SONYPI_EVENT_FNKEY_B */ +KEY_BLUETOOTH ,/* 24 SONYPI_EVENT_BLUETOOTH_PRESSED */ +KEY_PROG1 ,/* 25 SONYPI_EVENT_PKEY_P1 */ +KEY_PROG2 ,/* 26 SONYPI_EVENT_PKEY_P2 */ +KEY_PROG3 ,/* 27 SONYPI_EVENT_PKEY_P3 */ +KEY_BACK ,/* 28 SONYPI_EVENT_BACK_PRESSED */ +KEY_BLUETOOTH ,/* 29 SONYPI_EVENT_BLUETOOTH_ON */ +KEY_BLUETOOTH ,/* 30 SONYPI_EVENT_BLUETOOTH_OFF */ +KEY_HELP ,/* 31 SONYPI_EVENT_HELP_PRESSED */ +KEY_FN ,/* 32 SONYPI_EVENT_FNKEY_ONLY */ +KEY_RESERVED ,/* 33 SONYPI_EVENT_JOGDIAL_FAST_DOWN */ +KEY_RESERVED ,/* 34 SONYPI_EVENT_JOGDIAL_FAST_UP */ +KEY_RESERVED ,/* 35 SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */ +KEY_RESERVED ,/* 36 SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */ +KEY_RESERVED ,/* 37 SONYPI_EVENT_JOGDIAL_VFAST_DOWN */ +KEY_RESERVED ,/* 38 SONYPI_EVENT_JOGDIAL_VFAST_UP */ +KEY_RESERVED ,/* 39 SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */ +KEY_RESERVED ,/* 40 SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */ +KEY_ZOOM ,/* 41 SONYPI_EVENT_ZOOM_PRESSED */ +BTN_THUMB ,/* 42 SONYPI_EVENT_THUMBPHRASE_PRESSED */ +KEY_RESERVED ,/* 43 SONYPI_EVENT_MEYE_FACE */ +KEY_RESERVED ,/* 44 SONYPI_EVENT_MEYE_OPPOSITE */ +KEY_RESERVED ,/* 45 SONYPI_EVENT_MEMORYSTICK_INSERT */ +KEY_RESERVED ,/* 46 SONYPI_EVENT_MEMORYSTICK_EJECT */ +KEY_WLAN ,/* 47 SONYPI_EVENT_WIRELESS_ON */ +KEY_WLAN ,/* 48 SONYPI_EVENT_WIRELESS_OFF */ };/* release buttons after a short delay if pressed */
@@ -204,7 +283,6 @@ static void sony_laptop_report_input_event(u8 event)struct input_dev *jog_dev = sony_laptop_input.jog_dev;struct input_dev *key_dev = sony_laptop_input.key_dev;struct sony_laptop_keypress kp = {NULL }; -int i;if (event ==SONYPI_EVENT_FNKEY_RELEASED ) {/* Nothing, not all VAIOs generate this event */
@@ -233,17 +311,22 @@ static void sony_laptop_report_input_event(u8 event)break ;default : -for (i =0 ; sony_laptop_inputkeys[i].sonypiev; i++) -if (event == sony_laptop_inputkeys[i].sonypiev) { +if (event >ARRAY_SIZE (sony_laptop_input_keycode_map)) { +dprintk ("sony_laptop_report_input_event, event not known: %d\n" , event); +break ; + } +if (sony_laptop_input_index[event] !=-1 ) { + kp.key = sony_laptop_input_keycode_map[sony_laptop_input_index[event]]; +if (kp.key !=KEY_UNKNOWN ) kp.dev = key_dev; - kp.key = sony_laptop_inputkeys[i].inputev; -break ; - } + }break ; }if (kp.dev) {input_report_key (kp.dev, kp.key,1 ); +/* we emit the scancode so we can always remap the key */ +input_event (kp.dev,EV_MSC ,MSC_SCAN , event);input_sync (kp.dev);kfifo_put (sony_laptop_input.fifo, (unsigned char *)&kp,sizeof (kp));
@@ -298,11 +381,18 @@ static int sony_laptop_setup_input(void) key_dev->id.vendor =PCI_VENDOR_ID_SONY ;/* Initialize the Input Drivers: special keys */ - key_dev->evbit[0 ] =BIT (EV_KEY ); -for (i =0 ; sony_laptop_inputkeys[i].sonypiev; i++) -if (sony_laptop_inputkeys[i].inputev) -set_bit (sony_laptop_inputkeys[i].inputev, - key_dev->keybit); +set_bit (EV_KEY , key_dev->evbit); +set_bit (EV_MSC , key_dev->evbit); +set_bit (MSC_SCAN , key_dev->mscbit); + key_dev->keycodesize =sizeof (sony_laptop_input_keycode_map[0 ]); + key_dev->keycodemax =ARRAY_SIZE (sony_laptop_input_keycode_map); + key_dev->keycode = &sony_laptop_input_keycode_map; +for (i =0 ; i <ARRAY_SIZE (sony_laptop_input_keycode_map); i++) { +if (sony_laptop_input_keycode_map[i] !=KEY_RESERVED ) { +set_bit (sony_laptop_input_keycode_map[i], + key_dev->keybit); + } + } error =input_register_device (key_dev);if (error)
Signature · 2 lines
mattia :wq!
Len Brown
reviewerRe: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
okay, I replaced the original 5/7 with this one.
thanks,
-Len
ps. helpful when you can include "sony-laptop:" on the subject line
Quoted 247 lines · Mattia Dongili
Hi,
the following is the only way I could think of to hide some events as per Dmitry suggestions while still using the default {set,get}keycode implementation.
Unfortunately I don't have enough time to put more work in the sony-laptop module right now.I'll send an updated patch series later (tomorrow?).
commit
20c3d84c721706fd0893ba5f73c1b4f1c231322bAuthor: Richard Hughes <[email protected]> Date: Fri Jul 20 01:41:57 2007 +0900Make the driver use
MSC_SCANand a setkeycode and getkeycode key table.Cc Dmitry Torokhov <[email protected]>Signed-off-by Richard Hughes <[email protected]>Signed-off-by Mattia Dongili <[email protected]>drivers/misc/sony-laptop.c +140
-50@@ -142,45 +142,124 @@ struct sony_laptop_keypress {int key; }; -/* Correspondance table between sonypi events and input layer events */ -static struct { -int sonypiev; -int inputev; -} sony_laptop_inputkeys[] = { - {SONYPI_EVENT_CAPTURE_PRESSED ,KEY_CAMERA }, - {SONYPI_EVENT_FNKEY_ONLY ,KEY_FN }, - {SONYPI_EVENT_FNKEY_ESC ,KEY_FN_ESC }, - {SONYPI_EVENT_FNKEY_F1 ,KEY_FN_F1 }, - {SONYPI_EVENT_FNKEY_F2 ,KEY_FN_F2 }, - {SONYPI_EVENT_FNKEY_F3 ,KEY_FN_F3 }, - {SONYPI_EVENT_FNKEY_F4 ,KEY_FN_F4 }, - {SONYPI_EVENT_FNKEY_F5 ,KEY_FN_F5 }, - {SONYPI_EVENT_FNKEY_F6 ,KEY_FN_F6 }, - {SONYPI_EVENT_FNKEY_F7 ,KEY_FN_F7 }, - {SONYPI_EVENT_FNKEY_F8 ,KEY_FN_F8 }, - {SONYPI_EVENT_FNKEY_F9 ,KEY_FN_F9 }, - {SONYPI_EVENT_FNKEY_F10 ,KEY_FN_F10 }, - {SONYPI_EVENT_FNKEY_F11 ,KEY_FN_F11 }, - {SONYPI_EVENT_FNKEY_F12 ,KEY_FN_F12 }, - {SONYPI_EVENT_FNKEY_1 ,KEY_FN_1 }, - {SONYPI_EVENT_FNKEY_2 ,KEY_FN_2 }, - {SONYPI_EVENT_FNKEY_D ,KEY_FN_D }, - {SONYPI_EVENT_FNKEY_E ,KEY_FN_E }, - {SONYPI_EVENT_FNKEY_F ,KEY_FN_F }, - {SONYPI_EVENT_FNKEY_S ,KEY_FN_S }, - {SONYPI_EVENT_FNKEY_B ,KEY_FN_B }, - {SONYPI_EVENT_BLUETOOTH_PRESSED ,KEY_BLUE }, - {SONYPI_EVENT_BLUETOOTH_ON ,KEY_BLUE }, - {SONYPI_EVENT_PKEY_P1 ,KEY_PROG1 }, - {SONYPI_EVENT_PKEY_P2 ,KEY_PROG2 }, - {SONYPI_EVENT_PKEY_P3 ,KEY_PROG3 }, - {SONYPI_EVENT_BACK_PRESSED ,KEY_BACK }, - {SONYPI_EVENT_HELP_PRESSED ,KEY_HELP }, - {SONYPI_EVENT_ZOOM_PRESSED ,KEY_ZOOM }, - {SONYPI_EVENT_WIRELESS_ON ,KEY_WLAN }, - {SONYPI_EVENT_WIRELESS_OFF ,KEY_WLAN }, - {SONYPI_EVENT_THUMBPHRASE_PRESSED ,BTN_THUMB }, - {0 ,0 }, +/* Correspondance table between sonypi events +* and input layer indexes in the keymap +*/ +static int sony_laptop_input_index[] = { +-1 ,/* no event */ +-1 ,/* SONYPI_EVENT_JOGDIAL_DOWN */ +-1 ,/* SONYPI_EVENT_JOGDIAL_UP */ +-1 ,/* SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */ +-1 ,/* SONYPI_EVENT_JOGDIAL_UP_PRESSED */ +-1 ,/* SONYPI_EVENT_JOGDIAL_PRESSED */ +-1 ,/* SONYPI_EVENT_JOGDIAL_RELEASED */ +0 ,/* SONYPI_EVENT_CAPTURE_PRESSED */ +1 ,/* SONYPI_EVENT_CAPTURE_RELEASED */ +2 ,/* SONYPI_EVENT_CAPTURE_PARTIALPRESSED */ +3 ,/* SONYPI_EVENT_CAPTURE_PARTIALRELEASED */ +4 ,/* SONYPI_EVENT_FNKEY_ESC */ +5 ,/* SONYPI_EVENT_FNKEY_F1 */ +6 ,/* SONYPI_EVENT_FNKEY_F2 */ +7 ,/* SONYPI_EVENT_FNKEY_F3 */ +8 ,/* SONYPI_EVENT_FNKEY_F4 */ +9 ,/* SONYPI_EVENT_FNKEY_F5 */ +10 ,/* SONYPI_EVENT_FNKEY_F6 */ +11 ,/* SONYPI_EVENT_FNKEY_F7 */ +12 ,/* SONYPI_EVENT_FNKEY_F8 */ +13 ,/* SONYPI_EVENT_FNKEY_F9 */ +14 ,/* SONYPI_EVENT_FNKEY_F10 */ +15 ,/* SONYPI_EVENT_FNKEY_F11 */ +16 ,/* SONYPI_EVENT_FNKEY_F12 */ +17 ,/* SONYPI_EVENT_FNKEY_1 */ +18 ,/* SONYPI_EVENT_FNKEY_2 */ +19 ,/* SONYPI_EVENT_FNKEY_D */ +20 ,/* SONYPI_EVENT_FNKEY_E */ +21 ,/* SONYPI_EVENT_FNKEY_F */ +22 ,/* SONYPI_EVENT_FNKEY_S */ +23 ,/* SONYPI_EVENT_FNKEY_B */ +24 ,/* SONYPI_EVENT_BLUETOOTH_PRESSED */ +25 ,/* SONYPI_EVENT_PKEY_P1 */ +26 ,/* SONYPI_EVENT_PKEY_P2 */ +27 ,/* SONYPI_EVENT_PKEY_P3 */ +28 ,/* SONYPI_EVENT_BACK_PRESSED */ +-1 ,/* SONYPI_EVENT_LID_CLOSED */ +-1 ,/* SONYPI_EVENT_LID_OPENED */ +29 ,/* SONYPI_EVENT_BLUETOOTH_ON */ +30 ,/* SONYPI_EVENT_BLUETOOTH_OFF */ +31 ,/* SONYPI_EVENT_HELP_PRESSED */ +32 ,/* SONYPI_EVENT_FNKEY_ONLY */ +33 ,/* SONYPI_EVENT_JOGDIAL_FAST_DOWN */ +34 ,/* SONYPI_EVENT_JOGDIAL_FAST_UP */ +35 ,/* SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */ +36 ,/* SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */ +37 ,/* SONYPI_EVENT_JOGDIAL_VFAST_DOWN */ +38 ,/* SONYPI_EVENT_JOGDIAL_VFAST_UP */ +39 ,/* SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */ +40 ,/* SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */ +41 ,/* SONYPI_EVENT_ZOOM_PRESSED */ +42 ,/* SONYPI_EVENT_THUMBPHRASE_PRESSED */ +43 ,/* SONYPI_EVENT_MEYE_FACE */ +44 ,/* SONYPI_EVENT_MEYE_OPPOSITE */ +45 ,/* SONYPI_EVENT_MEMORYSTICK_INSERT */ +46 ,/* SONYPI_EVENT_MEMORYSTICK_EJECT */ +-1 ,/* SONYPI_EVENT_ANYBUTTON_RELEASED */ +-1 ,/* SONYPI_EVENT_BATTERY_INSERT */ +-1 ,/* SONYPI_EVENT_BATTERY_REMOVE */ +-1 ,/* SONYPI_EVENT_FNKEY_RELEASED */ +47 ,/* SONYPI_EVENT_WIRELESS_ON */ +48 ,/* SONYPI_EVENT_WIRELESS_OFF */ +}; + +static int sony_laptop_input_keycode_map[] = { +KEY_CAMERA ,/* 0 SONYPI_EVENT_CAPTURE_PRESSED */ +KEY_RESERVED ,/* 1 SONYPI_EVENT_CAPTURE_RELEASED */ +KEY_RESERVED ,/* 2 SONYPI_EVENT_CAPTURE_PARTIALPRESSED */ +KEY_RESERVED ,/* 3 SONYPI_EVENT_CAPTURE_PARTIALRELEASED */ +KEY_FN_ESC ,/* 4 SONYPI_EVENT_FNKEY_ESC */ +KEY_FN_F1 ,/* 5 SONYPI_EVENT_FNKEY_F1 */ +KEY_FN_F2 ,/* 6 SONYPI_EVENT_FNKEY_F2 */ +KEY_FN_F3 ,/* 7 SONYPI_EVENT_FNKEY_F3 */ +KEY_FN_F4 ,/* 8 SONYPI_EVENT_FNKEY_F4 */ +KEY_FN_F5 ,/* 9 SONYPI_EVENT_FNKEY_F5 */ +KEY_FN_F6 ,/* 10 SONYPI_EVENT_FNKEY_F6 */ +KEY_FN_F7 ,/* 11 SONYPI_EVENT_FNKEY_F7 */ +KEY_FN_F8 ,/* 12 SONYPI_EVENT_FNKEY_F8 */ +KEY_FN_F9 ,/* 13 SONYPI_EVENT_FNKEY_F9 */ +KEY_FN_F10 ,/* 14 SONYPI_EVENT_FNKEY_F10 */ +KEY_FN_F11 ,/* 15 SONYPI_EVENT_FNKEY_F11 */ +KEY_FN_F12 ,/* 16 SONYPI_EVENT_FNKEY_F12 */ +KEY_FN_F1 ,/* 17 SONYPI_EVENT_FNKEY_1 */ +KEY_FN_F2 ,/* 18 SONYPI_EVENT_FNKEY_2 */ +KEY_FN_D ,/* 19 SONYPI_EVENT_FNKEY_D */ +KEY_FN_E ,/* 20 SONYPI_EVENT_FNKEY_E */ +KEY_FN_F ,/* 21 SONYPI_EVENT_FNKEY_F */ +KEY_FN_S ,/* 22 SONYPI_EVENT_FNKEY_S */ +KEY_FN_B ,/* 23 SONYPI_EVENT_FNKEY_B */ +KEY_BLUETOOTH ,/* 24 SONYPI_EVENT_BLUETOOTH_PRESSED */ +KEY_PROG1 ,/* 25 SONYPI_EVENT_PKEY_P1 */ +KEY_PROG2 ,/* 26 SONYPI_EVENT_PKEY_P2 */ +KEY_PROG3 ,/* 27 SONYPI_EVENT_PKEY_P3 */ +KEY_BACK ,/* 28 SONYPI_EVENT_BACK_PRESSED */ +KEY_BLUETOOTH ,/* 29 SONYPI_EVENT_BLUETOOTH_ON */ +KEY_BLUETOOTH ,/* 30 SONYPI_EVENT_BLUETOOTH_OFF */ +KEY_HELP ,/* 31 SONYPI_EVENT_HELP_PRESSED */ +KEY_FN ,/* 32 SONYPI_EVENT_FNKEY_ONLY */ +KEY_RESERVED ,/* 33 SONYPI_EVENT_JOGDIAL_FAST_DOWN */ +KEY_RESERVED ,/* 34 SONYPI_EVENT_JOGDIAL_FAST_UP */ +KEY_RESERVED ,/* 35 SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */ +KEY_RESERVED ,/* 36 SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */ +KEY_RESERVED ,/* 37 SONYPI_EVENT_JOGDIAL_VFAST_DOWN */ +KEY_RESERVED ,/* 38 SONYPI_EVENT_JOGDIAL_VFAST_UP */ +KEY_RESERVED ,/* 39 SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */ +KEY_RESERVED ,/* 40 SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */ +KEY_ZOOM ,/* 41 SONYPI_EVENT_ZOOM_PRESSED */ +BTN_THUMB ,/* 42 SONYPI_EVENT_THUMBPHRASE_PRESSED */ +KEY_RESERVED ,/* 43 SONYPI_EVENT_MEYE_FACE */ +KEY_RESERVED ,/* 44 SONYPI_EVENT_MEYE_OPPOSITE */ +KEY_RESERVED ,/* 45 SONYPI_EVENT_MEMORYSTICK_INSERT */ +KEY_RESERVED ,/* 46 SONYPI_EVENT_MEMORYSTICK_EJECT */ +KEY_WLAN ,/* 47 SONYPI_EVENT_WIRELESS_ON */ +KEY_WLAN ,/* 48 SONYPI_EVENT_WIRELESS_OFF */ };/* release buttons after a short delay if pressed */ @@ -204,7 +283,6 @@ static void sony_laptop_report_input_event(u8 event)struct input_dev *jog_dev = sony_laptop_input.jog_dev;struct input_dev *key_dev = sony_laptop_input.key_dev;struct sony_laptop_keypress kp = {NULL }; -int i;if (event ==SONYPI_EVENT_FNKEY_RELEASED ) {/* Nothing, not all VAIOs generate this event */ @@ -233,17 +311,22 @@ static void sony_laptop_report_input_event(u8 event)break ;default : -for (i =0 ; sony_laptop_inputkeys[i].sonypiev; i++) -if (event == sony_laptop_inputkeys[i].sonypiev) { +if (event >ARRAY_SIZE (sony_laptop_input_keycode_map)) { +dprintk ("sony_laptop_report_input_event, event not known: %d\n" , event); +break ; + } +if (sony_laptop_input_index[event] !=-1 ) { + kp.key = sony_laptop_input_keycode_map[sony_laptop_input_index[event]]; +if (kp.key !=KEY_UNKNOWN ) kp.dev = key_dev; - kp.key = sony_laptop_inputkeys[i].inputev; -break ; - } + }break ; }if (kp.dev) {input_report_key (kp.dev, kp.key,1 ); +/* we emit the scancode so we can always remap the key */ +input_event (kp.dev,EV_MSC ,MSC_SCAN , event);input_sync (kp.dev);kfifo_put (sony_laptop_input.fifo, (unsigned char *)&kp,sizeof (kp));@@ -298,11 +381,18 @@ static int sony_laptop_setup_input(void) key_dev->id.vendor =PCI_VENDOR_ID_SONY ;/* Initialize the Input Drivers: special keys */ - key_dev->evbit[0 ] =BIT (EV_KEY ); -for (i =0 ; sony_laptop_inputkeys[i].sonypiev; i++) -if (sony_laptop_inputkeys[i].inputev) -set_bit (sony_laptop_inputkeys[i].inputev, - key_dev->keybit); +set_bit (EV_KEY , key_dev->evbit); +set_bit (EV_MSC , key_dev->evbit); +set_bit (MSC_SCAN , key_dev->mscbit); + key_dev->keycodesize =sizeof (sony_laptop_input_keycode_map[0 ]); + key_dev->keycodemax =ARRAY_SIZE (sony_laptop_input_keycode_map); + key_dev->keycode = &sony_laptop_input_keycode_map; +for (i =0 ; i <ARRAY_SIZE (sony_laptop_input_keycode_map); i++) { +if (sony_laptop_input_keycode_map[i] !=KEY_RESERVED ) { +set_bit (sony_laptop_input_keycode_map[i], + key_dev->keybit); + } + } error =input_register_device (key_dev);if (error)
Re: [PATCH 5/7] Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
In reply to Dmitry TorokhovQuoted 12 lines · Dmitry Torokhov
Hi Mattia,
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 153
Quoted 8 lines · Mattia Dongili
drivers/misc/sony-laptop.c +8
-0+static int sony_laptop_input_keycode_map[] = { +KEY_RESERVED ,/* no event... */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_DOWN */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_UP */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_UP_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_PRESSED */ +KEY_RESERVED ,/* SONYPI_EVENT_JOGDIAL_RELEASED */
Quoted 3 lines
Jogdial events are never passed through
key_dev, do they? If so then we should not allow remapping them as it is pointless. EVCSKEYCODE shoudl return-EINVALwehn trying to remap them.
yes, JOG events are going to the other input_dev.
...
Quoted 5 lines
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 184
Quoted 2 lines
drivers/misc/sony-laptop.c +2
-0+KEY_RESERVED ,/* SONYPI_EVENT_LID_CLOSED */ + KEY_RESERVED, /* SONYPI_EVENT_LID_OPENED */EV_SW/SW_LID unless LID events are delivered through ACPI (in which case we should hide these events completely).
every event except jogdial's is also being delivered through ACPI. Will hide these from input then.
...
Quoted 3 lines
drivers/misc/sony-laptop.c struct sony_laptop_keypress { · line 205
Quoted 3 lines
drivers/misc/sony-laptop.c +3
-0+KEY_RESERVED ,/* SONYPI_EVENT_ANYBUTTON_RELEASED */ +KEY_RESERVED ,/* SONYPI_EVENT_BATTERY_INSERT */ + KEY_RESERVED, /* SONYPI_EVENT_BATTERY_REMOVE */
ACPI only stuff as well?
Quoted 3 lines
Quoted 1 line
+
KEY_RESERVED, /*SONYPI_EVENT_FNKEY_RELEASED*/Do we really want let userspace remap this event?
hehehe, no, I don't think so.
Thanks for the comments
Signature · 2 lines
mattia :wq!
Len Brown
reviewerapplied (w/ updated 5/7)
thanks,
-Len
Quoted 12 lines · Mattia Dongili
Hi Len,
These patches a targeted to 2.6.23.
I updated the previous series with a couple more patches one of which fixes a bug present in 2.6.22 and that I'll push to the stable maintainers. Important changes include the scancode enabling work done by Richard Hughes and support for some recent vaio models.Many thanks
--- drivers/misc/sony-laptop.c | 312 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 252 insertions(+), 60 deletions(-)