Skip to contentSkip to conversation

ASoC: add compress stream support

PATCH Applied Vinod Koul 2 participants 5 messages Aug 16, 2012 – Aug 20, 2012

Subsystems (3)
lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

cover ASoC: add compress stream support

Here is the much delayed support for compress audio streams in ASoC. The v2 incorprates feedback discussed on v1 patches and this also adds the support in Intel drivers.

Namarta Kohli (1):
ASoC: add compress stream support

Vinod Koul (2):
ASoC: add definations for compressed operations
ASoC: mid-x86 - add support for compressed streams

 include/sound/compress_driver.h  |    1 +
 include/sound/soc-dai.h          |    3 +
 include/sound/soc.h              |   16 ++-
 sound/soc/Kconfig                |    1 +
 sound/soc/Makefile               |    2 +-
 sound/soc/mid-x86/mfld_machine.c |    9 ++
 sound/soc/mid-x86/sst_dsp.h      |  134 +++++++++++++++++
 sound/soc/mid-x86/sst_platform.c |  204 ++++++++++++++++++++++++++-
 sound/soc/mid-x86/sst_platform.h |   26 ++++-
 sound/soc/soc-compress.c         |  295 ++++++++++++++++++++++++++++++++++++++
 sound/soc/soc-core.c             |   57 +++++---
 11 files changed, 721 insertions(+), 27 deletions(-)
 create mode 100644 sound/soc/mid-x86/sst_dsp.h
 create mode 100644 sound/soc/soc-compress.c
author
#1 lore raw

PATCH 1/3 ASoC: add definations for compressed operations

Here we update the asoc structures to add compress stream definations 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 opertaions 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         |    3 +++
 include/sound/soc.h             |   16 +++++++++++++++-
 3 files changed, 19 insertions(+), 1 deletions(-)
include/sound/compress_driver.h +1 -0
index 48f2a1f..f2912ab 100644
@@ -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 +3 -0
index 1f69e0a..628db7b 100644
@@ -18,6 +18,7 @@
 
 struct snd_pcm_substream;
 struct snd_soc_dapm_widget;
+struct snd_compr_stream;
 
 /*
  * DAI hardware audio formats.
@@ -205,6 +206,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 +15 -1
index e063380..313b766 100644
@@ -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;
Signature · 1 line
1.7.0.4
author
#2 lore raw

PATCH 2/3 ASoC: add compress stream support

In reply to 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.c file while handles the compress stream operations, mostly analogus to what is done in the soc-pcm.c and aditional handling of the compress opertaions

---
 sound/soc/Kconfig        |    1 +
 sound/soc/Makefile       |    2 +-
 sound/soc/soc-compress.c |  295 ++++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/soc-core.c     |   57 ++++++----
 4 files changed, 331 insertions(+), 24 deletions(-)
 create mode 100644 sound/soc/soc-compress.c
sound/soc/Kconfig +1 -0
index c5de0a8..c24de90 100644
@@ -9,6 +9,7 @@ menuconfig SND_SOC
 	select SND_JACK if INPUT=y || INPUT=SND
 	select REGMAP_I2C if I2C
 	select REGMAP_SPI if SPI_MASTER
+	select SND_COMPRESS_OFFLOAD
 	---help---
 
 	  If you want ASoC support, you should say Y here and also to the
sound/soc/Makefile +1 -1
index 00a555a..c126400 100644
@@ -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 +295 -0

295 lines not on this page · raw message

sound/soc/soc-core.c +34 -23

71 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#3 lore raw

PATCH 3/3 ASoC: mid-x86 - add support for compressed streams

In reply to Vinod Koul
---
 sound/soc/mid-x86/mfld_machine.c |    9 ++
 sound/soc/mid-x86/sst_dsp.h      |  134 +++++++++++++++++++++++++
 sound/soc/mid-x86/sst_platform.c |  204 +++++++++++++++++++++++++++++++++++++-
 sound/soc/mid-x86/sst_platform.h |   26 +++++-
 4 files changed, 371 insertions(+), 2 deletions(-)
 create mode 100644 sound/soc/mid-x86/sst_dsp.h
sound/soc/mid-x86/mfld_machine.c +9 -0
index 2937e54..2cc7782 100644
@@ -318,6 +318,15 @@ static struct snd_soc_dai_link mfld_msic_dailink[] = {
 		.platform_name = "sst-platform",
 		.init = NULL,
 	},
+	{
+		.name = "Medfield Compress",
+		.stream_name = "Speaker",
+		.cpu_dai_name = "Compress-cpu-dai",
+		.codec_dai_name = "SN95031 Speaker",
+		.codec_name = "sn95031",
+		.platform_name = "sst-platform",
+		.init = NULL,
+	},
 };
 
 /* SoC card */
sound/soc/mid-x86/sst_dsp.h new file +134 -0

134 lines not on this page · raw message

sound/soc/mid-x86/sst_platform.c +203 -1

230 lines not on this page · raw message

sound/soc/mid-x86/sst_platform.h +25 -1
index f04f4f7..d61c5d5 100644
@@ -27,6 +27,8 @@
 #ifndef __SST_PLATFORMDRV_H__
 #define __SST_PLATFORMDRV_H__
 
+#include "sst_dsp.h"
+
 #define SST_MONO		1
 #define SST_STEREO		2
 #define SST_MAX_CAP		5
@@ -42,7 +44,6 @@
 #define SST_MIN_PERIODS		2
 #define SST_MAX_PERIODS		(1024*2)
 #define SST_FIFO_SIZE		0
-#define SST_CODEC_TYPE_PCM	1
 
 struct pcm_stream_info {
 	int str_id;
@@ -83,6 +84,7 @@ enum sst_audio_device_type {
 	SND_SST_DEVICE_VIBRA,
 	SND_SST_DEVICE_HAPTIC,
 	SND_SST_DEVICE_CAPTURE,
+	SND_SST_DEVICE_COMPRESS,
 };
 
 /* PCM Parameters */
@@ -107,6 +109,24 @@ struct sst_stream_params {
 	struct sst_pcm_params sparams;
 };
 
+struct sst_compress_cb {
+	void *param;
+	void (*compr_cb)(void *param);
+};
+
+struct compress_sst_ops {
+	const char *name;
+	int (*open) (struct snd_sst_params *str_params,
+			struct sst_compress_cb *cb);
+	int (*control) (unsigned int cmd, unsigned int str_id);
+	int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp);
+	int (*ack) (unsigned int str_id, unsigned long bytes);
+	int (*close) (unsigned int str_id);
+	int (*get_caps) (struct snd_compr_caps *caps);
+	int (*get_codec_caps) (struct snd_compr_codec_caps *codec);
+
+};
+
 struct sst_ops {
 	int (*open) (struct sst_stream_params *str_param);
 	int (*device_control) (int cmd, void *arg);
@@ -115,8 +135,11 @@ struct sst_ops {
 
 struct sst_runtime_stream {
 	int     stream_status;
+	unsigned int id;
+	size_t bytes_written;
 	struct pcm_stream_info stream_info;
 	struct sst_ops *ops;
+	struct compress_sst_ops *compr_ops;
 	spinlock_t	status_lock;
 };
 
@@ -124,6 +147,7 @@ struct sst_device {
 	char *name;
 	struct device *dev;
 	struct sst_ops *ops;
+	struct compress_sst_ops *compr_ops;
 };
 
 int sst_register_dsp(struct sst_device *sst);
Signature · 1 line
1.7.0.4
Applied
#4 lore raw
In reply to Vinod Koul
Quoted 3 lines · Vinod Koul

Here is the much delayed support for compress audio streams in ASoC. The v2 incorprates feedback discussed on v1 patches and this also adds the support in Intel drivers.

Applied all, thanks.