[alsa-devel] [RFC PATCH 06/11] ALSA: implement MEDIA_IOC_SETUP_LINK
Clemens Ladisch
clemens at ladisch.de
Tue Aug 28 00:32:31 CEST 2012
Just for compatibility with the media controller API, implement the
setup link ioctl, which does not actually do anything.
Signed-off-by: Clemens Ladisch <clemens at ladisch.de>
---
sound/core/media.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/sound/core/media.c b/sound/core/media.c
index aa90848..cbc51d9 100644
--- a/sound/core/media.c
+++ b/sound/core/media.c
@@ -289,6 +289,45 @@ static int snd_media_enum_links(struct snd_card *card,
return 0;
}
+static int snd_media_setup_link(struct snd_card *card,
+ struct media_link_desc __user *descp)
+{
+ struct media_link_desc desc;
+ struct snd_media_entity *source, *sink;
+ struct snd_media_link *link;
+ unsigned int i;
+ int err;
+
+ if (copy_from_user(&desc, descp, sizeof(desc)))
+ return -EFAULT;
+
+ if (desc.flags != (MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE))
+ return -EINVAL;
+
+ mutex_lock(&card->media_mutex);
+ source = search_entity(card, desc.source.entity);
+ sink = search_entity(card, desc.sink.entity);
+ mutex_unlock(&card->media_mutex);
+ if (!source || !sink)
+ return -EINVAL;
+
+ err = -EINVAL;
+ mutex_lock(&card->media_mutex);
+ for (i = 0; i < card->media_links_count; i++) {
+ link = &card->media_links[i];
+ if (link->source_entity == desc.source.entity &&
+ link->sink_entity == desc.sink.entity &&
+ link->source_pad == desc.source.index &&
+ link->sink_pad == desc.sink.index) {
+ err = 0;
+ break;
+ }
+ }
+ mutex_unlock(&card->media_mutex);
+
+ return err;
+}
+
static int snd_media_control_ioctl(struct snd_card *card,
struct snd_ctl_file *ctl_file,
unsigned int cmd, unsigned long arg)
@@ -302,6 +341,8 @@ static int snd_media_control_ioctl(struct snd_card *card,
return snd_media_enum_entities(card, argp);
case MEDIA_IOC_ENUM_LINKS:
return snd_media_enum_links(card, argp);
+ case MEDIA_IOC_SETUP_LINK:
+ return snd_media_setup_link(card, argp);
default:
return -ENOIOCTLCMD;
}
More information about the Alsa-devel
mailing list