runtime->hw的初始化时在打开pcm设备时完成的,代码:
snd_pcm_playback_open() --->
snd_pcm_open() --->
snd_pcm_open_file() --->
snd_pcm_open_substream() --->
substream->ops->open() --->
dpcm_fe_dai_open() --->
dpcm_fe_dai_startup() --->
soc_pcm_open() --->
platform->driver->ops->open(), 这里会针对不同应用调用其platform component的open函数,有如下这些:
/* 播放音乐,msm-pcm-q6-v2.c */
static int msm_pcm_open(struct snd_pcm_substream *substream)
{
......
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
runtime->hw = msm_pcm_hardware_playback;
else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
runtime->hw = msm_pcm_hardware_capture;
......
}
/* 通话,msm-pcm-voice-v2.c */
static int msm_pcm_open(struct snd_pcm_substream *substream)
{
......
runtime->hw = msm_pcm_hardware;
......
}
/* Loopback,msm-pcm-loopback-v2.c */
static int msm_pcm_open(struct snd_pcm_substream *substream)
{
......
snd_soc_set_runtime_hwparams(substream, &dummy_pcm_hardware);
......
}
后续在通过ioctl设置hw params时,会根据约束条件对应用层传入的runtime->hw的params做进一步调整。。。。。。
浙公网安备 33010602011771号