Blame include/topology.h

Packit Service db8eaa
/*
Packit Service db8eaa
 *
Packit Service db8eaa
 *  This library is free software; you can redistribute it and/or modify
Packit Service db8eaa
 *  it under the terms of the GNU Lesser General Public License as
Packit Service db8eaa
 *  published by the Free Software Foundation; either version 2.1 of
Packit Service db8eaa
 *  the License, or (at your option) any later version.
Packit Service db8eaa
 *
Packit Service db8eaa
 *  This program is distributed in the hope that it will be useful,
Packit Service db8eaa
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service db8eaa
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service db8eaa
 *  GNU Lesser General Public License for more details.
Packit Service db8eaa
 *
Packit Service db8eaa
 *  You should have received a copy of the GNU Lesser General Public
Packit Service db8eaa
 *  License along with this library; if not, write to the Free Software
Packit Service db8eaa
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit Service db8eaa
 *
Packit Service db8eaa
 *  Copyright (C) 2015 Intel Corporation
Packit Service db8eaa
 *
Packit Service db8eaa
 */
Packit Service db8eaa
Packit Service db8eaa
#ifndef __ALSA_TOPOLOGY_H
Packit Service db8eaa
#define __ALSA_TOPOLOGY_H
Packit Service db8eaa
Packit Service db8eaa
#include <stdint.h>
Packit Service db8eaa
Packit Service db8eaa
#ifdef __cplusplus
Packit Service db8eaa
extern "C" {
Packit Service db8eaa
#endif
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \defgroup topology Topology Interface
Packit Service db8eaa
 * \{
Packit Service db8eaa
 */
Packit Service db8eaa
Packit Service db8eaa
/*! \page topology ALSA Topology Interface
Packit Service db8eaa
 *
Packit Service db8eaa
 * The topology interface allows developers to define DSP topologies in a text
Packit Service db8eaa
 * file format and to convert the text topology to a binary topology
Packit Service db8eaa
 * representation that can be understood by the kernel. The topology core
Packit Service db8eaa
 * currently recognises the following object types :-
Packit Service db8eaa
 *
Packit Service db8eaa
 *  * Controls (mixer, enumerated and byte) including TLV data.
Packit Service db8eaa
 *  * PCMs (Front End DAI & DAI link)
Packit Service db8eaa
 *  * DAPM widgets
Packit Service db8eaa
 *  * DAPM graph elements.
Packit Service db8eaa
 *  * Physical DAI & DAI links
Packit Service db8eaa
 *  * Private data for each object type.
Packit Service db8eaa
 *  * Manifest (containing count of each object type)
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

Topology File Format

Packit Service db8eaa
 *
Packit Service db8eaa
 * The topology text format uses the standard ALSA configuration file format to
Packit Service db8eaa
 * describe each topology object type. This allows topology objects to include
Packit Service db8eaa
 * other topology objects as part of their definition. i.e. a TLV data object
Packit Service db8eaa
 * can be shared amongst many control objects that use the same TLV data.
Packit Service db8eaa
 *
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

Controls

Packit Service db8eaa
 * Topology audio controls can belong to three different types :-
Packit Service db8eaa
 *   * Mixer control
Packit Service db8eaa
 *   * Enumerated control
Packit Service db8eaa
 *   * Byte control
Packit Service db8eaa
 *
Packit Service db8eaa
 * Each control type can contain TLV data, private data, operations and also
Packit Service db8eaa
 * belong to widget objects.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Control Operations
Packit Service db8eaa
 * Driver Kcontrol callback info(), get() and put() operations are mapped with
Packit Service db8eaa
 * the CTL ops section in topology configuration files. The ctl ops section can
Packit Service db8eaa
 * assign operations using the standard names (listed below) for the standard
Packit Service db8eaa
 * kcontrol types or use ID numbers (>256) to map to bespoke driver controls.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 *	ops."ctl" {
Packit Service db8eaa
 *		info "volsw"
Packit Service db8eaa
 *		get "257"
Packit Service db8eaa
 *		put "257"
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * This mapping shows info() using the standard "volsw" info callback whilst
Packit Service db8eaa
 * the get() and put() are mapped to bespoke driver callbacks. 
Packit Service db8eaa
 *
Packit Service db8eaa
 * The Standard operations names for control get(), put() and info calls
Packit Service db8eaa
 * are :-
Packit Service db8eaa
 *  * volsw
Packit Service db8eaa
 *  * volsw_sx
Packit Service db8eaa
 *  * volsw_xr_sx
Packit Service db8eaa
 *  * enum
Packit Service db8eaa
 *  * bytes
Packit Service db8eaa
 *  * enum_value
Packit Service db8eaa
 *  * range
Packit Service db8eaa
 *  * strobe
Packit Service db8eaa
 *
Packit Service db8eaa
* 
Control Access
Packit Service db8eaa
 * Controls access can be specified using the "access" section. If no "access"
Packit Service db8eaa
 * section is defined then default RW access flags are set for normal and TLV
Packit Service db8eaa
 * controls.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 *	access [
Packit Service db8eaa
 *		read
Packit Service db8eaa
 *		write
Packit Service db8eaa
 *		tlv_command
Packit Service db8eaa
 *	]
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * The standard access flags are as follows :-
Packit Service db8eaa
 *  * read
Packit Service db8eaa
 *  * write
Packit Service db8eaa
 *  * read_write
Packit Service db8eaa
 *  * volatile
Packit Service db8eaa
 *  * timestamp
Packit Service db8eaa
 *  * tlv_read
Packit Service db8eaa
 *  * tlv_write
Packit Service db8eaa
 *  * tlv_read_write
Packit Service db8eaa
 *  * tlv_command
Packit Service db8eaa
 *  * inactive
Packit Service db8eaa
 *  * lock
Packit Service db8eaa
 *  * owner
Packit Service db8eaa
 *  * tlv_callback
Packit Service db8eaa
 *  * user
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Control TLV Data
Packit Service db8eaa
 * Controls can also use TLV data to represent dB information. This can be done
Packit Service db8eaa
 * by defining a TLV section and using the TLV section within the control.
Packit Service db8eaa
 * The TLV data for DBScale types are defined as follows :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 *	scale {
Packit Service db8eaa
 *		min "-9000"
Packit Service db8eaa
 *		step "300"
Packit Service db8eaa
 *		mute "1"
Packit Service db8eaa
 *	}
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * Where the meanings and values for min, step and mute are exactly the same
Packit Service db8eaa
 * as defined in driver code.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Control Channel Mapping
Packit Service db8eaa
 * Controls can also specify which channels they are mapped with. This is useful
Packit Service db8eaa
 * for userspace as it allows applications to determine the correct control
Packit Service db8eaa
 * channel for Left and Right etc. Channel maps are defined as follows :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 *	channel."name" {
Packit Service db8eaa
 *		reg "0"
Packit Service db8eaa
 *		shift "0"
Packit Service db8eaa
 *	}
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * The channel map reg is the register offset for the control, shift is the
Packit Service db8eaa
 * bit shift within the register for the channel and the section name is the
Packit Service db8eaa
 * channel name and can be one of the following :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 *  * mono		# mono stream
Packit Service db8eaa
 *  * fl 		# front left
Packit Service db8eaa
 *  * fr		# front right
Packit Service db8eaa
 *  * rl		# rear left
Packit Service db8eaa
 *  * rr		# rear right
Packit Service db8eaa
 *  * fc		# front center
Packit Service db8eaa
 *  * lfe		# LFE
Packit Service db8eaa
 *  * sl		# side left
Packit Service db8eaa
 *  * sr		# side right
Packit Service db8eaa
 *  * rc		# rear center
Packit Service db8eaa
 *  * flc		# front left center
Packit Service db8eaa
 *  * frc		# front right center
Packit Service db8eaa
 *  * rlc		# rear left center
Packit Service db8eaa
 *  * rrc		# rear right center
Packit Service db8eaa
 *  * flw		# front left wide
Packit Service db8eaa
 *  * frw		# front right wide
Packit Service db8eaa
 *  * flh		# front left high
Packit Service db8eaa
 *  * fch		# front center high
Packit Service db8eaa
 *  * frh		# front right high
Packit Service db8eaa
 *  * tc		# top center
Packit Service db8eaa
 *  * tfl		# top front left
Packit Service db8eaa
 *  * tfr		# top front right
Packit Service db8eaa
 *  * tfc		# top front center
Packit Service db8eaa
 *  * trl		# top rear left
Packit Service db8eaa
 *  * trr		# top rear right
Packit Service db8eaa
 *  * trc		# top rear center
Packit Service db8eaa
 *  * tflc		# top front left center
Packit Service db8eaa
 *  * tfrc		# top front right center
Packit Service db8eaa
 *  * tsl		# top side left
Packit Service db8eaa
 *  * tsr		# top side right
Packit Service db8eaa
 *  * llfe		# left LFE
Packit Service db8eaa
 *  * rlfe		# right LFE
Packit Service db8eaa
 *  * bc		# bottom center
Packit Service db8eaa
 *  * blc		# bottom left center
Packit Service db8eaa
 *  * brc		# bottom right center
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 *  
Control Private Data
Packit Service db8eaa
 * Controls can also have private data. This can be done by defining a private
Packit Service db8eaa
 * data section and including the section within the control. The private data
Packit Service db8eaa
 * section is defined as follows :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionData."pdata for EQU1" {
Packit Service db8eaa
 *	file "/path/to/file"
Packit Service db8eaa
 *	bytes "0x12,0x34,0x56,0x78"
Packit Service db8eaa
 *	shorts "0x1122,0x3344,0x5566,0x7788"
Packit Service db8eaa
 *	words "0xaabbccdd,0x11223344,0x66aa77bb,0xefef1234"
Packit Service db8eaa
 *	tuples "section id of the vendor tuples"
Packit Service db8eaa
 * };
Packit Service db8eaa
 * 
Packit Service db8eaa
 * The file, bytes, shorts, words and tuples keywords are all mutually
Packit Service db8eaa
 * exclusive as the private data should only be taken from one source.
Packit Service db8eaa
 * The private data can either be read from a separate file or defined in
Packit Service db8eaa
 * the topology file using the bytes, shorts, words or tuples keywords.
Packit Service db8eaa
 * The keyword tuples is to define vendor specific tuples. Please refer to
Packit Service db8eaa
 * section Vendor Tokens and Vendor tuples.
Packit Service db8eaa
 *
Packit Service db8eaa
 * It's easy to use a vendor tuples object to define a C structure instance.
Packit Service db8eaa
 * And a data section can include multiple vendor tuples objects:
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionData."data element name" {
Packit Service db8eaa
 *	index "1"	#Index number
Packit Service db8eaa
 *	tuples [
Packit Service db8eaa
 *		"id of the 1st vendor tuples section"
Packit Service db8eaa
 *		"id of the 2nd vendor tuples section"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	]
Packit Service db8eaa
 * };
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
How to define an element with private data
Packit Service db8eaa
 * An element can refer to a single data section or multiple data
Packit Service db8eaa
 * sections.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
To refer to a single data section:
Packit Service db8eaa
 * 
Packit Service db8eaa
 * Sectionxxx."element name" {
Packit Service db8eaa
 *    ...
Packit Service db8eaa
 *	data "name of data section"		# optional private data
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
To refer to multiple data sections:
Packit Service db8eaa
 * 
Packit Service db8eaa
 * Sectionxxx."element name" {
Packit Service db8eaa
 *	...
Packit Service db8eaa
 *	data [						# optional private data
Packit Service db8eaa
 *		"name of 1st data section"
Packit Service db8eaa
 *		"name of 2nd data section"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	]
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 * And data of these sections will be merged in the same order as they are
Packit Service db8eaa
 * in the list, as the element's private data for kernel.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 *  
Vendor Tokens
Packit Service db8eaa
 * A vendor token list is defined as a new section. Each token element is
Packit Service db8eaa
 * a pair of string ID and integer value. And both the ID and value are
Packit Service db8eaa
 * vendor-specific.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionVendorTokens."id of the vendor tokens" {
Packit Service db8eaa
 *	comment "optional comments"
Packit Service db8eaa
 *	VENDOR_TOKEN_ID1 "1"
Packit Service db8eaa
 *	VENDOR_TOKEN_ID2 "2"
Packit Service db8eaa
 *	VENDOR_TOKEN_ID3 "3"
Packit Service db8eaa
 *	...
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 *  
Vendor Tuples
Packit Service db8eaa
 * Vendor tuples are defined as a new section. It contains a reference to
Packit Service db8eaa
 * a vendor token list and several tuple arrays.
Packit Service db8eaa
 * All arrays share a vendor token list, defined by the tokens keyword.
Packit Service db8eaa
 * Each tuple array is for a specific type, defined by the string following
Packit Service db8eaa
 * the tuples keyword. Supported types are: string, uuid, bool, byte,
Packit Service db8eaa
 * short and word.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionVendorTuples."id of the vendor tuples" {
Packit Service db8eaa
 *	tokens "id of the vendor tokens"
Packit Service db8eaa
 *
Packit Service db8eaa
 *	tuples."string" {
Packit Service db8eaa
 *		VENDOR_TOKEN_ID1 "character string"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	tuples."uuid" {			# 16 characters separated by commas
Packit Service db8eaa
 *		VENDOR_TOKEN_ID2 "0x01,0x02,...,0x0f"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	tuples."bool" {
Packit Service db8eaa
 *		VENDOR_TOKEN_ID3 "true/false"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	tuples."byte" {
Packit Service db8eaa
 *		VENDOR_TOKEN_ID4 "0x11"
Packit Service db8eaa
 *		VENDOR_TOKEN_ID5 "0x22"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	tuples."short" {
Packit Service db8eaa
 *		VENDOR_TOKEN_ID6 "0x1122"
Packit Service db8eaa
 *		VENDOR_TOKEN_ID7 "0x3344"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	tuples."word" {
Packit Service db8eaa
 *		VENDOR_TOKEN_ID8 "0x11223344"
Packit Service db8eaa
 *		VENDOR_TOKEN_ID9 "0x55667788"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	}
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 * To define multiple vendor tuples of same type, please append some
Packit Service db8eaa
 * characters after the type string ("string", "uuid", "bool", "byte", "short"
Packit Service db8eaa
 * or "word"), to avoid ID duplication in the SectionVendorTuples.
Packit Service db8eaa
 * The parser will check the first few characters in ID to get the tuple type.
Packit Service db8eaa
 * Here is an example:
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionVendorTuples."id of the vendor tuples" {
Packit Service db8eaa
 *    ...
Packit Service db8eaa
 *	tuples."word.module0" {
Packit Service db8eaa
 *		VENDOR_TOKEN_PARAM_ID1 "0x00112233"
Packit Service db8eaa
 *		VENDOR_TOKEN_PARAM_ID2 "0x44556677"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	tuples."word.module2" {
Packit Service db8eaa
 *		VENDOR_TOKEN_PARAM_ID1 "0x11223344"
Packit Service db8eaa
 *		VENDOR_TOKEN_PARAM_ID2 "0x55667788"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *	...
Packit Service db8eaa
 * }
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Mixer Controls
Packit Service db8eaa
 * A mixer control is defined as a new section that can include channel mapping,
Packit Service db8eaa
 * TLV data, callback operations and private data. The mixer section also
Packit Service db8eaa
 * includes a few other config options that are shown here :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionControlMixer."mixer name" {
Packit Service db8eaa
 *	comment "optional comments"
Packit Service db8eaa
 *
Packit Service db8eaa
 *	index "1"			# Index number
Packit Service db8eaa
 *
Packit Service db8eaa
 *	channel."name" {		# Channel maps
Packit Service db8eaa
 *	   ....
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	ops."ctl" {			# Ops callback functions
Packit Service db8eaa
 *	   ....
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	max "32"			# Max control value
Packit Service db8eaa
 *	invert "0"			# Whether control values are inverted
Packit Service db8eaa
 *
Packit Service db8eaa
 *	tlv "tld_data"			# optional TLV data
Packit Service db8eaa
 *
Packit Service db8eaa
 *	data "pdata for mixer1"		# optional private data
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * The section name is used to define the mixer name. The index number can be
Packit Service db8eaa
 * used to identify topology objects groups(index "0" is common, fit for all
Packit Service db8eaa
 * user cases).This allows driver operations on objects with index number N and
Packit Service db8eaa
 * can be used to add/remove pipelines of objects whilst other objects are
Packit Service db8eaa
 * unaffected.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Byte Controls
Packit Service db8eaa
 * A byte control is defined as a new section that can include channel mapping,
Packit Service db8eaa
 * TLV data, callback operations and private data. The bytes section also
Packit Service db8eaa
 * includes a few other config options that are shown here :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionControlBytes."name" {
Packit Service db8eaa
 *	comment "optional comments"
Packit Service db8eaa
 *
Packit Service db8eaa
 *	index "1"			# Index number
Packit Service db8eaa
 *
Packit Service db8eaa
 *	channel."name" {		# Channel maps
Packit Service db8eaa
 *	   ....
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	ops."ctl" {			# Ops callback functions
Packit Service db8eaa
 *	   ....
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	base "0"			# Register base
Packit Service db8eaa
 *	num_regs "16"			# Number of registers
Packit Service db8eaa
 *	mask "0xff"			# Mask
Packit Service db8eaa
 *	max "255"			# Maximum value
Packit Service db8eaa
 *
Packit Service db8eaa
 *	tlv "tld_data"			# optional TLV data
Packit Service db8eaa
 *
Packit Service db8eaa
 *	data "pdata for mixer1"		# optional private data
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Enumerated Controls
Packit Service db8eaa
 * A enumerated control is defined as a new section (like mixer and byte) that
Packit Service db8eaa
 * can include channel mapping, callback operations, private data and
Packit Service db8eaa
 * text strings to represent the enumerated control options.
Packit Service db8eaa
 *
Packit Service db8eaa
 * The text strings for the enumerated controls are defined in a separate
Packit Service db8eaa
 * section as follows :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionText."name" {
Packit Service db8eaa
 *
Packit Service db8eaa
 *		Values [
Packit Service db8eaa
 *			"value1"
Packit Service db8eaa
 *			"value2"
Packit Service db8eaa
			"value3"
Packit Service db8eaa
 *		]
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * All the enumerated text values are listed in the values list.
Packit Service db8eaa
 * The enumerated control is similar to the other controls and defined as
Packit Service db8eaa
 * follows :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionControlMixer."name" {
Packit Service db8eaa
 *	comment "optional comments"
Packit Service db8eaa
 *
Packit Service db8eaa
 *	index "1"			# Index number
Packit Service db8eaa
 *
Packit Service db8eaa
 *	texts "EQU1"			# Enumerated text items
Packit Service db8eaa
 *
Packit Service db8eaa
 *	channel."name" {		# Channel maps
Packit Service db8eaa
 *	   ....
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	ops."ctl" {			# Ops callback functions
Packit Service db8eaa
 *	   ....
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	data "pdata for mixer1"		# optional private data
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

DAPM Graph

Packit Service db8eaa
 * DAPM graphs can easily be defined using the topology file. The format is
Packit Service db8eaa
 * very similar to the DAPM graph kernel format. :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionGraph."dsp" {
Packit Service db8eaa
 *	index "1"			# Index number
Packit Service db8eaa
 *
Packit Service db8eaa
 *	lines [
Packit Service db8eaa
 *		"sink1, control, source1"
Packit Service db8eaa
 *		"sink2, , source2"
Packit Service db8eaa
 *	]
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * The lines in the graph are defined as a variable size list of sinks,
Packit Service db8eaa
 * controls and sources. The control name is optional as some graph lines have
Packit Service db8eaa
 * no associated controls. The section name can be used to differentiate the
Packit Service db8eaa
 * graph with other graphs, it's not used by the kernel atm.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

DAPM Widgets

Packit Service db8eaa
 * DAPM widgets are similar to controls in that they can include many other
Packit Service db8eaa
 * objects. Widgets can contain private data, mixer controls and enum controls.
Packit Service db8eaa
 *
Packit Service db8eaa
 * The following widget types are supported and match the driver types :-
Packit Service db8eaa
 *
Packit Service db8eaa
 *  * input
Packit Service db8eaa
 *  * output
Packit Service db8eaa
 *  * mux
Packit Service db8eaa
 *  * mixer
Packit Service db8eaa
 *  * pga
Packit Service db8eaa
 *  * out_drv
Packit Service db8eaa
 *  * adc
Packit Service db8eaa
 *  * dac
Packit Service db8eaa
 *  * switch
Packit Service db8eaa
 *  * pre
Packit Service db8eaa
 *  * post
Packit Service db8eaa
 *  * aif_in
Packit Service db8eaa
 *  * aif_out
Packit Service db8eaa
 *  * dai_in
Packit Service db8eaa
 *  * dai_out
Packit Service db8eaa
 *  * dai_link
Packit Service db8eaa
 *
Packit Service db8eaa
 * Widgets are defined as follows :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionWidget."name" {
Packit Service db8eaa
 *
Packit Service db8eaa
 *	index "1"			# Index number
Packit Service db8eaa
 *
Packit Service db8eaa
 *	type "aif_in"			# Widget type - detailed above
Packit Service db8eaa
 *	stream_name "name"		# Stream name
Packit Service db8eaa
 *
Packit Service db8eaa
 *	no_pm "true"			# No PM control bit.
Packit Service db8eaa
 *	reg "20"			# PM bit register offset
Packit Service db8eaa
 *	shift "0"			# PM bit register shift
Packit Service db8eaa
 *	invert "1			# PM bit is inverted
Packit Service db8eaa
 *	subseq "8"			# subsequence number
Packit Service db8eaa
 *
Packit Service db8eaa
 *	event_type "1"			# DAPM widget event type
Packit Service db8eaa
 *	event_flags "1"			# DAPM widget event flags
Packit Service db8eaa
 *
Packit Service db8eaa
 *	mixer "name"			# Optional Mixer Control
Packit Service db8eaa
 *	enum "name"			# Optional Enum Control
Packit Service db8eaa
 *
Packit Service db8eaa
 *	data "name"			# optional private data
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * The section name is the widget name. The mixer and enum fields are mutually
Packit Service db8eaa
 * exclusive and used to include controls into the widget. The index and data
Packit Service db8eaa
 * fields are the same for widgets as they are for controls whilst the other
Packit Service db8eaa
 * fields map on very closely to the driver widget fields.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Widget Private Data
Packit Service db8eaa
 * Widget can have private data. For the format of the private data, please
Packit Service db8eaa
 * refer to section Control Private Data.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

PCM Capabilities

Packit Service db8eaa
 * Topology can also define the PCM capabilities of front end or physical DAIs.
Packit Service db8eaa
 * Capabilities can be defined with the following section :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionPCMCapabilities."name" {
Packit Service db8eaa
 *
Packit Service db8eaa
 *	formats "S24_LE,S16_LE"		# Supported formats
Packit Service db8eaa
 *	rates "48000"			# Supported rates
Packit Service db8eaa
 *	rate_min "48000"		# Max supported sample rate
Packit Service db8eaa
 *	rate_max "48000"		# Min supported sample rate
Packit Service db8eaa
 *	channels_min "2"		# Min number of channels
Packit Service db8eaa
 *	channels_max "2"		# max number of channels
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 * The supported formats use the same naming convention as the driver macros.
Packit Service db8eaa
 * The PCM capabilities name can be referred to and included by PCM and
Packit Service db8eaa
 * physical DAI sections.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

PCM Configurations

Packit Service db8eaa
 * PCM runtime configurations can be defined for playback and capture stream
Packit Service db8eaa
 * directions with the following section  :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionPCMConfig."name" {
Packit Service db8eaa
 *
Packit Service db8eaa
 *	config."playback" {		# playback config
Packit Service db8eaa
 *		format "S16_LE"		# playback format
Packit Service db8eaa
 *		rate "48000"		# playback sample rate
Packit Service db8eaa
 *		channels "2"		# playback channels
Packit Service db8eaa
 *		tdm_slot "0xf"		# playback TDM slot
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	config."capture" {		# capture config
Packit Service db8eaa
 *		format "S16_LE"		# capture format
Packit Service db8eaa
 *		rate "48000"		# capture sample rate
Packit Service db8eaa
 *		channels "2"		# capture channels
Packit Service db8eaa
 *		tdm_slot "0xf"		# capture TDM slot
Packit Service db8eaa
 *	}
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * The supported formats use the same naming convention as the driver macros.
Packit Service db8eaa
 * The PCM configuration name can be referred to and included by PCM and
Packit Service db8eaa
 * physical link sections.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

PCM (Front-end DAI & DAI link)

Packit Service db8eaa
 * PCM sections define the supported capabilities and configurations for
Packit Service db8eaa
 * supported playback and capture streams, names and flags for front end
Packit Service db8eaa
 * DAI & DAI links. Topology kernel driver will use a PCM object to create
Packit Service db8eaa
 * a pair of FE DAI & DAI links.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionPCM."name" {
Packit Service db8eaa
 *
Packit Service db8eaa
 *	index "1"			# Index number
Packit Service db8eaa
 *
Packit Service db8eaa
 *	id "0"				# used for binding to the PCM
Packit Service db8eaa
 *
Packit Service db8eaa
 *	dai."name of front-end DAI" {
Packit Service db8eaa
 *		id "0"		# used for binding to the front-end DAI
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	pcm."playback" {
Packit Service db8eaa
 *		capabilities "capabilities1"	# capabilities for playback
Packit Service db8eaa
 *
Packit Service db8eaa
 *		configs [		# supported configs for playback
Packit Service db8eaa
 *			"config1"
Packit Service db8eaa
 *			"config2"
Packit Service db8eaa
 *		]
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	pcm."capture" {
Packit Service db8eaa
 *		capabilities "capabilities2"	# capabilities for capture
Packit Service db8eaa
 *
Packit Service db8eaa
 *		configs [		# supported configs for capture
Packit Service db8eaa
 *			"config1"
Packit Service db8eaa
 *			"config2"
Packit Service db8eaa
 *			"config3"
Packit Service db8eaa
 *		]
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	# Optional boolean flags
Packit Service db8eaa
 *	symmetric_rates			"true"
Packit Service db8eaa
 *	symmetric_channels		"true"
Packit Service db8eaa
 *	symmetric_sample_bits		"false"
Packit Service db8eaa
 *
Packit Service db8eaa
 *	data "name"			# optional private data
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

Physical DAI Link Configurations

Packit Service db8eaa
 * The runtime configurations of a physical DAI link can be defined by
Packit Service db8eaa
 * SectionLink. 
Backend DAI links belong to physical links, and can
Packit Service db8eaa
 * be configured by either SectionLink or SectionBE, with same syntax.
Packit Service db8eaa
 * But SectionBE is deprecated atm since the internal processing is
Packit Service db8eaa
 * actually same.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionLink."name" {
Packit Service db8eaa
 *
Packit Service db8eaa
 *	index "1"			# Index number
Packit Service db8eaa
 *
Packit Service db8eaa
 *	id "0"				# used for binding to the link
Packit Service db8eaa
 *
Packit Service db8eaa
 *	stream_name "name"		# used for binding to the link
Packit Service db8eaa
 *
Packit Service db8eaa
 *	hw_configs [	# runtime supported HW configurations, optional
Packit Service db8eaa
 *		"config1"
Packit Service db8eaa
 *		"config2"
Packit Service db8eaa
 *		...
Packit Service db8eaa
 *	]
Packit Service db8eaa
 *
Packit Service db8eaa
 *	default_hw_conf_id "1"		#default HW config ID for init
Packit Service db8eaa
 *
Packit Service db8eaa
 *	# Optional boolean flags
Packit Service db8eaa
 *	symmetric_rates			"true"
Packit Service db8eaa
 *	symmetric_channels		"false"
Packit Service db8eaa
 *	symmetric_sample_bits		"true"
Packit Service db8eaa
 *
Packit Service db8eaa
 *	data "name"			# optional private data
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * A physical link can refer to multiple runtime supported hardware
Packit Service db8eaa
 * configurations, which is defined by SectionHWConfig.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionHWConfig."name" {
Packit Service db8eaa
 *
Packit Service db8eaa
 *	id "1"				# used for binding to the config
Packit Service db8eaa
 *	format "I2S"			# physical audio format.
Packit Service 45dc4a
 *	bclk   "master"			# Platform is master of bit clock
Packit Service 45dc4a
 *	fsync  "slave"			# Platform is slave of fsync
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

Physical DAI

Packit Service db8eaa
 * A physical DAI (e.g. backend DAI for DPCM) is defined as a new section
Packit Service db8eaa
 * that can include a unique ID, playback and capture stream capabilities,
Packit Service db8eaa
 * optional flags, and private data. 
Packit Service db8eaa
 * Its PCM stream capablities are same as those for PCM objects,
Packit Service db8eaa
 * please refer to section 'PCM Capabilities'.
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionDAI."name" {
Packit Service db8eaa
 *
Packit Service db8eaa
 *	index "1"			# Index number
Packit Service db8eaa
 *
Packit Service db8eaa
 *	id "0"				# used for binding to the Backend DAI
Packit Service db8eaa
 *
Packit Service db8eaa
 *	pcm."playback" {
Packit Service db8eaa
 *		capabilities "capabilities1"	# capabilities for playback
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	pcm."capture" {
Packit Service db8eaa
 *		capabilities "capabilities2"	# capabilities for capture
Packit Service db8eaa
 *	}
Packit Service db8eaa
 *
Packit Service db8eaa
 *	symmetric_rates "true"			# optional flags
Packit Service db8eaa
 *	symmetric_channels "true"
Packit Service db8eaa
 *	symmetric_sample_bits "false"
Packit Service db8eaa
 *
Packit Service db8eaa
 *	data "name"			# optional private data
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

Manifest Private Data

Packit Service db8eaa
 * Manfiest may have private data. Users need to define a manifest section
Packit Service db8eaa
 * and add the references to 1 or multiple data sections. Please refer to
Packit Service db8eaa
 * section 'How to define an element with private data'. 
Packit Service db8eaa
 * And the text conf file can have at most 1 manifest section. 

Packit Service db8eaa
 *
Packit Service db8eaa
 * Manifest section is defined as follows :-
Packit Service db8eaa
 *
Packit Service db8eaa
 * 
Packit Service db8eaa
 * SectionManifest"name" {
Packit Service db8eaa
 *
Packit Service db8eaa
 *	data "name"			# optional private data
Packit Service db8eaa
 * }
Packit Service db8eaa
 * 
Packit Service db8eaa
 *
Packit Service db8eaa
 * 

Include other files

Packit Service db8eaa
 * Users may include other files in a text conf file via alsaconf syntax
Packit Service db8eaa
 * <path/to/configuration-file>. This allows users to define common info
Packit Service db8eaa
 * in separate files (e.g. vendor tokens, tuples) and share them for
Packit Service db8eaa
 * different platforms, thus save the total size of config files. 
Packit Service db8eaa
 * Users can also specifiy additional configuraiton directories relative
Packit Service db8eaa
 * to "/usr/share/alsa/" to search the included files,  via alsaconf syntax
Packit Service db8eaa
 * <searchfdir:/relative-path/to/usr/share/alsa>. 

Packit Service db8eaa
 *
Packit Service db8eaa
 * For example, file A and file B are two text conf files for platform X,
Packit Service db8eaa
 * they will be installed to /usr/share/alsa/topology/platformx. If we
Packit Service db8eaa
 * need file A to include file B, in file A we can add: 
Packit Service db8eaa
 *
Packit Service db8eaa
 * <searchdir:topology/platformx> 
Packit Service db8eaa
 * <name-of-file-B> 

Packit Service db8eaa
 *
Packit Service db8eaa
 * ALSA conf will search and open an included file in the following order
Packit Service db8eaa
 * of priority:
Packit Service db8eaa
 *  1. directly open the file by its name;
Packit Service db8eaa
 *  2. search for the file name in "/usr/share/alsa";
Packit Service db8eaa
 *  3. search for the file name in user specified subdirectories under
Packit Service db8eaa
 *     "/usr/share/alsa".
Packit Service db8eaa
 *
Packit Service db8eaa
 * The order of the included files need not to be same as their
Packit Service db8eaa
 * dependencies, since the topology library will load them all before
Packit Service db8eaa
 * parsing their dependencies. 
Packit Service db8eaa
 *
Packit Service db8eaa
 * The configuration directories defined by a file will only be used to search
Packit Service db8eaa
 * the files included by this file.
Packit Service db8eaa
 */
Packit Service db8eaa
Packit Service db8eaa
/** Maximum number of channels supported in one control */
Packit Service db8eaa
#define SND_TPLG_MAX_CHAN		8
Packit Service db8eaa
Packit Service db8eaa
/** Topology context */
Packit Service db8eaa
typedef struct snd_tplg snd_tplg_t;
Packit Service db8eaa
Packit Service db8eaa
/** Topology object types */
Packit Service db8eaa
enum snd_tplg_type {
Packit Service db8eaa
	SND_TPLG_TYPE_TLV = 0,		/*!< TLV Data */
Packit Service db8eaa
	SND_TPLG_TYPE_MIXER,		/*!< Mixer control*/
Packit Service db8eaa
	SND_TPLG_TYPE_ENUM,		/*!< Enumerated control */
Packit Service db8eaa
	SND_TPLG_TYPE_TEXT,		/*!< Text data */
Packit Service db8eaa
	SND_TPLG_TYPE_DATA,		/*!< Private data */
Packit Service db8eaa
	SND_TPLG_TYPE_BYTES,		/*!< Byte control */
Packit Service db8eaa
	SND_TPLG_TYPE_STREAM_CONFIG,	/*!< PCM Stream configuration */
Packit Service db8eaa
	SND_TPLG_TYPE_STREAM_CAPS,	/*!< PCM Stream capabilities */
Packit Service db8eaa
	SND_TPLG_TYPE_PCM,		/*!< PCM stream device */
Packit Service db8eaa
	SND_TPLG_TYPE_DAPM_WIDGET,	/*!< DAPM widget */
Packit Service db8eaa
	SND_TPLG_TYPE_DAPM_GRAPH,	/*!< DAPM graph elements */
Packit Service db8eaa
	SND_TPLG_TYPE_BE,		/*!< BE DAI link */
Packit Service db8eaa
	SND_TPLG_TYPE_CC,		/*!< Hostless codec <-> codec link */
Packit Service db8eaa
	SND_TPLG_TYPE_MANIFEST,		/*!< Topology manifest */
Packit Service db8eaa
	SND_TPLG_TYPE_TOKEN,		/*!< Vendor tokens */
Packit Service db8eaa
	SND_TPLG_TYPE_TUPLE,		/*!< Vendor tuples */
Packit Service db8eaa
	SND_TPLG_TYPE_LINK,		/*!< Physical DAI link */
Packit Service db8eaa
	SND_TPLG_TYPE_HW_CONFIG,	/*!< Link HW config */
Packit Service db8eaa
	SND_TPLG_TYPE_DAI,		/*!< Physical DAI */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** Fit for all user cases */
Packit Service db8eaa
#define SND_TPLG_INDEX_ALL  0
Packit Service db8eaa
Packit Service db8eaa
/** Flags for the snd_tplg_create */
Packit Service db8eaa
#define SND_TPLG_CREATE_VERBOSE		(1<<0)	/*!< Verbose output */
Packit Service db8eaa
#define SND_TPLG_CREATE_DAPM_NOSORT	(1<<1)	/*!< Do not sort DAPM objects by index */
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Return the version of the topology library.
Packit Service db8eaa
 * \return A static string with the version number.
Packit Service db8eaa
 */
Packit Service db8eaa
const char *snd_tplg_version(void);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Create a new topology parser instance.
Packit Service db8eaa
 * \return New topology parser instance
Packit Service db8eaa
 */
Packit Service db8eaa
snd_tplg_t *snd_tplg_new(void);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Create a new topology parser instance.
Packit Service db8eaa
 * \return New topology parser instance
Packit Service db8eaa
 */
Packit Service db8eaa
snd_tplg_t *snd_tplg_create(int flags);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Free a topology parser instance.
Packit Service db8eaa
 * \param tplg Topology parser instance
Packit Service db8eaa
 */
Packit Service db8eaa
void snd_tplg_free(snd_tplg_t *tplg);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Load topology from the text buffer.
Packit Service db8eaa
 * \param tplg Topology instance.
Packit Service db8eaa
 * \param buf Text buffer.
Packit Service db8eaa
 * \param size Text buffer size in bytes.
Packit Service db8eaa
 * \return Zero on success, otherwise a negative error code
Packit Service db8eaa
 */
Packit Service db8eaa
int snd_tplg_load(snd_tplg_t *tplg, const char *buf, size_t size);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Parse and build topology text file into binary file.
Packit Service db8eaa
 * \param tplg Topology instance.
Packit Service db8eaa
 * \param infile Topology text input file to be parsed
Packit Service db8eaa
 * \param outfile Binary topology output file.
Packit Service db8eaa
 * \return Zero on success, otherwise a negative error code
Packit Service db8eaa
 */
Packit Service db8eaa
int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,
Packit Service db8eaa
			const char *outfile);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Enable verbose reporting of binary file output
Packit Service db8eaa
 * \param tplg Topology Instance
Packit Service db8eaa
 * \param verbose Enable verbose output level if non zero
Packit Service db8eaa
 */
Packit Service db8eaa
void snd_tplg_verbose(snd_tplg_t *tplg, int verbose);
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_tlv_template
Packit Service db8eaa
 * \brief Template type for all TLV objects.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_tlv_template {
Packit Service db8eaa
	int type;	 /*!< TLV type SNDRV_CTL_TLVT_ */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_tlv_dbscale_template
Packit Service db8eaa
 * \brief Template type for TLV Scale objects.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_tlv_dbscale_template {
Packit Service db8eaa
	struct snd_tplg_tlv_template hdr;	/*!< TLV type header */
Packit Service db8eaa
	int min;			/*!< dB minimum value in 0.1dB */
Packit Service db8eaa
	int step;			/*!< dB step size in 0.1dB */
Packit Service db8eaa
	int mute;			/*!< is min dB value mute ? */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_channel_template
Packit Service db8eaa
 * \brief Template type for single channel mapping.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_channel_elem {
Packit Service db8eaa
	int size;	/*!< size in bytes of this structure */
Packit Service db8eaa
	int reg;	/*!< channel control register */
Packit Service db8eaa
	int shift;	/*!< channel shift for control bits */
Packit Service db8eaa
	int id;		/*!< ID maps to Left, Right, LFE etc */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_channel_map_template
Packit Service db8eaa
 * \brief Template type for channel mapping.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_channel_map_template {
Packit Service db8eaa
	int num_channels;	/*!< number of channel mappings */
Packit Service db8eaa
	struct snd_tplg_channel_elem channel[SND_TPLG_MAX_CHAN];	/*!< mapping */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_pdata_template
Packit Service db8eaa
 * \brief Template type for private data objects.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_pdata_template {
Packit Service db8eaa
	unsigned int length;	/*!< data length */
Packit Service db8eaa
	const void *data;	/*!< data */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_io_ops_template
Packit Service db8eaa
 * \brief Template type for object operations mapping.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_io_ops_template {
Packit Service db8eaa
	int get;	/*!< get callback ID */
Packit Service db8eaa
	int put;	/*!< put callback ID */
Packit Service db8eaa
	int info;	/*!< info callback ID */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_ctl_template
Packit Service db8eaa
 * \brief Template type for control objects.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_ctl_template {
Packit Service db8eaa
	int type;		/*!< Control type */
Packit Service db8eaa
	const char *name;	/*!< Control name */
Packit Service db8eaa
	int access;		/*!< Control access */
Packit Service db8eaa
	struct snd_tplg_io_ops_template ops;	/*!< operations */
Packit Service db8eaa
	union {
Packit Service db8eaa
		struct snd_tplg_tlv_template *tlv; /*!< non NULL means we have TLV data */
Packit Service db8eaa
		struct snd_tplg_tlv_dbscale_template *tlv_scale; /*!< scale TLV data */
Packit Service db8eaa
	};
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_mixer_template
Packit Service db8eaa
 * \brief Template type for mixer control objects.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_mixer_template {
Packit Service db8eaa
	struct snd_tplg_ctl_template hdr;	/*!< control type header */
Packit Service db8eaa
	struct snd_tplg_channel_map_template *map;	/*!< channel map */
Packit Service db8eaa
	int min;	/*!< min value for mixer */
Packit Service db8eaa
	int max;	/*!< max value for mixer */
Packit Service db8eaa
	int platform_max;	/*!< max value for platform control */
Packit Service db8eaa
	int invert;	/*!< whether controls bits are inverted */
Packit Service db8eaa
	struct snd_soc_tplg_private *priv;	/*!< control private data */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_enum_template
Packit Service db8eaa
 * \brief Template type for enumerated control objects.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_enum_template {
Packit Service db8eaa
	struct snd_tplg_ctl_template hdr;	/*!< control type header */
Packit Service db8eaa
	struct snd_tplg_channel_map_template *map;	/*!< channel map */
Packit Service db8eaa
	int items;	/*!< number of enumerated items in control */
Packit Service db8eaa
	int mask;	/*!< register mask size */
Packit Service db8eaa
	const char **texts;	/*!< control text items */
Packit Service db8eaa
	const int **values;	/*!< control value items */
Packit Service db8eaa
	struct snd_soc_tplg_private *priv;	/*!< control private data */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_bytes_template
Packit Service db8eaa
 * \brief Template type for TLV Scale objects.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_bytes_template {
Packit Service db8eaa
	struct snd_tplg_ctl_template hdr;	/*!< control type header */
Packit Service db8eaa
	int max;		/*!< max byte control value */
Packit Service db8eaa
	int mask;		/*!< byte control mask */
Packit Service db8eaa
	int base;		/*!< base register */
Packit Service db8eaa
	int num_regs;		/*!< number of registers */
Packit Service db8eaa
	struct snd_tplg_io_ops_template ext_ops;	/*!< ops mapping */
Packit Service db8eaa
	struct snd_soc_tplg_private *priv;	/*!< control private data */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_graph_elem
Packit Service db8eaa
 * \brief Template type for single DAPM graph element.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_graph_elem {
Packit Service db8eaa
	const char *src;	/*!< source widget name */
Packit Service db8eaa
	const char *ctl;	/*!< control name or NULL if no control */
Packit Service db8eaa
	const char *sink;	/*!< sink widget name */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_graph_template
Packit Service db8eaa
 * \brief Template type for array of DAPM graph elements.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_graph_template {
Packit Service db8eaa
	int count;		/*!< Number of graph elements */
Packit Service db8eaa
	struct snd_tplg_graph_elem elem[0];	/*!< graph elements */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_widget_template
Packit Service db8eaa
 * \brief Template type for DAPM widget objects.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_widget_template {
Packit Service db8eaa
	int id;			/*!< SND_SOC_DAPM_CTL */
Packit Service db8eaa
	const char *name;	/*!< widget name */
Packit Service db8eaa
	const char *sname;	/*!< stream name (certain widgets only) */
Packit Service db8eaa
	int reg;		/*!< negative reg = no direct dapm */
Packit Service db8eaa
	int shift;		/*!< bits to shift */
Packit Service db8eaa
	int mask;		/*!< non-shifted mask */
Packit Service db8eaa
	int subseq;		/*!< sort within widget type */
Packit Service db8eaa
	unsigned int invert;		/*!< invert the power bit */
Packit Service db8eaa
	unsigned int ignore_suspend;	/*!< kept enabled over suspend */
Packit Service db8eaa
	unsigned short event_flags;	/*!< PM event sequence flags */
Packit Service db8eaa
	unsigned short event_type;	/*!< PM event sequence type */
Packit Service db8eaa
	struct snd_soc_tplg_private *priv;	/*!< widget private data */
Packit Service db8eaa
	int num_ctls;			/*!< Number of controls used by widget */
Packit Service db8eaa
	struct snd_tplg_ctl_template *ctl[0];	/*!< array of widget controls */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_stream_template
Packit Service db8eaa
 * \brief Stream configurations.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_stream_template {
Packit Service db8eaa
	const char *name;	/*!< name of the stream config */
Packit Service db8eaa
	int format;		/*!< SNDRV_PCM_FMTBIT_* */
Packit Service db8eaa
	int rate;		/*!< SNDRV_PCM_RATE_* */
Packit Service db8eaa
	int period_bytes;	/*!< size of period in bytes */
Packit Service db8eaa
	int buffer_bytes;	/*!< size of buffer in bytes. */
Packit Service db8eaa
	int channels;		/*!< number of channels */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_stream_caps_template
Packit Service db8eaa
 * \brief Stream Capabilities.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_stream_caps_template {
Packit Service db8eaa
	const char *name;	/*!< name of the stream caps */
Packit Service db8eaa
	uint64_t formats;	/*!< supported formats SNDRV_PCM_FMTBIT_* */
Packit Service db8eaa
	unsigned int rates;	/*!< supported rates SNDRV_PCM_RATE_* */
Packit Service db8eaa
	unsigned int rate_min;	/*!< min rate */
Packit Service db8eaa
	unsigned int rate_max;	/*!< max rate */
Packit Service db8eaa
	unsigned int channels_min;	/*!< min channels */
Packit Service db8eaa
	unsigned int channels_max;	/*!< max channels */
Packit Service db8eaa
	unsigned int periods_min;	/*!< min number of periods */
Packit Service db8eaa
	unsigned int periods_max;	/*!< max number of periods */
Packit Service db8eaa
	unsigned int period_size_min;	/*!< min period size bytes */
Packit Service db8eaa
	unsigned int period_size_max;	/*!< max period size bytes */
Packit Service db8eaa
	unsigned int buffer_size_min;	/*!< min buffer size bytes */
Packit Service db8eaa
	unsigned int buffer_size_max;	/*!< max buffer size bytes */
Packit Service db8eaa
	unsigned int sig_bits;		/*!< number of bits of content */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_pcm_template
Packit Service db8eaa
 * \brief Template type for PCM (FE DAI & DAI links).
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_pcm_template {
Packit Service db8eaa
	const char *pcm_name;	/*!< PCM stream name */
Packit Service db8eaa
	const char *dai_name;	/*!< DAI name */
Packit Service db8eaa
	unsigned int pcm_id;	/*!< unique ID - used to match */
Packit Service db8eaa
	unsigned int dai_id;	/*!< unique ID - used to match */
Packit Service db8eaa
	unsigned int playback;	/*!< supports playback mode */
Packit Service db8eaa
	unsigned int capture;	/*!< supports capture mode */
Packit Service db8eaa
	unsigned int compress;	/*!< 1 = compressed; 0 = PCM */
Packit Service db8eaa
	struct snd_tplg_stream_caps_template *caps[2]; /*!< playback & capture for DAI */
Packit Service db8eaa
	unsigned int flag_mask; /*!< bitmask of flags to configure */
Packit Service db8eaa
	unsigned int flags;     /*!< flag value SND_SOC_TPLG_LNK_FLGBIT_* */
Packit Service db8eaa
	struct snd_soc_tplg_private *priv;	/*!< private data */
Packit Service db8eaa
	int num_streams;	/*!< number of supported configs */
Packit Service db8eaa
	struct snd_tplg_stream_template stream[0]; /*!< supported configs */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
 /** \struct snd_tplg_hw_config_template
Packit Service db8eaa
 * \brief Template type to describe a physical link runtime supported
Packit Service db8eaa
 * hardware config, i.e. hardware audio formats.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_hw_config_template {
Packit Service db8eaa
	int id;                         /* unique ID - - used to match */
Packit Service db8eaa
	unsigned int fmt;               /* SND_SOC_DAI_FORMAT_ format value */
Packit Service db8eaa
	unsigned char clock_gated;      /* SND_SOC_TPLG_DAI_CLK_GATE_ value */
Packit Service db8eaa
	unsigned char  invert_bclk;     /* 1 for inverted BCLK, 0 for normal */
Packit Service db8eaa
	unsigned char  invert_fsync;    /* 1 for inverted frame clock, 0 for normal */
Packit Service 45dc4a
	unsigned char  bclk_master;     /* SND_SOC_TPLG_BCLK_ value */
Packit Service 45dc4a
	unsigned char  fsync_master;    /* SND_SOC_TPLG_FSYNC_ value */
Packit Service db8eaa
	unsigned char  mclk_direction;  /* SND_SOC_TPLG_MCLK_ value */
Packit Service db8eaa
	unsigned short reserved;        /* for 32bit alignment */
Packit Service db8eaa
	unsigned int mclk_rate;	        /* MCLK or SYSCLK freqency in Hz */
Packit Service db8eaa
	unsigned int bclk_rate;	        /* BCLK freqency in Hz */
Packit Service db8eaa
	unsigned int fsync_rate;        /* frame clock in Hz */
Packit Service db8eaa
	unsigned int tdm_slots;         /* number of TDM slots in use */
Packit Service db8eaa
	unsigned int tdm_slot_width;    /* width in bits for each slot */
Packit Service db8eaa
	unsigned int tx_slots;          /* bit mask for active Tx slots */
Packit Service db8eaa
	unsigned int rx_slots;          /* bit mask for active Rx slots */
Packit Service db8eaa
	unsigned int tx_channels;       /* number of Tx channels */
Packit Service db8eaa
	unsigned int *tx_chanmap;       /* array of slot number */
Packit Service db8eaa
	unsigned int rx_channels;       /* number of Rx channels */
Packit Service db8eaa
	unsigned int *rx_chanmap;       /* array of slot number */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_dai_template
Packit Service db8eaa
 * \brief Template type for physical DAI.
Packit Service db8eaa
 * It can be used to configure backend DAIs for DPCM.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_dai_template {
Packit Service db8eaa
	const char *dai_name;	/*!< DAI name */
Packit Service db8eaa
	unsigned int dai_id;	/*!< unique ID - used to match */
Packit Service db8eaa
	unsigned int playback;	/*!< supports playback mode */
Packit Service db8eaa
	unsigned int capture;	/*!< supports capture mode */
Packit Service db8eaa
	struct snd_tplg_stream_caps_template *caps[2]; /*!< playback & capture for DAI */
Packit Service db8eaa
	unsigned int flag_mask; /*!< bitmask of flags to configure */
Packit Service db8eaa
	unsigned int flags;	/*!< SND_SOC_TPLG_DAI_FLGBIT_* */
Packit Service db8eaa
	struct snd_soc_tplg_private *priv;	/*!< private data */
Packit Service db8eaa
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_link_template
Packit Service db8eaa
 * \brief Template type for physical DAI Links.
Packit Service db8eaa
 */
Packit Service db8eaa
struct snd_tplg_link_template {
Packit Service db8eaa
	const char *name;	/*!< link name, used to match */
Packit Service db8eaa
	int id;	/*!< unique ID - used to match with existing physical links */
Packit Service db8eaa
	const char *stream_name;        /*!< link stream name, used to match */
Packit Service db8eaa
Packit Service db8eaa
	int num_streams;	/*!< number of configs */
Packit Service db8eaa
	struct snd_tplg_stream_template *stream;       /*!< supported configs */
Packit Service db8eaa
Packit Service db8eaa
	struct snd_tplg_hw_config_template *hw_config; /*!< supported HW configs */
Packit Service db8eaa
	int num_hw_configs;		/* number of hw configs */
Packit Service db8eaa
	int default_hw_config_id;       /* default hw config ID for init */
Packit Service db8eaa
Packit Service db8eaa
	unsigned int flag_mask;         /* bitmask of flags to configure */
Packit Service db8eaa
	unsigned int flags;             /* SND_SOC_TPLG_LNK_FLGBIT_* flag value */
Packit Service db8eaa
	struct snd_soc_tplg_private *priv; /*!< private data */
Packit Service db8eaa
};
Packit Service db8eaa
Packit Service db8eaa
/** \struct snd_tplg_obj_template
Packit Service db8eaa
 * \brief Generic Template Object
Packit Service db8eaa
 */
Packit Service db8eaa
typedef struct snd_tplg_obj_template {
Packit Service db8eaa
	enum snd_tplg_type type;	/*!< template object type */
Packit Service db8eaa
	int index;		/*!< group index for object */
Packit Service db8eaa
	int version;		/*!< optional vendor specific version details */
Packit Service db8eaa
	int vendor_type;	/*!< optional vendor specific type info */
Packit Service db8eaa
	union {
Packit Service db8eaa
		struct snd_tplg_widget_template *widget;	/*!< DAPM widget */
Packit Service db8eaa
		struct snd_tplg_mixer_template *mixer;		/*!< Mixer control */
Packit Service db8eaa
		struct snd_tplg_bytes_template *bytes_ctl;	/*!< Bytes control */
Packit Service db8eaa
		struct snd_tplg_enum_template *enum_ctl;	/*!< Enum control */
Packit Service db8eaa
		struct snd_tplg_graph_template *graph;		/*!< Graph elements */
Packit Service db8eaa
		struct snd_tplg_pcm_template *pcm;		/*!< PCM elements */
Packit Service db8eaa
		struct snd_tplg_link_template *link;		/*!< physical DAI Links */
Packit Service db8eaa
		struct snd_tplg_dai_template *dai;		/*!< Physical DAI */
Packit Service db8eaa
	};
Packit Service db8eaa
} snd_tplg_obj_template_t;
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Register topology template object.
Packit Service db8eaa
 * \param tplg Topology instance.
Packit Service db8eaa
 * \param t Template object.
Packit Service db8eaa
 * \return Zero on success, otherwise a negative error code
Packit Service db8eaa
 */
Packit Service db8eaa
int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Build all registered topology data into binary file.
Packit Service db8eaa
 * \param tplg Topology instance.
Packit Service db8eaa
 * \param outfile Binary topology output file.
Packit Service db8eaa
 * \return Zero on success, otherwise a negative error code
Packit Service db8eaa
 */
Packit Service db8eaa
int snd_tplg_build(snd_tplg_t *tplg, const char *outfile);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Build all registered topology data into memory.
Packit Service db8eaa
 * \param tplg Topology instance.
Packit Service db8eaa
 * \param bin Binary topology output buffer (malloc).
Packit Service db8eaa
 * \param size Binary topology output buffer size in bytes.
Packit Service db8eaa
 * \return Zero on success, otherwise a negative error code
Packit Service db8eaa
 */
Packit Service db8eaa
int snd_tplg_build_bin(snd_tplg_t *tplg, void **bin, size_t *size);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Attach private data to topology manifest.
Packit Service db8eaa
 * \param tplg Topology instance.
Packit Service db8eaa
 * \param data Private data.
Packit Service db8eaa
 * \param len Length of data in bytes.
Packit Service db8eaa
 * \return Zero on success, otherwise a negative error code
Packit Service db8eaa
 */
Packit Service db8eaa
int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Set an optional vendor specific version number.
Packit Service db8eaa
 * \param tplg Topology instance.
Packit Service db8eaa
 * \param version Vendor specific version number.
Packit Service db8eaa
 * \return Zero on success, otherwise a negative error code
Packit Service db8eaa
 */
Packit Service db8eaa
int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version);
Packit Service db8eaa
Packit Service db8eaa
/*
Packit Service db8eaa
 * Flags for the snd_tplg_save()
Packit Service db8eaa
 */
Packit Service db8eaa
#define SND_TPLG_SAVE_SORT	(1<<0)	/*!< sort identifiers */
Packit Service db8eaa
#define SND_TPLG_SAVE_GROUPS	(1<<1)	/*!< create the structure by group index */
Packit Service db8eaa
#define SND_TPLG_SAVE_NOCHECK	(1<<16)	/*!< unchecked output for debugging */
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Save the topology to the text configuration string.
Packit Service db8eaa
 * \param tplg Topology instance.
Packit Service db8eaa
 * \param dst A pointer to string with result (malloc).
Packit Service db8eaa
 * \return Zero on success, otherwise a negative error code
Packit Service db8eaa
 */
Packit Service db8eaa
int snd_tplg_save(snd_tplg_t *tplg, char **dst, int flags);
Packit Service db8eaa
Packit Service db8eaa
/**
Packit Service db8eaa
 * \brief Decode the binary topology contents.
Packit Service db8eaa
 * \param tplg Topology instance.
Packit Service db8eaa
 * \param bin Binary topology input buffer.
Packit Service db8eaa
 * \param size Binary topology input buffer size.
Packit Service db8eaa
 * \return Zero on success, otherwise a negative error code
Packit Service db8eaa
 */
Packit Service db8eaa
int snd_tplg_decode(snd_tplg_t *tplg, void *bin, size_t size, int dflags);
Packit Service db8eaa
Packit Service db8eaa
/* \} */
Packit Service db8eaa
Packit Service db8eaa
#ifdef __cplusplus
Packit Service db8eaa
}
Packit Service db8eaa
#endif
Packit Service db8eaa
Packit Service db8eaa
#endif /* __ALSA_TOPOLOGY_H */