aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/soc.h
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-06-16 12:13:06 -0400
committerMark Brown <broonie@linaro.org>2014-06-21 16:34:15 -0400
commitce0fc93ae56e2ba50ff8c220d69e4e860e889320 (patch)
treeb444788c95c34b08a18f80f00a411f359aa8ce23 /include/sound/soc.h
parent68f831c2724ab72c0088471b2ed1dc99e81948ef (diff)
ASoC: Add DAPM support at the component level
This patch adds full DAPM support at the component level. Previously there was only full DAPM support for CODECs and partial DAPM support (e.g. no Mixers nor MUXs) for platforms. Having DAPM support at the component level will allow all types of components to use DAPM and also help in consolidating the DAPM support between CODECs and platforms. Since the DAPM context is directly embedded into the snd_soc_codec and snd_soc_platform struct and the 'dapm' field is directly referenced in a lot of drivers moving the field just right now is not possible without causing code churn. The approach this patch takes is to add two new fields to the component struct. One field which is the pointer to the actual DAPM context used by the component and one DAPM context that will be used as the default if no other context was specified. For CODECs and platforms the pointer is initialized to point to the CODEC or platform DAPM context. All generic code when referencing a component's DAPM struct will go via the pointer. This will make it possible to eventually seamlessly move the DAPM context from snd_soc_codec and snd_soc_platform struct over once all direct references have been eliminated. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'include/sound/soc.h')
-rw-r--r--include/sound/soc.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index f64bf9452466..a21dfecba56b 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -706,6 +706,10 @@ struct snd_soc_component {
706 int val_bytes; 706 int val_bytes;
707 707
708 struct mutex io_mutex; 708 struct mutex io_mutex;
709
710 /* Don't use these, use snd_soc_component_get_dapm() */
711 struct snd_soc_dapm_context dapm;
712 struct snd_soc_dapm_context *dapm_ptr;
709}; 713};
710 714
711/* SoC Audio Codec device */ 715/* SoC Audio Codec device */
@@ -1161,6 +1165,21 @@ static inline struct snd_soc_platform *snd_soc_component_to_platform(
1161} 1165}
1162 1166
1163/** 1167/**
1168 * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
1169 * embedded in
1170 * @dapm: The DAPM context to cast to the component
1171 *
1172 * This function must only be used on DAPM contexts that are known to be part of
1173 * a component (e.g. in a component driver). Otherwise the behavior is
1174 * undefined.
1175 */
1176static inline struct snd_soc_component *snd_soc_dapm_to_component(
1177 struct snd_soc_dapm_context *dapm)
1178{
1179 return container_of(dapm, struct snd_soc_component, dapm);
1180}
1181
1182/**
1164 * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in 1183 * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in
1165 * @dapm: The DAPM context to cast to the CODEC 1184 * @dapm: The DAPM context to cast to the CODEC
1166 * 1185 *
@@ -1187,6 +1206,17 @@ static inline struct snd_soc_platform *snd_soc_dapm_to_platform(
1187 return container_of(dapm, struct snd_soc_platform, dapm); 1206 return container_of(dapm, struct snd_soc_platform, dapm);
1188} 1207}
1189 1208
1209/**
1210 * snd_soc_component_get_dapm() - Returns the DAPM context associated with a
1211 * component
1212 * @component: The component for which to get the DAPM context
1213 */
1214static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
1215 struct snd_soc_component *component)
1216{
1217 return component->dapm_ptr;
1218}
1219
1190/* codec IO */ 1220/* codec IO */
1191unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); 1221unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
1192int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, 1222int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,