ASoC平台驱动

ASoC平台驱动类可以分为音频DMA驱动、SoC DAI驱动和DSP驱动。平台驱动程序只针对SoC CPU,并且必须没有板级特定代码。

音频DMA

平台DMA驱动程序可选地支持以下ALSA操作:-

/* SoC audio ops */
struct snd_soc_ops {
      int (*startup)(struct snd_pcm_substream *);
      void (*shutdown)(struct snd_pcm_substream *);
      int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
      int (*hw_free)(struct snd_pcm_substream *);
      int (*prepare)(struct snd_pcm_substream *);
      int (*trigger)(struct snd_pcm_substream *, int);
};

平台驱动程序通过 struct snd_soc_component_driver 导出其DMA功能:-

struct snd_soc_component_driver {
      const char *name;

      ...
      int (*probe)(struct snd_soc_component *);
      void (*remove)(struct snd_soc_component *);
      int (*suspend)(struct snd_soc_component *);
      int (*resume)(struct snd_soc_component *);

      /* pcm creation and destruction */
      int (*pcm_new)(struct snd_soc_pcm_runtime *);
      void (*pcm_free)(struct snd_pcm *);

      ...
      const struct snd_pcm_ops *ops;
      const struct snd_compr_ops *compr_ops;
      ...
};

有关音频DMA的详细信息,请参阅ALSA驱动程序文档。https://linuxkernel.org.cn/doc/html/latest/sound/kernel-api/writing-an-alsa-driver.html

一个DMA驱动程序的例子是soc/pxa/pxa2xx-pcm.c

SoC DAI驱动

每个SoC DAI驱动程序必须提供以下功能:-

  1. 数字音频接口(DAI)描述

  2. 数字音频接口配置

  3. PCM的描述

  4. SYSCLK配置

  5. 挂起和恢复(可选)

有关第1 - 4项的描述,请参阅ASoC Codec类驱动程序

SoC DSP驱动

每个SoC DSP驱动程序通常提供以下功能:-

  1. DAPM 图

  2. 混音器控制

  3. 与DSP缓冲区之间的DMA IO(如果适用)

  4. DSP前端(FE)PCM设备的定义。

有关第4项的描述,请参阅DPCM.txt。