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 
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 
898  int min;
899  int max;
901  int invert;
902  struct snd_soc_tplg_private *priv;
903 };
904 
911  int items;
912  int mask;
913  const char **texts;
914  const int **values;
915  struct snd_soc_tplg_private *priv;
916 };
917 
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;
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;
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 */
Definition: topology.h:751
struct snd_soc_tplg_private * priv
Definition: topology.h:928
const char * ctl
Definition: topology.h:936
const char * name
Definition: topology.h:984
int rate
Definition: topology.h:974
uint64_t formats
Definition: topology.h:985
unsigned char bclk_provider
Definition: topology.h:1029
int items
Definition: topology.h:911
struct snd_tplg_channel_elem channel[SND_TPLG_MAX_CHAN]
Definition: topology.h:858
int num_ctls
Definition: topology.h:964
unsigned int flags
Definition: topology.h:1057
const int ** values
Definition: topology.h:914
Template type to describe a physical link runtime supported hardware config, i.e. hardware audio form...
Definition: topology.h:1023
struct snd_soc_tplg_private * priv
Definition: topology.h:963
unsigned int flag_mask
Definition: topology.h:1056
int snd_tplg_decode(snd_tplg_t *tplg, void *bin, size_t size, int dflags)
Decode the binary topology contents.
Definition: decoder.c:43
Template type for enumerated control objects.
Definition: topology.h:908
Template type for single channel mapping.
Definition: topology.h:846
unsigned int rate_min
Definition: topology.h:987
Template type for array of DAPM graph elements.
Definition: topology.h:943
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
unsigned int fsync_rate
Definition: topology.h:1035
Definition: topology.h:764
Definition: topology.h:760
int reg
Definition: topology.h:955
Definition: topology.h:761
Template type for DAPM widget objects.
Definition: topology.h:951
unsigned int tx_channels
Definition: topology.h:1040
snd_tplg_type
Definition: topology.h:747
struct snd_tplg_pcm_template * pcm
Definition: topology.h:1096
int mask
Definition: topology.h:912
struct snd_tplg_enum_template * enum_ctl
Definition: topology.h:1094
struct snd_tplg_bytes_template * bytes_ctl
Definition: topology.h:1093
Definition: topology.h:757
struct snd_soc_tplg_private * priv
Definition: topology.h:902
struct snd_tplg_channel_map_template * map
Definition: topology.h:910
Definition: topology.h:756
unsigned short reserved
Definition: topology.h:1032
int access
Definition: topology.h:884
unsigned char clock_gated
Definition: topology.h:1026
unsigned int * tx_chanmap
Definition: topology.h:1041
Definition: topology.h:766
unsigned int dai_id
Definition: topology.h:1052
struct snd_tplg_io_ops_template ops
Definition: topology.h:885
struct snd_tplg_tlv_template hdr
Definition: topology.h:837
unsigned int ignore_suspend
Definition: topology.h:960
struct snd_tplg_stream_template stream[0]
Definition: topology.h:1016
snd_tplg_t * snd_tplg_create(int flags)
Create a new topology parser instance.
Definition: parser.c:434
int subseq
Definition: topology.h:958
int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
Register topology template object.
Definition: parser.c:324
unsigned char invert_bclk
Definition: topology.h:1027
Definition: topology.h:749
snd_tplg_t * snd_tplg_new(void)
Create a new topology parser instance.
Definition: parser.c:474
unsigned int tx_slots
Definition: topology.h:1038
struct snd_tplg_widget_template * widget
Definition: topology.h:1091
Template type for control objects.
Definition: topology.h:881
int platform_max
Definition: topology.h:900
struct snd_tplg_io_ops_template ext_ops
Definition: topology.h:927
unsigned int length
Definition: topology.h:865
unsigned int tdm_slots
Definition: topology.h:1036
Generic Template Object.
Definition: topology.h:1085
unsigned int buffer_size_max
Definition: topology.h:996
unsigned int invert
Definition: topology.h:959
struct snd_soc_tplg_private * priv
Definition: topology.h:915
unsigned int rate_max
Definition: topology.h:988
int count
Definition: topology.h:944
unsigned char mclk_direction
Definition: topology.h:1031
const char * dai_name
Definition: topology.h:1005
const char * name
Definition: topology.h:953
int format
Definition: topology.h:973
Definition: topology.h:762
struct snd_tplg_ctl_template hdr
Definition: topology.h:909
struct snd_tplg_stream_caps_template * caps[2]
Definition: topology.h:1055
struct snd_tplg snd_tplg_t
Definition: topology.h:744
int id
Definition: topology.h:1024
int reg
Definition: topology.h:848
Template type for TLV Scale objects.
Definition: topology.h:836
int vendor_type
Definition: topology.h:1089
unsigned char fsync_provider
Definition: topology.h:1030
struct snd_tplg_ctl_template * ctl[0]
Definition: topology.h:965
Stream configurations.
Definition: topology.h:971
struct snd_tplg_ctl_template hdr
Definition: topology.h:922
void snd_tplg_free(snd_tplg_t *tplg)
Free a topology parser instance.
Definition: parser.c:479
int max
Definition: topology.h:923
unsigned int capture
Definition: topology.h:1009
int max
Definition: topology.h:899
int shift
Definition: topology.h:956
int buffer_bytes
Definition: topology.h:976
int mute
Definition: topology.h:840
struct snd_tplg_graph_elem elem[0]
Definition: topology.h:945
int num_regs
Definition: topology.h:926
unsigned int bclk_rate
Definition: topology.h:1034
unsigned int * rx_chanmap
Definition: topology.h:1043
struct snd_tplg_mixer_template * mixer
Definition: topology.h:1092
Definition: topology.h:752
#define SND_TPLG_MAX_CHAN
Definition: topology.h:741
unsigned int rx_channels
Definition: topology.h:1042
unsigned short event_type
Definition: topology.h:962
Template type for PCM (FE DAI & DAI links).
Definition: topology.h:1003
const char ** texts
Definition: topology.h:913
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
int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version)
Set an optional vendor specific version number.
Definition: parser.c:414
struct snd_soc_tplg_private * priv
Definition: topology.h:1014
unsigned int buffer_size_min
Definition: topology.h:995
const char * src
Definition: topology.h:935
struct snd_tplg_dai_template * dai
Definition: topology.h:1098
Template type for single DAPM graph element.
Definition: topology.h:934
Definition: topology.h:754
int min
Definition: topology.h:838
void snd_tplg_verbose(snd_tplg_t *tplg, int verbose)
Enable verbose reporting of binary file output.
Definition: parser.c:421
struct snd_tplg_stream_caps_template * caps[2]
Definition: topology.h:1011
const char * sink
Definition: topology.h:937
Template type for TLV Scale objects.
Definition: topology.h:921
int id
Definition: topology.h:952
Template type for object operations mapping.
Definition: topology.h:872
struct snd_tplg_ctl_template hdr
Definition: topology.h:896
int put
Definition: topology.h:874
unsigned int capture
Definition: topology.h:1054
struct snd_tplg_channel_map_template * map
Definition: topology.h:897
int mask
Definition: topology.h:924
unsigned int tdm_slot_width
Definition: topology.h:1037
unsigned int flag_mask
Definition: topology.h:1012
Definition: topology.h:765
unsigned int pcm_id
Definition: topology.h:1006
Template type for all TLV objects.
Definition: topology.h:829
unsigned int periods_max
Definition: topology.h:992
const char * name
Definition: topology.h:883
Template type for physical DAI. It can be used to configure backend DAIs for DPCM.
Definition: topology.h:1050
Definition: topology.h:755
Definition: topology.h:763
int mask
Definition: topology.h:957
unsigned int periods_min
Definition: topology.h:991
unsigned int sig_bits
Definition: topology.h:997
unsigned int rx_slots
Definition: topology.h:1039
Definition: topology.h:758
unsigned short event_flags
Definition: topology.h:961
Definition: topology.h:759
Definition: topology.h:748
int shift
Definition: topology.h:849
const void * data
Definition: topology.h:866
int invert
Definition: topology.h:901
int num_streams
Definition: topology.h:1015
int type
Definition: topology.h:830
int size
Definition: topology.h:847
struct snd_tplg_graph_template * graph
Definition: topology.h:1095
Template type for mixer control objects.
Definition: topology.h:895
struct snd_soc_tplg_private * priv
Definition: topology.h:1058
struct snd_tplg_link_template * link
Definition: topology.h:1097
unsigned int channels_min
Definition: topology.h:989
const char * name
Definition: topology.h:972
const char * sname
Definition: topology.h:954
unsigned int dai_id
Definition: topology.h:1007
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
unsigned int playback
Definition: topology.h:1008
int type
Definition: topology.h:882
struct snd_tplg_tlv_dbscale_template * tlv_scale
Definition: topology.h:888
int channels
Definition: topology.h:977
int num_channels
Definition: topology.h:857
unsigned int period_size_min
Definition: topology.h:993
Template type for channel mapping.
Definition: topology.h:856
unsigned int period_size_max
Definition: topology.h:994
unsigned int compress
Definition: topology.h:1010
int min
Definition: topology.h:898
unsigned int fmt
Definition: topology.h:1025
unsigned int playback
Definition: topology.h:1053
unsigned int channels_max
Definition: topology.h:990
int snd_tplg_load(snd_tplg_t *tplg, const char *buf, size_t size)
Load topology from the text buffer.
Definition: parser.c:261
struct snd_tplg_tlv_template * tlv
Definition: topology.h:887
int base
Definition: topology.h:925
int info
Definition: topology.h:875
unsigned int flags
Definition: topology.h:1013
int snd_tplg_build(snd_tplg_t *tplg, const char *outfile)
Build all registered topology data into binary file.
Definition: parser.c:351
int step
Definition: topology.h:839
Definition: topology.h:753
unsigned int rates
Definition: topology.h:986
int index
Definition: topology.h:1087
const char * dai_name
Definition: topology.h:1051
Template type for private data objects.
Definition: topology.h:864
int id
Definition: topology.h:850
Stream Capabilities.
Definition: topology.h:983
int period_bytes
Definition: topology.h:975
int version
Definition: topology.h:1088
unsigned char invert_fsync
Definition: topology.h:1028
unsigned int mclk_rate
Definition: topology.h:1033
Definition: topology.h:750
const char * pcm_name
Definition: topology.h:1004