From: Vinod Koul <vinod.koul@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, Vinod Koul <vinod.koul@linux.intel.com>,
broonie@opensource.wolfsonmicro.com, lrg@ti.com
Subject: [PATCH 1/3] ALSA: pcm - introduce device_buffer
Date: Fri, 31 Aug 2012 06:44:42 +0530 [thread overview]
Message-ID: <1346375684-4145-2-git-send-email-vinod.koul@linux.intel.com> (raw)
In-Reply-To: <1346375684-4145-1-git-send-email-vinod.koul@linux.intel.com>
In many modern SoCs the audio DSP can buffer the PCM ring buffer data, typically
in SRAMs or any other memory available.
Today we have no means to represent this buffering and ALSA in some cases when
device still has to render this buffer but app_ptr is equal to hw_ptr alsa
wrongly detects an overrun
This patch tries to add a new field "device_buffer" to represent buffering done in
DSPs. This value is also used for the xrun calculations in ALSA
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
---
include/sound/pcm.h | 1 +
sound/core/pcm_lib.c | 10 +++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index c75c0d1..58e669a 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -281,6 +281,7 @@ struct snd_pcm_runtime {
unsigned long hw_ptr_jiffies; /* Time when hw_ptr is updated */
unsigned long hw_ptr_buffer_jiffies; /* buffer time in jiffies */
snd_pcm_sframes_t delay; /* extra delay; typically FIFO size */
+ snd_pcm_sframes_t device_buffer; /* buffered data in device/driver */
/* -- HW params -- */
snd_pcm_access_t access; /* access mode */
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 7ae6719..9b0127f 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -292,7 +292,15 @@ int snd_pcm_update_state(struct snd_pcm_substream *substream,
return -EPIPE;
}
} else {
- if (avail >= runtime->stop_threshold) {
+ snd_pcm_uframes_t actual_avail;
+ if (avail < runtime->device_buffer)
+ actual_avail = avail;
+ else
+ actual_avail = avail - runtime->device_buffer;
+ if (actual_avail >= runtime->stop_threshold) {
+ snd_printd(KERN_ERR "avail > stop_threshold!!\n");
+ snd_printd(KERN_ERR "actual_avail %ld, avail %ld, device_buffer %ld!!\n",
+ actual_avail, avail, runtime->device_buffer);
xrun(substream);
return -EPIPE;
}
--
1.7.9.5
next prev parent reply other threads:[~2012-08-31 1:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-31 1:14 [PATCH v3 0/3] introduce device_buffer Vinod Koul
2012-08-31 1:14 ` Vinod Koul [this message]
2012-08-31 2:06 ` [PATCH 1/3] ALSA: pcm - " Raymond Yau
2012-08-31 15:05 ` Vinod Koul
2012-08-31 10:48 ` Jaroslav Kysela
2012-08-31 15:02 ` Vinod Koul
2012-08-31 1:14 ` [PATCH 2/3] ASoC: add device_buffer in asoc Vinod Koul
2012-08-31 1:14 ` [PATCH 3/3] ASoC: mid-x86 - implement buffer query in sst_platform driver Vinod Koul
2012-08-31 10:41 ` [PATCH v3 0/3] introduce device_buffer Jaroslav Kysela
2012-08-31 14:53 ` Vinod Koul
2012-09-04 14:24 ` Takashi Iwai
-- strict thread matches above, loose matches on Subject: below --
2012-08-30 19:12 [PATCH " Vinod Koul
2012-08-30 19:12 ` [PATCH 1/3] ALSA: pcm - " Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1346375684-4145-2-git-send-email-vinod.koul@linux.intel.com \
--to=vinod.koul@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lrg@ti.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).