You are not logged in.

#1 2020-04-15 16:51:48

laggykiller
Member
Registered: 2020-04-12
Posts: 31

Getting graphics switch key to work on Sony Vaio VGN-Z46GD?

I am trying to get the hybrid graphics switch key (Stamina-Speed switch) to work on Sony Vaio VGN-Z46GD.
I have already figured out how to switch between Intel and Nvidia graphics card by using bash scripts. I am thinking to treat the graphics switch key as a hotkey, which when the switch key is flipped, it triggers my bash script to handle the graphics card switching.
Currently, it seems that Arch Linux cannot detect the switch key hardware, as the lights next to the switch do not light up (Interestingly, if I use Tiny Core Linux (Ubuntu? I can't remember. Give me some time to test), the 'stamina' light lits, though it cannot switch graphics card).
Is it possible to get graphics switch key to work? Is there any kernel modules, packages, scripts that can help detect the state of the switch key?
Not sure if this helps, but this is an image of the hybrid graphics switch key: https://imgur.com/a/6Kr0N6F

It would be so cool if it works smile

Last edited by laggykiller (2020-04-15 18:15:37)

Offline

#2 2020-04-15 17:07:40

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,771
Website

Re: Getting graphics switch key to work on Sony Vaio VGN-Z46GD?

Check under /sys/class/leds/ to see if the kernel exposes that hardware interface. A comparison with TinyCore might prove illuminating, if you'll pardon the pun big_smile

Offline

#3 2020-04-15 18:06:40

laggykiller
Member
Registered: 2020-04-12
Posts: 31

Re: Getting graphics switch key to work on Sony Vaio VGN-Z46GD?

$ cat /sys/class/leds
input2::capslock  input2::numlock  input2::scrolllock  mmc0::  phy0-led

Based on the naming and max_brightness setting of 1, it seems that phy0-led might have a chance to be the LED light of the graphics switch.

$ sudo tee /sys/class/leds/brightness <<< 1
1
$ cat /sys/class/leds/brightness
1

However, the LED light does not light up. It seems that it either do not correspond to the graphics switch key (and may require kernel modules...?), or I am doing something wrong.

Getting the LED light would be a bonus, but at this moment I am more interested in getting the switch to work. Is it likely for me to find it in /sys/class/input ? Or is there other places that I may consider having a look?
Here is an output of xinput --list

$ xinput --list
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ Sony Vaio Jogdial                       	id=9	[slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS GlidePoint                	id=12	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Sony Vaio Keys                          	id=8	[slave  keyboard (3)]
    ↳ Power Button                            	id=10	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=11	[slave  keyboard (3)]
    ↳ Video Bus                               	id=6	[slave  keyboard (3)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]

It seems like device 6 and 7 are likely to correspond to graphics switch?
I tried to enable all device with sudo xinput enable n (n equals to id given in xinput --list), then run xinput test-xi2 --root. Unfortunately, it fails to detect me flicking the graphics switch.
Interestingly, the 'S1' and 'S2' buttons located below the graphics switch (id=8) could be detected.

Last edited by laggykiller (2020-04-15 18:09:03)

Offline

#4 2020-04-15 18:16:10

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,771
Website

Re: Getting graphics switch key to work on Sony Vaio VGN-Z46GD?

laggykiller wrote:

Is it likely for me to find it in /sys/class/input ? Or is there other places that I may consider having a look?

Not sure tbh but syphilisfs sysfs is full of interesting odities so have a browse around and see what you can see.

You could try

# dmesg -w

Then flick the switch a few times to see if it's recorded by the kernel ring buffer.

Offline

#5 2020-04-15 19:15:10

laggykiller
Member
Registered: 2020-04-12
Posts: 31

Re: Getting graphics switch key to work on Sony Vaio VGN-Z46GD?

Tried dmesg -w without success sad
Also I found this Arch wiki entry for a similar (?) model just now: https://wiki.archlinux.org/index.php/So … _VGN-SA/SB

"STAMINA-SPEED" switch is designed as a software switch. This DIP switch is located on one of the individual circuit from mainboard, separately. For easy to understand it, just imagine such as a wireless switch on laptop computers. Therefore, there is nothing to do; feel free to control this switch.

This sounds discouraging, but I don't want to give up (yet). Assuming my laptop has the same design, is there any way to detect the switch?
If it is a 'software switch', then why it seems that Arch linux can detect the presence of 'Video Bus' input device, but cannot detect what position the switch is in?

Last edited by laggykiller (2020-04-15 19:17:24)

Offline

#6 2020-11-24 14:30:37

laggykiller
Member
Registered: 2020-04-12
Posts: 31

Re: Getting graphics switch key to work on Sony Vaio VGN-Z46GD?

Here is an update!

I still have not figure out how to make the LED next to the switch work...

However, I have found out how to read the state of the switch:

If switch is at stamina position:

$ cat /sys/devices/platform/sony-laptop/gfx_switch_status
stamina

If switch is at speed position:

$ cat /sys/devices/platform/sony-laptop/gfx_switch_status
speed

For reference:

$ ls -la /sys/devices/platform/sony-laptop
total 0
drwxr-xr-x  3 root root    0 Nov 24 18:44 .
drwxr-xr-x 18 root root    0 Nov 24 18:44 ..
-rw-r--r--  1 root root 4096 Nov 24 19:08 battery_care_limiter
-rw-r--r--  1 root root 4096 Nov 24 19:08 bluetoothpower
lrwxrwxrwx  1 root root    0 Nov 24 18:44 driver -> ../../../bus/platform/drivers/sony-laptop
-rw-r--r--  1 root root 4096 Nov 24 19:08 driver_override
-rw-r--r--  1 root root 4096 Nov 24 20:30 fanspeed
-r--r--r--  1 root root 4096 Nov 24 19:08 gfx_switch_status
-rw-r--r--  1 root root 4096 Nov 24 19:08 lid_resume_S3
-rw-r--r--  1 root root 4096 Nov 24 19:08 lid_resume_S4
-rw-r--r--  1 root root 4096 Nov 24 19:08 lid_resume_S5
-rw-r--r--  1 root root 4096 Nov 24 19:08 lowbatt_hibernate
-r--r--r--  1 root root 4096 Nov 24 19:08 modalias
-r--r--r--  1 root root 4096 Nov 24 19:08 panel_id
drwxr-xr-x  2 root root    0 Nov 24 18:44 power
lrwxrwxrwx  1 root root    0 Nov 24 19:08 subsystem -> ../../../bus/platform
-rw-r--r--  1 root root 4096 Nov 24 22:01 thermal_control
-r--r--r--  1 root root 4096 Nov 24 19:08 thermal_profiles
-rw-r--r--  1 root root 4096 Nov 24 19:08 touchpad
-rw-r--r--  1 root root 4096 Nov 24 18:44 uevent
-rw-r--r--  1 root root 4096 Nov 24 19:08 wwanpower

Note that value of gfx_switch_status reflect the physical state of the switch - It's value cannot be changed by echo or tee.

Moreover, I have even found out how to detect the change of switch position with help from studying this github repository: https://github.com/win9z/vaio-s-acpi-script

Here is what I have done to make switch position detection work:
1. Install acpid

$ sudo pacman -S acpid
$ sudo systemctl enable acpid
$ sudo systemctl start acpid

2. Create file

$ cat /etc/acpi/events/sony-laptop
event=sony/hotkey SNY5001:00
action=/etc/acpi/actions/sony-laptop.sh %e

3. Create bash script

$ cat /etc/acpi/actions/sony-laptop.sh
#!/bin/bash
if [ $3 == "00000003" ] ; then
    if [ $4 == "00000000" ]; then
        echo "You have changed the switch position to SPEED position"
    elif [ $4 == "00000001" ]; then
        echo "You have changed the switch position to STAMINA position"
fi

4. Give permission to shell script

$ sudo chmod 755 /etc/acpi/actions/sony-laptop.sh

5. Reboot

I hope this information can help people who stumble into this thread, and I hope someone can guess why the LED is not working based on the above information big_smile

Last edited by laggykiller (2020-11-24 15:02:24)

Offline

#7 2020-11-25 11:09:10

laggykiller
Member
Registered: 2020-04-12
Posts: 31

Re: Getting graphics switch key to work on Sony Vaio VGN-Z46GD?

I think I have found a solution to the graphics switch light problem, but it brings a lot of very odd side effects that I refuse to recognize it as a solution...

What I have done
In grub kernel boot parameter, I added the following:

acpi_osi="!Windows 2006"

What happen BEFORE adding the boot parameter
- Graphics switch light does not light up during boot process
- Graphics switch light lights up when booting to Windows 10
- Graphics switch light does not light when booting to arch linux
- Arch linux successfully detect graphics switch light, as shown from the presence of /sys/devices/platform/sony-laptop/gfx_switch_status
- No matter which position the graphics switch is, lspci shows the presence of NVIDIA graphics card
- When using nvidia graphics card, diagonal tearing appear, which I cannot fix but got used to it. For reference, my Xorg configuration for nvidia is:

Section "Module"
    Load "modesetting"
EndSection

Section "Files"
   ModulePath "/nvidia/glx,/nvidia/lib,/usr/lib/xorg/modules"
EndSection

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1:0:0"
    # Option "AllowEmptyInitialConfiguration" "on"
    Option "DPI" "96 x 96"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Monitor "HDMI-1-0"
    DefaultDepth 24
EndSection

# Section "Monitor"
#     Identifier "LVDS-0"
#     Option "Ignore" "true"
# EndSection

Section "ServerFlags"
    Option "DontZap" "false"
EndSection

Section "InputClass"
    Identifier      "Keyboard Defaults"
    MatchIsKeyboard "yes"
    Option          "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection

What happen AFTER adding the boot parameter (immediately after)
- Arch linux fails to detect graphics switch light, as shown from the absence of /sys/devices/platform/sony-laptop/gfx_switch_status
- Graphics switch light still does not light up
- Otherwise, nothing interesting happen, unless we reboot...

What happen AFTER adding the boot parameter (rebooting)
- The compute enters into 'weird state' (Explained below)
- It takes a bit longer to boot to grub (About 2-3 seconds longer)
- Grub resolution is reduced
- Graphics switch light lights up during boot process according to it's position at boot
- When booting into arch linux at SPEED position, a splash screen showing NVIDIA and it's logo briefly appear on screen while linux boots up, immediately before starting Xorg
- Arch linux successfully detect graphics switch light, as shown from the presence of /sys/devices/platform/sony-laptop/gfx_switch_status
- Changing position of the switch does not change graphics switch light to the correct one
- When booting into arch linux at SPEED position, I cannot switch to using intel using softward method (Which worked before adding the boot parameter)
- When booting into arch linux at STAMINA position, lspci show that NVIDIA graphics card is absent, even if I sudo tee "/sys/bus/pci/rescan" <<< 1
- /sys/class/leds does not have any new entry
- Diagonal tearing disappear, but now the screen randomly flash black for about 100ms, about once in a minute
- Unable to change backlight level. Here are the kernel parameters that I have tried to add to solve:

acpi_backlight=video
acpi_backlight=vendor
acpi_backlight=native
acpi_backlight=none

- Using reboot in Windows and Arch linux cause the machine to shutdown instead of reboot
- 'Weird state' lasts even if I remove the kernel option and reboot
- If I reboot into Windows at 'weird state', Windows resolution is reduced. Rebooting again will cause the 'weird state' disappear and Windows resolution become normal again

Conclusion
Too many things are happening. What is happening? Can any recommendations be given based on these information, such that the graphics switch light works again / diagonal tearing no longer appear without causing those side effects?

In the future I shall experiment with:
- Custom DSDT (UPDATE: I tried to make my custom dsdt.aml using instruction by arch wiki. If I do not add the acpi_osi kernel configuration and use custom dsdt.aml, booting is normal. However, if I add the acpi_osi kernal configuration and use custom dsdt.aml, it boots into black screen)
- setpci to turn on / off the switch light with bash script

I hope this information is useful for those who found my thread, as well as those who want to solve this mystery tongue

Last edited by laggykiller (2020-11-25 17:49:16)

Offline

Board footer

Powered by FluxBB