ALSA framework problem: FE disconnected, BE still connected!
Hi Liam,
We have a problem encountered in ALSA framework wrt FE/BE disconnection and fix to it is mentioned in below code change. please check it and provide your valuable comments.
----------------------
From: Laxminath Kasam <[email protected]>
Date: Wed, 3 Apr 2013 14:03:17 +0530
Subject: [PATCH] ASoC: audio: Fix BE not disconnected even codec teardown
Scenario:
When FE1(LowLatency) comes in which opens BE1 and puts it in state SND_SOC_DPCM_STATE_START. Similarly FE2(LPA) comes in with connecting to same BE. Now FE2 is in SND_SOC_DPCM_STATE_PREPARE state and waits for TRIGGER_START. Meanwhile FE1 is closed which doesn't affect BE1 and FE2 which are connected.
Also, for FE2 pcm_close is called before TRIGGER_START itself. In such a case, BE1 is not getting disconnected while Codec is teared down resulting in failures.
Fix:
Whenever BE1 is found to be in SND_SOC_DPCM_STATE_START state and FE1 being connected is not started yet, and close sequence happens for this FE, then allow hw_free to happen for BE1 if this is the only FE connected to this BE1. This allows BE to be disconnected which calls afe_close then followed by Codec teardown not resulting in any failures.
---sound/soc/soc-pcm.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
sound/soc/soc-pcm.c +0 -0
@@ -1765,7 +1765,12 @@ static int soc_dpcm_be_dai_hw_free(struct
snd_soc_pcm_runtime *fe, int stream)
(be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) &&
(be->dpcm[stream].state !=
SND_SOC_DPCM_STATE_HW_FREE) &&
(be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED) &&
- (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP))
+ (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) &&
+ !((be->dpcm[stream].state == SND_SOC_DPCM_STATE_START)&&+ ((fe->dpcm[stream].state !=SND_SOC_DPCM_STATE_START) &&
+ (fe->dpcm[stream].state !=SND_SOC_DPCM_STATE_PAUSED) &&
+ (fe->dpcm[stream].state !=
+SND_SOC_DPCM_STATE_SUSPEND))))
continue;
dev_dbg(be->dev, "dpcm: hw_free BE %s\n",--
-----------------------------------------
Please let me know if you are looking for more details.
Thanks
Kasam
Mark Brown
maintainerQuoted 4 lines · On Thu, Apr 18, 2013 at 09:56:25AM -0700, [email protected] wrote:
Hi Liam,
We have a problem encountered in ALSA framework wrt FE/BE disconnection and fix to it is mentioned in below code change. please check it and provide your valuable comments.
Please submit patches in hte form covered in SubmittingPatches.
Quoted 7 lines · Mark Brown
Quoted 4 lines · On Thu, Apr 18, 2013 at 09:56:25AM -0700, [email protected] wrote:
Hi Liam,
We have a problem encountered in ALSA framework wrt FE/BE disconnection and fix to it is mentioned in below code change. please check it and provide your valuable comments.Please submit patches in hte form covered in SubmittingPatches.
Hi Mark,
We are not sure if the solution is correct. Change from Kasam will skip the step which trigger stop the hardware and directly call hardware free. Is it expected that every driver internally stops the hardware before freeing the hardware resource if not stopped?
Thanks
Patrick
Quoted 8 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Mark Brown
maintainerQuoted 5 lines · Patrick Lai
Quoted 1 line · Mark Brown
Please submit patches in hte form covered in SubmittingPatches.
We are not sure if the solution is correct. Change from Kasam will skip
Even if you're not sure it's best to post as a normal patch so if the patch is a good solution it can be applied.
Quoted 3 lines
the step which trigger stop the hardware and directly call hardware free. Is it expected that every driver internally stops the hardware before freeing the hardware resource if not stopped?
That seems silly.