ASoC: core - Add platform read and write.
authorLiam Girdwood <lrg@ti.com>
Mon, 4 Jul 2011 10:10:15 +0000 (11:10 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 4 Jul 2011 19:41:07 +0000 (12:41 -0700)
In preparation for ASoC Dynamic PCM (AKA DSP) support.

Allow platform driver to perform IO. Intended for platform DAPM.

Signed-off-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
include/sound/soc.h
sound/soc/soc-core.c

index 6424b10ac29c0c9dbfae2f0af1e4309517a87eac..f30f3fe4a41bed42369b71d3f4c67d2b1799c0e6 100644 (file)
@@ -312,6 +312,10 @@ int snd_soc_default_readable_register(struct snd_soc_codec *codec,
                                      unsigned int reg);
 int snd_soc_default_writable_register(struct snd_soc_codec *codec,
                                      unsigned int reg);
+int snd_soc_platform_read(struct snd_soc_platform *platform,
+                                       unsigned int reg);
+int snd_soc_platform_write(struct snd_soc_platform *platform,
+                                       unsigned int reg, unsigned int val);
 
 /* Utility functions to get clock rates from various things */
 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
@@ -658,6 +662,10 @@ struct snd_soc_platform_driver {
        /* probe ordering - for components with runtime dependencies */
        int probe_order;
        int remove_order;
+
+       /* platform IO - used for platform DAPM */
+       unsigned int (*read)(struct snd_soc_platform *, unsigned int);
+       int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
 };
 
 struct snd_soc_platform {
index d49f0ed56f9c9c73526533613dffc8111ad0b3a0..d08abf4e3eb35a0a5ed7da19145c3e0504f65efc 100644 (file)
@@ -1640,6 +1640,36 @@ int snd_soc_codec_writable_register(struct snd_soc_codec *codec,
 }
 EXPORT_SYMBOL_GPL(snd_soc_codec_writable_register);
 
+int snd_soc_platform_read(struct snd_soc_platform *platform,
+                                       unsigned int reg)
+{
+       unsigned int ret;
+
+       if (!platform->driver->read) {
+               dev_err(platform->dev, "platform has no read back\n");
+               return -1;
+       }
+
+       ret = platform->driver->read(platform, reg);
+       dev_dbg(platform->dev, "read %x => %x\n", reg, ret);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_platform_read);
+
+int snd_soc_platform_write(struct snd_soc_platform *platform,
+                                        unsigned int reg, unsigned int val)
+{
+       if (!platform->driver->write) {
+               dev_err(platform->dev, "platform has no write back\n");
+               return -1;
+       }
+
+       dev_dbg(platform->dev, "write %x = %x\n", reg, val);
+       return platform->driver->write(platform, reg, val);
+}
+EXPORT_SYMBOL_GPL(snd_soc_platform_write);
+
 /**
  * snd_soc_new_ac97_codec - initailise AC97 device
  * @codec: audio codec