1 /* SPDX-License-Identifier: GPL-2.0 1 /* SPDX-License-Identifier: GPL-2.0 2 * 2 * 3 * linux/sound/soc-topology.h -- ALSA SoC Firm 3 * linux/sound/soc-topology.h -- ALSA SoC Firmware Controls and DAPM 4 * 4 * 5 * Copyright (C) 2012 Texas Instruments Inc. 5 * Copyright (C) 2012 Texas Instruments Inc. 6 * Copyright (C) 2015 Intel Corporation. 6 * Copyright (C) 2015 Intel Corporation. 7 * 7 * 8 * Simple file API to load FW that includes mi 8 * Simple file API to load FW that includes mixers, coefficients, DAPM graphs, 9 * algorithms, equalisers, DAIs, widgets, FE c 9 * algorithms, equalisers, DAIs, widgets, FE caps, BE caps, codec link caps etc. 10 */ 10 */ 11 11 12 #ifndef __LINUX_SND_SOC_TPLG_H 12 #ifndef __LINUX_SND_SOC_TPLG_H 13 #define __LINUX_SND_SOC_TPLG_H 13 #define __LINUX_SND_SOC_TPLG_H 14 14 15 #include <sound/asoc.h> 15 #include <sound/asoc.h> 16 #include <linux/list.h> 16 #include <linux/list.h> 17 17 18 struct firmware; 18 struct firmware; 19 struct snd_kcontrol; 19 struct snd_kcontrol; 20 struct snd_soc_tplg_pcm_be; 20 struct snd_soc_tplg_pcm_be; 21 struct snd_ctl_elem_value; 21 struct snd_ctl_elem_value; 22 struct snd_ctl_elem_info; 22 struct snd_ctl_elem_info; 23 struct snd_soc_dapm_widget; 23 struct snd_soc_dapm_widget; 24 struct snd_soc_component; 24 struct snd_soc_component; 25 struct snd_soc_tplg_pcm_fe; 25 struct snd_soc_tplg_pcm_fe; 26 struct snd_soc_dapm_context; 26 struct snd_soc_dapm_context; 27 struct snd_soc_card; 27 struct snd_soc_card; 28 struct snd_kcontrol_new; 28 struct snd_kcontrol_new; 29 struct snd_soc_dai_link; 29 struct snd_soc_dai_link; 30 struct snd_soc_dai_driver; 30 struct snd_soc_dai_driver; 31 struct snd_soc_dai; 31 struct snd_soc_dai; 32 struct snd_soc_dapm_route; 32 struct snd_soc_dapm_route; 33 33 >> 34 /* object scan be loaded and unloaded in groups with identfying indexes */ >> 35 #define SND_SOC_TPLG_INDEX_ALL 0 /* ID that matches all FW objects */ >> 36 34 /* dynamic object type */ 37 /* dynamic object type */ 35 enum snd_soc_dobj_type { 38 enum snd_soc_dobj_type { 36 SND_SOC_DOBJ_NONE = 0, 39 SND_SOC_DOBJ_NONE = 0, /* object is not dynamic */ 37 SND_SOC_DOBJ_MIXER, 40 SND_SOC_DOBJ_MIXER, 38 SND_SOC_DOBJ_BYTES, 41 SND_SOC_DOBJ_BYTES, 39 SND_SOC_DOBJ_ENUM, 42 SND_SOC_DOBJ_ENUM, 40 SND_SOC_DOBJ_GRAPH, 43 SND_SOC_DOBJ_GRAPH, 41 SND_SOC_DOBJ_WIDGET, 44 SND_SOC_DOBJ_WIDGET, 42 SND_SOC_DOBJ_DAI_LINK, 45 SND_SOC_DOBJ_DAI_LINK, 43 SND_SOC_DOBJ_PCM, 46 SND_SOC_DOBJ_PCM, 44 SND_SOC_DOBJ_CODEC_LINK, 47 SND_SOC_DOBJ_CODEC_LINK, 45 SND_SOC_DOBJ_BACKEND_LINK, 48 SND_SOC_DOBJ_BACKEND_LINK, 46 }; 49 }; 47 50 48 /* dynamic control object */ 51 /* dynamic control object */ 49 struct snd_soc_dobj_control { 52 struct snd_soc_dobj_control { 50 struct snd_kcontrol *kcontrol; 53 struct snd_kcontrol *kcontrol; 51 char **dtexts; 54 char **dtexts; 52 unsigned long *dvalues; 55 unsigned long *dvalues; 53 }; 56 }; 54 57 55 /* dynamic widget object */ 58 /* dynamic widget object */ 56 struct snd_soc_dobj_widget { 59 struct snd_soc_dobj_widget { 57 unsigned int *kcontrol_type; /* kco !! 60 unsigned int kcontrol_type; /* kcontrol type: mixer, enum, bytes */ 58 }; 61 }; 59 62 60 /* generic dynamic object - all dynamic object 63 /* generic dynamic object - all dynamic objects belong to this struct */ 61 struct snd_soc_dobj { 64 struct snd_soc_dobj { 62 enum snd_soc_dobj_type type; 65 enum snd_soc_dobj_type type; 63 unsigned int index; /* objects can 66 unsigned int index; /* objects can belong in different groups */ 64 struct list_head list; 67 struct list_head list; 65 int (*unload)(struct snd_soc_component !! 68 struct snd_soc_tplg_ops *ops; 66 union { 69 union { 67 struct snd_soc_dobj_control co 70 struct snd_soc_dobj_control control; 68 struct snd_soc_dobj_widget wid 71 struct snd_soc_dobj_widget widget; 69 }; 72 }; 70 void *private; /* core does not touch 73 void *private; /* core does not touch this */ 71 }; 74 }; 72 75 73 /* 76 /* 74 * Kcontrol operations - used to map handlers 77 * Kcontrol operations - used to map handlers onto firmware based controls. 75 */ 78 */ 76 struct snd_soc_tplg_kcontrol_ops { 79 struct snd_soc_tplg_kcontrol_ops { 77 u32 id; 80 u32 id; 78 int (*get)(struct snd_kcontrol *kcontr 81 int (*get)(struct snd_kcontrol *kcontrol, 79 struct snd_ctl_elem_va 82 struct snd_ctl_elem_value *ucontrol); 80 int (*put)(struct snd_kcontrol *kcontr 83 int (*put)(struct snd_kcontrol *kcontrol, 81 struct snd_ctl_elem_va 84 struct snd_ctl_elem_value *ucontrol); 82 int (*info)(struct snd_kcontrol *kcont 85 int (*info)(struct snd_kcontrol *kcontrol, 83 struct snd_ctl_elem_info *uinf 86 struct snd_ctl_elem_info *uinfo); 84 }; 87 }; 85 88 86 /* Bytes ext operations, for TLV byte controls 89 /* Bytes ext operations, for TLV byte controls */ 87 struct snd_soc_tplg_bytes_ext_ops { 90 struct snd_soc_tplg_bytes_ext_ops { 88 u32 id; 91 u32 id; 89 int (*get)(struct snd_kcontrol *kcontr 92 int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes, 90 93 unsigned int size); 91 int (*put)(struct snd_kcontrol *kcontr 94 int (*put)(struct snd_kcontrol *kcontrol, 92 const unsigned int __u 95 const unsigned int __user *bytes, unsigned int size); 93 }; 96 }; 94 97 95 /* 98 /* 96 * DAPM widget event handlers - used to map ha 99 * DAPM widget event handlers - used to map handlers onto widgets. 97 */ 100 */ 98 struct snd_soc_tplg_widget_events { 101 struct snd_soc_tplg_widget_events { 99 u16 type; 102 u16 type; 100 int (*event_handler)(struct snd_soc_da 103 int (*event_handler)(struct snd_soc_dapm_widget *w, 101 struct snd_kcontrol *k 104 struct snd_kcontrol *k, int event); 102 }; 105 }; 103 106 104 /* 107 /* 105 * Public API - Used by component drivers to l 108 * Public API - Used by component drivers to load and unload dynamic objects 106 * and their resources. 109 * and their resources. 107 */ 110 */ 108 struct snd_soc_tplg_ops { 111 struct snd_soc_tplg_ops { 109 112 110 /* external kcontrol init - used for a 113 /* external kcontrol init - used for any driver specific init */ 111 int (*control_load)(struct snd_soc_com 114 int (*control_load)(struct snd_soc_component *, int index, 112 struct snd_kcontrol_new *, str 115 struct snd_kcontrol_new *, struct snd_soc_tplg_ctl_hdr *); 113 int (*control_unload)(struct snd_soc_c 116 int (*control_unload)(struct snd_soc_component *, 114 struct snd_soc_dobj *); 117 struct snd_soc_dobj *); 115 118 116 /* DAPM graph route element loading an 119 /* DAPM graph route element loading and unloading */ 117 int (*dapm_route_load)(struct snd_soc_ 120 int (*dapm_route_load)(struct snd_soc_component *, int index, 118 struct snd_soc_dapm_route *rou 121 struct snd_soc_dapm_route *route); 119 int (*dapm_route_unload)(struct snd_so 122 int (*dapm_route_unload)(struct snd_soc_component *, 120 struct snd_soc_dobj *); 123 struct snd_soc_dobj *); 121 124 122 /* external widget init - used for any 125 /* external widget init - used for any driver specific init */ 123 int (*widget_load)(struct snd_soc_comp 126 int (*widget_load)(struct snd_soc_component *, int index, 124 struct snd_soc_dapm_widget *, 127 struct snd_soc_dapm_widget *, 125 struct snd_soc_tplg_dapm_widge 128 struct snd_soc_tplg_dapm_widget *); 126 int (*widget_ready)(struct snd_soc_com 129 int (*widget_ready)(struct snd_soc_component *, int index, 127 struct snd_soc_dapm_widget *, 130 struct snd_soc_dapm_widget *, 128 struct snd_soc_tplg_dapm_widge 131 struct snd_soc_tplg_dapm_widget *); 129 int (*widget_unload)(struct snd_soc_co 132 int (*widget_unload)(struct snd_soc_component *, 130 struct snd_soc_dobj *); 133 struct snd_soc_dobj *); 131 134 132 /* FE DAI - used for any driver specif 135 /* FE DAI - used for any driver specific init */ 133 int (*dai_load)(struct snd_soc_compone 136 int (*dai_load)(struct snd_soc_component *, int index, 134 struct snd_soc_dai_driver *dai 137 struct snd_soc_dai_driver *dai_drv, 135 struct snd_soc_tplg_pcm *pcm, 138 struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai); 136 139 137 int (*dai_unload)(struct snd_soc_compo 140 int (*dai_unload)(struct snd_soc_component *, 138 struct snd_soc_dobj *); 141 struct snd_soc_dobj *); 139 142 140 /* DAI link - used for any driver spec 143 /* DAI link - used for any driver specific init */ 141 int (*link_load)(struct snd_soc_compon 144 int (*link_load)(struct snd_soc_component *, int index, 142 struct snd_soc_dai_link *link, 145 struct snd_soc_dai_link *link, 143 struct snd_soc_tplg_link_confi 146 struct snd_soc_tplg_link_config *cfg); 144 int (*link_unload)(struct snd_soc_comp 147 int (*link_unload)(struct snd_soc_component *, 145 struct snd_soc_dobj *); 148 struct snd_soc_dobj *); 146 149 147 /* callback to handle vendor bespoke d 150 /* callback to handle vendor bespoke data */ 148 int (*vendor_load)(struct snd_soc_comp 151 int (*vendor_load)(struct snd_soc_component *, int index, 149 struct snd_soc_tplg_hdr *); 152 struct snd_soc_tplg_hdr *); 150 int (*vendor_unload)(struct snd_soc_co 153 int (*vendor_unload)(struct snd_soc_component *, 151 struct snd_soc_tplg_hdr *); 154 struct snd_soc_tplg_hdr *); 152 155 153 /* completion - called at completion o 156 /* completion - called at completion of firmware loading */ 154 int (*complete)(struct snd_soc_compone !! 157 void (*complete)(struct snd_soc_component *); 155 158 156 /* manifest - optional to inform compo 159 /* manifest - optional to inform component of manifest */ 157 int (*manifest)(struct snd_soc_compone 160 int (*manifest)(struct snd_soc_component *, int index, 158 struct snd_soc_tplg_manifest * 161 struct snd_soc_tplg_manifest *); 159 162 160 /* vendor specific kcontrol handlers a 163 /* vendor specific kcontrol handlers available for binding */ 161 const struct snd_soc_tplg_kcontrol_ops 164 const struct snd_soc_tplg_kcontrol_ops *io_ops; 162 int io_ops_count; 165 int io_ops_count; 163 166 164 /* vendor specific bytes ext handlers 167 /* vendor specific bytes ext handlers available for binding */ 165 const struct snd_soc_tplg_bytes_ext_op 168 const struct snd_soc_tplg_bytes_ext_ops *bytes_ext_ops; 166 int bytes_ext_ops_count; 169 int bytes_ext_ops_count; 167 }; 170 }; 168 171 169 #ifdef CONFIG_SND_SOC_TOPOLOGY 172 #ifdef CONFIG_SND_SOC_TOPOLOGY 170 173 171 /* gets a pointer to data from the firmware bl 174 /* gets a pointer to data from the firmware block header */ 172 static inline const void *snd_soc_tplg_get_dat 175 static inline const void *snd_soc_tplg_get_data(struct snd_soc_tplg_hdr *hdr) 173 { 176 { 174 const void *ptr = hdr; 177 const void *ptr = hdr; 175 178 176 return ptr + sizeof(*hdr); 179 return ptr + sizeof(*hdr); 177 } 180 } 178 181 179 /* Dynamic Object loading and removal for comp 182 /* Dynamic Object loading and removal for component drivers */ 180 int snd_soc_tplg_component_load(struct snd_soc 183 int snd_soc_tplg_component_load(struct snd_soc_component *comp, 181 const struct snd_soc_tplg_ops *ops, co !! 184 struct snd_soc_tplg_ops *ops, const struct firmware *fw, 182 int snd_soc_tplg_component_remove(struct snd_s !! 185 u32 index); >> 186 int snd_soc_tplg_component_remove(struct snd_soc_component *comp, u32 index); >> 187 >> 188 /* Widget removal - widgets also removed wth component API */ >> 189 void snd_soc_tplg_widget_remove(struct snd_soc_dapm_widget *w); >> 190 void snd_soc_tplg_widget_remove_all(struct snd_soc_dapm_context *dapm, >> 191 u32 index); 183 192 184 /* Binds event handlers to dynamic widgets */ 193 /* Binds event handlers to dynamic widgets */ 185 int snd_soc_tplg_widget_bind_event(struct snd_ 194 int snd_soc_tplg_widget_bind_event(struct snd_soc_dapm_widget *w, 186 const struct snd_soc_tplg_widget_event 195 const struct snd_soc_tplg_widget_events *events, int num_events, 187 u16 event_type); 196 u16 event_type); 188 197 189 #else 198 #else 190 199 191 static inline int snd_soc_tplg_component_remov !! 200 static inline int snd_soc_tplg_component_remove(struct snd_soc_component *comp, >> 201 u32 index) 192 { 202 { 193 return 0; 203 return 0; 194 } 204 } 195 205 196 #endif 206 #endif 197 207 198 #endif 208 #endif 199 209
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.