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 
743 #define SND_TPLG_MAX_CHAN 8
744 
746 typedef struct snd_tplg snd_tplg_t;
747 
769 };
770 
772 #define SND_TPLG_INDEX_ALL 0
773 
778 snd_tplg_t *snd_tplg_new(void);
779 
784 void snd_tplg_free(snd_tplg_t *tplg);
785 
793 int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,
794  const char *outfile);
795 
801 void snd_tplg_verbose(snd_tplg_t *tplg, int verbose);
802 
807  int type;
808 };
809 
815  int min;
816  int step;
817  int mute;
818 };
819 
824  int size;
825  int reg;
826  int shift;
827  int id;
828 };
829 
836 };
837 
842  unsigned int length;
843  const void *data;
844 };
845 
850  int get;
851  int put;
852  int info;
853 };
854 
859  int type;
860  const char *name;
861  int access;
864 };
865 
872  int min;
873  int max;
875  int invert;
876  struct snd_soc_tplg_private *priv;
877 };
878 
885  int items;
886  int mask;
887  const char **texts;
888  const int **values;
889  struct snd_soc_tplg_private *priv;
890 };
891 
897  int max;
898  int mask;
899  int base;
900  int num_regs;
902  struct snd_soc_tplg_private *priv;
903 };
904 
909  const char *src;
910  const char *ctl;
911  const char *sink;
912 };
913 
918  int count;
920 };
921 
926  int id;
927  const char *name;
928  const char *sname;
929  int reg;
930  int shift;
931  int mask;
932  int subseq;
933  unsigned int invert;
934  unsigned int ignore_suspend;
935  unsigned short event_flags;
936  unsigned short event_type;
937  struct snd_soc_tplg_private *priv;
938  int num_ctls;
940 };
941 
946  const char *name;
947  int format;
948  int rate;
951  int channels;
952 };
953 
958  const char *name;
959  uint64_t formats;
960  unsigned int rates;
961  unsigned int rate_min;
962  unsigned int rate_max;
963  unsigned int channels_min;
964  unsigned int channels_max;
965  unsigned int periods_min;
966  unsigned int periods_max;
967  unsigned int period_size_min;
968  unsigned int period_size_max;
969  unsigned int buffer_size_min;
970  unsigned int buffer_size_max;
971  unsigned int sig_bits;
972 };
973 
978  const char *pcm_name;
979  const char *dai_name;
980  unsigned int pcm_id;
981  unsigned int dai_id;
982  unsigned int playback;
983  unsigned int capture;
984  unsigned int compress;
986  unsigned int flag_mask;
987  unsigned int flags;
988  struct snd_soc_tplg_private *priv;
991 };
992 
998  int id; /* unique ID - - used to match */
999  unsigned int fmt; /* SND_SOC_DAI_FORMAT_ format value */
1000  unsigned char clock_gated; /* SND_SOC_TPLG_DAI_CLK_GATE_ value */
1001  unsigned char invert_bclk; /* 1 for inverted BCLK, 0 for normal */
1002  unsigned char invert_fsync; /* 1 for inverted frame clock, 0 for normal */
1003  unsigned char bclk_master; /* SND_SOC_TPLG_BCLK_ value */
1004  unsigned char fsync_master; /* SND_SOC_TPLG_FSYNC_ value */
1005  unsigned char mclk_direction; /* SND_SOC_TPLG_MCLK_ value */
1006  unsigned short reserved; /* for 32bit alignment */
1007  unsigned int mclk_rate; /* MCLK or SYSCLK freqency in Hz */
1008  unsigned int bclk_rate; /* BCLK freqency in Hz */
1009  unsigned int fsync_rate; /* frame clock in Hz */
1010  unsigned int tdm_slots; /* number of TDM slots in use */
1011  unsigned int tdm_slot_width; /* width in bits for each slot */
1012  unsigned int tx_slots; /* bit mask for active Tx slots */
1013  unsigned int rx_slots; /* bit mask for active Rx slots */
1014  unsigned int tx_channels; /* number of Tx channels */
1015  unsigned int *tx_chanmap; /* array of slot number */
1016  unsigned int rx_channels; /* number of Rx channels */
1017  unsigned int *rx_chanmap; /* array of slot number */
1018 };
1019 
1025  const char *dai_name;
1026  unsigned int dai_id;
1027  unsigned int playback;
1028  unsigned int capture;
1030  unsigned int flag_mask;
1031  unsigned int flags;
1032  struct snd_soc_tplg_private *priv;
1034 };
1035 
1040  const char *name;
1041  int id;
1042  const char *stream_name;
1048  int num_hw_configs; /* number of hw configs */
1049  int default_hw_config_id; /* default hw config ID for init */
1050 
1051  unsigned int flag_mask; /* bitmask of flags to configure */
1052  unsigned int flags; /* SND_SOC_TPLG_LNK_FLGBIT_* flag value */
1053  struct snd_soc_tplg_private *priv;
1054 };
1055 
1059 typedef struct snd_tplg_obj_template {
1060  enum snd_tplg_type type;
1061  int index;
1062  int version;
1064  union {
1073  };
1075 
1083 
1090 int snd_tplg_build(snd_tplg_t *tplg, const char *outfile);
1091 
1099 int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len);
1100 
1107 int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version);
1108 
1109 /* \} */
1110 
1111 #ifdef __cplusplus
1112 }
1113 #endif
1114 
1115 #endif /* __ALSA_TOPOLOGY_H */
Definition: topology.h:753
struct snd_soc_tplg_private * priv
Definition: topology.h:902
const char * ctl
Definition: topology.h:910
const char * name
Definition: topology.h:958
int rate
Definition: topology.h:948
uint64_t formats
Definition: topology.h:959
int items
Definition: topology.h:885
struct snd_tplg_channel_elem channel[SND_TPLG_MAX_CHAN]
Definition: topology.h:835
int num_ctls
Definition: topology.h:938
unsigned int flags
Definition: topology.h:1031
const int ** values
Definition: topology.h:888
Template type to describe a physical link runtime supported hardware config, i.e. hardware audio form...
Definition: topology.h:997
struct snd_soc_tplg_private * priv
Definition: topology.h:937
unsigned int flag_mask
Definition: topology.h:1030
Template type for enumerated control objects.
Definition: topology.h:882
Definition: topology.h:823
unsigned int rate_min
Definition: topology.h:961
Template type for array of DAPM graph elements.
Definition: topology.h:917
Definition: topology.h:766
Definition: topology.h:762
int reg
Definition: topology.h:929
Definition: topology.h:763
Template type for DAPM widget objects.
Definition: topology.h:925
snd_tplg_type
Definition: topology.h:749
struct snd_tplg_pcm_template * pcm
Definition: topology.h:1070
int mask
Definition: topology.h:886
struct snd_tplg_enum_template * enum_ctl
Definition: topology.h:1068
struct snd_tplg_bytes_template * bytes_ctl
Definition: topology.h:1067
Definition: topology.h:759
struct snd_soc_tplg_private * priv
Definition: topology.h:876
struct snd_tplg_channel_map_template * map
Definition: topology.h:884
Definition: topology.h:758
int access
Definition: topology.h:861
Definition: topology.h:768
unsigned int dai_id
Definition: topology.h:1026
struct snd_tplg_io_ops_template ops
Definition: topology.h:862
struct snd_tplg_tlv_template hdr
Definition: topology.h:814
unsigned int ignore_suspend
Definition: topology.h:934
struct snd_tplg_stream_template stream[0]
Definition: topology.h:990
int subseq
Definition: topology.h:932
int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
Register topology template object.
Definition: parser.c:361
Definition: topology.h:751
snd_tplg_t * snd_tplg_new(void)
Create a new topology parser instance.
Definition: parser.c:454
struct snd_tplg_widget_template * widget
Definition: topology.h:1065
Template type for control objects.
Definition: topology.h:858
int platform_max
Definition: topology.h:874
struct snd_tplg_io_ops_template ext_ops
Definition: topology.h:901
unsigned int length
Definition: topology.h:842
Definition: topology.h:1059
unsigned int buffer_size_max
Definition: topology.h:970
unsigned int invert
Definition: topology.h:933
struct snd_soc_tplg_private * priv
Definition: topology.h:889
unsigned int rate_max
Definition: topology.h:962
int count
Definition: topology.h:918
const char * dai_name
Definition: topology.h:979
const char * name
Definition: topology.h:927
int format
Definition: topology.h:947
Definition: topology.h:764
struct snd_tplg_ctl_template hdr
Definition: topology.h:883
struct snd_tplg_stream_caps_template * caps[2]
Definition: topology.h:1029
struct snd_tplg snd_tplg_t
Definition: topology.h:746
int reg
Definition: topology.h:825
Template type for TLV Scale objects.
Definition: topology.h:813
int vendor_type
Definition: topology.h:1063
struct snd_tplg_ctl_template * ctl[0]
Definition: topology.h:939
Stream configurations.
Definition: topology.h:945
struct snd_tplg_ctl_template hdr
Definition: topology.h:896
void snd_tplg_free(snd_tplg_t *tplg)
Free a topology parser instance.
Definition: parser.c:491
int max
Definition: topology.h:897
unsigned int capture
Definition: topology.h:983
int max
Definition: topology.h:873
int shift
Definition: topology.h:930
int buffer_bytes
Definition: topology.h:950
int mute
Definition: topology.h:817
struct snd_tplg_graph_elem elem[0]
Definition: topology.h:919
int num_regs
Definition: topology.h:900
struct snd_tplg_mixer_template * mixer
Definition: topology.h:1066
Definition: topology.h:754
#define SND_TPLG_MAX_CHAN
Definition: topology.h:743
unsigned short event_type
Definition: topology.h:936
Generic Template Object.
Template type for PCM (FE DAI & DAI links).
Definition: topology.h:977
const char ** texts
Definition: topology.h:887
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:315
int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version)
Set an optional vendor specific version number.
Definition: parser.c:432
struct snd_soc_tplg_private * priv
Definition: topology.h:988
unsigned int buffer_size_min
Definition: topology.h:969
const char * src
Definition: topology.h:909
struct snd_tplg_dai_template * dai
Definition: topology.h:1072
Template type for single DAPM graph element.
Definition: topology.h:908
Definition: topology.h:756
int min
Definition: topology.h:815
void snd_tplg_verbose(snd_tplg_t *tplg, int verbose)
Enable verbose reporting of binary file output.
Definition: parser.c:439
struct snd_tplg_stream_caps_template * caps[2]
Definition: topology.h:985
const char * sink
Definition: topology.h:911
Template type for TLV Scale objects.
Definition: topology.h:895
int id
Definition: topology.h:926
Template type for object operations mapping.
Definition: topology.h:849
struct snd_tplg_ctl_template hdr
Definition: topology.h:870
int put
Definition: topology.h:851
unsigned int capture
Definition: topology.h:1028
struct snd_tplg_channel_map_template * map
Definition: topology.h:871
int mask
Definition: topology.h:898
unsigned int flag_mask
Definition: topology.h:986
Definition: topology.h:767
unsigned int pcm_id
Definition: topology.h:980
Template type for all TLV objects.
Definition: topology.h:806
unsigned int len
Definition: seq_event.h:198
unsigned int periods_max
Definition: topology.h:966
const char * name
Definition: topology.h:860
Template type for physical DAI. It can be used to configure backend DAIs for DPCM.
Definition: topology.h:1024
Definition: topology.h:757
Definition: topology.h:765
int mask
Definition: topology.h:931
unsigned int periods_min
Definition: topology.h:965
unsigned int sig_bits
Definition: topology.h:971
Definition: topology.h:760
unsigned short event_flags
Definition: topology.h:935
Definition: topology.h:761
Definition: topology.h:750
int shift
Definition: topology.h:826
const void * data
Definition: topology.h:843
int invert
Definition: topology.h:875
int num_streams
Definition: topology.h:989
int type
Definition: topology.h:807
int size
Definition: topology.h:824
struct snd_tplg_graph_template * graph
Definition: topology.h:1069
Template type for mixer control objects.
Definition: topology.h:869
struct snd_soc_tplg_private * priv
Definition: topology.h:1032
struct snd_tplg_link_template * link
Definition: topology.h:1071
unsigned int channels_min
Definition: topology.h:963
const char * name
Definition: topology.h:946
const char * sname
Definition: topology.h:928
unsigned int dai_id
Definition: topology.h:981
int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len)
Attach private data to topology manifest.
Definition: parser.c:417
unsigned int playback
Definition: topology.h:982
int type
Definition: topology.h:859
int channels
Definition: topology.h:951
int num_channels
Definition: topology.h:834
unsigned int period_size_min
Definition: topology.h:967
Template type for channel mapping.
Definition: topology.h:833
unsigned int period_size_max
Definition: topology.h:968
unsigned int compress
Definition: topology.h:984
int min
Definition: topology.h:872
unsigned int playback
Definition: topology.h:1027
unsigned int channels_max
Definition: topology.h:964
struct snd_tplg_tlv_template * tlv
Definition: topology.h:863
int base
Definition: topology.h:899
int info
Definition: topology.h:852
unsigned int flags
Definition: topology.h:987
int snd_tplg_build(snd_tplg_t *tplg, const char *outfile)
Build all registered topology data into binary file.
Definition: parser.c:388
int step
Definition: topology.h:816
Definition: topology.h:755
unsigned int rates
Definition: topology.h:960
int index
Definition: topology.h:1061
const char * dai_name
Definition: topology.h:1025
Template type for private data objects.
Definition: topology.h:841
int id
Definition: topology.h:827
Stream Capabilities.
Definition: topology.h:957
int period_bytes
Definition: topology.h:949
int version
Definition: topology.h:1062
Definition: topology.h:752
const char * pcm_name
Definition: topology.h:978