[Alsa Document]4, machine.txt

[Alsa Document]1, overall.txt的描述中我们了解到Alsa分为三部分,分别是:
<1> codec driver
<2> platform driver
<3> Machine driver

本篇来介绍machine driver
基于4.9.123版本内核 Documentation/sound/alsa/soc/machine.txt

ASoC Machine Driver
===================

The ASoC machine (or board) driver is the code that glues together all the
component drivers (e.g. codecs, platforms and DAIs). It also describes the
relationships between each component which include audio paths, GPIOs,
interrupts, clocking, jacks and voltage regulators.
ASoC机器(或板)驱动程序是将所有组件驱动程序(例如编解码器,平台和DAI)粘合在一起的代码。
它还描述了每个组件之间的关系,包括音频路径,GPIO,中断,时钟,插孔和电压调节器。

The machine driver can contain codec and platform specific code. It registers
the audio subsystem with the kernel as a platform device and is represented by
the following struct:-
机器驱动程序可以包含编解码器和平台特定代码。 它将音频子系统注册为内核作为平台设备,并由
以下结构表示: - 

/* SoC machine */
struct snd_soc_card {
  char *name;

  ...

  int (*probe)(struct platform_device *pdev);
  int (*remove)(struct platform_device *pdev);

  /* the pre and post PM functions are used to do any PM work before and
   * after the codec and DAIs do any PM work. */
  int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
  int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
  int (*resume_pre)(struct platform_device *pdev);
  int (*resume_post)(struct platform_device *pdev);

  ...

  /* CPU <--> Codec DAI links  */
  struct snd_soc_dai_link *dai_link;
  int num_links;

  ...
};

probe()/remove()
----------------
probe/remove are optional. Do any machine specific probe here.
probe/remove 是可选的。 在这里做任何机器特定probe 。

suspend()/resume()
------------------
The machine driver has pre and post versions of suspend and resume to take care
of any machine audio tasks that have to be done before or after the codec, DAIs
and DMA is suspended and resumed. Optional.
机器驱动程序具有暂停和恢复的前后版本,以处理在编解码器,DAI和DMA暂停和恢复之前或之后必须
完成的任何机器音频任务。可选的。

Machine DAI Configuration
-------------------------
The machine DAI configuration glues all the codec and CPU DAIs together. It can
also be used to set up the DAI system clock and for any machine related DAI
initialisation e.g. the machine audio map can be connected to the codec audio
map, unconnected codec pins can be set as such.
机器DAI配置将所有编解码器和CPU DAI粘合在一起。 它还可用于设置DAI系统时钟和任何与机器相关
的DAI初始化,例如 机器音频图可以连接到编解码器音频图,未连接的编解码器引脚可以这样设置。

struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
struct snd_soc_dai_link 被用来设置每一个machine的DAI。例如:

/* corgi digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link corgi_dai = {
  .name = "WM8731",
  .stream_name = "WM8731",
  .cpu_dai_name = "pxa-is2-dai",
  .codec_dai_name = "wm8731-hifi",
  .platform_name = "pxa-pcm-audio",
  .codec_name = "wm8713-codec.0-001a",
  .init = corgi_wm8731_init,
  .ops = &corgi_ops,
};

struct snd_soc_card then sets up the machine with its DAIs. e.g.
然后struct snd_soc_card 用这些DAI来设置machine。例如:

/* corgi audio machine driver */
static struct snd_soc_card snd_soc_corgi = {
  .name = "Corgi",
  .dai_link = &corgi_dai,
  .num_links = 1,
};

Machine Power Map
-----------------

The machine driver can optionally extend the codec power map and to become an
audio power map of the audio subsystem. This allows for automatic power up/down
of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
sockets in the machine init function.
机器驱动器可以可选地扩展编解码器功率图并成为音频子系统的音频功率图。 这允许扬声器/ HP放
大器等的自动加电/断电。编解码器引脚可以在机器初始化功能中连接到机器插孔插座。

Machine Controls
----------------

Machine specific audio mixer controls can be added in the DAI init function.
可以在DAI初始化功能中添加机器特定的音频混音器控件。

猜你喜欢

转载自blog.csdn.net/wangyijieonline/article/details/88118009