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