From f682ab540db649f552e0829a67594e4033846d9a Mon Sep 17 00:00:00 2001 From: Zefa Chen Date: Mon, 13 Jun 2022 14:40:59 +0800 Subject: [PATCH] media: rockchip: vicap deal fe before fs When fe and the next frame of fs arrive at the same time, processing the fs of the next frame first will cause the timestamp of the current frame to be wrong. There is only one timestamp variable of fs, which is not stored in a ping-pong manner. Signed-off-by: Zefa Chen Change-Id: Ic76bdb67bf0debc11006df1195ffafa7540ca2d7 --- drivers/media/platform/rockchip/cif/capture.c | 64 +++++++++---------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/drivers/media/platform/rockchip/cif/capture.c b/drivers/media/platform/rockchip/cif/capture.c index 5b671c56c56a..74b50de7a5e0 100644 --- a/drivers/media/platform/rockchip/cif/capture.c +++ b/drivers/media/platform/rockchip/cif/capture.c @@ -8133,37 +8133,6 @@ void rkcif_irq_pingpong_v1(struct rkcif_device *cif_dev) return; } - for (i = 0; i < RKCIF_MAX_STREAM_MIPI; i++) { - if (intstat & CSI_START_INTSTAT(i)) { - stream = &cif_dev->stream[i]; - if (i == 0) { - rkcif_deal_sof(cif_dev); - } else { - spin_lock_irqsave(&stream->fps_lock, flags); - stream->readout.fs_timestamp = ktime_get_ns(); - if (cif_dev->sditf[0]->toisp_inf.link_mode == TOISP_NONE) - stream->frame_idx++; - spin_unlock_irqrestore(&stream->fps_lock, flags); - } - } - if (intstat & CSI_LINE_INTSTAT(i)) { - stream = &cif_dev->stream[i]; - if (stream->is_line_inten) { - stream->line_int_cnt++; - rkcif_line_wake_up(stream, stream->id); - rkcif_modify_line_int(stream, false); - stream->is_line_inten = false; - } - v4l2_dbg(1, rkcif_debug, &cif_dev->v4l2_dev, - "%s: id0 cur line:%d\n", __func__, lastline & 0x3fff); - } - } - - /* if do not reach frame dma end, return irq */ - mipi_id = rkcif_csi_g_mipi_id(&cif_dev->v4l2_dev, intstat); - if (mipi_id < 0) - return; - for (i = 0; i < RKCIF_MAX_STREAM_MIPI; i++) { mipi_id = rkcif_csi_g_mipi_id(&cif_dev->v4l2_dev, intstat); @@ -8248,8 +8217,33 @@ void rkcif_irq_pingpong_v1(struct rkcif_device *cif_dev) } } rkcif_monitor_reset_event(cif_dev); + cif_dev->irq_stats.all_frm_end_cnt++; + } + + for (i = 0; i < RKCIF_MAX_STREAM_MIPI; i++) { + if (intstat & CSI_START_INTSTAT(i)) { + stream = &cif_dev->stream[i]; + if (i == 0) { + rkcif_deal_sof(cif_dev); + } else { + spin_lock_irqsave(&stream->fps_lock, flags); + stream->readout.fs_timestamp = ktime_get_ns(); + stream->frame_idx++; + spin_unlock_irqrestore(&stream->fps_lock, flags); + } + } + if (intstat & CSI_LINE_INTSTAT(i)) { + stream = &cif_dev->stream[i]; + if (stream->is_line_inten) { + stream->line_int_cnt++; + rkcif_line_wake_up(stream, stream->id); + rkcif_modify_line_int(stream, false); + stream->is_line_inten = false; + } + v4l2_dbg(1, rkcif_debug, &cif_dev->v4l2_dev, + "%s: id0 cur line:%d\n", __func__, lastline & 0x3fff); + } } - cif_dev->irq_stats.all_frm_end_cnt++; } else { struct rkcif_stream *stream; int ch_id; @@ -8260,9 +8254,6 @@ void rkcif_irq_pingpong_v1(struct rkcif_device *cif_dev) stream = &cif_dev->stream[RKCIF_STREAM_CIF]; - if (intstat & DVP_FRAME0_START_ID0 || intstat & DVP_FRAME1_START_ID0) - rkcif_deal_sof(cif_dev); - if (intstat & DVP_SIZE_ERR) { cif_dev->irq_stats.dvp_size_err_cnt++; rkcif_write_register_or(cif_dev, CIF_REG_DVP_CTRL, 0x000A0000); @@ -8334,6 +8325,9 @@ void rkcif_irq_pingpong_v1(struct rkcif_device *cif_dev) cif_dev->irq_stats.all_frm_end_cnt++; } + if (intstat & DVP_FRAME0_START_ID0 || intstat & DVP_FRAME1_START_ID0) + rkcif_deal_sof(cif_dev); + if (stream->crop_dyn_en) rkcif_dynamic_crop(stream); }