Dynamic Audio Power Management Lars-Peter Clausen Analog Devices - - PowerPoint PPT Presentation

dynamic audio power management
SMART_READER_LITE
LIVE PREVIEW

Dynamic Audio Power Management Lars-Peter Clausen Analog Devices - - PowerPoint PPT Presentation

Dynamic Audio Power Management Lars-Peter Clausen Analog Devices What is DAPM? Oh, it's just a graph walk, ... Why DAPM? Anatomy of a modern sound card Why DAPM? Modern sound cards consist of many independent discrete components


slide-1
SLIDE 1

Dynamic Audio Power Management

Lars-Peter Clausen – Analog Devices

slide-2
SLIDE 2

What is DAPM?

“Oh, it's just a graph walk, ...”

slide-3
SLIDE 3

Why DAPM?

Anatomy of a modern sound card

slide-4
SLIDE 4

Why DAPM?

  • Modern sound cards consist of many

independent discrete components

  • Each component has functional units that can

be powered independently

  • Audio routing matrices get complex (1000+

functional units)

slide-5
SLIDE 5

Why DAPM?

  • Battery powered devices require lowest power

mode

  • Managing dependencies by hand is tedious

and error prone

slide-6
SLIDE 6

What is DAPM?

  • Models data flow and power dependencies in

a directed graph

  • Nodes represent functional units (called

widgets)

  • Edges represent connections between

functional units (called routes or paths)

slide-7
SLIDE 7

What is DAPM?

Simple DAPM graph

slide-8
SLIDE 8

What are the benefits of DAPM?

  • Provides a common API for audio component

interoperability

  • Implements efficient power management for

individual components

slide-9
SLIDE 9

How does DAPM work?

  • CODEC or component driver provides

description of it's subsection of the graph

– Special widgets are used for inputs and outputs

  • Board driver describes connections between

components as well as the audio fabric

– Fabric includes speakers, microphones, headphone

jacks, etc.

– Information might be provided by devicetree or

ACPI

slide-10
SLIDE 10

How does DAPM work?

  • Each widget has a type

– Speaker, Microphone, Amplifier, DAC, ADC,

internal supply, external supply, headphone output, line-in input, line-out output, audio interface, audio interface link, mixer, mux, input pin, output pin

  • Type defines how the widget behaves in the

graph

slide-11
SLIDE 11

How does DAPM work?

  • Detects active data paths

– Dynamically manages the power state of

functional units on those paths

– Also manages their power dependencies

  • Two phases

– Determine target power state – Power sequencing

slide-12
SLIDE 12

Phase 1 Determining Power State

slide-13
SLIDE 13

Categories of Widgets

  • For finding out the power state DAPM

differentiates between three different categories of widgets

– Endpoint widgets – Pass-through widgets – Supply widgets

slide-14
SLIDE 14

Endpoint Widgets

  • Consume or produce a signal from/into the

pipeline

  • Speaker, Microphone, Tone-generator, PCM

device

slide-15
SLIDE 15

Endpoint Widgets

  • Endpoints can be active or inactive

– This information is not available for all endpoints

  • Endpoints can be marked as disconnected

– SOC_DAPM_PIN_SWITCH()

slide-16
SLIDE 16

Pass-through Widgets

  • Only powered up when on a active path

between two endpoints

  • Amplifier, Mixer, Audio-Interface
slide-17
SLIDE 17

Pass-through Widgets

  • Static routing

– All inputs contribute to all output signals

  • Dynamic routing

– Connections between inputs and output depend

  • n state
slide-18
SLIDE 18

Supply Widgets

  • Model resource dependencies rather than

data flow relationships

  • Powered up when any of the consumers is

powered up

  • Clock, regulator, shared enable bits
slide-19
SLIDE 19

Determining Power State

  • For each widget DAPM records the number of

paths to an active output and number of paths to an active input

  • If the number of both connected active inputs

and connected active outputs is one or more the widget is assumed powered up.

slide-20
SLIDE 20

Determining Power State

slide-21
SLIDE 21

Determining Power State

slide-22
SLIDE 22

Determining Power State

  • Source endpoint widgets are assumed

powered up if they are active and there is a path to a active sink endpoint widget

  • Sink endpoint widgets are assumed powered

up if they are active and there is a path to a active source endpoint widget

slide-23
SLIDE 23

Determining Power State

slide-24
SLIDE 24

Determining Power State

  • Supply widgets are assumed powered up if

there is a path to an powered-up widget

slide-25
SLIDE 25

Determining Power State

slide-26
SLIDE 26

Phase 2 Power Sequencing

slide-27
SLIDE 27

Power Sequencing

  • Once the new state has been determined

DAPM makes a diff to the current state and schedules the required changes

  • Changes are performed in a certain order

depending on widget type

– Minimizes audio click/pop noises

slide-28
SLIDE 28

Powering Sequene

1.Power-down all newly disabled widgets 2.Perform routing changes (if any) 3.Power-up all newly enabled widgets

slide-29
SLIDE 29

Sequencing Order

  • Each widget type has a sequence ID

– Widgets of similar type have the same sequence

number

  • Power-up sequence order is not the reverse

power-down sequence order

  • Each widget can have a sub-sequence ID

– For ordering within the same sequence

slide-30
SLIDE 30

Sequencing Order

  • Power updates are order by

– Widget type sequence ID – Widget sub-sequence ID – IO register access – DAPM context (device)

slide-31
SLIDE 31

Applying Power Changes

  • DAPM has the concept of register mapped IO

built-in

– Widget specifies register offset, a mask and a

value for the on state and off state

  • Per widget callbacks are also available

– For external supplies – For widgets internal widgets that require a more

complex on/off register write sequence

slide-32
SLIDE 32

Register Update Coalescing

  • Multiple updates to the same register in the

same sub-sequence are coalesced into a single update

  • Reduces the number of IO operations

– Important for slow buses like I2C

slide-33
SLIDE 33

Dynamic Graph Changes

slide-34
SLIDE 34

Dynamic Graph Changes

  • DAPM has support for dynamic graph

changes

  • After each change the power state of the

graph is re-evaluated

slide-35
SLIDE 35

Dynamic Graph Changes

  • Enable/disable (add/remove) a edge in the

graph

– Dynamic routing changes

  • Enable/disable a endpoint node in the graph
  • Starting/Stopping a playback or capture stream
  • Hot-plug/-unplug of components

– Poorly supported at the moment

slide-36
SLIDE 36

Dynamic Routing Changes

  • DAPM has built-in support for common types
  • f dynamic routing changes

– Mixers, Mux, Demux

  • Driver can implement their own dynamic

routing when necessary

– Typically used when different operating modes

require different routing

slide-37
SLIDE 37

Mixer

  • Has multiple input paths that

can be independently enabled/disabled

  • Output is the sum of all inputs
  • Exported to userspace using

multiple boolean ALSA controls

slide-38
SLIDE 38

Mux/Demux

  • Mux: Routes one of multiple inputs

to a single output

  • Demux: Routes one input to exactly
  • ne of multiple outputs
  • Exported to userspace using a

single enum control

slide-39
SLIDE 39

Shared Mixers/Muxes

  • Allow to model independent data

flow paths with shared control path

– E.g. left and right path of a stereo

signal

  • In the driver pass the same

struct snd_kcontrol_new to all controlled mixers/muxes

slide-40
SLIDE 40

Auto-mute Mixers

  • Automatically mutes/disables the input to a

mixer source is powered down

  • Useful when the source outputs a invalid or

undefined signal when powered down

slide-41
SLIDE 41

Auto-mute Mixers

  • When the source stops the switch is

automatically opened

  • Switch state is still reported as closed to

userspace applications

slide-42
SLIDE 42

Auto-mute Mixers

  • When the source resumes the switch is set

back to the userspace provided setting

slide-43
SLIDE 43

Auto-disable Mux

  • When the selected source is powered down

the mux switches to a special off state

  • Useful when the source output is undefined or

invalid when powered off

  • Useful when the mux has no dedicated power-

down control

slide-44
SLIDE 44

Future

slide-45
SLIDE 45

Future - DXPM

  • Using DAPM not only for audio

– E.g. video processing pipelines

  • Allows to model complex power relationships
  • Doesn't suffer problems of classical power

runtime power management

– E.g. DAPM can handle cyclic dependencies – Finer grained resolution

  • DAPM core algorithm is not audio specific
slide-46
SLIDE 46

Q/A

slide-47
SLIDE 47

Thanks

slide-48
SLIDE 48

Bonus Slides

slide-49
SLIDE 49

Micbias Widget

  • Conceptually broken
  • Don't use them
  • Use supply widgets

instead

slide-50
SLIDE 50

Jack Detection

  • DAPM has jack detection integration
  • Automatically disables endpoint when nothing

is connected

slide-51
SLIDE 51

Suspend/Resume

  • During system suspend all endpoints are

marked as disconnected

– Unless the are marked to ignore suspend

slide-52
SLIDE 52

Runtime Suspend/Resume

  • DAPM integrates nicely with runtime PM
  • Runtime PM is enabled when at least one

widget is enabled

  • Runtime PM is disabled when all widgets are

disabled

  • Don't access the same hardware state from

DAPM and runtime PM

slide-53
SLIDE 53

Pre/Post widgets

  • Pre/Post widgets are special virtual widgets
  • Callbacks are executed each time the DAPM

sequencing runs

  • Don't need to be connected anywhere