# xrandr activating 3rd screen takes long time

## Massimo B.

Hi,

I have a Laptop with 3 display connectors like DVI-D, Display-Port and VGA. Using all 3 the builtin LCD does turn off.

When X does start with the Login screen (lightdm), 2 screens are active. Inside Xfce I have configured the 3rd screen (VGA) which is configured via xrandr I guess. Now every login takes very long about 3-4 minutes, until the 3rd screen (VGA) becomes active and configured. In the log I found these lines:

```
Nov 07 10:39:31 [kernel] [drm:0xffffffff81303ce9] *ERROR* unable to allocate a PPLL

Nov 07 10:39:31 [kernel] [drm:0xffffffff812bc8a6] *ERROR* failed to set mode on [CRTC:40:crtc-3]

Nov 07 10:39:31 [kernel] [drm:0xffffffff81303ce9] *ERROR* unable to allocate a PPLL

Nov 07 10:39:31 [kernel] [drm:0xffffffff812bc8a6] *ERROR* failed to set mode on [CRTC:40:crtc-3]

Nov 07 10:39:31 [kernel] [drm:0xffffffff81303ce9] *ERROR* unable to allocate a PPLL

Nov 07 10:39:31 [kernel] [drm:0xffffffff812bc8a6] *ERROR* failed to set mode on [CRTC:40:crtc-3]

Nov 07 10:39:31 [kernel] Console: switching to colour frame buffer device 200x56

Nov 07 10:39:31 [kernel] [drm:0xffffffff81303ce9] *ERROR* unable to allocate a PPLL

Nov 07 10:39:31 [kernel] [drm:0xffffffff812bc8a6] *ERROR* failed to set mode on [CRTC:40:crtc-3]

Nov 07 10:39:31 [kernel] radeon 0000:01:00.0: fb0: radeondrmfb frame buffer device

Nov 07 10:39:31 [kernel] [drm] Initialized radeon 2.46.0 20080528 for 0000:01:00.0 on minor 0
```

Why is the cause and how can I solve this?

Hardware is

```
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Whistler [Radeon HD 6730M/6770M/7690M XT]
```

----------

## Zucca

I've had similar problems with my laptop before. My solution was to have a script that was run at the start of the wm. The script would first disable the laptop's own panel by

```
xrandr --output <LAPTOP_MONITOR> --off
```

... and then turn on the external monitors using --auto -switch.

Although you can also turn on and off more monitors with just one xrandr -command, it still may need a small sleep between turning off the first display and turning on the external display(s).

Anyway... If you turn off the third monitor (inside wm) using xrandr and then back on, does any error get printed to the terminal?

----------

## Massimo B.

Hi, I tried some stuff manually:

--listmonitors and --listactivemonitors are always equal. Initially looks like that:

```
Monitors: 3

 0: +*DisplayPort-1 1920/518x1200/324+1680+0  DisplayPort-1

 1: +VGA-0 1680/474x1050/296+0+0  VGA-0

 2: +DisplayPort-2 1680/433x1050/271+0+0  DisplayPort-2
```

Switching the VGA off the VGA disappears from list:

```
$ xrandr --output VGA-0 --off

$ xrandr --listmonitors 

Monitors: 2

 0: +*DisplayPort-1 1920/518x1200/324+1680+0  DisplayPort-1

 1: +DisplayPort-2 1680/433x1050/271+0+0  DisplayPort-2
```

Switching on again works fine without delay:

```
$ xrandr --output VGA-0 --auto
```

You are right, starting X with lightdm, the internal display (LVDS) is on eventhough the lid was closed. Where should I place such a script turning off LVDS when logging in?

I would like to have the same setup configured within WM using some xrandr gui also in the initial X with lightdm. But I did not find a way to export the xrandr calls from Xfce to some xorg.conf if not writing my own xorg.conf.

But using the xrandr GUIs it's always easy to setup and place very different monitors with different resultions side by side.

Testing further:

Turning on the internal display while VGA is still active does not work:

```
$ xrandr --output LVDS --auto

xrandr: Configure crtc 3 failed
```

Too bad, that would mean 4 active monitors including the internal one. I would like that. But maybe restricted by hardware. This wasn't possible in the original operating system (MS) with manufacturer drivers either.

So this is working without delay:

```
$ xrandr --output VGA-0 --off --output LVDS --auto
```

And this as well:

```
$ xrandr --output LVDS --off --output VGA-0 --auto
```

So why is this failing at WM login? And if I do it as you proposed, what happens if I'm on the road without screens, I like to have that all automatically, also by hotplugging with running X as I need to move the laptop from 3 screens desktop to the presentation with VGA beamer. Next thing will be if Xfce will be able to setup the same panels on every screen when switching between those environments.

----------

## Zucca

 *Massimo B. wrote:*   

> You are right, starting X with lightdm, the internal display (LVDS) is on eventhough the lid was closed. Where should I place such a script turning off LVDS when logging in?
> 
> I would like to have the same setup configured within WM using some xrandr gui also in the initial X with lightdm. But I did not find a way to export the xrandr calls from Xfce to some xorg.conf if not writing my own xorg.conf.
> 
> But using the xrandr GUIs it's always easy to setup and place very different monitors with different resultions side by side.

 I've left my xorg.configs pretty empty, but as this PC is dual seated I have something there, but not relevant to the issue here.

Instead of xorg.configs I use plain xrandr to set up my monitors correctly.

Well not exatly plain xrandr but bash, awk and xrandr to set my monitor settings automatically.

You need to edit /etc/lightdm/lightdm.conf. And put under the [Seat:*] -section somelike this:

```
display-setup-script=/etc/lightdm/display-setup.sh
```

You can then probe with the script which monitors (the physical ones) are connected.

I'm not sure how I'd do it on-the-fly without first locking the session or logging out.

Here's a function I use commonly when I need to list the monitors.

```
function list-monitors {

    # first argument to this function should only have values "connected", "disconnected", "" or NULL.

    xrandr | awk '/^[[:alnum:]-]+ '$1'/ {if ($1 != "Screen") print $1}'

}
```

And here's an exaple you you can use it:

```
zucca@wren ~ $ list-monitors 

DisplayPort-0

DisplayPort-1

DisplayPort-2

HDMI-A-1

zucca@wren ~ $ list-monitors connected

DisplayPort-2

HDMI-A-1

zucca@wren ~ $ list-monitors disconnected

DisplayPort-0

DisplayPort-1
```

Now with that you can easily:

Turn off all the disconnected monitors:

```
xrandr $(list-monitors disconnected | awk '{print "--output " $1 " --off"}')
```

Turn on all monitors except the laptop display:

```
xrandr $(list-monitors connected | grep -v LAPTOPDISP | awk '{print "--output " $1 " --auto"}')
```

LAPTOPDISP being the name for your internal laptop display (LVDS?).

Both above combined:

```
xrandr $(list-monitors disconnected | awk '{print "--output " $1 " --off"}') --output LAPTOPDISP --off $(list-monitors connected | grep -v LAPTOPDISP | awk '{print "--output " $1 " --auto"}')
```

I hope those code snippets made any sense.  :Very Happy:  But yeah. I'm using those in various ways to automatically turn on and off displays in different situations.

I hope this gets you started and you get the problem fixed.

----------

## Massimo B.

Thank you for the scripts, I'm going to test that...

I first try with some hard switchoff:

```
# grep display-setup /etc/lightdm/lightdm.conf 

display-setup-script=/usr/local/bin/2xrandr_singleScreen

# cat /usr/local/bin/2xrandr_singleScreen

#!/usr/bin/env bash

xrandr --output VGA-0 --off --output LVDS --off --output DisplayPort-0 --off
```

What does disconnected mean? Does X remember screens that have been connected some day before?

----------

## Zucca

 *Massimo B. wrote:*   

> What does disconnected mean? Does X remember screens that have been connected some day before?

 Nah. Those are actutally just display connectors.

With laptops the internal one is always seen as connected of course. And that needs to be taken into account when probing connected monitors. That's where I use grep -v.

----------

## Massimo B.

Happy new year, I have my scripts working. I startup lightdm with

```
# grep setup-script /etc/lightdm/lightdm.conf 

display-setup-script=/usr/local/bin/1xrandr_externalSingleHead

# cat /usr/local/bin/1xrandr_externalSingleHead

#!/usr/bin/env bash

xrandr --output VGA-0 --off --output LVDS --off --output DisplayPort-2 --off --output DisplayPort-1 --auto
```

But starting Xfce with the 3 monitor setup still takes minutes. After that I can switch the displays by xrandr very fast. I would need to start Xfce with 1 monitor only and switch it later by xrandr to the 3 monitor setup. But why does Xfce take so long to switch it? We were guessing it is caused by the internal screen taking long to disable, but the problem is still there when starting lightdm with only 1 external screen enabled.

Then I wonder that at boot time I see some kernel error messages I can still lookup in dmesg later:

```
[    3.246458] fbcon: radeondrmfb (fb0) is primary device

[    3.494585] [drm:0xffffffff81302ac2] *ERROR* unable to allocate a PPLL

[    3.494587] [drm:0xffffffff812bb697] *ERROR* failed to set mode on [CRTC:40:crtc-3]

[    3.494612] [drm:0xffffffff81302ac2] *ERROR* unable to allocate a PPLL

[    3.494613] [drm:0xffffffff812bb697] *ERROR* failed to set mode on [CRTC:40:crtc-3]

[    3.497539] [drm:0xffffffff81302ac2] *ERROR* unable to allocate a PPLL

[    3.497540] [drm:0xffffffff812bb697] *ERROR* failed to set mode on [CRTC:40:crtc-3]

[    3.500447] Console: switching to colour frame buffer device 200x56

[    3.500453] [drm:0xffffffff81302ac2] *ERROR* unable to allocate a PPLL

[    3.500454] [drm:0xffffffff812bb697] *ERROR* failed to set mode on [CRTC:40:crtc-3]

[    3.503417] radeon 0000:01:00.0: fb0: radeondrmfb frame buffer device
```

 Is this the same issue?

----------

## Massimo B.

Something similar: https://bugzilla.kernel.org/show_bug.cgi?id=54381 However that is a hardware with 2 PLLs, but I'm able to run 3 independent screens, so my hardware should have 3 PLLs.

----------

## Zucca

Looking at the log... It could be that frame buffer driver is messing something up.

Radeon Wiki page has CONFIG_FB_RADEON unselected on kernel configuration.

You could try to disable that (if you have it enabled) and see if the problem vanishes...

----------

## Massimo B.

Same here:

```
# zgrep RADEON /proc/config.gz 

CONFIG_DRM_RADEON=y

# CONFIG_DRM_RADEON_USERPTR is not set

# CONFIG_FB_RADEON is not set
```

----------

## Zucca

Does this delay occur only when turning on displays inside xfce? Or does it happen also when in LightDM or some other WM/DE?

----------

## Massimo B.

Turning displays inside Xfce is no issue. Just the login.

I tried now to startup lightdm with my tripleHead script, that works fine. Lightdm then has the same setup that Xfce tries to set up. but the login still takes as long as before. Another drawback, having lightdm with 3 monitors set up, I'm not possible to switch to plain terminal (F1) anymore, switching back to F7 works at once and brings lightdm back. Maybe the plain terminal would appear after minutes as well, I didn't try.

It looks like I need to start Xfce with a single screen always and do the switching later by calling my xrandr script. The configured panels are already there in Xfce, even if the monitor doesn't exist at startup...

----------

## Zucca

If you use systemd you need to specifically tell systemd to start login on vt. Otherwise it starts the login when the vt has been activated. I've encountered some (sometimes long) delays when I have let systemd to start the login.

Anyway that does not still explain the delay when activating the monitor.

So if you force TripleHead via lightdm script that runs xrandr it works. But if xfce tries to set it up for you at the startup of xfce it takes a long time? Right?

----------

## Massimo B.

 *Zucca wrote:*   

> So if you force TripleHead via lightdm script that runs xrandr it works. But if xfce tries to set it up for you at the startup of xfce it takes a long time? Right?

 Yes. The TripleHead script turns off the internal screen and turns on all 3 external screens. That works and Lightdm comes up at once with the correct monitor setup. Then I guess Xfce tries to set up what is saved there, actually the same setup. I could try to delete the setup so that Xfce doesn't try to change it again.

Then it is unclear why switching to the VT is blocked when lightdm runs in 3 screen setup.

What do you mean by "systemd by default starts the login when vt has been activated"? The VTs are setup, but the login (running pam scripts and so on) only starts after passing user/pass... That all doesn't matter for the screen resolution.

Something else I changed, maybe related: Without passing a video= to the kernel I had monitors #1 and #2 up on booting, but only half of the screen was used. Passing video=1920x1200 switches the main screen into full range, the complete screen is used, while the second screen is blurred while having a resolution different from native.. but ok, I can live with it if at least the bigger main screen is ok.

Finally there's something weird with that laptop and docking station driving 3 external screens. As I don't restart that machine often, most time in S3 suspend, I don't see the delay at login that often..

----------

## Zucca

You can change the number of VTs etc via logind.conf. But I think I read somewhere that it may be impossible to switch to a VT if you have already reserved many monitors for X use. It's a limitation of the GPU in use.

You could try to disable xfce from changing the resolution at the startup. At this point a suspect thta theres sometihng "lagging" in the xfce's way to set up this TripleHead setup.

----------

