summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-07 21:52:53 +1100
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-26 17:27:37 +1100
commitf834eb7b0799a4678639d2a9f71c1dc4352469ce (patch)
tree0be207d5be59bdbbd0560ba96cb03caecc9da71b
parentaeb43d0374f4b1fb383da088b198de55f139a280 (diff)
Move 'streams_sealed' to avirt_core
Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
-rw-r--r--configfs.c8
-rw-r--r--core.c23
-rw-r--r--core_internal.h8
3 files changed, 30 insertions, 9 deletions
diff --git a/configfs.c b/configfs.c
index bca0f56..cdfd171 100644
--- a/configfs.c
+++ b/configfs.c
@@ -10,8 +10,6 @@
#include <sound/core.h>
#include "core_internal.h"
-static bool streams_sealed = false;
-
static ssize_t cfg_avirt_stream_direction_show(struct config_item *item,
char *page)
{
@@ -137,7 +135,7 @@ cfg_avirt_stream_make_item(struct config_group *group, const char *name)
static ssize_t cfg_avirt_stream_group_sealed_show(struct config_item *item,
char *page)
{
- return snprintf(page, PAGE_SIZE, "%d\n", streams_sealed);
+ return snprintf(page, PAGE_SIZE, "%d\n", __avirt_streams_sealed());
}
static ssize_t cfg_avirt_stream_group_sealed_store(struct config_item *item,
@@ -147,7 +145,7 @@ static ssize_t cfg_avirt_stream_group_sealed_store(struct config_item *item,
unsigned long tmp;
char *p = (char *)page;
- if (streams_sealed) {
+ if (__avirt_streams_sealed()) {
pr_err("AVIRT streams are already sealed!\n");
return -EPERM;
}
@@ -159,8 +157,6 @@ static ssize_t cfg_avirt_stream_group_sealed_store(struct config_item *item,
return -ERANGE;
}
- streams_sealed = (bool)tmp;
-
CHK_ERR(__avirt_card_register());
return count;
diff --git a/core.c b/core.c
index 96a4686..d925eae 100644
--- a/core.c
+++ b/core.c
@@ -32,6 +32,7 @@ extern struct snd_pcm_ops pcm_ops;
static struct avirt_core core = {
.stream_count = 0,
+ .streams_sealed = false,
};
struct avirt_coreinfo coreinfo = {
@@ -245,6 +246,11 @@ int avirt_audiopath_register(struct avirt_audiopath *audiopath,
audiopath->hw->periods_max);
list_add_tail(&audiopath_obj->list, &audiopath_list);
+ // If we have already sealed the streams, configure this AP
+ if (core.streams_sealed)
+ audiopath->configure(core.card, core.stream_group,
+ core.stream_count);
+
*info = &coreinfo;
return 0;
@@ -356,10 +362,14 @@ struct avirt_stream *__avirt_stream_create(const char *name, int direction)
int __avirt_card_register(void)
{
int err = 0;
-
struct avirt_audiopath_obj *ap_obj;
- list_for_each_entry(ap_obj, &audiopath_list, list)
- {
+
+ if (core.streams_sealed) {
+ pr_err("Streams already sealed!\n");
+ return -1;
+ }
+
+ list_for_each_entry (ap_obj, &audiopath_list, list) {
pr_info("Calling configure for AP uid: %s\n",
ap_obj->path->uid);
ap_obj->path->configure(core.stream_group, core.stream_count);
@@ -371,9 +381,16 @@ int __avirt_card_register(void)
snd_card_free(core.card);
}
+ core.streams_sealed = true;
+
return err;
}
+bool __avirt_streams_sealed(void)
+{
+ return core.streams_sealed;
+}
+
struct avirt_stream *__avirt_stream_find_by_device(unsigned int device)
{
struct avirt_stream *stream;
diff --git a/core_internal.h b/core_internal.h
index 3639d6e..e7bea07 100644
--- a/core_internal.h
+++ b/core_internal.h
@@ -20,6 +20,7 @@ struct avirt_core {
struct class *avirt_class;
struct config_group *stream_group;
unsigned int stream_count;
+ bool streams_sealed;
};
int __init __avirt_configfs_init(struct avirt_core *core);
@@ -32,6 +33,13 @@ void __exit __avirt_configfs_exit(struct avirt_core *core);
int __avirt_card_register(void);
/**
+ * __avirt_streams_sealed - Check whether the streams have been sealed or not
+ * @return: true if sealed, false otherwise
+ */
+bool __avirt_streams_sealed(void);
+
+/**
+/**
* __avirt_stream_find_by_device - Get audio stream from device number
* @device: The PCM device number corresponding to the desired stream
* @return: The audio stream if found, or an error pointer otherwise