From 18007ca500654b48011e8a8cf96c47b1a5aa3be7 Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Thu, 25 Oct 2018 15:56:58 +1100 Subject: Move system-leavel header to sound directory Change include guards to reflect Linux sound driver format Signed-off-by: Mark Farrugia --- Makefile | 2 +- configfs.c | 3 +- core.c | 3 +- core.h | 123 ---------------------------------------------------- core_internal.h | 8 ++-- dummy/Makefile | 2 +- dummy/dummy.c | 2 +- loopback/Makefile | 2 +- loopback/loopback.c | 3 +- sound/avirt.h | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++ utils.h | 14 +++--- 11 files changed, 141 insertions(+), 143 deletions(-) delete mode 100644 core.h create mode 100644 sound/avirt.h diff --git a/Makefile b/Makefile index 44874ca..791a60a 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ avirt_core-y += configfs.o ifeq ($(CONFIG_AVIRT_BUILDLOCAL),) CCFLAGS_AVIRT := "drivers/staging/" else - CCFLAGS_AVIRT := "$(PWD)/../" + CCFLAGS_AVIRT := "$(PWD)" endif ccflags-y += -I${CCFLAGS_AVIRT} diff --git a/configfs.c b/configfs.c index 13e38b2..49eaa78 100644 --- a/configfs.c +++ b/configfs.c @@ -7,7 +7,8 @@ * configfs.c - AVIRT configfs support */ -#include +#include + #include "core_internal.h" #define D_LOGNAME "configfs" diff --git a/core.c b/core.c index b63944a..6509b55 100644 --- a/core.c +++ b/core.c @@ -9,9 +9,8 @@ #include #include -#include +#include #include -#include #include "core_internal.h" diff --git a/core.h b/core.h deleted file mode 100644 index bac4fc0..0000000 --- a/core.h +++ /dev/null @@ -1,123 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * ALSA Virtual Soundcard - * - * core.h - System-level header for virtual ALSA card - * - * Copyright (C) 2010-2018 Fiberdyne Systems Pty Ltd - */ - -#ifndef __AVIRT_CORE_H__ -#define __AVIRT_CORE_H__ - -#include -#include - -#define MAX_STREAMS 16 -#define MAX_NAME_LEN 80 - -#define DINFO(logname, fmt, args...) \ - printk(KERN_INFO "[AVIRT][%s]: " fmt "\n", logname, ##args) - -#define DERROR(logname, fmt, args...) \ - printk(KERN_ERR "[AVIRT][%s]: %d:%s " fmt "\n", logname, __LINE__, \ - __func__, ##args) - -#define DDEBUG(logname, fmt, args...) \ - printk(KERN_DEBUG "[AVIRT][%s]: %d:%s " fmt "\n", logname, __LINE__, \ - __func__, ##args) - -/** - * AVIRT Audio Path configure function type - * Each Audio Path registers this at avirt_audiopath_register time. - * It is then called by the core once AVIRT has been configured - */ -typedef int (*avirt_audiopath_configure)(struct snd_card *card, - struct config_group *stream_group, - unsigned int stream_count); - -/** - * AVIRT Audio Path info - */ -struct avirt_audiopath { - const char *uid; /* Unique identifier */ - const char *name; /* Pretty name */ - unsigned int version[3]; /* Version - Major.Minor.Ext */ - const struct snd_pcm_hardware *hw; /* ALSA PCM HW conf */ - const struct snd_pcm_ops *pcm_ops; /* ALSA PCM op table */ - avirt_audiopath_configure configure; /* Configure callback function */ - - void *context; -}; - -/* - * Audio stream configuration - */ -struct avirt_stream { - char name[MAX_NAME_LEN]; /* Stream name */ - char map[MAX_NAME_LEN]; /* Stream Audio Path mapping */ - unsigned int channels; /* Stream channel count */ - unsigned int device; /* Stream PCM device no. */ - unsigned int direction; /* Stream direction */ - struct snd_pcm *pcm; /* ALSA PCM */ - struct config_item item; /* configfs item reference */ -}; - -/** - * AVIRT core info - */ -struct avirt_coreinfo { - unsigned int version[3]; -}; - -/** - * avirt_audiopath_register - register Audio Path with ALSA virtual driver - * @audiopath: Audio Path to be registered - * @core: ALSA virtual driver core info - * @return: 0 on success or error code otherwise - */ -int avirt_audiopath_register(struct avirt_audiopath *audiopath, - struct avirt_coreinfo **coreinfo); - -/** - * avirt_audiopath_deregister - deregister Audio Path with ALSA virtual driver - * @audiopath: Audio Path to be deregistered - * @return: 0 on success or error code otherwise - */ -int avirt_audiopath_deregister(struct avirt_audiopath *audiopath); - -/** - * avirt_audiopath_get - retrieves the Audio Path by it's UID - * @uid: Unique ID for the Audio Path - * @return: Corresponding Audio Path - */ -struct avirt_audiopath *avirt_audiopath_get(const char *uid); - -/** - * 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 avirt_stream_count(unsigned int direction); - -/** - * avirt_stream_from_config_item - Convert a config_item to an avirt_stream - * @item: The config_item to convert from - * @return: The item's avirt_stream if successful, NULL otherwise - */ -static inline struct avirt_stream * -avirt_stream_from_config_item(struct config_item *item) -{ - return item ? container_of(item, struct avirt_stream, item) : NULL; -} - -/** - * avirt_pcm_period_elapsed - PCM buffer complete callback - * @substream: pointer to ALSA PCM substream - * - * This should be called from a child Audio Path once it has finished processing - * the PCM buffer - */ -void avirt_pcm_period_elapsed(struct snd_pcm_substream *substream); - -#endif // __AVIRT_CORE_H__ diff --git a/core_internal.h b/core_internal.h index 5bff1c8..f3fcb48 100644 --- a/core_internal.h +++ b/core_internal.h @@ -7,10 +7,10 @@ * core_internal.h - AVIRT internal header */ -#ifndef __AVIRT_CORE_INTERNAL_H__ -#define __AVIRT_CORE_INTERNAL_H__ +#ifndef __SOUND_AVIRT_CORE_H +#define __SOUND_AVIRT_CORE_H -#include +#include #include "utils.h" @@ -64,4 +64,4 @@ struct avirt_stream *__avirt_stream_find_by_device(unsigned int device); */ struct avirt_stream *__avirt_stream_create(const char *name, int direction); -#endif // __AVIRT_CORE_INTERNAL_H__ +#endif /* __SOUND_AVIRT_CORE_H */ diff --git a/dummy/Makefile b/dummy/Makefile index 965bd1a..78579d7 100644 --- a/dummy/Makefile +++ b/dummy/Makefile @@ -3,4 +3,4 @@ obj-$(CONFIG_AVIRT_DUMMYAP) += avirt_dummyap.o $(info $(src)) avirt_dummyap-objs := dummy.o ccflags-y += -Idrivers/staging/ -ccflags-y += -I$(src)/../../ +ccflags-y += -I$(src)/../ diff --git a/dummy/dummy.c b/dummy/dummy.c index 596838d..100972a 100644 --- a/dummy/dummy.c +++ b/dummy/dummy.c @@ -13,7 +13,7 @@ #include #include -#include +#include MODULE_AUTHOR("James O'Shannessy "); MODULE_AUTHOR("Mark Farrugia "); diff --git a/loopback/Makefile b/loopback/Makefile index 0464aba..9d3c606 100644 --- a/loopback/Makefile +++ b/loopback/Makefile @@ -4,4 +4,4 @@ obj-$(CONFIG_AVIRT_LOOPBACKAP) += avirt_loopbackap.o $(info $(src)) avirt_loopbackap-objs := loopback.o ccflags-y += -Idrivers/staging/ -ccflags-y += -I$(src)/../../ +ccflags-y += -I$(src)/../ diff --git a/loopback/loopback.c b/loopback/loopback.c index acddf99..ba9225e 100644 --- a/loopback/loopback.c +++ b/loopback/loopback.c @@ -27,13 +27,12 @@ #include #include #include -#include #include #include #include #include #include -#include +#include MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Loopback Audio Path for AVIRT"); diff --git a/sound/avirt.h b/sound/avirt.h new file mode 100644 index 0000000..5df84fe --- /dev/null +++ b/sound/avirt.h @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AVIRT - ALSA Virtual Soundcard + * + * Copyright (c) 2010-2018 Fiberdyne Systems Pty Ltd + * + * avirt.h - AVIRT system-level header + */ + +#ifndef __SOUND_AVIRT_H +#define __SOUND_AVIRT_H + +#include +#include +#include + +#define MAX_STREAMS 16 +#define MAX_NAME_LEN 80 + +#define DINFO(logname, fmt, args...) \ + snd_printk(KERN_INFO "AVIRT: %s: " fmt "\n", logname, ##args) + +#define DERROR(logname, fmt, args...) \ + snd_printk(KERN_ERR "AVIRT: %s: " fmt "\n", logname, ##args) + +#define DDEBUG(logname, fmt, args...) \ + snd_printk(KERN_DEBUG "AVIRT: %s: " fmt "\n", logname, ##args) + +/** + * AVIRT Audio Path configure function type + * Each Audio Path registers this at avirt_audiopath_register time. + * It is then called by the core once AVIRT has been configured + */ +typedef int (*avirt_audiopath_configure)(struct snd_card *card, + struct config_group *stream_group, + unsigned int stream_count); + +/** + * AVIRT Audio Path info + */ +struct avirt_audiopath { + const char *uid; /* Unique identifier */ + const char *name; /* Pretty name */ + unsigned int version[3]; /* Version - Major.Minor.Ext */ + const struct snd_pcm_hardware *hw; /* ALSA PCM HW conf */ + const struct snd_pcm_ops *pcm_ops; /* ALSA PCM op table */ + avirt_audiopath_configure configure; /* Configure callback function */ + + void *context; +}; + +/* + * Audio stream configuration + */ +struct avirt_stream { + char name[MAX_NAME_LEN]; /* Stream name */ + char map[MAX_NAME_LEN]; /* Stream Audio Path mapping */ + unsigned int channels; /* Stream channel count */ + unsigned int device; /* Stream PCM device no. */ + unsigned int direction; /* Stream direction */ + struct snd_pcm *pcm; /* ALSA PCM */ + struct config_item item; /* configfs item reference */ +}; + +/** + * AVIRT core info + */ +struct avirt_coreinfo { + unsigned int version[3]; +}; + +/** + * avirt_audiopath_register - register Audio Path with ALSA virtual driver + * @audiopath: Audio Path to be registered + * @core: ALSA virtual driver core info + * @return: 0 on success or error code otherwise + */ +int avirt_audiopath_register(struct avirt_audiopath *audiopath, + struct avirt_coreinfo **coreinfo); + +/** + * avirt_audiopath_deregister - deregister Audio Path with ALSA virtual driver + * @audiopath: Audio Path to be deregistered + * @return: 0 on success or error code otherwise + */ +int avirt_audiopath_deregister(struct avirt_audiopath *audiopath); + +/** + * avirt_audiopath_get - retrieves the Audio Path by it's UID + * @uid: Unique ID for the Audio Path + * @return: Corresponding Audio Path + */ +struct avirt_audiopath *avirt_audiopath_get(const char *uid); + +/** + * 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 avirt_stream_count(unsigned int direction); + +/** + * avirt_stream_from_config_item - Convert a config_item to an avirt_stream + * @item: The config_item to convert from + * @return: The item's avirt_stream if successful, NULL otherwise + */ +static inline struct avirt_stream * +avirt_stream_from_config_item(struct config_item *item) +{ + return item ? container_of(item, struct avirt_stream, item) : NULL; +} + +/** + * avirt_pcm_period_elapsed - PCM buffer complete callback + * @substream: pointer to ALSA PCM substream + * + * This should be called from a child Audio Path once it has finished processing + * the PCM buffer + */ +void avirt_pcm_period_elapsed(struct snd_pcm_substream *substream); + +#endif // __SOUND_AVIRT_H diff --git a/utils.h b/utils.h index 34e273f..844ee55 100644 --- a/utils.h +++ b/utils.h @@ -1,14 +1,14 @@ // SPDX-License-Identifier: GPL-2.0 /* - * ALSA Virtual Soundcard + * AVIRT - ALSA Virtual Soundcard * - * utils.h - Some useful utilities for AVIRT - * - * Copyright (C) 2010-2018 Fiberdyne Systems Pty Ltd + * Copyright (c) 2010-2018 Fiberdyne Systems Pty Ltd + * + * utils.h - Some useful macros/utils for AVIRT */ -#ifndef __AVIRT_UTILS_H__ -#define __AVIRT_UTILS_H__ +#ifndef __SOUND_AVIRT_UTILS_H +#define __SOUND_AVIRT_UTILS_H #include @@ -46,4 +46,4 @@ } \ } while (0) -#endif +#endif /* __SOUND_AVIRT_UTILS_H */ -- cgit