Considerations for the future Marvel/Linux driver design
(this text was written by Benoit, editing done by Gernot)
I'm looking at the memory grabbing and BES. Therefore,
I'm interested in writing a code which can easily be
merged with the dvd and mga_vid code.
I would like to receive your comments about the design of
a common driver for all mga extensions.
First, let's check if I know all the possibilities :
- base board with g100 / g200 / g400
- optional DVD codec extension
- optional KS0127+MJPEG extension,
sometimes with tuner and audio
- optional TV out
Now, what could a user want to do ?
Here I assume that the g200 grabs the video to the
frame buffer, and always provides preview and/or
uncompressed grabbing.
Tvout is optional, but should be available for
free if we know how to activate the video pass-through.
- dvd -> g200 -> tvout
- tuner -> ks0127 --> g200 -> tvout
--> mjpeg compression
- mjpeg decompression -> ks0127 -> g200 -> tvout
- software video source -> g200
(old mga_vid driver, I suppose that tvout will not
be available, unless we output the whole desktop to TV).
Let us define channels :
- tuner
- composite
- Y/C (S-VHS)
- mjpeg play
- dvd play
- software uncompressed play
Here are the available services :
(once the channel has been chosen,
one can activate any number of services simultaneously)
Available channels depend on the board type.
| channel: | tuner | composite | Y/C | mjpeg | dvd | software |
service: |
preview | | * | * | * | * | * | * |
tvout | | * | * | * | * | * | n/a |
mjpeg/memgrab | | */* | */* | */* | na/* | na/* | n/a//n/a (?) |
We define the available ioctls, and the behavior of read/write
as a function of the current status.
Board status is defined by :
- active channel,
- preview settings, preview active
- tvout settings, tvout active
- mjpeg compress settings, mjpeg compress active
- uncompressed grab settings, grab active
- mjpeg play settings, mjpeg play active
- dvd play settings, dvd active
- software play settings, software active
- tuner settings
- decoder settings
- who is sleeping
How do we decide when a flag is set "active" ?
Memory grabbing can be done in a "one shot" mode
(when "read" is called). Therefore, I propose
to set the flag "active" only between the
"buffer request" and the "buffer release" commands.
(does this exist ?). There should be some ioctls to
release services, but I think they do not exist in V4L...
Then operations are allowed or forbidden :
- changing channel :
forbidden if 4,5,6,7 or 8 is active.
available channels depend on the board type.
- activating mjpeg compress :
forbidden if 5 is active or channel "mjpeg" or "dvd"
is selected
- activating grab compress :
forbidden if 4 is active
- activating mjpeg play, dvd play or software play :
ok if the correct channel is selected.
How to decide when we put a chip to sleep ?
- everybody can sleep if the device is not open.
- tuner and ks0127 can be put to sleep when dvd or software
channel is selected (do they reset parameters when they
are put to sleep ?)
- mjpeg codec can sleep if no data has to be uploaded
and mjpeg play or grab is not active (zr36060 keeps the
status when it is sleeping, and wakes up with no delay).
- dvd codec : ?
If you have ideas about this, please send me your comments.
Open questions:
-
What is the cleanest way to determine if a service is
currently used ?
The problem is that there is no ioctl
to release the buffers and tell the driver "I will not
need to grab any more, allow me to change channel".
One solution would be to stop any grabbing or playing which
is not compatible with the current demanded service
(for example, lauching an mjpeg play stops any dvd play
or mjpeg grabbing), before starting the new service.
I think that it is always possible to stop a service
immediately, but for an interrupt handling (data transfer
from mga framebuffer to memory can be quite long).