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