ASoC: core - Add platform read and write.
PATCH 1/1 ASoC: core - Add platform read and write.
In preparation for ASoC Dynamic PCM (AKA DSP) support.
Allow platform driver to perform IO. Intended for platform DAPM.
--- include/sound/soc.h | 8 ++++++++ sound/soc/soc-core.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 0 deletions(-)
include/sound/soc.h +8 -0
@@ -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 {
sound/soc/soc-core.c +30 -0
@@ -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
Signature · 1 line
1.7.4.1
sound/soc/soc-core.c int snd_soc_codec_writable_register(struct snd_soc_codec *codec, · line 1654
Quoted 12 lines · Liam Girdwood
sound/soc/soc-core.c +12
-0+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);
We should add tracepoints into these as well.
sound/soc/soc-core.c int snd_soc_codec_writable_register(struct snd_soc_codec *codec, · line 1665
Quoted 6 lines
sound/soc/soc-core.c +6
-0+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 ;
Could return -EINVAL or something here - it's not like read where we're mixing with the in band data.
Quoted 16 lines · Mark Brown
sound/soc/soc-core.c int snd_soc_codec_writable_register(struct snd_soc_codec *codec, · line 1654
Quoted 12 lines · Liam Girdwood
sound/soc/soc-core.c +12
-0+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);We should add tracepoints into these as well.
Ah, forgot to send that one with this one. It's on it's way now ;)
Quoted 10 lines
sound/soc/soc-core.c int snd_soc_codec_writable_register(struct snd_soc_codec *codec, · line 1665
Quoted 7 lines
sound/soc/soc-core.c +6
-0+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 ;Could return
-EINVALor something here - it's not like read where we're mixing with the in band data.
I was thinking that too, but consistency with the codec IO would mean return -1.
However, I've no real preference. I happy to change to EINVAL.
Liam
Quoted 8 lines · Liam Girdwood
Quoted 2 lines · Mark Brown
Could return
-EINVALor something here - it's not like read where we're mixing with the in band data.I was thinking that too, but consistency with the codec IO would mean return -1.
However, I've no real preference. I happy to change to EINVAL.
Should probably fix the CODEC code as well.
Quoted 3 lines · Liam Girdwood
In preparation for ASoC Dynamic PCM (AKA DSP) support.
Allow platform driver to perform IO. Intended for platform DAPM.
Sorry, also meant to add at the top that I applied the patch!