#define TPG_CSI_GROUP_ID 10
+static s64 queue_init_ts;
+
static void gang_buffer_offsets(struct tegra_channel *chan)
{
int i;
void release_buffer(struct tegra_channel *chan, struct tegra_channel_buffer* buf)
{
struct vb2_v4l2_buffer* vbuf = &buf->buf;
+ s64 frame_arrived_ts = 0;
/* release one frame */
vbuf->sequence = chan->sequence++;
vbuf->field = V4L2_FIELD_NONE;
buf->state = VB2_BUF_STATE_ERROR;
}
+ if (chan->sequence == 1) {
+ /*
+ * Evaluate the initial capture latency between videobuf2 queue
+ * and first captured frame release to user-space.
+ */
+ frame_arrived_ts = ktime_to_ms(ktime_get());
+ dev_dbg(&chan->video.dev, "%s: capture init latency is %lld ms\n",
+ __func__, (frame_arrived_ts - queue_init_ts));
+ }
+
+ dev_dbg(&chan->video.dev,
+ "%s: release buf[%p] frame[%d] to user-space\n",
+ __func__, buf, chan->sequence);
vb2_buffer_done(&vbuf->vb2_buf, buf->state);
}
if (chan->bypass)
return;
+ if (!queue_init_ts) {
+ /*
+ * Record videobuf2 queue initial timestamp.
+ * Note: latency is accurate when streaming is already turned ON
+ */
+ queue_init_ts = ktime_to_ms(ktime_get());
+ }
+
/* Put buffer into the capture queue */
spin_lock(&chan->start_lock);
list_add_tail(&buf->queue, &chan->capture);
if (vi->fops)
vi->fops->vi_stop_streaming(vq);
+
+ /* Clean-up recorded videobuf2 queue initial timestamp */
+ queue_init_ts = 0;
}
static const struct vb2_ops tegra_channel_queue_qops = {
chan->capture_state = CAPTURE_TIMEOUT;
break;
}
+ dev_dbg(&chan->video.dev,
+ "%s: vi2 got SOF syncpt buf[%p]\n", __func__, buf);
}
if (!err && !chan->pg_mode) {
if (err)
dev_err(&chan->video.dev,
"MW_ACK_DONE syncpoint time out!%d\n", index);
+
+ dev_dbg(&chan->video.dev,
+ "%s: vi2 got EOF syncpt buf[%p]\n", __func__, buf);
}
if (err) {
/* wait for vi notifier events */
vi_notify_wait(chan, &ts);
+ dev_dbg(&chan->video.dev,
+ "%s: vi4 got SOF syncpt buf[%p]\n", __func__, buf);
vi4_check_status(chan);
dev_err(&chan->video.dev,
"MW_ACK_DONE syncpoint time out!%d\n", index);
}
+ dev_dbg(&chan->video.dev,
+ "%s: vi4 got EOF syncpt buf[%p]\n", __func__, buf);
if (err) {
buf->state = VB2_BUF_STATE_ERROR;