Skip to content

Commit 07fa5db

Browse files
marcanjannau
authored andcommitted
ASoC: apple: mca: Do not mark clocks in use for non-providers
On the speakers PCM, this sequence: 1. Open playback 2. Open sense 3. Close playback 4. Close sense would result in the sense FE being marked as clocks in use at (2), since there is a clock provider (playback FE). Then at (4) this would WARN since there is no driver any more when closing the in use clocks. If (1) and (2) are reversed this does not happen, since the sense PCM is not marked as using the clocks when there is no provider yet. So, check explicitly whether the substream FE is a clock provider in be_prepare, and skip everything if it isn't. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 59c5d99 commit 07fa5db

1 file changed

Lines changed: 37 additions & 30 deletions

File tree

sound/soc/apple/mca.c

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -352,36 +352,6 @@ static bool mca_fe_clocks_in_use(struct mca_cluster *cl)
352352
return false;
353353
}
354354

355-
static int mca_be_prepare(struct snd_pcm_substream *substream,
356-
struct snd_soc_dai *dai)
357-
{
358-
struct mca_cluster *cl = mca_dai_to_cluster(dai);
359-
struct mca_data *mca = cl->host;
360-
struct mca_cluster *fe_cl;
361-
int ret;
362-
363-
if (cl->port_clk_driver < 0)
364-
return 0;
365-
366-
fe_cl = &mca->clusters[cl->port_clk_driver];
367-
368-
/*
369-
* Typically the CODECs we are paired with will require clocks
370-
* to be present at time of unmute with the 'mute_stream' op
371-
* or at time of DAPM widget power-up. We need to enable clocks
372-
* here at the latest (frontend prepare would be too late).
373-
*/
374-
if (!mca_fe_clocks_in_use(fe_cl)) {
375-
ret = mca_fe_enable_clocks(fe_cl);
376-
if (ret < 0)
377-
return ret;
378-
}
379-
380-
cl->clocks_in_use[substream->stream] = true;
381-
382-
return 0;
383-
}
384-
385355
static int mca_fe_prepare(struct snd_pcm_substream *substream,
386356
struct snd_soc_dai *dai)
387357
{
@@ -787,6 +757,43 @@ static struct snd_soc_pcm_runtime *mca_be_get_fe(struct snd_soc_pcm_runtime *be,
787757
return fe;
788758
}
789759

760+
static int mca_be_prepare(struct snd_pcm_substream *substream,
761+
struct snd_soc_dai *dai)
762+
{
763+
struct snd_soc_pcm_runtime *be = snd_soc_substream_to_rtd(substream);
764+
struct snd_soc_pcm_runtime *fe = mca_be_get_fe(be, substream->stream);
765+
struct mca_cluster *cl = mca_dai_to_cluster(dai);
766+
struct mca_data *mca = cl->host;
767+
struct mca_cluster *fe_cl, *fe_clk_cl;
768+
int ret;
769+
770+
fe_cl = mca_dai_to_cluster(snd_soc_rtd_to_cpu(fe, 0));
771+
772+
if (!fe_cl->clk_provider)
773+
return 0;
774+
775+
if (cl->port_clk_driver < 0)
776+
return 0;
777+
778+
fe_clk_cl = &mca->clusters[cl->port_clk_driver];
779+
780+
/*
781+
* Typically the CODECs we are paired with will require clocks
782+
* to be present at time of unmute with the 'mute_stream' op
783+
* or at time of DAPM widget power-up. We need to enable clocks
784+
* here at the latest (frontend prepare would be too late).
785+
*/
786+
if (!mca_fe_clocks_in_use(fe_clk_cl)) {
787+
ret = mca_fe_enable_clocks(fe_clk_cl);
788+
if (ret < 0)
789+
return ret;
790+
}
791+
792+
cl->clocks_in_use[substream->stream] = true;
793+
794+
return 0;
795+
}
796+
790797
static int mca_be_startup(struct snd_pcm_substream *substream,
791798
struct snd_soc_dai *dai)
792799
{

0 commit comments

Comments
 (0)