RTEMS sound device driver
Joel Sherrill
joel.sherrill at OARcorp.com
Thu Feb 7 21:08:32 UTC 2002
"Aaron J. Grier" wrote:
>
> On Thu, Feb 07, 2002 at 07:02:49PM +0100, Pattara Kiatisevi wrote:
> > 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?
>
> it depends where the device driver registers itself. if it registers
> itself as "/dev/dsp" then the above will work.
>
> > -in Linux I do:
> > int format = AFMT_S16_LE;
> > ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format);
> > -in RTEMS?
> > What should I do?
>
> again, this is completely dependent on the device driver. there is no
> reason why this couldn't be supported.
>
> > -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?
>
> RTEMS supports write() with the same parameters. but it is up to the
> device driver to interpret these parameters.
>
> > 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?
>
> look at the other device drivers for your target. a device driver has
> six interface points (initialize, open, close, read, write, and
> control). to write a device driver you fill these in and add an entry
> to your application's device driver list. it's quite elegant once you
> get the hang of it.
There has been discussion of adding more entry points -- in particular
a shutdown one. I would look for a properly licensed starting point
driver (BSD?).
> look in the console driver for your BSP to start.
>
> > 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?
>
> I'm not familiar with the ogg source code, but I'm guessing that if you
> can get a suitable device driver in place, it has a good chance of
> working.
Me either but I agree. Can you compile it under RTEMS without
major problems? Then all you have left is finding some implementation
of a /dev/dsp for your card.
> --
> Aaron J. Grier | Frye Electronics, Tigard, OR | aaron at frye.com
> "In a few thousand years people will be scratching their heads
> wondering how on earth the first computer was invented and
> bootstrapped without a prior computer to do it with."
> -- Chris Malcolm, on comp.arch
--
Joel Sherrill, Ph.D. Director of Research & Development
joel at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users
mailing list