]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - include/sound/soc.h
ASoC: Add DAPM support at the component level
[mirror_ubuntu-bionic-kernel.git] / include / sound / soc.h
index f64bf94524668ab7a72def734e102207a7af5a07..a21dfecba56b429a5c1e53b2dc3bbc4baeee7b60 100644 (file)
@@ -706,6 +706,10 @@ struct snd_soc_component {
        int val_bytes;
 
        struct mutex io_mutex;
+
+       /* Don't use these, use snd_soc_component_get_dapm() */
+       struct snd_soc_dapm_context dapm;
+       struct snd_soc_dapm_context *dapm_ptr;
 };
 
 /* SoC Audio Codec device */
@@ -1160,6 +1164,21 @@ static inline struct snd_soc_platform *snd_soc_component_to_platform(
        return container_of(component, struct snd_soc_platform, component);
 }
 
+/**
+ * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
+ *  embedded in
+ * @dapm: The DAPM context to cast to the component
+ *
+ * This function must only be used on DAPM contexts that are known to be part of
+ * a component (e.g. in a component driver). Otherwise the behavior is
+ * undefined.
+ */
+static inline struct snd_soc_component *snd_soc_dapm_to_component(
+       struct snd_soc_dapm_context *dapm)
+{
+       return container_of(dapm, struct snd_soc_component, dapm);
+}
+
 /**
  * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in
  * @dapm: The DAPM context to cast to the CODEC
@@ -1187,6 +1206,17 @@ static inline struct snd_soc_platform *snd_soc_dapm_to_platform(
        return container_of(dapm, struct snd_soc_platform, dapm);
 }
 
+/**
+ * snd_soc_component_get_dapm() - Returns the DAPM context associated with a
+ *  component
+ * @component: The component for which to get the DAPM context
+ */
+static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
+       struct snd_soc_component *component)
+{
+       return component->dapm_ptr;
+}
+
 /* codec IO */
 unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
 int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,