[Xorg] How should a driver hook into the X server's idle loop

Ken Healy k.healy at mars.ucc.ie
Tue Jul 13 17:01:15 PDT 2004


Quick summary. (See below for context and details).

How can an X device driver hook in to the X server's idle loop to process
asynchronous requests (e.g. read a command from a file descriptor and act on
it, when flagged by a SIGIO handler).

-----------------------
(I'm new to X driver and linux kernel coding, so if I say anything incorrect,
please point it out.
Also apologies for the poor terminology. Its hard to phrase questions when
you're only beginning to learn the lingo).

I'm working on extending the video/tv sections of the GATOS driver to fully
support video4linux(2). (See http://gatos.sf.net for more info on GATOS, it
provides 3D accel and video/tv-in support for Radeon, All In Wonder and older
ATI cards).

This presents what seems to be an unusual challenge, in the context of the
current graphics and video implementations in X + linux.
This comes down to the fact that the graphics and tv-in hardware are together
on the same card, whereas in software, the graphics driver is in the Xserver,
and the tv-in driver (at least the v4l one) is in the kernel.

Given that I'm not going to be rewriting the X driver architecture, or
video4linux, then my driver is going to have kernel-side and Xserver-side
parts, and an interface between them. Also, most of the communication on this
interface will be initiated on the kernel-side - this seems to be unusual too
(is it?).

I see as much of the hardware specifics as possible staying on the Xserver
side (the notable exception being DMA).
So commands on the interface will be, for example, set_tuner_frequency,
set_input_source, set_brightness, get_signal_strength etc.

I have a idea of how I am going to implement this interface, but there are
still some blanks to fill in.
I'd really appreciate any comments, suggestions or advice on the outline
below.


The kernel module will create a /proc or sysfs file for the i/o, which the X
driver will open with FASYNC set, for async notification.
The X driver also installs a corresponding SIGIO handler to pickup to
notifications.

Now, I am pretty sure its a bad idea to do any significant processing in a
SIGIO handler (although I haven't found any docs on that). So I think the
handler should just set a flag or post an event telling the driver there's a
command waiting to be read.

Here's where the blanks are.
How can a driver hook in to the Xserver's idle loop to check for flags or
events, and then run the relevant commands?

Is it ok to use a simple flag? Or is it possible to define private events, and
have the driver hook in to the event loop to receive them?


Is this a good way to implement an interface like this? Is there a better way?

Pointers to relevant documentation, and existing driver, extension code that
would make good examples, would also be greatly appreciated.
(I've seen the docs in xc/doc and xc/programs/Xserver/hw/xfree86/doc)

Regards,
Ken.






More information about the xorg mailing list