3 * This library is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU Lesser General Public License as
5 * published by the Free Software Foundation; either version 2.1 of
6 * the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Copyright (C) 2015 Intel Corporation
21 #ifndef __ALSA_TOPOLOGY_H
22 #define __ALSA_TOPOLOGY_H
31 * \defgroup topology Topology Interface
35 /*! \page topology ALSA Topology Interface
37 * The topology interface allows developers to define DSP topologies in a text
38 * file format and to convert the text topology to a binary topology
39 * representation that can be understood by the kernel. The topology core
40 * currently recognises the following object types :-
42 * * Controls (mixer, enumerated and byte) including TLV data.
43 * * PCMs (FE and BE configurations and capabilities)
45 * * DAPM graph elements.
46 * * Private data for each object type.
47 * * Manifest (containing count of each object type)
49 * <h3>Topology File Format</h3>
51 * The topology text format uses the standard ALSA configuration file format to
52 * describe each topology object type. This allows topology objects to include
53 * other topology objects as part of their definition. i.e. a TLV data object
54 * can be shared amongst many control objects that use the same TLV data.
58 * Topology audio controls can belong to three different types :-
60 * * Enumerated control
63 * Each control type can contain TLV data, private data, operations and also
64 * belong to widget objects.<br>
66 * <h5>Control Operations</h5>
67 * Driver Kcontrol callback info(), get() and put() operations are mapped with
68 * the CTL ops section in topology configuration files. The ctl ops section can
69 * assign operations using the standard names (listed below) for the standard
70 * kcontrol types or use ID numbers (>256) to map to bespoke driver controls.<br>
82 * This mapping shows info() using the standard "volsw" info callback whilst
83 * the get() and put() are mapped to bespoke driver callbacks. <br>
85 * The Standard operations names for control get(), put() and info calls
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 TLV
109 * The standard access flags are as follows :-
125 * <h5>Control TLV Data</h5>
126 * Controls can also use TLV data to represent dB information. This can be done
127 * by defining a TLV section and using the TLV section within the control.
128 * The TLV data for DBScale types are defined as follows :-
138 * Where the meanings and values for min, step and mute are exactly the same
139 * as defined in driver code.
141 * <h5>Control Channel Mapping</h5>
142 * Controls can also specify which channels they are mapped with. This is useful
143 * for userspace as it allows applications to determine the correct control
144 * channel for Left and Right etc. Channel maps are defined as follows :-
153 * The channel map reg is the register offset for the control, shift is the
154 * bit shift within the register for the channel and the section name is the
155 * channel name and can be one of the following :-
158 * * mono # mono stream
163 * * fc # front center
168 * * flc # front left center
169 * * frc # front right center
170 * * rlc # rear left center
171 * * rrc # rear right center
172 * * flw # front left wide
173 * * frw # front right wide
174 * * flh # front left high
175 * * fch # front center high
176 * * frh # front right high
178 * * tfl # top front left
179 * * tfr # top front right
180 * * tfc # top front center
181 * * trl # top rear left
182 * * trr # top rear right
183 * * trc # top rear center
184 * * tflc # top front left center
185 * * tfrc # top front right center
186 * * tsl # top side left
187 * * tsr # top side right
190 * * bc # bottom center
191 * * blc # bottom left center
192 * * brc # bottom right center
195 * <h5>Control Private Data</h5>
196 * Controls can also have private data. This can be done by defining a private
197 * data section and including the section within the control. The private data
198 * section is defined as follows :-
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"
209 * The file, bytes, shorts, words and tuples keywords are all mutually
210 * 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 in
212 * the topology file using the bytes, shorts, words or tuples keywords.
213 * The keyword tuples is to define vendor specific tuples. Please refer to
214 * section Vendor Tokens and Vendor tuples.
216 * <h5>How to define an element with private data</h5>
217 * An element can refer to a single data section or multiple data
220 * <h6>To refer to a single data section:</h6>
222 * Sectionxxx."element name" {
224 * data "name of data section" # optional private data
228 * <h6>To refer to multiple data sections:</h6>
230 * Sectionxxx."element name" {
232 * data [ # optional private data
233 * "name of 1st data section"
234 * "name of 2nd data section"
239 * And data of these sections will be merged in the same order as they are
240 * in the list, as the element's private data for kernel.
244 * <h6>Vendor Tokens</h6>
245 * A vendor token list is defined as a new section. Each token element is
246 * a pair of string ID and integer value. And both the ID and value are
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"
259 * <h6>Vendor Tuples</h6>
260 * Vendor tuples are defined as a new section. It contains a reference to
261 * 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 following
264 * the tuples keyword. Supported types are: string, uuid, bool, byte,
268 * SectionVendorTuples."id of the vendor tuples" {
269 * tokens "id of the vendor tokens"
272 * VENDOR_TOKEN_ID1 "character string"
276 * tuples."uuid" { # 16 characters separated by commas
277 * VENDOR_TOKEN_ID2 "0x01,0x02,...,0x0f"
282 * VENDOR_TOKEN_ID3 "true/false"
287 * VENDOR_TOKEN_ID4 "0x11"
288 * VENDOR_TOKEN_ID5 "0x22"
293 * VENDOR_TOKEN_ID6 "0x1122"
294 * VENDOR_TOKEN_ID7 "0x3344"
299 * VENDOR_TOKEN_ID8 "0x11223344"
300 * VENDOR_TOKEN_ID9 "0x55667788"
305 * To define multiple vendor tuples of same type, please append some
306 * 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:
311 * SectionVendorTuples."id of the vendor tuples" {
313 * tuples."word.module0" {
314 * VENDOR_TOKEN_PARAM_ID1 "0x00112233"
315 * VENDOR_TOKEN_PARAM_ID2 "0x44556677"
319 * tuples."word.module2" {
320 * VENDOR_TOKEN_PARAM_ID1 "0x11223344"
321 * VENDOR_TOKEN_PARAM_ID2 "0x55667788"
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 also
332 * includes a few other config options that are shown here :-
335 * SectionControlMixer."mixer name" {
336 * comment "optional comments"
338 * index "1" # Index number
340 * channel."name" { # Channel maps
344 * ops."ctl" { # Ops callback functions
348 * max "32" # Max control value
349 * invert "0" # Whether control values are inverted
351 * tlv "tld_data" # optional TLV data
353 * data "pdata for mixer1" # optional private data
357 * The section name is used to define the mixer name. The index number can be
358 * used to identify topology objects groups. This allows driver operations on
359 * objects with index number N and can be used to add/remove pipelines of
360 * objects whilst other objects are unaffected.
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 also
365 * includes a few other config options that are shown here :-
368 * SectionControlBytes."name" {
369 * comment "optional comments"
371 * index "1" # Index number
373 * channel."name" { # Channel maps
377 * ops."ctl" { # Ops callback functions
381 * base "0" # Register base
382 * num_regs "16" # Number of registers
384 * max "255" # Maximum value
386 * tlv "tld_data" # optional TLV data
388 * data "pdata for mixer1" # optional private data
392 * <h5>Enumerated Controls</h5>
393 * A enumerated control is defined as a new section (like mixer and byte) that
394 * can include channel mapping, callback operations, private data and
395 * text strings to represent the enumerated control options.<br>
397 * The text strings for the enumerated controls are defined in a separate
398 * section as follows :-
401 * SectionText."name" {
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 as
416 * SectionControlMixer."name" {
417 * comment "optional comments"
419 * index "1" # Index number
421 * texts "EQU1" # Enumerated text items
423 * channel."name" { # Channel maps
427 * ops."ctl" { # Ops callback functions
431 * data "pdata for mixer1" # optional private data
435 * <h4>DAPM Graph</h4>
436 * DAPM graphs can easily be defined using the topology file. The format is
437 * very similar to the DAPM graph kernel format. :-
440 * SectionGraph."dsp" {
441 * index "1" # Index number
444 * "sink1, control, source1"
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 have
452 * no associated controls. The section name can be used to differentiate the
453 * graph with other graphs, it's not used by the kernel atm.
455 * <h4>DAPM Widgets</h4>
456 * DAPM widgets are similar to controls in that they can include many other
457 * objects. Widgets can contain private data, mixer controls and enum controls.
459 * The following widget types are supported and match the driver types :-
478 * Widgets are defined as follows :-
481 * SectionWidget."name" {
483 * index "1" # Index number
485 * type "aif_in" # Widget type - detailed above
486 * stream_name "name" # Stream name
488 * no_pm "true" # No PM control bit.
489 * reg "20" # PM bit register offset
490 * shift "0" # PM bit register shift
491 * invert "1 # PM bit is inverted
492 * subseq "8" # subsequence number
494 * event_type "1" # DAPM widget event type
495 * event_flags "1" # DAPM widget event flags
497 * mixer "name" # Optional Mixer Control
498 * enum "name" # Optional Enum Control
500 * data "name" # optional private data
504 * The section name is the widget name. The mixer and enum fields are mutually
505 * exclusive and used to include controls into the widget. The index and data
506 * fields are the same for widgets as they are for controls whilst the other
507 * fields map on very closely to the driver widget fields.
509 * <h5>Widget Private Data</h5>
510 * Widget can have private data. For the format of the private data, please
511 * refer to section Control Private Data.
513 * <h4>PCM Capabilities</h4>
514 * Topology can also define the capabilities of FE and BE PCMs. Capabilities
515 * can be defined with the following section :-
518 * SectionPCMCapabilities."name" {
520 * formats "S24_LE,S16_LE" # Supported formats
521 * rate_min "48000" # Max supported sample rate
522 * rate_max "48000" # Min supported sample rate
523 * channels_min "2" # Min number of channels
524 * channels_max "2" # max number of channels
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 BE, PCM and
529 * Codec <-> codec topology sections.
531 * <h4>PCM Configurations</h4>
532 * PCM runtime configurations can be defined for playback and capture stream
533 * directions with the following section :-
536 * SectionPCMConfig."name" {
538 * config."playback" { # playback config
539 * format "S16_LE" # playback format
540 * rate "48000" # playback sample rate
541 * channels "2" # playback channels
542 * tdm_slot "0xf" # playback TDM slot
545 * config."capture" { # capture config
546 * format "S16_LE" # capture format
547 * rate "48000" # capture sample rate
548 * channels "2" # capture channels
549 * tdm_slot "0xf" # capture TDM slot
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 BE, PCM and
556 * Codec <-> codec topology sections.
558 * <h4>PCM Configurations</h4>
559 * PCM, BE and Codec to Codec link sections define the supported capabilities
560 * and configurations for supported playback and capture streams. The
561 * definitions and content for PCMs, BE and Codec links are the same with the
562 * exception of the section type :-
565 * SectionPCM."name" {
576 * The section types above should be used for PCMs, Back Ends and Codec to Codec
577 * links respectively.<br>
579 * The data for each section is defined as follows :-
582 * SectionPCM."name" {
584 * index "1" # Index number
586 * id "0" # used for binding to the PCM
588 * dai."name of front-end DAI" {
589 * id "0" # used for binding to the front-end DAI
593 * capabilities "capabilities1" # capabilities for playback
595 * configs [ # supported configs for playback
602 * capabilities "capabilities2" # capabilities for capture
604 * configs [ # supported configs for capture
611 * # Optional boolean flags
612 * symmetric_rates "true"
613 * symmetric_channels "true"
614 * symmetric_sample_bits "false"
616 * data "name" # optional private data
620 * <h4>Manifest Private Data</h4>
621 * Manfiest may have private data. Users need to define a manifest section
622 * and add the references to 1 or multiple data sections. Please refer to
623 * section 'How to define an element with private data'. <br>
624 * And the text conf file can have at most 1 manifest section. <br><br>
626 * Manifest section is defined as follows :-
629 * SectionManifest"name" {
631 * data "name" # optional private data
635 * <h4>Include other files</h4>
636 * Users may include other files in a text conf file via alsaconf syntax
637 * <path/to/configuration-file>. This allows users to define common info
638 * in separate files (e.g. vendor tokens, tuples) and share them for
639 * different platforms, thus save the total size of config files. <br>
640 * Users can also specifiy additional configuraiton directories relative
641 * to "/usr/share/alsa/" to search the included files, via alsaconf syntax
642 * <searchfdir:/relative-path/to/usr/share/alsa>. <br><br>
644 * For example, file A and file B are two text conf files for platform X,
645 * they will be installed to /usr/share/alsa/topology/platformx. If we
646 * need file A to include file B, in file A we can add: <br>
648 * <searchdir:topology/platformx> <br>
649 * <name-of-file-B> <br><br>
651 * ALSA conf will search and open an included file in the following order
653 * 1. directly open the file by its name;
654 * 2. search for the file name in "/usr/share/alsa";
655 * 3. search for the file name in user specified subdirectories under
658 * The order of the included files need not to be same as their
659 * dependencies, since the topology library will load them all before
660 * parsing their dependencies. <br>
662 * The configuration directories defined by a file will only be used to search
663 * the files included by this file.
666 /** Maximum number of channels supported in one control */
667 #define SND_TPLG_MAX_CHAN 8
669 /** Topology context */
670 typedef struct snd_tplg snd_tplg_t;
672 /** Topology object types */
674 SND_TPLG_TYPE_TLV = 0, /*!< TLV Data */
675 SND_TPLG_TYPE_MIXER, /*!< Mixer control*/
676 SND_TPLG_TYPE_ENUM, /*!< Enumerated control */
677 SND_TPLG_TYPE_TEXT, /*!< Text data */
678 SND_TPLG_TYPE_DATA, /*!< Private data */
679 SND_TPLG_TYPE_BYTES, /*!< Byte control */
680 SND_TPLG_TYPE_STREAM_CONFIG, /*!< PCM Stream configuration */
681 SND_TPLG_TYPE_STREAM_CAPS, /*!< PCM Stream capabilities */
682 SND_TPLG_TYPE_PCM, /*!< PCM stream device */
683 SND_TPLG_TYPE_DAPM_WIDGET, /*!< DAPM widget */
684 SND_TPLG_TYPE_DAPM_GRAPH, /*!< DAPM graph elements */
685 SND_TPLG_TYPE_BE, /*!< BE DAI link */
686 SND_TPLG_TYPE_CC, /*!< Hostless codec <-> codec link */
687 SND_TPLG_TYPE_MANIFEST, /*!< Topology manifest */
688 SND_TPLG_TYPE_TOKEN, /*!< Vendor tokens */
689 SND_TPLG_TYPE_TUPLE, /*!< Vendor tuples */
693 * \brief Create a new topology parser instance.
694 * \return New topology parser instance
696 snd_tplg_t *snd_tplg_new(void);
699 * \brief Free a topology parser instance.
700 * \param tplg Topology parser instance
702 void snd_tplg_free(snd_tplg_t *tplg);
705 * \brief Parse and build topology text file into binary file.
706 * \param tplg Topology instance.
707 * \param infile Topology text input file to be parsed
708 * \param outfile Binary topology output file.
709 * \return Zero on success, otherwise a negative error code
711 int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,
712 const char *outfile);
715 * \brief Enable verbose reporting of binary file output
716 * \param tplg Topology Instance
717 * \param verbose Enable verbose output level if non zero
719 void snd_tplg_verbose(snd_tplg_t *tplg, int verbose);
721 /** \struct snd_tplg_tlv_template
722 * \brief Template type for all TLV objects.
724 struct snd_tplg_tlv_template {
725 int type; /*!< TLV type SNDRV_CTL_TLVT_ */
728 /** \struct snd_tplg_tlv_dbscale_template
729 * \brief Template type for TLV Scale objects.
731 struct snd_tplg_tlv_dbscale_template {
732 struct snd_tplg_tlv_template hdr; /*!< TLV type header */
733 int min; /*!< dB minimum value in 0.1dB */
734 int step; /*!< dB step size in 0.1dB */
735 int mute; /*!< is min dB value mute ? */
738 /** \struct snd_tplg_channel_template
739 * \brief Template type for single channel mapping.
741 struct snd_tplg_channel_elem {
742 int size; /*!< size in bytes of this structure */
743 int reg; /*!< channel control register */
744 int shift; /*!< channel shift for control bits */
745 int id; /*!< ID maps to Left, Right, LFE etc */
748 /** \struct snd_tplg_channel_map_template
749 * \brief Template type for channel mapping.
751 struct snd_tplg_channel_map_template {
752 int num_channels; /*!< number of channel mappings */
753 struct snd_tplg_channel_elem channel[SND_TPLG_MAX_CHAN]; /*!< mapping */
756 /** \struct snd_tplg_pdata_template
757 * \brief Template type for private data objects.
759 struct snd_tplg_pdata_template {
760 unsigned int length; /*!< data length */
761 const void *data; /*!< data */
764 /** \struct snd_tplg_io_ops_template
765 * \brief Template type for object operations mapping.
767 struct snd_tplg_io_ops_template {
768 int get; /*!< get callback ID */
769 int put; /*!< put callback ID */
770 int info; /*!< info callback ID */
773 /** \struct snd_tplg_ctl_template
774 * \brief Template type for control objects.
776 struct snd_tplg_ctl_template {
777 int type; /*!< Control type */
778 const char *name; /*!< Control name */
779 int access; /*!< Control access */
780 struct snd_tplg_io_ops_template ops; /*!< operations */
781 struct snd_tplg_tlv_template *tlv; /*!< non NULL means we have TLV data */
784 /** \struct snd_tplg_mixer_template
785 * \brief Template type for mixer control objects.
787 struct snd_tplg_mixer_template {
788 struct snd_tplg_ctl_template hdr; /*!< control type header */
789 struct snd_tplg_channel_map_template *map; /*!< channel map */
790 int min; /*!< min value for mixer */
791 int max; /*!< max value for mixer */
792 int platform_max; /*!< max value for platform control */
793 int invert; /*!< whether controls bits are inverted */
794 struct snd_soc_tplg_private *priv; /*!< control private data */
797 /** \struct snd_tplg_enum_template
798 * \brief Template type for enumerated control objects.
800 struct snd_tplg_enum_template {
801 struct snd_tplg_ctl_template hdr; /*!< control type header */
802 struct snd_tplg_channel_map_template *map; /*!< channel map */
803 int items; /*!< number of enumerated items in control */
804 int mask; /*!< register mask size */
805 const char **texts; /*!< control text items */
806 const int **values; /*!< control value items */
807 struct snd_soc_tplg_private *priv; /*!< control private data */
810 /** \struct snd_tplg_bytes_template
811 * \brief Template type for TLV Scale objects.
813 struct snd_tplg_bytes_template {
814 struct snd_tplg_ctl_template hdr; /*!< control type header */
815 int max; /*!< max byte control value */
816 int mask; /*!< byte control mask */
817 int base; /*!< base register */
818 int num_regs; /*!< number of registers */
819 struct snd_tplg_io_ops_template ext_ops; /*!< ops mapping */
820 struct snd_soc_tplg_private *priv; /*!< control private data */
823 /** \struct snd_tplg_graph_elem
824 * \brief Template type for single DAPM graph element.
826 struct snd_tplg_graph_elem {
827 const char *src; /*!< source widget name */
828 const char *ctl; /*!< control name or NULL if no control */
829 const char *sink; /*!< sink widget name */
832 /** \struct snd_tplg_graph_template
833 * \brief Template type for array of DAPM graph elements.
835 struct snd_tplg_graph_template {
836 int count; /*!< Number of graph elements */
837 struct snd_tplg_graph_elem elem[0]; /*!< graph elements */
840 /** \struct snd_tplg_widget_template
841 * \brief Template type for DAPM widget objects.
843 struct snd_tplg_widget_template {
844 int id; /*!< SND_SOC_DAPM_CTL */
845 const char *name; /*!< widget name */
846 const char *sname; /*!< stream name (certain widgets only) */
847 int reg; /*!< negative reg = no direct dapm */
848 int shift; /*!< bits to shift */
849 int mask; /*!< non-shifted mask */
850 int subseq; /*!< sort within widget type */
851 unsigned int invert; /*!< invert the power bit */
852 unsigned int ignore_suspend; /*!< kept enabled over suspend */
853 unsigned short event_flags; /*!< PM event sequence flags */
854 unsigned short event_type; /*!< PM event sequence type */
855 struct snd_soc_tplg_private *priv; /*!< widget private data */
856 int num_ctls; /*!< Number of controls used by widget */
857 struct snd_tplg_ctl_template *ctl[0]; /*!< array of widget controls */
860 /** \struct snd_tplg_stream_template
861 * \brief Stream configurations.
863 struct snd_tplg_stream_template {
864 const char *name; /*!< name of the stream config */
865 int format; /*!< SNDRV_PCM_FMTBIT_* */
866 int rate; /*!< SNDRV_PCM_RATE_* */
867 int period_bytes; /*!< size of period in bytes */
868 int buffer_bytes; /*!< size of buffer in bytes. */
869 int channels; /*!< number of channels */
872 /** \struct snd_tplg_stream_caps_template
873 * \brief Stream Capabilities.
875 struct snd_tplg_stream_caps_template {
876 const char *name; /*!< name of the stream caps */
877 uint64_t formats; /*!< supported formats SNDRV_PCM_FMTBIT_* */
878 unsigned int rates; /*!< supported rates SNDRV_PCM_RATE_* */
879 unsigned int rate_min; /*!< min rate */
880 unsigned int rate_max; /*!< max rate */
881 unsigned int channels_min; /*!< min channels */
882 unsigned int channels_max; /*!< max channels */
883 unsigned int periods_min; /*!< min number of periods */
884 unsigned int periods_max; /*!< max number of periods */
885 unsigned int period_size_min; /*!< min period size bytes */
886 unsigned int period_size_max; /*!< max period size bytes */
887 unsigned int buffer_size_min; /*!< min buffer size bytes */
888 unsigned int buffer_size_max; /*!< max buffer size bytes */
889 unsigned int sig_bits; /*!< number of bits of content */
892 /** \struct snd_tplg_pcm_template
893 * \brief Template type for PCM (FE DAI & DAI links).
895 struct snd_tplg_pcm_template {
896 const char *pcm_name; /*!< PCM stream name */
897 const char *dai_name; /*!< DAI name */
898 unsigned int pcm_id; /*!< unique ID - used to match */
899 unsigned int dai_id; /*!< unique ID - used to match */
900 unsigned int playback; /*!< supports playback mode */
901 unsigned int capture; /*!< supports capture mode */
902 unsigned int compress; /*!< 1 = compressed; 0 = PCM */
903 struct snd_tplg_stream_caps_template *caps[2]; /*!< playback & capture for DAI */
904 unsigned int flag_mask; /*!< bitmask of flags to configure */
905 unsigned int flags; /*!< flag value SND_SOC_TPLG_LNK_FLGBIT_* */
906 struct snd_soc_tplg_private *priv; /*!< private data */
907 int num_streams; /*!< number of supported configs */
908 struct snd_tplg_stream_template stream[0]; /*!< supported configs */
911 /** \struct snd_tplg_link_template
912 * \brief Template type for BE and CC DAI Links.
914 struct snd_tplg_link_template {
915 const char *name; /*!< link name */
916 int id; /*!< unique ID - used to match with existing BE and CC links */
917 int num_streams; /*!< number of configs */
918 struct snd_tplg_stream_template stream[0]; /*!< supported configs */
921 /** \struct snd_tplg_obj_template
922 * \brief Generic Template Object
924 typedef struct snd_tplg_obj_template {
925 enum snd_tplg_type type; /*!< template object type */
926 int index; /*!< group index for object */
927 int version; /*!< optional vendor specific version details */
928 int vendor_type; /*!< optional vendor specific type info */
930 struct snd_tplg_widget_template *widget; /*!< DAPM widget */
931 struct snd_tplg_mixer_template *mixer; /*!< Mixer control */
932 struct snd_tplg_bytes_template *bytes_ctl; /*!< Bytes control */
933 struct snd_tplg_enum_template *enum_ctl; /*!< Enum control */
934 struct snd_tplg_graph_template *graph; /*!< Graph elements */
935 struct snd_tplg_pcm_template *pcm; /*!< PCM elements */
936 struct snd_tplg_link_template *link; /*!< BE and CC Links */
938 } snd_tplg_obj_template_t;
941 * \brief Register topology template object.
942 * \param tplg Topology instance.
943 * \param t Template object.
944 * \return Zero on success, otherwise a negative error code
946 int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t);
949 * \brief Build all registered topology data into binary file.
950 * \param tplg Topology instance.
951 * \param outfile Binary topology output file.
952 * \return Zero on success, otherwise a negative error code
954 int snd_tplg_build(snd_tplg_t *tplg, const char *outfile);
957 * \brief Attach private data to topology manifest.
958 * \param tplg Topology instance.
959 * \param data Private data.
960 * \param len Length of data in bytes.
961 * \return Zero on success, otherwise a negative error code
963 int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len);
966 * \brief Set an optional vendor specific version number.
967 * \param tplg Topology instance.
968 * \param version Vendor specific version number.
969 * \return Zero on success, otherwise a negative error code
971 int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version);
979 #endif /* __ALSA_TOPOLOGY_H */