All of lore.kernel.org
 help / color / mirror / Atom feed
* Trigger Callback
@ 2006-08-01 19:48 Julien Bramary
  2006-08-01 19:55 ` Lee Revell
  0 siblings, 1 reply; 5+ messages in thread
From: Julien Bramary @ 2006-08-01 19:48 UTC (permalink / raw)
  To: alsa-devel

I'm an Alsa beginner and I'm trying to write an alsa driver for an embedded dac on ARM.

>From Iwai's doc:

/* trigger callback */
static int snd_mychip_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{
    switch (cmd) {
    case SNDRV_PCM_TRIGGER_START:
            // do something to start the PCM engine
            break;
    case SNDRV_PCM_TRIGGER_STOP:
            // do something to stop the PCM engine
            break;
    default:
            return -EINVAL;
    }
}

My question here is,
What are we supposed to do to start the PCM engine?
Because, I'm currently doing nothing, and yet it starts anyway...
I'd like to understand to have more control.



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: Trigger Callback
  2006-08-01 19:48 Trigger Callback Julien Bramary
@ 2006-08-01 19:55 ` Lee Revell
  2006-08-01 20:14   ` Julien Bramary
  0 siblings, 1 reply; 5+ messages in thread
From: Lee Revell @ 2006-08-01 19:55 UTC (permalink / raw)
  To: Julien Bramary; +Cc: alsa-devel

On Tue, 2006-08-01 at 20:48 +0100, Julien Bramary wrote:
> I'm an Alsa beginner and I'm trying to write an alsa driver for an embedded dac on ARM.
> 
> >From Iwai's doc:
> 
> /* trigger callback */
> static int snd_mychip_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
> {
>     switch (cmd) {
>     case SNDRV_PCM_TRIGGER_START:
>             // do something to start the PCM engine
>             break;
>     case SNDRV_PCM_TRIGGER_STOP:
>             // do something to stop the PCM engine
>             break;
>     default:
>             return -EINVAL;
>     }
> }
> 
> My question here is,
> What are we supposed to do to start the PCM engine?
> Because, I'm currently doing nothing, and yet it starts anyway...
> I'd like to understand to have more control.

"PCM engine" refers to the hardware's PCM engine, not ALSA's.  It's 100%
device dependent - you need to consult the docs for your sound device to
determine how to start the PCM.

Lee


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: Trigger Callback
  2006-08-01 19:55 ` Lee Revell
@ 2006-08-01 20:14   ` Julien Bramary
  2006-08-02 11:29     ` Takashi Iwai
  0 siblings, 1 reply; 5+ messages in thread
From: Julien Bramary @ 2006-08-01 20:14 UTC (permalink / raw)
  To: Lee Revell; +Cc: alsa-devel

Lee Revell wrote:

>>  > "PCM engine" refers to the hardware's PCM engine, not ALSA's.  It's 100%
>>  > device dependent - you need to consult the docs for your sound device to
>>  > determine how to start the PCM.
>>  >
>>  > Lee
Thanks, I see now why it starts, I'm doing some inits in my dac in the
open callback... I should do those here in the trigger.



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: Trigger Callback
  2006-08-01 20:14   ` Julien Bramary
@ 2006-08-02 11:29     ` Takashi Iwai
  2006-08-02 12:16       ` Julien Bramary
  0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2006-08-02 11:29 UTC (permalink / raw)
  To: Julien Bramary; +Cc: Lee Revell, alsa-devel

At Tue, 01 Aug 2006 21:14:24 +0100,
Julien Bramary wrote:
> 
> Lee Revell wrote:
> 
> >>  > "PCM engine" refers to the hardware's PCM engine, not ALSA's.  It's 100%
> >>  > device dependent - you need to consult the docs for your sound device to
> >>  > determine how to start the PCM.
> >>  >
> >>  > Lee
> Thanks, I see now why it starts, I'm doing some inits in my dac in the
> open callback... I should do those here in the trigger.

Remember that the trigger callback is designed really as a "trigger".
That is, it should be executed as shortly as possible.  The callback
is even in the atomic context within spinlock and irq disablement, so
any function that my sleep shall cause lockup.

If you need to allocate something, it should be done in either
open, hw_params or prepare callback.  Only start and stop are done in
trigger callback.


Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: Trigger Callback
  2006-08-02 11:29     ` Takashi Iwai
@ 2006-08-02 12:16       ` Julien Bramary
  0 siblings, 0 replies; 5+ messages in thread
From: Julien Bramary @ 2006-08-02 12:16 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

Takashi Iwai wrote:
> At Tue, 01 Aug 2006 21:14:24 +0100,
> Julien Bramary wrote:
>   
>> Lee Revell wrote:
>>
>>     
>>>>  > "PCM engine" refers to the hardware's PCM engine, not ALSA's.  It's 100%
>>>>  > device dependent - you need to consult the docs for your sound device to
>>>>  > determine how to start the PCM.
>>>>  >
>>>>  > Lee
>>>>         
>> Thanks, I see now why it starts, I'm doing some inits in my dac in the
>> open callback... I should do those here in the trigger.
>>     
>
> Remember that the trigger callback is designed really as a "trigger".
> That is, it should be executed as shortly as possible.  The callback
> is even in the atomic context within spinlock and irq disablement, so
> any function that my sleep shall cause lockup.
>
> If you need to allocate something, it should be done in either
> open, hw_params or prepare callback.  Only start and stop are done in
> trigger callback.
>
>
> Takashi
>
>   
Thanks for the reminder. I think this should be ok. The only function I 
now have in the trigger is the following 'write' (atomic enough):
   /* enable SSC data Tx */
   at91_ssc_write(AT91_SSC_CR, AT91_SSC_TXEN);

Cheers,
Julien


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

end of thread, other threads:[~2006-08-02 12:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-01 19:48 Trigger Callback Julien Bramary
2006-08-01 19:55 ` Lee Revell
2006-08-01 20:14   ` Julien Bramary
2006-08-02 11:29     ` Takashi Iwai
2006-08-02 12:16       ` Julien Bramary

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.