ASoC Drivers: Which files are platform, machine, and codec drivers? [closed]
Asked Answered
M

3

5

When navigating the Linux ASoC files, which ones pertain to the following categories:

  • Platform Driver: ? (somewhere in sound/soc/ ?)
  • Machine Driver: ? (somewhere in sound/soc/ ?)
  • Codec Driver: sound/soc/codecs/partname.c

From kernel documentation: https://www.kernel.org/doc/Documentation/sound/alsa/soc/overview.txt

To achieve all this, ASoC basically splits an embedded audio system into 3 components :-

  • Codec driver: The codec driver is platform independent and contains audio controls, audio interface capabilities, codec DAPM definition and codec IO functions.

  • Platform driver: The platform driver contains the audio DMA engine and audio interface drivers (e.g. I2S, AC97, PCM) for that platform.

  • Machine driver: The machine driver handles any machine specific controls and audio events (e.g. turning on an amp at start of playback).

Also, where are the launching points for each of these pieces? (May be self explanatory when I find which files they are in)

Masera answered 21/11, 2013 at 1:34 Comment(1)
I know such questions are not allowed in StackOverflow. But such question and their detailed answers are very useful for understanding new systems or refreshing your system knowledge after sometime. - I think stackoverflow allow such questionStowage
C
6

The codec drivers are in sound/soc/codecs/.

The platform drivers typcially are in sound/soc/platform/.

Machine drivers can be in some arch-specific directory; those for development boards typically are in the same directory; for example, this is sound/soc/atmel/Makefile:

# AT91 Platform Support
snd-soc-atmel-pcm-objs := atmel-pcm.o
snd-soc-atmel-pcm-pdc-objs := atmel-pcm-pdc.o
snd-soc-atmel-pcm-dma-objs := atmel-pcm-dma.o
snd-soc-atmel_ssc_dai-objs := atmel_ssc_dai.o

obj-$(CONFIG_SND_ATMEL_SOC) += snd-soc-atmel-pcm.o
obj-$(CONFIG_SND_ATMEL_SOC_PDC) += snd-soc-atmel-pcm-pdc.o
obj-$(CONFIG_SND_ATMEL_SOC_DMA) += snd-soc-atmel-pcm-dma.o
obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o

# AT91 Machine Support
snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o
snd-atmel-soc-wm8904-objs := atmel_wm8904.o
snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o

obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
obj-$(CONFIG_SND_ATMEL_SOC_WM8904) += snd-atmel-soc-wm8904.o
obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o
obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o

Machine driver files typcially implement a platform driver.

Carnauba answered 21/11, 2013 at 8:49 Comment(1)
Where did you learn this information? So far, I have just been learning by putting pr_info statements in the source code, but I feel there should be a better way.Masera
I
2

Refer this link https://01.org/linuxgraphics/gfx-docs/drm/sound/soc/index.html, it has very good explanation on ASOC

Codec class drivers: The codec class driver is platform independent and contains audio controls, audio interface capabilities, codec DAPM definition and codec IO functions. This class extends to BT, FM and MODEM ICs if required. Codec class drivers should be generic code that can run on any architecture and machine.

Platform class drivers: The platform class driver includes the audio DMA engine driver, digital audio interface (DAI) drivers (e.g. I2S, AC97, PCM) and any audio DSP drivers for that platform.

Machine class driver: The machine driver class acts as the glue that describes and binds the other component drivers together to form an ALSA “sound card device”. It handles any machine specific controls and machine level audio events (e.g. turning on an amp at start of playback).

You can match this information with source code to find your corresponding Codec,Platform and Machine drivers.

Example

Codec Driver: https://elixir.bootlin.com/linux/latest/source/sound/soc/codecs/max98927.c

Platform Driver: https://elixir.bootlin.com/linux/latest/source/sound/soc/qcom/lpass-platform.c

Machine Driver: https://elixir.bootlin.com/linux/latest/source/sound/soc/qcom/sdm845.c

Illconditioned answered 6/1, 2019 at 9:9 Comment(0)
S
2

CL's answer can be used as a rule of thumb.

But, I feel the best way to figure out which file have which driver code(platform, machine, codec) is by analyzing the the structures that the driver code is using.

A Codec class driver must provide the DAI an PCM configurations. Therefore it has to have an instance of struct snd_soc_dai_driver. Also the audio controls and DAPM handlers must be defined, this is done by using struct snd_soc_codec_driver

More info here

A Platform driver has to define the PCM operations. This is done by using struct snd_pcm_ops

A Machine driver acts as a link between the two. Hence it has to make use of struct snd_soc_dai_link. This struct has members cpu_dai_name and codec_dai_name for mentioning the platform and codec driver it's going to link

Hope this helps.

Shooter answered 6/11, 2019 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.