aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames O'Shannessy <james.oshannessy@fiberdyne.com.au>2018-09-19 16:26:40 +1000
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-26 17:27:28 +1100
commitb46cfdf55851280f0c90c7b54ba041932ddfa397 (patch)
tree75d57248b31744276a64d26c1a646ccb22dfb9bc
parent7bbfc5e47a58851dbb56da1c4b77e534ca00c782 (diff)
Changes to loopback
Added more detailed printing to loopback, alsa-pcm. Updated load and unload functions Signed-off-by: James O'Shannessy <james.oshannessy@fiberdyne.com.au>
-rw-r--r--alsa-pcm.c9
-rwxr-xr-xloadDrivers.sh5
-rw-r--r--loopback/loopback.c56
-rwxr-xr-xunload.sh3
4 files changed, 62 insertions, 11 deletions
diff --git a/alsa-pcm.c b/alsa-pcm.c
index 342188b..0f623f6 100644
--- a/alsa-pcm.c
+++ b/alsa-pcm.c
@@ -10,6 +10,9 @@
#include "core.h"
#include "alsa.h"
+#define DINFO(fmt, args...) \
+ printk(KERN_INFO "[CORE] %d:%s " fmt "\n", __LINE__, __func__, ##args)
+
#define DO_AUDIOPATH_CB(callback, substream, ...) \
do { \
struct avirt_audiopath *ap; \
@@ -86,6 +89,7 @@ static int configure_pcm(struct snd_pcm_substream *substream)
*/
static int pcm_open(struct snd_pcm_substream *substream)
{
+ DINFO("");
// Setup the pcm device based on the configuration assigned
CHK_ERR_V(configure_pcm(substream), "Failed to setup pcm device");
@@ -105,6 +109,7 @@ static int pcm_open(struct snd_pcm_substream *substream)
*/
static int pcm_close(struct snd_pcm_substream *substream)
{
+ DINFO("");
// Do additional Audio Path 'close' callback
DO_AUDIOPATH_CB(close, substream);
@@ -191,6 +196,8 @@ static int pcm_prepare(struct snd_pcm_substream *substream)
struct avirt_alsa_dev_group *group;
struct snd_pcm_runtime *runtime = substream->runtime;
+ DINFO("");
+
group = avirt_alsa_get_dev_group(substream->stream);
CHK_NULL(group);
@@ -219,6 +226,8 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{
struct avirt_alsa_dev_group *group;
+ DINFO("");
+
group = avirt_alsa_get_dev_group(substream->stream);
CHK_NULL(group);
diff --git a/loadDrivers.sh b/loadDrivers.sh
index fca3203..9ff5960 100755
--- a/loadDrivers.sh
+++ b/loadDrivers.sh
@@ -13,6 +13,7 @@ capture_names=voice"
insmod avirt_core.ko "$params"
# Load the additional audio path
-insmod dummy/avirt_dummyap.ko
+#insmod dummy/avirt_dummyap.ko
+insmod loopback/avirt_loopbackap.ko
-echo "Drivers Loaded!" \ No newline at end of file
+echo "Drivers Loaded!"
diff --git a/loopback/loopback.c b/loopback/loopback.c
index 6f2a5d9..215ed5d 100644
--- a/loopback/loopback.c
+++ b/loopback/loopback.c
@@ -16,6 +16,20 @@ MODULE_AUTHOR("MFARRUGI <mark.farrugia@fiberdyne.com.au>");
MODULE_DESCRIPTION("Sample Audio Path Module Interface");
MODULE_LICENSE("GPL v2");
+#define AP_LOGNAME "LOOPAP"
+
+#define DERROR(fmt, args...) \
+ printk(KERN_ERR "[%s] %d:%s " fmt "\n", AP_LOGNAME, __LINE__, \
+ __func__, ##args)
+
+#define DINFO(fmt, args...) \
+ printk(KERN_INFO "[%s] %d:%s " fmt "\n", AP_LOGNAME, __LINE__, \
+ __func__, ##args)
+
+#define DPRINT(fmt, args...) \
+ printk(KERN_DEBUG "[%s] %d:%s " fmt "\n", AP_LOGNAME, __LINE__, \
+ __func__, ##args)
+
static struct avirt_coreinfo *coreinfo;
struct loopback_pcm {
@@ -148,6 +162,7 @@ void systimer_update(struct loopback_pcm *dpcm)
* Loopback Timer Callback
*******/
+//
void loopback_callback(struct timer_list *tlist)
{
struct loopback_pcm *dpcm = from_timer(dpcm, tlist, timer);
@@ -172,7 +187,15 @@ void loopback_callback(struct timer_list *tlist)
******************************************************************************/
static int loopback_pcm_open(struct snd_pcm_substream *substream)
{
- int err = systimer_create(substream);
+ int err;
+
+ struct snd_pcm_runtime *runtime = substream->runtime;
+ struct loopback_pcm *dpcm = runtime->private_data;
+
+ DINFO("Open\n%s\nrate: %d\nch: %d", substream->pcm->name, runtime->rate,
+ runtime->channels);
+
+ err = systimer_create(substream);
if (err < 0)
return err;
@@ -181,6 +204,11 @@ static int loopback_pcm_open(struct snd_pcm_substream *substream)
static int loopback_pcm_close(struct snd_pcm_substream *substream)
{
+ struct snd_pcm_runtime *runtime = substream->runtime;
+ struct loopback_pcm *dpcm = runtime->private_data;
+
+ DINFO("Close");
+
systimer_free(substream);
return 0;
}
@@ -188,11 +216,15 @@ static int loopback_pcm_close(struct snd_pcm_substream *substream)
static snd_pcm_uframes_t
loopback_pcm_pointer(struct snd_pcm_substream *substream)
{
+ DINFO("Pointer");
+
return systimer_pointer(substream);
}
static int loopback_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{
+ DINFO("Trigger");
+
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
@@ -206,6 +238,12 @@ static int loopback_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
static int loopback_pcm_prepare(struct snd_pcm_substream *substream)
{
+ struct snd_pcm_runtime *runtime = substream->runtime;
+ struct loopback_pcm *dpcm = runtime->private_data;
+
+ DINFO("Prepare");
+ DINFO("Runtime\nrate: %d\nch: %d", runtime->rate, runtime->channels);
+
return systimer_prepare(substream);
}
@@ -225,14 +263,16 @@ static struct snd_pcm_hardware loopbackap_hw = {
.info = (SNDRV_PCM_INFO_INTERLEAVED // Channel interleaved audio
| SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID),
- .rates = SNDRV_PCM_RATE_48000,
- .rate_min = 2000,
+ .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+ SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
+ SNDRV_PCM_RATE_48000,
+ .rate_min = 8000,
.rate_max = 48000,
.channels_min = 1,
.channels_max = 8,
- .buffer_bytes_max = 32768,
+ //.buffer_bytes_max = 32768,
.periods_min = 1,
- .periods_max = 1024,
+ .periods_max = 8,
};
static struct avirt_audiopath loopbackap_module = {
@@ -248,11 +288,11 @@ static int __init loopback_init(void)
{
int err = 0;
- pr_info("init()\n");
+ DINFO("init()\n");
err = avirt_register_audiopath(&loopbackap_module, &coreinfo);
if ((err < 0) || (!coreinfo)) {
- pr_err("%s: coreinfo is NULL!\n", __func__);
+ DERROR("%s: coreinfo is NULL!\n", __func__);
return err;
}
@@ -261,7 +301,7 @@ static int __init loopback_init(void)
static void __exit loopback_exit(void)
{
- pr_info("exit()\n");
+ DINFO("exit()\n");
avirt_deregister_audiopath(&loopbackap_module);
}
diff --git a/unload.sh b/unload.sh
index 02ed767..a011a2b 100755
--- a/unload.sh
+++ b/unload.sh
@@ -4,6 +4,7 @@ rm_module() {
lsmod |grep "^$1\>" && rmmod $1 || true
}
+rm_module avirt_loopbackap
rm_module avirt_dummyap
rm_module avirt_core
-echo "Drivers Removed!" \ No newline at end of file
+echo "Drivers Removed!"