18c2ecf20Sopenharmony_ci======================= 28c2ecf20Sopenharmony_ciALSA SoC Layer Overview 38c2ecf20Sopenharmony_ci======================= 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciThe overall project goal of the ALSA System on Chip (ASoC) layer is to 68c2ecf20Sopenharmony_ciprovide better ALSA support for embedded system-on-chip processors (e.g. 78c2ecf20Sopenharmony_cipxa2xx, au1x00, iMX, etc) and portable audio codecs. Prior to the ASoC 88c2ecf20Sopenharmony_cisubsystem there was some support in the kernel for SoC audio, however it 98c2ecf20Sopenharmony_cihad some limitations:- 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci * Codec drivers were often tightly coupled to the underlying SoC 128c2ecf20Sopenharmony_ci CPU. This is not ideal and leads to code duplication - for example, 138c2ecf20Sopenharmony_ci Linux had different wm8731 drivers for 4 different SoC platforms. 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci * There was no standard method to signal user initiated audio events (e.g. 168c2ecf20Sopenharmony_ci Headphone/Mic insertion, Headphone/Mic detection after an insertion 178c2ecf20Sopenharmony_ci event). These are quite common events on portable devices and often require 188c2ecf20Sopenharmony_ci machine specific code to re-route audio, enable amps, etc., after such an 198c2ecf20Sopenharmony_ci event. 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci * Drivers tended to power up the entire codec when playing (or 228c2ecf20Sopenharmony_ci recording) audio. This is fine for a PC, but tends to waste a lot of 238c2ecf20Sopenharmony_ci power on portable devices. There was also no support for saving 248c2ecf20Sopenharmony_ci power via changing codec oversampling rates, bias currents, etc. 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ciASoC Design 288c2ecf20Sopenharmony_ci=========== 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ciThe ASoC layer is designed to address these issues and provide the following 318c2ecf20Sopenharmony_cifeatures :- 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci * Codec independence. Allows reuse of codec drivers on other platforms 348c2ecf20Sopenharmony_ci and machines. 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci * Easy I2S/PCM audio interface setup between codec and SoC. Each SoC 378c2ecf20Sopenharmony_ci interface and codec registers its audio interface capabilities with the 388c2ecf20Sopenharmony_ci core and are subsequently matched and configured when the application 398c2ecf20Sopenharmony_ci hardware parameters are known. 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci * Dynamic Audio Power Management (DAPM). DAPM automatically sets the codec to 428c2ecf20Sopenharmony_ci its minimum power state at all times. This includes powering up/down 438c2ecf20Sopenharmony_ci internal power blocks depending on the internal codec audio routing and any 448c2ecf20Sopenharmony_ci active streams. 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci * Pop and click reduction. Pops and clicks can be reduced by powering the 478c2ecf20Sopenharmony_ci codec up/down in the correct sequence (including using digital mute). ASoC 488c2ecf20Sopenharmony_ci signals the codec when to change power states. 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci * Machine specific controls: Allow machines to add controls to the sound card 518c2ecf20Sopenharmony_ci (e.g. volume control for speaker amplifier). 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciTo achieve all this, ASoC basically splits an embedded audio system into 548c2ecf20Sopenharmony_cimultiple re-usable component drivers :- 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci * Codec class drivers: The codec class driver is platform independent and 578c2ecf20Sopenharmony_ci contains audio controls, audio interface capabilities, codec DAPM 588c2ecf20Sopenharmony_ci definition and codec IO functions. This class extends to BT, FM and MODEM 598c2ecf20Sopenharmony_ci ICs if required. Codec class drivers should be generic code that can run 608c2ecf20Sopenharmony_ci on any architecture and machine. 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci * Platform class drivers: The platform class driver includes the audio DMA 638c2ecf20Sopenharmony_ci engine driver, digital audio interface (DAI) drivers (e.g. I2S, AC97, PCM) 648c2ecf20Sopenharmony_ci and any audio DSP drivers for that platform. 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci * Machine class driver: The machine driver class acts as the glue that 678c2ecf20Sopenharmony_ci describes and binds the other component drivers together to form an ALSA 688c2ecf20Sopenharmony_ci "sound card device". It handles any machine specific controls and 698c2ecf20Sopenharmony_ci machine level audio events (e.g. turning on an amp at start of playback). 70