Correctly detect Sony TX770P PIC device type
Subsystems (2)
PATCH 1/3 Correctly detect Sony TX770P PIC device type
This laptop has Type 4 SPIC device, support for which has been added recently. This device resides behind an older ISA bridge and was earlier incorrectly detected as Type 3.
--- drivers/misc/sony-laptop.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/misc/sony-laptop.c +5 -0
@@ -1563,6 +1563,11 @@ static void sony_pic_detect_device_type(struct sony_pic_dev *dev) pcidev =pci_get_device (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_ICH6_1 ,NULL );if (pcidev) { +if (pcidev->subsystem_vendor ==PCI_VENDOR_ID_SONY && + pcidev->subsystem_device ==0x81E2 ) { + dev->control = &spic_types[3 ]; + goto out; + } dev->control = &spic_types[2 ]; goto out; }
Signature · 1 line
1.5.5
PATCH 2/3 Add control over wifi power in Sony laptops
Sony laptops have a single hardware rfkill switch, which controls several wireless devices: wifi, bluetooth, wwan. The code to selectively control bluetooth and wwan is already present. This paths adds handling of wifi.
--- drivers/misc/sony-laptop.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-)
drivers/misc/sony-laptop.c +43 -0
@@ -1227,6 +1227,7 @@ struct sony_pic_dev {u8 camera_power;u8 bluetooth_power;u8 wwan_power; +u8 wifi_power; };static struct sony_pic_dev spic_dev = {
@@ -1760,6 +1761,7 @@ static void sony_pic_set_wwanpower(u8 state)return ; }sony_pic_call2 (0xB0 , state); +sony_pic_call1 (0x82 ); spic_dev.wwan_power = state;mutex_unlock (&spic_dev.lock); }
@@ -1788,6 +1790,45 @@ static ssize_t sony_pic_wwanpower_show(struct device *dev,return count; } +/* wifi power (TX series) */ +static void sony_pic_set_wifipower (u8 state) +{ + state = !!state; +mutex_lock (&spic_dev.lock); +if (spic_dev.wifi_power == state) { +mutex_unlock (&spic_dev.lock); +return ; + } +sony_pic_call2 (0x98 , -state); +sony_pic_call1 (0x82 ); + spic_dev.wifi_power = state; +mutex_unlock (&spic_dev.lock); +} + +static ssize_t sony_pic_wifipower_store (struct device *dev, +struct device_attribute *attr, +const char *buffer,size_t count) +{ +unsigned long value; +if (count >31 ) +return -EINVAL ; + + value =simple_strtoul (buffer,NULL ,10 ); +sony_pic_set_wifipower (value); + +return count; +} + +static ssize_t sony_pic_wifipower_show (struct device *dev, +struct device_attribute *attr,char *buffer) +{ +ssize_t count; +mutex_lock (&spic_dev.lock); + count =snprintf (buffer,PAGE_SIZE ,"%d\n" , spic_dev.wifi_power); +mutex_unlock (&spic_dev.lock); +return count; +} +/* bluetooth subsystem power state */ static void __sony_pic_set_bluetoothpower (u8 state) {
@@ -1870,11 +1911,13 @@ struct device_attribute spic_attr_##_name = __ATTR(_name, \ static SPIC_ATTR(bluetoothpower, 0644); static SPIC_ATTR(wwanpower, 0644); +static SPIC_ATTR(wifipower, 0644); static SPIC_ATTR(fanspeed, 0644);static struct attribute *spic_attributes[] = { &spic_attr_bluetoothpower.attr, &spic_attr_wwanpower.attr, + &spic_attr_wifipower.attr, &spic_attr_fanspeed.attr,NULL };
Signature · 1 line
1.5.5
PATCH 3/3 Synchronize wireless power state with hardware for Sony laptops
The drivers stores own representation of wireless power states. Since hardware switch takes presedence over software controls, internal data goes out of sync with device state, after the hardware switch is toggled.
This patch safeguards itself against possible conflicts with earlier models, and will only have any effect on the latest Type 4 devices.
--- drivers/misc/sony-laptop.c | 37 ++++++++++++++++++++++++++++++++++--- 1 files changed, 34 insertions(+), 3 deletions(-)
drivers/misc/sony-laptop.c +34 -3
@@ -281,12 +281,15 @@ static void do_sony_laptop_release_key(struct work_struct *work) static DECLARE_WORK(sony_laptop_release_key_work, do_sony_laptop_release_key); +static void sony_pic_rfkill_event (u8 is_on); +/* forward event to the input subsystem */ static void sony_laptop_report_input_event (u8 event) {struct input_dev *jog_dev = sony_laptop_input.jog_dev;struct input_dev *key_dev = sony_laptop_input.key_dev;struct sony_laptop_keypress kp = {NULL }; +u8 is_on =0 ;if (event ==SONYPI_EVENT_FNKEY_RELEASED ) {/* Nothing, not all VAIOs generate this event */
@@ -314,6 +317,15 @@ static void sony_laptop_report_input_event(u8 event) kp.dev = jog_dev;break ; +case SONYPI_EVENT_WIRELESS_ON : + is_on =1 ; +// fall through here +case SONYPI_EVENT_WIRELESS_OFF : + kp.key =KEY_WLAN ; + kp.dev = key_dev; +sony_pic_rfkill_event (is_on); +break ; +default :if (event >=ARRAY_SIZE (sony_laptop_input_index)) {dprintk ("sony_laptop_report_input_event, event not known: %d\n" , event);
@@ -1228,6 +1240,7 @@ struct sony_pic_dev {u8 bluetooth_power;u8 wwan_power;u8 wifi_power; +u8 rfkill; };static struct sony_pic_dev spic_dev = {
@@ -1756,7 +1769,7 @@ static void sony_pic_set_wwanpower(u8 state) { state = !!state;mutex_lock (&spic_dev.lock); -if (spic_dev.wwan_power == state) { +if (spic_dev.rfkill || spic_dev.wwan_power == state) {mutex_unlock (&spic_dev.lock);return ; }
@@ -1795,7 +1808,7 @@ static void sony_pic_set_wifipower(u8 state) { state = !!state;mutex_lock (&spic_dev.lock); -if (spic_dev.wifi_power == state) { +if (spic_dev.rfkill || spic_dev.wifi_power == state) {mutex_unlock (&spic_dev.lock);return ; }
@@ -1833,11 +1846,15 @@ static ssize_t sony_pic_wifipower_show(struct device *dev,static void __sony_pic_set_bluetoothpower (u8 state) { state = !!state; -if (spic_dev.bluetooth_power == state) +mutex_lock (&spic_dev.lock); +if (spic_dev.rfkill || spic_dev.bluetooth_power == state) { +mutex_unlock (&spic_dev.lock);return ; + }sony_pic_call2 (0x96 , state);sony_pic_call1 (0x82 ); spic_dev.bluetooth_power = state; +mutex_unlock (&spic_dev.lock); } static ssize_t sony_pic_bluetoothpower_store(struct device *dev,
@@ -1866,6 +1883,20 @@ static ssize_t sony_pic_bluetoothpower_show(struct device *dev,return count; } +static void sony_pic_rfkill_event (u8 is_on) +{ +if (spic_dev.control->model !=SONYPI_DEVICE_TYPE4 ) +return ; + +mutex_lock (&spic_dev.lock); + spic_dev.rfkill = ! is_on; + spic_dev.bluetooth_power = is_on; + spic_dev.wifi_power = is_on; +if (! is_on) + spic_dev.wwan_power =0 ; +mutex_unlock (&spic_dev.lock); +} +/* fan speed */ /* FAN0 information (reverse engineered from ACPI tables) */ #define SONY_PIC_FAN0_STATUS 0x93
Signature · 1 line
1.5.5
Re: [PATCH 3/3] Synchronize wireless power state with hardware for Sony laptops
Quoted 11 lines · Sergey Yanovich
The drivers stores own representation of wireless power states. Since hardware switch takes presedence over software controls, internal data goes out of sync with device state, after the hardware switch is toggled.
This patch safeguards itself against possible conflicts with earlier models, and will only have any effect on the latest Type 4 devices.
---
drivers/misc/sony-laptop.c static ssize_t sony_pic_wifipower_show(struct device *dev, · line 1849
Quoted 5 lines
drivers/misc/sony-laptop.c +1
-1@@ -1833,11 +1846,15 @@ static ssize_t sony_pic_wifipower_show(struct device *dev,static void __sony_pic_set_bluetoothpower (u8 state) { state = !!state; -if (spic_dev.bluetooth_power == state) +mutex_lock (&spic_dev.lock);
This is redundant and causing a deadlock :) Correction follows.
Signature · 1 line
Sergey Yanovich
PATCH 3/3 Synchronize wireless power state with hardware for Sony laptops
The drivers stores own representation of wireless power states. Since hardware switch takes presedence over software controls, internal data goes out of sync with device state, after the hardware switch is toggled.
This patch safeguards itself against possible conflicts with earlier models, and will only have any effect on the latest Type 4 devices.
--- drivers/misc/sony-laptop.c | 36 ++++++++++++++++++++++++++++++++---- 1 files changed, 32 insertions(+), 4 deletions(-)
drivers/misc/sony-laptop.c +32 -4
@@ -281,12 +281,15 @@ static void do_sony_laptop_release_key(struct work_struct *work) static DECLARE_WORK(sony_laptop_release_key_work, do_sony_laptop_release_key); +static void sony_pic_rfkill_event (u8 is_on); +/* forward event to the input subsystem */ static void sony_laptop_report_input_event (u8 event) {struct input_dev *jog_dev = sony_laptop_input.jog_dev;struct input_dev *key_dev = sony_laptop_input.key_dev;struct sony_laptop_keypress kp = {NULL }; +u8 is_on =0 ;if (event ==SONYPI_EVENT_FNKEY_RELEASED ) {/* Nothing, not all VAIOs generate this event */
@@ -314,6 +317,15 @@ static void sony_laptop_report_input_event(u8 event) kp.dev = jog_dev;break ; +case SONYPI_EVENT_WIRELESS_ON : + is_on =1 ; +// fall through here +case SONYPI_EVENT_WIRELESS_OFF : + kp.key =KEY_WLAN ; + kp.dev = key_dev; +sony_pic_rfkill_event (is_on); +break ; +default :if (event >=ARRAY_SIZE (sony_laptop_input_index)) {dprintk ("sony_laptop_report_input_event, event not known: %d\n" , event);
@@ -1228,6 +1240,7 @@ struct sony_pic_dev {u8 bluetooth_power;u8 wwan_power;u8 wifi_power; +u8 rfkill; };static struct sony_pic_dev spic_dev = {
@@ -1756,7 +1769,7 @@ static void sony_pic_set_wwanpower(u8 state) { state = !!state;mutex_lock (&spic_dev.lock); -if (spic_dev.wwan_power == state) { +if (spic_dev.rfkill || spic_dev.wwan_power == state) {mutex_unlock (&spic_dev.lock);return ; }
@@ -1795,7 +1808,7 @@ static void sony_pic_set_wifipower(u8 state) { state = !!state;mutex_lock (&spic_dev.lock); -if (spic_dev.wifi_power == state) { +if (spic_dev.rfkill || spic_dev.wifi_power == state) {mutex_unlock (&spic_dev.lock);return ; }
@@ -1833,7 +1846,7 @@ static ssize_t sony_pic_wifipower_show(struct device *dev,static void __sony_pic_set_bluetoothpower (u8 state) { state = !!state; -if (spic_dev.bluetooth_power == state) +if (spic_dev.rfkill || spic_dev.bluetooth_power == state)return ;sony_pic_call2 (0x96 , state);sony_pic_call1 (0x82 );
@@ -1866,6 +1879,20 @@ static ssize_t sony_pic_bluetoothpower_show(struct device *dev,return count; } +static void sony_pic_rfkill_event (u8 is_on) +{ +if (spic_dev.control->model !=SONYPI_DEVICE_TYPE4 ) +return ; + +mutex_lock (&spic_dev.lock); + spic_dev.rfkill = ! is_on; + spic_dev.bluetooth_power = is_on; + spic_dev.wifi_power = is_on; +if (! is_on) + spic_dev.wwan_power =0 ; +mutex_unlock (&spic_dev.lock); +} +/* fan speed */ /* FAN0 information (reverse engineered from ACPI tables) */ #define SONY_PIC_FAN0_STATUS 0x93
@@ -2684,7 +2711,8 @@ static int sony_pic_add(struct acpi_device *device) goto err_free_irq; } - spic_dev.bluetooth_power =-1 ; + spic_dev.bluetooth_power =1 ; + spic_dev.wifi_power =1 ;/* create device attributes */ result =sony_pf_add ();if (result)
Signature · 1 line
1.5.5
PATCH 1/1 acpi: synchronize wireless power state for Sony laptops
The drivers stores own representation of wireless power states. Since hardware switch takes presedence over software controls, internal data goes out of sync with device state, after the hardware switch is toggled.
This patch safeguards itself against possible conflicts with earlier models, and will only have any effect on the latest Type 4 devices.
--- drivers/misc/sony-laptop.c | 36 ++++++++++++++++++++++++++++++++---- 1 files changed, 32 insertions(+), 4 deletions(-)
drivers/misc/sony-laptop.c +32 -4
@@ -281,12 +281,15 @@ static void do_sony_laptop_release_key(struct work_struct *work) static DECLARE_WORK(sony_laptop_release_key_work, do_sony_laptop_release_key); +static void sony_pic_rfkill_event (u8 is_on); +/* forward event to the input subsystem */ static void sony_laptop_report_input_event (u8 event) {struct input_dev *jog_dev = sony_laptop_input.jog_dev;struct input_dev *key_dev = sony_laptop_input.key_dev;struct sony_laptop_keypress kp = {NULL }; +u8 is_on =0 ;if (event ==SONYPI_EVENT_FNKEY_RELEASED ) {/* Nothing, not all VAIOs generate this event */
@@ -314,6 +317,15 @@ static void sony_laptop_report_input_event(u8 event) kp.dev = jog_dev;break ; +case SONYPI_EVENT_WIRELESS_ON : + is_on =1 ; +/* fall through here */ +case SONYPI_EVENT_WIRELESS_OFF : + kp.key =KEY_WLAN ; + kp.dev = key_dev; +sony_pic_rfkill_event (is_on); +break ; +default :if (event >=ARRAY_SIZE (sony_laptop_input_index)) {dprintk ("sony_laptop_report_input_event, event not known: %d\n" , event);
@@ -1228,6 +1240,7 @@ struct sony_pic_dev {u8 bluetooth_power;u8 wwan_power;u8 wifi_power; +u8 rfkill; };static struct sony_pic_dev spic_dev = {
@@ -1756,7 +1769,7 @@ static void sony_pic_set_wwanpower(u8 state) { state = !!state;mutex_lock (&spic_dev.lock); -if (spic_dev.wwan_power == state) { +if (spic_dev.rfkill || spic_dev.wwan_power == state) {mutex_unlock (&spic_dev.lock);return ; }
@@ -1795,7 +1808,7 @@ static void sony_pic_set_wifipower(u8 state) { state = !!state;mutex_lock (&spic_dev.lock); -if (spic_dev.wifi_power == state) { +if (spic_dev.rfkill || spic_dev.wifi_power == state) {mutex_unlock (&spic_dev.lock);return ; }
@@ -1832,7 +1845,7 @@ static ssize_t sony_pic_wifipower_show(struct device *dev,static void __sony_pic_set_bluetoothpower (u8 state) { state = !!state; -if (spic_dev.bluetooth_power == state) +if (spic_dev.rfkill || spic_dev.bluetooth_power == state)return ;sony_pic_call2 (0x96 , state);sony_pic_call1 (0x82 );
@@ -1865,6 +1878,20 @@ static ssize_t sony_pic_bluetoothpower_show(struct device *dev,return count; } +static void sony_pic_rfkill_event (u8 is_on) +{ +if (spic_dev.control->model !=SONYPI_DEVICE_TYPE4 ) +return ; + +mutex_lock (&spic_dev.lock); + spic_dev.rfkill = !is_on; + spic_dev.bluetooth_power = is_on; + spic_dev.wifi_power = is_on; +if (!is_on) + spic_dev.wwan_power =0 ; +mutex_unlock (&spic_dev.lock); +} +/* fan speed */ /* FAN0 information (reverse engineered from ACPI tables) */ #define SONY_PIC_FAN0_STATUS 0x93
@@ -2683,7 +2710,8 @@ static int sony_pic_add(struct acpi_device *device) goto err_free_irq; } - spic_dev.bluetooth_power =-1 ; + spic_dev.bluetooth_power =1 ; + spic_dev.wifi_power =1 ;/* create device attributes */ result =sony_pf_add ();if (result)
Signature · 1 line
1.5.5.1
Re: [PATCH 3/3] Synchronize wireless power state with hardware for Sony laptops
In reply to Sergey YanovichQuoted 8 lines · Sergey Yanovich
The drivers stores own representation of wireless power states. Since hardware switch takes presedence over software controls, internal data goes out of sync with device state, after the hardware switch is toggled.
This patch safeguards itself against possible conflicts with earlier models, and will only have any effect on the latest Type 4 devices.
---
I am enclosing a script, which I use with acpid and invoke by Fn-F1. It makes the wireless leds blink like a Christmas tree.
Signature · 1 line
Sergey Yanovich
PATCH 1/1 acpi: add control over wifi power in Sony laptops
In reply to Sergey YanovichSony laptops have a single hardware rfkill switch, which controls several wireless devices: wifi, bluetooth, wwan. The code to selectively control bluetooth and wwan is already present. This paths adds handling of wifi.
--- drivers/misc/sony-laptop.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-)
drivers/misc/sony-laptop.c +42 -0
@@ -1227,6 +1227,7 @@ struct sony_pic_dev {u8 camera_power;u8 bluetooth_power;u8 wwan_power; +u8 wifi_power; };static struct sony_pic_dev spic_dev = {
@@ -1760,6 +1761,7 @@ static void sony_pic_set_wwanpower(u8 state)return ; }sony_pic_call2 (0xB0 , state); +sony_pic_call1 (0x82 ); spic_dev.wwan_power = state;mutex_unlock (&spic_dev.lock); }
@@ -1788,6 +1790,44 @@ static ssize_t sony_pic_wwanpower_show(struct device *dev,return count; } +/* wifi power (TX series) */ +static void sony_pic_set_wifipower (u8 state) +{ + state = !!state; +mutex_lock (&spic_dev.lock); +if (spic_dev.wifi_power == state) { +mutex_unlock (&spic_dev.lock); +return ; + } +sony_pic_call2 (0x98 , -state); +sony_pic_call1 (0x82 ); + spic_dev.wifi_power = state; +mutex_unlock (&spic_dev.lock); +} + +static ssize_t sony_pic_wifipower_store (struct device *dev, +struct device_attribute *attr, +const char *buffer,size_t count) +{ +unsigned long value; +if (!strict_strtoul (buffer,10 , &value)) +return -EINVAL ; + +sony_pic_set_wifipower (value); + +return count; +} + +static ssize_t sony_pic_wifipower_show (struct device *dev, +struct device_attribute *attr,char *buffer) +{ +ssize_t count; +mutex_lock (&spic_dev.lock); + count =snprintf (buffer,PAGE_SIZE ,"%d\n" , spic_dev.wifi_power); +mutex_unlock (&spic_dev.lock); +return count; +} +/* bluetooth subsystem power state */ static void __sony_pic_set_bluetoothpower (u8 state) {
@@ -1870,11 +1910,13 @@ struct device_attribute spic_attr_##_name = __ATTR(_name, \ static SPIC_ATTR(bluetoothpower, 0644); static SPIC_ATTR(wwanpower, 0644); +static SPIC_ATTR(wifipower, 0644); static SPIC_ATTR(fanspeed, 0644);static struct attribute *spic_attributes[] = { &spic_attr_bluetoothpower.attr, &spic_attr_wwanpower.attr, + &spic_attr_wifipower.attr, &spic_attr_fanspeed.attr,NULL };
Signature · 1 line
1.5.5.1
Mattia Dongili
NAKQuoted 3 lines · Sergey Yanovich
This laptop has Type 4 SPIC device, support for which has been added recently. This device resides behind an older ISA bridge and was earlier incorrectly detected as Type 3.
NAK, introducing Type4 was actually a mistake in the beginning. Soon after my patches have been merged into mainline I had reports from Type3 users who would actually benefit from the same extra hotkey handling implemented for the Type4.
What I'm going to do is remove the Type3/Type4 distinction, this should be enough.
Cheers
Signature · 2 lines
mattia :wq!
Quoted 2 lines · Mattia Dongili
What I'm going to do is remove the Type3/Type4 distinction, this should be enough.
Great to hear, that the problem is being addressed. It'll be nice to have all keys working with a stock kernel.
Any comments about wifi power and state sync patches?
Cheers,
Signature · 1 line
Sergey Yanovich
Quoted 8 lines · Sergey Yanovich
Quoted 2 lines · Mattia Dongili
What I'm going to do is remove the Type3/Type4 distinction, this should be enough.
Great to hear, that the problem is being addressed. It'll be nice to have all keys working with a stock kernel.
Any comments about wifi power and state sync patches?
Yes, they are missing your sign off ;)
The wifi power patch seems ok.
The state sync patch instead I'd like to rework things a little but it definitely makes sense.
Oh, last but not least, give your patches a go through scripts/checkpatch.pl
Thanks
Signature · 2 lines
mattia :wq!