Showing posts with label xorg. Show all posts
Showing posts with label xorg. Show all posts

Insecrure Screensavers with Xorg 1.11+

Due to a serious bug, pretty much all screensavers are vulnerable if they run with a recent Xorg 1.11+. I leave it to others to describe more details and a hotfix.

New Open Source Poulsbo Driver in 2.6.39 staging

It works pretty nicely - though just as a framebuffer device so far. A specialized Xorg userspace driver for the new staging kernel driver is expected sometime soon. It already supplies KMS and can be used with the fbdev driver of Xorg. So next time you want to try a new kernel you can at least get into a working X without much ado. And there will surely be at least a simple driver coming with new kernels now. The first steps have been taken. And of course, all this is hopefully just the beginning...

Understanding the Necessity of Wayland

Questioning the necessity for Wayland and the wiseness of the choice has become a phenomena, especially after Mark Shuttleworth annouced Ubuntu's plans to eventually switch to Wayland. Following I will provide a concise reasoning why we want Wayland. At the end there are some more links for further reading.

In 1984 the MIT started X11.
In 1991, XFree86 started out of the X386 server based on the X11 platform.
In 2003, Xorg took over from XFree86 after a license dispute.
In 2008, Wayland was started to overhaul the entire system and keep only what's necessary for the desktop today, using only today's modern infrastructure in a leightweight architecture.

Quick Fix for Your Multimedia Keys

If your multimedia keys give this warning in dmesg:
atkbd.c: Unknown key pressed (translated set 2, code 0xf7 on isa0060/serio0).
atkbd.c: Use 'setkeycodes e077 ' to make it known.
then you need to look up the right number in include/linux/input.h E.g.
And use that number with setkeycodes, e.g. for my system:
setkeycodes e077 224 # brightness down
setkeycodes e078 225 # brightness up
setkeycodes 0xee 212 # webcam
setkeycodes 0xe4 240 # touchpad -> unknown
setkeycodes e076 238 # wifi + bluetooth
And now your system (e.g. KDE or Gnome) should immediately recognize the keys. Post the information to your distribution and it should be included in future releases. Just write the commands (without sudo) into /etc/rc.local to make them permanent for now.

If you get stuck, here's a good guide.

Moblin 2.1 IVI FC Release tested on the MSI Wind U110 (GMA 500/Poulsbo)

Phoronix hasn't gotten to it yet, but now I've done a quick test with the Moblin distribution IVI version with supposed GMA 500 support (moblin-2.1-preview-ivi-20091208.img) to see how well it's working on my netbook and what feature advantages its IEGD driver may have over the psb driver.

Well, it's not a lot:
  • The resolution was set to 800x600. No other resolutions were detected (xrandr -q)
  • The colors were distorted. It looked like 256 colors but randomly exchanged.
  • The touchpad was not working. The mouse moved in seemingly opposite or random directions and kept skipping back and forth. I had to use an external mouse to do anything at all.
  • The sound wasn't working, thought that might possibly be fixed by disabling power saving, just like in Ubuntu
  • Wifi wasn't working. I could not add networks or configure the wifi. " Join other Network" was greyed out. The iwconfig tools have to be started manually from /sbin. They found a network, but I didn't bother to try to set it up with wpa_supplicant manually. A path is not set. wpa_supplicant was already running with 99% cpu usage when I boot.
  • Switching to the console and back is impossible. It completely and irreversibly crashes the graphics until a reboot.
  • ACPI showed tons of errors in dmesg.
  • Trying to suspend crashed the system.
  • I wonder if there's an application in the distribution that can take advantage of VAAPI accelerated video decoding. There is a video player. But I had no easy access to the hard drive's partitions (ntfs).
The distribution as tested on my netbook is in two words:
utterly unusable.

The psb driver set up according to my howto works flawlessly compared to that! It interesting how difficult it seems to be for Intel to get its own chipset to work in its own distribution with its own driver.

But, yes. Moblin was very snappy. ;-) (I think that just shows just how cool XFCE is, though.)

How to set up X and VAAPI Accelerated HD Video on the MSI Wind U110 (GMA500 - Poulsbo) and Ubuntu Karmic 9.10

The following guide is now slightly outdated as Ubuntu 10.04 is out and new drivers are necessary, also some of the repositories I originally used have disappeared. If you use Ubuntu 10.04, try following my much easier directions here instead. (The largest detriment to the Ubuntu 9.10 driver is a complete lack of suspend to ram for me. I will leave my guide for 9.10 online as reference, though. It seems to have been the first good description and I'm happy about the major online media coverage. :)

I've finally managed to get it running. Here is what I did. First you need to get Ubuntu 9.10 running with poulsbo. The first steps 1.-4. describe how to set up the driver for X. The second part (5.-10.) describes how to set up VAAPI and mplayer to get video acceleration. (There is already an early stage GMA500 driver for Ubuntu 10.04.)

The image shows the phoronix test suite benchmarking when I play Grey.ts in a loop (-loop 0) with mplayer and vaapi but without sound (-nosound) on my netbook. During the entire time, the CPU frequency is also downscaled to 800 Mhz. Compare to phoronix vdpau benchmark on a core 2 duo system (which obviously shows even less cpu usage, because the CPU is much more powerful) or the Atom and Nvidia ION benchmark on Phoronix.
CPU usage when playing a 10 minute fireworks recording in 1080p @ 50 fps without sound and then two FullHD movie trailers. The CPU is clocked at 800Mhz the entire time. The spike is caused by a bug in my test sequence: I didn't start a new mplayer process for new files but passed them all at once on the command line.

I can watch FullHD (1080p @ 50 fps + AC3) videos with about 30% or less CPU utilization (Atom@800 Mhz) on my netbook now. Looks really nice, too. Some videos produce artefacts, especially self-recorded AVCHD m2ts files. If you use the right demuxer, AVCHD videos play fine, but deinterlacing does not work. Sometimes the video seems not to run very smooth, etc. It's not perfect yet, don't expect too much! But most videos work perfectly, no matter what resolution.

The only real problem is with suspend to ram. You can't use suspend to ram or VAAPI at the same time: If you used VAAPI and try to suspend, the system doesn't suspend and/or crashes. If you suspend, then use VAAPI or even xv I think, the system crashes really hard. So suspend doesn't really work as expected yet. I think the sound also doesn't work properly after suspend. Suspend works fine for me even after resume if I do a double console switch (Ctrl-Alt-F1 wait until you see the console, then Ctrl-Alt-F7).

Here's what you need to do
1. Basically you add the GMA500 Repositories for Ubuntu 9.10 (karmic) and 10.04 (Lucid) to /etc/apt/sources.list.d/mobile.list. (If the entry below doesn't work, check this page.)
sudo add-apt-repository ppa:gma500/ppa && sudo apt-get update

2. Then you install the poulsbo-driver-3d including the firmware and everything.

2.a. Check if you can load the psb module: sudo modprobe psb. If you see this in dmesg instead of a switch to the correct resolution,
"kernel BUG: unable to handle kernel NULL pointer dereference at (null)" (2.6.31)
you need a manual hack to get the driver working, as I just reported.

3. Once that's done, for a more stable and speedy operation, you need to add an /etc/X11/xorg.conf:

Section "Device"
Identifier "GMA500"
Option "AccelMethod" "EXA"
# someone suggested UXA? but that's for the i965 drivers
Option "DRI" "on"
Option "MigrationHeuristic" "greedy"
Option "IgnoreACPI" "yes"
Driver "psb"

Section "DRI"
Mode 0666

4. Reboot and make sure that it works! If X doesn't work properly yet, VAAPI won't, either. After a short black screen, you should be greeted in the correct resolution. Full screen xv video should already work fine. Suspend to RAM also worked perfectly at this point for me.

If  the system goes to DPMS standby and from there switches to other modes (DPMS suspend, etc.), then my screen actually turns on again (showing all black with backlight active). So make sure you chose only one setting for DPMS. A constantly running screen is not good at all.

VAAPI Video Acceleration setup
Now comes the part where we install the hardware decoding acceleration. If you just want X you can stop now. ;) This is written for Ubuntu 9.10 with old repositories, so 5+6 might not be necessary anymore or work for Ubuntu 10.04!

5. Install the Libva library from This replaces your current libva1 with a newer version.  also works for me. Don't forget to install the -dev version ( as well if you want to compile mplayer later.

6. Create a link of your video driver to the vaapi driver directory:
sudo ln -s /usr/X11R6/lib/modules/dri/ /usr/lib/va/drivers/

A. Precompiled setup. (You can alternatively skip to part B: compiling the source code setup)

7. Download and unpack the precompiled mplayer:

8. Install a normal mplayer and libmad with apt-get.
sudo apt-get install mplayer libmad0

9. Unpack mplayer and create necessary links to the libraries it expects.
"ldd mplayer" tells you what library (names) mplayer expects.
Just to go /usr/lib and create links to them:
ln -s
This should work as long as your libraries are newer than the expected ones. It may actually work out of the box in Ubuntu Jaunty.

10. Start mplayer from the package you downloaded:
e.g. ~/mplayer-vaapi-20090914.i686/mplayer -fs -vo vaapi -va vaapi HDtest.avi

B. Compiling the Source Code

I've also manged to get the source code to work. This is less bothersome, because you need not link the libaries. Hence less man hours, but more disk space and computer hours for compiling. Didn't take as long as I feared, though. And it's using a slightly newer version of mplayer-vaapi, which includes some rudimentary OSD in vaapi mode now.

7. Install the build environment:

sudo apt-get build-dep mplayer
sudo apt-get install libdrm-dev
maybe: sudo apt-get -f install

8. Download the source at Unpack it and execute the

9. Check if it works, e.g.
mplayer -fs -vo vaapi -va vaapi ~/HDtest.avi

sudo make install.

X. Done! Enjoy e.g. a nice HD trailer for a start! Post your results! I can recommend using it in smplayer for more comfort(e.g. automatically continue where you left of last). If it crashed, check out by blog entry about smplayer crashing in vaapi mode.

Update: It turns out deinterlacing not working is not due to VAAPI, but a limit in the psb driver. It works with the current iegd driver and other drivers from AMD and NVIDIA (press the D putton in mplayer I think). If I could just get one of those iegd drivers... Thanks Gwenole from for answering my email and of course for writing the mplayer-vaapi patches in the first place! He seems to be the absolute VAAPI expert.

Also some experiments show that I can attach an external screen and watch videos with VAAPI on it. That means I should be able to actually use the netbook for decoding HD video and displaying it on an external screen. (But it does not work for me with except in mirror or single display mode.) Only thing missing now is a digital display port to connect a FullHD display... ;)

You might also be interested in Surround Sound and Battery Life
And I did get a USB surround sound card working wonderfully now. Also here's some advice I wrote on decreasing your power consumption.

X Video finally works - Poulsbo and Linux on the MSI Wind U110 - Fix for BUG: kernel NULL pointer dereference at 00000000

If you tried to get poulsbo to run on your system and you get a message like this, you should try the fix posted below.

"kernel BUG: unable to handle kernel NULL pointer dereference at 00000000" (2.6.28)
"kernel BUG: unable to handle kernel NULL pointer dereference at (null)" (2.6.31)

Thanks to a post on Ubuntu's bugzilla, the poulsbo video module now finally works on my MSI Wind U110 (full review & installation guide). Download the psb-kernel-source module You only have to comment out the two lines in intel_lvds.c starting with

if (edid)

/* if (edid)
drm_add_edid_modes(output, edid); */

Then reconfigure the package and it should be recompiled. The next time you start it, it should work instead of creating kernel BUG

Xvideo actually works better than in Directx video in Windows XP, where I often see blocky video scaling. The CPU usage is not too high, either. Currently it's only working under Ubuntu 9.04 for me. Though I had managed to compile the module with kernel 2.6.30 before, I don't remember how I did that... And I haven't gotten actual video acceleration to work yet.

Of course I'll keep you updated and I'll post a little howto once it's all working. But feel free to ask, anyway. And thanks so much to the person from the Ubuntu bugzilla who helped me to finally get it all working!!!

Update2: Keep checking the page. I will post a link to an archive with a script that will manage the compilation in Ubuntu 9.10. If someone could help me figure out how to, I'd love to create, upload and post a .deb for dkms so it all works automatically... Or ultimately, we could modify the driver to check for the MSI's signature and then skip the edid check.

I've created a package for Karmic that you can use to manually install the driver with the fix already applied: Extract it and execute the script, then reboot and try to modprobe psb. Let me know when the 10 downloads run out and it it works for you.

Update3: Here is a step by step howto. It explains setting up X and then VAAPI (hardware video decoding) in Kubuntu 9.10.

My script for making the psb module out of the package:

KERNEL=/lib/modules/`uname -r`/
make KERNELRELEASE="$(uname -r)" LINUXDIR="/lib/modules/$(uname -r)/build" DRM_MODULES=psb || exit 1;
sudo cp drm.ko $KERNEL/kernel/drivers/gpu/drm/drm.ko
sudo mkdir -p $KERNEL/updates/dkms
sudo cp psb.ko $KERNEL/updates/dkms/psb.ko
ls -l $KERNEL/kernel/drivers/gpu/drm/drm.ko $KERNEL/updates/dkms/psb.ko
sudo depmod -a

Automatically switch to connected External Display on Boot with XRandR

I bought a notebook to be flexible, but when at home I use it with external monitor, keyboard and mouse to be comfortable. Now the problem was that I couldn't tell Ubuntu I want to only use the external monitor - if it's available.

Well, I've written a one-liner that fixes that problem. If the external display is attached, it will automatically switch over to it and display the internal display. Otherwise it boots normally (leaving the internal display enabled).

I put the script into the Xsession.d directory so it gets started for every user on boot: /etc/X11/Xsession.d/98vgaonly and made it executable.

The actual script line is this:
xrandr -q | grep 'VGA connected' && xrandr --output LVDS --off --output VGA --auto
It checks if the line 'VGA connected' was found in xrandr's query and then asks your X server to turn off the internal output and use the external one with automatic resolution detection.

So to automatically switch to a connected VGA during boot just execute:
echo 'xrandr -q | grep \'VGA connected\' && xrandr --output LVDS --off --output VGA --auto' | sudo tee /etc/X11/Xsession.d/98vgaonly && sudo chmod a+x /etc/X11/Xsession.d/98vgaonly

You may have to change the name of the outputs for your setup. xrandr -q will let you know what's available. It would probably be possible to somehow call this script automatically when plugging in a monitor, but I've not figured out how. xrandr only works when called from inside the running X session in my experience.

If you want to know more about XRandR, check this recent article.

Any comments are welcome!

Blanking External Monitor to Save Energy with Xorg

I've just found out that my external monitor remains on for quite a while in the suspend and off modes (xset dpms force off). The only one that it accepts is standby. Then it turns off right away. And the internal one as well. So that's fine for me. But good to know, isn't it? ;-)

And btw. if you want to use it in a script you have to issue the xset command twice and sleep in between for about 6 seconds. Otherwise they're not really off. Don't ask me why...

NVIDIA Brings Fast GPU Video Acceleration to Linux

It's been a while. I've sat here on my chair for a long time and thought to myself: Hey, if you want to do it, video acceleration would be really easy to integrate into Linux software: It's mostly open source and the changed would be pretty specific to that part.

Then came XvMC and it was not really convincing, because the impact was not too fast and it only worked during playback Mpeg2 AFAIK, not during transconding.

Now came NVIDIA (admittedly a couple weeks after AMD, but therefore publicly and including patches for mplayer) and finally brought out really nice and efficient video acceleration for linux.

My favorite Linux Performance News Site Phoronix checked it out and you can see quite an improvement (CPU usage with first OpenGL, then XVideo and then Nvidia's "VDPAU"(Video Decode and Presentation API).

I hope AMD and Intel will finally come out with some progress in this area, too. Next I would like to see support for encoding, e.g. in Xvid and then maybe even tasks such as gzip, bzip2 (the latter ones didn't even show multi-core support in my tests).

Disabling Touchpad on Demand

There's now an alternative to using the shared memory of the synaptic driver to enable and disable the touchpad:

xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Off" 8 1 (enable)
xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Off" 8 0 (disable)

This should work out of the box in Ubuntu 8.10 (Intrepid). But it doesn't. At least not for me. But this works for me:

xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Off" 8 0
xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Off" 8 1

Nice! :)

Ubuntu 8.10 No-Go for Dual Head

Don't upgrade your Ubuntu to 8.10 if you want to use a dual head setup. There second screen will reguarly turn off for a second while there is an edid ddc scan shown in the Xorg.log. (The bug is not really fixed or fix not in main repository yet. Or I've found a different one. -> It's still not working!)

And the whole system will stutter during that time. That makes video playback very annoyingly slow and usage an external monitor impossible. I'll let you know when I find a fix.

KDE 4.1 with Multi-Head

Just a short note: If you plan to use KDE 4.1 with Multi-Head, make sure you do *not* do it using xrandr, otherwise KDE gets confused and messes up your screen. So set up your xorg.conf statically.

Intel put up a short howto, but it shouldn't be that different for other drivers. The important part goes like this:

Section "Device"
Identifier "Configured Video Device"
Driver "intel"
Option "FramebufferCompression" "off" # on for battery, off for multi-display
Option "monitor-LVDS" "internal"
Option "monitor-VGA" "external"

Section "Monitor"
Identifier "internal"

Section "Monitor"
Identifier "external"
Option "RightOf" "internal" #the left display is the primary one

Section "Screen"
Identifier "Default Screen"
Monitor "internal"
Device "Configured Video Device"
SubSection "Display"
Virtual 2560 1024
# this should be as large as both displays next to each other

Section "ServerFlags"
# Option "Xinerama" "true" # crashes
Option "AIGLX" "false" # crashes multi-head

After doing that, (instead of crashes and frustration) you're rewarded with very nice customization options in KDE 4.1.2: You can set the wallpaper for each screen, put different plasma applets at different locations, etc.

If you're using the intel driver I can also recommend disabling AIGLX in the ServerFlags Section of your xorg.conf to make the setup more stable. After supend/resume I regularly have to set reconfigure the screen setup with xrandr and then switch back and forth between X and the console to turn my external monitor back on.

I wonder how the new X server version in Kubuntu 8.10 will be.

Multiseat Display Manager Out Now

The Multiseat Display Manager is now out and (hopefully) helps you to set up a multiseat environment (much) easier than before.

I have always wondered when a software such as the MDM would come out, as the Unix and X architecture is already perfectly prepared for cases as this and even over Network it is already possible.

Now you need only one computer with several displays, keyboards and mice to let several users e.g. surf the internet at the same time.

I will post my experiences as soon as I get to trying it out. For the curious of you here is a link to installing instructions, packages for debian and ubuntu are provided, as well as the sources of couse.

Update: The packages is very large at 20K, but unfortunately at this point available only as i386 package...

Update2: I've quickly assembled a Ubuntu 8.04 package for AMD64 systems ;-).

Minimal X Environment

If you want to e.g. use nxserver, but only for a few selected applications it is often wise to install just the most basic packages, in ubuntu these are
xfonts-base xterm xutils xauth icewm

Then you should be able to login with nxclient, if you set it to use the custom environment with a virtual desktop and to execute /usr/bin/icewm.

Helping Windows Users with UltraVNC Single Click and ssvnc from Linux

If you ever (try to) use UltraVNC Single Click to help Windows users from Linux, you will find out that it's not that easy. Though you can use the UltraVNC viewer in Wine, you may see disconnects after around 15 minutes. The easy solution lies in starting a regular TightVNC with these parameters:

xtightvncviewer -listen 0 -encodings "hextile copyrect"

Replace the 0 with the display number, e.g. 0 for port 5500 or 400 for 5900. (port = 5500 + x) You need to have the package xtightvncviewer installed for this to work in Ubuntu. The color parameter does not work properly in this configuration.

Or give ssvnc a try. It works even with SCIII (uvnc Single Click via SSL), supports different color depths and much more!

And if you've got a current wine version, you might as well use the original ultravnc viewer. It works fine by now.

I usually use ssvn and the following script to start the vnc listener and quit it when finished.
$VNC -listen 487 -use64 & # 64 colors
read -p "Press enter when finished"
killall tightvncviewer vncviewer

NX Remote Control Software.

I'm a big fan of Nomachine NX. It's a great remote control software for X which is so efficient you can actually run it over a modem connection. It has comfortable clients for Windows, Mac OS and of course Linux and others. The technology is great and the main library is published under the GPL.

It only needs one free port - the SSH port 22. And you can get your free server for Linux or Solaris(limited to two users). The two users which can use NX are chosen when you first connect as a certain user. If you want to free one user slot, just delele the user from NX:

/usr/NX/bin/nxserver --userdel user123

Another cool thing: Instead of the whole desktop environment you can also just run a single program. That makes it really easy to run a Linux program in a Windows environment. It supports printing over cups and has (rudimentary) sound and video support.

And this is not paid advertisement, I actually really like the software. And I think it's great the small company publish the library under the GPL. Of course you have to pay for enterprise level tools. But hey, they got to make money as well. ;)

New Intel Xorg Driver Released

It seems the intel driver in the Ubuntu repositories is still pretty old. You can download a new one from their website, though and install it manually.

I wish there was an updated package available for hardy. You can probably use the intrepid package again, though. It has version number 2.3.2. Then you can leave the EXA acceleration enabled without the related problems with e.g. Opera.

Locking your Screen with dbus from the command line in Gnome, KDE4 and others.

dbus-send --session --dest=org.freedesktop.ScreenSaver --type=method_call \
--print-reply /ScreenSaver org.freedesktop.ScreenSaver.Lock

This will work with KDE4 and should as well work with newer Gnome versions. Tested with KDE 4.1 beta1. It needs the display variable to be set and be run as the appropriate user.
e.g. su $user -c "DISPLAY=:0 dbus-send... "

In Ubuntu 8.04 you can change your /etc/acpi/resume.d/ to lock the screen on resume like this:


# now, we should poke xscreensaver so you get a dialog
#if pidof xscreensaver > /dev/null; then
for x in /tmp/.X11-unix/*; do
displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
if [ x"$XAUTHORITY" != x"" ]; then
export DISPLAY=":$displaynum"
su $user -c "(xscreensaver-command -deactivate)"
su $user -c "dbus-send --session --dest=org.freedesktop.ScreenSaver \
--type=method_call --print-reply /ScreenSaver \

Opera+Intel X Shared Memory Problem Fixed

It turns out it is an issue in the X driver. Thanks to develcuy for the fix! You simply change the accelaration mode from EXA to XAA in the xorg.conf file:

in /etc/X11/xorg.conf

you insert in

Section "Device"
Identifier "Configured Video Device"
Option "AccelMethod" "XAA" # not EXA

It's also supposed to help with some memory issues. I will see if that maybe fixes my problems with plasma x shared pixmap cache I just posted about earlier. Even though its the older one of the two x acceleration infrastructures, the intel driver's support of it seems much more stable and fast.


It turns out there is a better fix for this issue, just upgrade to the newest driver package.


The new driver package does not always fix the issue. I hope that these fixes will not be required for Kubuntu 8.10.