OSDN Git Service

topology: add support for CTL access flags to config file
[android-x86/external-alsa-lib.git] / include / topology.h
1 /*
2  *
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.
7  *
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.
12  *
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
16  *
17  *  Copyright (C) 2015 Intel Corporation
18  *
19  */
20
21 #ifndef __ALSA_TOPOLOGY_H
22 #define __ALSA_TOPOLOGY_H
23
24 #include <stdint.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /**
31  * \defgroup topology Topology Interface
32  * \{
33  */
34
35 /*! \page topology ALSA Topology Interface
36  *
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 :-
41  *
42  *  * Controls (mixer, enumerated and byte) including TLV data.
43  *  * PCMs (FE and BE configurations and capabilities)
44  *  * DAPM widgets
45  *  * DAPM graph elements.
46  *  * 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 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.
55  *
56  *
57  * <h4>Controls</h4>
58  * Topology audio controls can belong to three different types :-
59  *   * Mixer control
60  *   * Enumerated control
61  *   * Byte control
62  *
63  * Each control type can contain TLV data, private data, operations and also
64  * belong to widget objects.<br>
65  *
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>
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 whilst
83  * the get() and put() are mapped to bespoke driver callbacks. <br>
84  *
85  * The Standard operations names for control get(), put() and info calls
86  * are :-
87  *  * volsw
88  *  * volsw_sx
89  *  * volsw_xr_sx
90  *  * enum
91  *  * bytes
92  *  * enum_value
93  *  * range
94  *  * strobe
95  *
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
99  * controls.
100  *
101  * <pre>
102  *      access [
103  *              read
104  *              write
105  *              tlv_command
106  *      ]
107  * </pre>
108  *
109  * The standard access flags are as follows :-
110  *  * read
111  *  * write
112  *  * read_write
113  *  * volatile
114  *  * timestamp
115  *  * tlv_read
116  *  * tlv_write
117  *  * tlv_read_write
118  *  * tlv_command
119  *  * inactive
120  *  * lock
121  *  * owner
122  *  * tlv_callback
123  *  * user
124  *
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 :-
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 same
139  * 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 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 :-
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 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 :-
156  *
157  * <pre>
158  *  * mono              # mono stream
159  *  * fl                # front left
160  *  * fr                # front right
161  *  * rl                # rear left
162  *  * rr                # rear right
163  *  * fc                # front center
164  *  * lfe               # LFE
165  *  * sl                # side left
166  *  * sr                # side right
167  *  * rc                # rear 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
177  *  * tc                # top center
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
188  *  * llfe              # left LFE
189  *  * rlfe              # right LFE
190  *  * bc                # bottom center
191  *  * blc               # bottom left center
192  *  * brc               # bottom right center
193  * </pre>
194  *
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 :-
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  * };
207  * </pre>
208  * The file, bytes, shorts and words keywords are all mutually exclusive as
209  * the private data should only be taken from one source.  The private data can
210  * either be read from a separate file or defined in the topology file using
211  * the bytes, shorts or words keywords.
212  *
213  * <h5>Mixer Controls</h5>
214  * A mixer control is defined as a new section that can include channel mapping,
215  * TLV data, callback operations and private data. The mixer section also
216  * includes a few other config options that are shown here :-
217  *
218  * <pre>
219  * SectionControlMixer."mixer name" {
220  *      comment "optional comments"
221  *
222  *      index "1"                       # Index number
223  *
224  *      channel."name" {                # Channel maps
225  *         ....
226  *      }
227  *
228  *      ops."ctl" {                     # Ops callback functions
229  *         ....
230  *      }
231  *
232  *      max "32"                        # Max control value
233  *      invert "0"                      # Whether control values are inverted
234  *
235  *      tlv "tld_data"                  # optional TLV data
236  *
237  *      data "pdata for mixer1"         # optional private data
238  * }
239  * </pre>
240  *
241  * The section name is used to define the mixer name. The index number can be
242  * used to identify topology objects groups. This allows driver operations on
243  * objects with index number N and can be used to add/remove pipelines of
244  * objects whilst other objects are unaffected.
245  *
246  * <h5>Byte Controls</h5>
247  * A byte control is defined as a new section that can include channel mapping,
248  * TLV data, callback operations and private data. The bytes section also
249  * includes a few other config options that are shown here :-
250  *
251  * <pre>
252  * SectionControlBytes."name" {
253  *      comment "optional comments"
254  *
255  *      index "1"                       # Index number
256  *
257  *      channel."name" {                # Channel maps
258  *         ....
259  *      }
260  *
261  *      ops."ctl" {                     # Ops callback functions
262  *         ....
263  *      }
264  *
265  *      base "0"                        # Register base
266  *      num_regs "16"                   # Number of registers
267  *      mask "0xff"                     # Mask
268  *      max "255"                       # Maximum value
269  *
270  *      tlv "tld_data"                  # optional TLV data
271  *
272  *      data "pdata for mixer1"         # optional private data
273  * }
274  * </pre>
275  *
276  * <h5>Enumerated Controls</h5>
277  * A enumerated control is defined as a new section (like mixer and byte) that
278  * can include channel mapping, callback operations, private data and
279  * text strings to represent the enumerated control options.<br>
280  *
281  * The text strings for the enumerated controls are defined in a separate
282  * section as follows :-
283  *
284  * <pre>
285  * SectionText."name" {
286  *
287  *              Values [
288  *                      "value1"
289  *                      "value2"
290                         "value3"
291  *              ]
292  * }
293  * </pre>
294  *
295  * All the enumerated text values are listed in the values list.<br>
296  * The enumerated control is similar to the other controls and defined as
297  * follows :-
298  *
299  * <pre>
300  * SectionControlMixer."name" {
301  *      comment "optional comments"
302  *
303  *      index "1"                       # Index number
304  *
305  *      texts "EQU1"                    # Enumerated text items
306  *
307  *      channel."name" {                # Channel maps
308  *         ....
309  *      }
310  *
311  *      ops."ctl" {                     # Ops callback functions
312  *         ....
313  *      }
314  *
315  *      data "pdata for mixer1"         # optional private data
316  * }
317  * </pre>
318  *
319  * <h4>DAPM Graph</h4>
320  * DAPM graphs can easily be defined using the topology file. The format is
321  * very similar to the DAPM graph kernel format. :-
322  *
323  * <pre>
324  * SectionGraph."dsp" {
325  *      index "1"                       # Index number
326  *
327  *      lines [
328  *              "sink1, control, source1"
329  *              "sink2, , source2"
330  *      ]
331  * }
332  * </pre>
333  *
334  * The lines in the graph are defined as a variable size list of sinks,
335  * controls and sources. The control name is optional as some graph lines have
336  * no associated controls. The section name can be used to differentiate the
337  * graph with other graphs, it's not used by the kernel atm.
338  *
339  * <h4>DAPM Widgets</h4>
340  * DAPM widgets are similar to controls in that they can include many other
341  * objects. Widgets can contain private data, mixer controls and enum controls.
342  *
343  * The following widget types are supported and match the driver types :-
344  *
345  *  * input
346  *  * output
347  *  * mux
348  *  * mixer
349  *  * pga
350  *  * out_drv
351  *  * adc
352  *  * dac
353  *  * switch
354  *  * pre
355  *  * post
356  *  * aif_in
357  *  * aif_out
358  *  * dai_in
359  *  * dai_out
360  *  * dai_link
361  *
362  * Widgets are defined as follows :-
363  *
364  * <pre>
365  * SectionWidget."name" {
366  *
367  *      index "1"                       # Index number
368  *
369  *      type "aif_in"                   # Widget type - detailed above
370  *
371  *      no_pm "true"                    # No PM control bit.
372  *      reg "20"                        # PM bit register offset
373  *      shift "0"                       # PM bit register shift
374  *      invert "1                       # PM bit is inverted
375  *      subseq "8"                      # subsequence number
376  *
377  *      event_type "1"                  # DAPM widget event type
378  *      event_flags "1"                 # DAPM widget event flags
379  *
380  *      mixer "name"                    # Optional Mixer Control
381  *      enum "name"                     # Optional Enum Control
382  *
383  *      data "name"                     # optional private data
384  * }
385  * </pre>
386  *
387  * The section name is the widget name. The mixer and enum fields are mutually
388  * exclusive and used to include controls into the widget. The index and data
389  * fields are the same for widgets as they are for controls whilst the other
390  * fields map on very closely to the driver widget fields.
391  *
392  * <h4>PCM Capabilities</h4>
393  * Topology can also define the capabilities of FE and BE PCMs. Capabilities
394  * can be defined with the following section :-
395  *
396  * <pre>
397  * SectionPCMCapabilities."name" {
398  *
399  *      formats "S24_LE,S16_LE"         # Supported formats
400  *      rate_min "48000"                # Max supported sample rate
401  *      rate_max "48000"                # Min supported sample rate
402  *      channels_min "2"                # Min number of channels
403  *      channels_max "2"                # max number of channels
404  * }
405  * </pre>
406  * The supported formats use the same naming convention as the driver macros.
407  * The PCM capabilities name can be referred to and included by BE, PCM and
408  * Codec <-> codec topology sections.
409  *
410  * <h4>PCM Configurations</h4>
411  * PCM runtime configurations can be defined for playback and capture stream
412  * directions with the following section  :-
413  *
414  * <pre>
415  * SectionPCMConfig."name" {
416  *
417  *      config."playback" {             # playback config
418  *              format "S16_LE"         # playback format
419  *              rate "48000"            # playback sample rate
420  *              channels "2"            # playback channels
421  *              tdm_slot "0xf"          # playback TDM slot
422  *      }
423  *
424  *      config."capture" {              # capture config
425  *              format "S16_LE"         # capture format
426  *              rate "48000"            # capture sample rate
427  *              channels "2"            # capture channels
428  *              tdm_slot "0xf"          # capture TDM slot
429  *      }
430  * }
431  * </pre>
432  *
433  * The supported formats use the same naming convention as the driver macros.
434  * The PCM configuration name can be referred to and included by BE, PCM and
435  * Codec <-> codec topology sections.
436  *
437  * <h4>PCM Configurations</h4>
438  * PCM, BE and Codec to Codec link sections define the supported capabilities
439  * and configurations for supported playback and capture streams. The
440  * definitions and content for PCMs, BE and Codec links are the same with the
441  * exception of the section type :-
442  *
443  * <pre>
444  * SectionPCM."name" {
445  *      ....
446  * }
447  * SectionBE."name" {
448  *      ....
449  * }
450  * SectionCC."name" {
451  *      ....
452  * }
453  * </pre>
454  *
455  * The section types above should be used for PCMs, Back Ends and Codec to Codec
456  * links respectively.<br>
457  *
458  * The data for each section is defined as follows :-
459  *
460  * <pre>
461  * SectionPCM."name" {
462  *
463  *      index "1"                       # Index number
464  *
465  *      id "0"                          # used for binding to the PCM
466  *
467  *      pcm."playback" {
468  *              capabilities "capabilities1"    # capabilities for playback
469  *
470  *              configs [               # supported configs for playback
471  *                      "config1"
472  *                      "config2"
473  *              ]
474  *      }
475  *
476  *      pcm."capture" {
477  *              capabilities "capabilities2"    # capabilities for capture
478  *
479  *              configs [               # supported configs for capture
480  *                      "config1"
481  *                      "config2"
482  *                      "config3"
483  *              ]
484  *      }
485  * }
486  * </pre>
487  *
488  */
489
490 /** Maximum number of channels supported in one control */
491 #define SND_TPLG_MAX_CHAN               8
492
493 /** Topology context */
494 typedef struct snd_tplg snd_tplg_t;
495
496 /** Topology object types */
497 enum snd_tplg_type {
498         SND_TPLG_TYPE_TLV = 0,          /*!< TLV Data */
499         SND_TPLG_TYPE_MIXER,            /*!< Mixer control*/
500         SND_TPLG_TYPE_ENUM,             /*!< Enumerated control */
501         SND_TPLG_TYPE_TEXT,             /*!< Text data */
502         SND_TPLG_TYPE_DATA,             /*!< Private data */
503         SND_TPLG_TYPE_BYTES,            /*!< Byte control */
504         SND_TPLG_TYPE_STREAM_CONFIG,    /*!< PCM Stream configuration */
505         SND_TPLG_TYPE_STREAM_CAPS,      /*!< PCM Stream capabilities */
506         SND_TPLG_TYPE_PCM,              /*!< PCM stream device */
507         SND_TPLG_TYPE_DAPM_WIDGET,      /*!< DAPM widget */
508         SND_TPLG_TYPE_DAPM_GRAPH,       /*!< DAPM graph elements */
509         SND_TPLG_TYPE_BE,               /*!< BE DAI link */
510         SND_TPLG_TYPE_CC,               /*!< Hostless codec <-> codec link */
511         SND_TPLG_TYPE_MANIFEST,         /*!< Topology manifest */
512 };
513
514 /**
515  * \brief Create a new topology parser instance.
516  * \return New topology parser instance
517  */
518 snd_tplg_t *snd_tplg_new(void);
519
520 /**
521  * \brief Free a topology parser instance.
522  * \param tplg Topology parser instance
523  */
524 void snd_tplg_free(snd_tplg_t *tplg);
525
526 /**
527  * \brief Parse and build topology text file into binary file.
528  * \param tplg Topology instance.
529  * \param infile Topology text input file to be parsed
530  * \param outfile Binary topology output file.
531  * \return Zero on success, otherwise a negative error code
532  */
533 int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,
534         const char *outfile);
535
536 /**
537  * \brief Enable verbose reporting of binary file output
538  * \param tplg Topology Instance
539  * \param verbose Enable verbose output level if non zero
540  */
541 void snd_tplg_verbose(snd_tplg_t *tplg, int verbose);
542
543 /** \struct snd_tplg_tlv_template
544  * \brief Template type for all TLV objects.
545  */
546 struct snd_tplg_tlv_template {
547         int type;        /*!< TLV type SNDRV_CTL_TLVT_ */
548 };
549
550 /** \struct snd_tplg_tlv_dbscale_template
551  * \brief Template type for TLV Scale objects.
552  */
553 struct snd_tplg_tlv_dbscale_template {
554         struct snd_tplg_tlv_template hdr;       /*!< TLV type header */
555         int min;                        /*!< dB minimum value in 0.1dB */
556         int step;                       /*!< dB step size in 0.1dB */
557         int mute;                       /*!< is min dB value mute ? */
558 };
559
560 /** \struct snd_tplg_channel_template
561  * \brief Template type for single channel mapping.
562  */
563 struct snd_tplg_channel_elem {
564         int size;       /*!< size in bytes of this structure */
565         int reg;        /*!< channel control register */
566         int shift;      /*!< channel shift for control bits */
567         int id;         /*!< ID maps to Left, Right, LFE etc */
568 };
569
570 /** \struct snd_tplg_channel_map_template
571  * \brief Template type for channel mapping.
572  */
573 struct snd_tplg_channel_map_template {
574         int num_channels;       /*!< number of channel mappings */
575         struct snd_tplg_channel_elem channel[SND_TPLG_MAX_CHAN];        /*!< mapping */
576 };
577
578 /** \struct snd_tplg_pdata_template
579  * \brief Template type for private data objects.
580  */
581 struct snd_tplg_pdata_template {
582         unsigned int length;    /*!< data length */
583         const void *data;       /*!< data */
584 };
585
586 /** \struct snd_tplg_io_ops_template
587  * \brief Template type for object operations mapping.
588  */
589 struct snd_tplg_io_ops_template {
590         int get;        /*!< get callback ID */
591         int put;        /*!< put callback ID */
592         int info;       /*!< info callback ID */
593 };
594
595 /** \struct snd_tplg_ctl_template
596  * \brief Template type for control objects.
597  */
598 struct snd_tplg_ctl_template {
599         int type;               /*!< Control type */
600         const char *name;       /*!< Control name */
601         int access;             /*!< Control access */
602         struct snd_tplg_io_ops_template ops;    /*!< operations */
603         struct snd_tplg_tlv_template *tlv; /*!< non NULL means we have TLV data */
604 };
605
606 /** \struct snd_tplg_mixer_template
607  * \brief Template type for mixer control objects.
608  */
609 struct snd_tplg_mixer_template {
610         struct snd_tplg_ctl_template hdr;       /*!< control type header */
611         struct snd_tplg_channel_map_template *map;      /*!< channel map */
612         int min;        /*!< min value for mixer */
613         int max;        /*!< max value for mixer */
614         int platform_max;       /*!< max value for platform control */
615         int invert;     /*!< whether controls bits are inverted */
616         struct snd_soc_tplg_private *priv;      /*!< control private data */
617 };
618
619 /** \struct snd_tplg_enum_template
620  * \brief Template type for enumerated control objects.
621  */
622 struct snd_tplg_enum_template {
623         struct snd_tplg_ctl_template hdr;       /*!< control type header */
624         struct snd_tplg_channel_map_template *map;      /*!< channel map */
625         int items;      /*!< number of enumerated items in control */
626         int mask;       /*!< register mask size */
627         const char **texts;     /*!< control text items */
628         const int **values;     /*!< control value items */
629         struct snd_soc_tplg_private *priv;      /*!< control private data */
630 };
631
632 /** \struct snd_tplg_bytes_template
633  * \brief Template type for TLV Scale objects.
634  */
635 struct snd_tplg_bytes_template {
636         struct snd_tplg_ctl_template hdr;       /*!< control type header */
637         int max;                /*!< max byte control value */
638         int mask;               /*!< byte control mask */
639         int base;               /*!< base register */
640         int num_regs;           /*!< number of registers */
641         struct snd_tplg_io_ops_template ext_ops;        /*!< ops mapping */
642         struct snd_soc_tplg_private *priv;      /*!< control private data */
643 };
644
645 /** \struct snd_tplg_graph_elem
646  * \brief Template type for single DAPM graph element.
647  */
648 struct snd_tplg_graph_elem {
649         const char *src;        /*!< source widget name */
650         const char *ctl;        /*!< control name or NULL if no control */
651         const char *sink;       /*!< sink widget name */
652 };
653
654 /** \struct snd_tplg_graph_template
655  * \brief Template type for array of DAPM graph elements.
656  */
657 struct snd_tplg_graph_template {
658         int count;              /*!< Number of graph elements */
659         struct snd_tplg_graph_elem elem[0];     /*!< graph elements */
660 };
661
662 /** \struct snd_tplg_widget_template
663  * \brief Template type for DAPM widget objects.
664  */
665 struct snd_tplg_widget_template {
666         int id;                 /*!< SND_SOC_DAPM_CTL */
667         const char *name;       /*!< widget name */
668         const char *sname;      /*!< stream name (certain widgets only) */
669         int reg;                /*!< negative reg = no direct dapm */
670         int shift;              /*!< bits to shift */
671         int mask;               /*!< non-shifted mask */
672         int subseq;             /*!< sort within widget type */
673         unsigned int invert;            /*!< invert the power bit */
674         unsigned int ignore_suspend;    /*!< kept enabled over suspend */
675         unsigned short event_flags;     /*!< PM event sequence flags */
676         unsigned short event_type;      /*!< PM event sequence type */
677         struct snd_soc_tplg_private *priv;      /*!< widget private data */
678         int num_ctls;                   /*!< Number of controls used by widget */
679         struct snd_tplg_ctl_template *ctl[0];   /*!< array of widget controls */
680 };
681
682 /** \struct snd_tplg_stream_template
683  * \brief Stream configurations.
684  */
685 struct snd_tplg_stream_template {
686         const char *name;       /*!< name of the stream config */
687         int format;             /*!< SNDRV_PCM_FMTBIT_* */
688         int rate;               /*!< SNDRV_PCM_RATE_* */
689         int period_bytes;       /*!< size of period in bytes */
690         int buffer_bytes;       /*!< size of buffer in bytes. */
691         int channels;           /*!< number of channels */
692 };
693
694 /** \struct snd_tplg_stream_caps_template
695  * \brief Stream Capabilities.
696  */
697 struct snd_tplg_stream_caps_template {
698         const char *name;       /*!< name of the stream caps */
699         uint64_t formats;       /*!< supported formats SNDRV_PCM_FMTBIT_* */
700         unsigned int rates;     /*!< supported rates SNDRV_PCM_RATE_* */
701         unsigned int rate_min;  /*!< min rate */
702         unsigned int rate_max;  /*!< max rate */
703         unsigned int channels_min;      /*!< min channels */
704         unsigned int channels_max;      /*!< max channels */
705         unsigned int periods_min;       /*!< min number of periods */
706         unsigned int periods_max;       /*!< max number of periods */
707         unsigned int period_size_min;   /*!< min period size bytes */
708         unsigned int period_size_max;   /*!< max period size bytes */
709         unsigned int buffer_size_min;   /*!< min buffer size bytes */
710         unsigned int buffer_size_max;   /*!< max buffer size bytes */
711 };
712
713 /** \struct snd_tplg_pcm_template
714  * \brief Template type for PCM (FE DAI & DAI links).
715  */
716 struct snd_tplg_pcm_template {
717         const char *pcm_name;   /*!< PCM stream name */
718         const char *dai_name;   /*!< DAI name */
719         unsigned int pcm_id;    /*!< unique ID - used to match */
720         unsigned int dai_id;    /*!< unique ID - used to match */
721         unsigned int playback;  /*!< supports playback mode */
722         unsigned int capture;   /*!< supports capture mode */
723         unsigned int compress;  /*!< 1 = compressed; 0 = PCM */
724         struct snd_tplg_stream_caps_template *caps[2]; /*!< playback & capture for DAI */
725         int num_streams;        /*!< number of supported configs */
726         struct snd_tplg_stream_template stream[0]; /*!< supported configs */
727 };
728
729 /** \struct snd_tplg_link_template
730  * \brief Template type for BE and CC DAI Links.
731  */
732 struct snd_tplg_link_template {
733         const char *name;       /*!< link name */
734         int id; /*!< unique ID - used to match with existing BE and CC links */
735         int num_streams;        /*!< number of configs */
736         struct snd_tplg_stream_template stream[0]; /*!< supported configs */
737 };
738
739 /** \struct snd_tplg_obj_template
740  * \brief Generic Template Object
741  */
742 typedef struct snd_tplg_obj_template {
743         enum snd_tplg_type type;        /*!< template object type */
744         int index;              /*!< group index for object */
745         int version;            /*!< optional vendor specific version details */
746         int vendor_type;        /*!< optional vendor specific type info */
747         union {
748                 struct snd_tplg_widget_template *widget;        /*!< DAPM widget */
749                 struct snd_tplg_mixer_template *mixer;          /*!< Mixer control */
750                 struct snd_tplg_bytes_template *bytes_ctl;      /*!< Bytes control */
751                 struct snd_tplg_enum_template *enum_ctl;        /*!< Enum control */
752                 struct snd_tplg_graph_template *graph;          /*!< Graph elements */
753                 struct snd_tplg_pcm_template *pcm;              /*!< PCM elements */
754                 struct snd_tplg_link_template *link;            /*!< BE and CC Links */
755         };
756 } snd_tplg_obj_template_t;
757
758 /**
759  * \brief Register topology template object.
760  * \param tplg Topology instance.
761  * \param t Template object.
762  * \return Zero on success, otherwise a negative error code
763  */
764 int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t);
765
766 /**
767  * \brief Build all registered topology data into binary file.
768  * \param tplg Topology instance.
769  * \param outfile Binary topology output file.
770  * \return Zero on success, otherwise a negative error code
771  */
772 int snd_tplg_build(snd_tplg_t *tplg, const char *outfile);
773
774 /**
775  * \brief Attach private data to topology manifest.
776  * \param tplg Topology instance.
777  * \param data Private data.
778  * \param len Length of data in bytes.
779  * \return Zero on success, otherwise a negative error code
780  */
781 int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len);
782
783 /**
784  * \brief Set an optional vendor specific version number.
785  * \param tplg Topology instance.
786  * \param version Vendor specific version number.
787  * \return Zero on success, otherwise a negative error code
788  */
789 int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version);
790
791 /* \} */
792
793 #ifdef __cplusplus
794 }
795 #endif
796
797 #endif /* __ALSA_TOPOLOGY_H */