Driving audio card

Bjoern Doebel doebel at tudos.org
Fri Jun 6 17:54:27 CEST 2008

Hi Sheng,

> Hi all,
> Does anybody know whether there are some documents in English for
> teaching how to drive a audio card such that a application on l4
> can use it?  It is known that driver can be ported via DDE but 
> how to do that? I am a newbie in this area, Could you please give 
> me some advice?

Generally, the approach to get any driver running with the DDE 
works as follows (note, when I speak of DDE examples, I mean the 
ones in l4/pkg/dde as well as larger examples such as l4/pkg/ore):

1) Start a new L4 application consisting of a main() function
   calling the DDE initialization routines. There are several
   ones depending on which DDE subsystems you want to use
   (timers, memory, pci, ...). Please consult the DDE examples
   for that.

2) After calling the init functions, call l4dde26_do_initcalls().
   This will execute all the functions Linux functions marked as
   *_initcall(), such as the init function of your driver.

3) Compile your application (consisting of your main function and
   the driver you want to use) and link it with the DDE libraries
   as you can see from the DDE examples.

4) If your type of device is already supported by the DDE (such
   as network, block and TPM devices), then this should give you
   a working executable which you then just boot and there goes
   your driver. Proceed to step 6 in this case.

5) If your type of device is not yet supported, which will 
   be the  case for sound devices, then you will encounter
   potentially lots of linker errors in step 3. In this case
   * Find out whether the missing function is necessary. If
     you can get away without it, then implement it as an
     empty function returning a default good value.
   * If the function does something necessary:
     * Check if you can reuse the implementation from the
       Linux kernel. This is the case for functions that
       use default Linux features that are provided by the
       DDE, such as kmalloc(), request_region() etc.
     * In some cases reusing things from Linux will result
       in too much unnecessary Linux code ending up in your
       application or it might prove too hard to get all of
       it compile. If this occurs, consider reimplementing
       the feature to the extent needed by your application.

   Note, that step 5) is the real hard part and it often takes
   a lot of time to understand which code you can copy from
   Linux and which one you should replace with code written
   by yourself.

   If everything compiles, proceed to step 6.

6) If the Linux part of your driver compiles and starting the
   application boots and initializes the driver, it is time to
   add some L4 glue code, so that external applications can
   use your driver.

7) Have fun with your driver server.

After gaining some experience with extending DDE, you will be
able to identify which pieces of your newly written code are
only needed for your specific application and which ones should
be provided for future device drivers, too. The latter should
then be incorporated into a DDE subsystem (e.g., a library in
the DDE package), but I recommend, you don't worry about this
at the current point.


More information about the l4-hackers mailing list