All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Takashi Iwai <tiwai@suse.de>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	alsa-devel@alsa-project.org
Subject: [RFC PATCH 03/11] ALSA: pcm: add ALSA PCM device entities
Date: Tue, 28 Aug 2012 00:30:43 +0200	[thread overview]
Message-ID: <503BF513.1020302@ladisch.de> (raw)
In-Reply-To: <503BF48E.1090100@ladisch.de>

Add a helper function for creating entities representing ALSA PCM
devices.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
---
 include/sound/pcm.h |    6 ++++++
 sound/core/pcm.c    |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 39e26a3..f0a80b7 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -480,6 +480,12 @@ int snd_pcm_new_internal(struct snd_card *card, const char *id, int device,
 		int playback_count, int capture_count,
 		struct snd_pcm **rpcm);
 int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count);
+#ifdef CONFIG_SND_MEDIA
+int snd_pcm_media_entities_create(struct snd_pcm *pcm, int stream,
+				  unsigned int id);
+#else
+#define snd_pcm_media_entities_create(pcm, stream, id)
+#endif

 int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree);

diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 1a3070b..a138c57 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -25,11 +25,13 @@
 #include <linux/time.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
+#include <linux/media.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/pcm.h>
 #include <sound/control.h>
 #include <sound/info.h>
+#include <sound/media.h>

 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Abramo Bagnara <abramo@alsa-project.org>");
 MODULE_DESCRIPTION("Midlevel PCM code for ALSA.");
@@ -1136,6 +1138,50 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)

 EXPORT_SYMBOL(snd_pcm_notify);

+#ifdef CONFIG_SND_MEDIA
+static int snd_pcm_get_entity_desc(struct snd_card *card,
+				   void *private_data,
+				   struct media_entity_desc *desc)
+{
+	struct snd_pcm_substream *substream = private_data;
+
+	if (memcmp(substream->name, "subdevice #", 11))
+		strlcpy(desc->name, substream->name, sizeof(desc->name));
+	else
+		strlcpy(desc->name, substream->pcm->name, sizeof(desc->name));
+	desc->type = MEDIA_ENT_T_DEVNODE_ALSA;
+	desc->alsa.card = card->number;
+	desc->alsa.device = substream->pcm->device;
+	desc->alsa.subdevice = substream->number;
+
+	return 0;
+}
+
+int snd_pcm_media_entities_create(struct snd_pcm *pcm, int stream,
+				  unsigned int id)
+{
+	struct snd_pcm_str *pstr = &pcm->streams[stream];
+	struct snd_pcm_substream *substream;
+	int err;
+
+	for (substream = pstr->substream;
+	     substream;
+	     substream = substream->next) {
+		err = snd_media_entity_create(
+				pcm->card, snd_pcm_get_entity_desc,
+				id + substream->number,
+				stream == SNDRV_PCM_STREAM_CAPTURE  ? 1 : 0,
+				stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0,
+				substream);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(snd_pcm_media_entities_create);
+#endif
+
 #ifdef CONFIG_PROC_FS
 /*
  *  Info interface

  parent reply	other threads:[~2012-08-27 22:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-27 22:28 [RFC PATCH 1/11] expose sound device topology information Clemens Ladisch
2012-08-27 22:29 ` [RFC PATCH 01/11] ALSA: implement MEDIA_IOC_DEVICE_INFO Clemens Ladisch
2012-09-07  2:13   ` Mark Brown
2012-09-07  7:14     ` Clemens Ladisch
2012-09-07 10:40       ` Takashi Iwai
2012-08-27 22:30 ` [RFC PATCH 02/11] ALSA: implement MEDIA_IOC_ENUM_ENTITIES Clemens Ladisch
2012-08-27 22:30 ` Clemens Ladisch [this message]
2012-08-27 22:31 ` [RFC PATCH 04/11] ALSA: implement MEDIA_IOC_ENUM_LINKS (1) Clemens Ladisch
2012-08-27 22:31 ` [RFC PATCH 05/11] ALSA: implement MEDIA_IOC_ENUM_LINKS (2) Clemens Ladisch
2012-08-27 22:32 ` [RFC PATCH 06/11] ALSA: implement MEDIA_IOC_SETUP_LINK Clemens Ladisch
2012-08-27 22:33 ` [RFC PATCH 07/11] [media] media: add entity types for ALSA Clemens Ladisch
2012-08-27 22:33 ` [RFC PATCH 08/11] ALSA: usb-audio: implement card get_info callback Clemens Ladisch
2012-08-27 22:34 ` [RFC PATCH 09/11] ALSA: usb-audio: create PCM device entities Clemens Ladisch
2012-08-27 22:35 ` [RFC PATCH 10/11] ALSA: usb-audio: add terminal/unit entities and links Clemens Ladisch
2012-08-27 22:36 ` [RFC PATCH 11/11] ALSA: hda-intel: implement card get_info callback Clemens Ladisch
2012-09-04 15:56 ` [RFC PATCH 1/11] expose sound device topology information Takashi Iwai
2012-09-04 18:02   ` Clemens Ladisch

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=503BF513.1020302@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=tiwai@suse.de \
    /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.