aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames O'Shannessy <james.oshannessy@fiberdyne.com.au>2018-10-02 15:55:55 +1000
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-26 17:27:29 +1100
commit55d9a9f22aa909449925da9cb2e8de4d5a41bdfb (patch)
treef07b99a5b5955128e3a48aa25e3a2a97013eceb5
parentbc249f293cab17c0dcde886fccc26deb0dfca33c (diff)
Loopback progress
Loopback currently reads from dma_area but the initial copy from playback to capture has not been implemented. Signed-off-by: James O'Shannessy <james.oshannessy@fiberdyne.com.au>
-rw-r--r--alsa-pcm.c10
-rwxr-xr-xalsa.c6
-rw-r--r--core.c18
-rw-r--r--core.h16
-rw-r--r--loopback/loopback.c20
5 files changed, 43 insertions, 27 deletions
diff --git a/alsa-pcm.c b/alsa-pcm.c
index 4fd4323..8c01c36 100644
--- a/alsa-pcm.c
+++ b/alsa-pcm.c
@@ -59,8 +59,12 @@ static int configure_pcm(struct snd_pcm_substream *substream)
CHK_NULL(group);
// Check if substream id is valid
- if (substream->pcm->device >= group->devices)
+ pr_info("%d substream is < %d", substream->pcm->device, group->devices);
+ if (substream->pcm->device >= group->devices) {
+ pr_err("%s %d substream id is invalid expecting %d", __func__,
+ substream->pcm->device, group->devices);
return -1;
+ }
// Setup remaining hw properties
config = &group->config[substream->pcm->device];
@@ -158,7 +162,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
}
// Do additional Audio Path 'hw_params' callback
- // DO_AUDIOPATH_CB(hw_params, substream, hw_params);
+ DO_AUDIOPATH_CB(hw_params, substream, hw_params);
return 0;
}
@@ -178,7 +182,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
CHK_ERR(snd_pcm_lib_free_vmalloc_buffer(substream));
// Do additional Audio Path 'hw_free' callback
- // DO_AUDIOPATH_CB(hw_free, substream);
+ DO_AUDIOPATH_CB(hw_free, substream);
return 0;
}
diff --git a/alsa.c b/alsa.c
index e283794..44e0b15 100755
--- a/alsa.c
+++ b/alsa.c
@@ -32,10 +32,11 @@ static int pcm_constructor(struct snd_card *card)
for (i = 0; i < _driver->playback.devices; i++) {
CHK_ERR(snd_pcm_new(card,
_driver->playback.config[i].devicename, i,
- 1, 0, &pcm));
+ 1, 1, &pcm));
/** Register driver callbacks */
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_ops);
+ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_ops);
pcm->info_flags = 0;
strcpy(pcm->name, _driver->playback.config[i].devicename);
@@ -112,9 +113,8 @@ struct avirt_alsa_dev_group *avirt_alsa_get_dev_group(int direction)
switch (direction) {
case SNDRV_PCM_STREAM_PLAYBACK:
- return &_driver->playback;
case SNDRV_PCM_STREAM_CAPTURE:
- return &_driver->capture;
+ return &_driver->playback;
default:
pr_err("[%s] Direction must be SNDRV_PCM_STREAM_XXX!",
__func__);
diff --git a/core.c b/core.c
index 875e844..479b93e 100644
--- a/core.c
+++ b/core.c
@@ -19,6 +19,12 @@ MODULE_AUTHOR("MFARRUGI <mark.farrugia@fiberdyne.com.au>");
MODULE_DESCRIPTION("A configurable virtual soundcard");
MODULE_LICENSE("GPL v2");
+#define AP_LOGNAME "CORE"
+
+#define D_INFOK(fmt, args...) DINFO(AP_LOGNAME, fmt, ##args)
+#define D_PRINTK(fmt, args...) DPRINT(AP_LOGNAME, fmt, ##args)
+#define D_ERRORK(fmt, args...) DERROR(AP_LOGNAME, fmt, ##args)
+
#define SND_AVIRTUAL_DRIVER "snd_avirt"
#define MAX_PCM_DEVS 8
#define MAX_AUDIOPATHS 4
@@ -350,8 +356,8 @@ int avirt_register_audiopath(struct avirt_audiopath *audiopath,
audiopath_obj->path = audiopath;
audiopath->context = audiopath_obj;
- pr_info("Registered new Audio Path: %s\n", audiopath->name);
- pr_info("\tBlocksize: %d, Periods: %d\n", audiopath->blocksize,
+ D_INFOK("Registered new Audio Path: %s", audiopath->name);
+ D_INFOK("\tBlocksize: %d, Periods: %d", audiopath->blocksize,
audiopath->hw->periods_max);
list_add_tail(&audiopath_obj->list, &audiopath_list);
@@ -405,9 +411,9 @@ static void avirt_unregister_all(void)
static int __init core_init(void)
{
int err;
-
- pr_info("Alsa Virtual Sound Driver avirt-%d.%d.%d\n",
- coreinfo.version[0], coreinfo.version[1], coreinfo.version[2]);
+ D_INFOK("Starting new core\n\n\n\n");
+ D_INFOK("Alsa Virtual Sound Driver avirt-%d.%d.%d", coreinfo.version[0],
+ coreinfo.version[1], coreinfo.version[2]);
// Initialize audiopaths linked list
INIT_LIST_HEAD(&audiopath_list);
@@ -466,7 +472,7 @@ static void __exit core_exit(void)
class_destroy(core.avirt_class);
avirt_unregister_all();
-
+ D_INFOK("Exit begin!");
pr_info("playback_num: %d, capture_num: %d\n", playback_num,
capture_num);
diff --git a/core.h b/core.h
index 6e3b651..7a562f4 100644
--- a/core.h
+++ b/core.h
@@ -12,16 +12,16 @@
#include <sound/pcm.h>
-#define DINFO(ap, fmt, args...) \
- printk(KERN_INFO "[%s] %d:%s " fmt "\n", ap, __LINE__, __func__, ##args)
+#define DINFO(ap, fmt, args...) \
+ printk(KERN_INFO "[%s]: %d:%s " fmt "\n", ap, __LINE__, __func__, \
+ ##args)
-#define DERROR(ap, fmt, args...) \
- printk(KERN_ERR "[%s] %d:%s " fmt "\n", AP_LOGNAME, __LINE__, \
- __func__, ##args)
+#define DERROR(ap, fmt, args...) \
+ printk(KERN_ERR "[%s]: %d:%s " fmt "\n", ap, __LINE__, __func__, ##args)
-#define DPRINT(ap, fmt, args...) \
- printk(KERN_DEBUG "[%s] %d:%s " fmt "\n", AP_LOGNAME, __LINE__, \
- __func__, ##args)
+#define DPRINT(ap, fmt, args...) \
+ printk(KERN_DEBUG "[%s]: %d:%s " fmt "\n", ap, __LINE__, __func__, \
+ ##args)
/**
* PCM buffer complete callback
diff --git a/loopback/loopback.c b/loopback/loopback.c
index a925eaa..5694dce 100644
--- a/loopback/loopback.c
+++ b/loopback/loopback.c
@@ -162,6 +162,7 @@ void loopback_callback(struct timer_list *tlist)
unsigned long flags;
int elapsed = 0;
+ AP_INFOK("");
spin_lock_irqsave(&dpcm->lock, flags);
// Perform copy from playback to capture
@@ -169,6 +170,7 @@ void loopback_callback(struct timer_list *tlist)
systimer_rearm(dpcm);
elapsed = dpcm->elapsed;
dpcm->elapsed = 0;
+
spin_unlock_irqrestore(&dpcm->lock, flags);
if (elapsed)
coreinfo->pcm_buff_complete(dpcm->substream);
@@ -184,9 +186,6 @@ static int loopback_pcm_open(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
struct loopback_pcm *dpcm = runtime->private_data;
- AP_INFOK("Open\n%s\nrate: %d\nch: %d", substream->pcm->name,
- runtime->rate, runtime->channels);
-
err = systimer_create(substream);
if (err < 0)
return err;
@@ -233,8 +232,10 @@ static int loopback_pcm_prepare(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
struct loopback_pcm *dpcm = runtime->private_data;
- AP_INFOK("Prepare");
- AP_INFOK("Runtime\nrate: %d\nch: %d", runtime->rate, runtime->channels);
+ AP_INFOK("%s\n%s\n%d\n%d", substream->pcm->name,
+ substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? "PLAYBACK" :
+ "CAPTURE",
+ runtime->rate, runtime->channels);
return systimer_prepare(substream);
}
@@ -255,11 +256,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_8000 | SNDRV_PCM_RATE_16000 |
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
SNDRV_PCM_RATE_48000,
.rate_min = 8000,
.rate_max = 48000,
+ */
+ .rates = SNDRV_PCM_RATE_48000,
+ .rate_min = 48000,
+ .rate_max = 48000,
.channels_min = 1,
.channels_max = 8,
//.buffer_bytes_max = 32768,
@@ -280,7 +286,7 @@ static int __init loopback_init(void)
{
int err = 0;
- AP_INFOK("init()\n");
+ AP_INFOK("init()");
err = avirt_register_audiopath(&loopbackap_module, &coreinfo);
if ((err < 0) || (!coreinfo)) {
@@ -293,7 +299,7 @@ static int __init loopback_init(void)
static void __exit loopback_exit(void)
{
- AP_INFOK("exit()\n");
+ AP_INFOK("loopback: exit()");
avirt_deregister_audiopath(&loopbackap_module);
}