ASoC: add compress stream support
Subsystems (3)
cover ASoC: add compress stream support
Here is the much delayed support for compress audio streams in ASoC. This patch series is in RFC form, once we have agreed on this I will send the patches supporting Intel driver as well.
Mainly we indicate if the dai is of compressed nature and based on that register a new compressed device. Also the platform driver adds the compress stream operations.
Since the codecs handles PCM only, the assumption is that they will not have anything to do here and machine needs to set codec appropriately for compressed streams. In future if codec with such support are available then we can simply add compressed operations into codec as well
Comments, criticism welcome...
--
Namarta Kohli (1):
ASoC: add compress stream support
Vinod Koul (1):
ASoC: add definations for compressed operations
include/sound/compress_driver.h | 1 + include/sound/soc-dai.h | 2 + include/sound/soc.h | 17 ++- sound/soc/Makefile | 2 +- sound/soc/soc-compress.c | 297 +++++++++++++++++++++++++++++++++++++++ sound/soc/soc-core.c | 10 ++- 6 files changed, 326 insertions(+), 3 deletions(-) create mode 100644 sound/soc/soc-compress.c
RFC PATCH 1/2 ASoC: add definitions for compressed operations
Here we update the asoc structures to add compress stream definitions First the struct snd_soc_dai_driver adds a new member to indicate if the dai is compressed or pcm. Next we add a new structre the struct snd_soc_compr_ops in the struct snd_soc_dai_link. This is to be used for machine driver to perform any operations required for setting up compressed audio streams
next is the compressed data operations, they are added using struct snd_compr_ops in the struct snd_soc_platform_driver.
--- include/sound/compress_driver.h | 1 + include/sound/soc-dai.h | 2 ++ include/sound/soc.h | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletions(-)
include/sound/compress_driver.h +1 -0
@@ -61,6 +61,7 @@ struct snd_compr_runtime {u64 total_bytes_available;u64 total_bytes_transferred;wait_queue_head_t sleep; +void *private_data; };/**
include/sound/soc-dai.h +2 -0
@@ -205,6 +205,8 @@ struct snd_soc_dai_driver {int (*remove)(struct snd_soc_dai *dai);int (*suspend)(struct snd_soc_dai *dai);int (*resume)(struct snd_soc_dai *dai); +/* compress dai */ +bool compress_dai;/* ops */ const struct snd_soc_dai_ops *ops;
include/sound/soc.h +16 -1
@@ -22,6 +22,7 @@#include <linux/regmap.h> #include <sound/core.h> #include <sound/pcm.h> +#include <sound/compress_driver.h> #include <sound/control.h> #include <sound/ac97_codec.h>
@@ -399,6 +400,7 @@ int snd_soc_platform_read(struct snd_soc_platform *platform,int snd_soc_platform_write (struct snd_soc_platform *platform,unsigned int reg,unsigned int val);int soc_new_pcm (struct snd_soc_pcm_runtime *rtd,int num); +int soc_new_compress (struct snd_soc_pcm_runtime *rtd,int num);struct snd_pcm_substream *snd_soc_get_dai_substream (struct snd_soc_card *card,const char *dai_link,int stream);
@@ -632,6 +634,13 @@ struct snd_soc_ops {int (*trigger)(struct snd_pcm_substream *,int ); }; +struct snd_soc_compr_ops { +int (*startup)(struct snd_compr_stream *); +void (*shutdown)(struct snd_compr_stream *); +int (*set_params)(struct snd_compr_stream *); +int (*trigger)(struct snd_compr_stream *); +}; +/* SoC cache ops */ struct snd_soc_cache_ops {const char *name;
@@ -787,9 +796,12 @@ struct snd_soc_platform_driver {snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,struct snd_soc_dai *); -/* platform stream ops */ +/* platform stream pcm ops */ struct snd_pcm_ops *ops; +/* platform stream compress ops */ +struct snd_compr_ops *compr_ops; +/* platform stream completion event */ int (*stream_event)(struct snd_soc_dapm_context *dapm,int event);
@@ -891,6 +903,7 @@ struct snd_soc_dai_link {/* machine stream operations */ struct snd_soc_ops *ops; +struct snd_soc_compr_ops *compr_ops; };struct snd_soc_codec_conf {
@@ -1027,6 +1040,7 @@ struct snd_soc_pcm_runtime {/* runtime devices */ struct snd_pcm *pcm; +struct snd_compr *compr;struct snd_soc_codec *codec;struct snd_soc_platform *platform;struct snd_soc_dai *codec_dai;
@@ -1039,6 +1053,7 @@ struct snd_soc_pcm_runtime {#endif }; +/* mixer control */ struct soc_mixer_control {int min, max, platform_max;
Signature · 1 line
1.7.0.4
RFC PATCH 2/2 ASoC: add compress stream support
In reply to Vinod KoulFrom: Namarta Kohli <[email protected]>
This patch adds the support to parse the compress dai's and then also adds the soc-compress.c file while handles the compress stream operations, mostly analogous to what is done in the soc-pcm.c and additional handling of the compress operations
--- sound/soc/Makefile | 2 +- sound/soc/soc-compress.c | 297 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/soc-core.c | 10 ++- 3 files changed, 307 insertions(+), 2 deletions(-) create mode 100644 sound/soc/soc-compress.c
sound/soc/Makefile +1 -1
@@ -1,5 +1,5 @@ snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o -snd-soc-core-objs += soc-pcm.o soc-io.o +snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o snd-soc-dmaengine-pcm-objs := soc-dmaengine-pcm.o obj-$(CONFIG_SND_SOC_DMAENGINE_PCM) += snd-soc-dmaengine-pcm.o
sound/soc/soc-compress.c new file +297 -0
297 lines not on this page · raw message
sound/soc/soc-core.c +9 -1
@@ -1388,7 +1388,15 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)if (ret <0 )pr_warn ("asoc: failed to add pmdown_time sysfs:%d\n" , ret); -if (!dai_link->params) { +if (cpu_dai->driver->compress_dai) { +/*create compress device*/ + ret =soc_new_compress (rtd, num); +if (ret <0 ) { +printk (KERN_ERR "asoc: can't create offload %s\n" , + dai_link->stream_name); +return ret; + } + }else if (!dai_link->params) {/* create the pcm */ ret =soc_new_pcm (rtd, num);if (ret <0 ) {
Signature · 1 line
1.7.0.4
Quoted 6 lines · Vinod Koul
From: Namarta Kohli <[email protected]>
This patch adds the support to parse the compress dai's and then also adds the
soc-compress.cfile while handles the compress stream operations, mostly analogous to what is done in thesoc-pcm.cand additional handling of the compress operations
This is all mostly fine, though it's very sad that there's so much code duplication between this and the regular PCM streams. Some smallish comments below.
sound/soc/soc-compress.c line 60
Quoted 9 lines
sound/soc/soc-compress.c new file +9
-0+if (cstream->direction ==SND_COMPRESS_PLAYBACK ) { + cpu_dai->playback_active++; + codec_dai->playback_active++; + }else { + cpu_dai->capture_active++; + codec_dai->capture_active++; + } + cpu_dai->active++; + codec_dai->active++;
In quite a few places in the code there's missing blanks between blocks of code.
sound/soc/soc-compress.c line 174
Quoted 5 lines
sound/soc/soc-compress.c new file +4
-0+int soc_compr_set_params (struct snd_compr_stream *cstream, +struct snd_compr_params *params) +{ +snd_soc_dai_digital_mute (codec_dai,0 );
This looks wrong - the unmute should be associated with the start of the data transfer rather than the configuration. But we don't have any other ops... can we have one, or a non-atomic trigger?
sound/soc/soc-compress.c line 274
Quoted 4 lines
sound/soc/soc-compress.c new file +4
-0+/* check client and interface hw capabilities */ +snprintf (new_name,sizeof (new_name),"%s %s-%d" , + rtd->dai_link->stream_name, codec_dai->name, num); +/* TODO add support for cature */
Meow :)
sound/soc/soc-compress.c line 295
Quoted 2 lines
sound/soc/soc-compress.c new file +2
-0+printk (KERN_INFO "asoc: %s <-> %s mapping ok\n" , codec_dai->name, + cpu_dai->name);
Say it's a compressed mapping?
sound/soc/soc-core.c static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) · line 1398
Quoted 8 lines
sound/soc/soc-core.c +8
-0+if (cpu_dai->driver->compress_dai) { +/*create compress device*/ + ret =soc_new_compress (rtd, num); +if (ret <0 ) { +printk (KERN_ERR "asoc: can't create offload %s\n" , + dai_link->stream_name); +return ret; + }
Should we be complaining here if there's PCM operations too? Alternatively, should we support mixed PCM and compressed DAIs (possibly be creating two pcms from a single dai_link)?
At Thu, 2 Aug 2012 19:09:27 +0100,
Quoted 11 lines · Mark Brown
Quoted 6 lines · Vinod Koul
From: Namarta Kohli <[email protected]>
This patch adds the support to parse the compress dai's and then also adds the
soc-compress.cfile while handles the compress stream operations, mostly analogous to what is done in thesoc-pcm.cand additional handling of the compress operationsThis is all mostly fine, though it's very sad that there's so much code duplication between this and the regular PCM streams.
Yeah, it's a generic issue in the compress API, too. The design is a kind of fork from PCM. We can consider a bit more consolidation in the core part as well in future.
Takashi
Quoted 9 lines · Mark Brown
sound/soc/soc-compress.c line 174
Quoted 5 lines
sound/soc/soc-compress.c new file +4
-0+int soc_compr_set_params (struct snd_compr_stream *cstream, +struct snd_compr_params *params) +{ +snd_soc_dai_digital_mute (codec_dai,0 );This looks wrong - the unmute should be associated with the start of the data transfer rather than the configuration. But we don't have any other ops... can we have one, or a non-atomic trigger?
Sure we discussed this, but wasnt too sure. Will change to trigger, it seem the correct way.
Quoted 7 lines
sound/soc/soc-compress.c line 274
Quoted 5 lines
sound/soc/soc-compress.c new file +4
-0+/* check client and interface hw capabilities */ +snprintf (new_name,sizeof (new_name),"%s %s-%d" , + rtd->dai_link->stream_name, codec_dai->name, num); +/* TODO add support for cature */ Meow :)
:D, some trvial ocde was still misisng, rest of the code should work for both although havent been able to test that part.
Quoted 6 lines
sound/soc/soc-compress.c line 295
Quoted 3 lines
sound/soc/soc-compress.c new file +2
-0+printk (KERN_INFO "asoc: %s <-> %s mapping ok\n" , codec_dai->name, + cpu_dai->name);Say it's a compressed mapping?
Quoted 10 lines
sound/soc/soc-core.c static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) · line 1398
Quoted 8 lines
sound/soc/soc-core.c +8
-0+if (cpu_dai->driver->compress_dai) { +/*create compress device*/ + ret =soc_new_compress (rtd, num); +if (ret <0 ) { +printk (KERN_ERR "asoc: can't create offload %s\n" , + dai_link->stream_name); +return ret; + }Should we be complaining here if there's PCM operations too?
I think so. A device should be either PCM or compress.
Quoted 2 lines
Alternatively, should we support mixed PCM and compressed DAIs (possibly be creating two pcms from a single
dai_link)?
I can't perceive why that should be done :)
Signature · 1 line
~Vinod
At Thu, 2 Aug 2012 19:09:27 +0100,
Quoted 10 lines · Mark Brown
sound/soc/soc-compress.c line 174
Quoted 6 lines
sound/soc/soc-compress.c new file +4
-0+int soc_compr_set_params (struct snd_compr_stream *cstream, +struct snd_compr_params *params) +{ +snd_soc_dai_digital_mute (codec_dai,0 );This looks wrong - the unmute should be associated with the start of the data transfer rather than the configuration. But we don't have any other ops... can we have one, or a non-atomic trigger?
I've been thinking of the possibility for a long time.
The problem is how to handle the trigger(STOP) gracefully. Maybe creating a dedicated work struct would be required. Also it'd require a new schedulable lock for the substream on the top of snd_pcm_stream_lock*(). But before adding it, we should revisit the current lock mess in the code...
Takashi
Quoted 2 lines · Takashi Iwai
of snd_pcm_stream_lock*(). But before adding it, we should revisit the current lock mess in the code...
Yes, simplifying the locking scheme would be really helpful all round.
sound/soc/Makefile line 2
Quoted 9 lines · Vinod Koul
sound/soc/Makefile +0
-0@@ -1,5 +1,5 @@ snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.osoc-utils.o
sound/soc/Makefile +1
-1-snd-soc-core-objs += soc-pcm.o soc-io.o +snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o
Mark,
I am planning to add a symbol, SND_SOC_COMPRESS_OFFLOAD and compile this file and other changes under this flag.
This will select SND_COMPRESS_OFFLOAD and users should select this symbol when using compressed offload...
Let me know if its fine and will send patch for this.
Thanks
Signature · 1 line
~Vinod
Quoted 11 lines · Vinod Koul
sound/soc/Makefile line 2
Quoted 2 lines · Vinod Koul
sound/soc/Makefile +1
-1-snd-soc-core-objs += soc-pcm.o soc-io.o +snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.oI am planning to add a symbol,
SND_SOC_COMPRESS_OFFLOADand compile this file and other changes under this flag.
This will selectSND_COMPRESS_OFFLOADand users should select this symbol when using compressed offload...Let me know if its fine and will send patch for this.
To be honest given the code for compressed stuff is so small in comparison with the size of ASoC that I'm not sure it's worth bothering, we should probably just enable it unconditionally with ASoC.
Quoted 11 lines · Mark Brown
Quoted 9 lines · Vinod Koul
sound/soc/Makefile line 2
Quoted 2 lines · Vinod Koul
sound/soc/Makefile +1
-1-snd-soc-core-objs += soc-pcm.o soc-io.o +snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.oI am planning to add a symbol,
SND_SOC_COMPRESS_OFFLOADand compile this file and other changes under this flag.
This will selectSND_COMPRESS_OFFLOADand users should select this symbol when using compressed offload...
Quoted 5 lines
Quoted 1 line
Let me know if its fine and will send patch for this.
To be honest given the code for compressed stuff is so small in comparison with the size of ASoC that I'm not sure it's worth bothering, we should probably just enable it unconditionally with ASoC.
Okay, so select SND_COMPRESS_OFFLOAD it is in SND_SOC :)
Signature · 1 line
~Vinod
Quoted 3 lines · Vinod Koul
Here is the much delayed support for compress audio streams in ASoC. This patch series is in RFC form, once we have agreed on this I will send the patches supporting Intel driver as well.
These should probably be a single patch.