ALSA project - the C library reference
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 
741 #define SND_TPLG_MAX_CHAN 8
742 
744 typedef struct snd_tplg snd_tplg_t;
745 
767 };
768 
770 #define SND_TPLG_INDEX_ALL 0
771 
773 #define SND_TPLG_CREATE_VERBOSE (1<<0)
774 #define SND_TPLG_CREATE_DAPM_NOSORT (1<<1)
780 const char *snd_tplg_version(void);
781 
786 snd_tplg_t *snd_tplg_new(void);
787 
792 snd_tplg_t *snd_tplg_create(int flags);
793 
798 void snd_tplg_free(snd_tplg_t *tplg);
799 
807 int snd_tplg_load(snd_tplg_t *tplg, const char *buf, size_t size);
808 
816 int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,
817  const char *outfile);
818 
824 void snd_tplg_verbose(snd_tplg_t *tplg, int verbose);
825 
830  int type;
831 };
832 
837  struct snd_tplg_tlv_template hdr;
838  int min;
839  int step;
840  int mute;
841 };
842 
847  int size;
848  int reg;
849  int shift;
850  int id;
851 };
852 
859 };
860 
865  unsigned int length;
866  const void *data;
867 };
868 
873  int get;
874  int put;
875  int info;
876 };
877 
882  int type;
883  const char *name;
884  int access;
886  union {
889  };
890 };
891 
896  struct snd_tplg_ctl_template hdr;
898  int min;
899  int max;
901  int invert;
902  struct snd_soc_tplg_private *priv;
903 };
904 
909  struct snd_tplg_ctl_template hdr;
911  int items;
912  int mask;
913  const char **texts;
914  const int **values;
915  struct snd_soc_tplg_private *priv;
916 };
917 
922  struct snd_tplg_ctl_template hdr;
923  int max;
924  int mask;
925  int base;
926  int num_regs;
928  struct snd_soc_tplg_private *priv;
929 };
930 
935  const char *src;
936  const char *ctl;
937  const char *sink;
938 };
939 
944  int count;
945  struct snd_tplg_graph_elem elem[0];
946 };
947 
952  int id;
953  const char *name;
954  const char *sname;
955  int reg;
956  int shift;
957  int mask;
958  int subseq;
959  unsigned int invert;
960  unsigned int ignore_suspend;
961  unsigned short event_flags;
962  unsigned short event_type;
963  struct snd_soc_tplg_private *priv;
964  int num_ctls;
966 };
967 
972  const char *name;
973  int format;
974  int rate;
977  int channels;
978 };
979 
984  const char *name;
985  uint64_t formats;
986  unsigned int rates;
987  unsigned int rate_min;
988  unsigned int rate_max;
989  unsigned int channels_min;
990  unsigned int channels_max;
991  unsigned int periods_min;
992  unsigned int periods_max;
993  unsigned int period_size_min;
994  unsigned int period_size_max;
995  unsigned int buffer_size_min;
996  unsigned int buffer_size_max;
997  unsigned int sig_bits;
998 };
999 
1004  const char *pcm_name;
1005  const char *dai_name;
1006  unsigned int pcm_id;
1007  unsigned int dai_id;
1008  unsigned int playback;
1009  unsigned int capture;
1010  unsigned int compress;
1012  unsigned int flag_mask;
1013  unsigned int flags;
1014  struct snd_soc_tplg_private *priv;
1016  struct snd_tplg_stream_template stream[0];
1017 };
1018 
1024  int id;
1025  unsigned int fmt;
1026  unsigned char clock_gated;
1027  unsigned char invert_bclk;
1028  unsigned char invert_fsync;
1029  unsigned char bclk_provider;
1030  unsigned char fsync_provider;
1031  unsigned char mclk_direction;
1032  unsigned short reserved;
1033  unsigned int mclk_rate;
1034  unsigned int bclk_rate;
1035  unsigned int fsync_rate;
1036  unsigned int tdm_slots;
1037  unsigned int tdm_slot_width;
1038  unsigned int tx_slots;
1039  unsigned int rx_slots;
1040  unsigned int tx_channels;
1041  unsigned int *tx_chanmap;
1042  unsigned int rx_channels;
1043  unsigned int *rx_chanmap;
1044 };
1045 
1051  const char *dai_name;
1052  unsigned int dai_id;
1053  unsigned int playback;
1054  unsigned int capture;
1056  unsigned int flag_mask;
1057  unsigned int flags;
1058  struct snd_soc_tplg_private *priv;
1060 };
1061 
1066  const char *name;
1067  int id;
1068  const char *stream_name;
1077  unsigned int flag_mask;
1078  unsigned int flags;
1079  struct snd_soc_tplg_private *priv;
1080 };
1081 
1085 typedef struct snd_tplg_obj_template {
1086  enum snd_tplg_type type;
1087  int index;
1088  int version;
1090  union {
1099  };
1101 
1109 
1116 int snd_tplg_build(snd_tplg_t *tplg, const char *outfile);
1117 
1125 int snd_tplg_build_bin(snd_tplg_t *tplg, void **bin, size_t *size);
1126 
1134 int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len);
1135 
1142 int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version);
1143 
1144 /*
1145  * Flags for the snd_tplg_save()
1146  */
1147 #define SND_TPLG_SAVE_SORT (1<<0)
1148 #define SND_TPLG_SAVE_GROUPS (1<<1)
1149 #define SND_TPLG_SAVE_NOCHECK (1<<16)
1163 int snd_tplg_save(snd_tplg_t *tplg, char **dst, int flags);
1164 
1173 int snd_tplg_decode(snd_tplg_t *tplg, void *bin, size_t size, int dflags);
1174 
1177 #ifdef __cplusplus
1178 }
1179 #endif
1180 
1181 #endif /* __ALSA_TOPOLOGY_H */
int snd_tplg_save(snd_tplg_t *tplg, char **dst, int flags)
Save the topology to the text configuration string.
Definition: save.c:557
int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
Register topology template object.
Definition: parser.c:324
#define SND_TPLG_MAX_CHAN
Definition: topology.h:741
int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile, const char *outfile)
Parse and build topology text file into binary file.
Definition: parser.c:295
snd_tplg_t * snd_tplg_new(void)
Create a new topology parser instance.
Definition: parser.c:474
int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version)
Set an optional vendor specific version number.
Definition: parser.c:414
int snd_tplg_build_bin(snd_tplg_t *tplg, void **bin, size_t *size)
Build all registered topology data into memory.
Definition: parser.c:379
snd_tplg_type
Definition: topology.h:747
int snd_tplg_decode(snd_tplg_t *tplg, void *bin, size_t size, int dflags)
Decode the binary topology contents.
Definition: decoder.c:43
int snd_tplg_build(snd_tplg_t *tplg, const char *outfile)
Build all registered topology data into binary file.
Definition: parser.c:351
const char * snd_tplg_version(void)
Return the version of the topology library.
Definition: parser.c:506
struct snd_tplg snd_tplg_t
Definition: topology.h:744
int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len)
Attach private data to topology manifest.
Definition: parser.c:395
void snd_tplg_verbose(snd_tplg_t *tplg, int verbose)
Enable verbose reporting of binary file output.
Definition: parser.c:421
int snd_tplg_load(snd_tplg_t *tplg, const char *buf, size_t size)
Load topology from the text buffer.
Definition: parser.c:261
snd_tplg_t * snd_tplg_create(int flags)
Create a new topology parser instance.
Definition: parser.c:434
void snd_tplg_free(snd_tplg_t *tplg)
Free a topology parser instance.
Definition: parser.c:479
@ SND_TPLG_TYPE_TEXT
Definition: topology.h:751
@ SND_TPLG_TYPE_MANIFEST
Definition: topology.h:761
@ SND_TPLG_TYPE_STREAM_CAPS
Definition: topology.h:755
@ SND_TPLG_TYPE_STREAM_CONFIG
Definition: topology.h:754
@ SND_TPLG_TYPE_TOKEN
Definition: topology.h:762
@ SND_TPLG_TYPE_HW_CONFIG
Definition: topology.h:765
@ SND_TPLG_TYPE_DATA
Definition: topology.h:752
@ SND_TPLG_TYPE_DAPM_GRAPH
Definition: topology.h:758
@ SND_TPLG_TYPE_DAI
Definition: topology.h:766
@ SND_TPLG_TYPE_LINK
Definition: topology.h:764
@ SND_TPLG_TYPE_CC
Definition: topology.h:760
@ SND_TPLG_TYPE_BE
Definition: topology.h:759
@ SND_TPLG_TYPE_MIXER
Definition: topology.h:749
@ SND_TPLG_TYPE_TLV
Definition: topology.h:748
@ SND_TPLG_TYPE_PCM
Definition: topology.h:756
@ SND_TPLG_TYPE_BYTES
Definition: topology.h:753
@ SND_TPLG_TYPE_TUPLE
Definition: topology.h:763
@ SND_TPLG_TYPE_ENUM
Definition: topology.h:750
@ SND_TPLG_TYPE_DAPM_WIDGET
Definition: topology.h:757
Template type for TLV Scale objects.
Definition: topology.h:921
struct snd_soc_tplg_private * priv
Definition: topology.h:928
int base
Definition: topology.h:925
int max
Definition: topology.h:923
struct snd_tplg_ctl_template hdr
Definition: topology.h:922
struct snd_tplg_io_ops_template ext_ops
Definition: topology.h:927
int mask
Definition: topology.h:924
int num_regs
Definition: topology.h:926
Template type for single channel mapping.
Definition: topology.h:846
int size
Definition: topology.h:847
int shift
Definition: topology.h:849
int id
Definition: topology.h:850
int reg
Definition: topology.h:848
Template type for channel mapping.
Definition: topology.h:856
int num_channels
Definition: topology.h:857
struct snd_tplg_channel_elem channel[SND_TPLG_MAX_CHAN]
Definition: topology.h:858
Template type for control objects.
Definition: topology.h:881
int access
Definition: topology.h:884
int type
Definition: topology.h:882
struct snd_tplg_io_ops_template ops
Definition: topology.h:885
struct snd_tplg_tlv_dbscale_template * tlv_scale
Definition: topology.h:888
const char * name
Definition: topology.h:883
struct snd_tplg_tlv_template * tlv
Definition: topology.h:887
Template type for physical DAI. It can be used to configure backend DAIs for DPCM.
Definition: topology.h:1050
unsigned int flags
Definition: topology.h:1057
struct snd_soc_tplg_private * priv
Definition: topology.h:1058
const char * dai_name
Definition: topology.h:1051
unsigned int capture
Definition: topology.h:1054
unsigned int dai_id
Definition: topology.h:1052
unsigned int playback
Definition: topology.h:1053
struct snd_tplg_stream_caps_template * caps[2]
Definition: topology.h:1055
unsigned int flag_mask
Definition: topology.h:1056
Template type for enumerated control objects.
Definition: topology.h:908
const int ** values
Definition: topology.h:914
struct snd_soc_tplg_private * priv
Definition: topology.h:915
const char ** texts
Definition: topology.h:913
struct snd_tplg_ctl_template hdr
Definition: topology.h:909
struct snd_tplg_channel_map_template * map
Definition: topology.h:910
int mask
Definition: topology.h:912
int items
Definition: topology.h:911
Template type for single DAPM graph element.
Definition: topology.h:934
const char * src
Definition: topology.h:935
const char * sink
Definition: topology.h:937
const char * ctl
Definition: topology.h:936
Template type for array of DAPM graph elements.
Definition: topology.h:943
struct snd_tplg_graph_elem elem[0]
Definition: topology.h:945
int count
Definition: topology.h:944
Template type to describe a physical link runtime supported hardware config, i.e. hardware audio form...
Definition: topology.h:1023
unsigned int * rx_chanmap
Definition: topology.h:1043
unsigned char fsync_provider
Definition: topology.h:1030
unsigned int tx_channels
Definition: topology.h:1040
unsigned int rx_slots
Definition: topology.h:1039
unsigned int tdm_slot_width
Definition: topology.h:1037
unsigned int fmt
Definition: topology.h:1025
unsigned int mclk_rate
Definition: topology.h:1033
unsigned int tdm_slots
Definition: topology.h:1036
unsigned char bclk_provider
Definition: topology.h:1029
unsigned int bclk_rate
Definition: topology.h:1034
unsigned int rx_channels
Definition: topology.h:1042
unsigned char invert_bclk
Definition: topology.h:1027
unsigned short reserved
Definition: topology.h:1032
unsigned char clock_gated
Definition: topology.h:1026
unsigned int * tx_chanmap
Definition: topology.h:1041
unsigned char mclk_direction
Definition: topology.h:1031
int id
Definition: topology.h:1024
unsigned int fsync_rate
Definition: topology.h:1035
unsigned int tx_slots
Definition: topology.h:1038
unsigned char invert_fsync
Definition: topology.h:1028
Template type for object operations mapping.
Definition: topology.h:872
int info
Definition: topology.h:875
int get
Definition: topology.h:873
int put
Definition: topology.h:874
Template type for mixer control objects.
Definition: topology.h:895
struct snd_soc_tplg_private * priv
Definition: topology.h:902
struct snd_tplg_ctl_template hdr
Definition: topology.h:896
int invert
Definition: topology.h:901
int min
Definition: topology.h:898
int max
Definition: topology.h:899
int platform_max
Definition: topology.h:900
struct snd_tplg_channel_map_template * map
Definition: topology.h:897
Generic Template Object.
Definition: topology.h:1085
struct snd_tplg_link_template * link
Definition: topology.h:1097
struct snd_tplg_dai_template * dai
Definition: topology.h:1098
int version
Definition: topology.h:1088
struct snd_tplg_bytes_template * bytes_ctl
Definition: topology.h:1093
struct snd_tplg_pcm_template * pcm
Definition: topology.h:1096
struct snd_tplg_graph_template * graph
Definition: topology.h:1095
int vendor_type
Definition: topology.h:1089
struct snd_tplg_enum_template * enum_ctl
Definition: topology.h:1094
struct snd_tplg_widget_template * widget
Definition: topology.h:1091
struct snd_tplg_mixer_template * mixer
Definition: topology.h:1092
int index
Definition: topology.h:1087
Template type for PCM (FE DAI & DAI links).
Definition: topology.h:1003
unsigned int playback
Definition: topology.h:1008
unsigned int flags
Definition: topology.h:1013
const char * pcm_name
Definition: topology.h:1004
const char * dai_name
Definition: topology.h:1005
int num_streams
Definition: topology.h:1015
unsigned int capture
Definition: topology.h:1009
struct snd_tplg_stream_caps_template * caps[2]
Definition: topology.h:1011
struct snd_soc_tplg_private * priv
Definition: topology.h:1014
struct snd_tplg_stream_template stream[0]
Definition: topology.h:1016
unsigned int dai_id
Definition: topology.h:1007
unsigned int flag_mask
Definition: topology.h:1012
unsigned int compress
Definition: topology.h:1010
unsigned int pcm_id
Definition: topology.h:1006
Template type for private data objects.
Definition: topology.h:864
const void * data
Definition: topology.h:866
unsigned int length
Definition: topology.h:865
Stream Capabilities.
Definition: topology.h:983
unsigned int periods_min
Definition: topology.h:991
unsigned int rate_max
Definition: topology.h:988
unsigned int rates
Definition: topology.h:986
unsigned int buffer_size_max
Definition: topology.h:996
unsigned int period_size_max
Definition: topology.h:994
unsigned int periods_max
Definition: topology.h:992
uint64_t formats
Definition: topology.h:985
unsigned int period_size_min
Definition: topology.h:993
unsigned int channels_min
Definition: topology.h:989
unsigned int channels_max
Definition: topology.h:990
unsigned int sig_bits
Definition: topology.h:997
const char * name
Definition: topology.h:984
unsigned int rate_min
Definition: topology.h:987
unsigned int buffer_size_min
Definition: topology.h:995
Stream configurations.
Definition: topology.h:971
int period_bytes
Definition: topology.h:975
const char * name
Definition: topology.h:972
int format
Definition: topology.h:973
int channels
Definition: topology.h:977
int rate
Definition: topology.h:974
int buffer_bytes
Definition: topology.h:976
Template type for TLV Scale objects.
Definition: topology.h:836
struct snd_tplg_tlv_template hdr
Definition: topology.h:837
int min
Definition: topology.h:838
int mute
Definition: topology.h:840
int step
Definition: topology.h:839
Template type for all TLV objects.
Definition: topology.h:829
int type
Definition: topology.h:830
Template type for DAPM widget objects.
Definition: topology.h:951
int id
Definition: topology.h:952
struct snd_tplg_ctl_template * ctl[0]
Definition: topology.h:965
int subseq
Definition: topology.h:958
const char * sname
Definition: topology.h:954
unsigned int ignore_suspend
Definition: topology.h:960
unsigned short event_flags
Definition: topology.h:961
int num_ctls
Definition: topology.h:964
unsigned short event_type
Definition: topology.h:962
int reg
Definition: topology.h:955
int mask
Definition: topology.h:957
struct snd_soc_tplg_private * priv
Definition: topology.h:963
unsigned int invert
Definition: topology.h:959
const char * name
Definition: topology.h:953
int shift
Definition: topology.h:956