All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org
Cc: lgirdwood@gmail.com, Cezary Rojewski <cezary.rojewski@intel.com>,
	broonie@kernel.org, tiwai@suse.com,
	pierre-louis.bossart@linux.intel.com
Subject: [alsa-devel] [PATCH 01/12] ALSA: hda: Allow for compress stream to hdac_ext_stream assignment
Date: Fri, 24 Jan 2020 20:04:02 +0100	[thread overview]
Message-ID: <20200124190413.18154-2-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20200124190413.18154-1-cezary.rojewski@intel.com>

Currently only PCM streams can enlist hdac_stream for their data
transfer. Add cstream field to hdac_ext_stream to expose possibility of
compress stream assignment in place of PCM one.
Limited to HOST-type only.

Rather than copying entire hdac_ext_host_stream_assign, declare separate
PCM and compress wrappers and reuse it for both cases.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 include/sound/hdaudio.h         |  1 +
 include/sound/hdaudio_ext.h     |  2 ++
 sound/hda/ext/hdac_ext_stream.c | 49 +++++++++++++++++++++++++++++----
 3 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 541ca99b154b..91aabda56c96 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -484,6 +484,7 @@ struct hdac_stream {
 	struct snd_pcm_substream *substream;	/* assigned substream,
 						 * set in PCM open
 						 */
+	struct snd_compr_stream *cstream;
 	unsigned int format_val;	/* format value to be set in the
 					 * controller and the codec
 					 */
diff --git a/include/sound/hdaudio_ext.h b/include/sound/hdaudio_ext.h
index ef88b20c7b0a..ec01f2024f0b 100644
--- a/include/sound/hdaudio_ext.h
+++ b/include/sound/hdaudio_ext.h
@@ -84,6 +84,8 @@ int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
 		int num_stream, int dir);
 void snd_hdac_stream_free_all(struct hdac_bus *bus);
 void snd_hdac_link_free_all(struct hdac_bus *bus);
+struct hdac_ext_stream *snd_hdac_ext_cstream_assign(struct hdac_bus *bus,
+					   struct snd_compr_stream *cstream);
 struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus,
 					   struct snd_pcm_substream *substream,
 					   int type);
diff --git a/sound/hda/ext/hdac_ext_stream.c b/sound/hda/ext/hdac_ext_stream.c
index c4d54a838773..014841a7f966 100644
--- a/sound/hda/ext/hdac_ext_stream.c
+++ b/sound/hda/ext/hdac_ext_stream.c
@@ -14,6 +14,7 @@
 #include <sound/pcm.h>
 #include <sound/hda_register.h>
 #include <sound/hdaudio_ext.h>
+#include <sound/compress_driver.h>
 
 /**
  * snd_hdac_ext_stream_init - initialize each stream (aka device)
@@ -281,8 +282,7 @@ hdac_ext_link_stream_assign(struct hdac_bus *bus,
 }
 
 static struct hdac_ext_stream *
-hdac_ext_host_stream_assign(struct hdac_bus *bus,
-				struct snd_pcm_substream *substream)
+hdac_ext_host_stream_assign(struct hdac_bus *bus, int direction)
 {
 	struct hdac_ext_stream *res = NULL;
 	struct hdac_stream *stream = NULL;
@@ -296,12 +296,13 @@ hdac_ext_host_stream_assign(struct hdac_bus *bus,
 		struct hdac_ext_stream *hstream = container_of(stream,
 						struct hdac_ext_stream,
 						hstream);
-		if (stream->direction != substream->stream)
+		if (stream->direction != direction)
 			continue;
 
 		if (!stream->opened) {
 			if (!hstream->decoupled)
-				snd_hdac_ext_stream_decouple(bus, hstream, true);
+				snd_hdac_ext_stream_decouple(bus,
+						hstream, true);
 			res = hstream;
 			break;
 		}
@@ -310,13 +311,49 @@ hdac_ext_host_stream_assign(struct hdac_bus *bus,
 		spin_lock_irq(&bus->reg_lock);
 		res->hstream.opened = 1;
 		res->hstream.running = 0;
-		res->hstream.substream = substream;
+		res->hstream.substream = NULL;
+		res->hstream.cstream = NULL;
 		spin_unlock_irq(&bus->reg_lock);
 	}
 
 	return res;
 }
 
+static struct hdac_ext_stream *
+hdac_ext_host_stream_pcm_assign(struct hdac_bus *bus,
+				struct snd_pcm_substream *substream)
+{
+	struct hdac_ext_stream *res;
+
+	res = hdac_ext_host_stream_assign(bus, substream->stream);
+	if (res)
+		res->hstream.substream = substream;
+
+	return res;
+}
+
+/**
+ * snd_hdac_ext_cstream_assign - assign a host stream for compress
+ * @bus: HD-audio core bus
+ * @cstream: Compress stream to assign
+ *
+ * Assign an unused host stream for the given compress stream.
+ * If no stream is free, NULL is returned. Stream is decoupled
+ * before assignment.
+ */
+struct hdac_ext_stream *snd_hdac_ext_cstream_assign(struct hdac_bus *bus,
+					   struct snd_compr_stream *cstream)
+{
+	struct hdac_ext_stream *res;
+
+	res = hdac_ext_host_stream_assign(bus, cstream->direction);
+	if (res)
+		res->hstream.cstream = cstream;
+
+	return res;
+}
+EXPORT_SYMBOL_GPL(snd_hdac_ext_cstream_assign);
+
 /**
  * snd_hdac_ext_stream_assign - assign a stream for the PCM
  * @bus: HD-audio core bus
@@ -350,7 +387,7 @@ struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus,
 		return hstream;
 
 	case HDAC_EXT_STREAM_TYPE_HOST:
-		return hdac_ext_host_stream_assign(bus, substream);
+		return hdac_ext_host_stream_pcm_assign(bus, substream);
 
 	case HDAC_EXT_STREAM_TYPE_LINK:
 		return hdac_ext_link_stream_assign(bus, substream);
-- 
2.17.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2020-01-24 19:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 19:04 [alsa-devel] [PATCH 00/12] ASoC: SOF: Data probing Cezary Rojewski
2020-01-24 19:04 ` Cezary Rojewski [this message]
2020-01-24 19:04 ` [alsa-devel] [PATCH 02/12] ALSA: hda: Prepare for compress stream support Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 03/12] ALSA: hda: Interrupt servicing and BDL setup for compress streams Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 04/12] ALSA: core: Expand DMA buffer information Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 05/12] ALSA: core: Implement compress page allocation and free routines Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 06/12] ASoC: SOF: Intel: Account for compress streams when servicing IRQs Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 07/12] ASoC: SOF: Implement Probe IPC API Cezary Rojewski
2020-01-24 19:28   ` Pierre-Louis Bossart
2020-01-27 12:16     ` Cezary Rojewski
2020-01-24 19:55   ` Pierre-Louis Bossart
2020-01-27 12:20     ` Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 08/12] ASoC: SOF: Generic probe compress operations Cezary Rojewski
2020-01-24 19:41   ` Pierre-Louis Bossart
2020-01-27 12:23     ` Cezary Rojewski
2020-01-24 20:00   ` Pierre-Louis Bossart
2020-01-27 12:28     ` Cezary Rojewski
2020-01-27 15:56       ` Pierre-Louis Bossart
2020-01-24 19:04 ` [alsa-devel] [PATCH 09/12] ASoC: SOF: Intel: Probe " Cezary Rojewski
2020-01-24 20:07   ` Pierre-Louis Bossart
2020-01-27 12:28     ` Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 10/12] ASoC: SOF: Provide probe debugfs support Cezary Rojewski
2020-01-24 20:22   ` Pierre-Louis Bossart
2020-01-27 12:31     ` Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 11/12] ASoC: SOF: Intel: Add Probe compress CPU DAIs Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 12/12] ASoC: Intel: sof_rt5682: Add compress probe DAI links Cezary Rojewski
2020-01-24 19:31   ` Pierre-Louis Bossart
2020-01-27 12:32     ` Cezary Rojewski
2020-01-25 10:49 ` [alsa-devel] [PATCH 00/12] ASoC: SOF: Data probing Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200124190413.18154-2-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.