* [PATCH] ASoC: core - Add platform read and write.
@ 2011-07-04 10:10 Liam Girdwood
2011-07-04 19:41 ` Mark Brown
2011-07-04 19:41 ` Mark Brown
0 siblings, 2 replies; 5+ messages in thread
From: Liam Girdwood @ 2011-07-04 10:10 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Liam Girdwood
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>
---
include/sound/soc.h | 8 ++++++++
sound/soc/soc-core.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 6424b10..f30f3fe 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -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 {
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d49f0ed..d08abf4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] ASoC: core - Add platform read and write.
2011-07-04 10:10 [PATCH] ASoC: core - Add platform read and write Liam Girdwood
@ 2011-07-04 19:41 ` Mark Brown
2011-07-04 21:14 ` Liam Girdwood
2011-07-04 19:41 ` Mark Brown
1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2011-07-04 19:41 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel
On Mon, Jul 04, 2011 at 11:10:15AM +0100, Liam Girdwood wrote:
> +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.
> +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.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] ASoC: core - Add platform read and write.
2011-07-04 19:41 ` Mark Brown
@ 2011-07-04 21:14 ` Liam Girdwood
2011-07-04 22:34 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Liam Girdwood @ 2011-07-04 21:14 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel@alsa-project.org
On 04/07/11 20:41, Mark Brown wrote:
> On Mon, Jul 04, 2011 at 11:10:15AM +0100, Liam Girdwood wrote:
>
>> +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 ;)
>
>> +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.
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] ASoC: core - Add platform read and write.
2011-07-04 21:14 ` Liam Girdwood
@ 2011-07-04 22:34 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2011-07-04 22:34 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel@alsa-project.org
On Mon, Jul 04, 2011 at 10:14:05PM +0100, Liam Girdwood wrote:
> On 04/07/11 20:41, Mark Brown wrote:
> > Could return -EINVAL or 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: core - Add platform read and write.
2011-07-04 10:10 [PATCH] ASoC: core - Add platform read and write Liam Girdwood
2011-07-04 19:41 ` Mark Brown
@ 2011-07-04 19:41 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2011-07-04 19:41 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel
On Mon, Jul 04, 2011 at 11:10:15AM +0100, Liam Girdwood wrote:
> 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!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-07-04 22:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-04 10:10 [PATCH] ASoC: core - Add platform read and write Liam Girdwood
2011-07-04 19:41 ` Mark Brown
2011-07-04 21:14 ` Liam Girdwood
2011-07-04 22:34 ` Mark Brown
2011-07-04 19:41 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.