Xrandr panning in Raspbian


4 posts
by pirandr » Mon Aug 05, 2013 5:11 pm
I'm running Raspbian and xrandr always gives me a single mode line. While I can change what resolution this line contains by altering config.txt, I can't get mutliple lines at the same time (so I can change resolution without reboot). Is there any way to do this?

What I actually want to do is get panning/virtual resolution working (a low resolution screen with a larger "virtual" desktop). This is a standard feature in X and on other machines, I'd just run something like
Code: Select all
xrandr --fb 1920x1080 --mode 800x600 --panning 1920x1080

to get a 800x600 resolution with a 1920x1080 sized "virtual" desktop.

I just want to get something like this running. Of course, after that, it'd be nice if I could also change resolution without a reboot.

Thanks in advance for any help.
Posts: 13
Joined: Mon Aug 05, 2013 4:57 pm
by pirandr » Tue Aug 06, 2013 5:20 pm
The closest thing I've found is this stack overflow question

http://unix.stackexchange.com/questions/34515/cannot-set-up-screen-panning-in-ubuntu-with-xrandr-which-states-that-it-cannot-f

but unfortunately, this lead me to an error with some magic numbers I can't decipher.

Code: Select all
pi@raspberrypi ~ $ xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 720 x 480, current 720 x 480, maximum 720 x 480
default connected 720x480+0+0 0mm x 0mm
   720x480         0.0*

pi@raspberrypi ~ $ sudo xrandr --fb 1920x1080 --output default --mode 720x480 --panning 1920x1080
xrandr: Failed to get size of gamma for output default
xrandr: screen cannot be larger than 720x480 (desired size 1920x1080)
pi@raspberrypi ~ $ gtf 1920 1200 60

  # 1920x1200 @ 60.00 Hz (GTF) hsync: 74.52 kHz; pclk: 193.16 MHz
  Modeline "1920x1200_60.00"  193.16  1920 2048 2256 2592  1200 1201 1204 1242  -HSync +Vsync

pi@raspberrypi ~ $ xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 720 x 480, current 720 x 480, maximum 720 x 480
default connected 720x480+0+0 0mm x 0mm
   720x480         0.0*
pi@raspberrypi ~ $ xrandr --newmode "1920x1200_60.00"  193.16  1920 2048 2256 2592  1200 1201 1204 1242  -HSync +Vsync
xrandr: Failed to get size of gamma for output default
pi@raspberrypi ~ $ xrandr --addmode default "1920x1200_60.00"
xrandr: Failed to get size of gamma for output default
pi@raspberrypi ~ $ xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 720 x 480, current 720 x 480, maximum 720 x 480
default connected 720x480+0+0 0mm x 0mm
   720x480         0.0*
   1920x1200_60.00   60.0 


Unlike the Stackexchange question, I was able to add the modeline because my monitor does support 1920x1200 @ 60Hz. But then I got this error.


Code: Select all
pi@raspberrypi ~ $ sudo xrandr --fb 1920x1200 --output default --mode 720x480 --panning 1920x1200
xrandr: Failed to get size of gamma for output default
X Error of failed request:  BadRRCrtc (invalid Crtc parameter)
  Major opcode of failed request:  149 (RANDR)
  Minor opcode of failed request:  29 (RRSetPanning)
  Crtc id in failed request: 0x62
  Serial number of failed request:  22
  Current serial number in output stream:  22


I'm not even trying to use the new modeline (except into "tricking" xrandr into accepting 1920x1200 as my virtual resolution)!

So any and all ideas are still very welcome.
Posts: 13
Joined: Mon Aug 05, 2013 4:57 pm
by pirandr » Sun Aug 18, 2013 12:33 pm
Adventure in Xrandr land continues!

Some output removed for brevity.

What could BadRRCrtc (invalid Crtc parameter) mean? Which parameter is wrong? Looks like there's no choice. I have to dig deeper.

Code: Select all
$ apt-get source x11-xserver-utils
$ cd x11-xserver-utils-7.7~3/xrandr/
$ mkdir build
$ cd build
$ ../configure

** Loads of missing packages, as expected. **

$ apt-get install xrandr xrender x11 xproto libxrandr-dev libxrender-dev

** Some finger twiddling later. **

$ ../configure

** Seems fine this time. **

$ make
$ ./xrandr
./xrandr: Failed to get size of gamma for output default
Screen 0: minimum 640 x 480, current 640 x 480, maximum 1024 x 800
default connected 640x480+0+0 0mm x 0mm
   640x480        60.0*
   1024x800_60.00   60.0 


Now that it works, lets try one of the command we want to run.

Code: Select all
$ ./xrandr --output default --mode 640x480 --panning 1024x800+0+0/640x480+0+0 --verbose
./xrandr: Failed to get size of gamma for output default
X Error of failed request:  BadRRCrtc (invalid Crtc parameter)
  Major opcode of failed request:  149 (RANDR)
  Minor opcode of failed request:  29 (RRSetPanning)
  Crtc id in failed request: 0x63
  Serial number of failed request:  22
  Current serial number in output stream:  22
$ vi ../xrandr.c

** Add some printf statement here and there near the panning code. **

$ make
$ ./xrandr --output default --mode 640x480 --panning 1024x800+0+0/640x480+0+0 --verbose


A few hours of editing and running later, it looks like the error happens on the line
Code: Select all
                s = XRRSetPanning (dpy, res, crtc->crtc.xid, crtc->panning_info);

In fact, it exists with status code 1 and doesn't run any lines after this. But XRRSetPanning is not defined in xrandr.c (or anything within x11-xserver-utils-7.7~3). So, after some searching
Code: Select all
$ cd
$ apt-get source libxrandr
$ cd libxrandr-1.3.2
$ mkdir build
$ cd build
$ ../configure && make

** After installing some missing packages. **

$ make

** I'm not sure how to make it use the new library. I guess I'll just install it, which is probably a bad idea. **

$ sudo make install

** It says the new library was installed in /usr/local/lib instead of /usr/lib. How do I make xrandr.c use that that new library? **

~/x11-xserver-utils-7.7~3/xrandr/build $ export LD_LIBRARY_PATH=/usr/local/lib
~/x11-xserver-utils-7.7~3/xrandr/build $ ldd xrandr
        libXrandr.so.2 => /usr/local/lib/libXrandr.so.2 (0xb6f44000)


Running this version does give the print statement I added to XrrCrtc.c (which is where XRRSetPanning is defined) but rebuilding every time is getting tiresome. Time to use something better than printf statement debugging.

Code: Select all
$ gdb ./xrandr

** Luckily, the -g flag was included by default in the rebuilt library so extra information (symbols) is available to gdb. **

(gdb) r --output default --mode 640x480 --panning 1024x800+0+0/640x480+0+0 --verbose

** Same BadRRCrtc error. **

(gdb) break 1444
(gdb) r --output default --mode 640x480 --panning 1024x800+0+0/640x480+0+0 --verbose

** After some examining and stepping. **

(gdb) c


And then the gdb just froze there. And the same thing happened many times (xrandr had to be killed via ssh).

Time passes.

It turns out that its a bad idea to send error messages (and console) to a display you are in the process of debugging. Now, instead I will ssh into the machine (while the xserver is on), export DISPLAY=:0.0 and then run gdb from the ssh session.

No more freezing. But eventually, I discover that the problem is contained in one line
Code: Select all
    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))


_XReply looks like something pretty generic that is just passing along our request to ultimately call a panning function. But _XReply is also not defined anywhere in libxrandr.

It looks like I'll need the entire X11 library because some googling shows _XReply is defined in xcb_io.c.

Code: Select all
$ apt-get source libx11


But I don't want to rebuild the entire X11 library just to add the debug flag -g everywhere. In the meantime, my drunken journey on the internets brought me here.

http://www.x.org/wiki/Development/Docum ... Debugging/

There are specific packages available with those flags set.

Code: Select all
$ apt-get install libx11-6-dbg libx11-xcb1-dbg


All of this could have been done from the very start, of course.

Now I can step through the _XReply function. Although I'm starting to suspect all of this is just client-side work and I should really be looking that what the server is doing instead.
Posts: 13
Joined: Mon Aug 05, 2013 4:57 pm
by karsenault » Sat Jan 11, 2014 7:28 pm
Did you ever get this fixed? I get the same CRTC error when trying to change panning. I also have a tiny (4.3") screen that I obviously need to have bigger as I can't even see "Ok" in some windows.
Posts: 1
Joined: Sat Jan 11, 2014 7:27 pm