sony-laptop for 2.6.33
Subsystems (3)
Mattia Dongili
maintainerv2 cover sony-laptop for 2.6.33
Hi Len,
as promised here is a re-submission of the previous two patches plus two more that are helpful to support rfkill on newer models like Type P and Type X.
Dmitry Torokhov (1):
sony-laptop: remove private workqueue, use keventd instead
Mattia Dongili (3):
sony-laptop: add AVMode key mapping
sony-laptop: rfkill support for newer models
sony-laptop: enumerate rfkill devices using SN06
drivers/platform/x86/sony-laptop.c | 151 ++++++++++++++++++++++++------------ include/linux/sonypi.h | 1 + 2 files changed, 103 insertions(+), 49 deletions(-)
Mattia Dongili
maintainerPATCH v2 1/4 sony-laptop: add AVMode key mapping
Some models are equipped with an "AVMode" function key that sends
sony-laptop: Unknown event: 0x100 0xa1
sony-laptop: Unknown event: 0x100 0x21
for press and release respectively.
--- drivers/platform/x86/sony-laptop.c | 4 ++++ include/linux/sonypi.h | 1 + 2 files changed, 5 insertions(+), 0 deletions(-)
drivers/platform/x86/sony-laptop.c +4 -0
@@ -232,6 +232,7 @@ static int sony_laptop_input_index[] = {56 ,/* 69 SONYPI_EVENT_VOLUME_INC_PRESSED */ 57 ,/* 70 SONYPI_EVENT_VOLUME_DEC_PRESSED */ -1 ,/* 71 SONYPI_EVENT_BRIGHTNESS_PRESSED */ + 58, /* 72 SONYPI_EVENT_MEDIA_PRESSED */ }; static int sony_laptop_input_keycode_map[] = {
@@ -293,6 +294,7 @@ static int sony_laptop_input_keycode_map[] = {KEY_F15 ,/* 55 SONYPI_EVENT_SETTINGKEY_PRESSED */ KEY_VOLUMEUP ,/* 56 SONYPI_EVENT_VOLUME_INC_PRESSED */ KEY_VOLUMEDOWN ,/* 57 SONYPI_EVENT_VOLUME_DEC_PRESSED */ + KEY_MEDIA, /* 58 SONYPI_EVENT_MEDIA_PRESSED */ };/* release buttons after a short delay if pressed */
@@ -890,6 +892,8 @@ static struct sony_nc_event sony_100_events[] = { { 0x0C, SONYPI_EVENT_FNKEY_RELEASED }, { 0x9f, SONYPI_EVENT_CD_EJECT_PRESSED }, { 0x1f, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0xa1, SONYPI_EVENT_MEDIA_PRESSED }, + { 0x21, SONYPI_EVENT_ANYBUTTON_RELEASED }, { 0, 0 }, };
include/linux/sonypi.h +1 -0
@@ -111,6 +111,7 @@#define SONYPI_EVENT_VOLUME_INC_PRESSED 69#define SONYPI_EVENT_VOLUME_DEC_PRESSED 70#define SONYPI_EVENT_BRIGHTNESS_PRESSED 71 +#define SONYPI_EVENT_MEDIA_PRESSED 72/* get/set brightness */ #define SONYPI_IOCGBRT _IOR('v', 0, __u8)
Signature · 1 line
1.6.5.4
Mattia Dongili
maintainerPATCH v2 2/4 sony-laptop: remove private workqueue, use keventd instead
From: Dmitry Torokhov <[email protected]>
If we reschedule work instead of having work function sleep for 10 msecs between reads from kfifo we can safely use the main workqueue (keventd) and not bother with creating driver-private one.
--- drivers/platform/x86/sony-laptop.c | 57 +++++++++++++++++++---------------- 1 files changed, 31 insertions(+), 26 deletions(-)
drivers/platform/x86/sony-laptop.c +31 -26
@@ -144,7 +144,6 @@ struct sony_laptop_input_s {struct input_dev *key_dev;struct kfifo *fifo;spinlock_t fifo_lock; -struct workqueue_struct *wq; };static struct sony_laptop_input_s sony_laptop_input = {
@@ -300,17 +299,28 @@ static int sony_laptop_input_keycode_map[] = {/* release buttons after a short delay if pressed */ static void do_sony_laptop_release_key (struct work_struct *work) { +struct delayed_work *dwork = + container_of(work, struct delayed_work, work);struct sony_laptop_keypress kp; -while (kfifo_get (sony_laptop_input.fifo, (unsigned char *)&kp, -sizeof (kp)) ==sizeof (kp)) { -msleep (10 ); +if (kfifo_get (sony_laptop_input.fifo, + (unsigned char *)&kp,sizeof (kp)) ==sizeof (kp)) {input_report_key (kp.dev, kp.key,0 );input_sync (kp.dev); } + +/* +* If there is something in the fifo scnhedule nect release. +* We don't care about locking, at worst we may schedule an +* extra "empty" wakeup. This may be improved with the new +* kfifo API. +*/ +if (__kfifo_len (sony_laptop_input.fifo) !=0 ) +schedule_delayed_work (dwork,msecs_to_jiffies (10 )); } -static DECLARE_WORK(sony_laptop_release_key_work, - do_sony_laptop_release_key); + +static DECLARE_DELAYED_WORK(sony_laptop_release_key_work, + do_sony_laptop_release_key);/* forward event to the input subsystem */ static void sony_laptop_report_input_event (u8 event)
@@ -364,12 +374,12 @@ static void sony_laptop_report_input_event(u8 event)/* we emit the scancode so we can always remap the key */ input_event (kp.dev,EV_MSC ,MSC_SCAN , event);input_sync (kp.dev); + +/* schedule key release */ kfifo_put (sony_laptop_input.fifo, (unsigned char *)&kp,sizeof (kp)); - -if (!work_pending (&sony_laptop_release_key_work)) -queue_work (sony_laptop_input.wq, - &sony_laptop_release_key_work); +schedule_delayed_work (&sony_laptop_release_key_work, +msecs_to_jiffies (10 )); }else dprintk ("unknown input event %.2x\n" , event); }
@@ -396,20 +406,11 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device) goto err_dec_users; } -/* init workqueue */ - sony_laptop_input.wq =create_singlethread_workqueue ("sony-laptop" ); -if (!sony_laptop_input.wq) { - printk(KERN_ERR DRV_PFX - "Unable to create workqueue.\n"); - error = -ENXIO ; - goto err_free_kfifo; - } -/* input keys */ key_dev =input_allocate_device ();if (!key_dev) { error = -ENOMEM ; - goto err_destroy_wq; + goto err_free_kfifo; } key_dev->name ="Sony Vaio Keys" ;
@@ -472,9 +473,6 @@ err_unregister_keydev: err_free_keydev:input_free_device (key_dev); -err_destroy_wq: -destroy_workqueue (sony_laptop_input.wq); - err_free_kfifo:kfifo_free (sony_laptop_input.fifo);
@@ -485,12 +483,20 @@ err_dec_users:static void sony_laptop_remove_input (void ) { +struct sony_laptop_keypress kp = {NULL }; +/* cleanup only after the last user has gone */ if (!atomic_dec_and_test (&sony_laptop_input.users))return ; -/* flush workqueue first */ -flush_workqueue (sony_laptop_input.wq); +cancel_delayed_work_sync (&sony_laptop_release_key_work); + +/* Generate key-up events for remaining keys */ +while (kfifo_get (sony_laptop_input.fifo, + (unsigned char *)&kp,sizeof (kp)) ==sizeof (kp)) { +input_report_key (kp.dev, kp.key,0 ); +input_sync (kp.dev); + }/* destroy input devs */ input_unregister_device (sony_laptop_input.key_dev);
@@ -501,7 +507,6 @@ static void sony_laptop_remove_input(void) sony_laptop_input.jog_dev =NULL ; } -destroy_workqueue (sony_laptop_input.wq);kfifo_free (sony_laptop_input.fifo); }
Signature · 1 line
1.6.5.4
Mattia Dongili
maintainerPATCH v2 3/4 sony-laptop: rfkill support for newer models
Vaio Type X and possibly other new models use F135 as the radio frequency controlling function attached to the SNC device. In the indexed table this corresponds to 0x0135 (surpise!).
--- drivers/platform/x86/sony-laptop.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)
drivers/platform/x86/sony-laptop.c +14 -8
@@ -131,6 +131,7 @@ enum sony_nc_rfkill { N_SONY_RFKILL, }; +static int sony_rfkill_handle;static struct rfkill *sony_rfkill_devices[N_SONY_RFKILL ];static int sony_rfkill_address[N_SONY_RFKILL ] = {0x300 ,0x500 ,0x700 ,0x900 };static void sony_nc_rfkill_update (void );
@@ -970,7 +971,7 @@ static void sony_nc_notify(struct acpi_device *device, u32 event)else sony_laptop_report_input_event (ev); } - }else if (sony_find_snc_handle (0x124 ) == ev) { + }else if (sony_find_snc_handle (sony_rfkill_handle) == ev) {sony_nc_rfkill_update ();return ; }
@@ -1076,7 +1077,7 @@ static int sony_nc_rfkill_set(void *data, bool blocked)if (!blocked) argument |=0xff0000 ; -return sony_call_snc_handle (0x124 , argument, &result); +return sony_call_snc_handle (sony_rfkill_handle, argument, &result); }static const struct rfkill_ops sony_rfkill_ops = {
@@ -1119,7 +1120,7 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,if (!rfk)return -ENOMEM ; -sony_call_snc_handle (0x124 ,0x200 , &result); +sony_call_snc_handle (sony_rfkill_handle,0x200 , &result); hwblock = !(result &0x1 );rfkill_set_hw_state (rfk, hwblock);
@@ -1138,7 +1139,7 @@ static void sony_nc_rfkill_update()int result;bool hwblock; -sony_call_snc_handle (0x124 ,0x200 , &result); +sony_call_snc_handle (sony_rfkill_handle,0x200 , &result); hwblock = !(result &0x1 );for (i =0 ; i <N_SONY_RFKILL ; i++) {
@@ -1154,7 +1155,7 @@ static void sony_nc_rfkill_update()continue ; } -sony_call_snc_handle (0x124 , argument, &result); +sony_call_snc_handle (sony_rfkill_handle, argument, &result);rfkill_set_states (sony_rfkill_devices[i], !(result &0xf ), false); }
@@ -1164,10 +1165,15 @@ static int sony_nc_rfkill_setup(struct acpi_device *device) {int result, ret; -if (sony_find_snc_handle (0x124 ) ==-1 ) -return -1 ; +if (sony_find_snc_handle (0x124 ) ==-1 ) { +if (sony_find_snc_handle (0x135 ) ==-1 ) +return -1 ; +else + sony_rfkill_handle =0x135 ; + }else + sony_rfkill_handle =0x124 ; - ret =sony_call_snc_handle (0x124 ,0xb00 , &result); + ret =sony_call_snc_handle (sony_rfkill_handle,0xb00 , &result);if (ret) { printk(KERN_INFO DRV_PFX "Unable to enumerate rfkill devices: %x\n", ret);
Signature · 1 line
1.6.5.4
Mattia Dongili
maintainerPATCH v2 4/4 sony-laptop: enumerate rfkill devices using SN06
SN06 makes sure we get back a longer buffer which seems to be necessary going forward as the SNC devices describes more and more devices (or features more precisely). Moreover SN06 should be called with only the descriptor offset to make sure we hit the rfkill controlling function (F124 or F135) with a 0 argument to get a full list of features.
--- drivers/platform/x86/sony-laptop.c | 76 +++++++++++++++++++++++++++--------- 1 files changed, 57 insertions(+), 19 deletions(-)
drivers/platform/x86/sony-laptop.c +57 -19
@@ -1161,35 +1161,73 @@ static void sony_nc_rfkill_update() } } -static int sony_nc_rfkill_setup (struct acpi_device *device) +static void sony_nc_rfkill_setup (struct acpi_device *device) { -int result, ret; +int offset; +u8 dev_code, i; +acpi_status status; +struct acpi_object_list params; +union acpi_object in_obj; +union acpi_object *device_enum; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; -if (sony_find_snc_handle (0x124 ) ==-1 ) { -if (sony_find_snc_handle (0x135 ) ==-1 ) -return -1 ; + offset =sony_find_snc_handle (0x124 ); +if (offset ==-1 ) { + offset =sony_find_snc_handle (0x135 ); +if (offset ==-1 ) +return ;else sony_rfkill_handle =0x135 ; }else sony_rfkill_handle =0x124 ; +dprintk ("Found rkfill handle: 0x%.4x\n" , sony_rfkill_handle); - ret =sony_call_snc_handle (sony_rfkill_handle,0xb00 , &result); -if (ret) { - printk(KERN_INFO DRV_PFX - "Unable to enumerate rfkill devices: %x\n", ret); -return ret; +/* need to read the whole buffer returned by the acpi call to SN06 +* here otherwise we may miss some features +*/ + params.count =1 ; + params.pointer = &in_obj; + in_obj.type =ACPI_TYPE_INTEGER ; + in_obj.integer.value = offset; + status =acpi_evaluate_object (sony_nc_acpi_handle,"SN06" , ¶ms, + &buffer); +if (ACPI_FAILURE (status)) { +dprintk ("Radio device enumeration failed\n" ); +return ; } -if (result &0x1 ) -sony_nc_setup_rfkill (device,SONY_WIFI ); -if (result &0x2 ) -sony_nc_setup_rfkill (device,SONY_BLUETOOTH ); -if (result &0x1c ) -sony_nc_setup_rfkill (device,SONY_WWAN ); -if (result &0x20 ) -sony_nc_setup_rfkill (device,SONY_WIMAX ); + device_enum = (union acpi_object *) buffer.pointer; +if (!device_enum || device_enum->type !=ACPI_TYPE_BUFFER ) { +printk (KERN_ERR "Invalid SN06 return object 0x%.2x\n" , + device_enum->type); + goto out_no_enum; + } -return 0 ; +/* the buffer is filled with magic numbers describing the devices +* available, 0xff terminates the enumeration +*/ +while ((dev_code = *(device_enum->buffer.pointer + i)) !=0xff && + i < device_enum->buffer.length) { + i++; +dprintk ("Radio devices, looking at 0x%.2x\n" , dev_code); + +if (dev_code ==0 && !sony_rfkill_devices[SONY_WIFI ]) +sony_nc_setup_rfkill (device,SONY_WIFI ); + +if (dev_code ==0x10 && !sony_rfkill_devices[SONY_BLUETOOTH ]) +sony_nc_setup_rfkill (device,SONY_BLUETOOTH ); + +if ((0xf0 & dev_code) ==0x20 && + !sony_rfkill_devices[SONY_WWAN ]) +sony_nc_setup_rfkill (device,SONY_WWAN ); + +if (dev_code ==0x30 && !sony_rfkill_devices[SONY_WIMAX ]) +sony_nc_setup_rfkill (device,SONY_WIMAX ); + } + +out_no_enum: +kfree (buffer.pointer); +return ; }static int sony_nc_add (struct acpi_device *device)
Signature · 6 lines
1.6.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Len Brown
reviewerRe: [PATCH 4/4] sony-laptop: enumerate rfkill devices using SN06
Mattia,
The mystery is (partially) solved.
This one wouldn't merge b/c in my mailbox it has a copy of the 1st patch appended to it. I don't know how that happened, maybe the the formail processing I use to delete duplicates in my mailbox got confused, as the message does not have this issue in the list archives.
Anyway, with that repaired, this 4th patch joins
the previous 3 in the acpi-test tree.
thanks,
Len Brown, Intel Open Source Technology Center
Quoted 116 lines · Mattia Dongili
SN06 makes sure we get back a longer buffer which seems to be necessary going forward as the SNC devices describes more and more devices (or features more precisely). Moreover SN06 should be called with only the descriptor offset to make sure we hit the rfkill controlling function (F124 or F135) with a 0 argument to get a full list of features.
Signed-off-by Mattia Dongili <[email protected]>--- drivers/platform/x86/sony-laptop.c | 76 +++++++++++++++++++++++++++--------- 1 files changed, 57 insertions(+), 19 deletions(-)drivers/platform/x86/sony-laptop.c +57
-19@@ -1161,35 +1161,73 @@ static void sony_nc_rfkill_update() } } -static int sony_nc_rfkill_setup (struct acpi_device *device) +static void sony_nc_rfkill_setup (struct acpi_device *device) { -int result, ret; +int offset; +u8 dev_code, i; +acpi_status status; +struct acpi_object_list params; +union acpi_object in_obj; +union acpi_object *device_enum; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; -if (sony_find_snc_handle (0x124 ) ==-1 ) { -if (sony_find_snc_handle (0x135 ) ==-1 ) -return -1 ; + offset =sony_find_snc_handle (0x124 ); +if (offset ==-1 ) { + offset =sony_find_snc_handle (0x135 ); +if (offset ==-1 ) +return ;else sony_rfkill_handle =0x135 ; }else sony_rfkill_handle =0x124 ; +dprintk ("Found rkfill handle: 0x%.4x\n" , sony_rfkill_handle); - ret =sony_call_snc_handle (sony_rfkill_handle,0xb00 , &result); -if (ret) { - printk(KERN_INFO DRV_PFX - "Unable to enumerate rfkill devices: %x\n", ret); -return ret; +/* need to read the whole buffer returned by the acpi call to SN06 +* here otherwise we may miss some features +*/ + params.count =1 ; + params.pointer = &in_obj; + in_obj.type =ACPI_TYPE_INTEGER ; + in_obj.integer.value = offset; + status =acpi_evaluate_object (sony_nc_acpi_handle,"SN06" , ¶ms, + &buffer); +if (ACPI_FAILURE (status)) { +dprintk ("Radio device enumeration failed\n" ); +return ; } -if (result &0x1 ) -sony_nc_setup_rfkill (device,SONY_WIFI ); -if (result &0x2 ) -sony_nc_setup_rfkill (device,SONY_BLUETOOTH ); -if (result &0x1c ) -sony_nc_setup_rfkill (device,SONY_WWAN ); -if (result &0x20 ) -sony_nc_setup_rfkill (device,SONY_WIMAX ); + device_enum = (union acpi_object *) buffer.pointer; +if (!device_enum || device_enum->type !=ACPI_TYPE_BUFFER ) { +printk (KERN_ERR "Invalid SN06 return object 0x%.2x\n" , + device_enum->type); + goto out_no_enum; + } -return 0 ; +/* the buffer is filled with magic numbers describing the devices +* available, 0xff terminates the enumeration +*/ +while ((dev_code = *(device_enum->buffer.pointer + i)) !=0xff && + i < device_enum->buffer.length) { + i++; +dprintk ("Radio devices, looking at 0x%.2x\n" , dev_code); + +if (dev_code ==0 && !sony_rfkill_devices[SONY_WIFI ]) +sony_nc_setup_rfkill (device,SONY_WIFI ); + +if (dev_code ==0x10 && !sony_rfkill_devices[SONY_BLUETOOTH ]) +sony_nc_setup_rfkill (device,SONY_BLUETOOTH ); + +if ((0xf0 & dev_code) ==0x20 && + !sony_rfkill_devices[SONY_WWAN ]) +sony_nc_setup_rfkill (device,SONY_WWAN ); + +if (dev_code ==0x30 && !sony_rfkill_devices[SONY_WIMAX ]) +sony_nc_setup_rfkill (device,SONY_WIMAX ); + } + +out_no_enum: +kfree (buffer.pointer); +return ; }static int sony_nc_add (struct acpi_device *device)Signature · 6 lines
1.6.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
unexpected content begins here.
Quoted 54 lines
Cc "Matthew W. S. Bell" <[email protected]>Cc Dmitry Torokhov <[email protected]>Signed-off-by Mattia Dongili <[email protected]>--- drivers/platform/x86/sony-laptop.c | 4 ++++ include/linux/sonypi.h | 1 + 2 files changed, 5 insertions(+), 0 deletions(-)drivers/platform/x86/sony-laptop.c +4
-0@@ -232,6 +232,7 @@ static int sony_laptop_input_index[] = {56 ,/* 69 SONYPI_EVENT_VOLUME_INC_PRESSED */ 57 ,/* 70 SONYPI_EVENT_VOLUME_DEC_PRESSED */ -1 ,/* 71 SONYPI_EVENT_BRIGHTNESS_PRESSED */ + 58, /* 72 SONYPI_EVENT_MEDIA_PRESSED */ }; static int sony_laptop_input_keycode_map[] = {@@ -293,6 +294,7 @@ static int sony_laptop_input_keycode_map[] = {KEY_F15 ,/* 55 SONYPI_EVENT_SETTINGKEY_PRESSED */ KEY_VOLUMEUP ,/* 56 SONYPI_EVENT_VOLUME_INC_PRESSED */ KEY_VOLUMEDOWN ,/* 57 SONYPI_EVENT_VOLUME_DEC_PRESSED */ + KEY_MEDIA, /* 58 SONYPI_EVENT_MEDIA_PRESSED */ };/* release buttons after a short delay if pressed */ @@ -890,6 +892,8 @@ static struct sony_nc_event sony_100_events[] = { { 0x0C, SONYPI_EVENT_FNKEY_RELEASED }, { 0x9f, SONYPI_EVENT_CD_EJECT_PRESSED }, { 0x1f, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0xa1, SONYPI_EVENT_MEDIA_PRESSED }, + { 0x21, SONYPI_EVENT_ANYBUTTON_RELEASED }, { 0, 0 }, };include/linux/sonypi.h +1
-0@@ -111,6 +111,7 @@#define SONYPI_EVENT_VOLUME_INC_PRESSED 69#define SONYPI_EVENT_VOLUME_DEC_PRESSED 70#define SONYPI_EVENT_BRIGHTNESS_PRESSED 71 +#define SONYPI_EVENT_MEDIA_PRESSED 72/* get/set brightness */ #define SONYPI_IOCGBRT _IOR('v', 0, __u8)Signature · 1 line
1.6.5.4
Mattia Dongili
maintainerRe: [PATCH 4/4] sony-laptop: enumerate rfkill devices using SN06
Quoted 8 lines · Len Brown
Mattia,
The mystery is (partially) solved.This one wouldn't merge b/c in my mailbox it has a copy of the 1st patch appended to it. I don't know how that happened, maybe the the formail processing I use to delete duplicates in my mailbox got confused, as the message does not have this issue in the list archives.
I slightly changed the subject of one of them (the private workqueue one), could that be the reason?
Quoted 2 lines
Anyway, with that repaired, this 4th patch joins
the previous 3 in the acpi-test tree.
Thanks!
Signature · 2 lines
mattia :wq!