Edit online

接口设计

3 Mar 2025
Read time: 1 minute(s)
1. aic_codec_trigger

函数原型

static int aic_codec_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai)

功能说明

AudioCodec 的触发函数,根据 cmd 执行不同的操作

参数定义

substream:指向需要执行 cmd 的 substreamcmd:需要执行的操作 dai:unused

返回值

0:执行成功-EINVAL:参数非法

注意事项

可以传递的 cmd 参数有:
  • SNDRV_PCM_TRIGGER_START
  • SNDRV_PCM_TRIGGER_RESUME
  • SNDRV_PCM_TRIGGER_PAUSE_RELEASE
  • SNDRV_PCM_TRIGGER_STOPSNDRV_PCM_TRIGGER_SUSPENDSNDRV_PCM_TRIGGER_PAUSE_PUSH
2. aic_codec_get_mod_freq

函数原型

static unsigned int aic_codec_get_mod_freq(struct aic_codec *codec, struct snd_pcm_hw_params *params)

功能说明

根据传入的参数 params,获取需要设置的 AudioCodec 模块的时钟频率

参数定义

codec:指向 codec 的指针 params:传入的硬件参数指针

返回值

执行成功返回需要设置的 codec 时钟频率,否则返回 0

注意事项

-

3. aic_codec_hw_params

函数原型

static int aic_codec_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)

功能说明

根据传入的 params 参数,设置 codec 模块的时钟及采样率

参数定义

substream:指向需要设置的 subtsreamparams:需要设置的硬件参数 dai:unused

返回值

0:执行成功-EINVAL:参数非法

注意事项

-

4. aic_codec_startup

函数原型

static int aic_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)

功能说明

AudioCodec 的 startup 函数,执行音频流 trigger 前需要设置的操作。 此处用于设置 period 和 dma buffer 的对齐方式

参数定义

substream:指向需要执行 startup 的 substreamdai:设置的 dai 指针

返回值

0:执行成功-EINVAL:参数非法

5. aic_codec_dai_probe

函数原型

static int aic_codec_dai_probe(struct snd_soc_dai *dai)

功能原型

执行 dma 的初始化操作

参数定义

dai:指向 dai 的指针

返回值

0:执行成功

注意事项

-