[PATCH 1/1] ASoC: soc-dai: export some symbols
Jason Zhu
jason.zhu at rock-chips.com
Wed Sep 21 04:37:06 CEST 2022
在 2022/9/20 20:47, Mark Brown 写道:
> On Tue, Sep 20, 2022 at 11:45:45AM +0800, Jason Zhu wrote:
>
>> Sometimes we need to make some dais alive when close the card, like
>> VAD, so these functions must be exported so that they can be called.
> I'm not sure I fully understand the use case here - why wouldn't
> the core know about the audio stream being kept active? For
> something like VAD I'd expect this to be just working like a
> normal audio path, if there's a DSP consuming the audio stream
> then it'll keep everything open. If there is a good use case I
> suspect it'll be clearer if you send the users along with this
> patch.
Thanks. For example, we use the VAD(Voice Activity Detect) & PDM(
Pulse Density Modulation) to record sound>. The PDM is used to
record and copy data to DDR memory by DMA when the system is alive.
The VAD is used to detect voice from PDM and copy data to sram
(The sram is small) when the system is sleep. If the VAD detect
specific sound, wake up the system and continue to record sound.
The data can not be lost in this process. So we attach VAD & PDM
in the same card, then close the card and wake up VAD & PDM again
when the system is goto sleep. Like these code:
vad-sound {
...
rockchip,cpu = <&pdm0>;
rockchip,codec = <&es7202>, <&vad>;
...
};
static int rockchip_vad_enable_cpudai(struct rockchip_vad *vad)
{
struct snd_soc_dai *cpu_dai;
struct snd_pcm_substream *substream;
int ret = 0;
cpu_dai = vad->cpu_dai;
substream = vad->substream;
if (!cpu_dai || !substream)
return 0;
pm_runtime_get_sync(cpu_dai->dev);
if (cpu_dai->driver->ops && cpu_dai->driver->ops->trigger) {
ret = cpu_dai->driver->ops->startup(substream,
cpu_dai);
ret = cpu_dai->driver->ops->trigger(substream,
SNDRV_PCM_TRIGGER_START,
cpu_dai);
}
return ret;
}
When the system is waked up, open the sound card. The data in sram
is copied firstly and close the vad. Then use the DMA to move data
to DDR memory from PDM.
Now we prefer to use framework code, like:
static int rockchip_vad_enable_cpudai(struct rockchip_vad *vad)
{
struct snd_soc_dai *cpu_dai;
struct snd_pcm_substream *substream;
int ret = 0;
cpu_dai = vad->cpu_dai;
substream = vad->substream;
if (!cpu_dai || !substream)
return 0;
pm_runtime_get_sync(cpu_dai->dev);
ret = snd_soc_dai_startup(cpu_dai, substream);
ret |= snd_soc_pcm_dai_prepare(substream);
ret |= snd_soc_pcm_dai_trigger(substream, SNDRV_PCM_TRIGGER_START);
return ret;
}
In this situation, those symbols must be exported.
Look forward to your reply and suggestions.
More information about the Alsa-devel
mailing list