Nexus 7 2013 X server in landscape

Refer to previous post, Debian on Nexus 7 2013 for the details of the debian setup.

I prefer the screen to display in landscape, which also makes it easier to use with usb keyboard. However, the installed video driver freedreno does not support rotation to turn the default portrait to landscape.

As the touchscreen only reacts to touch on its right edge, it would be even more useable in landscape since being able to touch on the top edge will make clicking on links in web-browser possible, and clicking on app menus.

Luckily, there is a solution Unofficial Archlinuxarm release N7 2013 provided by xda user ShadowEO. (page3#27) - Thanks!

I have adapted the solution.

Rename the working xorg.conf which is using freedreno to xorg.freedreno.conf

/etc/X11/xorg.freedreno.conf

    Section "Device"
Identifier "Video Device"
Driver "freedreno"
# Uncomment for addition debug traces in xorg log:
#Option "Debug" "true"
# The below two options are not needed if you are using the
# msm drm/kms driver:
Option "fb" "/dev/fb0"
Option "SWCursor" "true"
Option "SWRefresher" "false"
Option "NoAccel" "true"
EndSection
Section "Monitor"
# use xrandr
Identifier "default"
EndSection
Section "Screen"
Identifier "Screen"
Monitor "default"
Device "Video Device"
EndSection


Download the fbturbo video driver from https://archive.raspberrypi.org/ and install it, (this version is compatible with jessie)

    dpkg -i xserver-xorg-video-fbturbo_1.20150305~205708_armhf.deb


The fbturbo driver supports rotation, save the following config to /etc/X11/xorg.fbturbo.conf

/etc/X11/xorg.fbturbo.conf

    Section "Device"
Identifier "Video Device"
Driver "fbturbo"
# Uncomment for addition debug traces in xorg log:
#Option "Debug" "true"
Option "fbdev" "/dev/fb0"
# landscape
Option "Rotate" "CW"
EndSection
Section "Monitor"
# use xrandr
Identifier "default"
EndSection
Section "Screen"
Identifier "Screen"
Monitor "default"
Device "Video Device"
EndSection
Section "InputClass"
Identifier "evdev touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
# landscape
Option "SwapAxes" "on"
Option "InvertY" "on"
EndSection


There will be error if the X server is started with xorg.fbturbo.conf . It seems that the video device is only initialized properly by the xorg.freedreno.conf, or rather the freedreno driver.

So, the basic solution is to run the X server with xorg.freedreno.conf, then to stop it, and then to run X server again with xorg.fbturbo.conf . (to make it seamless)


As normal user, if I run startx with the config option, there is an error.

    $ startx -- -dpi 300 -config xorg.freedreno.conf vt1



    Fatal server error:
(EE) xf86OpenConsole: Cannot open virtual console 1 (Permission denied)


Without passing the config option, startx runs fine.

Since normal user cannot touch /etc/X11/xorg.conf , I create a script similar to debian update-alternatives .

First, as staff user, creates dir /usr/local/etc/X11/ , change group ownership to staff, and set permission as rwxrwsr-x .

Then, as root user, symlink /etc/X11/xorg.conf to /usr/local/etc/X11/xorg.conf

    ln -s /usr/local/etc/X11/xorg.conf /etc/X11/xorg.conf


As staff user, we can now symlink /usr/local/etc/X11/xorg.conf to either /etc/X11/xorg.fbturbo.conf or /etc/X11/xorg.freedreno.conf , and we can run startx without passing the config file.

bin/usexorg

    #!/bin/sh
# change which xorg.conf to use: driver is either freedreno or fbturbo
USERXCONF=/usr/local/etc/X11/xorg.conf
if [ -f "/etc/X11/xorg.$1.conf" ]; then
rm "$USERXCONF"
ln -s "/etc/X11/xorg.$1.conf" "$USERXCONF"
else
echo "no such xorg.conf!"
fi


bin/myx

    #!/bin/bash
touch ~/.xsession
# init with freedreno driver
usexorg freedreno
startx -- -quiet -dpi 300 vt1
rm ~/.xsession
# run with fbturbo driver
usexorg fbturbo
startx -- -dpi 300 vt1


Now, as staff user, I run myx to start X server in landscape.

Note: the first startx in myx script runs with freedreno driver, but the X server stops due to the empty .xsession file.


The touchscreen can be enabled or disabled using xinput. (Debian package is xinput)

    $ xinput | grep touch
⎜ ↳ elan-touchscreen id=9 ...
 
$ xinput --disable 9
$ xinput --enable 9


I recommend i3 as it can manage windows entirely using keyboard.

Comments

blog comments powered by Disqus