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://kernel.linux.club.tw/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。