RTEMS sound device driver

Eric Norum eric.norum at usask.ca
Thu Feb 7 19:17:10 UTC 2002


Pattara Kiatisevi wrote:
> 
> Hi,
> 
> I am going to write a device driver for a sound device to be run with RTEMS and
> LEON chip. As I have very little experience with RTEMS, I have some questions:
> 
> Client program that will use this device driver:
> ================================================
> 
> -in Linux I do:
>         audio_fd = open("/dev/dsp",O_WRONLY , 0)
> -in RTEMS:
>         Will the above open() work? or do I have to:
>         rtems_io_open( xxx )? And how can I know what "xxx" should be?

If your device driver registers itself properly you should be able use
the standard open() routine as shown in your Linux example.

> 
> -in Linux I do:
>         int format = AFMT_S16_LE;
>         ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format);
> -in RTEMS?
>         What should I do?
> 
> -in Linux I do:
>         sizewritten = write(audio_fd, audio_buffer, inputsize);
> -in RTEMS:
>         I should use rtems_io_write() right? And how about the parameters?

Again, you should be able to use exactly the same code on RTEMS as on
Linux, assuming you write your device driver properly.

> 
> Device driver:
> ==============
> 
> -The place that I have to put the device driver code is under
> <rtems>/c/src/lib/libbsp/sparc/leon/ right? As I couldn't find any implementation of audio driver before, does it have any template so that I could know which functions should exist in order to support the above client calls?

While getting started it's probably easiest to just build your driver as
part of your application.  That relieves you of the effort of fitting
your driver into the RTEMS source tree.

> 
> I'm porting Ogg Vorbis Player (which runs on Linux/UNIX) to RTEMS. At first I
> think that it could be sth. like "source-code compatible" but in the real
> it is not right?
> 

Try looking at the TFTP driver (libnetworking/lib/tftpDriver.c, and any
of the console drivers xxxxx/console.c) for how to write  device driver
which can be used by application programs in the same way as Linux
drivers.

-- 
Eric Norum                                 eric.norum at usask.ca
Department of Electrical Engineering       Phone: (306) 966-5394
University of Saskatchewan                 FAX:   (306) 966-5407
Saskatoon, Canada.



More information about the users mailing list