|
ALSA project - the C library reference
|
00001 /* 00002 * 00003 * This library is free software; you can redistribute it and/or modify 00004 * it under the terms of the GNU Lesser General Public License as 00005 * published by the Free Software Foundation; either version 2.1 of 00006 * the License, or (at your option) any later version. 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 * GNU Lesser General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public 00014 * License along with this library; if not, write to the Free Software 00015 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 * 00017 * Copyright (C) 2015 Intel Corporation 00018 * 00019 */ 00020 00021 #ifndef __ALSA_TOPOLOGY_H 00022 #define __ALSA_TOPOLOGY_H 00023 00024 #include <stdint.h> 00025 00026 #ifdef __cplusplus 00027 extern "C" { 00028 #endif 00029 00742 #define SND_TPLG_MAX_CHAN 8 00743 00745 typedef struct snd_tplg snd_tplg_t; 00746 00748 enum snd_tplg_type { 00749 SND_TPLG_TYPE_TLV = 0, 00750 SND_TPLG_TYPE_MIXER, 00751 SND_TPLG_TYPE_ENUM, 00752 SND_TPLG_TYPE_TEXT, 00753 SND_TPLG_TYPE_DATA, 00754 SND_TPLG_TYPE_BYTES, 00755 SND_TPLG_TYPE_STREAM_CONFIG, 00756 SND_TPLG_TYPE_STREAM_CAPS, 00757 SND_TPLG_TYPE_PCM, 00758 SND_TPLG_TYPE_DAPM_WIDGET, 00759 SND_TPLG_TYPE_DAPM_GRAPH, 00760 SND_TPLG_TYPE_BE, 00761 SND_TPLG_TYPE_CC, 00762 SND_TPLG_TYPE_MANIFEST, 00763 SND_TPLG_TYPE_TOKEN, 00764 SND_TPLG_TYPE_TUPLE, 00765 SND_TPLG_TYPE_LINK, 00766 SND_TPLG_TYPE_HW_CONFIG, 00767 SND_TPLG_TYPE_DAI, 00768 }; 00769 00771 #define SND_TPLG_INDEX_ALL 0 00772 00777 snd_tplg_t *snd_tplg_new(void); 00778 00783 void snd_tplg_free(snd_tplg_t *tplg); 00784 00792 int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile, 00793 const char *outfile); 00794 00800 void snd_tplg_verbose(snd_tplg_t *tplg, int verbose); 00801 00805 struct snd_tplg_tlv_template { 00806 int type; 00807 }; 00808 00812 struct snd_tplg_tlv_dbscale_template { 00813 struct snd_tplg_tlv_template hdr; 00814 int min; 00815 int step; 00816 int mute; 00817 }; 00818 00822 struct snd_tplg_channel_elem { 00823 int size; 00824 int reg; 00825 int shift; 00826 int id; 00827 }; 00828 00832 struct snd_tplg_channel_map_template { 00833 int num_channels; 00834 struct snd_tplg_channel_elem channel[SND_TPLG_MAX_CHAN]; 00835 }; 00836 00840 struct snd_tplg_pdata_template { 00841 unsigned int length; 00842 const void *data; 00843 }; 00844 00848 struct snd_tplg_io_ops_template { 00849 int get; 00850 int put; 00851 int info; 00852 }; 00853 00857 struct snd_tplg_ctl_template { 00858 int type; 00859 const char *name; 00860 int access; 00861 struct snd_tplg_io_ops_template ops; 00862 struct snd_tplg_tlv_template *tlv; 00863 }; 00864 00868 struct snd_tplg_mixer_template { 00869 struct snd_tplg_ctl_template hdr; 00870 struct snd_tplg_channel_map_template *map; 00871 int min; 00872 int max; 00873 int platform_max; 00874 int invert; 00875 struct snd_soc_tplg_private *priv; 00876 }; 00877 00881 struct snd_tplg_enum_template { 00882 struct snd_tplg_ctl_template hdr; 00883 struct snd_tplg_channel_map_template *map; 00884 int items; 00885 int mask; 00886 const char **texts; 00887 const int **values; 00888 struct snd_soc_tplg_private *priv; 00889 }; 00890 00894 struct snd_tplg_bytes_template { 00895 struct snd_tplg_ctl_template hdr; 00896 int max; 00897 int mask; 00898 int base; 00899 int num_regs; 00900 struct snd_tplg_io_ops_template ext_ops; 00901 struct snd_soc_tplg_private *priv; 00902 }; 00903 00907 struct snd_tplg_graph_elem { 00908 const char *src; 00909 const char *ctl; 00910 const char *sink; 00911 }; 00912 00916 struct snd_tplg_graph_template { 00917 int count; 00918 struct snd_tplg_graph_elem elem[0]; 00919 }; 00920 00924 struct snd_tplg_widget_template { 00925 int id; 00926 const char *name; 00927 const char *sname; 00928 int reg; 00929 int shift; 00930 int mask; 00931 int subseq; 00932 unsigned int invert; 00933 unsigned int ignore_suspend; 00934 unsigned short event_flags; 00935 unsigned short event_type; 00936 struct snd_soc_tplg_private *priv; 00937 int num_ctls; 00938 struct snd_tplg_ctl_template *ctl[0]; 00939 }; 00940 00944 struct snd_tplg_stream_template { 00945 const char *name; 00946 int format; 00947 int rate; 00948 int period_bytes; 00949 int buffer_bytes; 00950 int channels; 00951 }; 00952 00956 struct snd_tplg_stream_caps_template { 00957 const char *name; 00958 uint64_t formats; 00959 unsigned int rates; 00960 unsigned int rate_min; 00961 unsigned int rate_max; 00962 unsigned int channels_min; 00963 unsigned int channels_max; 00964 unsigned int periods_min; 00965 unsigned int periods_max; 00966 unsigned int period_size_min; 00967 unsigned int period_size_max; 00968 unsigned int buffer_size_min; 00969 unsigned int buffer_size_max; 00970 unsigned int sig_bits; 00971 }; 00972 00976 struct snd_tplg_pcm_template { 00977 const char *pcm_name; 00978 const char *dai_name; 00979 unsigned int pcm_id; 00980 unsigned int dai_id; 00981 unsigned int playback; 00982 unsigned int capture; 00983 unsigned int compress; 00984 struct snd_tplg_stream_caps_template *caps[2]; 00985 unsigned int flag_mask; 00986 unsigned int flags; 00987 struct snd_soc_tplg_private *priv; 00988 int num_streams; 00989 struct snd_tplg_stream_template stream[0]; 00990 }; 00991 00996 struct snd_tplg_hw_config_template { 00997 int id; /* unique ID - - used to match */ 00998 unsigned int fmt; /* SND_SOC_DAI_FORMAT_ format value */ 00999 unsigned char clock_gated; /* 1 if clock can be gated to save power */ 01000 unsigned char invert_bclk; /* 1 for inverted BCLK, 0 for normal */ 01001 unsigned char invert_fsync; /* 1 for inverted frame clock, 0 for normal */ 01002 unsigned char bclk_master; /* 1 for master of BCLK, 0 for slave */ 01003 unsigned char fsync_master; /* 1 for master of FSYNC, 0 for slave */ 01004 unsigned char mclk_direction; /* 0 for input, 1 for output */ 01005 unsigned short reserved; /* for 32bit alignment */ 01006 unsigned int mclk_rate; /* MCLK or SYSCLK freqency in Hz */ 01007 unsigned int bclk_rate; /* BCLK freqency in Hz */ 01008 unsigned int fsync_rate; /* frame clock in Hz */ 01009 unsigned int tdm_slots; /* number of TDM slots in use */ 01010 unsigned int tdm_slot_width; /* width in bits for each slot */ 01011 unsigned int tx_slots; /* bit mask for active Tx slots */ 01012 unsigned int rx_slots; /* bit mask for active Rx slots */ 01013 unsigned int tx_channels; /* number of Tx channels */ 01014 unsigned int *tx_chanmap; /* array of slot number */ 01015 unsigned int rx_channels; /* number of Rx channels */ 01016 unsigned int *rx_chanmap; /* array of slot number */ 01017 }; 01018 01023 struct snd_tplg_dai_template { 01024 const char *dai_name; 01025 unsigned int dai_id; 01026 unsigned int playback; 01027 unsigned int capture; 01028 struct snd_tplg_stream_caps_template *caps[2]; 01029 unsigned int flag_mask; 01030 unsigned int flags; 01031 struct snd_soc_tplg_private *priv; 01033 }; 01034 01038 struct snd_tplg_link_template { 01039 const char *name; 01040 int id; 01041 const char *stream_name; 01043 int num_streams; 01044 struct snd_tplg_stream_template *stream; 01046 struct snd_tplg_hw_config_template *hw_config; 01047 int num_hw_configs; /* number of hw configs */ 01048 int default_hw_config_id; /* default hw config ID for init */ 01049 01050 unsigned int flag_mask; /* bitmask of flags to configure */ 01051 unsigned int flags; /* SND_SOC_TPLG_LNK_FLGBIT_* flag value */ 01052 struct snd_soc_tplg_private *priv; 01053 }; 01054 01058 typedef struct snd_tplg_obj_template { 01059 enum snd_tplg_type type; 01060 int index; 01061 int version; 01062 int vendor_type; 01063 union { 01064 struct snd_tplg_widget_template *widget; 01065 struct snd_tplg_mixer_template *mixer; 01066 struct snd_tplg_bytes_template *bytes_ctl; 01067 struct snd_tplg_enum_template *enum_ctl; 01068 struct snd_tplg_graph_template *graph; 01069 struct snd_tplg_pcm_template *pcm; 01070 struct snd_tplg_link_template *link; 01071 struct snd_tplg_dai_template *dai; 01072 }; 01073 } snd_tplg_obj_template_t; 01074 01081 int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t); 01082 01089 int snd_tplg_build(snd_tplg_t *tplg, const char *outfile); 01090 01098 int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len); 01099 01106 int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version); 01107 01108 /* \} */ 01109 01110 #ifdef __cplusplus 01111 } 01112 #endif 01113 01114 #endif /* __ALSA_TOPOLOGY_H */
1.7.3