From: Vinod Koul Date: Mon, 14 May 2012 10:08:13 +0000 (+0530) Subject: sound core: add soc_delay X-Git-Tag: 2.1b_release~709 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=769204d13563673a4b99ec626aeae589c6b213d9;p=kernel%2Fkernel-mfld-blackbay.git sound core: add soc_delay BZ: 35394 soc_delay is a new delay varible which should be added to overall sound delay reporting. This is the delay encountered in queing of buffers inside soc, like dsp buffers, usb usb queue delay etc Change-Id: I8483ed9d7f345dcd2124d97e9c807e6e11fc34d7 Signed-off-by: Vinod Koul Reviewed-on: http://android.intel.com:8080/49238 Reviewed-by: Babu, Ramesh Reviewed-by: Koul, Vinod Reviewed-by: Gupta, ArvindX K Reviewed-by: Hibare, PramodX Tested-by: Hibare, PramodX Reviewed-by: buildbot Tested-by: buildbot --- diff --git a/include/sound/pcm.h b/include/sound/pcm.h index e1bad11..1ae357a 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 soc_delay; /* extra delay; typically delay incurred in soc */ /* -- HW params -- */ snd_pcm_access_t access; /* access mode */ diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 3388442..484035a 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -288,7 +288,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->soc_delay) + actual_avail = avail; + else + actual_avail = avail - runtime->soc_delay; + if (actual_avail >= runtime->stop_threshold) { + snd_printd(KERN_ERR "avail > stop_threshold!!\n"); + snd_printd(KERN_ERR "actual_avail %ld, avail %ld, soc_delay %ld!!\n", + actual_avail, avail, runtime->soc_delay); xrun(substream); return -EPIPE; } @@ -423,9 +431,9 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) goto no_jiffies_check; hdelta = delta; - if (hdelta < runtime->delay) + if (hdelta < (runtime->delay + runtime->soc_delay)) goto no_jiffies_check; - hdelta -= runtime->delay; + hdelta -= (runtime->delay + runtime->soc_delay); jdelta = jiffies - runtime->hw_ptr_jiffies; if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { delta = jdelta / diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 1c6be91..0fb5866 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -605,13 +605,13 @@ int snd_pcm_status(struct snd_pcm_substream *substream, if (runtime->status->state == SNDRV_PCM_STATE_RUNNING || runtime->status->state == SNDRV_PCM_STATE_DRAINING) { status->delay = runtime->buffer_size - status->avail; - status->delay += runtime->delay; + status->delay += runtime->delay + runtime->soc_delay; } else status->delay = 0; } else { status->avail = snd_pcm_capture_avail(runtime); if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) - status->delay = status->avail + runtime->delay; + status->delay = status->avail + runtime->delay + runtime->soc_delay; else status->delay = 0; } @@ -2432,7 +2432,7 @@ static int snd_pcm_delay(struct snd_pcm_substream *substream, n = snd_pcm_playback_hw_avail(runtime); else n = snd_pcm_capture_avail(runtime); - n += runtime->delay; + n += runtime->delay + runtime->soc_delay; break; case SNDRV_PCM_STATE_XRUN: err = -EPIPE; diff --git a/sound/soc/mid-x86/sst_platform.c b/sound/soc/mid-x86/sst_platform.c index dca2284..0c1d83e 100644 --- a/sound/soc/mid-x86/sst_platform.c +++ b/sound/soc/mid-x86/sst_platform.c @@ -556,7 +556,7 @@ static snd_pcm_uframes_t sst_platform_pcm_pointer pr_err("sst: error code = %d\n", ret_val); return ret_val; } - substream->runtime->delay = stream->stream_info.pcm_delay; + substream->runtime->soc_delay = stream->stream_info.pcm_delay; return stream->stream_info.buffer_ptr; }