autorandr icon indicating copy to clipboard operation
autorandr copied to clipboard

autorandr not working on Nvidia Optimus device

Open 9las opened this issue 4 years ago • 4 comments

Hi, I have a computer (81SX0008MX Legion Y540-15IRH) that uses the NVIDIA Optimus technology. I have trouble making autorandr work when enabling "Switchable Graphics" in the firmware settings menu and with the early DRM kernel mode setting. It works fine when I use "Discrete Graphics" instead and the late DRM kernel mode setting (nvidia-drm.modeset=1 kernel parameter). When I have "Switchable Graphics" enabled and the early DRM kernel mode setting, then autorandr does detect when I plug in my DisplayPort cable and plug it out again (I can see this by running autorandr --detected). But the laptop monitor does not turn off and I receive no picture on the external monitor. Using xrandr manually to switch displays does work though. What might be the cause of this?

9las avatar Nov 16 '20 12:11 9las

I am noticing that the monitors have different names when using "Discrete Graphics" from when using "Switchable Graphics". I have set autorandr up with the matching names used under "Switchable Graphics" though.

Output from xrandr -q ("Discrete Graphics"):

Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
DP-0 disconnected primary (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
DP-2 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   1920x1080    144.00*+
DP-3 connected (normal left inverted right x axis y axis)
   2560x1440     59.95 +
   1920x1200     59.88  
   1920x1080     60.00    59.94    50.00    23.98  
   1680x1050     59.95  
   1600x1200     60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.93    59.94  
DP-4 disconnected (normal left inverted right x axis y axis)

Output from xrandr -q ("Switchable Graphics"):

Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
eDP-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   1920x1080    144.00*+  60.01    59.97    59.96    59.93  
   1680x1050     59.95    59.88  
   1400x1050     74.76    59.98  
   1600x900      59.99    59.94    59.95    59.82  
   1280x1024     85.02    75.02    60.02  
   1400x900      59.96    59.88  
   1280x960      85.00    60.00  
   1440x810      60.00    59.97  
   1368x768      59.88    59.85  
   1280x800      59.99    59.97    59.81    59.91  
   1152x864      75.00  
   1280x720      60.00    59.99    59.86    59.74  
   1024x768      85.00    75.05    60.04    85.00    75.03    70.07    60.00  
   1024x768i     86.96  
   960x720       85.00    75.00    60.00  
   928x696       75.00    60.05  
   896x672       75.05    60.01  
   1024x576      59.95    59.96    59.90    59.82  
   960x600       59.93    60.00  
   832x624       74.55  
   960x540       59.96    59.99    59.63    59.82  
   800x600       85.00    75.00    70.00    65.00    60.00    85.14    72.19    75.00    60.32    56.25  
   840x525       60.01    59.88  
   864x486       59.92    59.57  
   700x525       74.76    59.98  
   800x450       59.95    59.82  
   640x512       85.02    75.02    60.02  
   700x450       59.96    59.88  
   640x480       85.09    60.00    85.01    72.81    75.00    59.94  
   720x405       59.51    58.99  
   720x400       85.04  
   684x384       59.88    59.85  
   640x400       59.88    59.98    85.08  
   576x432       75.00  
   640x360       59.86    59.83    59.84    59.32  
   640x350       85.08  
   512x384       85.00    75.03    70.07    60.00  
   512x384i      87.06  
   512x288       60.00    59.92  
   416x312       74.66  
   480x270       59.63    59.82  
   400x300       85.27    72.19    75.12    60.32    56.34  
   432x243       59.92    59.57  
   320x240       85.18    72.81    75.00    60.05  
   360x202       59.51    59.13  
   360x200       85.04  
   320x200       85.27  
   320x180       59.84    59.32  
   320x175       85.27  
DP-1-0 disconnected
DP-1-1 disconnected
HDMI-1-0 disconnected
DP-1-2 connected
   2560x1440     59.95 +
   1920x1200     59.88  
   1920x1080     60.00    59.94    50.00    23.98  
   1680x1050     59.95  
   1600x1200     60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.93    59.94  
DP-1-3 disconnected
  1680x1050 (0x49) 146.250MHz -HSync +VSync
        h: width  1680 start 1784 end 1960 total 2240 skew    0 clock  65.29KHz
        v: height 1050 start 1053 end 1059 total 1089           clock  59.95Hz
  1280x1024 (0x52) 135.000MHz +HSync +VSync
        h: width  1280 start 1296 end 1440 total 1688 skew    0 clock  79.98KHz
        v: height 1024 start 1025 end 1028 total 1066           clock  75.02Hz
  1280x1024 (0x53) 108.000MHz +HSync +VSync
        h: width  1280 start 1328 end 1440 total 1688 skew    0 clock  63.98KHz
        v: height 1024 start 1025 end 1028 total 1066           clock  60.02Hz
  1280x800 (0x5e) 83.500MHz -HSync +VSync
        h: width  1280 start 1352 end 1480 total 1680 skew    0 clock  49.70KHz
        v: height  800 start  803 end  809 total  831           clock  59.81Hz
  1152x864 (0x60) 108.000MHz +HSync +VSync
        h: width  1152 start 1216 end 1344 total 1600 skew    0 clock  67.50KHz
        v: height  864 start  865 end  868 total  900           clock  75.00Hz
  1024x768 (0x69) 78.750MHz +HSync +VSync
        h: width  1024 start 1040 end 1136 total 1312 skew    0 clock  60.02KHz
        v: height  768 start  769 end  772 total  800           clock  75.03Hz
  1024x768 (0x6b) 65.000MHz -HSync -VSync
        h: width  1024 start 1048 end 1184 total 1344 skew    0 clock  48.36KHz
        v: height  768 start  771 end  777 total  806           clock  60.00Hz
  800x600 (0x86) 49.500MHz +HSync +VSync
        h: width   800 start  816 end  896 total 1056 skew    0 clock  46.88KHz
        v: height  600 start  601 end  604 total  625           clock  75.00Hz
  800x600 (0x87) 40.000MHz +HSync +VSync
        h: width   800 start  840 end  968 total 1056 skew    0 clock  37.88KHz
        v: height  600 start  601 end  605 total  628           clock  60.32Hz
  640x480 (0x9a) 31.500MHz -HSync -VSync
        h: width   640 start  656 end  720 total  840 skew    0 clock  37.50KHz
        v: height  480 start  481 end  484 total  500           clock  75.00Hz
  640x480 (0x9b) 25.175MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
        v: height  480 start  490 end  492 total  525           clock  59.94Hz

9las avatar Nov 17 '20 11:11 9las

I have just discovered that I get the following from the command autorandr --debug --change:

docked (detected)
mobile (current)
Loading profile 'docked'
| Differences between the two profiles:
| [Output eDP-1] The output is currently enabled, but inactive in the new configuration
| [Output DP-1-2] The output is disabled currently, but active in the new configuration
\-
Going to run:
xrandr --fb 2560x1440 --output eDP-1 --off --output DP-1-2 --crtc 0 --gamma 1.0:1.0:1.0 --mode 2560x1440 --pos 0x0 --primary --rate 59.95 --reflect normal --rotate normal
xrandr: output DP-1-2 cannot use crtc 0x3f
Failed to apply profile 'docked' (line 857):
  Command failed: xrandr --fb 2560x1440 --output eDP-1 --off --output DP-1-2 --crtc 0 --gamma 1.0:1.0:1.0 --mode 2560x1440 --pos 0x0 --primary --rate 59.95 --reflect normal --rotate normal (line 857)

That is I get the error xrandr: output DP-1-2 cannot use crtc 0x3f When I save the profiles using the option --skip-options crtc then I can switch profiles using the command autorandr --change and the picture switches between my monitors. However, the pictures do still not switch between my monitors when I unplug and plug in the cable.

This is the output from running autorandr --debug --change after I have saved the profiles using the the option --skip-options crtc :

mobile                                             
docked (detected)
| Differences between the two profiles:
| [Output DP-1-2] The output is disabled currently, but active in the new configuration
| [Output eDP-1] The output is currently enabled, but inactive in the new configuration
\-
Loading profile 'docked'
| Differences between the two profiles:
| [Output DP-1-2] The output is disabled currently, but active in the new configuration
| [Output eDP-1] The output is currently enabled, but inactive in the new configuration
\-
Going to run:
xrandr --fb 2560x1440 --output eDP-1 --off --output DP-1-2 --gamma 1.0:1.0:1.0 --mode 2560x1440 --pos 0x0 --primary --rate 59.95 --reflect normal --rotate normal
The configuration change did not go as expected:
| Differences between the two profiles:
| [Output DP-1-2] Option --crtc (= `0') is not present in the new configuration
\-

9las avatar Nov 20 '20 01:11 9las

@phillipberndt Do you have an idea of why I can switch between my monitors using the autorandr --change command after plugging/unplugging the cable to my external monitor but that the switch does not happen automatically (I have to use the command to make the switch happen).

9las avatar Nov 24 '20 23:11 9las

What means of running it automatically do you use? Have you tried the others? (E.g. launcher instead of udev)

You might also have to patch them to include the option to skip the crtc config - if doing that works, that'd mean we have to include a patch in autorandr to persist this option somewhere else, presumably in the configuration itself.

phillipberndt avatar Nov 25 '20 06:11 phillipberndt