Portrait mode X-Windows on i.MX51

Published on October 31, 2010

Archived Notice

This article has been archived and may contain broken links, photos and out-of-date information. If you have any questions, please Contact Us.

Sometimes this software gig is like wizarding school: you just need the right words and magic happens.I want to thank Richard Johnston for handing me this one:

xrandr

With the libXrandr package and this little command-line tool you can flip your X desktop and apps by 90, 180, or 270 degrees.Try this one on your development machine:

user@host:~$ for rot in left inverted right normal ; do
>        xrandr -o $rot ;
>        sleep 2 ;
> done

We've had a couple of customers interested in using our Nitrogen-E boards with X-Windows in portrait mode and didn't have an answer. With the xrandrutility it's pretty simple.If you're using Ubuntu or Debian, the xrandr utility is available through the x11-xserver-utils package.xrandr isn't currently included in the Freescale-provided LTIB releases, but you can add it with a little effort:

Grab the srpm and import

A really nice feature of LTIB known is the addsrpms mode that I found out about here. It allows you to take a Red Hat or Fedora source rpm (srpm) and import it into LTIB.I'm not sure exactly which version of xorg-x11-xserver-utils matches up with the other x11 packages, but the Fedora 12 repository seems to have the same version of xorg-x11-xserver, so it's probably a good start.

user@host:~/ltib$ wget https://mirrors.kernel.org/fedora/releases/12/Everything/source/SRPMS/xorg-x11-server-utils-7.4-13.fc12.src.rpm
--2010-10-30 15:09:37-- https://mirrors.kernel.org/fedora/releases/12/Everything/source/SRPMS/xorg-x11-server-utils-7.4-13.fc12.src.rpm
Resolving mirrors.kernel.org... 204.152.191.39
Connecting to mirrors.kernel.org|204.152.191.39|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1508668 (1.4M) [application/x-rpm]
Saving to: `xorg-x11-server-utils-7.4-13.fc12.src.rpm'
100%[==========================================================>] 1,508,668    926K/s   in 1.6s
2010-10-30 15:09:39 (926 KB/s) - `xorg-x11-server-utils-7.4-13.fc12.src.rpm' saved [1508668/1508668]
user@host:~/ltib$ ./ltib -m addsrpms xorg-x11-server-utils-7.4-13.fc12.src.rpm
importing xorg-x11-server-utils-7.4-7.fc11.src.rpm to /home/ericn/ltib/rpm
+ rpm --dbpath /var/lib/rpm --define _topdir /home/ericn/ltib/rpm -ivh xorg-x11-server-utils-7.4-13.fc12.src.rpm
   1:xorg-x11-server-utils  ########################################### [100%]
dropping %{?dist} in spec token: release

After adding the package, you can select the xorg-x11-server-utils package using ltib - config.

Doctor the spec file

I wasn't able to get this to compile, though. There appear to be issues with some of the other utilities contained within the package. If you look at dist/lfs-5.1/xorg-x11-server-utils/xorg-x11-server-utils.spec, you'll see a total of 17 packages:

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Source0:  https://www.x.org/pub/individual/app/iceauth-1.0.2.tar.bz2
Source2:  https://www.x.org/pub/individual/app/rgb-1.0.1.tar.bz2
Source3:  https://www.x.org/pub/individual/app/sessreg-1.0.4.tar.bz2
Source4:  https://www.x.org/pub/individual/app/xcmsdb-1.0.1.tar.bz2
Source5:  https://www.x.org/pub/individual/app/xgamma-1.0.2.tar.bz2
Source6:  https://www.x.org/pub/individual/app/xhost-1.0.2.tar.bz2
Source7:  https://www.x.org/pub/individual/app/xmodmap-1.0.3.tar.bz2
Source8:  https://www.x.org/pub/individual/app/xrandr-1.2.99.4.tar.bz2
Source9:  https://www.x.org/pub/individual/app/xrdb-1.0.5.tar.bz2
Source10: https://www.x.org/pub/individual/app/xrefresh-1.0.2.tar.bz2
Source11: https://www.x.org/pub/individual/app/xset-1.0.4.tar.bz2
Source12: https://www.x.org/pub/individual/app/xsetmode-1.0.0.tar.bz2
Source13: https://www.x.org/pub/individual/app/xsetpointer-1.0.1.tar.bz2
Source14: https://www.x.org/pub/individual/app/xsetroot-1.0.2.tar.bz2
Source15: https://www.x.org/pub/individual/app/xstdcmap-1.0.1.tar.bz2
Source16: https://www.x.org/pub/individual/app/xvidtune-1.0.1.tar.bz2

Since I'm only interested in xrandr, I patched the spec file to remove the others like so:

--- dist/lfs-5.1/xorg-x11-server-utils/xorg-x11-server-utils.spec.orig	2010-10-30 15:12:06.000000000 -0700
+++ dist/lfs-5.1/xorg-x11-server-utils/xorg-x11-server-utils.spec	2010-10-30 15:28:09.000000000 -0700
@@ -9,25 +9,7 @@
 Packager        : UNKNOWN(LTIB addsrpms)
 Group           : User Interface/X
 URL             : https://www.x.org
-Source0:  https://www.x.org/pub/individual/app/iceauth-1.0.2.tar.bz2
-Source2:  https://www.x.org/pub/individual/app/rgb-1.0.1.tar.bz2
-Source3:  https://www.x.org/pub/individual/app/sessreg-1.0.4.tar.bz2
-Source4:  https://www.x.org/pub/individual/app/xcmsdb-1.0.1.tar.bz2
-Source5:  https://www.x.org/pub/individual/app/xgamma-1.0.2.tar.bz2
-Source6:  https://www.x.org/pub/individual/app/xhost-1.0.2.tar.bz2
-Source7:  https://www.x.org/pub/individual/app/xmodmap-1.0.3.tar.bz2
-Source8:  https://www.x.org/pub/individual/app/xrandr-1.2.99.4.tar.bz2
-Source9:  https://www.x.org/pub/individual/app/xrdb-1.0.5.tar.bz2
-Source10: https://www.x.org/pub/individual/app/xrefresh-1.0.2.tar.bz2
-Source11: https://www.x.org/pub/individual/app/xset-1.0.4.tar.bz2
-Source12: https://www.x.org/pub/individual/app/xsetmode-1.0.0.tar.bz2
-Source13: https://www.x.org/pub/individual/app/xsetpointer-1.0.1.tar.bz2
-Source14: https://www.x.org/pub/individual/app/xsetroot-1.0.2.tar.bz2
-Source15: https://www.x.org/pub/individual/app/xstdcmap-1.0.1.tar.bz2
-Source16: https://www.x.org/pub/individual/app/xvidtune-1.0.1.tar.bz2
-Patch1100: rgb-1.0.0-datadir-rgbpath-fix.patch
-Patch1200: xset-1.0.2-spurious-xprint.patch
-Patch1700: xvidtune-1.0.1-buffer-stomp.patch
+Source0:  https://www.x.org/pub/individual/app/xrandr-1.2.99.4.tar.bz2
 BuildRoot       : %{_tmppath}/%{name}
 Prefix          : %{pfx}
@@ -39,13 +21,7 @@
 %Prep
-%setup -q -c %{name}-%{version} -a2 -a3 -a4 -a5 -a6 -a7 -a8 -a9 -a10 -a11 -a12 -a13 -a14 -a15 -a16
-
-%patch1100 -p0 -b .datadir-rgbpath-fix
-%patch1200 -p0 -b .xprint
-#%patch1700 -p0 -b .datadir-app-defaults-fix
-%patch1700 -p1 -b .buffer-stomp
-
+%setup -q -c %{name}-%{version}
 %Build
 # Build all apps
@@ -99,9 +75,6 @@
       popd
    done
 }
-%if !%{with_xkeystone}
-rm -f $RPM_BUILD_ROOT/%{pfx}//usr/bin/xkeystone
-%endif
 %Clean

After this, LTIB was able to compile xrandr:

user@host:~/ltib$ ./ltib
Processing deployment operations
==================================
Started: Sat Oct 30 15:32:55 2010
Ended:   Sat Oct 30 15:33:15 2010
Elapsed: 20 seconds
Build Succeeded
user@host:~/ltib$ ls -l rootfs/usr/bin/xrandr
-rwxr-xr-x 1 root root 51283 2010-10-30 15:33 rootfs/usr/bin/xrandr
ericn@officeserver:~/ltib$

And it can run the Java app from our previous post on LTIB and Java in rotated mode.The fbgrab utility doesn't use X, which is why you just turned your head to the left...