From ad82d4278c405d4ac6a8e3661732ddee02b947e7 Mon Sep 17 00:00:00 2001 From: Ahung Cheng Date: Wed, 7 Feb 2018 15:37:34 +0800 Subject: [PATCH 2/2] media: tegra: fix missing timestamp for vi4 bug 200376318 Change-Id: Ibdd4d17ff5a54d6ed518af41316c05019db3f55b Signed-off-by: Ahung Cheng Reviewed-on: https://git-master.nvidia.com/r/1653384 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/media/platform/tegra/camera/vi/channel.c | 10 ++++++++++ drivers/media/platform/tegra/camera/vi/vi2_fops.c | 10 ++-------- drivers/media/platform/tegra/camera/vi/vi4_fops.c | 5 +++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/tegra/camera/vi/channel.c b/drivers/media/platform/tegra/camera/vi/channel.c index 46d4ff1..afed2938 100644 --- a/drivers/media/platform/tegra/camera/vi/channel.c +++ b/drivers/media/platform/tegra/camera/vi/channel.c @@ -46,6 +46,16 @@ static s64 queue_init_ts; +/* + * Update the timestamp of the buffer + */ +void set_timestamp(struct tegra_channel_buffer *buf, + const struct timespec *ts) +{ + buf->buf.timestamp.tv_sec = ts->tv_sec; + buf->buf.timestamp.tv_usec = ts->tv_nsec / NSEC_PER_USEC; +} + static void gang_buffer_offsets(struct tegra_channel *chan) { int i; diff --git a/drivers/media/platform/tegra/camera/vi/vi2_fops.c b/drivers/media/platform/tegra/camera/vi/vi2_fops.c index d8cb190..a1fb024 100644 --- a/drivers/media/platform/tegra/camera/vi/vi2_fops.c +++ b/drivers/media/platform/tegra/camera/vi/vi2_fops.c @@ -37,14 +37,8 @@ extern void enqueue_inflight(struct tegra_channel *chan, extern struct tegra_channel_buffer *dequeue_inflight(struct tegra_channel *chan); extern int tegra_channel_set_power(struct tegra_channel *chan, bool on); extern void release_buffer(struct tegra_channel *chan, struct tegra_channel_buffer* buf); - -/* - * Update the timestamp of the buffer - */ -static void set_timestamp(struct tegra_channel_buffer *buf, const struct timespec* ts) { - buf->buf.timestamp.tv_sec = ts->tv_sec; - buf->buf.timestamp.tv_usec = ts->tv_nsec / NSEC_PER_USEC; -} +extern void set_timestamp(struct tegra_channel_buffer *buf, + const struct timespec *ts); static void vi_write(struct tegra_mc_vi *vi, unsigned int addr, u32 val) { diff --git a/drivers/media/platform/tegra/camera/vi/vi4_fops.c b/drivers/media/platform/tegra/camera/vi/vi4_fops.c index 45bc734..5f59b66 100644 --- a/drivers/media/platform/tegra/camera/vi/vi4_fops.c +++ b/drivers/media/platform/tegra/camera/vi/vi4_fops.c @@ -52,6 +52,8 @@ static void tegra_channel_error_worker(struct work_struct *status_work); static void tegra_channel_notify_error_callback(void *); extern void release_buffer(struct tegra_channel *chan, struct tegra_channel_buffer *buf); +extern void set_timestamp(struct tegra_channel_buffer *buf, + const struct timespec *ts); u32 csimux_config_stream[] = { CSIMUX_CONFIG_STREAM_0, @@ -547,6 +549,8 @@ static int tegra_channel_capture_frame(struct tegra_channel *chan, chan->capture_state = CAPTURE_GOOD; spin_unlock_irqrestore(&chan->capture_state_lock, flags); + set_timestamp(buf, &ts); + if (chan->capture_state == CAPTURE_GOOD) { /* * Set the buffer version to match @@ -692,6 +696,7 @@ static void tegra_channel_capture_done(struct tegra_channel *chan) /* Mark capture state to IDLE as capture is finished */ chan->capture_state = CAPTURE_IDLE; + set_timestamp(buf, &ts); release_buffer(chan, buf); } -- 2.1.4