All of lore.kernel.org
 help / color / mirror / Atom feed
* fsl_ssi: Cannot do simultaneous capture and playback
@ 2013-09-23  2:05 Fabio Estevam
  2013-09-23  2:13 ` Nicolin Chen
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2013-09-23  2:05 UTC (permalink / raw)
  To: Mark Brown, Lars-Peter Clausen, Shawn Guo, Sascha Hauer,
	Nicolin Chen
  Cc: alsa-devel@alsa-project.org

Hi,

I am trying to do simultaneous capture and playback on mx6 wandboard
and I noticed that it only works if I run 'aplay first'.

Here is the sequence that works:

1) aplay file.wav

2) Run 'alsamixer' and select line-in in the capture tab

3) Connect audio via line-in input

4) arecord -f cd -c 2 | aplay -f cd

Then I am able to hear the playback.

However, if I do not do step 1, and try to do the arecord/aplay directly I get:

$ arecord -f cd  | aplay -f cd
imx-sgtl5000 sound.13: set sample size in capture stream first
fsl-ssi-dai 2028000.ssi: ASoC: can't open interface 2028000.ssi: -11
ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_
open) unable to open slave
aplay: main:660: audio open error: Device or resource busy
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

I will try to debug this, but if anyone has any suggestions, please let me know.

Thanks,

Fabio Estevam

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

* Re: fsl_ssi: Cannot do simultaneous capture and playback
  2013-09-23  2:05 fsl_ssi: Cannot do simultaneous capture and playback Fabio Estevam
@ 2013-09-23  2:13 ` Nicolin Chen
  2013-09-23  2:56   ` Fabio Estevam
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolin Chen @ 2013-09-23  2:13 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: alsa-devel@alsa-project.org, Mark Brown, Lars-Peter Clausen,
	Sascha Hauer, Shawn Guo

Hi Fabio,

On Sun, Sep 22, 2013 at 11:05:03PM -0300, Fabio Estevam wrote:
> Hi,
> 
> I am trying to do simultaneous capture and playback on mx6 wandboard
> and I noticed that it only works if I run 'aplay first'.
> 
> Here is the sequence that works:
> 
> 1) aplay file.wav
> 
> 2) Run 'alsamixer' and select line-in in the capture tab
> 
> 3) Connect audio via line-in input
> 
> 4) arecord -f cd -c 2 | aplay -f cd
> 
> Then I am able to hear the playback.
> 
> However, if I do not do step 1, and try to do the arecord/aplay directly I get:
> 
> $ arecord -f cd  | aplay -f cd
> imx-sgtl5000 sound.13: set sample size in capture stream first

We can pinpoint the issue by the log "set sample size in":

450                 if (synchronous) {                             
451                         struct snd_pcm_runtime *first_runtime =
452                                 ssi_private->first_stream->runtime;
453                         /*
454                          * This is the second stream open, and we're in
455                          * synchronous mode, so we need to impose sample
456                          * sample size constraints. This is because STCCR is
457                          * used for playback and capture in synchronous mode,
458                          * so there's no way to specify different word
459                          * lengths.
460                          *
461                          * Note that this can cause a race condition if the
462                          * second stream is opened before the first stream is
463                          * fully initialized.  We provide some protection by
464                          * checking to make sure the first stream is   
465                          * initialized, but it's not perfect.  ALSA sometimes
466                          * re-initializes the driver with a different sample
467                          * rate or size.  If the second stream is opened
468                          * before the first stream has received its final
469                          * parameters, then the second stream may be         
470                          * constrained to the wrong sample rate or size.
471                          */                                              
472                         if (!first_runtime->sample_bits) {                 
473                                 dev_err(substream->pcm->card->dev,
474                                         "set sample size in %s stream first\n",
475                                         substream->stream ==                
476                                         SNDRV_PCM_STREAM_PLAYBACK          
477                                         ? "capture" : "playback");
478                                 return -EAGAIN;                       
479                         }
480 
481                         snd_pcm_hw_constraint_minmax(substream->runtime,
482                                 SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
483                                 first_runtime->sample_bits,
484                                 first_runtime->sample_bits);
485                 }  


In freescale internal branch, I had a patch to drop this part of code because
the hw_params() in fsl_ssi.c is already considering about the wl configuration,
so it won't change the wl value even if two streams' sample bits are different.

But if we think about the benefit of snd_pcm_hw_constraint() for a case like
"(arecord -d10 xx.wav &);sleep 1;aplay yy.wav", yea the non-simultaneous case,
we might also just turn the dev_err() into dev_warn() from my point of view:

			if (first_runtime->sample_bits)
				snd_pcm_hw_constraint_minmax(substream->runtime,
                                	SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
                                 	first_runtime->sample_bits,
                                 	first_runtime->sample_bits);
			else
				dev_warn(substream->pcm->card->dev,
                                        "Not enforcing sample bits due to race\n");

You can try this two solutions and find a better one.

Best regards,
Nicolin Chen

> fsl-ssi-dai 2028000.ssi: ASoC: can't open interface 2028000.ssi: -11
> ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_
> open) unable to open slave
> aplay: main:660: audio open error: Device or resource busy
> Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
> 
> I will try to debug this, but if anyone has any suggestions, please let me know.
> 
> Thanks,
> 
> Fabio Estevam
> 

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

* Re: fsl_ssi: Cannot do simultaneous capture and playback
  2013-09-23  2:56   ` Fabio Estevam
@ 2013-09-23  2:40     ` Nicolin Chen
  2013-09-23  3:14       ` Fabio Estevam
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolin Chen @ 2013-09-23  2:40 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: alsa-devel@alsa-project.org, Mark Brown, Lars-Peter Clausen,
	Sascha Hauer, Shawn Guo

On Sun, Sep 22, 2013 at 11:56:17PM -0300, Fabio Estevam wrote:
> Hi Nicolin,
> 
> On Sun, Sep 22, 2013 at 11:13 PM, Nicolin Chen <b42378@freescale.com> wrote:
> 
> > In freescale internal branch, I had a patch to drop this part of code because
> > the hw_params() in fsl_ssi.c is already considering about the wl configuration,
> > so it won't change the wl value even if two streams' sample bits are different.
> >
> > But if we think about the benefit of snd_pcm_hw_constraint() for a case like
> > "(arecord -d10 xx.wav &);sleep 1;aplay yy.wav", yea the non-simultaneous case,
> > we might also just turn the dev_err() into dev_warn() from my point of view:
> >
> >                         if (first_runtime->sample_bits)
> >                                 snd_pcm_hw_constraint_minmax(substream->runtime,
> >                                         SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
> >                                         first_runtime->sample_bits,
> >                                         first_runtime->sample_bits);
> >                         else
> >                                 dev_warn(substream->pcm->card->dev,
> >                                         "Not enforcing sample bits due to race\n");
> >
> > You can try this two solutions and find a better one.
> 
> Yes, tried both and none of them worked for me.
> 
> Could you try linux-next if you have a chance?

I want to, but I don't have a wandboard. Could you please give me the new
printed log? I think after the modification there should be little different
for the case.

> 
> Thanks,
> 
> Fabio Estevam
>

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

* Re: fsl_ssi: Cannot do simultaneous capture and playback
  2013-09-23  2:13 ` Nicolin Chen
@ 2013-09-23  2:56   ` Fabio Estevam
  2013-09-23  2:40     ` Nicolin Chen
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2013-09-23  2:56 UTC (permalink / raw)
  To: Nicolin Chen
  Cc: alsa-devel@alsa-project.org, Mark Brown, Lars-Peter Clausen,
	Sascha Hauer, Shawn Guo

Hi Nicolin,

On Sun, Sep 22, 2013 at 11:13 PM, Nicolin Chen <b42378@freescale.com> wrote:

> In freescale internal branch, I had a patch to drop this part of code because
> the hw_params() in fsl_ssi.c is already considering about the wl configuration,
> so it won't change the wl value even if two streams' sample bits are different.
>
> But if we think about the benefit of snd_pcm_hw_constraint() for a case like
> "(arecord -d10 xx.wav &);sleep 1;aplay yy.wav", yea the non-simultaneous case,
> we might also just turn the dev_err() into dev_warn() from my point of view:
>
>                         if (first_runtime->sample_bits)
>                                 snd_pcm_hw_constraint_minmax(substream->runtime,
>                                         SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
>                                         first_runtime->sample_bits,
>                                         first_runtime->sample_bits);
>                         else
>                                 dev_warn(substream->pcm->card->dev,
>                                         "Not enforcing sample bits due to race\n");
>
> You can try this two solutions and find a better one.

Yes, tried both and none of them worked for me.

Could you try linux-next if you have a chance?

Thanks,

Fabio Estevam

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

* Re: fsl_ssi: Cannot do simultaneous capture and playback
  2013-09-23  2:40     ` Nicolin Chen
@ 2013-09-23  3:14       ` Fabio Estevam
  2013-09-23  3:19         ` Nicolin Chen
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2013-09-23  3:14 UTC (permalink / raw)
  To: Nicolin Chen
  Cc: alsa-devel@alsa-project.org, Mark Brown, Lars-Peter Clausen,
	Sascha Hauer, Shawn Guo

Hi Nicolin,

On Sun, Sep 22, 2013 at 11:40 PM, Nicolin Chen <b42378@freescale.com> wrote:
> On Sun, Sep 22, 2013 at 11:56:17PM -0300, Fabio Estevam wrote:

> I want to, but I don't have a wandboard. Could you please give me the new
> printed log? I think after the modification there should be little different
> for the case.

Sorry, I made something wrong and now it is working.

Will submit the patch.

Running several times in a row, sometimes I get:

$ arecord -d 10 -f cd | aplay -f cd
fsl-ssi-dai 2028000.ssi: ASoC: Not enforcing symmetric_rates due to race
sgtl5000 1-000a: ASoC: Not enforcing symmetric_rates due to race
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

,but the playback always work now.

Thanks,

Fabio Estevam

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

* Re: fsl_ssi: Cannot do simultaneous capture and playback
  2013-09-23  3:14       ` Fabio Estevam
@ 2013-09-23  3:19         ` Nicolin Chen
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolin Chen @ 2013-09-23  3:19 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: alsa-devel@alsa-project.org, Mark Brown, Lars-Peter Clausen,
	Sascha Hauer, Shawn Guo

On Mon, Sep 23, 2013 at 12:14:44AM -0300, Fabio Estevam wrote:
> Hi Nicolin,
> 
> On Sun, Sep 22, 2013 at 11:40 PM, Nicolin Chen <b42378@freescale.com> wrote:
> > On Sun, Sep 22, 2013 at 11:56:17PM -0300, Fabio Estevam wrote:
> 
> > I want to, but I don't have a wandboard. Could you please give me the new
> > printed log? I think after the modification there should be little different
> > for the case.
> 
> Sorry, I made something wrong and now it is working.
> 
> Will submit the patch.

Great.

> 
> Running several times in a row, sometimes I get:
> 
> $ arecord -d 10 -f cd | aplay -f cd
> fsl-ssi-dai 2028000.ssi: ASoC: Not enforcing symmetric_rates due to race
> sgtl5000 1-000a: ASoC: Not enforcing symmetric_rates due to race
> Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
> Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
> 
> ,but the playback always work now.
> 
> Thanks,

Welcome.

> 
> Fabio Estevam
> 

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

end of thread, other threads:[~2013-09-23  3:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-23  2:05 fsl_ssi: Cannot do simultaneous capture and playback Fabio Estevam
2013-09-23  2:13 ` Nicolin Chen
2013-09-23  2:56   ` Fabio Estevam
2013-09-23  2:40     ` Nicolin Chen
2013-09-23  3:14       ` Fabio Estevam
2013-09-23  3:19         ` Nicolin Chen

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.