diff options
Diffstat (limited to 'core.c')
-rw-r--r-- | core.c | 88 |
1 files changed, 44 insertions, 44 deletions
@@ -44,9 +44,9 @@ struct snd_avirt_audiopath_obj { static struct kset *snd_avirt_audiopath_kset; static struct kobject *kobj; -#define to_audiopath_obj(d) \ +#define to_audiopath_obj(d) \ container_of(d, struct snd_avirt_audiopath_obj, kobj) -#define to_audiopath_attr(a) \ +#define to_audiopath_attr(a) \ container_of(a, struct snd_avirt_audiopath_attribute, attr) /** @@ -188,6 +188,15 @@ static struct snd_avirt_audiopath_obj * return snd_avirt_audiopath; } +/** + * destroy_snd_avirt_audiopath_obj - destroys an Audio Path object + * @name: the Audio Path object + */ +static void destroy_snd_avirt_audiopath_obj(struct snd_avirt_audiopath_obj *p) +{ + kobject_put(&p->kobj); +} + static struct snd_pcm *pcm_create(struct snd_avirt_stream *stream) { bool playback = false, capture = false; @@ -223,13 +232,22 @@ static struct snd_pcm *pcm_create(struct snd_avirt_stream *stream) return pcm; } -/** - * destroy_snd_avirt_audiopath_obj - destroys an Audio Path object - * @name: the Audio Path object - */ -static void destroy_snd_avirt_audiopath_obj(struct snd_avirt_audiopath_obj *p) +static int snd_avirt_streams_get(const char *map, + struct snd_avirt_stream_array *stream_array) { - kobject_put(&p->kobj); + struct list_head *entry; + struct config_item *item; + struct snd_avirt_stream *stream; + + list_for_each (entry, &core.stream_group->cg_children) { + item = container_of(entry, struct config_item, ci_entry); + stream = snd_avirt_stream_from_config_item(item); + if (!strcmp(map, stream->map)) { + stream_array->streams[stream_array->count++] = stream; + } + } + + return 0; } /** @@ -258,6 +276,7 @@ struct snd_avirt_audiopath *snd_avirt_audiopath_get(const char *uid) int snd_avirt_audiopath_register(struct snd_avirt_audiopath *audiopath) { struct snd_avirt_audiopath_obj *audiopath_obj; + struct snd_avirt_stream_array stream_array; if (!audiopath) { D_ERRORK("Audio Path is NULL!"); @@ -277,11 +296,11 @@ int snd_avirt_audiopath_register(struct snd_avirt_audiopath *audiopath) 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; + if (core.streams_sealed) { + stream_array.count = 0; + snd_avirt_streams_get(audiopath->uid, &stream_array); + audiopath->configure(core.card, &stream_array); + } return 0; } @@ -317,34 +336,6 @@ int snd_avirt_audiopath_deregister(struct snd_avirt_audiopath *audiopath) EXPORT_SYMBOL_GPL(snd_avirt_audiopath_deregister); /** - * snd_avirt_stream_count - get the stream count for the given direction - * @direction: The direction to get the stream count for - * @return: The stream count - */ -int snd_avirt_stream_count(unsigned int direction) -{ - struct list_head *entry; - struct config_item *item; - struct snd_avirt_stream *stream; - unsigned int count = 0; - - if (direction > 1) - return -ERANGE; - - list_for_each(entry, &core.stream_group->cg_children) { - item = container_of(entry, struct config_item, ci_entry); - stream = snd_avirt_stream_from_config_item(item); - if (!stream) - return -EFAULT; - if (stream->direction == direction) - count++; - } - - return count; -} -EXPORT_SYMBOL_GPL(snd_avirt_stream_count); - -/** * snd_avirt_stream_create - Create audio stream, including it's ALSA PCM device * @name: The name designated to the audio stream * @direction: The PCM direction (SNDRV_PCM_STREAM_PLAYBACK or @@ -356,6 +347,11 @@ struct snd_avirt_stream *snd_avirt_stream_create(const char *name, { struct snd_avirt_stream *stream; + if ((core.stream_count + 1) > MAX_STREAMS) { + D_ERRORK("Cannot add stream %s, PCMs are maxxed out!", name); + return ERR_PTR(-EPERM); + } + stream = kzalloc(sizeof(*stream), GFP_KERNEL); if (!stream) return ERR_PTR(-ENOMEM); @@ -373,9 +369,10 @@ struct snd_avirt_stream *snd_avirt_stream_create(const char *name, int snd_avirt_streams_seal(void) { - int err = 0; + int err = 0, i = 0; struct snd_avirt_audiopath_obj *ap_obj; struct snd_avirt_stream *stream; + struct snd_avirt_stream_array stream_array; struct config_item *item; struct list_head *entry; @@ -396,8 +393,11 @@ int snd_avirt_streams_seal(void) list_for_each_entry(ap_obj, &audiopath_list, list) { D_INFOK("configure() AP uid: %s", ap_obj->path->uid); - ap_obj->path->configure(core.card, core.stream_group, - core.stream_count); + for (i = 0; i < MAX_STREAMS; i++) + stream_array.streams[i] = NULL; + stream_array.count = 0; + snd_avirt_streams_get(ap_obj->path->uid, &stream_array); + ap_obj->path->configure(core.card, &stream_array); } err = snd_card_register(core.card); |