Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77190f03 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ASoC: doc: ReSTize dapm.txt



A simple conversion from a plain text file.
The section numbers and the item numbers are dropped to align with the
ReST format.  Some lists are converted to description lists to be
clearer.

Acked-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent e732d1bc
Loading
Loading
Loading
Loading
+143 −106
Original line number Diff line number Diff line
===================================================
Dynamic Audio Power Management for Portable Devices
===================================================

1. Description
==============
Description
===========

Dynamic Audio Power Management (DAPM) is designed to allow portable
Linux devices to use the minimum amount of power within the audio
@@ -21,20 +22,28 @@ level power systems.

There are 4 power domains within DAPM

   1. Codec bias domain - VREF, VMID (core codec and audio power)
Codec bias domain
      VREF, VMID (core codec and audio power)

      Usually controlled at codec probe/remove and suspend/resume, although
      can be set at stream time if power is not needed for sidetone, etc.

   2. Platform/Machine domain - physically connected inputs and outputs
Platform/Machine domain
      physically connected inputs and outputs

      Is platform/machine and user action specific, is configured by the
      machine driver and responds to asynchronous events e.g when HP
      are inserted

   3. Path domain - audio subsystem signal paths
Path domain
      audio subsystem signal paths

      Automatically set when mixer and mux settings are changed by the user.
      e.g. alsamixer, amixer.

   4. Stream domain - DACs and ADCs.
Stream domain
      DACs and ADCs.

      Enabled and disabled when stream playback/capture is started and
      stopped respectively. e.g. aplay, arecord.

@@ -45,34 +54,57 @@ internal codec components). All audio components that effect power are called
widgets hereafter.


2. DAPM Widgets
===============
DAPM Widgets
============

Audio DAPM widgets fall into a number of types:-

 o Mixer      - Mixes several analog signals into a single analog signal.
 o Mux        - An analog switch that outputs only one of many inputs.
 o PGA        - A programmable gain amplifier or attenuation widget.
 o ADC        - Analog to Digital Converter
 o DAC        - Digital to Analog Converter
 o Switch     - An analog switch
 o Input      - A codec input pin
 o Output     - A codec output pin
 o Headphone  - Headphone (and optional Jack)
 o Mic        - Mic (and optional Jack)
 o Line       - Line Input/Output (and optional Jack)
 o Speaker    - Speaker
 o Supply     - Power or clock supply widget used by other widgets.
 o Regulator  - External regulator that supplies power to audio components.
 o Clock      -	External clock that supplies clock to audio components.
 o AIF IN     - Audio Interface Input (with TDM slot mask).
 o AIF OUT    - Audio Interface Output (with TDM slot mask).
 o Siggen     - Signal Generator.
 o DAI IN     - Digital Audio Interface Input.
 o DAI OUT    - Digital Audio Interface Output.
 o DAI Link   - DAI Link between two DAI structures */
 o Pre        - Special PRE widget (exec before all others)
 o Post       - Special POST widget (exec after all others)
Mixer
	Mixes several analog signals into a single analog signal.
Mux
	An analog switch that outputs only one of many inputs.
PGA
	A programmable gain amplifier or attenuation widget.
ADC
	Analog to Digital Converter
DAC
	Digital to Analog Converter
Switch
	An analog switch
Input
	A codec input pin
Output
	A codec output pin
Headphone
	Headphone (and optional Jack)
Mic
	Mic (and optional Jack)
Line
	Line Input/Output (and optional Jack)
Speaker
	Speaker
Supply
	Power or clock supply widget used by other widgets.
Regulator
	External regulator that supplies power to audio components.
Clock
	External clock that supplies clock to audio components.
AIF IN
	Audio Interface Input (with TDM slot mask).
AIF OUT
	Audio Interface Output (with TDM slot mask).
Siggen
	Signal Generator.
DAI IN
	Digital Audio Interface Input.
DAI OUT
	Digital Audio Interface Output.
DAI Link
	DAI Link between two DAI structures
Pre
	Special PRE widget (exec before all others)
Post
	Special POST widget (exec after all others)

(Widgets are defined in include/sound/soc-dapm.h)

@@ -84,14 +116,15 @@ Most widgets have a name, register, shift and invert. Some widgets have extra
parameters for stream name and kcontrols.


2.1 Stream Domain Widgets
-------------------------
Stream Domain Widgets
---------------------

Stream Widgets relate to the stream power domain and only consist of ADCs
(analog to digital converters), DACs (digital to analog converters),
AIF IN and AIF OUT.

Stream widgets have the following format:-
::

  SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert),
  SND_SOC_DAPM_AIF_IN(name, stream, slot, reg, shift, invert)
@@ -100,27 +133,31 @@ NOTE: the stream name must match the corresponding stream name in your codec
snd_soc_codec_dai.

e.g. stream widgets for HiFi playback and capture
::

  SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1),
  SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1),

e.g. stream widgets for AIF
::

  SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
  SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),


2.2 Path Domain Widgets
-----------------------
Path Domain Widgets
-------------------

Path domain widgets have a ability to control or affect the audio signal or
audio paths within the audio subsystem. They have the following form:-
::

  SND_SOC_DAPM_PGA(name, reg, shift, invert, controls, num_controls)

Any widget kcontrols can be set using the controls and num_controls members.

e.g. Mixer widget (the kcontrols are declared first)
::

  /* Output Mixer */
  static const snd_kcontrol_new_t wm8731_output_mixer_controls[] = {
@@ -137,22 +174,22 @@ you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same
as for SND_SOC_DAPM_MIXER.


2.3 Machine domain Widgets
--------------------------
Machine domain Widgets
----------------------

Machine widgets are different from codec widgets in that they don't have a
codec register bit associated with them. A machine widget is assigned to each
machine audio component (non codec or DSP) that can be independently
powered. e.g.

 o Speaker Amp
 o Microphone Bias
 o Jack connectors
* Speaker Amp
* Microphone Bias
* Jack connectors

A machine widget can have an optional call back.

e.g. Jack connector widget for an external Mic that enables Mic Bias
when the Mic is inserted:-
when the Mic is inserted:-::

  static int spitz_mic_bias(struct snd_soc_dapm_widget* w, int event)
  {
@@ -163,20 +200,21 @@ static int spitz_mic_bias(struct snd_soc_dapm_widget* w, int event)
  SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias),


2.4 Codec (BIAS) Domain
-----------------------
Codec (BIAS) Domain
-------------------

The codec bias power domain has no widgets and is handled by the codecs DAPM
event handler. This handler is called when the codec powerstate is changed wrt
to any stream event or by kernel PM events.


2.5 Virtual Widgets
-------------------
Virtual Widgets
---------------

Sometimes widgets exist in the codec or machine audio map that don't have any
corresponding soft power control. In this case it is necessary to create
a virtual widget - a widget with no control bits e.g.
::

  SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_DAPM_NOPM, 0, 0, NULL, 0),

@@ -186,8 +224,8 @@ After all the widgets have been defined, they can then be added to the DAPM
subsystem individually with a call to snd_soc_dapm_new_control().


3. Codec/DSP Widget Interconnections
====================================
Codec/DSP Widget Interconnections
=================================

Widgets are connected to each other within the codec, platform and machine by
audio paths (called interconnections). Each interconnection must be defined in
@@ -208,6 +246,7 @@ The WM8731 output mixer has 3 inputs (sources)
Each input in this example has a kcontrol associated with it (defined in example
above) and is connected to the output mixer via its kcontrol name. We can now
connect the destination widget (wrt audio signal) with its source widgets.
::

	/* output mixer */
	{"Output Mixer", "Line Bypass Switch", "Line Input"},
@@ -216,20 +255,15 @@ connect the destination widget (wrt audio signal) with its source widgets.

So we have :-

	Destination Widget  <=== Path Name <=== Source Widget

Or:-

	Sink, Path, Source

Or :-

	"Output Mixer" is connected to the "DAC" via the "HiFi Playback Switch".
* Destination Widget  <=== Path Name <=== Source Widget, or
* Sink, Path, Source, or
* ``Output Mixer`` is connected to the ``DAC`` via the ``HiFi Playback Switch``.

When there is no path name connecting widgets (e.g. a direct connection) we
pass NULL for the path name.

Interconnections are created with a call to:-
::

  snd_soc_dapm_connect_input(codec, sink, path, source);

@@ -239,12 +273,13 @@ scan the codec and machine so that the internal DAPM state matches the
physical state of the machine.


3.1 Machine Widget Interconnections
-----------------------------------
Machine Widget Interconnections
-------------------------------
Machine widget interconnections are created in the same way as codec ones and
directly connect the codec pins to machine level widgets.

e.g. connects the speaker out codec pins to the internal speaker.
::

	/* ext speaker connected to codec pins LOUT2, ROUT2  */
	{"Ext Spk", NULL , "ROUT2"},
@@ -254,28 +289,29 @@ This allows the DAPM to power on and off pins that are connected (and in use)
and pins that are NC respectively.


4 Endpoint Widgets
===================
Endpoint Widgets
================
An endpoint is a start or end point (widget) of an audio signal within the
machine and includes the codec. e.g.

 o Headphone Jack
 o Internal Speaker
 o Internal Mic
 o Mic Jack
 o Codec Pins
* Headphone Jack
* Internal Speaker
* Internal Mic
* Mic Jack
* Codec Pins

Endpoints are added to the DAPM graph so that their usage can be determined in
order to save power. e.g. NC codecs pins will be switched OFF, unconnected
jacks can also be switched OFF.


5 DAPM Widget Events
====================
DAPM Widget Events
==================

Some widgets can register their interest with the DAPM core in PM events.
e.g. A Speaker with an amplifier registers a widget so the amplifier can be
powered only when the spk is in use.
::

  /* turn speaker amplifier on/off depending on use */
  static int corgi_amp_event(struct snd_soc_dapm_widget *w, int event)
@@ -291,10 +327,11 @@ static const struct snd_soc_dapm_widget wm8731_dapm_widgets =
Please see soc-dapm.h for all other widgets that support events.


5.1 Event types
---------------
Event types
-----------

The following event types are supported by event widgets.
::

  /* dapm event types */
  #define SND_SOC_DAPM_PRE_PMU	0x1 	/* before widget power up */
+1 −0
Original line number Diff line number Diff line
@@ -10,3 +10,4 @@ The documentation is spilt into the following sections:-
   overview
   codec
   dai
   dapm