Path: blob/master/thirdparty/linuxbsd_headers/alsa/topology.h
9898 views
/*1*2* This library is free software; you can redistribute it and/or modify3* it under the terms of the GNU Lesser General Public License as4* published by the Free Software Foundation; either version 2.1 of5* the License, or (at your option) any later version.6*7* This program is distributed in the hope that it will be useful,8* but WITHOUT ANY WARRANTY; without even the implied warranty of9* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10* GNU Lesser General Public License for more details.11*12* You should have received a copy of the GNU Lesser General Public13* License along with this library; if not, write to the Free Software14* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA15*16* Copyright (C) 2015 Intel Corporation17*18*/1920#ifndef __ALSA_TOPOLOGY_H21#define __ALSA_TOPOLOGY_H2223#include <stdint.h>2425#ifdef __cplusplus26extern "C" {27#endif2829/**30* \defgroup topology Topology Interface31* \{32*/3334/*! \page topology ALSA Topology Interface35*36* The topology interface allows developers to define DSP topologies in a text37* file format and to convert the text topology to a binary topology38* representation that can be understood by the kernel. The topology core39* currently recognises the following object types :-40*41* * Controls (mixer, enumerated and byte) including TLV data.42* * PCMs (Front End DAI & DAI link)43* * DAPM widgets44* * DAPM graph elements.45* * Physical DAI & DAI links46* * Private data for each object type.47* * Manifest (containing count of each object type)48*49* <h3>Topology File Format</h3>50*51* The topology text format uses the standard ALSA configuration file format to52* describe each topology object type. This allows topology objects to include53* other topology objects as part of their definition. i.e. a TLV data object54* can be shared amongst many control objects that use the same TLV data.55*56*57* <h4>Controls</h4>58* Topology audio controls can belong to three different types :-59* * Mixer control60* * Enumerated control61* * Byte control62*63* Each control type can contain TLV data, private data, operations and also64* belong to widget objects.<br>65*66* <h5>Control Operations</h5>67* Driver Kcontrol callback info(), get() and put() operations are mapped with68* the CTL ops section in topology configuration files. The ctl ops section can69* assign operations using the standard names (listed below) for the standard70* kcontrol types or use ID numbers (>256) to map to bespoke driver controls.<br>71*72* <pre>73*74* ops."ctl" {75* info "volsw"76* get "257"77* put "257"78* }79*80* </pre>81*82* This mapping shows info() using the standard "volsw" info callback whilst83* the get() and put() are mapped to bespoke driver callbacks. <br>84*85* The Standard operations names for control get(), put() and info calls86* are :-87* * volsw88* * volsw_sx89* * volsw_xr_sx90* * enum91* * bytes92* * enum_value93* * range94* * strobe95*96* <h5>Control Access</h5>97* Controls access can be specified using the "access" section. If no "access"98* section is defined then default RW access flags are set for normal and TLV99* controls.100*101* <pre>102* access [103* read104* write105* tlv_command106* ]107* </pre>108*109* The standard access flags are as follows :-110* * read111* * write112* * read_write113* * volatile114* * timestamp115* * tlv_read116* * tlv_write117* * tlv_read_write118* * tlv_command119* * inactive120* * lock121* * owner122* * tlv_callback123* * user124*125* <h5>Control TLV Data</h5>126* Controls can also use TLV data to represent dB information. This can be done127* by defining a TLV section and using the TLV section within the control.128* The TLV data for DBScale types are defined as follows :-129*130* <pre>131* scale {132* min "-9000"133* step "300"134* mute "1"135* }136* </pre>137*138* Where the meanings and values for min, step and mute are exactly the same139* as defined in driver code.140*141* <h5>Control Channel Mapping</h5>142* Controls can also specify which channels they are mapped with. This is useful143* for userspace as it allows applications to determine the correct control144* channel for Left and Right etc. Channel maps are defined as follows :-145*146* <pre>147* channel."name" {148* reg "0"149* shift "0"150* }151* </pre>152*153* The channel map reg is the register offset for the control, shift is the154* bit shift within the register for the channel and the section name is the155* channel name and can be one of the following :-156*157* <pre>158* * mono # mono stream159* * fl # front left160* * fr # front right161* * rl # rear left162* * rr # rear right163* * fc # front center164* * lfe # LFE165* * sl # side left166* * sr # side right167* * rc # rear center168* * flc # front left center169* * frc # front right center170* * rlc # rear left center171* * rrc # rear right center172* * flw # front left wide173* * frw # front right wide174* * flh # front left high175* * fch # front center high176* * frh # front right high177* * tc # top center178* * tfl # top front left179* * tfr # top front right180* * tfc # top front center181* * trl # top rear left182* * trr # top rear right183* * trc # top rear center184* * tflc # top front left center185* * tfrc # top front right center186* * tsl # top side left187* * tsr # top side right188* * llfe # left LFE189* * rlfe # right LFE190* * bc # bottom center191* * blc # bottom left center192* * brc # bottom right center193* </pre>194*195* <h5>Control Private Data</h5>196* Controls can also have private data. This can be done by defining a private197* data section and including the section within the control. The private data198* section is defined as follows :-199*200* <pre>201* SectionData."pdata for EQU1" {202* file "/path/to/file"203* bytes "0x12,0x34,0x56,0x78"204* shorts "0x1122,0x3344,0x5566,0x7788"205* words "0xaabbccdd,0x11223344,0x66aa77bb,0xefef1234"206* tuples "section id of the vendor tuples"207* };208* </pre>209* The file, bytes, shorts, words and tuples keywords are all mutually210* exclusive as the private data should only be taken from one source.211* The private data can either be read from a separate file or defined in212* the topology file using the bytes, shorts, words or tuples keywords.213* The keyword tuples is to define vendor specific tuples. Please refer to214* section Vendor Tokens and Vendor tuples.215*216* <h5>How to define an element with private data</h5>217* An element can refer to a single data section or multiple data218* sections.219*220* <h6>To refer to a single data section:</h6>221* <pre>222* Sectionxxx."element name" {223* ...224* data "name of data section" # optional private data225* }226* </pre>227*228* <h6>To refer to multiple data sections:</h6>229* <pre>230* Sectionxxx."element name" {231* ...232* data [ # optional private data233* "name of 1st data section"234* "name of 2nd data section"235* ...236* ]237* }238* </pre>239* And data of these sections will be merged in the same order as they are240* in the list, as the element's private data for kernel.241*242* </pre>243*244* <h6>Vendor Tokens</h6>245* A vendor token list is defined as a new section. Each token element is246* a pair of string ID and integer value. And both the ID and value are247* vendor-specific.248*249* <pre>250* SectionVendorTokens."id of the vendor tokens" {251* comment "optional comments"252* VENDOR_TOKEN_ID1 "1"253* VENDOR_TOKEN_ID2 "2"254* VENDOR_TOKEN_ID3 "3"255* ...256* }257* </pre>258*259* <h6>Vendor Tuples</h6>260* Vendor tuples are defined as a new section. It contains a reference to261* a vendor token list and several tuple arrays.262* All arrays share a vendor token list, defined by the tokens keyword.263* Each tuple array is for a specific type, defined by the string following264* the tuples keyword. Supported types are: string, uuid, bool, byte,265* short and word.266*267* <pre>268* SectionVendorTuples."id of the vendor tuples" {269* tokens "id of the vendor tokens"270*271* tuples."string" {272* VENDOR_TOKEN_ID1 "character string"273* ...274* }275*276* tuples."uuid" { # 16 characters separated by commas277* VENDOR_TOKEN_ID2 "0x01,0x02,...,0x0f"278* ...279* }280*281* tuples."bool" {282* VENDOR_TOKEN_ID3 "true/false"283* ...284* }285*286* tuples."byte" {287* VENDOR_TOKEN_ID4 "0x11"288* VENDOR_TOKEN_ID5 "0x22"289* ...290* }291*292* tuples."short" {293* VENDOR_TOKEN_ID6 "0x1122"294* VENDOR_TOKEN_ID7 "0x3344"295* ...296* }297*298* tuples."word" {299* VENDOR_TOKEN_ID8 "0x11223344"300* VENDOR_TOKEN_ID9 "0x55667788"301* ...302* }303* }304* </pre>305* To define multiple vendor tuples of same type, please append some306* characters after the type string ("string", "uuid", "bool", "byte", "short"307* or "word"), to avoid ID duplication in the SectionVendorTuples.<br>308* The parser will check the first few characters in ID to get the tuple type.309* Here is an example:310* <pre>311* SectionVendorTuples."id of the vendor tuples" {312* ...313* tuples."word.module0" {314* VENDOR_TOKEN_PARAM_ID1 "0x00112233"315* VENDOR_TOKEN_PARAM_ID2 "0x44556677"316* ...317* }318*319* tuples."word.module2" {320* VENDOR_TOKEN_PARAM_ID1 "0x11223344"321* VENDOR_TOKEN_PARAM_ID2 "0x55667788"322* ...323* }324* ...325* }326*327* </pre>328*329* <h5>Mixer Controls</h5>330* A mixer control is defined as a new section that can include channel mapping,331* TLV data, callback operations and private data. The mixer section also332* includes a few other config options that are shown here :-333*334* <pre>335* SectionControlMixer."mixer name" {336* comment "optional comments"337*338* index "1" # Index number339*340* channel."name" { # Channel maps341* ....342* }343*344* ops."ctl" { # Ops callback functions345* ....346* }347*348* max "32" # Max control value349* invert "0" # Whether control values are inverted350*351* tlv "tld_data" # optional TLV data352*353* data "pdata for mixer1" # optional private data354* }355* </pre>356*357* The section name is used to define the mixer name. The index number can be358* used to identify topology objects groups. This allows driver operations on359* objects with index number N and can be used to add/remove pipelines of360* objects whilst other objects are unaffected.361*362* <h5>Byte Controls</h5>363* A byte control is defined as a new section that can include channel mapping,364* TLV data, callback operations and private data. The bytes section also365* includes a few other config options that are shown here :-366*367* <pre>368* SectionControlBytes."name" {369* comment "optional comments"370*371* index "1" # Index number372*373* channel."name" { # Channel maps374* ....375* }376*377* ops."ctl" { # Ops callback functions378* ....379* }380*381* base "0" # Register base382* num_regs "16" # Number of registers383* mask "0xff" # Mask384* max "255" # Maximum value385*386* tlv "tld_data" # optional TLV data387*388* data "pdata for mixer1" # optional private data389* }390* </pre>391*392* <h5>Enumerated Controls</h5>393* A enumerated control is defined as a new section (like mixer and byte) that394* can include channel mapping, callback operations, private data and395* text strings to represent the enumerated control options.<br>396*397* The text strings for the enumerated controls are defined in a separate398* section as follows :-399*400* <pre>401* SectionText."name" {402*403* Values [404* "value1"405* "value2"406"value3"407* ]408* }409* </pre>410*411* All the enumerated text values are listed in the values list.<br>412* The enumerated control is similar to the other controls and defined as413* follows :-414*415* <pre>416* SectionControlMixer."name" {417* comment "optional comments"418*419* index "1" # Index number420*421* texts "EQU1" # Enumerated text items422*423* channel."name" { # Channel maps424* ....425* }426*427* ops."ctl" { # Ops callback functions428* ....429* }430*431* data "pdata for mixer1" # optional private data432* }433* </pre>434*435* <h4>DAPM Graph</h4>436* DAPM graphs can easily be defined using the topology file. The format is437* very similar to the DAPM graph kernel format. :-438*439* <pre>440* SectionGraph."dsp" {441* index "1" # Index number442*443* lines [444* "sink1, control, source1"445* "sink2, , source2"446* ]447* }448* </pre>449*450* The lines in the graph are defined as a variable size list of sinks,451* controls and sources. The control name is optional as some graph lines have452* no associated controls. The section name can be used to differentiate the453* graph with other graphs, it's not used by the kernel atm.454*455* <h4>DAPM Widgets</h4>456* DAPM widgets are similar to controls in that they can include many other457* objects. Widgets can contain private data, mixer controls and enum controls.458*459* The following widget types are supported and match the driver types :-460*461* * input462* * output463* * mux464* * mixer465* * pga466* * out_drv467* * adc468* * dac469* * switch470* * pre471* * post472* * aif_in473* * aif_out474* * dai_in475* * dai_out476* * dai_link477*478* Widgets are defined as follows :-479*480* <pre>481* SectionWidget."name" {482*483* index "1" # Index number484*485* type "aif_in" # Widget type - detailed above486* stream_name "name" # Stream name487*488* no_pm "true" # No PM control bit.489* reg "20" # PM bit register offset490* shift "0" # PM bit register shift491* invert "1 # PM bit is inverted492* subseq "8" # subsequence number493*494* event_type "1" # DAPM widget event type495* event_flags "1" # DAPM widget event flags496*497* mixer "name" # Optional Mixer Control498* enum "name" # Optional Enum Control499*500* data "name" # optional private data501* }502* </pre>503*504* The section name is the widget name. The mixer and enum fields are mutually505* exclusive and used to include controls into the widget. The index and data506* fields are the same for widgets as they are for controls whilst the other507* fields map on very closely to the driver widget fields.508*509* <h5>Widget Private Data</h5>510* Widget can have private data. For the format of the private data, please511* refer to section Control Private Data.512*513* <h4>PCM Capabilities</h4>514* Topology can also define the PCM capabilities of front end or physical DAIs.515* Capabilities can be defined with the following section :-516*517* <pre>518* SectionPCMCapabilities."name" {519*520* formats "S24_LE,S16_LE" # Supported formats521* rate_min "48000" # Max supported sample rate522* rate_max "48000" # Min supported sample rate523* channels_min "2" # Min number of channels524* channels_max "2" # max number of channels525* }526* </pre>527* The supported formats use the same naming convention as the driver macros.528* The PCM capabilities name can be referred to and included by PCM and529* physical DAI sections.530*531* <h4>PCM Configurations</h4>532* PCM runtime configurations can be defined for playback and capture stream533* directions with the following section :-534*535* <pre>536* SectionPCMConfig."name" {537*538* config."playback" { # playback config539* format "S16_LE" # playback format540* rate "48000" # playback sample rate541* channels "2" # playback channels542* tdm_slot "0xf" # playback TDM slot543* }544*545* config."capture" { # capture config546* format "S16_LE" # capture format547* rate "48000" # capture sample rate548* channels "2" # capture channels549* tdm_slot "0xf" # capture TDM slot550* }551* }552* </pre>553*554* The supported formats use the same naming convention as the driver macros.555* The PCM configuration name can be referred to and included by PCM and556* physical link sections.557*558* <h4>PCM (Front-end DAI & DAI link) </h4>559* PCM sections define the supported capabilities and configurations for560* supported playback and capture streams, names and flags for front end561* DAI & DAI links. Topology kernel driver will use a PCM object to create562* a pair of FE DAI & DAI links.563*564* <pre>565* SectionPCM."name" {566*567* index "1" # Index number568*569* id "0" # used for binding to the PCM570*571* dai."name of front-end DAI" {572* id "0" # used for binding to the front-end DAI573* }574*575* pcm."playback" {576* capabilities "capabilities1" # capabilities for playback577*578* configs [ # supported configs for playback579* "config1"580* "config2"581* ]582* }583*584* pcm."capture" {585* capabilities "capabilities2" # capabilities for capture586*587* configs [ # supported configs for capture588* "config1"589* "config2"590* "config3"591* ]592* }593*594* # Optional boolean flags595* symmetric_rates "true"596* symmetric_channels "true"597* symmetric_sample_bits "false"598*599* data "name" # optional private data600* }601* </pre>602*603* <h4>Physical DAI Link Configurations</h4>604* The runtime configurations of a physical DAI link can be defined by605* SectionLink. <br> Backend DAI links belong to physical links, and can606* be configured by either SectionLink or SectionBE, with same syntax.607* But SectionBE is deprecated atm since the internal processing is608* actually same.609*610* <pre>611* SectionLink."name" {612*613* index "1" # Index number614*615* id "0" # used for binding to the link616*617* stream_name "name" # used for binding to the link618*619* hw_configs [ # runtime supported HW configurations, optional620* "config1"621* "config2"622* ...623* ]624*625* default_hw_conf_id "1" #default HW config ID for init626*627* # Optional boolean flags628* symmetric_rates "true"629* symmetric_channels "false"630* symmetric_sample_bits "true"631*632* data "name" # optional private data633* }634* </pre>635*636* A physical link can refer to multiple runtime supported hardware637* configurations, which is defined by SectionHWConfig.638*639* <pre>640* SectionHWConfig."name" {641*642* id "1" # used for binding to the config643* format "I2S" # physical audio format.644* bclk "master" # Platform is master of bit clock645* fsync "slave" # Platform is slave of fsync646* }647* </pre>648*649* <h4>Physical DAI</h4>650* A physical DAI (e.g. backend DAI for DPCM) is defined as a new section651* that can include a unique ID, playback and capture stream capabilities,652* optional flags, and private data. <br>653* Its PCM stream capablities are same as those for PCM objects,654* please refer to section 'PCM Capabilities'.655*656* <pre>657* SectionDAI."name" {658*659* index "1" # Index number660*661* id "0" # used for binding to the Backend DAI662*663* pcm."playback" {664* capabilities "capabilities1" # capabilities for playback665* }666*667* pcm."capture" {668* capabilities "capabilities2" # capabilities for capture669* }670*671* symmetric_rates "true" # optional flags672* symmetric_channels "true"673* symmetric_sample_bits "false"674*675* data "name" # optional private data676* }677* </pre>678*679* <h4>Manifest Private Data</h4>680* Manfiest may have private data. Users need to define a manifest section681* and add the references to 1 or multiple data sections. Please refer to682* section 'How to define an element with private data'. <br>683* And the text conf file can have at most 1 manifest section. <br><br>684*685* Manifest section is defined as follows :-686*687* <pre>688* SectionManifest"name" {689*690* data "name" # optional private data691* }692* </pre>693*694* <h4>Include other files</h4>695* Users may include other files in a text conf file via alsaconf syntax696* <path/to/configuration-file>. This allows users to define common info697* in separate files (e.g. vendor tokens, tuples) and share them for698* different platforms, thus save the total size of config files. <br>699* Users can also specifiy additional configuraiton directories relative700* to "/usr/share/alsa/" to search the included files, via alsaconf syntax701* <searchfdir:/relative-path/to/usr/share/alsa>. <br><br>702*703* For example, file A and file B are two text conf files for platform X,704* they will be installed to /usr/share/alsa/topology/platformx. If we705* need file A to include file B, in file A we can add: <br>706*707* <searchdir:topology/platformx> <br>708* <name-of-file-B> <br><br>709*710* ALSA conf will search and open an included file in the following order711* of priority:712* 1. directly open the file by its name;713* 2. search for the file name in "/usr/share/alsa";714* 3. search for the file name in user specified subdirectories under715* "/usr/share/alsa".716*717* The order of the included files need not to be same as their718* dependencies, since the topology library will load them all before719* parsing their dependencies. <br>720*721* The configuration directories defined by a file will only be used to search722* the files included by this file.723*/724725/** Maximum number of channels supported in one control */726#define SND_TPLG_MAX_CHAN 8727728/** Topology context */729typedef struct snd_tplg snd_tplg_t;730731/** Topology object types */732enum snd_tplg_type {733SND_TPLG_TYPE_TLV = 0, /*!< TLV Data */734SND_TPLG_TYPE_MIXER, /*!< Mixer control*/735SND_TPLG_TYPE_ENUM, /*!< Enumerated control */736SND_TPLG_TYPE_TEXT, /*!< Text data */737SND_TPLG_TYPE_DATA, /*!< Private data */738SND_TPLG_TYPE_BYTES, /*!< Byte control */739SND_TPLG_TYPE_STREAM_CONFIG, /*!< PCM Stream configuration */740SND_TPLG_TYPE_STREAM_CAPS, /*!< PCM Stream capabilities */741SND_TPLG_TYPE_PCM, /*!< PCM stream device */742SND_TPLG_TYPE_DAPM_WIDGET, /*!< DAPM widget */743SND_TPLG_TYPE_DAPM_GRAPH, /*!< DAPM graph elements */744SND_TPLG_TYPE_BE, /*!< BE DAI link */745SND_TPLG_TYPE_CC, /*!< Hostless codec <-> codec link */746SND_TPLG_TYPE_MANIFEST, /*!< Topology manifest */747SND_TPLG_TYPE_TOKEN, /*!< Vendor tokens */748SND_TPLG_TYPE_TUPLE, /*!< Vendor tuples */749SND_TPLG_TYPE_LINK, /*!< Physical DAI link */750SND_TPLG_TYPE_HW_CONFIG, /*!< Link HW config */751SND_TPLG_TYPE_DAI, /*!< Physical DAI */752};753754/**755* \brief Create a new topology parser instance.756* \return New topology parser instance757*/758snd_tplg_t *snd_tplg_new(void);759760/**761* \brief Free a topology parser instance.762* \param tplg Topology parser instance763*/764void snd_tplg_free(snd_tplg_t *tplg);765766/**767* \brief Parse and build topology text file into binary file.768* \param tplg Topology instance.769* \param infile Topology text input file to be parsed770* \param outfile Binary topology output file.771* \return Zero on success, otherwise a negative error code772*/773int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,774const char *outfile);775776/**777* \brief Enable verbose reporting of binary file output778* \param tplg Topology Instance779* \param verbose Enable verbose output level if non zero780*/781void snd_tplg_verbose(snd_tplg_t *tplg, int verbose);782783/** \struct snd_tplg_tlv_template784* \brief Template type for all TLV objects.785*/786struct snd_tplg_tlv_template {787int type; /*!< TLV type SNDRV_CTL_TLVT_ */788};789790/** \struct snd_tplg_tlv_dbscale_template791* \brief Template type for TLV Scale objects.792*/793struct snd_tplg_tlv_dbscale_template {794struct snd_tplg_tlv_template hdr; /*!< TLV type header */795int min; /*!< dB minimum value in 0.1dB */796int step; /*!< dB step size in 0.1dB */797int mute; /*!< is min dB value mute ? */798};799800/** \struct snd_tplg_channel_template801* \brief Template type for single channel mapping.802*/803struct snd_tplg_channel_elem {804int size; /*!< size in bytes of this structure */805int reg; /*!< channel control register */806int shift; /*!< channel shift for control bits */807int id; /*!< ID maps to Left, Right, LFE etc */808};809810/** \struct snd_tplg_channel_map_template811* \brief Template type for channel mapping.812*/813struct snd_tplg_channel_map_template {814int num_channels; /*!< number of channel mappings */815struct snd_tplg_channel_elem channel[SND_TPLG_MAX_CHAN]; /*!< mapping */816};817818/** \struct snd_tplg_pdata_template819* \brief Template type for private data objects.820*/821struct snd_tplg_pdata_template {822unsigned int length; /*!< data length */823const void *data; /*!< data */824};825826/** \struct snd_tplg_io_ops_template827* \brief Template type for object operations mapping.828*/829struct snd_tplg_io_ops_template {830int get; /*!< get callback ID */831int put; /*!< put callback ID */832int info; /*!< info callback ID */833};834835/** \struct snd_tplg_ctl_template836* \brief Template type for control objects.837*/838struct snd_tplg_ctl_template {839int type; /*!< Control type */840const char *name; /*!< Control name */841int access; /*!< Control access */842struct snd_tplg_io_ops_template ops; /*!< operations */843struct snd_tplg_tlv_template *tlv; /*!< non NULL means we have TLV data */844};845846/** \struct snd_tplg_mixer_template847* \brief Template type for mixer control objects.848*/849struct snd_tplg_mixer_template {850struct snd_tplg_ctl_template hdr; /*!< control type header */851struct snd_tplg_channel_map_template *map; /*!< channel map */852int min; /*!< min value for mixer */853int max; /*!< max value for mixer */854int platform_max; /*!< max value for platform control */855int invert; /*!< whether controls bits are inverted */856struct snd_soc_tplg_private *priv; /*!< control private data */857};858859/** \struct snd_tplg_enum_template860* \brief Template type for enumerated control objects.861*/862struct snd_tplg_enum_template {863struct snd_tplg_ctl_template hdr; /*!< control type header */864struct snd_tplg_channel_map_template *map; /*!< channel map */865int items; /*!< number of enumerated items in control */866int mask; /*!< register mask size */867const char **texts; /*!< control text items */868const int **values; /*!< control value items */869struct snd_soc_tplg_private *priv; /*!< control private data */870};871872/** \struct snd_tplg_bytes_template873* \brief Template type for TLV Scale objects.874*/875struct snd_tplg_bytes_template {876struct snd_tplg_ctl_template hdr; /*!< control type header */877int max; /*!< max byte control value */878int mask; /*!< byte control mask */879int base; /*!< base register */880int num_regs; /*!< number of registers */881struct snd_tplg_io_ops_template ext_ops; /*!< ops mapping */882struct snd_soc_tplg_private *priv; /*!< control private data */883};884885/** \struct snd_tplg_graph_elem886* \brief Template type for single DAPM graph element.887*/888struct snd_tplg_graph_elem {889const char *src; /*!< source widget name */890const char *ctl; /*!< control name or NULL if no control */891const char *sink; /*!< sink widget name */892};893894/** \struct snd_tplg_graph_template895* \brief Template type for array of DAPM graph elements.896*/897struct snd_tplg_graph_template {898int count; /*!< Number of graph elements */899struct snd_tplg_graph_elem elem[0]; /*!< graph elements */900};901902/** \struct snd_tplg_widget_template903* \brief Template type for DAPM widget objects.904*/905struct snd_tplg_widget_template {906int id; /*!< SND_SOC_DAPM_CTL */907const char *name; /*!< widget name */908const char *sname; /*!< stream name (certain widgets only) */909int reg; /*!< negative reg = no direct dapm */910int shift; /*!< bits to shift */911int mask; /*!< non-shifted mask */912int subseq; /*!< sort within widget type */913unsigned int invert; /*!< invert the power bit */914unsigned int ignore_suspend; /*!< kept enabled over suspend */915unsigned short event_flags; /*!< PM event sequence flags */916unsigned short event_type; /*!< PM event sequence type */917struct snd_soc_tplg_private *priv; /*!< widget private data */918int num_ctls; /*!< Number of controls used by widget */919struct snd_tplg_ctl_template *ctl[0]; /*!< array of widget controls */920};921922/** \struct snd_tplg_stream_template923* \brief Stream configurations.924*/925struct snd_tplg_stream_template {926const char *name; /*!< name of the stream config */927int format; /*!< SNDRV_PCM_FMTBIT_* */928int rate; /*!< SNDRV_PCM_RATE_* */929int period_bytes; /*!< size of period in bytes */930int buffer_bytes; /*!< size of buffer in bytes. */931int channels; /*!< number of channels */932};933934/** \struct snd_tplg_stream_caps_template935* \brief Stream Capabilities.936*/937struct snd_tplg_stream_caps_template {938const char *name; /*!< name of the stream caps */939uint64_t formats; /*!< supported formats SNDRV_PCM_FMTBIT_* */940unsigned int rates; /*!< supported rates SNDRV_PCM_RATE_* */941unsigned int rate_min; /*!< min rate */942unsigned int rate_max; /*!< max rate */943unsigned int channels_min; /*!< min channels */944unsigned int channels_max; /*!< max channels */945unsigned int periods_min; /*!< min number of periods */946unsigned int periods_max; /*!< max number of periods */947unsigned int period_size_min; /*!< min period size bytes */948unsigned int period_size_max; /*!< max period size bytes */949unsigned int buffer_size_min; /*!< min buffer size bytes */950unsigned int buffer_size_max; /*!< max buffer size bytes */951unsigned int sig_bits; /*!< number of bits of content */952};953954/** \struct snd_tplg_pcm_template955* \brief Template type for PCM (FE DAI & DAI links).956*/957struct snd_tplg_pcm_template {958const char *pcm_name; /*!< PCM stream name */959const char *dai_name; /*!< DAI name */960unsigned int pcm_id; /*!< unique ID - used to match */961unsigned int dai_id; /*!< unique ID - used to match */962unsigned int playback; /*!< supports playback mode */963unsigned int capture; /*!< supports capture mode */964unsigned int compress; /*!< 1 = compressed; 0 = PCM */965struct snd_tplg_stream_caps_template *caps[2]; /*!< playback & capture for DAI */966unsigned int flag_mask; /*!< bitmask of flags to configure */967unsigned int flags; /*!< flag value SND_SOC_TPLG_LNK_FLGBIT_* */968struct snd_soc_tplg_private *priv; /*!< private data */969int num_streams; /*!< number of supported configs */970struct snd_tplg_stream_template stream[0]; /*!< supported configs */971};972973/** \struct snd_tplg_hw_config_template974* \brief Template type to describe a physical link runtime supported975* hardware config, i.e. hardware audio formats.976*/977struct snd_tplg_hw_config_template {978int id; /* unique ID - - used to match */979unsigned int fmt; /* SND_SOC_DAI_FORMAT_ format value */980unsigned char clock_gated; /* 1 if clock can be gated to save power */981unsigned char invert_bclk; /* 1 for inverted BCLK, 0 for normal */982unsigned char invert_fsync; /* 1 for inverted frame clock, 0 for normal */983unsigned char bclk_master; /* 1 for master of BCLK, 0 for slave */984unsigned char fsync_master; /* 1 for master of FSYNC, 0 for slave */985unsigned char mclk_direction; /* 0 for input, 1 for output */986unsigned short reserved; /* for 32bit alignment */987unsigned int mclk_rate; /* MCLK or SYSCLK freqency in Hz */988unsigned int bclk_rate; /* BCLK freqency in Hz */989unsigned int fsync_rate; /* frame clock in Hz */990unsigned int tdm_slots; /* number of TDM slots in use */991unsigned int tdm_slot_width; /* width in bits for each slot */992unsigned int tx_slots; /* bit mask for active Tx slots */993unsigned int rx_slots; /* bit mask for active Rx slots */994unsigned int tx_channels; /* number of Tx channels */995unsigned int *tx_chanmap; /* array of slot number */996unsigned int rx_channels; /* number of Rx channels */997unsigned int *rx_chanmap; /* array of slot number */998};9991000/** \struct snd_tplg_dai_template1001* \brief Template type for physical DAI.1002* It can be used to configure backend DAIs for DPCM.1003*/1004struct snd_tplg_dai_template {1005const char *dai_name; /*!< DAI name */1006unsigned int dai_id; /*!< unique ID - used to match */1007unsigned int playback; /*!< supports playback mode */1008unsigned int capture; /*!< supports capture mode */1009struct snd_tplg_stream_caps_template *caps[2]; /*!< playback & capture for DAI */1010unsigned int flag_mask; /*!< bitmask of flags to configure */1011unsigned int flags; /*!< SND_SOC_TPLG_DAI_FLGBIT_* */1012struct snd_soc_tplg_private *priv; /*!< private data */10131014};10151016/** \struct snd_tplg_link_template1017* \brief Template type for physical DAI Links.1018*/1019struct snd_tplg_link_template {1020const char *name; /*!< link name, used to match */1021int id; /*!< unique ID - used to match with existing physical links */1022const char *stream_name; /*!< link stream name, used to match */10231024int num_streams; /*!< number of configs */1025struct snd_tplg_stream_template *stream; /*!< supported configs */10261027struct snd_tplg_hw_config_template *hw_config; /*!< supported HW configs */1028int num_hw_configs; /* number of hw configs */1029int default_hw_config_id; /* default hw config ID for init */10301031unsigned int flag_mask; /* bitmask of flags to configure */1032unsigned int flags; /* SND_SOC_TPLG_LNK_FLGBIT_* flag value */1033struct snd_soc_tplg_private *priv; /*!< private data */1034};10351036/** \struct snd_tplg_obj_template1037* \brief Generic Template Object1038*/1039typedef struct snd_tplg_obj_template {1040enum snd_tplg_type type; /*!< template object type */1041int index; /*!< group index for object */1042int version; /*!< optional vendor specific version details */1043int vendor_type; /*!< optional vendor specific type info */1044union {1045struct snd_tplg_widget_template *widget; /*!< DAPM widget */1046struct snd_tplg_mixer_template *mixer; /*!< Mixer control */1047struct snd_tplg_bytes_template *bytes_ctl; /*!< Bytes control */1048struct snd_tplg_enum_template *enum_ctl; /*!< Enum control */1049struct snd_tplg_graph_template *graph; /*!< Graph elements */1050struct snd_tplg_pcm_template *pcm; /*!< PCM elements */1051struct snd_tplg_link_template *link; /*!< physical DAI Links */1052struct snd_tplg_dai_template *dai; /*!< Physical DAI */1053};1054} snd_tplg_obj_template_t;10551056/**1057* \brief Register topology template object.1058* \param tplg Topology instance.1059* \param t Template object.1060* \return Zero on success, otherwise a negative error code1061*/1062int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t);10631064/**1065* \brief Build all registered topology data into binary file.1066* \param tplg Topology instance.1067* \param outfile Binary topology output file.1068* \return Zero on success, otherwise a negative error code1069*/1070int snd_tplg_build(snd_tplg_t *tplg, const char *outfile);10711072/**1073* \brief Attach private data to topology manifest.1074* \param tplg Topology instance.1075* \param data Private data.1076* \param len Length of data in bytes.1077* \return Zero on success, otherwise a negative error code1078*/1079int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len);10801081/**1082* \brief Set an optional vendor specific version number.1083* \param tplg Topology instance.1084* \param version Vendor specific version number.1085* \return Zero on success, otherwise a negative error code1086*/1087int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version);10881089/* \} */10901091#ifdef __cplusplus1092}1093#endif10941095#endif /* __ALSA_TOPOLOGY_H */109610971098