RTEMS sound device driver
Pattara Kiatisevi
pkiatisevi at student.ei.uni-stuttgart.de
Thu Feb 7 23:02:33 UTC 2002
Firstly thank you for all answer.
On Thu, 7 Feb 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.
But how exactly is this "registering" process? I took a look at the
existing driver code as suggested and draft the steps as follow.
-I create a file contained device driver's code: sound-driver.c
-Which should contain initialize(), open(), close(), read(),
write(), and control(). Arguments of these functions = like in console.c?
-In the initialize() I would have sth. like:
rtems_io_register_name( "/dev/dsp", major, 0 );
-In my application file, I do open(), ioctl(), write(), close() to
/dev/dsp as usual.
-And then how can I tell RTEMS to call this sound device driver when there
is access to /dev/dsp? Something to do with
#def CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE and I have to create my own
Device_drivers? (Hmm, but how and where? :) )
Thank you very much.
Gruss,
Ott
The best things in life are free. - B.G. DeSilva (1927)
----------------------------------------------------------------------
Ott Pattara Kiatisevi T L W G
M.Sc. INFOTECH Student, Stuttgart, Germany http://linux.thai.net/
----------------------------------------------------------------------
>
> > -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.
>
> 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.
>
> --
> 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
>
>
More information about the users
mailing list