- Backport upstream fix patches, including the deadlock fix for aplay/arecord (boo#1031525): 0001-ucm-Add-ATTRIBUTE_UNUSED-for-unused-parameters-of-ex.patch 0002-ucm-parser-needs-limits.h.patch 0003-pcm-direct-allow-users-to-configure-different-period.patch 0004-pcm-dshare-enable-silence.patch 0005-pcm-rate-fix-the-hw_ptr-update-until-the-boundary-av.patch 0006-plugin-dynamically-update-avail_min-on-slave.patch 0007-rate-dynamic-update-avail_min-on-slave.patch 0008-topology-fix-unused-const-variable-warning.patch 0009-seq-improve-documentation-about-new-get-pid-card-fun.patch 0010-pcm-direct-returning-semop-error-code-for-semaphore-.patch 0011-pcm-direct-Fix-for-sync-issue-on-xrun-recover.patch 0012-pcm-direct-check-state-before-enter-poll-on-timer.patch 0013-pcm-direct-don-t-return-bogus-buffer-levels-in-xrun-.patch 0014-conf-ucm-broxton-add-broxton-rt298-conf-files.patch 0015-pcm-direct-Fix-deadlock-in-poll_descriptors.patch 0016-ucm-Assure-the-user-input-card-name-not-to-exceed-ma.patch 0017-ucm-Load-device-specific-configuration-file-based-on.patch 0018-ucm-Add-command-get-_file-to-get-the-config-file-nam.patch 0019-topology-Fix-incorrect-license-in-source-comments.patch 0020-conf-cards-add-support-for-pistachio-card.patch 0021-pcm-multi-Drop-the-fixed-slave_map-in-snd_pcm_multi_.patch 0022-conf-Add-card-config-for-Intel-HDMI-DP-LPE-audio.patch 0023-pcm-Avoid-lock-for-snd_pcm_nonblock.patch 0024-pcm-Disable-locking-in-async-mode.patch 0025-pcm-dmix-Allow-disabling-x86-optimizations.patch 0026-pcm-dmix_rewind-corrupts-application-pointer-fix.patch 0027-pcm-direct-fix-race-on-clearing-timer-events.patch 0028-pcm-file-Enable-file-writing-for-capture-path.patch OBS-URL: https://build.opensuse.org/request/show/483406 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=210
93 lines
3.6 KiB
Diff
93 lines
3.6 KiB
Diff
From 7570e5d77514d8d8af387da04a010fa2ccaf543c Mon Sep 17 00:00:00 2001
|
|
From: "mahendran.k" <mahendran.kuppusamy@in.bosch.com>
|
|
Date: Fri, 30 Dec 2016 11:59:27 +0530
|
|
Subject: [PATCH 05/43] pcm: rate: fix the hw_ptr update until the boundary
|
|
available
|
|
|
|
For long time test case, the slave_hw_ptr will exceed the boundary
|
|
and wraparound the slave_hw_ptr. This slave boundary wraparound will
|
|
cause the rate->hw_ptr to wraparound irrespective of the
|
|
rate->boundary availability and due to that the available size goes
|
|
wrong.
|
|
|
|
Hence, to get the correct available size,
|
|
- Its necessary to increment the rate->hw_ptr upto the rate->boundary
|
|
and then wraparound the rate->hw_ptr.
|
|
- While handling fraction part of slave period, rounded value will be
|
|
introduced by input_frames(). To eliminate rounding issue on
|
|
rate->hw_ptr, subtract last rounded value from rate->hw_ptr and add
|
|
new rounded value of present slave_hw_ptr fraction part to
|
|
rate->hw_ptr.
|
|
|
|
Signed-off-by: mahendran.k <mahendran.kuppusamy@in.bosch.com>
|
|
Signed-off-by: Mounesh Sutar <mounesh_sutar@mentor.com>
|
|
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
---
|
|
src/pcm/pcm_rate.c | 31 +++++++++++++++++++++++++------
|
|
1 file changed, 25 insertions(+), 6 deletions(-)
|
|
|
|
--- a/src/pcm/pcm_rate.c
|
|
+++ b/src/pcm/pcm_rate.c
|
|
@@ -50,7 +50,7 @@ typedef struct _snd_pcm_rate snd_pcm_rat
|
|
|
|
struct _snd_pcm_rate {
|
|
snd_pcm_generic_t gen;
|
|
- snd_pcm_uframes_t appl_ptr, hw_ptr;
|
|
+ snd_pcm_uframes_t appl_ptr, hw_ptr, last_slave_hw_ptr;
|
|
snd_pcm_uframes_t last_commit_ptr;
|
|
snd_pcm_uframes_t orig_avail_min;
|
|
snd_pcm_sw_params_t sw_params;
|
|
@@ -563,14 +563,31 @@ static inline void snd_pcm_rate_sync_hwp
|
|
{
|
|
snd_pcm_rate_t *rate = pcm->private_data;
|
|
|
|
+ snd_pcm_sframes_t slave_hw_ptr_diff = slave_hw_ptr - rate->last_slave_hw_ptr;
|
|
+ snd_pcm_sframes_t last_slave_hw_ptr_frac;
|
|
+
|
|
if (pcm->stream != SND_PCM_STREAM_PLAYBACK)
|
|
return;
|
|
- /* FIXME: boundary overlap of slave hw_ptr isn't evaluated here!
|
|
- * e.g. if slave rate is small...
|
|
+
|
|
+ if (slave_hw_ptr_diff < 0)
|
|
+ slave_hw_ptr_diff += rate->gen.slave->boundary; /* slave boundary wraparound */
|
|
+ else if (slave_hw_ptr_diff == 0)
|
|
+ return;
|
|
+ last_slave_hw_ptr_frac = rate->last_slave_hw_ptr % rate->gen.slave->period_size;
|
|
+ /* While handling fraction part fo slave period, rounded value will be
|
|
+ * introduced by input_frames().
|
|
+ * To eliminate rounding issue on rate->hw_ptr, subtract last rounded
|
|
+ * value from rate->hw_ptr and add new rounded value of present
|
|
+ * slave_hw_ptr fraction part to rate->hw_ptr. Hence,
|
|
+ * rate->hw_ptr += [ (no. of updated slave periods * pcm rate period size) -
|
|
+ * fractional part of last_slave_hw_ptr rounded value +
|
|
+ * fractional part of updated slave hw ptr's rounded value ]
|
|
*/
|
|
- rate->hw_ptr =
|
|
- (slave_hw_ptr / rate->gen.slave->period_size) * pcm->period_size +
|
|
- rate->ops.input_frames(rate->obj, slave_hw_ptr % rate->gen.slave->period_size);
|
|
+ rate->hw_ptr += (
|
|
+ (((last_slave_hw_ptr_frac + slave_hw_ptr_diff) / rate->gen.slave->period_size) * pcm->period_size) -
|
|
+ rate->ops.input_frames(rate->obj, last_slave_hw_ptr_frac) +
|
|
+ rate->ops.input_frames(rate->obj, (last_slave_hw_ptr_frac + slave_hw_ptr_diff) % rate->gen.slave->period_size));
|
|
+ rate->last_slave_hw_ptr = slave_hw_ptr;
|
|
|
|
rate->hw_ptr %= pcm->boundary;
|
|
}
|
|
@@ -635,6 +652,7 @@ static int snd_pcm_rate_prepare(snd_pcm_
|
|
return err;
|
|
*pcm->hw.ptr = 0;
|
|
*pcm->appl.ptr = 0;
|
|
+ rate->last_slave_hw_ptr = 0;
|
|
err = snd_pcm_rate_init(pcm);
|
|
if (err < 0)
|
|
return err;
|
|
@@ -650,6 +668,7 @@ static int snd_pcm_rate_reset(snd_pcm_t
|
|
return err;
|
|
*pcm->hw.ptr = 0;
|
|
*pcm->appl.ptr = 0;
|
|
+ rate->last_slave_hw_ptr = 0;
|
|
err = snd_pcm_rate_init(pcm);
|
|
if (err < 0)
|
|
return err;
|