^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) ALSA SoC Layer Overview
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) The overall project goal of the ALSA System on Chip (ASoC) layer is to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) provide better ALSA support for embedded system-on-chip processors (e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) pxa2xx, au1x00, iMX, etc) and portable audio codecs. Prior to the ASoC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) subsystem there was some support in the kernel for SoC audio, however it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) had some limitations:-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Codec drivers were often tightly coupled to the underlying SoC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) CPU. This is not ideal and leads to code duplication - for example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) Linux had different wm8731 drivers for 4 different SoC platforms.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * There was no standard method to signal user initiated audio events (e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) Headphone/Mic insertion, Headphone/Mic detection after an insertion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) event). These are quite common events on portable devices and often require
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) machine specific code to re-route audio, enable amps, etc., after such an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Drivers tended to power up the entire codec when playing (or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) recording) audio. This is fine for a PC, but tends to waste a lot of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) power on portable devices. There was also no support for saving
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) power via changing codec oversampling rates, bias currents, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ASoC Design
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) The ASoC layer is designed to address these issues and provide the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) features :-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * Codec independence. Allows reuse of codec drivers on other platforms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) and machines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * Easy I2S/PCM audio interface setup between codec and SoC. Each SoC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) interface and codec registers its audio interface capabilities with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) core and are subsequently matched and configured when the application
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) hardware parameters are known.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * Dynamic Audio Power Management (DAPM). DAPM automatically sets the codec to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) its minimum power state at all times. This includes powering up/down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) internal power blocks depending on the internal codec audio routing and any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) active streams.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * Pop and click reduction. Pops and clicks can be reduced by powering the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) codec up/down in the correct sequence (including using digital mute). ASoC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) signals the codec when to change power states.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * Machine specific controls: Allow machines to add controls to the sound card
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) (e.g. volume control for speaker amplifier).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) To achieve all this, ASoC basically splits an embedded audio system into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) multiple re-usable component drivers :-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * Codec class drivers: The codec class driver is platform independent and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) contains audio controls, audio interface capabilities, codec DAPM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) definition and codec IO functions. This class extends to BT, FM and MODEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) ICs if required. Codec class drivers should be generic code that can run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) on any architecture and machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * Platform class drivers: The platform class driver includes the audio DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) engine driver, digital audio interface (DAI) drivers (e.g. I2S, AC97, PCM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) and any audio DSP drivers for that platform.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * Machine class driver: The machine driver class acts as the glue that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) describes and binds the other component drivers together to form an ALSA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) "sound card device". It handles any machine specific controls and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) machine level audio events (e.g. turning on an amp at start of playback).