The Linux Kernel
  • Linux kernel licensing rules
    • License identifier syntax
    • License identifiers
  • The Linux kernel user’s and administrator’s guide
    • Linux kernel release 4.x <http://kernel.org/>
    • The kernel’s command-line parameters
    • Linux allocated devices (4.x+ version)
    • Hardware vulnerabilities
    • Reporting bugs
    • Security bugs
    • Bug hunting
    • Bisecting a bug
    • Tainted kernels
    • Ramoops oops/panic logger
    • Dynamic debug
    • Explaining the dreaded “No init found.” boot hang message
    • Rules on how to access information in sysfs
    • Using the initial RAM disk (initrd)
    • Control Group v2
    • Linux Serial Console
    • Linux Braille Console
    • Parport
    • RAID arrays
    • Kernel module signing facility
    • Linux Magic System Request Key Hacks
    • Unicode support
    • Software cursor for VGA
    • Kernel Support for miscellaneous (your favourite) Binary Formats v1.1
    • Mono(tm) Binary Kernel Support for Linux
    • Java(tm) Binary Kernel Support for Linux v1.03
    • Reliability, Availability and Serviceability
    • A block layer cache (bcache)
    • Power Management
    • Thunderbolt
    • Linux Security Module Usage
    • Memory Management
  • The Linux kernel user-space API guide
    • No New Privileges Flag
    • Seccomp BPF (SECure COMPuting with filters)
    • unshare system call
    • Speculation Control
  • Working with the kernel development community
    • HOWTO do Linux kernel development
    • Contributor Covenant Code of Conduct
    • Linux Kernel Contributor Covenant Code of Conduct Interpretation
    • A guide to the Kernel Development Process
    • Submitting patches: the essential guide to getting your code into the kernel
    • Linux kernel coding style
    • Kernel Maintainer PGP guide
    • Email clients info for Linux
    • Linux Kernel Enforcement Statement
    • Kernel Driver Statement
    • Minimal requirements to compile the Kernel
    • Submitting Drivers For The Linux Kernel
    • The Linux Kernel Driver Interface
    • Linux kernel management style
    • Everything you ever wanted to know about Linux -stable releases
    • Linux Kernel patch submission checklist
    • Index of Documentation for People Interested in Writing and/or Understanding the Linux Kernel
    • Applying Patches To The Linux Kernel
    • Adding a New System Call
    • Linux magic numbers
    • Why the “volatile” type class should not be used
    • clang-format
  • Development tools for the kernel
    • Coccinelle
    • Sparse
    • kcov: code coverage for fuzzing
    • Using gcov with the Linux kernel
    • The Kernel Address Sanitizer (KASAN)
    • The Undefined Behavior Sanitizer - UBSAN
    • Kernel Memory Leak Detector
    • Debugging kernel and modules via gdb
    • Using kgdb, kdb and the kernel debugger internals
    • Linux Kernel Selftests
  • How to write kernel documentation
    • Introduction
    • Sphinx Install
    • Sphinx Build
    • Writing Documentation
    • Figures & Images
    • Writing kernel-doc comments
    • Including kernel-doc comments
    • Including uAPI header files
  • Kernel Hacking Guides
    • Unreliable Guide To Hacking The Linux Kernel
    • Unreliable Guide To Locking
  • Linux Tracing Technologies
    • Function Tracer Design
    • Notes on Analysing Behaviour Using Events and Tracepoints
    • ftrace - Function Tracer
    • Using ftrace to hook to functions
    • Kprobe-based Event Tracing
    • Uprobe-tracer: Uprobe-based Event Tracing
    • Using the Linux Kernel Tracepoints
    • Event Tracing
    • Subsystem Trace Points: kmem
    • Subsystem Trace Points: power
    • NMI Trace Events
    • MSR Trace Events
    • In-kernel memory-mapped I/O tracing
    • Event Histograms
    • Hardware Latency Detector
    • Intel(R) Trace Hub (TH)
    • System Trace Module
  • Kernel Maintainer Handbook
    • Configure Git
    • Creating Pull Requests
  • The Linux driver implementer’s API guide
    • Driver Basics
    • Device drivers infrastructure
    • Device Power Management
    • The Common Clk Framework
    • Bus-Independent Device Accesses
    • Device connections
    • Buffer Sharing and Synchronization
    • Device links
    • Message-based devices
    • Sound Devices
    • Frame Buffer Library
    • Voltage and current regulator API
    • Industrial I/O
    • Input Subsystem
    • Linux USB API
    • PCI Support Library
    • PCI Hotplug Support Library
    • Serial Peripheral Interface (SPI)
    • I2C and SMBus Subsystem
    • High Speed Synchronous Serial Interface (HSI)
    • Error Detection And Correction (EDAC) Devices
    • SCSI Interfaces Guide
    • libATA Developer’s Guide
    • target and iSCSI Interfaces Guide
    • MTD NAND Driver Programming Interface
    • Parallel Port Devices
    • 16x50 UART Driver
    • Pulse-Width Modulation (PWM)
    • W1: Dallas’ 1-wire bus
    • RapidIO Subsystem Guide
    • Writing s390 channel device drivers
    • VME Device Drivers
    • Linux 802.11 Driver Developer’s Guide
    • The Userspace I/O HOWTO
    • Linux Firmware API
    • PINCTRL (PIN CONTROL) subsystem
    • General Purpose Input/Output (GPIO)
    • Miscellaneous Devices
    • DMAEngine documentation
    • Linux kernel SLIMbus support
    • SoundWire Documentation
    • FPGA Subsystem
  • Core API Documentation
    • Core utilities
    • Interfaces for kernel debugging
  • Linux Media Subsystem Documentation
    • Linux Media Infrastructure userspace API
    • Media subsystem kernel internal API
    • Linux Digital TV driver-specific documentation
    • Video4Linux (V4L) driver-specific documentation
    • CEC driver-specific documentation
  • Linux Networking Documentation
    • netdev FAQ
    • AF_XDP
    • batman-adv
    • SocketCAN - Controller Area Network
    • The UCAN Protocol
    • DPAA2 Documentation
    • Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters
    • Linux* Base Driver for Intel(R) Ethernet Network Connection
    • Linux Networking and Network Devices APIs
    • Z8530 Programming Guide
    • MSG_ZEROCOPY
    • FAILOVER
    • NET_FAILOVER
    • IP-Aliasing
    • Ethernet Bridging
  • The Linux Input Documentation
    • Linux Input Subsystem userspace API
    • Linux Input Subsystem kernel API
    • Driver-specific documentation
  • Linux GPU Driver Developer’s Guide
    • Introduction
    • DRM Internals
    • DRM Memory Management
    • Kernel Mode Setting (KMS)
    • Mode Setting Helper Functions
    • Userland interfaces
    • Kernel clients
    • GPU Driver Documentation
    • VGA Switcheroo
    • VGA Arbiter
    • TODO list
  • Security Documentation
    • Credentials in Linux
    • IMA Template Management Mechanism
    • Kernel Keys
    • Linux Security Module Development
    • SCTP LSM Support
    • Security Hooks used for Association Establishment
    • SCTP SELinux Support
    • Security Hooks
    • Policy Statements
    • SCTP Peer Labeling
    • Kernel Self-Protection
    • Trusted Platform Module documentation
  • Linux Sound Subsystem Documentation
    • ALSA Kernel API Documentation
    • Designs and Implementations
    • ALSA SoC Layer
    • Advanced Linux Sound Architecture - Driver Configuration guide
    • HD-Audio
    • Card-Specific Information
  • Linux Kernel Crypto API
    • Kernel Crypto API Interface Specification
    • Kernel Crypto API Architecture
    • Developing Cipher Algorithms
    • User Space Interface
    • CRYPTO ENGINE
    • Programming Interface
    • Code Examples
  • Linux Filesystems API
    • The Linux VFS
    • The proc filesystem
    • Events based on file descriptors
    • The Filesystem for Exporting Kernel Objects
    • The debugfs filesystem
    • The Linux Journalling API
    • splice API
    • pipes API
    • Encryption API
  • Linux Memory Management Documentation
    • User guides for MM features
    • Kernel developers MM documentation
  • BPF Documentation
    • Frequently asked questions (FAQ)
  • SuperH Interfaces Guide
    • Memory Management
    • Machine Specific Interfaces
    • Busses
  • x86 architecture specifics
    • Microarchitectural Data Sampling (MDS) mitigation
  • ext4 Filesystem
    • 1. General Information
    • 2. Data Structures and Algorithms
  • Translations
    • Chinese translations
    • Traduzione italiana
    • Korean translations
    • Japanese translations
 
The Linux Kernel
  • Docs »
  • Linux Sound Subsystem Documentation »
  • ALSA SoC Layer »
  • Creating codec to codec dai link for ALSA dapm
  • View page source

Creating codec to codec dai link for ALSA dapmΒΆ

Mostly the flow of audio is always from CPU to codec so your system will look as below:

 ---------          ---------
|         |  dai   |         |
    CPU    ------->    codec
|         |        |         |
 ---------          ---------

In case your system looks as below:

                     ---------
                    |         |
                      codec-2
                    |         |
                    ---------
                         |
                       dai-2
                         |
 ----------          ---------
|          |  dai-1 |         |
    CPU     ------->  codec-1
|          |        |         |
 ----------          ---------
                         |
                       dai-3
                         |
                     ---------
                    |         |
                      codec-3
                    |         |
                     ---------

Suppose codec-2 is a bluetooth chip and codec-3 is connected to a speaker and you have a below scenario: codec-2 will receive the audio data and the user wants to play that audio through codec-3 without involving the CPU.This aforementioned case is the ideal case when codec to codec connection should be used.

Your dai_link should appear as below in your machine file:

/*
 * this pcm stream only supports 24 bit, 2 channel and
 * 48k sampling rate.
 */
static const struct snd_soc_pcm_stream dsp_codec_params = {
       .formats = SNDRV_PCM_FMTBIT_S24_LE,
       .rate_min = 48000,
       .rate_max = 48000,
       .channels_min = 2,
       .channels_max = 2,
};

{
   .name = "CPU-DSP",
   .stream_name = "CPU-DSP",
   .cpu_dai_name = "samsung-i2s.0",
   .codec_name = "codec-2,
   .codec_dai_name = "codec-2-dai_name",
   .platform_name = "samsung-i2s.0",
   .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
           | SND_SOC_DAIFMT_CBM_CFM,
   .ignore_suspend = 1,
   .params = &dsp_codec_params,
},
{
   .name = "DSP-CODEC",
   .stream_name = "DSP-CODEC",
   .cpu_dai_name = "wm0010-sdi2",
   .codec_name = "codec-3,
   .codec_dai_name = "codec-3-dai_name",
   .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
           | SND_SOC_DAIFMT_CBM_CFM,
   .ignore_suspend = 1,
   .params = &dsp_codec_params,
},

Above code snippet is motivated from sound/soc/samsung/speyside.c.

Note the “params” callback which lets the dapm know that this dai_link is a codec to codec connection.

In dapm core a route is created between cpu_dai playback widget and codec_dai capture widget for playback path and vice-versa is true for capture path. In order for this aforementioned route to get triggered, DAPM needs to find a valid endpoint which could be either a sink or source widget corresponding to playback and capture path respectively.

In order to trigger this dai_link widget, a thin codec driver for the speaker amp can be created as demonstrated in wm8727.c file, it sets appropriate constraints for the device even if it needs no control.

Make sure to name your corresponding cpu and codec playback and capture dai names ending with “Playback” and “Capture” respectively as dapm core will link and power those dais based on the name.

Note that in current device tree there is no way to mark a dai_link as codec to codec. However, it may change in future.

Next Previous

© Copyright The kernel development community.

Sphinx theme provided by Read the Docs