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 */
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;
}
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 /
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;
}
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;
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;
}