All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Driver design question
@ 2006-09-14 11:29 Takashi Iwai
  2006-09-15 14:47 ` Lee Revell
  0 siblings, 1 reply; 35+ messages in thread
From: Takashi Iwai @ 2006-09-14 11:29 UTC (permalink / raw)
  To: rlrevell, alsa-devel, tiwai

>>> Lee Revell <rlrevell@joe-job.com> 09/12/06 10:27 PM >>>
> I have a device here that can play PCM, but it's a weird implementation.
> Only 2 periods of 0x2000 words per buffer are supported, and there is no
> DMA - the driver must poll a status register, and when the chip is
> ready, deliver all 0x2000 words using outw() then send an end xfer
> command.
> 
> I think I need to use an intermediate buffer, and implement copy/silence
> callbacks that write to this.  Then I plan to use a tasklet or workqueue
> to do the actual xfer of PCM data to the hardware.  A timer callback
> will periodically check whether at least 0x2000 words are in the buffer
> and if so, schedule the tasklet to drain it.

You can implement it in two ways, at least.

One is to use copy and silent callbacks.  This is pretty straightforward,
doesn't need extra buffer, but it cannot use the native mmap.  (alsa-lib
provides the mmap emulation mode, but it seems not so stable.)
Also, the buffer and period sizes are very restricitve (in your case, 0x2000
x 2 words), so many apps might not work well.
An exampleof this type is isa/sb/emu8000_pcm.c (and some of gus pcm,
IIRC).

Another is to use an intermediate buffer as you suggsted.
In this case, you do _not_ need copy and silent callbacks.  These callbacks
are the operations to copy and silent the hardware buffers.  WIth an
intermediate buffer, the copy and silent are done on this buffer, i.e. on
normal RAM.  What you need instead is the background-running copy
operation from this intermediate buffer to the hardware via outw.

This copy task could be done in the interrupt handler (or timer in your case)
if it's minimum.  If not, it'd be better to take a workq since it can sleep and
much preemptive.

> I presume this implementation cannot support mmap() as there's no random
> access to the hardware buffer.  Is this correct?

Mmap works in practice.  The driver simply shares the intermediate
buffer with user-space.

> Do I call snd_pcm_period_elapsed() from the timer, immediately before
> scheduling the tasklet, or from the tasklet, after the data has been
> transferred to the hw?

Yes, by calling snd_pcm_period_elapsed(), the actual hwptr is updated.
Then schedule workq to run copy-task from the buffer to h/w for the
appropriate size.  

> In general, does this seem like a reasonable implementation?

I don't see other possibilities.


BTW, I'll be less communicative (and don't read MLs) for a while until
the next Tuesday since I'm in a conference.


Takashi

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 35+ messages in thread
* Driver Design Question
@ 2013-10-22  7:02 Johannes Thumshirn
  2013-10-23  3:10 ` Guenter Roeck
  0 siblings, 1 reply; 35+ messages in thread
From: Johannes Thumshirn @ 2013-10-22  7:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Samuel Ortiz, Lee Jones, Michael Buesch, Johannes Thumshirn

Hi List,

I have a design question concerning a device driver. The device in question is
somewhere in between drivers/mfd/timberdale and drivers/ssb. It is mapped
connected via PCI and on PCI Bar 0 there is a table describing which
"sub-devices" are contained in the FPGA as well as where their Memory and IRQ
resources are.

Unlike the timberdale driver, there is no static configuration of the FPGA's
sub-devices, but their number and kind is variable. But luckily we have unique
device-ids for every sub-device, so it is possible to do a PCI/USB like
enumeration.

In my understanding the MFD API, which timberdale uses, isn't tailored to this
Plug'n'Play like behavior. Whereas the I think (virtual) bus concept used by
SSB is much more suited for this kind of devices. But would it be wise to add a
bus only suited to devices manufactured by one vendor, when there is already a
API for such kinds of multi function devices?

Long story short, which would be the preferred way to implement such a driver? At
the point I currently reached I could go in both directions.

I'd appreciate any advice I can get on this topic.

Thanks in advance,

       Johannes

P.S.: MFD and SSB maintainers are on CC as I'd really like to hear their opinion

^ permalink raw reply	[flat|nested] 35+ messages in thread
* Driver design question
@ 2006-09-12 20:27 Lee Revell
  0 siblings, 0 replies; 35+ messages in thread
From: Lee Revell @ 2006-09-12 20:27 UTC (permalink / raw)
  To: alsa-devel; +Cc: Takashi Iwai

I have a device here that can play PCM, but it's a weird implementation.
Only 2 periods of 0x2000 words per buffer are supported, and there is no
DMA - the driver must poll a status register, and when the chip is
ready, deliver all 0x2000 words using outw() then send an end xfer
command.

I think I need to use an intermediate buffer, and implement copy/silence
callbacks that write to this.  Then I plan to use a tasklet or workqueue
to do the actual xfer of PCM data to the hardware.  A timer callback
will periodically check whether at least 0x2000 words are in the buffer
and if so, schedule the tasklet to drain it.

I presume this implementation cannot support mmap() as there's no random
access to the hardware buffer.  Is this correct?

Do I call snd_pcm_period_elapsed() from the timer, immediately before
scheduling the tasklet, or from the tasklet, after the data has been
transferred to the hw?

In general, does this seem like a reasonable implementation?

Lee


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 35+ messages in thread
* driver design question
@ 2005-05-19  6:24 Jean Delvare
  2005-05-19  6:24 ` Philip Edelbrock
                   ` (9 more replies)
  0 siblings, 10 replies; 35+ messages in thread
From: Jean Delvare @ 2005-05-19  6:24 UTC (permalink / raw)
  To: lm-sensors


Hi all,

Reading some code today, I noticed that most of our drivers, if not all,
read the current values and the limit values when updated. Why that? I
would have read the current values only. We set the limits ourself
(either at init time or through procfs/sysfs) so they are unlikely to
have changed. Looks like an overhead we could easily get rid of. Is
there something obvious I am missing?

Thanks.

-- 
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2013-10-23  7:29 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-14 11:29 Driver design question Takashi Iwai
2006-09-15 14:47 ` Lee Revell
2006-09-19 15:15   ` Takashi Iwai
2006-09-25 19:54     ` Lee Revell
2006-09-27 17:18       ` Takashi Iwai
2006-09-27 17:38         ` Lee Revell
2006-09-30  2:03         ` Lee Revell
2006-10-03 15:35           ` Lee Revell
2006-10-04  9:17             ` Takashi Iwai
2006-10-19 22:12               ` Lee Revell
2006-10-20 12:55                 ` Takashi Iwai
2006-10-20 20:12                   ` Lee Revell
2006-10-23 13:09                     ` Takashi Iwai
2006-10-23 17:46                       ` Lee Revell
2006-10-24 15:01                         ` Takashi Iwai
2006-10-24 15:30                           ` Lee Revell
2006-10-24 23:54                           ` Lee Revell
2006-10-04  9:07           ` Takashi Iwai
2006-09-27 13:58     ` Lee Revell
2006-09-27 16:52       ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2013-10-22  7:02 Driver Design Question Johannes Thumshirn
2013-10-23  3:10 ` Guenter Roeck
2013-10-23  7:29   ` Johannes Thumshirn
2006-09-12 20:27 Driver design question Lee Revell
2005-05-19  6:24 driver " Jean Delvare
2005-05-19  6:24 ` Philip Edelbrock
2005-05-19  6:24 ` Jean Delvare
2005-05-19  6:24 ` Philip Edelbrock
2005-05-19  6:24 ` Jean Delvare
2005-05-19  6:24 ` Philip Edelbrock
2005-05-19  6:24 ` Mark M. Hoffman
2005-05-19  6:24 ` Philip Pokorny
2005-05-19  6:24 ` Jean Delvare
2005-05-19  6:24 ` Mark D. Studebaker 
2005-05-19  6:24 ` Philip Pokorny

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.