sony-laptop: support rfkill via ACPI interfaces
Subsystems (4)
PATCH 1/1 sony-laptop: support rfkill via ACPI interfaces
Enable events on all Vaio's with the new-style ACPI interface, and use it to support rfkill where available.
---
Mattia, I didn't want to mess with the DMI stuff, but I suspect we can probably drop the setup callbacks there and just enable them on all hardware that supports these methods. We possibly also want to be calling the ECON method on the SNC since some codepaths in the tables seem to depend on them - but I'm also worried to a certain extent on how much that might change driver interactions with some machines.
drivers/platform/x86/sony-laptop.c +153 -0
@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h>
@@ -143,6 +144,11 @@ struct sony_laptop_keypress {int key; }; +static struct rfkill *sony_wifi_rfkill; +static struct rfkill *sony_bluetooth_rfkill; +static struct rfkill *sony_wwan_rfkill; +static struct rfkill *sony_wimax_rfkill; +/* Correspondance table between sonypi events * and input layer indexes in the keymap */
@@ -981,6 +987,145 @@ static int sony_nc_resume(struct acpi_device *device)return 0 ; } +static void sony_rfkill_cleanup (void ) +{ +if (sony_wifi_rfkill) +rfkill_unregister (sony_wifi_rfkill); +if (sony_bluetooth_rfkill) +rfkill_unregister (sony_bluetooth_rfkill); +if (sony_wwan_rfkill) +rfkill_unregister (sony_wwan_rfkill); +if (sony_wimax_rfkill) +rfkill_unregister (sony_wimax_rfkill); +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; + +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x3 | ((long ) data <<8 ), + &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int call =0x3 | (((long ) data +1 ) <<8 ); + +if (state ==RFKILL_STATE_UNBLOCKED ) + call |=0xff0000 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , call, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN ); +if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)3 ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_unregister (sony_wifi_rfkill); +return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)5 ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_unregister (sony_bluetooth_rfkill); +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)7 ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_unregister (sony_wwan_rfkill); +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)9 ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_unregister (sony_wimax_rfkill); +return err; +} + +static int sony_nc_function_setup (struct acpi_device *device) +{ +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); + +/* Setup hotkey decoding */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x2 , &result); + +/* Eaable hotkey event generation */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0 , &result); + +/* Set BCHA, whatever /that/ does */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x101 , &result); + +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0xb03 , &result); + +if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device); + +return 0 ; +} +static int sony_nc_add (struct acpi_device *device) {acpi_status status;
@@ -1024,6 +1169,12 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN07" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {
@@ -1131,6 +1282,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_rfkill_cleanup ();return result; }
@@ -1156,6 +1308,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;
Signature · 1 line
Matthew Garrett | [email protected]
PATCH 1/1 sony-laptop: support rfkill via ACPI interfaces
Enable events on all Vaios with the new-style ACPI interface, and use it to support rfkill where available.
---
This one has less apostrophe abuse in the commit log. No content changes.
drivers/platform/x86/sony-laptop.c +153 -0
@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h>
@@ -143,6 +144,11 @@ struct sony_laptop_keypress {int key; }; +static struct rfkill *sony_wifi_rfkill; +static struct rfkill *sony_bluetooth_rfkill; +static struct rfkill *sony_wwan_rfkill; +static struct rfkill *sony_wimax_rfkill; +/* Correspondance table between sonypi events * and input layer indexes in the keymap */
@@ -981,6 +987,145 @@ static int sony_nc_resume(struct acpi_device *device)return 0 ; } +static void sony_rfkill_cleanup (void ) +{ +if (sony_wifi_rfkill) +rfkill_unregister (sony_wifi_rfkill); +if (sony_bluetooth_rfkill) +rfkill_unregister (sony_bluetooth_rfkill); +if (sony_wwan_rfkill) +rfkill_unregister (sony_wwan_rfkill); +if (sony_wimax_rfkill) +rfkill_unregister (sony_wimax_rfkill); +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; + +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x3 | ((long ) data <<8 ), + &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int call =0x3 | (((long ) data +1 ) <<8 ); + +if (state ==RFKILL_STATE_UNBLOCKED ) + call |=0xff0000 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , call, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN ); +if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)3 ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_unregister (sony_wifi_rfkill); +return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)5 ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_unregister (sony_bluetooth_rfkill); +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)7 ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_unregister (sony_wwan_rfkill); +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)9 ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_unregister (sony_wimax_rfkill); +return err; +} + +static int sony_nc_function_setup (struct acpi_device *device) +{ +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); + +/* Setup hotkey decoding */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x2 , &result); + +/* Eaable hotkey event generation */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0 , &result); + +/* Set BCHA, whatever /that/ does */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x101 , &result); + +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0xb03 , &result); + +if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device); + +return 0 ; +} +static int sony_nc_add (struct acpi_device *device) {acpi_status status;
@@ -1024,6 +1169,12 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN07" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {
@@ -1131,6 +1282,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_rfkill_cleanup ();return result; }
@@ -1156,6 +1308,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;
Signature · 1 line
Matthew Garrett | [email protected]
HI Matthew,
Quoted 2 lines · Matthew Garrett
Enable events on all Vaio's with the new-style ACPI interface, and use it to support rfkill where available.
Thanks for these patches, do they enable wwan activation on Vaio Z series, too?
Currently the stock kernel sony-laptop with all patches floating around on lkml did not make the wwan interface show up from the turned off state. The only way to do that is using the 0.6 version for Vaio Z from
http://www.basyskom.org/~eva/log_installation_vaio_z21vnx.html
Thanks and all the best
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
BAUGHURST
That kind of large fierce ugly woman who owns a small fierce ugly dog.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 8 lines · Norbert Preining
HI Matthew,
Quoted 2 lines · Matthew Garrett
Enable events on all Vaio's with the new-style ACPI interface, and use it to support rfkill where available.
Thanks for these patches, do they enable wwan activation on Vaio Z series, too?
I expect so.
Quoted 4 lines
Currently the stock kernel sony-laptop with all patches floating around on lkml did not make the wwan interface show up from the turned off state. The only way to do that is using the 0.6 version for Vaio Z from
http://www.basyskom.org/~eva/log_installation_vaio_z21vnx.html
Sigh. I could have saved some amount of time if these patches had actually been sent to the mailing list. They're functionally equivalent, except mine integrate with the rfkill class correctly and check whether the hardware is present before creating the rfkill device.
Signature · 5 lines
Matthew Garrett | [email protected] -- 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
Quoted 2 lines · Matthew Garrett
Sigh. I could have saved some amount of time if these patches had actually been sent to the mailing list. They're functionally equivalent,
Umpf, bad.
Quoted 2 lines
except mine integrate with the rfkill class correctly and check whether the hardware is present before creating the rfkill device.
I found that out only recently that there is this module floating around.
Ok, I will give your patches a testing spin on my Vaio Z11.
One question: Should I apply the patches Mattia posted some time ago (9 of them if I remember correctly) and your patch on top of them, or apply your patch to current -rc8?
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
DITHERINGTON (n)
Sudden access to panic experienced by one who realises that he is being drawn inexorably into a clabby (q.v.) conversation, i.e. one he has no hope of enjoying, benefiting from or understanding.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 3 lines · Norbert Preining
One question: Should I apply the patches Mattia posted some time ago (9 of them if I remember correctly) and your patch on top of them, or apply your patch to current -rc8?
Mine doesn't depend on any of Mattia's patches, but should work with them.
Signature · 1 line
Matthew Garrett | [email protected]
Hi Matthew,
Quoted 7 lines · Matthew Garrett
Quoted 5 lines
Quoted 2 lines
Enable events on all Vaio's with the new-style ACPI interface, and use it to support rfkill where available.
Thanks for these patches, do they enable wwan activation on Vaio Z series, too?
I expect so.
Ok, here some first test result:
kernel 2.6.29-rc8 plus only your patch.
Nice.
Now I have loads of rfkill switches:
/sys/class/rfkill# for i in rfkill*/name ; do echo $i; cat $i; done rfkill10/name
5100AGN
rfkill11/name
sony-wifi
rfkill12/name
sony-bluetooth
rfkill13/name
sony-wwan
rfkill15/name
hso-0
The interesting thing is that the last one hso-0 does not do anything when echoing 0/1 onto the state, while echoing 0/1 onto rfkill13/state the device is actually dis/enabled.
Fine.
Especially since I can now also turn on and off the bluetooth device. Great.
Thanks a lot!
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
CLACKMANNAN (n.)
The sound made by knocking over an elephant's-foot umbrella stand full of walking sticks. Hence name for a particular kind of disco drum riff.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 2 lines · Norbert Preining
Ok, here some first test result:
kernel 2.6.29-rc8 plus only your patch.
Another result, but this time a bit negative: Your patch does not (well I know) incorporate the stuff turning off the secondary nvidia card on the device having Stamina-Speed switch.
Outcome of that is that the power consumption is much higher with your modules about 8-10W (measured with powertop). So I have to go back to the other module.
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
`That young girl is one of the least benightedly unintelligent organic life forms it has been my profound lack of pleasure not to be able to avoid meeting.'
--- Marvin's first ever compliment about anybody. --- Douglas Adams, The Hitchhikers Guide to the Galaxy
--
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
Quoted 7 lines · Norbert Preining
Quoted 2 lines · Norbert Preining
Ok, here some first test result:
kernel 2.6.29-rc8 plus only your patch.Another result, but this time a bit negative: Your patch does not (well I know) incorporate the stuff turning off the secondary nvidia card on the device having Stamina-Speed switch.
As far as we can tell, the handling of the handover is consistent across all dual-GPU nvidia laptops[1]. The right place for support to end up is in the kernel component of the nouveau drivers.
[1] Possibly not the Macs
Signature · 5 lines
Matthew Garrett | [email protected] -- 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
Quoted 3 lines · Matthew Garrett
As far as we can tell, the handling of the handover is consistent across all dual-GPU nvidia laptops[1]. The right place for support to end up is in the kernel component of the nouveau drivers.
Whatever the nouveau drivers are? You mean those based on the kernel mode swching? Unfortunately that is far from prime time, and we need power saving now.
I will take a look over the weekend maybe I can add a patch ontop of yours that only does that, taken from the code in the special vaio-Z sony-laptop module.
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
BODMIN
The irrational and inevitable discrepancy between the amount pooled and the amount needed when a large group of people try to pay a bill together after a meal.
--- Douglas Adams, The Meaning of Liff
--
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
Hi all,
Quoted 8 lines · Norbert Preining
Quoted 3 lines
As far as we can tell, the handling of the handover is consistent across all dual-GPU nvidia laptops[1]. The right place for support to end up is in the kernel component of the nouveau drivers.
Whatever the nouveau drivers are? You mean those based on the kernel mode swching? Unfortunately that is far from prime time, and we need power saving now.
Quoted 7 lines
I will take a look over the weekend maybe I can add a patch ontop of yours that only does that, taken from the code in the special vaio-Z sony-laptop module.
Now it would be nice to merge over *only* the stuff concerning speed/stamina into the in-kernel driver added with the patch for rfkill support.
Ok, here is the code.
For those interested I Cc the [email protected] group where I first found that modules.
You need:
kernel 2.6.29-rc8 (maybe it works with all from .28 on)
the patch Matthew sent
the attached patch
Together you get full rfkill support for bluetooth/wwan/wifi, plus afais stamina-speed mode setting.
Maybe Matthias the creator of the sony-laptop for vaio-zseries modules can take a look at the patch and see if I missed something.
Matthias: sony_led_off and sony_dgpu_sta is never used, is that intentional? And also the #define SONY_WMMX_GUID I couldn't find being used anywhere.
Maybe Matthew can take a look and fix the compile warnings in function ‘sony_ovga_dsm’ (there are some!).
My intention is that we do not digress too far from the kernel code of sony-laptop making eventual merging possible.
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
OSBASTON (n.)
A point made for the seventh time to somebody who insists that they know exactly what you mean but clearly hasn't got the faintest idea.
--- Douglas Adams, The Meaning of Liff
sony-laptop.c renamed from usr/src/linux-2.6.29-rc8/drivers/platform/x86/sony-laptop.c +161 -0
@@ -116,6 +116,11 @@"set this to 1 to enable Motion Eye camera controls " "(only use it if you have a C1VE or C1VN model)"); +static int speed_stamina; +module_param (speed_stamina, int,0444 ); +MODULE_PARM_DESC (speed_stamina, +"Set this to 1 to enable SPEED mode on module load (EXPERIMENTAL)" ); +#ifdef CONFIG_SONYPI_COMPAT static int minor =-1 ;module_param (minor, int,0 );
@@ -482,8 +487,158 @@/*********** Platform Device ***********/ +static int sony_ovga_dsm (int func,int arg) +{ +static const char *path ="\\_SB.PCI0.OVGA._DSM" ; +static const char muid[] = { +/*00*/ 0xA0 ,0xA0 ,0x95 ,0x9D ,0x60 ,0x00 ,0x48 ,0x4D ,/* MUID */ +/*08*/ 0xB3 ,0x4D ,0x7E ,0x5F ,0xEA ,0x12 ,0x9F ,0xD4 , + }; + +struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL }; +struct acpi_object_list input; +union acpi_object params[4 ]; +union acpi_object *obj; +int result; + + input.count =4 ; + input.pointer = params; + params[0 ].type =ACPI_TYPE_BUFFER ; + params[0 ].buffer.length =sizeof (muid); + params[0 ].buffer.pointer = muid; + params[1 ].type =ACPI_TYPE_INTEGER ; + params[1 ].integer.value =0x00000102 ; + params[2 ].type =ACPI_TYPE_INTEGER ; + params[2 ].integer.value = func; + params[3 ].type =ACPI_TYPE_INTEGER ; + params[3 ].integer.value = arg; + + result =acpi_evaluate_object (NULL , path, &input, &output); +if (result) { +printk ("%s failed: %d\n" , path, result); +return -1 ; + } + + obj = (union acpi_object *)output.pointer; +printk ("result type %d\n" , obj->type); +if (obj->type ==ACPI_TYPE_PACKAGE ) { +int i; +printk ("returned package sized %d\n" , obj->package.count); +for (i =0 ; i < obj->package.count; i++) +printk ("%d %08x\n" , i, obj->package.elements[i].integer.value); + }else +if (obj->type ==ACPI_TYPE_INTEGER ) { +printk ("returned integer %08X\n" , obj->integer.value); + }else +if (obj->type ==ACPI_TYPE_BUFFER ) { +int i; +printk ("returned buffer sized %d\n" , obj->buffer.length); +for (i =0 ; i < obj->buffer.length; i++) +printk ("%d %02x\n" , i, obj->buffer.pointer[i]); + } +kfree (output.pointer); + +return 0 ; +} + +static int sony_led_stamina (void ) +{ +return sony_ovga_dsm (2 ,0x11 ); +} + +static int sony_led_speed (void ) +{ +return sony_ovga_dsm (2 ,0x12 ); +} + +static int sony_led_off (void ) +{ +return sony_ovga_dsm (2 ,0x13 ); +} + +static int sony_dgpu_sta (void ) +{ +return sony_ovga_dsm (3 ,0x00 ); +} + +static int sony_dgpu_off (void ) +{ +return sony_ovga_dsm (3 ,0x02 ); +} + +static int sony_dgpu_on (void ) +{ +return sony_ovga_dsm (3 ,0x01 ); +} + +static ssize_t sony_pf_store_speed_stamina (struct device *dev, +struct device_attribute *attr, +const char *buffer,size_t count) +{ +if (!strncmp (buffer,"speed" ,strlen ("speed" ))) { +sony_dgpu_on (); +sony_led_speed (); + speed_stamina =1 ; + }else +if (!strncmp (buffer,"stamina" ,strlen ("stamina" ))) { +sony_dgpu_off (); +sony_led_stamina (); + speed_stamina =0 ; + }else +return -EINVAL ; + +return count; +} + +static ssize_t sony_pf_show_speed_stamina (struct device *dev, +struct device_attribute *attr,char *buffer) +{ +return snprintf (buffer,PAGE_SIZE ,"%s\n" , speed_stamina ?"speed" :"stamina" ); +} + +static struct device_attribute sony_pf_speed_stamina_attr = +__ATTR (speed_stamina,S_IWUSR |S_IRUGO , + sony_pf_show_speed_stamina, sony_pf_store_speed_stamina); + +static int sony_pf_probe (struct platform_device *pdev) +{ +int result; + + result =device_create_file (&pdev->dev, &sony_pf_speed_stamina_attr); +if (result) +printk (KERN_DEBUG "sony_pf_probe: failed to add speed/stamina switch\n" ); + +/* initialize default, look at module param speed_stamina */ +if (speed_stamina ==1 ) { +sony_dgpu_on (); +sony_led_speed (); + }else { +sony_dgpu_off (); +sony_led_stamina (); + } + +return 0 ; +} + +static int sony_pf_resume (struct platform_device *pdev) +{ +/* on resume, restore previous state */ +if (speed_stamina ==1 ) { +sony_dgpu_on (); +sony_led_speed (); + }else { +sony_dgpu_off (); +sony_led_stamina (); + } +return 0 ; +} +static atomic_t sony_pf_users =ATOMIC_INIT (0 );static struct platform_driver sony_pf_driver = { + .probe = sony_pf_probe, +#ifdef CONFIG_PM + .resume_early = sony_pf_resume, +#endif .driver = { .name ="sony-laptop" , .owner =THIS_MODULE ,
@@ -1169,6 +1324,12 @@dprintk ("_INI Method failed\n" ); } +#if 0 +/* try to _INI the ECON variable */ +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 , &result)) +dprintk ("ECON Method failed\n" ); +#endif +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN07" , &handle))) {dprintk ("Doing SNC setup\n" );
Quoted 29 lines · On Friday 20 March 2009 02:18:37 Norbert Preining wrote:
Hi all,
Quoted 8 lines · Norbert Preining
Quoted 3 lines
As far as we can tell, the handling of the handover is consistent across all dual-GPU nvidia laptops[1]. The right place for support to end up is in the kernel component of the nouveau drivers.
Whatever the nouveau drivers are? You mean those based on the kernel mode swching? Unfortunately that is far from prime time, and we need power saving now.
Quoted 7 lines
I will take a look over the weekend maybe I can add a patch ontop of yours that only does that, taken from the code in the special vaio-Z sony-laptop module.
Now it would be nice to merge over *only* the stuff concerning speed/stamina into the in-kernel driver added with the patch for rfkill support.
Ok, here is the code.
For those interested I Cc the [email protected] group where I first found that modules.
You need:
kernel 2.6.29-rc8 (maybe it works with all from .28 on)
the patch Matthew sent
the attached patch
Quoted 5 lines
Together you get full rfkill support for bluetooth/wwan/wifi, plus afais stamina-speed mode setting.
Maybe Matthias the creator of the sony-laptop for vaio-zseries modules can take a look at the patch and see if I missed something.
Too much of honour ;) I only took the in-kernel module as a base for my experiments. But I'll have a look this weekend.
Quoted 3 lines
Matthias:
sony_led_offandsony_dgpu_stais never used, is that intentional? And also the #defineSONY_WMMX_GUIDI couldn't find being used anywhere.
sony_led_off is an experiment vehicle only, and sony_dgpu_sta can be used to query the power state of the nvidia adapter. It's in there for demonstration purposes.
Quoted 2 lines
Maybe Matthew can take a look and fix the compile warnings in function ‘sony_ovga_dsm’ (there are some!).
I'm aware of that. Most are in debug code, though, which can be removed safely without changing the functionality.
Quoted 7 lines
My intention is that we do not digress too far from the kernel code of sony-laptop making eventual merging possible.
Best wishes
Norbert
Quoted 10 lines
---------------------------------------------------------------------------
---- Dr. Norbert Preining <[email protected]> Vienna University of
Technology Debian Developer <[email protected]>
Debian TeX Group gpg DSA:0x09C5B094fp: 14DF 2E6C 0307 BE6D AD76
A9C0 D2BF 4AA3 09C5 B094
---------------------------------------------------------------------------
---- OSBASTON (n.)
A point made for the seventh time to somebody who insists that they know exactly what you mean but clearly hasn't got the faintest idea.
--- Douglas Adams, The Meaning of Liff
--
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
Mattia Dongili
maintainerQuoted 10 lines · Matthew Garrett
Enable events on all Vaio's with the new-style ACPI interface, and use it to support rfkill where available.
Signed-off-by Matthew Garrett <[email protected]>---
Mattia, I didn't want to mess with the DMI stuff, but I suspect we can probably drop the setup callbacks there and just enable them on all hardware that supports these methods. We possibly also want to be
I'm more of the idea to provide a module option to force the setup callback if the module is not in the DMI list.
Although for now all of the models that have SN07 and friends seem to benefit from throwing some magic numbers at them.
Quoted 3 lines
calling the ECON method on the SNC since some codepaths in the tables seem to depend on them - but I'm also worried to a certain extent on how much that might change driver interactions with some machines.
My understanding about ECON is that it is always enabled if the embedded controller is enabled. The SPIC device has the same kind of dependency and as far as I could see ECON is always 1. So I don't think it makes much of a difference.
A couple of comments below.
Thanks
Quoted 69 lines
drivers/platform/x86/sony-laptop.c +47
-0@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h> @@ -143,6 +144,11 @@ struct sony_laptop_keypress {int key; }; +static struct rfkill *sony_wifi_rfkill; +static struct rfkill *sony_bluetooth_rfkill; +static struct rfkill *sony_wwan_rfkill; +static struct rfkill *sony_wimax_rfkill; +/* Correspondance table between sonypi events * and input layer indexes in the keymap */ @@ -981,6 +987,145 @@ static int sony_nc_resume(struct acpi_device *device)return 0 ; } +static void sony_rfkill_cleanup (void ) +{ +if (sony_wifi_rfkill) +rfkill_unregister (sony_wifi_rfkill); +if (sony_bluetooth_rfkill) +rfkill_unregister (sony_bluetooth_rfkill); +if (sony_wwan_rfkill) +rfkill_unregister (sony_wwan_rfkill); +if (sony_wimax_rfkill) +rfkill_unregister (sony_wimax_rfkill); +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; + +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x3 | ((long ) data <<8 ), + &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int call =0x3 | (((long ) data +1 ) <<8 ); + +if (state ==RFKILL_STATE_UNBLOCKED ) + call |=0xff0000 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , call, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN );
drivers/platform/x86/sony-laptop.c static int sony_nc_resume(struct acpi_device *device) · line 1040
Quoted 10 lines
drivers/platform/x86/sony-laptop.c +10
-0+if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)3 ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_unregister (sony_wifi_rfkill);
do we really need to unregister if registering failed? Looking at rfkill_{un,}register this seems unnecessary while an rfkill_free seems more appropriate.
The same applies for the other rfkill setup functions.
Quoted 68 lines
drivers/platform/x86/sony-laptop.c +65
-0+return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)5 ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_unregister (sony_bluetooth_rfkill); +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)7 ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_unregister (sony_wwan_rfkill); +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)9 ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_unregister (sony_wimax_rfkill); +return err; +} + +static int sony_nc_function_setup (struct acpi_device *device) +{ +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); +
drivers/platform/x86/sony-laptop.c static int sony_nc_resume(struct acpi_device *device) · line 1115
Quoted 10 lines
drivers/platform/x86/sony-laptop.c +10
-0+/* Setup hotkey decoding */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x2 , &result); + +/* Eaable hotkey event generation */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0 , &result); + +/* Set BCHA, whatever /that/ does */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x101 , &result); + +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0xb03 , &result);
hummm, this is very similar to the callback setup executed when matching the snc dmi list.
On which vaio model did you get this numbers? Did you find the other initialization path (the one dependent on the DMI list) any useful on that model? i.e.: do you need both?
Quoted 48 lines
drivers/platform/x86/sony-laptop.c +20
-0+if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device); + +return 0 ; +} +static int sony_nc_add (struct acpi_device *device) {acpi_status status;@@ -1024,6 +1169,12 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN07" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {@@ -1131,6 +1282,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_rfkill_cleanup ();return result; }@@ -1156,6 +1308,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;Signature · 2 lines
-- Matthew Garrett | [email protected]
Signature · 2 lines
mattia :wq!
Quoted 4 lines · Mattia Dongili
I'm more of the idea to provide a module option to force the setup callback if the module is not in the DMI list.
Although for now all of the models that have SN07 and friends seem to benefit from throwing some magic numbers at them.
I suspect that this is how new machines expect to be controlled.
Quoted 8 lines
Quoted 3 lines
calling the ECON method on the SNC since some codepaths in the tables seem to depend on them - but I'm also worried to a certain extent on how much that might change driver interactions with some machines.
My understanding about ECON is that it is always enabled if the embedded controller is enabled. The SPIC device has the same kind of dependency and as far as I could see ECON is always 1. So I don't think it makes much of a difference.
I had one machine where ECON seemed to need to be called explicitly, but I can't remember the details now. Calling it probably wouldn't hurt anything.
Quoted 4 lines
do we really need to unregister if registering failed? Looking at rfkill_{un,}register this seems unnecessary while an
rfkill_freeseems more appropriate.
The same applies for the other rfkill setup functions.
Yeah, I'll fix that up.
Quoted 9 lines
drivers/platform/x86/sony-laptop.c static int sony_nc_resume(struct acpi_device *device) · line 1115
Quoted 3 lines
drivers/platform/x86/sony-laptop.c +3
-0+acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x101 , &result); + +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0xb03 , &result);hummm, this is very similar to the callback setup executed when matching the snc dmi list.
On which vaio model did you get this numbers? Did you find the other initialization path (the one dependent on the DMI list) any useful on that model? i.e.: do you need both?
The numbers correspond to enabling all events. I couldn't think of any reason why we'd only want to enable a subset. The current nc setup code seems to enable some events and then disable them again, which I don't really understand.
Signature · 1 line
Matthew Garrett | [email protected]
Mattia Dongili
maintainerQuoted 8 lines · Matthew Garrett
Quoted 4 lines · Mattia Dongili
I'm more of the idea to provide a module option to force the setup callback if the module is not in the DMI list.
Although for now all of the models that have SN07 and friends seem to benefit from throwing some magic numbers at them.I suspect that this is how new machines expect to be controlled.
agreed, but I need to figure out if the initialization sequence is really the same for those new TT/Z models and the olders one (see also below).
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
calling the ECON method on the SNC since some codepaths in the tables seem to depend on them - but I'm also worried to a certain extent on how much that might change driver interactions with some machines.
Quoted 8 lines
Quoted 4 lines
My understanding about ECON is that it is always enabled if the embedded controller is enabled. The SPIC device has the same kind of dependency and as far as I could see ECON is always 1. So I don't think it makes much of a difference.
I had one machine where ECON seemed to need to be called explicitly, but I can't remember the details now. Calling it probably wouldn't hurt anything.
seems to be a TT and Z specific thing though. The DSDT on other models doesn't provide the ECON method.
...
Quoted 10 lines
Quoted 9 lines
drivers/platform/x86/sony-laptop.c static int sony_nc_resume(struct acpi_device *device) · line 1115
Quoted 3 lines
drivers/platform/x86/sony-laptop.c +3
-0+acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0x101 , &result); + +acpi_callsetfunc (sony_nc_acpi_handle,"SN07" ,0xb03 , &result);hummm, this is very similar to the callback setup executed when matching the snc dmi list.
On which vaio model did you get this numbers? Did you find the other initialization path (the one dependent on the DMI list) any useful on that model? i.e.: do you need both?
Quoted 4 lines
The numbers correspond to enabling all events. I couldn't think of any reason why we'd only want to enable a subset. The current nc setup code seems to enable some events and then disable them again, which I don't really understand.
Well, the current sequence was taken from a trace in windows on a Vaio C Type, then it demonstrated to be helpful on other models as well. The SN07[1] method is very different from the Z and TT type to the AR, C, FE, FZ and N so I'm starting to suspect that we're just seeing a new generation of SNC based models. I'll see if some users with older models can give the new sequence a go.
In the meantime can we make your sony_nc_function_setup less invasive and depend on the DMI to match?
[1]: more dsdt tables here http://www.kamineko.org/dsdt-vaio/
Signature · 2 lines
mattia :wq!
Quoted 7 lines · Mattia Dongili
Quoted 3 lines · Matthew Garrett
I had one machine where ECON seemed to need to be called explicitly, but I can't remember the details now. Calling it probably wouldn't hurt anything.
seems to be a TT and Z specific thing though. The DSDT on other models doesn't provide the ECON method.
Yeah. As I said, I don't think there's any harm in causing it - I think I was getting more promising results from hotkey events in the Z when I called ECON, but I don't have access to that machine right now and never got it finished off.
Quoted 11 lines
Quoted 4 lines
The numbers correspond to enabling all events. I couldn't think of any reason why we'd only want to enable a subset. The current nc setup code seems to enable some events and then disable them again, which I don't really understand.
Well, the current sequence was taken from a trace in windows on a Vaio C Type, then it demonstrated to be helpful on other models as well. The SN07[1] method is very different from the Z and TT type to the AR, C, FE, FZ and N so I'm starting to suspect that we're just seeing a new generation of SNC based models. I'll see if some users with older models can give the new sequence a go.
Looking through, the implementation seems quite different but the functionality seems the same - the newer machines seem to return values directly, whereas older ones tended to trap into SMM. The wireless control (at least, the enumeration call I make) seems to be a noop on these older machines. It /looks/ like we can probably get some sort of versioning information about the interface by calling SN00. I think that would probably be a better approach than using DMI for this.
I've put this into rawhide, so I suspect we'll hear complaints if it breaks things for anybody.
Signature · 1 line
Matthew Garrett | [email protected]
Mattia Dongili
maintainerQuoted 6 lines · Matthew Garrett
Quoted 5 lines · Mattia Dongili
Quoted 3 lines · Matthew Garrett
I had one machine where ECON seemed to need to be called explicitly, but I can't remember the details now. Calling it probably wouldn't hurt anything.
Quoted 7 lines
Quoted 2 lines
seems to be a TT and Z specific thing though. The DSDT on other models doesn't provide the ECON method.
Yeah. As I said, I don't think there's any harm in causing it - I think I was getting more promising results from hotkey events in the Z when I called ECON, but I don't have access to that machine right now and never got it finished off.
Sounds reasonable.
Quoted 12 lines
Quoted 11 lines
Quoted 4 lines
The numbers correspond to enabling all events. I couldn't think of any reason why we'd only want to enable a subset. The current nc setup code seems to enable some events and then disable them again, which I don't really understand.
Well, the current sequence was taken from a trace in windows on a Vaio C Type, then it demonstrated to be helpful on other models as well. The SN07[1] method is very different from the Z and TT type to the AR, C, FE, FZ and N so I'm starting to suspect that we're just seeing a new generation of SNC based models. I'll see if some users with older models can give the new sequence a go.
Quoted 7 lines
Looking through, the implementation seems quite different but the functionality seems the same - the newer machines seem to return values directly, whereas older ones tended to trap into SMM. The wireless control (at least, the enumeration call I make) seems to be a noop on these older machines. It /looks/ like we can probably get some sort of versioning information about the interface by calling SN00. I think that would probably be a better approach than using DMI for this.
sure, that DMI whitelist is already annoying in its current shape. Getting the ACPI tables to tell us what SNC version we are looking at would be so much better.
I just grepped the DSDTs I have here and this is what I got:
DSDT.c1s.dsl: Name (SNI4, 0x344A0001) DSDT.c71bw.dsl: Name (SNI4, 0x344A0001) DSDT.fe21b.dsl: Name (SNI4, 0x334A0000) DSDT.fe31m.dsl: Name (SNI4, 0x334A0000) DSDT.fe41z.dsl: Name (SNI4, 0x334A0000) DSDT.fe830fe.dsl: Name (SNI4, 0x334A0000) DSDT.fz15.dsl: Name (SNI4, 0x374A0000) DSDT.fz180e.dsl: Name (SNI4, 0x374A0000) DSDT.n370e.dsl: Name (SNI4, 0x344A0001) DSDT.tt11lnb.dsl: Store (0x344D0000, Index (CFGI, 0x04)) DSDT.z11awn.dsl: Store (0x334D0000, Index (CFGI, 0x04)) DSDT.z11vn.dsl: Store (0x334D0000, Index (CFGI, 0x04)) DSDT.z26gn.dsl: Store (0x334D0000, Index (CFGI, 0x04)) DSDT.z90s.dsl: Store (0x334D0000, Index (CFGI, 0x04)) VGN-AR31S-R0200J6.dsl: Name (SNI4, 0x364A0000) VGN-AR370E-R0200J6.dsl: Name (SNI4, 0x364A0000) VGN-C1S.dsl: Name (SNI4, 0x344A0001) VGN-C1ZB-R0034J4.dsl: Name (SNI4, 0x344A0001) VGN-C240E-R0080J4.dsl: Name (SNI4, 0x344A0001) VGN-C2S-R0080J4.dsl: Name (SNI4, 0x344A0001) VGN-C2Z-R0080J4.dsl: Name (SNI4, 0x344A0001) VGN-FE11H-R0072J3.dsl: Name (SNI4, 0x334A0000) VGN-FE11H-R0074J3.dsl: Name (SNI4, 0x334A0000) VGN-FE11M-R0172J3.dsl: Name (SNI4, 0x334A0000) VGN-FE21M-R0130J3.dsl: Name (SNI4, 0x334A0000) VGN-FE31M.dsl: Name (SNI4, 0x334A0000) VGN-FE41E-R0190J3.dsl: Name (SNI4, 0x334A0000) VGN-FE41M-R0190J3.dsl: Name (SNI4, 0x334A0000) VGN-FE41Z-R0200J3.dsl: Name (SNI4, 0x334A0000) VGN-FE550G-R0074J3.dsl: Name (SNI4, 0x334A0000) VGN-FE590P-R0072J3.dsl: Name (SNI4, 0x334A0000) VGN-FE660G-R0133J3.dsl: Name (SNI4, 0x334A0000) VGN-FE770G-R0173J3.dsl: Name (SNI4, 0x334A0000) VGN-FE830.dsl: Name (SNI4, 0x334A0000) VGN-FE880EH-R0200J3.dsl: Name (SNI4, 0x334A0000) VGN-N130G-R0020J4.dsl: Name (SNI4, 0x344A0001) VGN-N230E-R0070J4.dsl: Name (SNI4, 0x344A0001)
SNI4 or CFGI+0x04 is the only differing number and is returned with SN00(4).
Quoted 2 lines
I've put this into rawhide, so I suspect we'll hear complaints if it breaks things for anybody.
want to try to push your patch to mainline or would you prefer to wait? IMO pushing it and eventually fixing support for 0x344a000[10] models is fine. After all your snc_setup code could be easily plugged into the DMI list for the time being and Z and TT users would be happy.
Signature · 2 lines
mattia :wq!
Quoted 10 lines · On Friday 20 March 2009 02:18:37 Norbert Preining wrote:
Ok, here is the code.
For those interested I Cc the [email protected] group where I first found that modules.
You need:
kernel 2.6.29-rc8 (maybe it works with all from .28 on)
the patch Matthew sent
the attached patch
Quoted 5 lines
Together you get full rfkill support for bluetooth/wwan/wifi, plus afais stamina-speed mode setting.
Maybe Matthias the creator of the sony-laptop for vaio-zseries modules can take a look at the patch and see if I missed something.
I checked the code and I think you didn't miss anything. Looks good.
Quoted 3 lines
Matthias:
sony_led_offandsony_dgpu_stais never used, is that intentional? And also the #defineSONY_WMMX_GUIDI couldn't find being used anywhere.
You can safely get rid of this, its the GUID of the only valid (but broken) WMMX function in the DSDT code. It was a dead end.
Quoted 2 lines
Maybe Matthew can take a look and fix the compile warnings in function ‘sony_ovga_dsm’ (there are some!).
Check the attached patch, it does away with the compile warnings. I've removed the warnings in functional code and put ifdefs (ugh!) around debug only code. You can just remove it if you don't like it, I'm only keeping it around for reference.
I've also backported Matthews patch to the standard Suse 11.1 kernel so that we can test it more easily.
sony-laptop.c renamed from sony-laptop.c.orig +26 -22
@@ -85,8 +85,6 @@#define SONY_PIC_HID "SNY6001"#define SONY_PIC_DRIVER_NAME "Sony Programmable IO Control Driver" -#define SONY_WMMX_GUID "F6CB5C3C-9CAE-4EBD-B577-931EA32A2CC0" -MODULE_AUTHOR ("Stelian Pop, Mattia Dongili" );MODULE_DESCRIPTION ("Sony laptop extras driver (SPIC and SNC ACPI device)" );MODULE_LICENSE ("GPL" );
@@ -485,8 +483,8 @@/*********** Platform Device ***********/ static int sony_ovga_dsm (int func,int arg) { -static const char *path ="\\_SB.PCI0.OVGA._DSM" ; -static const char muid[] = { +static char *path ="\\_SB.PCI0.OVGA._DSM" ; +static char muid[] = {/*00*/ 0xA0 ,0xA0 ,0x95 ,0x9D ,0x60 ,0x00 ,0x48 ,0x4D ,/* MUID */ /*08*/ 0xB3 ,0x4D ,0x7E ,0x5F ,0xEA ,0x12 ,0x9F ,0xD4 , };
@@ -494,7 +492,6 @@struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };struct acpi_object_list input;union acpi_object params[4 ]; -union acpi_object *obj;int result; input.count =4 ;
@@ -515,25 +512,30 @@return -1 ; } - obj = (union acpi_object *)output.pointer; -printk ("result type %d\n" , obj->type); -if (obj->type ==ACPI_TYPE_PACKAGE ) { -int i; -printk ("returned package sized %d\n" , obj->package.count); -for (i =0 ; i < obj->package.count; i++) -printk ("%d %08x\n" , i, obj->package.elements[i].integer.value); - }else -if (obj->type ==ACPI_TYPE_INTEGER ) { -printk ("returned integer %08X\n" , obj->integer.value); - }else -if (obj->type ==ACPI_TYPE_BUFFER ) { -int i; -printk ("returned buffer sized %d\n" , obj->buffer.length); -for (i =0 ; i < obj->buffer.length; i++) -printk ("%d %02x\n" , i, obj->buffer.pointer[i]); +#ifdef DEBUG + { +union acpi_object *obj; + obj = (union acpi_object *)output.pointer; +printk ("result type %d\n" , obj->type); +if (obj->type ==ACPI_TYPE_PACKAGE ) { +int i; +printk ("returned package sized %d\n" , obj->package.count); +for (i =0 ; i < obj->package.count; i++) +printk ("%d %08x\n" , i, obj->package.elements[i].integer.value); + }else +if (obj->type ==ACPI_TYPE_INTEGER ) { +printk ("returned integer %08X\n" , obj->integer.value); + }else +if (obj->type ==ACPI_TYPE_BUFFER ) { +int i; +printk ("returned buffer sized %d\n" , obj->buffer.length); +for (i =0 ; i < obj->buffer.length; i++) +printk ("%d %02x\n" , i, obj->buffer.pointer[i]); + } } -kfree (output.pointer); +#endif +kfree (output.pointer);return 0 ; }
@@ -547,6 +549,7 @@return sony_ovga_dsm (2 ,0x12 ); } +#ifdef DEBUG static int sony_led_off (void ) {return sony_ovga_dsm (2 ,0x13 );
@@ -556,6 +559,7 @@ {return sony_ovga_dsm (3 ,0x00 ); } +#endif static int sony_dgpu_off (void ) {
Quoted 2 lines · On Saturday 21 March 2009 12:22:35 Matthias Welwarsky wrote:
I've also backported Matthews patch to the standard Suse 11.1 kernel so that we can test it more easily.
Done, looks quite promising. The "wireless" switch on the Z21 works now, and apparently there is some script magic in opensuse that operates all rfkill switches, so it kills all wireless devices at once. Not bad.
The new init sequence for SN07 also enables all the special keys, even the speed/stamina switch now generates an ACPI event, as well as S1, S2 and Eject. But you cannot distinguish them, they all report the same event.
All in all - nice.
regards,
matthias
Quoted 6 lines · Mattia Dongili
sure, that DMI whitelist is already annoying in its current shape. Getting the ACPI tables to tell us what SNC version we are looking at would be so much better.
I just grepped the DSDTs I have here and this is what I got:DSDT.c1s.dsl: Name (SNI4, 0x344A0001) DSDT.c71bw.dsl: Name (SNI4, 0x344A0001)
(snip)
The second byte seems to be the most consistent here - 0x4a for the models currently handled by the nc code, 0x4d for the tt and z, 0x55 for the p. I've no idea whether this is a monotonically increasing version string or a bitmask of supported functionality, but it ought to be enough to key off to begin with.
Quoted 4 lines
want to try to push your patch to mainline or would you prefer to wait? IMO pushing it and eventually fixing support for 0x344a000[10] models is fine. After all your
snc_setupcode could be easily plugged into the DMI list for the time being and Z and TT users would be happy.
Might as well push it and see what happens?
Signature · 1 line
Matthew Garrett | [email protected]
Mattia Dongili
maintainerQuoted 9 lines · Matthew Garrett
Quoted 6 lines · Mattia Dongili
sure, that DMI whitelist is already annoying in its current shape. Getting the ACPI tables to tell us what SNC version we are looking at would be so much better.
I just grepped the DSDTs I have here and this is what I got:DSDT.c1s.dsl: Name (SNI4, 0x344A0001) DSDT.c71bw.dsl: Name (SNI4, 0x344A0001)
Quoted 7 lines
(snip)
The second byte seems to be the most consistent here -
0x4afor the models currently handled by the nc code,0x4dfor the tt and z,0x55for the p. I've no idea whether this is a monotonically increasing version string or a bitmask of supported functionality, but it ought to be enough to key off to begin with.
Oh, do you have a vaio type P DSDT to share?
Quoted 6 lines
Quoted 4 lines
want to try to push your patch to mainline or would you prefer to wait? IMO pushing it and eventually fixing support for 0x344a000[10] models is fine. After all your
snc_setupcode could be easily plugged into the DMI list for the time being and Z and TT users would be happy.Might as well push it and see what happens?
Sure, if you're ok I'll apply the patch you sent just changing the rfkill_free and send the whole patch-set to Len tomorrow morning (JST).
cheers
Signature · 2 lines
mattia :wq!
Mattia Dongili
maintainerQuoted 11 lines · Matthias Welwarsky
Quoted 2 lines · On Saturday 21 March 2009 12:22:35 Matthias Welwarsky wrote:
I've also backported Matthews patch to the standard Suse 11.1 kernel so that we can test it more easily.
Done, looks quite promising. The "wireless" switch on the Z21 works now, and apparently there is some script magic in opensuse that operates all rfkill switches, so it kills all wireless devices at once. Not bad.
The new init sequence for SN07 also enables all the special keys, even the speed/stamina switch now generates an ACPI event, as well as S1, S2 and Eject. But you cannot distinguish them, they all report the same event.
You mey need the additional SN07 call to get the actual key press, see the code in sony_acpi_notify.
Signature · 2 lines
mattia :wq!
Quoted 1 line · Mattia Dongili
Oh, do you have a vaio type P DSDT to share?
Attached. I'm now fairly sure that the second byte returned by SN00(4) is the gross version, with the leading byte being a subversion(!?). Machines with 0x4a in the second byte have the following set of methods (as called by SN07):
0x33: 0x34: 0x36: 0x37:
0, 0x0101 0x0101 0x0101 0x0101
1, 0x0102 0x0102 0x0102 0x0102
2, 0x0100 0x0100 0x0100 0x0100
3, 0x0104 0x0104
4, 0x0107 0x010F 0x0107 0x010F
5, 0x0106 0x0106
6, 0x0000 0x0113
7, 0x0111 0x010A
C, 0x010C
D, 0x010D 0x010D
E, 0x0105 0x0105 0x0105 0x0105
F, 0x0103 0x0103 0x0103
They're indexed by the leading byte. Machines with 0x4d as the second byte have:
0, 0x0100
1, 0x0101
2, 0x0113
3, 0x0124
4, 0x0126
5, 0x0125
6, 0x011D
7, 0x0121
8, 0x0105
9, 0x0114
a, 0x0119
b, 0x0122
c, 0x0128
d, 0x0115
e, 0x0131
f, 0x12f
Machines with 0x55 as the second byte (only the P, as far as I can tell):
0, 0x100
1, 0x101
2, 0x113
3, 0x124
4, 0x132
5, 0x125
6, 0x11d
7, 0x121
8, 0x105
9, 0x114
a, 0x119
b, 0x122
c, 0x130
d, 0x115
e, 0x131
This actually makes me think I've been taking the wrong approach. I'm now guessing that the numbers returned by SN00 in the 20-2f range are method signatures - 0x100 is hotkeys, 0x124 is rfkill. This fits with the fact that SN07(0) looks to return hotkey values on the Z, whereas that's SN07(2) on the older hardware. Both have 0x100 returned by SN00(0x20). I think if we rewrite the code on this basis we can merge the functionality. I'll try to do that tomorrow and also (with luck) get the hotkey stuff on the Z back up.
Quoted 2 lines
Sure, if you're ok I'll apply the patch you sent just changing the
rfkill_freeand send the whole patch-set to Len tomorrow morning (JST).
Mind waiting until I've tried this rewrite? It'd be nice to know what a bunch more of these methods do, but I guess that's less urgent.
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 13 lines · Matthew Garrett
0x33: 0x34: 0x36: 0x37:0,
0x01010x01010x01010x01011,0x01020x01020x01020x01022,0x01000x01000x01000x0100
3,0x01040x0104
4,0x01070x010F0x01070x010F
5,0x01060x0106
6,0x00000x0113
7,0x01110x010A
C,0x010C
D,0x010D0x010D
E,0x01050x01050x01050x0105F,0x01030x01030x0103
Actually slightly more complicated than that - some are only stored on certain OS versions. Here's a more complete table.
0x33: 0x34: 0x36: 0x37:
0, 0x0101 0x0101 0x0101 0x0101
1, 0x0102 0x0102 0x0102 0x0102
2, 0x0100 0x0100 0x0100 0x0100
3, 0x0104 0x0113 0x0104
4, 0x0107 0x010F 0x0107 0x010F
5, 0x0106 0x0106
6, 0x0113 0x0113
7, 0x0111 0x010A
C, 0x010C
D, 0x010D 0x010D
E, 0x0105 0x0105 0x0105 0x0105
F, 0x0103 0x0103 0x0103
The way that 0x113 moves around leaves me pretty sure that calling SN07 without checking what the function signature is is not a good idea. I'll rewrite my patch.
Signature · 1 line
Matthew Garrett | [email protected]
Hi Matthias,
Quoted 7 lines · Matthias Welwarsky
Quoted 2 lines
Maybe Matthew can take a look and fix the compile warnings in function ‘sony_ovga_dsm’ (there are some!).
Check the attached patch, it does away with the compile warnings. I've removed the warnings in functional code and put ifdefs (ugh!) around debug only code. You can just remove it if you don't like it, I'm only keeping it around for reference.
Against which version of sony-laptop does it apply? Against kernel, against kernel+Matthew, against yours, against kernel+Matthew+mine? I couldn't find out ..
Thanks for taking a look into that
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
AFFPUDDLE (n.)
A puddle which is hidden under a pivoted paving stone. You only know it's there when you step on the paving stone and the puddle shoots up your leg.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 6 lines · Mattia Dongili
Quoted 3 lines
The new init sequence for SN07 also enables all the special keys, even the speed/stamina switch now generates an ACPI event, as well as S1, S2 and Eject. But you cannot distinguish them, they all report the same event.
You mey need the additional SN07 call to get the actual key press, see the code in
sony_acpi_notify.
Hey that would be phantastic to have the keys working, please!
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
DUNBOYNE (n.)
The moment of realisation that the train you have just patiently watched pulling out of the station was the one you were meant to be on.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 33 lines · On Saturday 21 March 2009 16:10:37 Matthew Garrett wrote:
Quoted 13 lines · Matthew Garrett
0x33: 0x34: 0x36: 0x37:0,
0x01010x01010x01010x01011,0x01020x01020x01020x01022,0x01000x01000x01000x0100
3,0x01040x0104
4,0x01070x010F0x01070x010F
5,0x01060x0106
6,0x00000x0113
7,0x01110x010A
C,0x010C
D,0x010D0x010D
E,0x01050x01050x01050x0105F,0x01030x01030x0103Actually slightly more complicated than that - some are only stored on certain OS versions. Here's a more complete table.
0x33: 0x34: 0x36: 0x37:0,
0x01010x01010x01010x0101
1,0x01020x01020x01020x0102
2,0x01000x01000x01000x0100
3,0x01040x01130x0104
4,0x01070x010F0x01070x010F
5,0x01060x0106
6,0x01130x0113
7,0x01110x010A
C,0x010C
D,0x010D0x010D
E,0x01050x01050x01050x0105
F,0x01030x01030x0103
Quoted 3 lines
The way that
0x113moves around leaves me pretty sure that calling SN07 without checking what the function signature is is not a good idea. I'll rewrite my patch.
If that's really a function signature, why are some of the slots empty? If you're supposed to read the CFGI first via SN00, that would not make much sense. However, it makes sense if the function is encoded by the slot and a hole (i.e. Zero) means that the function is not supported or disabled.
If you're right though, it means that "0x124" on all new-style models (those with SN07 method) must always operate the killswitch. I might be able to find that out from the decompiled DSDT. Right now I only checked the Z series DSDTs (Z11 and Z21) and of course they are very similar. But I would be very interested to see the code of functions called for the other "slot 3" methods, like 0x0104 and 0x0113. If you had some DSDTs to share...
regards,
matthias
Mattia Dongili
maintainerQuoted 34 lines · Matthew Garrett
Quoted 13 lines · Matthew Garrett
0x33: 0x34: 0x36: 0x37:0,
0x01010x01010x01010x01011,0x01020x01020x01020x01022,0x01000x01000x01000x0100
3,0x01040x0104
4,0x01070x010F0x01070x010F
5,0x01060x0106
6,0x00000x0113
7,0x01110x010A
C,0x010C
D,0x010D0x010D
E,0x01050x01050x01050x0105F,0x01030x01030x0103Actually slightly more complicated than that - some are only stored on certain OS versions. Here's a more complete table.
0x33: 0x34: 0x36: 0x37:0,
0x01010x01010x01010x0101
1,0x01020x01020x01020x0102
2,0x01000x01000x01000x0100
3,0x01040x01130x0104
4,0x01070x010F0x01070x010F
5,0x01060x0106
6,0x01130x0113
7,0x01110x010A
C,0x010C
D,0x010D0x010D
E,0x01050x01050x01050x0105
F,0x01030x01030x0103
Quoted 3 lines
The way that
0x113moves around leaves me pretty sure that calling SN07 without checking what the function signature is is not a good idea. I'll rewrite my patch.
Ok no rush, I'll wait until you're done before submitting the batch for .30.
PS: you forgot the type P DSDT attachment. ;)
Signature · 2 lines
mattia :wq!
Quoted 9 lines · Matthias Welwarsky
Quoted 3 lines · On Saturday 21 March 2009 16:10:37 Matthew Garrett wrote:
The way that
0x113moves around leaves me pretty sure that calling SN07 without checking what the function signature is is not a good idea. I'll rewrite my patch.If that's really a function signature, why are some of the slots empty? If you're supposed to read the CFGI first via SN00, that would not make much sense. However, it makes sense if the function is encoded by the slot and a hole (i.e. Zero) means that the function is not supported or disabled.
I thought that at first, but 0x113 is the same code on the machines I checked even though it moves around. 0x100 appears to be "Get hotkey event" on the newer hardware even though it's not in slot 2.
Quoted 6 lines
If you're right though, it means that "
0x124" on all new-style models (those with SN07 method) must always operate the killswitch. I might be able to find that out from the decompiled DSDT. Right now I only checked the Z series DSDTs (Z11 and Z21) and of course they are very similar. But I would be very interested to see the code of functions called for the other "slot 3" methods, like0x0104and0x0113. If you had some DSDTs to share...
The P, TT and Z all seem to have 0x124 as killswitch - the 0x113 and 0x104 methods don't seem to be killswitch related, as far as I can tell. Mattia linked to a set of DSDTs earlier in the thread.
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 3 lines · Matthias Welwarsky
The new init sequence for SN07 also enables all the special keys, even the speed/stamina switch now generates an ACPI event, as well as S1, S2 and Eject. But you cannot distinguish them, they all report the same event.
Can you try this? I don't have physical access to an appropriate machine right now, so I've got no idea if it actually works. I suspect that we'll need another table of event mappings for the 0x93 type. This is on top of mainline - it migrates everything over to my guesses about how this interface is meant to be used, adds support for querying the event type in the 0x93 event case and uses it all for the rfkill support as well. If this works I'll send the patch series.
drivers/platform/x86/sony-laptop.c +219 -80
@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h>
@@ -123,6 +124,11 @@ MODULE_PARM_DESC(minor, "default is -1 (automatic)");#endif +static struct rfkill *sony_wifi_rfkill; +static struct rfkill *sony_bluetooth_rfkill; +static struct rfkill *sony_wwan_rfkill; +static struct rfkill *sony_wimax_rfkill; +/*********** Input Devices ***********/ #define SONY_LAPTOP_BUF_SIZE 128
@@ -134,6 +140,7 @@ struct sony_laptop_input_s {spinlock_t fifo_lock;struct workqueue_struct *wq; }; +static struct sony_laptop_input_s sony_laptop_input = { .users =ATOMIC_INIT (0 ), };
@@ -689,6 +696,31 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,return -1 ; } +static int sony_find_snc_handle (int handle) +{ +int i; +int result; + +for (i=0x20 ; i<0x30 ; i++) { +acpi_callsetfunc (sony_nc_acpi_handle,"SN00" , i, &result); +if (result == handle) +return i; + } + +return -1 ; +} + +static int sony_call_snc_handle (int handle,int argument,int *result) +{ +int offset =sony_find_snc_handle (handle); + +if (offset <0 ) +return -1 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , offset | argument, + result); +} +/* * sony_nc_values input/output validate functions */
@@ -809,32 +841,6 @@ struct sony_nc_event {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 (const 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 },
@@ -851,57 +857,17 @@ static struct sony_nc_event sony_C_events[] = { { 0, 0 }, }; -/* SNC-only model map */ -static const 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 FZ 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-FZ" ), - }, - }, - { - .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" ), - }, - }, - { - .ident ="Sony Vaio N 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-N" ), - }, - }, - { } -}; -/* * ACPI callbacks */ static void sony_acpi_notify (acpi_handle handle,u32 event,void *data) { -struct sony_nc_event *evmap; +int i;u32 ev = event;int result; -if (ev ==0x92 ) { +if (ev ==0x92 || ev ==0x93 ) { +int origev = ev;/* 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
@@ -913,20 +879,23 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)* 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 ) +if (sony_call_snc_handle (0x100 ,0x200 , &result))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; +for (i=0 ; sony_C_events[i].data; i++) { +if (sony_C_events[i].data == ev) { + ev = sony_C_events[i].event;break ; } } +if (!sony_C_events[i].data) + printk(KERN_INFO DRV_PFX "Unknown event: %x %x\n", + origev, ev); + } +dprintk ("sony_acpi_notify, event: 0x%.2x\n" , ev);sony_laptop_report_input_event (ev);acpi_bus_generate_proc_event (sony_nc_acpi_device,1 , ev);
@@ -953,9 +922,24 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,/* * ACPI device */ +static int sony_nc_function_setup (struct acpi_device *device) { +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); + +/* Setup hotkeys */ +sony_call_snc_handle (0x0100 ,0 , &result); +sony_call_snc_handle (0x0101 ,0 , &result); +sony_call_snc_handle (0x0102 ,0x100 , &result); + +return 0 ; +} +static int sony_nc_resume (struct acpi_device *device) {struct sony_nc_value *item; +acpi_handle handle;for (item = sony_nc_values; item->name; item++) {int ret;
@@ -970,13 +954,156 @@ static int sony_nc_resume(struct acpi_device *device) } } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* set the last requested brightness level */ if (sony_backlight_device && !sony_backlight_update_status (sony_backlight_device)) printk(KERN_WARNING DRV_PFX "unable to restore brightness level\n"); -/* re-initialize models with specific requirements */ -dmi_check_system (sony_nc_ids); +return 0 ; +} + +static void sony_nc_rfkill_cleanup (void ) +{ +if (sony_wifi_rfkill) +rfkill_unregister (sony_wifi_rfkill); +if (sony_bluetooth_rfkill) +rfkill_unregister (sony_bluetooth_rfkill); +if (sony_wwan_rfkill) +rfkill_unregister (sony_wwan_rfkill); +if (sony_wimax_rfkill) +rfkill_unregister (sony_wimax_rfkill); +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; + +sony_call_snc_handle (0x124 , (long ) data, &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int argument = (long ) data +1 ; + +if (state ==RFKILL_STATE_UNBLOCKED ) + argument |=0xff0000 ; + +return sony_call_snc_handle (0x124 , argument, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN ); +if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)0x300 ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_free (sony_wifi_rfkill); +return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)0x500 ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_free (sony_bluetooth_rfkill); +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)0x700 ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_free (sony_wwan_rfkill); +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)0x900 ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_free (sony_wimax_rfkill); +return err; +} + +static int sony_nc_rfkill_setup (struct acpi_device *device) +{ +int result, ret; + +if (sony_find_snc_handle (0x124 ) ==-1 ) +return -1 ; + + ret =sony_call_snc_handle (0x124 ,0xb00 , &result); +if (ret) { + printk(KERN_INFO DRV_PFX + "Unable to enumerate rfkill devices: %x\n", ret); +return ret; + } + +if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device);return 0 ; }
@@ -1024,6 +1151,19 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); +sony_nc_rfkill_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {
@@ -1063,9 +1203,6 @@ 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;
@@ -1131,6 +1268,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_nc_rfkill_cleanup ();return result; }
@@ -1156,6 +1294,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_nc_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;
Signature · 1 line
Matthew Garrett | [email protected]
Actually, try this one instead - obvious think in the first one.
drivers/platform/x86/sony-laptop.c +219 -80
@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h>
@@ -123,6 +124,11 @@ MODULE_PARM_DESC(minor, "default is -1 (automatic)");#endif +static struct rfkill *sony_wifi_rfkill; +static struct rfkill *sony_bluetooth_rfkill; +static struct rfkill *sony_wwan_rfkill; +static struct rfkill *sony_wimax_rfkill; +/*********** Input Devices ***********/ #define SONY_LAPTOP_BUF_SIZE 128
@@ -134,6 +140,7 @@ struct sony_laptop_input_s {spinlock_t fifo_lock;struct workqueue_struct *wq; }; +static struct sony_laptop_input_s sony_laptop_input = { .users =ATOMIC_INIT (0 ), };
@@ -689,6 +696,31 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,return -1 ; } +static int sony_find_snc_handle (int handle) +{ +int i; +int result; + +for (i=0x20 ; i<0x30 ; i++) { +acpi_callsetfunc (sony_nc_acpi_handle,"SN00" , i, &result); +if (result == handle) +return i-0x20 ; + } + +return -1 ; +} + +static int sony_call_snc_handle (int handle,int argument,int *result) +{ +int offset =sony_find_snc_handle (handle); + +if (offset <0 ) +return -1 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , offset | argument, + result); +} +/* * sony_nc_values input/output validate functions */
@@ -809,32 +841,6 @@ struct sony_nc_event {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 (const 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 },
@@ -851,57 +857,17 @@ static struct sony_nc_event sony_C_events[] = { { 0, 0 }, }; -/* SNC-only model map */ -static const 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 FZ 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-FZ" ), - }, - }, - { - .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" ), - }, - }, - { - .ident ="Sony Vaio N 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-N" ), - }, - }, - { } -}; -/* * ACPI callbacks */ static void sony_acpi_notify (acpi_handle handle,u32 event,void *data) { -struct sony_nc_event *evmap; +int i;u32 ev = event;int result; -if (ev ==0x92 ) { +if (ev ==0x92 || ev ==0x93 ) { +int origev = ev;/* 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
@@ -913,20 +879,23 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)* 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 ) +if (sony_call_snc_handle (0x100 ,0x200 , &result))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; +for (i=0 ; sony_C_events[i].data; i++) { +if (sony_C_events[i].data == ev) { + ev = sony_C_events[i].event;break ; } } +if (!sony_C_events[i].data) + printk(KERN_INFO DRV_PFX "Unknown event: %x %x\n", + origev, ev); + } +dprintk ("sony_acpi_notify, event: 0x%.2x\n" , ev);sony_laptop_report_input_event (ev);acpi_bus_generate_proc_event (sony_nc_acpi_device,1 , ev);
@@ -953,9 +922,24 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,/* * ACPI device */ +static int sony_nc_function_setup (struct acpi_device *device) { +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); + +/* Setup hotkeys */ +sony_call_snc_handle (0x0100 ,0 , &result); +sony_call_snc_handle (0x0101 ,0 , &result); +sony_call_snc_handle (0x0102 ,0x100 , &result); + +return 0 ; +} +static int sony_nc_resume (struct acpi_device *device) {struct sony_nc_value *item; +acpi_handle handle;for (item = sony_nc_values; item->name; item++) {int ret;
@@ -970,13 +954,156 @@ static int sony_nc_resume(struct acpi_device *device) } } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* set the last requested brightness level */ if (sony_backlight_device && !sony_backlight_update_status (sony_backlight_device)) printk(KERN_WARNING DRV_PFX "unable to restore brightness level\n"); -/* re-initialize models with specific requirements */ -dmi_check_system (sony_nc_ids); +return 0 ; +} + +static void sony_nc_rfkill_cleanup (void ) +{ +if (sony_wifi_rfkill) +rfkill_unregister (sony_wifi_rfkill); +if (sony_bluetooth_rfkill) +rfkill_unregister (sony_bluetooth_rfkill); +if (sony_wwan_rfkill) +rfkill_unregister (sony_wwan_rfkill); +if (sony_wimax_rfkill) +rfkill_unregister (sony_wimax_rfkill); +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; + +sony_call_snc_handle (0x124 , (long ) data, &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int argument = (long ) data +1 ; + +if (state ==RFKILL_STATE_UNBLOCKED ) + argument |=0xff0000 ; + +return sony_call_snc_handle (0x124 , argument, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN ); +if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)0x300 ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_free (sony_wifi_rfkill); +return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)0x500 ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_free (sony_bluetooth_rfkill); +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)0x700 ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_free (sony_wwan_rfkill); +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)0x900 ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_free (sony_wimax_rfkill); +return err; +} + +static int sony_nc_rfkill_setup (struct acpi_device *device) +{ +int result, ret; + +if (sony_find_snc_handle (0x124 ) ==-1 ) +return -1 ; + + ret =sony_call_snc_handle (0x124 ,0xb00 , &result); +if (ret) { + printk(KERN_INFO DRV_PFX + "Unable to enumerate rfkill devices: %x\n", ret); +return ret; + } + +if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device);return 0 ; }
@@ -1024,6 +1151,19 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); +sony_nc_rfkill_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {
@@ -1063,9 +1203,6 @@ 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;
@@ -1131,6 +1268,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_nc_rfkill_cleanup ();return result; }
@@ -1156,6 +1294,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_nc_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 1 line · Matthew Garrett
Actually, try this one instead - obvious think in the first one.
Tried it but acpi_listen still reports the same events:
sony/hotkey SNC 00000001 00000090
sony/hotkey SNC 00000001 00000090
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
FIUNARY (n.)
The safe place you put something and then forget where it was.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 6 lines · Norbert Preining
Quoted 1 line · Matthew Garrett
Actually, try this one instead - obvious think in the first one.
Tried it but
acpi_listenstill reports the same events:
sony/hotkey SNC 00000001 00000090
sony/hotkey SNC 00000001 00000090
Hm. Try changing 0x93 to 0x90 in the notify handler.
Signature · 5 lines
Matthew Garrett | [email protected] -- 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
Quoted 4 lines · Matthew Garrett
Quoted 2 lines
sony/hotkey SNC 00000001 00000090
sony/hotkey SNC 00000001 00000090Hm. Try changing
0x93to0x90in the notify handler.
That did the trick, now different syms are reported.
BUT:
- suddenly the sony-laptop module is convinced that the *hardware* rfkill switch is always turned on, always. Not even reloading an older sony-laptop helped. Rebooting neither. Shutting down and rebooting with an older sony-laptop as default made wifi show up again. I am not sure if cold booting into the latest version of your patch will work, haven't tried till now, sorry, will do tomorrow.
- S1 and S2 do adjustment of the brightness, while Fn-F5 and Fn-F6 do not do anything, but this is probably only configuration stuff.
Thanks as usual
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
TROSSACHS (pl.n.) The useless epaulettes on an expensive raincoat.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 7 lines · Norbert Preining
BUT:
- suddenly the sony-laptop module is convinced that the *hardware* rfkill switch is always turned on, always. Not even reloading an older sony-laptop helped. Rebooting neither. Shutting down and rebooting with an older sony-laptop as default made wifi show up again. I am not sure if cold booting into the latest version of your patch will work, haven't tried till now, sorry, will do tomorrow.
Hmm. Don't /think/ I did anything that should affect that, but it's possible. If it's reproducable, can you try commenting out the sony_call_snc_handle calls in sony_nc_function_setup and see if they change the behaviour? You'll probably need to reboot in between.
Quoted 2 lines
- S1 and S2 do adjustment of the brightness, while Fn-F5 and Fn-F6 do not do anything, but this is probably only configuration stuff.
Ok, sounds like the mapping needs to be changed. Can you let me know which ACPI events are generated for each key?
Signature · 1 line
Matthew Garrett | [email protected]
Mattia Dongili
maintainerQuoted 15 lines · Matthew Garrett
Quoted 7 lines · Norbert Preining
BUT:
- suddenly the sony-laptop module is convinced that the *hardware* rfkill switch is always turned on, always. Not even reloading an older sony-laptop helped. Rebooting neither. Shutting down and rebooting with an older sony-laptop as default made wifi show up again. I am not sure if cold booting into the latest version of your patch will work, haven't tried till now, sorry, will do tomorrow.Hmm. Don't /think/ I did anything that should affect that, but it's possible. If it's reproducable, can you try commenting out the
sony_call_snc_handlecalls insony_nc_function_setupand see if they change the behaviour? You'll probably need to reboot in between.
Quoted 5 lines
Quoted 2 lines
- S1 and S2 do adjustment of the brightness, while Fn-F5 and Fn-F6 do not do anything, but this is probably only configuration stuff.
Ok, sounds like the mapping needs to be changed. Can you let me know which ACPI events are generated for each key?
Yes it does.
A vaio SR user sent me this list for 0x9c that after a call to SN07(202) becomes:
+ { 0x81, SONYPI_EVENT_MODEKEY_PRESSED },
+ { 0x01, SONYPI_EVENT_ANYBUTTON_RELEASED },
+ { 0x82, SONYPI_EVENT_PKEY_P1 },
+ { 0x02, SONYPI_EVENT_ANYBUTTON_RELEASED },
+ { 0x83, SONYPI_EVENT_PKEY_P2 },
+ { 0x03, SONYPI_EVENT_ANYBUTTON_RELEASED },
+ { 0x84, SONYPI_EVENT_PKEY_P3 },
+ { 0x04, SONYPI_EVENT_ANYBUTTON_RELEASED },
+ { 0x85, SONYPI_EVENT_PKEY_P4 },
+ { 0x05, SONYPI_EVENT_ANYBUTTON_RELEASED },
+ { 0x86, SONYPI_EVENT_PKEY_P5 },
+ { 0x06, SONYPI_EVENT_ANYBUTTON_RELEASED },
+ { 0x87, SONYPI_EVENT_SETTINGKEY_PRESSED },
+ { 0x07, SONYPI_EVENT_ANYBUTTON_RELEASED },
+ { 0, 0 },Signature · 2 lines
mattia :wq!
Quoted 7 lines · Mattia Dongili
Quoted 2 lines · Matthew Garrett
Ok, sounds like the mapping needs to be changed. Can you let me know which ACPI events are generated for each key?
Yes it does.
A vaio SR user sent me this list for0x9cthat after a call to SN07(202) becomes:
0x9c as well? Interesting. Easy enough to generalise that code, I guess. If we don't have a match, maybe we should just send the scancode with KEY_UNKNOWN and let hal remap them?
Signature · 1 line
Matthew Garrett | [email protected]
Mattia Dongili
maintainerQuoted 10 lines · Matthew Garrett
Quoted 7 lines · Mattia Dongili
Quoted 2 lines · Matthew Garrett
Ok, sounds like the mapping needs to be changed. Can you let me know which ACPI events are generated for each key?
Yes it does.
A vaio SR user sent me this list for0x9cthat after a call to SN07(202) becomes:
0x9cas well? Interesting. Easy enough to generalise that code, I guess.
well, I was thinking of a two layer lookup keyed on the event code (0x9[02ce]).
Quoted 2 lines
If we don't have a match, maybe we should just send the scancode with
KEY_UNKNOWNand let hal remap them?
the problem is that the decoded keypress (after the SN07 call) generates duplicates, i.e.: 0x81 is fn+f1 for the 0x92 case and some "Mode" key for 0x9c the an SR model.
I guess sending the whole combination as the scancode would do the trick (0x9c81).
But as long as we can make it consistent with what sony-laptop currently sends to userspace then we should try to have a map.
Signature · 2 lines
mattia :wq!
Quoted 5 lines · Mattia Dongili
the problem is that the decoded keypress (after the SN07 call) generates duplicates, i.e.:
0x81is fn+f1 for the0x92case and some "Mode" key for0x9cthe an SR model.
I guess sending the whole combination as the scancode would do the trick (0x9c81).
Mm. That ought to work. Still, if we can get a map from the new models, it might not be too urgent.
Signature · 1 line
Matthew Garrett | [email protected]
Hi Matthew,
Quoted 9 lines · Matthew Garrett
Quoted 6 lines
- suddenly the sony-laptop module is convinced that the *hardware* rfkill switch is always turned on, always. Not even reloading an older sony-laptop helped. Rebooting neither. Shutting down and rebooting with an older sony-laptop as default made wifi show up again. I am not sure if cold booting into the latest version of your patch will work, haven't tried till now, sorry, will do tomorrow.
Hmm. Don't /think/ I did anything that should affect that, but it's possible. If it's reproducable, can you try commenting out the
Forget it, as I said, I will retry cold booting and that made it work without a problem.
Quoted 5 lines
Quoted 2 lines
- S1 and S2 do adjustment of the brightness, while Fn-F5 and Fn-F6 do not do anything, but this is probably only configuration stuff.
Ok, sounds like the mapping needs to be changed. Can you let me know which ACPI events are generated for each key?
S1
sony/hotkey SNC 00000001 00000090 sony/hotkey SNC 00000001 00000010
S2
sony/hotkey SNC 00000001 00000091 sony/hotkey SNC 00000001 00000011 Fn-F5 (brightness -) sony/hotkey SNC 00000001 00000010 sony/hotkey SNC 00000001 0000003b Fn-F6 (brightness +) sony/hotkey SNC 00000001 00000011 sony/hotkey SNC 00000001 0000003b Fn-F7 (switch output mode) sony/hotkey SNC 00000001 00000012 sony/hotkey SNC 00000001 0000003b Fn-F9 (Zoom minus) sony/hotkey SNC 00000001 00000089 sony/hotkey SNC 00000001 00000009 Fn-F10 sony/hotkey SNC 00000001 00000015 sony/hotkey SNC 00000001 0000003b Fn-F12 (suspend to disk) (not sure about that, it actuallyDID suspend and I am not sure. At least NOW I know that S2D works ;-) sony/hotkey SNC 00000001 00000017 sony/hotkey SNC 00000001 0000003b
Hope that helps
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
SHIFNAL (n.,vb.)
An awkward shuffling walk caused by two or more people in a hurry accidentally getting into the same segment of revolving door. A similar effect is achieved by people entering three-legged races unwisely joined at the neck instead of the ankles.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 8 lines · Mattia Dongili
A vaio SR user sent me this list for
0x9cthat after a call to SN07(202) becomes:(quoted diff) +5
-0+ { 0x81, SONYPI_EVENT_MODEKEY_PRESSED }, + { 0x01, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x82, SONYPI_EVENT_PKEY_P1 }, + { 0x02, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x83, SONYPI_EVENT_PKEY_P2 },
Review
Quoted 10 lines
(quoted diff) +10
-0+ { 0x03, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x84, SONYPI_EVENT_PKEY_P3 }, + { 0x04, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x85, SONYPI_EVENT_PKEY_P4 }, + { 0x05, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x86, SONYPI_EVENT_PKEY_P5 }, + { 0x06, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x87, SONYPI_EVENT_SETTINGKEY_PRESSED }, + { 0x07, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0, 0 },
Couldn't test that since several SONYPI_EVENT* are not defined in current -rc8 plus Matthew patch. And I didn't want to try it out.
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
BABWORTH
Something which justifies having a really good cry.
--- Douglas Adams, The Meaning of Liff
--
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
Mattia Dongili
maintainerQuoted 20 lines · Norbert Preining
Quoted 8 lines · Mattia Dongili
A vaio SR user sent me this list for
0x9cthat after a call to SN07(202) becomes:(quoted diff) +5
-0+ { 0x81, SONYPI_EVENT_MODEKEY_PRESSED }, + { 0x01, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x82, SONYPI_EVENT_PKEY_P1 }, + { 0x02, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x83, SONYPI_EVENT_PKEY_P2 },Review
Quoted 10 lines
(quoted diff) +10
-0+ { 0x03, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x84, SONYPI_EVENT_PKEY_P3 }, + { 0x04, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x85, SONYPI_EVENT_PKEY_P4 }, + { 0x05, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x86, SONYPI_EVENT_PKEY_P5 }, + { 0x06, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0x87, SONYPI_EVENT_SETTINGKEY_PRESSED }, + { 0x07, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0, 0 },
Quoted 2 lines
Couldn't test that since several SONYPI_EVENT* are not defined in current -rc8 plus Matthew patch. And I didn't want to try it out.
the above code was not meant to be tested. What you should do instead is changing the line (after Matthew's patch):
if (ev == 0x92 || ev == 0x93) {
in sony_acpi_notify to
if (ev == 0x92 || ev == 0x93 || ev == 0x90) {load the driver with debug=1 and press the unrecognized Fn keys. You *should* get a bunch of "unknown input event XX" in the kernel log, with those we can build the necessary mappings for your specific model (hopefully not just yours).
Signature · 6 lines
mattia :wq! -- 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
Ok, thanks. Can you try this instead of the other patches? I'm a touch concerned about the release events on the S1 and S2 buttons looking like the events for some of the Fn keys, which may mean that we need to find some way of distinguishing them.
drivers/platform/x86/sony-laptop.c +240 -80
@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h>
@@ -123,6 +124,11 @@ MODULE_PARM_DESC(minor, "default is -1 (automatic)");#endif +static struct rfkill *sony_wifi_rfkill; +static struct rfkill *sony_bluetooth_rfkill; +static struct rfkill *sony_wwan_rfkill; +static struct rfkill *sony_wimax_rfkill; +/*********** Input Devices ***********/ #define SONY_LAPTOP_BUF_SIZE 128
@@ -134,6 +140,7 @@ struct sony_laptop_input_s {spinlock_t fifo_lock;struct workqueue_struct *wq; }; +static struct sony_laptop_input_s sony_laptop_input = { .users =ATOMIC_INIT (0 ), };
@@ -689,6 +696,31 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,return -1 ; } +static int sony_find_snc_handle (int handle) +{ +int i; +int result; + +for (i=0x20 ; i<0x30 ; i++) { +acpi_callsetfunc (sony_nc_acpi_handle,"SN00" , i, &result); +if (result == handle) +return i-0x20 ; + } + +return -1 ; +} + +static int sony_call_snc_handle (int handle,int argument,int *result) +{ +int offset =sony_find_snc_handle (handle); + +if (offset <0 ) +return -1 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , offset | argument, + result); +} +/* * sony_nc_values input/output validate functions */
@@ -809,33 +841,21 @@ struct sony_nc_event {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 (const 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_90_events[] = { + {0x90 ,SONYPI_EVENT_PKEY_P1 }, + {0x91 ,SONYPI_EVENT_PKEY_P1 }, + {0x10 ,SONYPI_EVENT_FNKEY_F5 }, + {0x11 ,SONYPI_EVENT_FNKEY_F6 }, + {0x12 ,SONYPI_EVENT_FNKEY_F7 }, + {0x89 ,SONYPI_EVENT_FNKEY_F9 }, + {0x15 ,SONYPI_EVENT_FNKEY_F10 }, + {0x17 ,SONYPI_EVENT_FNKEY_F12 }, + {0x3b ,SONYPI_EVENT_FNKEY_RELEASED }, + {0x09 ,SONYPI_EVENT_FNKEY_RELEASED }, + {0 ,0 }, +}; -static struct sony_nc_event sony_C_events[] = { +static struct sony_nc_event sony_92_events[] = { {0x81 ,SONYPI_EVENT_FNKEY_F1 }, {0x01 ,SONYPI_EVENT_FNKEY_RELEASED }, {0x85 ,SONYPI_EVENT_FNKEY_F5 },
@@ -851,57 +871,18 @@ static struct sony_nc_event sony_C_events[] = { { 0, 0 }, }; -/* SNC-only model map */ -static const 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 FZ 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-FZ" ), - }, - }, - { - .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" ), - }, - }, - { - .ident ="Sony Vaio N 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-N" ), - }, - }, - { } -}; -/* * ACPI callbacks */ static void sony_acpi_notify (acpi_handle handle,u32 event,void *data) { -struct sony_nc_event *evmap;u32 ev = event;int result; -if (ev ==0x92 ) { +if (ev ==0x90 || ev ==0x92 ) { +struct sony_nc_event *events; +int origev = ev; +/* 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
@@ -913,20 +894,29 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)* 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 ) +if (sony_call_snc_handle (0x100 ,0x200 , &result))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; +if (origev ==0x90 ) + events = sony_90_events; +else + events = sony_92_events; + +while (events->event) { +if (events->data == ev) { + ev = events->event;break ; } + events++; } +if (!events->data) + printk(KERN_INFO DRV_PFX "Unknown event: %x %x\n", + origev, ev); + } +dprintk ("sony_acpi_notify, event: 0x%.2x\n" , ev);sony_laptop_report_input_event (ev);acpi_bus_generate_proc_event (sony_nc_acpi_device,1 , ev);
@@ -953,9 +943,24 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,/* * ACPI device */ +static int sony_nc_function_setup (struct acpi_device *device) { +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); + +/* Setup hotkeys */ +sony_call_snc_handle (0x0100 ,0 , &result); +sony_call_snc_handle (0x0101 ,0 , &result); +sony_call_snc_handle (0x0102 ,0x100 , &result); + +return 0 ; +} +static int sony_nc_resume (struct acpi_device *device) {struct sony_nc_value *item; +acpi_handle handle;for (item = sony_nc_values; item->name; item++) {int ret;
@@ -970,13 +975,156 @@ static int sony_nc_resume(struct acpi_device *device) } } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* set the last requested brightness level */ if (sony_backlight_device && !sony_backlight_update_status (sony_backlight_device)) printk(KERN_WARNING DRV_PFX "unable to restore brightness level\n"); -/* re-initialize models with specific requirements */ -dmi_check_system (sony_nc_ids); +return 0 ; +} + +static void sony_nc_rfkill_cleanup (void ) +{ +if (sony_wifi_rfkill) +rfkill_unregister (sony_wifi_rfkill); +if (sony_bluetooth_rfkill) +rfkill_unregister (sony_bluetooth_rfkill); +if (sony_wwan_rfkill) +rfkill_unregister (sony_wwan_rfkill); +if (sony_wimax_rfkill) +rfkill_unregister (sony_wimax_rfkill); +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; + +sony_call_snc_handle (0x124 , (long ) data, &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int argument = (long ) data +1 ; + +if (state ==RFKILL_STATE_UNBLOCKED ) + argument |=0xff0000 ; + +return sony_call_snc_handle (0x124 , argument, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN ); +if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)0x300 ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_free (sony_wifi_rfkill); +return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)0x500 ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_free (sony_bluetooth_rfkill); +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)0x700 ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_free (sony_wwan_rfkill); +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)0x900 ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_free (sony_wimax_rfkill); +return err; +} + +static int sony_nc_rfkill_setup (struct acpi_device *device) +{ +int result, ret; + +if (sony_find_snc_handle (0x124 ) ==-1 ) +return -1 ; + + ret =sony_call_snc_handle (0x124 ,0xb00 , &result); +if (ret) { + printk(KERN_INFO DRV_PFX + "Unable to enumerate rfkill devices: %x\n", ret); +return ret; + } + +if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device);return 0 ; }
@@ -1024,6 +1172,19 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); +sony_nc_rfkill_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {
@@ -1063,9 +1224,6 @@ 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;
@@ -1131,6 +1289,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_nc_rfkill_cleanup ();return result; }
@@ -1156,6 +1315,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_nc_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;
Signature · 1 line
Matthew Garrett | [email protected]
Hi you two,
Quoted 4 lines · Matthew Garrett
Ok, thanks. Can you try this instead of the other patches? I'm a touch concerned about the release events on the S1 and S2 buttons looking like the events for some of the Fn keys, which may mean that we need to find some way of distinguishing them.
I tried your patch together with Mattia's remark:
Quoted 5 lines · Mattia Dongili
the above code was not meant to be tested. What you should do instead is changing the line (after Matthew's patch):
if (ev == 0x92 || ev == 0x93) { in sony_acpi_notify to if (ev == 0x92 || ev == 0x93 || ev == 0x90) {
and it works fine.
Regarding the key press events I did what Mattia said (loading with debug=1): Some created an "Unknown event" in the log, some not.
S1:
sony-laptop: sony_acpi_notify, event: 0x20
sony-laptop: sony_acpi_notify, event: 0x10
S2:
sony-laptop: sony_acpi_notify, event: 0x20
sony-laptop: sony_acpi_notify, event: 0x11
Fn-F5 (brightness -)
sony-laptop: Unknown event: 90 85
sony-laptop: sony_acpi_notify, event: 0x85
sony-laptop: sony_laptop_report_input_event, event not known: 133
sony-laptop: unknown input event 85
sony-laptop: Unknown event: 90 5
sony-laptop: sony_acpi_notify, event: 0x05
Fn-F6 (brightness +)
sony-laptop: Unknown event: 90 86
sony-laptop: sony_acpi_notify, event: 0x86
sony-laptop: sony_laptop_report_input_event, event not known: 134
sony-laptop: unknown input event 86
sony-laptop: Unknown event: 90 6
sony-laptop: sony_acpi_notify, event: 0x06
sony-laptop: unknown input event 06
Fn-F7 (switch output mode)
sony-laptop: Unknown event: 90 87
sony-laptop: sony_acpi_notify, event: 0x87
sony-laptop: sony_laptop_report_input_event, event not known: 135
sony-laptop: unknown input event 87
sony-laptop: Unknown event: 90 7
sony-laptop: sony_acpi_notify, event: 0x07
Fn-F9 (Zoom minus)
sony-laptop: sony_acpi_notify, event: 0x14
sony-laptop: sony_acpi_notify, event: 0x3b
Fn-F10 (Zoom plus)
sony-laptop: Unknown event: 90 8a
sony-laptop: sony_acpi_notify, event: 0x8a
sony-laptop: sony_laptop_report_input_event, event not known: 138
sony-laptop: unknown input event 8a
sony-laptop: Unknown event: 90 a
sony-laptop: sony_acpi_notify, event: 0x0a
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
LULWORTH (n.)
Measure of conversation. A lulworth defines the amount of the length, loudness and embarrassment of a statement you make when everyone else in the room unaccountably stops talking at the same time.
--- Douglas Adams, The Meaning of Liff
--
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
Interesting. These don't seem to match your earlier numbers, but instead look much more like the 0x92-style events. Do any of the other keys generate events? This one should be consistent with the events you're reporting.
drivers/platform/x86/sony-laptop.c +244 -80
@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h>
@@ -123,6 +124,11 @@ MODULE_PARM_DESC(minor, "default is -1 (automatic)");#endif +static struct rfkill *sony_wifi_rfkill; +static struct rfkill *sony_bluetooth_rfkill; +static struct rfkill *sony_wwan_rfkill; +static struct rfkill *sony_wimax_rfkill; +/*********** Input Devices ***********/ #define SONY_LAPTOP_BUF_SIZE 128
@@ -134,6 +140,7 @@ struct sony_laptop_input_s {spinlock_t fifo_lock;struct workqueue_struct *wq; }; +static struct sony_laptop_input_s sony_laptop_input = { .users =ATOMIC_INIT (0 ), };
@@ -689,6 +696,31 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,return -1 ; } +static int sony_find_snc_handle (int handle) +{ +int i; +int result; + +for (i=0x20 ; i<0x30 ; i++) { +acpi_callsetfunc (sony_nc_acpi_handle,"SN00" , i, &result); +if (result == handle) +return i-0x20 ; + } + +return -1 ; +} + +static int sony_call_snc_handle (int handle,int argument,int *result) +{ +int offset =sony_find_snc_handle (handle); + +if (offset <0 ) +return -1 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , offset | argument, + result); +} +/* * sony_nc_values input/output validate functions */
@@ -809,33 +841,25 @@ struct sony_nc_event {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 (const 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_90_events[] = { + {0x10 ,SONYPI_EVENT_PKEY_P1 }, + {0x11 ,SONYPI_EVENT_PKEY_P1 }, + {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 }, + {0x89 ,SONYPI_EVENT_FNKEY_F9 }, + {0x09 ,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 }, +}; -static struct sony_nc_event sony_C_events[] = { +static struct sony_nc_event sony_92_events[] = { {0x81 ,SONYPI_EVENT_FNKEY_F1 }, {0x01 ,SONYPI_EVENT_FNKEY_RELEASED }, {0x85 ,SONYPI_EVENT_FNKEY_F5 },
@@ -851,57 +875,18 @@ static struct sony_nc_event sony_C_events[] = { { 0, 0 }, }; -/* SNC-only model map */ -static const 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 FZ 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-FZ" ), - }, - }, - { - .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" ), - }, - }, - { - .ident ="Sony Vaio N 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-N" ), - }, - }, - { } -}; -/* * ACPI callbacks */ static void sony_acpi_notify (acpi_handle handle,u32 event,void *data) { -struct sony_nc_event *evmap;u32 ev = event;int result; -if (ev ==0x92 ) { +if (ev ==0x90 || ev ==0x92 ) { +struct sony_nc_event *events; +int origev = ev; +/* 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
@@ -913,20 +898,29 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)* 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 ) +if (sony_call_snc_handle (0x100 ,0x200 , &result))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; +if (origev ==0x90 ) + events = sony_90_events; +else + events = sony_92_events; + +while (events->event) { +if (events->data == ev) { + ev = events->event;break ; } + events++; } +if (!events->data) + printk(KERN_INFO DRV_PFX "Unknown event: %x %x\n", + origev, ev); + } +dprintk ("sony_acpi_notify, event: 0x%.2x\n" , ev);sony_laptop_report_input_event (ev);acpi_bus_generate_proc_event (sony_nc_acpi_device,1 , ev);
@@ -953,9 +947,24 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,/* * ACPI device */ +static int sony_nc_function_setup (struct acpi_device *device) { +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); + +/* Setup hotkeys */ +sony_call_snc_handle (0x0100 ,0 , &result); +sony_call_snc_handle (0x0101 ,0 , &result); +sony_call_snc_handle (0x0102 ,0x100 , &result); + +return 0 ; +} +static int sony_nc_resume (struct acpi_device *device) {struct sony_nc_value *item; +acpi_handle handle;for (item = sony_nc_values; item->name; item++) {int ret;
@@ -970,13 +979,156 @@ static int sony_nc_resume(struct acpi_device *device) } } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* set the last requested brightness level */ if (sony_backlight_device && !sony_backlight_update_status (sony_backlight_device)) printk(KERN_WARNING DRV_PFX "unable to restore brightness level\n"); -/* re-initialize models with specific requirements */ -dmi_check_system (sony_nc_ids); +return 0 ; +} + +static void sony_nc_rfkill_cleanup (void ) +{ +if (sony_wifi_rfkill) +rfkill_unregister (sony_wifi_rfkill); +if (sony_bluetooth_rfkill) +rfkill_unregister (sony_bluetooth_rfkill); +if (sony_wwan_rfkill) +rfkill_unregister (sony_wwan_rfkill); +if (sony_wimax_rfkill) +rfkill_unregister (sony_wimax_rfkill); +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; + +sony_call_snc_handle (0x124 , (long ) data, &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int argument = (long ) data +1 ; + +if (state ==RFKILL_STATE_UNBLOCKED ) + argument |=0xff0000 ; + +return sony_call_snc_handle (0x124 , argument, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN ); +if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)0x300 ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_free (sony_wifi_rfkill); +return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)0x500 ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_free (sony_bluetooth_rfkill); +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)0x700 ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_free (sony_wwan_rfkill); +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)0x900 ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_free (sony_wimax_rfkill); +return err; +} + +static int sony_nc_rfkill_setup (struct acpi_device *device) +{ +int result, ret; + +if (sony_find_snc_handle (0x124 ) ==-1 ) +return -1 ; + + ret =sony_call_snc_handle (0x124 ,0xb00 , &result); +if (ret) { + printk(KERN_INFO DRV_PFX + "Unable to enumerate rfkill devices: %x\n", ret); +return ret; + } + +if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device);return 0 ; }
@@ -1024,6 +1176,19 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); +sony_nc_rfkill_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {
@@ -1063,9 +1228,6 @@ 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;
@@ -1131,6 +1293,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_nc_rfkill_cleanup ();return result; }
@@ -1156,6 +1319,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_nc_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 4 lines · Matthew Garrett
Interesting. These don't seem to match your earlier numbers, but instead look much more like the 0x92-style events. Do any of the other keys generate events? This one should be consistent with the events you're reporting.
With this patch I get:
S1
sony-laptop: Unknown event: 90 90
sony-laptop: sony_acpi_notify, event: 0x90
sony-laptop: sony_laptop_report_input_event, event not known: 144
sony-laptop: unknown input event 90
sony-laptop: sony_acpi_notify, event: 0x20
S2
sony-laptop: Unknown event: 90 91
sony-laptop: sony_acpi_notify, event: 0x91
sony-laptop: sony_laptop_report_input_event, event not known: 145
sony-laptop: unknown input event 91
sony-laptop: sony_acpi_notify, event: 0x20
Fn-F5
sony-laptop: sony_acpi_notify, event: 0x10
sony-laptop: sony_acpi_notify, event: 0x3b
Fn-F6
sony-laptop: sony_acpi_notify, event: 0x11
sony-laptop: sony_acpi_notify, event: 0x3b
Fn-F7
sony-laptop: sony_acpi_notify, event: 0x12
sony-laptop: sony_acpi_notify, event: 0x3b
Fn-F9
sony-laptop: sony_acpi_notify, event: 0x14
sony-laptop: sony_acpi_notify, event: 0x3b
Fn-F10
sony-laptop: sony_acpi_notify, event: 0x15
sony-laptop: sony_acpi_notify, event: 0x3b
and now also Fn-F5 and Fn-F6 do the right thing, i.e., adjust the brightness, while S1 and S2 are doing nothing.
Thanks a lot and all the best
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
CLOVIS (q.v.)
One who actually looks forward to putting up the Christmas decorations in the office.
--- Douglas Adams, The Meaning of Liff
--
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
Ok, this one should cover it. Thanks for testing! S1 and S2 will just generate events that can be bound with your desktop environment or xbindkeys or something similar.
Mattia, how do you feel about this approach? If you're happy enough I can send this as a patchset.
drivers/platform/x86/sony-laptop.c +246 -80
@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h>
@@ -123,6 +124,11 @@ MODULE_PARM_DESC(minor, "default is -1 (automatic)");#endif +static struct rfkill *sony_wifi_rfkill; +static struct rfkill *sony_bluetooth_rfkill; +static struct rfkill *sony_wwan_rfkill; +static struct rfkill *sony_wimax_rfkill; +/*********** Input Devices ***********/ #define SONY_LAPTOP_BUF_SIZE 128
@@ -134,6 +140,7 @@ struct sony_laptop_input_s {spinlock_t fifo_lock;struct workqueue_struct *wq; }; +static struct sony_laptop_input_s sony_laptop_input = { .users =ATOMIC_INIT (0 ), };
@@ -689,6 +696,31 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,return -1 ; } +static int sony_find_snc_handle (int handle) +{ +int i; +int result; + +for (i=0x20 ; i<0x30 ; i++) { +acpi_callsetfunc (sony_nc_acpi_handle,"SN00" , i, &result); +if (result == handle) +return i-0x20 ; + } + +return -1 ; +} + +static int sony_call_snc_handle (int handle,int argument,int *result) +{ +int offset =sony_find_snc_handle (handle); + +if (offset <0 ) +return -1 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , offset | argument, + result); +} +/* * sony_nc_values input/output validate functions */
@@ -809,33 +841,27 @@ struct sony_nc_event {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 (const 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_90_events[] = { + {0x90 ,SONYPI_EVENT_PKEY_P1 }, + {0x10 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x91 ,SONYPI_EVENT_PKEY_P1 }, + {0x11 ,SONYPI_EVENT_ANYBUTTON_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 }, + {0x89 ,SONYPI_EVENT_FNKEY_F9 }, + {0x09 ,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 }, +}; -static struct sony_nc_event sony_C_events[] = { +static struct sony_nc_event sony_92_events[] = { {0x81 ,SONYPI_EVENT_FNKEY_F1 }, {0x01 ,SONYPI_EVENT_FNKEY_RELEASED }, {0x85 ,SONYPI_EVENT_FNKEY_F5 },
@@ -851,57 +877,18 @@ static struct sony_nc_event sony_C_events[] = { { 0, 0 }, }; -/* SNC-only model map */ -static const 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 FZ 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-FZ" ), - }, - }, - { - .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" ), - }, - }, - { - .ident ="Sony Vaio N 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-N" ), - }, - }, - { } -}; -/* * ACPI callbacks */ static void sony_acpi_notify (acpi_handle handle,u32 event,void *data) { -struct sony_nc_event *evmap;u32 ev = event;int result; -if (ev ==0x92 ) { +if (ev ==0x90 || ev ==0x92 ) { +struct sony_nc_event *events; +int origev = ev; +/* 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
@@ -913,20 +900,29 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)* 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 ) +if (sony_call_snc_handle (0x100 ,0x200 , &result))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; +if (origev ==0x90 ) + events = sony_90_events; +else + events = sony_92_events; + +while (events->event) { +if (events->data == ev) { + ev = events->event;break ; } + events++; } +if (!events->data) + printk(KERN_INFO DRV_PFX "Unknown event: %x %x\n", + origev, ev); + } +dprintk ("sony_acpi_notify, event: 0x%.2x\n" , ev);sony_laptop_report_input_event (ev);acpi_bus_generate_proc_event (sony_nc_acpi_device,1 , ev);
@@ -953,9 +949,24 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,/* * ACPI device */ +static int sony_nc_function_setup (struct acpi_device *device) { +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); + +/* Setup hotkeys */ +sony_call_snc_handle (0x0100 ,0 , &result); +sony_call_snc_handle (0x0101 ,0 , &result); +sony_call_snc_handle (0x0102 ,0x100 , &result); + +return 0 ; +} +static int sony_nc_resume (struct acpi_device *device) {struct sony_nc_value *item; +acpi_handle handle;for (item = sony_nc_values; item->name; item++) {int ret;
@@ -970,13 +981,156 @@ static int sony_nc_resume(struct acpi_device *device) } } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* set the last requested brightness level */ if (sony_backlight_device && !sony_backlight_update_status (sony_backlight_device)) printk(KERN_WARNING DRV_PFX "unable to restore brightness level\n"); -/* re-initialize models with specific requirements */ -dmi_check_system (sony_nc_ids); +return 0 ; +} + +static void sony_nc_rfkill_cleanup (void ) +{ +if (sony_wifi_rfkill) +rfkill_unregister (sony_wifi_rfkill); +if (sony_bluetooth_rfkill) +rfkill_unregister (sony_bluetooth_rfkill); +if (sony_wwan_rfkill) +rfkill_unregister (sony_wwan_rfkill); +if (sony_wimax_rfkill) +rfkill_unregister (sony_wimax_rfkill); +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; + +sony_call_snc_handle (0x124 , (long ) data, &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int argument = (long ) data +1 ; + +if (state ==RFKILL_STATE_UNBLOCKED ) + argument |=0xff0000 ; + +return sony_call_snc_handle (0x124 , argument, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN ); +if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)0x300 ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_free (sony_wifi_rfkill); +return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)0x500 ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_free (sony_bluetooth_rfkill); +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)0x700 ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_free (sony_wwan_rfkill); +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)0x900 ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_free (sony_wimax_rfkill); +return err; +} + +static int sony_nc_rfkill_setup (struct acpi_device *device) +{ +int result, ret; + +if (sony_find_snc_handle (0x124 ) ==-1 ) +return -1 ; + + ret =sony_call_snc_handle (0x124 ,0xb00 , &result); +if (ret) { + printk(KERN_INFO DRV_PFX + "Unable to enumerate rfkill devices: %x\n", ret); +return ret; + } + +if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device);return 0 ; }
@@ -1024,6 +1178,19 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); +sony_nc_rfkill_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {
@@ -1063,9 +1230,6 @@ 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;
@@ -1131,6 +1295,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_nc_rfkill_cleanup ();return result; }
@@ -1156,6 +1321,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_nc_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 1 line · Matthew Garrett
Ok, this one should cover it. Thanks for testing! S1 and S2 will just
Did I mess something up, but now I get
sony-laptop: sony_acpi_notify, event: 0x20 sony-laptop: sony_acpi_notify, event: 0x38 sony-laptop: unknown input event 38
for S1.
Why do I have again different numbers ....
But the Unknwon even is gone, now we have unknown input event.
Quoted 2 lines
generate events that can be bound with your desktop environment or xbindkeys or something similar.
But it works, now S1 can be bound in gnome shortcuts menu.
Thanks.
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
HIGH OFFLEY (n.)
Gossnargh (q.v.) three weeks later.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 5 lines · Norbert Preining
Did I mess something up, but now I get
sony-laptop: sony_acpi_notify, event: 0x20 sony-laptop: sony_acpi_notify, event: 0x38 sony-laptop: unknown input event 38for S1.
Yes, that's fine - it's just coming from SONYPI_EVENT_ANYBUTTON_RELEASED, which doesn't map onto an actual event. Can you do one last thing and (with debugging enabled) try flicking the rfkill switch, then let me know what event it generates?
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 2 lines · Matthew Garrett
Can you do one last thing and (with debugging enabled) try flicking the rfkill switch, then let me know what event it generates?
Besides loads of remove foo bar stuff I get:
for turning from on to off:
sony-laptop: sony_acpi_notify, event: 0x93
sony-laptop: sony_laptop_report_input_event, event not known: 147
sony-laptop: unknown input event 93
for turning to from off to on
sony-laptop: sony_acpi_notify, event: 0x93
sony-laptop: sony_laptop_report_input_event, event not known: 147
sony-laptop: unknown input event 93
One more thing: Can you check the "Eject" button, I always forgot that one (press-release):
sony-laptop: Unknown event: 90 9f
sony-laptop: sony_acpi_notify, event: 0x9f
sony-laptop: sony_laptop_report_input_event, event not known: 159
sony-laptop: unknown input event 9f
sony-laptop: Unknown event: 90 1f
sony-laptop: sony_acpi_notify, event: 0x1f
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
ABERYSTWYTH (n.)
A nostalgic yearning which is in itself more pleasant than the thing being yearned for.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 4 lines · Norbert Preining
for turning from on to off:
sony-laptop:sony_acpi_notify, event:0x93
sony-laptop:sony_laptop_report_input_event, event not known: 147
sony-laptop: unknown input event 93
Ok, thanks. That's sent as a separate event type, which makes this easier. It may need some further work to figure out whether it's going from on to off or off to on, but I'll see if I can figure that out.
Quoted 2 lines
One more thing: Can you check the "Eject" button, I always forgot that one (press-release):
Is this CD eject or dock eject?
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 4 lines · Matthew Garrett
Quoted 2 lines
One more thing: Can you check the "Eject" button, I always forgot that one (press-release):
Is this CD eject or dock eject?
Sorry, CD eject button. That would be nice, because the hardware eject button is a pain to press for me with my big fingers ;-)
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
DEAL (n.)
The gummy substance found between damp toes.
--- Douglas Adams, The Meaning of Liff
--
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
Ok, here you go.
drivers/platform/x86/sony-laptop.c +251 -81
@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h>
@@ -123,6 +124,11 @@ MODULE_PARM_DESC(minor, "default is -1 (automatic)");#endif +static struct rfkill *sony_wifi_rfkill; +static struct rfkill *sony_bluetooth_rfkill; +static struct rfkill *sony_wwan_rfkill; +static struct rfkill *sony_wimax_rfkill; +/*********** Input Devices ***********/ #define SONY_LAPTOP_BUF_SIZE 128
@@ -134,6 +140,7 @@ struct sony_laptop_input_s {spinlock_t fifo_lock;struct workqueue_struct *wq; }; +static struct sony_laptop_input_s sony_laptop_input = { .users =ATOMIC_INIT (0 ), };
@@ -211,6 +218,7 @@ static int sony_laptop_input_index[] = {48 ,/* 61 SONYPI_EVENT_WIRELESS_OFF */ 49 ,/* 62 SONYPI_EVENT_ZOOM_IN_PRESSED */ 50 ,/* 63 SONYPI_EVENT_ZOOM_OUT_PRESSED */ + 51, /* 64 SONYPI_EVENT_CD_EJECT_PRESSED */ }; static int sony_laptop_input_keycode_map[] = {
@@ -264,7 +272,8 @@ static int sony_laptop_input_keycode_map[] = {KEY_WLAN ,/* 47 SONYPI_EVENT_WIRELESS_ON */ KEY_WLAN ,/* 48 SONYPI_EVENT_WIRELESS_OFF */ KEY_ZOOMIN ,/* 49 SONYPI_EVENT_ZOOM_IN_PRESSED */ - KEY_ZOOMOUT /* 50 SONYPI_EVENT_ZOOM_OUT_PRESSED */ +KEY_ZOOMOUT ,/* 50 SONYPI_EVENT_ZOOM_OUT_PRESSED */ + KEY_EJECTCD /* 51 SONYPI_EVENT_CD_EJECT_PRESSED */ };/* release buttons after a short delay if pressed */
@@ -689,6 +698,31 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,return -1 ; } +static int sony_find_snc_handle (int handle) +{ +int i; +int result; + +for (i=0x20 ; i<0x30 ; i++) { +acpi_callsetfunc (sony_nc_acpi_handle,"SN00" , i, &result); +if (result == handle) +return i-0x20 ; + } + +return -1 ; +} + +static int sony_call_snc_handle (int handle,int argument,int *result) +{ +int offset =sony_find_snc_handle (handle); + +if (offset <0 ) +return -1 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , offset | argument, + result); +} +/* * sony_nc_values input/output validate functions */
@@ -809,33 +843,29 @@ struct sony_nc_event {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 (const 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_90_events[] = { + {0x90 ,SONYPI_EVENT_PKEY_P1 }, + {0x10 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x91 ,SONYPI_EVENT_PKEY_P1 }, + {0x11 ,SONYPI_EVENT_ANYBUTTON_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 }, + {0x89 ,SONYPI_EVENT_FNKEY_F9 }, + {0x09 ,SONYPI_EVENT_FNKEY_RELEASED }, + {0x8a ,SONYPI_EVENT_FNKEY_F10 }, + {0x0a ,SONYPI_EVENT_FNKEY_RELEASED }, + {0x8C ,SONYPI_EVENT_FNKEY_F12 }, + {0x0C ,SONYPI_EVENT_FNKEY_RELEASED }, + {0x9f ,SONYPI_EVENT_CD_EJECT_PRESSED }, + {0x1f ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0 ,0 }, +}; -static struct sony_nc_event sony_C_events[] = { +static struct sony_nc_event sony_92_events[] = { {0x81 ,SONYPI_EVENT_FNKEY_F1 }, {0x01 ,SONYPI_EVENT_FNKEY_RELEASED }, {0x85 ,SONYPI_EVENT_FNKEY_F5 },
@@ -851,57 +881,18 @@ static struct sony_nc_event sony_C_events[] = { { 0, 0 }, }; -/* SNC-only model map */ -static const 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 FZ 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-FZ" ), - }, - }, - { - .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" ), - }, - }, - { - .ident ="Sony Vaio N 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-N" ), - }, - }, - { } -}; -/* * ACPI callbacks */ static void sony_acpi_notify (acpi_handle handle,u32 event,void *data) { -struct sony_nc_event *evmap;u32 ev = event;int result; -if (ev ==0x92 ) { +if (ev ==0x90 || ev ==0x92 ) { +struct sony_nc_event *events; +int origev = ev; +/* 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
@@ -913,20 +904,29 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)* 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 ) +if (sony_call_snc_handle (0x100 ,0x200 , &result))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; +if (origev ==0x90 ) + events = sony_90_events; +else + events = sony_92_events; + +while (events->event) { +if (events->data == ev) { + ev = events->event;break ; } + events++; } +if (!events->data) + printk(KERN_INFO DRV_PFX "Unknown event: %x %x\n", + origev, ev); + } +dprintk ("sony_acpi_notify, event: 0x%.2x\n" , ev);sony_laptop_report_input_event (ev);acpi_bus_generate_proc_event (sony_nc_acpi_device,1 , ev);
@@ -953,9 +953,24 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,/* * ACPI device */ +static int sony_nc_function_setup (struct acpi_device *device) { +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); + +/* Setup hotkeys */ +sony_call_snc_handle (0x0100 ,0 , &result); +sony_call_snc_handle (0x0101 ,0 , &result); +sony_call_snc_handle (0x0102 ,0x100 , &result); + +return 0 ; +} +static int sony_nc_resume (struct acpi_device *device) {struct sony_nc_value *item; +acpi_handle handle;for (item = sony_nc_values; item->name; item++) {int ret;
@@ -970,13 +985,156 @@ static int sony_nc_resume(struct acpi_device *device) } } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* set the last requested brightness level */ if (sony_backlight_device && !sony_backlight_update_status (sony_backlight_device)) printk(KERN_WARNING DRV_PFX "unable to restore brightness level\n"); -/* re-initialize models with specific requirements */ -dmi_check_system (sony_nc_ids); +return 0 ; +} + +static void sony_nc_rfkill_cleanup (void ) +{ +if (sony_wifi_rfkill) +rfkill_unregister (sony_wifi_rfkill); +if (sony_bluetooth_rfkill) +rfkill_unregister (sony_bluetooth_rfkill); +if (sony_wwan_rfkill) +rfkill_unregister (sony_wwan_rfkill); +if (sony_wimax_rfkill) +rfkill_unregister (sony_wimax_rfkill); +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; + +sony_call_snc_handle (0x124 , (long ) data, &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int argument = (long ) data +1 ; + +if (state ==RFKILL_STATE_UNBLOCKED ) + argument |=0xff0000 ; + +return sony_call_snc_handle (0x124 , argument, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN ); +if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)0x300 ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_free (sony_wifi_rfkill); +return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)0x500 ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_free (sony_bluetooth_rfkill); +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)0x700 ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_free (sony_wwan_rfkill); +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)0x900 ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_free (sony_wimax_rfkill); +return err; +} + +static int sony_nc_rfkill_setup (struct acpi_device *device) +{ +int result, ret; + +if (sony_find_snc_handle (0x124 ) ==-1 ) +return -1 ; + + ret =sony_call_snc_handle (0x124 ,0xb00 , &result); +if (ret) { + printk(KERN_INFO DRV_PFX + "Unable to enumerate rfkill devices: %x\n", ret); +return ret; + } + +if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device);return 0 ; }
@@ -1024,6 +1182,19 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); +sony_nc_rfkill_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {
@@ -1063,9 +1234,6 @@ 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;
@@ -1131,6 +1299,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_nc_rfkill_cleanup ();return result; }
@@ -1156,6 +1325,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_nc_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;
include/linux/sonypi.h +1 -0
@@ -103,6 +103,7 @@#define SONYPI_EVENT_WIRELESS_OFF 61#define SONYPI_EVENT_ZOOM_IN_PRESSED 62#define SONYPI_EVENT_ZOOM_OUT_PRESSED 63 +#define SONYPI_EVENT_CD_EJECT_PRESSED 64/* get/set brightness */ #define SONYPI_IOCGBRT _IOR('v', 0, __u8)
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 1 line · Matthew Garrett
Ok, here you go.
Thanks, worked perfectly. And my gnome desktop opened the CD drive without even thinking.
Great.
What remains for me for the moment is some decent rfkill switching utility GUI. Something that shows the names and one can press the button next to the name to turn off and on ...
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
WHASSET (n.)
A business card in you wallet belonging to someone whom you have no recollection of meeting.
--- Douglas Adams, The Meaning of Liff
--
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
Ok, and here's what I consider to be the "final" version for now. It cleans up the event handling (it turns out that the event value corresponds to the SN00 value required to call the corresponding function) and adds support for the external switch to flag the devices as being in HARD_BLOCKED state. Tested on a P series (remotely), if someone could check it on a Z and ideally a TT, that would be great. I think it's otherwise basically complete for keyboard and rfkill handling.
drivers/platform/x86/sony-laptop.c +283 -97
@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h>
@@ -123,6 +124,18 @@ MODULE_PARM_DESC(minor, "default is -1 (automatic)");#endif +enum sony_nc_rfkill { +SONY_WIFI , +SONY_BLUETOOTH , +SONY_WWAN , +SONY_WIMAX , +SONY_RFKILL_MAX , +}; + +static struct rfkill *sony_rfkill_devices[SONY_RFKILL_MAX ]; +static int sony_rfkill_address[SONY_RFKILL_MAX ] = {0x300 ,0x500 ,0x700 ,0x900 }; +static void sony_nc_rfkill_update (void ); +/*********** Input Devices ***********/ #define SONY_LAPTOP_BUF_SIZE 128
@@ -134,6 +147,7 @@ struct sony_laptop_input_s {spinlock_t fifo_lock;struct workqueue_struct *wq; }; +static struct sony_laptop_input_s sony_laptop_input = { .users =ATOMIC_INIT (0 ), };
@@ -211,6 +225,7 @@ static int sony_laptop_input_index[] = {48 ,/* 61 SONYPI_EVENT_WIRELESS_OFF */ 49 ,/* 62 SONYPI_EVENT_ZOOM_IN_PRESSED */ 50 ,/* 63 SONYPI_EVENT_ZOOM_OUT_PRESSED */ + 51, /* 64 SONYPI_EVENT_CD_EJECT_PRESSED */ }; static int sony_laptop_input_keycode_map[] = {
@@ -264,7 +279,8 @@ static int sony_laptop_input_keycode_map[] = {KEY_WLAN ,/* 47 SONYPI_EVENT_WIRELESS_ON */ KEY_WLAN ,/* 48 SONYPI_EVENT_WIRELESS_OFF */ KEY_ZOOMIN ,/* 49 SONYPI_EVENT_ZOOM_IN_PRESSED */ - KEY_ZOOMOUT /* 50 SONYPI_EVENT_ZOOM_OUT_PRESSED */ +KEY_ZOOMOUT ,/* 50 SONYPI_EVENT_ZOOM_OUT_PRESSED */ + KEY_EJECTCD /* 51 SONYPI_EVENT_CD_EJECT_PRESSED */ };/* release buttons after a short delay if pressed */
@@ -689,6 +705,31 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,return -1 ; } +static int sony_find_snc_handle (int handle) +{ +int i; +int result; + +for (i=0x20 ; i<0x30 ; i++) { +acpi_callsetfunc (sony_nc_acpi_handle,"SN00" , i, &result); +if (result == handle) +return i-0x20 ; + } + +return -1 ; +} + +static int sony_call_snc_handle (int handle,int argument,int *result) +{ +int offset =sony_find_snc_handle (handle); + +if (offset <0 ) +return -1 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , offset | argument, + result); +} +/* * sony_nc_values input/output validate functions */
@@ -809,33 +850,11 @@ struct sony_nc_event {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 (const 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[] = { +static struct sony_nc_event sony_nc_events[] = { + {0x90 ,SONYPI_EVENT_PKEY_P1 }, + {0x10 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x91 ,SONYPI_EVENT_PKEY_P1 }, + {0x11 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, {0x81 ,SONYPI_EVENT_FNKEY_F1 }, {0x01 ,SONYPI_EVENT_FNKEY_RELEASED }, {0x85 ,SONYPI_EVENT_FNKEY_F5 },
@@ -844,88 +863,53 @@ static struct sony_nc_event sony_C_events[] = { { 0x06, SONYPI_EVENT_FNKEY_RELEASED }, { 0x87, SONYPI_EVENT_FNKEY_F7 }, { 0x07, SONYPI_EVENT_FNKEY_RELEASED }, + { 0x89, SONYPI_EVENT_FNKEY_F9 }, + { 0x09, SONYPI_EVENT_FNKEY_RELEASED }, { 0x8A, SONYPI_EVENT_FNKEY_F10 }, { 0x0A, SONYPI_EVENT_FNKEY_RELEASED }, { 0x8C, SONYPI_EVENT_FNKEY_F12 }, { 0x0C, SONYPI_EVENT_FNKEY_RELEASED }, + { 0x9f, SONYPI_EVENT_CD_EJECT_PRESSED }, + { 0x1f, SONYPI_EVENT_ANYBUTTON_RELEASED }, { 0, 0 }, }; -/* SNC-only model map */ -static const 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 FZ 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-FZ" ), - }, - }, - { - .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" ), - }, - }, - { - .ident ="Sony Vaio N 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-N" ), - }, - }, - { } -}; -/* * ACPI callbacks */ static void sony_acpi_notify (acpi_handle handle,u32 event,void *data) { -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 (ev >=0x90 ) { +/* New-style event */ +int origev = ev; + ev -=0x90 ; -if (sony_nc_events) -for (evmap = sony_nc_events; evmap->event; evmap++) { -if (evmap->data == ev) { - ev = evmap->event; -break ; +if (sony_find_snc_handle (0x100 ) == ev) { +int i; + +if (sony_call_snc_handle (0x100 ,0x200 , &result)) +dprintk ("sony_acpi_notify, unable to decode event 0x%.2x\n" , ev); +else + ev = result &0xFF ; + +for (i=0 ; sony_nc_events[i].event; i++) { +if (sony_nc_events[i].data == ev) { + ev = sony_nc_events[i].event; +break ; + } } + +if (!sony_nc_events[i].data) + printk(KERN_INFO DRV_PFX +"Unknown event: %x %x\n" , origev, ev); + }else if (sony_find_snc_handle (0x124 ) == ev) { +sony_nc_rfkill_update (); +return ; } + }dprintk ("sony_acpi_notify, event: 0x%.2x\n" , ev);sony_laptop_report_input_event (ev);
@@ -953,9 +937,24 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,/* * ACPI device */ +static int sony_nc_function_setup (struct acpi_device *device) { +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); + +/* Setup hotkeys */ +sony_call_snc_handle (0x0100 ,0 , &result); +sony_call_snc_handle (0x0101 ,0 , &result); +sony_call_snc_handle (0x0102 ,0x100 , &result); + +return 0 ; +} +static int sony_nc_resume (struct acpi_device *device) {struct sony_nc_value *item; +acpi_handle handle;for (item = sony_nc_values; item->name; item++) {int ret;
@@ -970,13 +969,188 @@ static int sony_nc_resume(struct acpi_device *device) } } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* set the last requested brightness level */ if (sony_backlight_device && !sony_backlight_update_status (sony_backlight_device)) printk(KERN_WARNING DRV_PFX "unable to restore brightness level\n"); -/* re-initialize models with specific requirements */ -dmi_check_system (sony_nc_ids); +return 0 ; +} + +static void sony_nc_rfkill_cleanup (void ) +{ +int i; + +for (i=0 ; i<SONY_RFKILL_MAX ; i++) { +if (sony_rfkill_devices[i]) +rfkill_unregister (sony_rfkill_devices[i]); + } +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; +int argument = sony_rfkill_address[(long ) data]; + +sony_call_snc_handle (0x124 ,0x200 , &result); +if (result &0x1 ) { +sony_call_snc_handle (0x124 , argument, &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; + }else { + *state =RFKILL_STATE_HARD_BLOCKED ; + } + +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int argument = sony_rfkill_address[(long ) data] +0x100 ; + +if (state ==RFKILL_STATE_UNBLOCKED ) + argument |=0xff0000 ; + +return sony_call_snc_handle (0x124 , argument, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; +struct rfkill *sony_wifi_rfkill; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN ); +if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)SONY_WIFI ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_free (sony_wifi_rfkill); +else + sony_rfkill_devices[SONY_WIFI ] = sony_wifi_rfkill; +return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; +struct rfkill *sony_bluetooth_rfkill; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)SONY_BLUETOOTH ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_free (sony_bluetooth_rfkill); +else + sony_rfkill_devices[SONY_BLUETOOTH ] = sony_bluetooth_rfkill; +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; +struct rfkill *sony_wwan_rfkill; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)SONY_WWAN ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_free (sony_wwan_rfkill); +else + sony_rfkill_devices[SONY_WWAN ] = sony_wwan_rfkill; +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; +struct rfkill *sony_wimax_rfkill; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)SONY_WIMAX ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_free (sony_wimax_rfkill); +else + sony_rfkill_devices[SONY_WIMAX ] = sony_wimax_rfkill; +return err; +} + +static void sony_nc_rfkill_update () +{ +int i; +enum rfkill_state state; + +for (i=0 ; i<SONY_RFKILL_MAX ; i++) { +if (sony_rfkill_devices[i]) { + sony_rfkill_devices[i]-> +get_state (sony_rfkill_devices[i]->data, + &state); +rfkill_force_state (sony_rfkill_devices[i], state); + } + } +} + +static int sony_nc_rfkill_setup (struct acpi_device *device) +{ +int result, ret; + +if (sony_find_snc_handle (0x124 ) ==-1 ) +return -1 ; + + ret =sony_call_snc_handle (0x124 ,0xb00 , &result); +if (ret) { + printk(KERN_INFO DRV_PFX + "Unable to enumerate rfkill devices: %x\n", ret); +return ret; + } + +if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device);return 0 ; }
@@ -1024,6 +1198,19 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); +sony_nc_rfkill_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {
@@ -1063,9 +1250,6 @@ 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;
@@ -1131,6 +1315,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_nc_rfkill_cleanup ();return result; }
@@ -1156,6 +1341,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_nc_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;
include/linux/sonypi.h +1 -0
@@ -103,6 +103,7 @@#define SONYPI_EVENT_WIRELESS_OFF 61#define SONYPI_EVENT_ZOOM_IN_PRESSED 62#define SONYPI_EVENT_ZOOM_OUT_PRESSED 63 +#define SONYPI_EVENT_CD_EJECT_PRESSED 64/* get/set brightness */ #define SONYPI_IOCGBRT _IOR('v', 0, __u8)
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 3 lines · Mattia Dongili
Yes it does.
A vaio SR user sent me this list for0x9cthat after a call to SN07(202) becomes:
After looking at this, I think we actually want to be calling SN07(20C) on these machines - they implement an 0x127 function in the C function slot which also calls GECR. I suspect that this corresponds to the larger number of programmable buttons, so should be added to another table. Something like the following - some amount of tidying up required. That would avoid needing to add a multilevel setup.
Interestingly, the recent SRs also appear to implement the 0x124 rfill method, but at SN07(4) rather than SN07(3). This leaves me pretty happy that I've got the right idea about how this all works now :)
drivers/platform/x86/sony-laptop.c +37 -0
@@ -850,6 +850,25 @@ struct sony_nc_event {u8 event; }; +static struct sony_nc_event sony_127_events[] = { + {0x81 ,SONYPI_EVENT_MODEKEY_PRESSED }, + {0x01 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x82 ,SONYPI_EVENT_PKEY_P1 }, + {0x02 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x83 ,SONYPI_EVENT_PKEY_P2 }, + {0x03 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x84 ,SONYPI_EVENT_PKEY_P3 }, + {0x04 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x85 ,SONYPI_EVENT_PKEY_P4 }, + {0x05 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x86 ,SONYPI_EVENT_PKEY_P5 }, + {0x06 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x06 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x87 ,SONYPI_EVENT_SETTINGKEY_PRESSED }, + {0x07 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0 ,0 }, +} +static struct sony_nc_event sony_nc_events[] = { {0x90 ,SONYPI_EVENT_PKEY_P1 }, {0x10 ,SONYPI_EVENT_ANYBUTTON_RELEASED },
@@ -908,6 +927,24 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data) }else if (sony_find_snc_handle (0x124 ) == ev) {sony_nc_rfkill_update ();return ; + }else if (sony_find_snc_handle (0x127 ) == ev) { +int i; + +if (sony_call_snc_handle (0x127 ,0x200 , &result)) +dprintk ("sony_acpi_notify, unable to decode event 0x%.2x\n" , ev); +else + ev = result &0xFF ; + +for (i=0 ; sony_127_events[i].event; i++) { +if (sony_127_events[i].data == ev) { + ev = sony_127_events[i].event; +break ; + } + } + +if (!sony_127_events[i].data) + printk(KERN_INFO DRV_PFX +"Unknown event: %x %x\n" , origev, ev); } }
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 2 lines · Matthew Garrett
Ok, and here's what I consider to be the "final" version for now. It cleans up the event handling (it turns out that the event value
Tested, works as far as my tests go (kbds, rfkill on/off tests)
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
`In those days spirits were brave, the stakes were high,
men were REAL men, women were REAL women, and small furry creatures from Alpha Centauri were REAL small furry creatures from Aplha Centauri.'
--- The Book getting all nostalgic.
--- Douglas Adams, The Hitchhikers Guide to the Galaxy
--
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
drivers/platform/x86/sony-laptop.c
Quoted 6 lines · Matthew Garrett
Interestingly, the recent SRs also appear to implement the
0x124rfill method, but at SN07(4) rather than SN07(3). This leaves me pretty happy that I've got the right idea about how this all works now :)drivers/platform/x86/sony-laptop.c +0
-0
So does that mean I should test this on on top of your "final" patch?
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
GILDERSOME (adj.) Descriptive of a joke someone tells you which starts well, but which becomes so embellished in the telling that you start to weary of it after scarcely half an hour.
--- Douglas Adams, The Meaning of Liff
--
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
Quoted 9 lines · Norbert Preining
drivers/platform/x86/sony-laptop.c
Quoted 6 lines · Matthew Garrett
Interestingly, the recent SRs also appear to implement the
0x124rfill method, but at SN07(4) rather than SN07(3). This leaves me pretty happy that I've got the right idea about how this all works now :)drivers/platform/x86/sony-laptop.c +0
-0So does that mean I should test this on on top of your "final" patch?
The Z series doesn't implement the 0x127 method, so it won't make any difference.
Signature · 5 lines
Matthew Garrett | [email protected] -- 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
Mattia Dongili
maintainer[Cc-ing more people who could test the patch on different models]
Quoted 8 lines · Matthew Garrett
Ok, and here's what I consider to be the "final" version for now. It cleans up the event handling (it turns out that the event value corresponds to the SN00 value required to call the corresponding function) and adds support for the external switch to flag the devices as being in
HARD_BLOCKEDstate. Tested on a P series (remotely), if someone could check it on a Z and ideally a TT, that would be great. I think it's otherwise basically complete for keyboard and rfkill handling.
Looks good to me. I asked Michael to test one of you earlier versions on his TT and he seems to be happy about it (apart from an oops somewhere in the tty_release path[1] which is unlikely to be related to sony-laptop).
Please send your series in, I'll then rebase my patches and push to Len.
[1]: http://bugzilla.kernel.org/attachment.cgi?id=20651
Quoted 526 lines
drivers/platform/x86/sony-laptop.c +283
-97@@ -64,6 +64,7 @@#include <asm/uaccess.h> #include <linux/sonypi.h> #include <linux/sony-laptop.h> +#include <linux/rfkill.h> #ifdef CONFIG_SONYPI_COMPAT #include <linux/poll.h> #include <linux/miscdevice.h> @@ -123,6 +124,18 @@ MODULE_PARM_DESC(minor, "default is -1 (automatic)");#endif +enum sony_nc_rfkill { +SONY_WIFI , +SONY_BLUETOOTH , +SONY_WWAN , +SONY_WIMAX , +SONY_RFKILL_MAX , +}; + +static struct rfkill *sony_rfkill_devices[SONY_RFKILL_MAX ]; +static int sony_rfkill_address[SONY_RFKILL_MAX ] = {0x300 ,0x500 ,0x700 ,0x900 }; +static void sony_nc_rfkill_update (void ); +/*********** Input Devices ***********/ #define SONY_LAPTOP_BUF_SIZE 128@@ -134,6 +147,7 @@ struct sony_laptop_input_s {spinlock_t fifo_lock;struct workqueue_struct *wq; }; +static struct sony_laptop_input_s sony_laptop_input = { .users =ATOMIC_INIT (0 ), };@@ -211,6 +225,7 @@ static int sony_laptop_input_index[] = {48 ,/* 61 SONYPI_EVENT_WIRELESS_OFF */ 49 ,/* 62 SONYPI_EVENT_ZOOM_IN_PRESSED */ 50 ,/* 63 SONYPI_EVENT_ZOOM_OUT_PRESSED */ + 51, /* 64 SONYPI_EVENT_CD_EJECT_PRESSED */ }; static int sony_laptop_input_keycode_map[] = {@@ -264,7 +279,8 @@ static int sony_laptop_input_keycode_map[] = {KEY_WLAN ,/* 47 SONYPI_EVENT_WIRELESS_ON */ KEY_WLAN ,/* 48 SONYPI_EVENT_WIRELESS_OFF */ KEY_ZOOMIN ,/* 49 SONYPI_EVENT_ZOOM_IN_PRESSED */ - KEY_ZOOMOUT /* 50 SONYPI_EVENT_ZOOM_OUT_PRESSED */ +KEY_ZOOMOUT ,/* 50 SONYPI_EVENT_ZOOM_OUT_PRESSED */ + KEY_EJECTCD /* 51 SONYPI_EVENT_CD_EJECT_PRESSED */ };/* release buttons after a short delay if pressed */ @@ -689,6 +705,31 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,return -1 ; } +static int sony_find_snc_handle (int handle) +{ +int i; +int result; + +for (i=0x20 ; i<0x30 ; i++) { +acpi_callsetfunc (sony_nc_acpi_handle,"SN00" , i, &result); +if (result == handle) +return i-0x20 ; + } + +return -1 ; +} + +static int sony_call_snc_handle (int handle,int argument,int *result) +{ +int offset =sony_find_snc_handle (handle); + +if (offset <0 ) +return -1 ; + +return acpi_callsetfunc (sony_nc_acpi_handle,"SN07" , offset | argument, + result); +} +/* * sony_nc_values input/output validate functions */ @@ -809,33 +850,11 @@ struct sony_nc_event {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 (const 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[] = { +static struct sony_nc_event sony_nc_events[] = { + {0x90 ,SONYPI_EVENT_PKEY_P1 }, + {0x10 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, + {0x91 ,SONYPI_EVENT_PKEY_P1 }, + {0x11 ,SONYPI_EVENT_ANYBUTTON_RELEASED }, {0x81 ,SONYPI_EVENT_FNKEY_F1 }, {0x01 ,SONYPI_EVENT_FNKEY_RELEASED }, {0x85 ,SONYPI_EVENT_FNKEY_F5 },@@ -844,88 +863,53 @@ static struct sony_nc_event sony_C_events[] = { { 0x06, SONYPI_EVENT_FNKEY_RELEASED }, { 0x87, SONYPI_EVENT_FNKEY_F7 }, { 0x07, SONYPI_EVENT_FNKEY_RELEASED }, + { 0x89, SONYPI_EVENT_FNKEY_F9 }, + { 0x09, SONYPI_EVENT_FNKEY_RELEASED }, { 0x8A, SONYPI_EVENT_FNKEY_F10 }, { 0x0A, SONYPI_EVENT_FNKEY_RELEASED }, { 0x8C, SONYPI_EVENT_FNKEY_F12 }, { 0x0C, SONYPI_EVENT_FNKEY_RELEASED }, + { 0x9f, SONYPI_EVENT_CD_EJECT_PRESSED }, + { 0x1f, SONYPI_EVENT_ANYBUTTON_RELEASED }, { 0, 0 }, }; -/* SNC-only model map */ -static const 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 FZ 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-FZ" ), - }, - }, - { - .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" ), - }, - }, - { - .ident ="Sony Vaio N 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-N" ), - }, - }, - { } -}; -/* * ACPI callbacks */ static void sony_acpi_notify (acpi_handle handle,u32 event,void *data) { -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 (ev >=0x90 ) { +/* New-style event */ +int origev = ev; + ev -=0x90 ; -if (sony_nc_events) -for (evmap = sony_nc_events; evmap->event; evmap++) { -if (evmap->data == ev) { - ev = evmap->event; -break ; +if (sony_find_snc_handle (0x100 ) == ev) { +int i; + +if (sony_call_snc_handle (0x100 ,0x200 , &result)) +dprintk ("sony_acpi_notify, unable to decode event 0x%.2x\n" , ev); +else + ev = result &0xFF ; + +for (i=0 ; sony_nc_events[i].event; i++) { +if (sony_nc_events[i].data == ev) { + ev = sony_nc_events[i].event; +break ; + } } + +if (!sony_nc_events[i].data) + printk(KERN_INFO DRV_PFX +"Unknown event: %x %x\n" , origev, ev); + }else if (sony_find_snc_handle (0x124 ) == ev) { +sony_nc_rfkill_update (); +return ; } + }dprintk ("sony_acpi_notify, event: 0x%.2x\n" , ev);sony_laptop_report_input_event (ev);@@ -953,9 +937,24 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,/* * ACPI device */ +static int sony_nc_function_setup (struct acpi_device *device) { +int result; + +/* Enable all events */ +acpi_callsetfunc (sony_nc_acpi_handle,"SN02" ,0xffff , &result); + +/* Setup hotkeys */ +sony_call_snc_handle (0x0100 ,0 , &result); +sony_call_snc_handle (0x0101 ,0 , &result); +sony_call_snc_handle (0x0102 ,0x100 , &result); + +return 0 ; +} +static int sony_nc_resume (struct acpi_device *device) {struct sony_nc_value *item; +acpi_handle handle;for (item = sony_nc_values; item->name; item++) {int ret;@@ -970,13 +969,188 @@ static int sony_nc_resume(struct acpi_device *device) } } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); + } +/* set the last requested brightness level */ if (sony_backlight_device && !sony_backlight_update_status (sony_backlight_device)) printk(KERN_WARNING DRV_PFX "unable to restore brightness level\n"); -/* re-initialize models with specific requirements */ -dmi_check_system (sony_nc_ids); +return 0 ; +} + +static void sony_nc_rfkill_cleanup (void ) +{ +int i; + +for (i=0 ; i<SONY_RFKILL_MAX ; i++) { +if (sony_rfkill_devices[i]) +rfkill_unregister (sony_rfkill_devices[i]); + } +} + +static int sony_nc_rfkill_get (void *data,enum rfkill_state *state) +{ +int result; +int argument = sony_rfkill_address[(long ) data]; + +sony_call_snc_handle (0x124 ,0x200 , &result); +if (result &0x1 ) { +sony_call_snc_handle (0x124 , argument, &result); +if (result &0xf ) + *state =RFKILL_STATE_UNBLOCKED ; +else + *state =RFKILL_STATE_SOFT_BLOCKED ; + }else { + *state =RFKILL_STATE_HARD_BLOCKED ; + } + +return 0 ; +} + +static int sony_nc_rfkill_set (void *data,enum rfkill_state state) +{ +int result; +int argument = sony_rfkill_address[(long ) data] +0x100 ; + +if (state ==RFKILL_STATE_UNBLOCKED ) + argument |=0xff0000 ; + +return sony_call_snc_handle (0x124 , argument, &result); +} + +static int sony_nc_setup_wifi_rfkill (struct acpi_device *device) +{ +int err =0 ; +struct rfkill *sony_wifi_rfkill; + + sony_wifi_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WLAN ); +if (!sony_wifi_rfkill) +return -1 ; + sony_wifi_rfkill->name ="sony-wifi" ; + sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wifi_rfkill->get_state = sony_nc_rfkill_get; + sony_wifi_rfkill->user_claim_unsupported =1 ; + sony_wifi_rfkill->data = (void *)SONY_WIFI ; + err =rfkill_register (sony_wifi_rfkill); +if (err) +rfkill_free (sony_wifi_rfkill); +else + sony_rfkill_devices[SONY_WIFI ] = sony_wifi_rfkill; +return err; +} + +static int sony_nc_setup_bluetooth_rfkill (struct acpi_device *device) +{ +int err =0 ; +struct rfkill *sony_bluetooth_rfkill; + + sony_bluetooth_rfkill =rfkill_allocate (&device->dev, +RFKILL_TYPE_BLUETOOTH ); +if (!sony_bluetooth_rfkill) +return -1 ; + sony_bluetooth_rfkill->name ="sony-bluetooth" ; + sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; + sony_bluetooth_rfkill->user_claim_unsupported =1 ; + sony_bluetooth_rfkill->data = (void *)SONY_BLUETOOTH ; + err =rfkill_register (sony_bluetooth_rfkill); +if (err) +rfkill_free (sony_bluetooth_rfkill); +else + sony_rfkill_devices[SONY_BLUETOOTH ] = sony_bluetooth_rfkill; +return err; +} + +static int sony_nc_setup_wwan_rfkill (struct acpi_device *device) +{ +int err =0 ; +struct rfkill *sony_wwan_rfkill; + + sony_wwan_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WWAN ); +if (!sony_wwan_rfkill) +return -1 ; + sony_wwan_rfkill->name ="sony-wwan" ; + sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wwan_rfkill->get_state = sony_nc_rfkill_get; + sony_wwan_rfkill->user_claim_unsupported =1 ; + sony_wwan_rfkill->data = (void *)SONY_WWAN ; + err =rfkill_register (sony_wwan_rfkill); +if (err) +rfkill_free (sony_wwan_rfkill); +else + sony_rfkill_devices[SONY_WWAN ] = sony_wwan_rfkill; +return err; +} + +static int sony_nc_setup_wimax_rfkill (struct acpi_device *device) +{ +int err =0 ; +struct rfkill *sony_wimax_rfkill; + + sony_wimax_rfkill =rfkill_allocate (&device->dev,RFKILL_TYPE_WIMAX ); +if (!sony_wimax_rfkill) +return -1 ; + sony_wimax_rfkill->name ="sony-wimax" ; + sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; + sony_wimax_rfkill->get_state = sony_nc_rfkill_get; + sony_wimax_rfkill->user_claim_unsupported =1 ; + sony_wimax_rfkill->data = (void *)SONY_WIMAX ; + err =rfkill_register (sony_wimax_rfkill); +if (err) +rfkill_free (sony_wimax_rfkill); +else + sony_rfkill_devices[SONY_WIMAX ] = sony_wimax_rfkill; +return err; +} + +static void sony_nc_rfkill_update () +{ +int i; +enum rfkill_state state; + +for (i=0 ; i<SONY_RFKILL_MAX ; i++) { +if (sony_rfkill_devices[i]) { + sony_rfkill_devices[i]-> +get_state (sony_rfkill_devices[i]->data, + &state); +rfkill_force_state (sony_rfkill_devices[i], state); + } + } +} + +static int sony_nc_rfkill_setup (struct acpi_device *device) +{ +int result, ret; + +if (sony_find_snc_handle (0x124 ) ==-1 ) +return -1 ; + + ret =sony_call_snc_handle (0x124 ,0xb00 , &result); +if (ret) { + printk(KERN_INFO DRV_PFX + "Unable to enumerate rfkill devices: %x\n", ret); +return ret; + } + +if (result &0x1 ) +sony_nc_setup_wifi_rfkill (device); +if (result &0x2 ) +sony_nc_setup_bluetooth_rfkill (device); +if (result &0x1c ) +sony_nc_setup_wwan_rfkill (device); +if (result &0x20 ) +sony_nc_setup_wimax_rfkill (device);return 0 ; }@@ -1024,6 +1198,19 @@ static int sony_nc_add(struct acpi_device *device)dprintk ("_INI Method failed\n" ); } +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"ECON" , + &handle))) { +if (acpi_callsetfunc (sony_nc_acpi_handle,"ECON" ,1 ,NULL )) +dprintk ("ECON Method failed\n" ); + } + +if (ACPI_SUCCESS (acpi_get_handle (sony_nc_acpi_handle,"SN00" , + &handle))) { +dprintk ("Doing SNC setup\n" ); +sony_nc_function_setup (device); +sony_nc_rfkill_setup (device); + } +/* setup input devices and helper fifo */ result =sony_laptop_setup_input (device);if (result) {@@ -1063,9 +1250,6 @@ 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;@@ -1131,6 +1315,7 @@ static int sony_nc_add(struct acpi_device *device)sony_laptop_remove_input (); outwalk: +sony_nc_rfkill_cleanup ();return result; }@@ -1156,6 +1341,7 @@ static int sony_nc_remove(struct acpi_device *device, int type)sony_pf_remove ();sony_laptop_remove_input (); +sony_nc_rfkill_cleanup ();dprintk (SONY_NC_DRIVER_NAME " removed.\n" );return 0 ;include/linux/sonypi.h +1
-0@@ -103,6 +103,7 @@#define SONYPI_EVENT_WIRELESS_OFF 61#define SONYPI_EVENT_ZOOM_IN_PRESSED 62#define SONYPI_EVENT_ZOOM_OUT_PRESSED 63 +#define SONYPI_EVENT_CD_EJECT_PRESSED 64/* get/set brightness */ #define SONYPI_IOCGBRT _IOR('v', 0, __u8)Signature · 2 lines
-- Matthew Garrett | [email protected]
Signature · 2 lines
mattia :wq!