The purpose of xf86HandleColormaps in xf86-video-fbdev?

Michel Dänzer michel at daenzer.net
Mon Feb 11 01:56:33 PST 2013


On Sam, 2013-02-09 at 00:39 +0200, Siarhei Siamashka wrote: 
> Hello,
> 
> I have tried to look into the root cause of the case when
> xf86-video-fbdev DDX is spamming the /var/log/Xorg.0.log
> with lots of bogus error messages like:
> 
>     FBDEV(0): FBIOPUTCMAP: Invalid argument
> 
> Searching a bit on the Internet, looks like lots of people have
> encountered this problem, this ubuntu bug can be used as an example:
>     https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-fbdev/+bug/573668
> 
> The spamming is done by the following code:
>     http://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/fbdevhw/fbdevhw.c?id=xorg-server-1.13.2#n768
> 
> The FBIOPUTCMAP ioctl starts failing when cmap.start >= 16 which makes
> sense because it tries to set pseudo_palette in the kernel fbdev
> drivers. And this palette normally has just 16 elements. The return
> code for this failed ioctl is inconsistent in different drivers. For
> example, have a look at
>     http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=blob;f=drivers/video/uvesafb.c;h=b0e2a4261afe;hb=v3.4.29#l1003
>     http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=blob;f=drivers/video/i740fb.c;h=fe574d84ed99;hb=v3.4.29#l888
>     http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=blob;f=drivers/video/cirrusfb.c;h=738c8ce7d132;hb=v3.4.29#l1314
> 
> Most of the drivers (including uvesafb) just ignore this error and
> return 0. Some of the drivers return -EINVAL, some of the drivers
> return 1.
> 
> The fbdev documentation at http://www.linux-fbdev.org/HOWTO/4.html
> indeed specifies 16 elements for pseudo_palette (and one more for
> the cursor?) but I still don't have a clear understanding about how
> exactly it is supposed to be used. The
>     http://comments.gmane.org/gmane.linux.fbdev.devel/1363
> post suggests that the pseudo_palette has something to do with the
> penguin logo drawing, which kind of makes some sense (have a paletted
> image to save memory, but show it on a truecolor framebuffer) :-)

My (possibly outdated) understanding is that pseudo_palette is only
relevant for fbcon (i.e. it's a kernel internal thing), and drivers
returning errors from FBIOPUTCMAP because of it are broken.


> In xf86-video-fbdev the call to xf86HandleColormaps() function, which
> sets 256 elements for the colormap, is done from here:
>     http://cgit.freedesktop.org/xorg/driver/xf86-video-fbdev/tree/src/fbdev.c?id=xf86-video-fbdev-0.4.3#n887
> 
> So how all this stuff is supposed to work? What would be the use case
> when this colormap is used for real?

It's used for the pseudocolour palette or gamma ramp.

> Can anything bad happen because of these failed ioctls (silent for
> uvesafb, very noisy for some other drivers)?

Presumably X ends up using whatever pseudocolour palette / gamma ramp
happened to be active before instead of the one it wants. Which may
happen to be the same most of the time.


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the xorg-devel mailing list