Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Ideas about an analog-to-digital converter API



On Thursday 01 January 2009 6:07:43 am Jared D. McNeill wrote:
> A hardware driver using MI audio can provide its own ioctls, you could 
> use that for your driver (or layer another API between MI audio and your 
> driver using custom ioctls).

I've been teaching a "driver writing" class at Western Washington University
for several years and I've been using a simple, inexpensive A to D card as
the device for which the students are to write a "new" driver.   Part of the
reason for this was the lack of any A to D card support in NetBSD.

My initial look at the audio(4) layer made me think that it was too audio
specific for a general purpose A to D driver.   Yes, you could add MD ioctls,
but there appeared to me to have a lot ioctls in the MI layer that would not
make sense for a general A to D card.  For example,  the ioctl
AUDIO_GETENC (audio_encoding_t)  and  the fields in the struct audio_prinfo
like gain, balance, and encoding.

The card I use in the class is Measurement Computing PCI DAS-08.
It is a simple 8 channel, 8 or 12 bit converter.   It can sample only
one channel at a time.

I'm sure the interface I designed for the students is way to simple for a 
general
A to D framework, but it can give you an example of a much simpler framework
for A to D generic work.

The generic API was ioctl control and reading the data via the device.

The set of ioctls are:

#define DAS_START_SAMPLING              _IO ('D', 0)
#define DAS_STOP_SAMPLING               _IO ('D', 1)

/* Rate ... int is time in units of 10E-5 seconds.  So 100000 is 1 second. */
#define DAS_SET_RATE                    _IOW('D', 2, int)
#define DAS_GET_RATE                    _IOR('D', 3, int)

/* Channel is a number from 0 to 7. */
#define DAS_SET_CHANNEL                 _IOW('D', 4, int)
#define DAS_GET_CHANNEL                 _IOR('D', 5, int)

This is WAY to simple for general purpose API for A to D work, but you
asked for some ideas.   We have had many working drivers for this
card.

--Phil

-- 
Phil Nelson (phil at cs.wwu.edu) http://www.cs.wwu.edu/nelson
NetBSD: http://www.NetBSD.org  Coda: http://www.coda.cs.cmu.edu

Attachment: signature.asc
Description: This is a digitally signed message part.



Home | Main Index | Thread Index | Old Index