From 1543e317f1da31b75942316931e8f491a8920811 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Thu, 04 Jan 2024 10:08:02 +0000
Subject: [PATCH] disable FB
---
kernel/drivers/media/platform/rockchip/isp/capture_v21.c | 189 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 178 insertions(+), 11 deletions(-)
diff --git a/kernel/drivers/media/platform/rockchip/isp/capture_v21.c b/kernel/drivers/media/platform/rockchip/isp/capture_v21.c
index 7983651..7aeef97 100644
--- a/kernel/drivers/media/platform/rockchip/isp/capture_v21.c
+++ b/kernel/drivers/media/platform/rockchip/isp/capture_v21.c
@@ -1150,7 +1150,8 @@
if (!ret) {
denominator = sensor->fi.interval.denominator;
numerator = sensor->fi.interval.numerator;
- time = numerator * 1000 / denominator * 1000 * 1000;
+ if (denominator)
+ time = numerator * 1000 / denominator * 1000 * 1000;
if (numerator)
fps = denominator / numerator;
}
@@ -1206,6 +1207,9 @@
unsigned long lock_flags = 0;
int i = 0;
+ if (stream->id == RKISP_STREAM_VIR)
+ return 0;
+
if (!stream->next_buf && stream->streaming &&
dev->dmarx_dev.trigger == T_MANUAL &&
is_rdbk_stream(stream))
@@ -1218,8 +1222,18 @@
(!interlaced ||
(stream->u.sp.field_rec == RKISP_FIELD_ODD &&
stream->u.sp.field == RKISP_FIELD_EVEN))) {
+ struct rkisp_stream *vir = &dev->cap_dev.stream[RKISP_STREAM_VIR];
struct vb2_buffer *vb2_buf = &stream->curr_buf->vb.vb2_buf;
u64 ns = 0;
+
+ if (stream->skip_frame) {
+ spin_lock_irqsave(&stream->vbq_lock, lock_flags);
+ list_add_tail(&stream->curr_buf->queue, &stream->buf_queue);
+ spin_unlock_irqrestore(&stream->vbq_lock, lock_flags);
+ if (stream->skip_frame)
+ stream->skip_frame--;
+ goto end;
+ }
/* Dequeue a filled buffer */
for (i = 0; i < isp_fmt->mplanes; i++) {
@@ -1237,10 +1251,10 @@
atomic_read(&stream->sequence) - 1;
}
if (!ns)
- ns = ktime_get_ns();
+ ns = rkisp_time_get_ns(dev);
vb2_buf->timestamp = ns;
- ns = ktime_get_ns();
+ ns = rkisp_time_get_ns(dev);
stream->dbg.interval = ns - stream->dbg.timestamp;
stream->dbg.timestamp = ns;
stream->dbg.id = stream->curr_buf->vb.sequence;
@@ -1268,12 +1282,22 @@
rdbk_frame_end(stream);
}
} else {
- rkisp_stream_buf_done(stream, stream->curr_buf);
+ if (vir->streaming && vir->conn_id == stream->id) {
+ spin_lock_irqsave(&vir->vbq_lock, lock_flags);
+ list_add_tail(&stream->curr_buf->queue,
+ &dev->cap_dev.vir_cpy.queue);
+ spin_unlock_irqrestore(&vir->vbq_lock, lock_flags);
+ if (!completion_done(&dev->cap_dev.vir_cpy.cmpl))
+ complete(&dev->cap_dev.vir_cpy.cmpl);
+ } else {
+ rkisp_stream_buf_done(stream, stream->curr_buf);
+ }
}
stream->curr_buf = NULL;
}
+end:
if (!interlaced ||
(stream->curr_buf == stream->next_buf &&
stream->u.sp.field == RKISP_FIELD_ODD)) {
@@ -1379,6 +1403,98 @@
stream->interlaced = false;
}
+static void vir_cpy_image(struct work_struct *work)
+{
+ struct rkisp_vir_cpy *cpy =
+ container_of(work, struct rkisp_vir_cpy, work);
+ struct rkisp_stream *vir = cpy->stream;
+ struct rkisp_buffer *src_buf = NULL;
+ unsigned long lock_flags = 0;
+ u32 i;
+
+ v4l2_dbg(1, rkisp_debug, &vir->ispdev->v4l2_dev,
+ "%s enter\n", __func__);
+
+ vir->streaming = true;
+ spin_lock_irqsave(&vir->vbq_lock, lock_flags);
+ if (!list_empty(&cpy->queue)) {
+ src_buf = list_first_entry(&cpy->queue,
+ struct rkisp_buffer, queue);
+ list_del(&src_buf->queue);
+ }
+ spin_unlock_irqrestore(&vir->vbq_lock, lock_flags);
+
+ while (src_buf || vir->streaming) {
+ if (vir->stopping || !vir->streaming)
+ goto end;
+
+ if (!src_buf)
+ wait_for_completion(&cpy->cmpl);
+
+ vir->frame_end = false;
+ spin_lock_irqsave(&vir->vbq_lock, lock_flags);
+
+ if (!src_buf && !list_empty(&cpy->queue)) {
+ src_buf = list_first_entry(&cpy->queue,
+ struct rkisp_buffer, queue);
+ list_del(&src_buf->queue);
+ }
+
+ if (src_buf && !vir->curr_buf && !list_empty(&vir->buf_queue)) {
+ vir->curr_buf = list_first_entry(&vir->buf_queue,
+ struct rkisp_buffer, queue);
+ list_del(&vir->curr_buf->queue);
+ }
+ spin_unlock_irqrestore(&vir->vbq_lock, lock_flags);
+
+ if (!vir->curr_buf || !src_buf)
+ goto end;
+
+ for (i = 0; i < vir->out_isp_fmt.mplanes; i++) {
+ u32 payload_size = vir->out_fmt.plane_fmt[i].sizeimage;
+ void *src = vb2_plane_vaddr(&src_buf->vb.vb2_buf, i);
+ void *dst = vb2_plane_vaddr(&vir->curr_buf->vb.vb2_buf, i);
+
+ if (!src || !dst)
+ break;
+ vb2_set_plane_payload(&vir->curr_buf->vb.vb2_buf, i, payload_size);
+ memcpy(dst, src, payload_size);
+ }
+
+ vir->curr_buf->vb.sequence = src_buf->vb.sequence;
+ vir->curr_buf->vb.vb2_buf.timestamp = src_buf->vb.vb2_buf.timestamp;
+ vb2_buffer_done(&vir->curr_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
+ vir->curr_buf = NULL;
+end:
+ if (src_buf)
+ vb2_buffer_done(&src_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
+ src_buf = NULL;
+ spin_lock_irqsave(&vir->vbq_lock, lock_flags);
+
+ if (!list_empty(&cpy->queue)) {
+ src_buf = list_first_entry(&cpy->queue,
+ struct rkisp_buffer, queue);
+ list_del(&src_buf->queue);
+ } else if (vir->stopping) {
+ vir->streaming = false;
+ }
+
+ spin_unlock_irqrestore(&vir->vbq_lock, lock_flags);
+ }
+
+ vir->frame_end = true;
+
+ if (vir->stopping) {
+ vir->stopping = false;
+ vir->streaming = false;
+ wake_up(&vir->done);
+ }
+
+ v4l2_dbg(1, rkisp_debug, &vir->ispdev->v4l2_dev,
+ "%s exit\n", __func__);
+}
+
+
/*
* Most of registers inside rockchip isp1 have shadow register since
* they must be not changed during processing a frame.
@@ -1400,7 +1516,7 @@
if (stream->id == RKISP_STREAM_MP || stream->id == RKISP_STREAM_SP)
hdr_config_dmatx(dev);
stream->streaming = true;
-
+ stream->skip_frame = 0;
return 0;
}
@@ -1571,6 +1687,21 @@
if (!stream->streaming)
goto end;
+ if (stream->id == RKISP_STREAM_VIR) {
+ stream->stopping = true;
+ wait_event_timeout(stream->done,
+ stream->frame_end,
+ msecs_to_jiffies(500));
+ stream->streaming = false;
+ stream->stopping = false;
+ destroy_buf_queue(stream, VB2_BUF_STATE_ERROR);
+
+ if (!completion_done(&dev->cap_dev.vir_cpy.cmpl))
+ complete(&dev->cap_dev.vir_cpy.cmpl);
+ stream->conn_id = -1;
+ goto end;
+ }
+
rkisp_stream_stop(stream);
if (stream->id == RKISP_STREAM_MP ||
stream->id == RKISP_STREAM_SP) {
@@ -1650,6 +1781,28 @@
if (WARN_ON(stream->streaming)) {
mutex_unlock(&dev->hw_dev->dev_lock);
return -EBUSY;
+ }
+
+ if (stream->id == RKISP_STREAM_VIR) {
+ struct rkisp_stream *t = &dev->cap_dev.stream[stream->conn_id];
+
+ if (t->streaming) {
+ INIT_WORK(&dev->cap_dev.vir_cpy.work, vir_cpy_image);
+ init_completion(&dev->cap_dev.vir_cpy.cmpl);
+ INIT_LIST_HEAD(&dev->cap_dev.vir_cpy.queue);
+ dev->cap_dev.vir_cpy.stream = stream;
+ schedule_work(&dev->cap_dev.vir_cpy.work);
+ ret = 0;
+ } else {
+ v4l2_err(&dev->v4l2_dev,
+ "no stream enable for iqtool\n");
+ destroy_buf_queue(stream, VB2_BUF_STATE_QUEUED);
+ ret = -EINVAL;
+ }
+
+ mutex_unlock(&dev->hw_dev->dev_lock);
+
+ return ret;
}
memset(&stream->dbg, 0, sizeof(stream->dbg));
@@ -1787,7 +1940,7 @@
switch (id) {
case RKISP_STREAM_SP:
- strlcpy(vdev->name, SP_VDEV_NAME,
+ strscpy(vdev->name, SP_VDEV_NAME,
sizeof(vdev->name));
stream->ops = &rkisp_sp_streams_ops;
stream->config = &rkisp_sp_stream_config;
@@ -1795,25 +1948,32 @@
stream->config->fmt_size = ARRAY_SIZE(sp_fmts);
break;
case RKISP_STREAM_DMATX0:
- strlcpy(vdev->name, DMATX0_VDEV_NAME,
+ strscpy(vdev->name, DMATX0_VDEV_NAME,
sizeof(vdev->name));
stream->ops = &rkisp2_dmatx0_streams_ops;
stream->config = &rkisp2_dmatx0_stream_config;
break;
case RKISP_STREAM_DMATX2:
- strlcpy(vdev->name, DMATX2_VDEV_NAME,
+ strscpy(vdev->name, DMATX2_VDEV_NAME,
sizeof(vdev->name));
stream->ops = &rkisp2_dmatx2_streams_ops;
stream->config = &rkisp2_dmatx1_stream_config;
break;
case RKISP_STREAM_DMATX3:
- strlcpy(vdev->name, DMATX3_VDEV_NAME,
+ strscpy(vdev->name, DMATX3_VDEV_NAME,
sizeof(vdev->name));
stream->ops = &rkisp2_dmatx3_streams_ops;
stream->config = &rkisp2_dmatx3_stream_config;
break;
+ case RKISP_STREAM_VIR:
+ strscpy(vdev->name, VIR_VDEV_NAME,
+ sizeof(vdev->name));
+ stream->ops = NULL;
+ stream->config = &rkisp_mp_stream_config;
+ stream->conn_id = -1;
+ break;
default:
- strlcpy(vdev->name, MP_VDEV_NAME,
+ strscpy(vdev->name, MP_VDEV_NAME,
sizeof(vdev->name));
stream->ops = &rkisp_mp_streams_ops;
stream->config = &rkisp_mp_stream_config;
@@ -1857,8 +2017,13 @@
ret = rkisp_stream_init(dev, RKISP_STREAM_DMATX3);
if (ret < 0)
goto err_free_tx2;
+ ret = rkisp_stream_init(dev, RKISP_STREAM_VIR);
+ if (ret < 0)
+ goto err_free_tx3;
return 0;
+err_free_tx3:
+ rkisp_unregister_stream_vdev(&cap_dev->stream[RKISP_STREAM_DMATX3]);
err_free_tx2:
rkisp_unregister_stream_vdev(&cap_dev->stream[RKISP_STREAM_DMATX2]);
err_free_tx0:
@@ -1886,6 +2051,8 @@
rkisp_unregister_stream_vdev(stream);
stream = &cap_dev->stream[RKISP_STREAM_DMATX3];
rkisp_unregister_stream_vdev(stream);
+ stream = &cap_dev->stream[RKISP_STREAM_VIR];
+ rkisp_unregister_stream_vdev(stream);
}
/**************** Interrupter Handler ****************/
@@ -1905,7 +2072,7 @@
for (i = 0; i < RKISP_MAX_STREAM; ++i) {
stream = &dev->cap_dev.stream[i];
- if (!(mis_val & CIF_MI_FRAME(stream)))
+ if (!(mis_val & CIF_MI_FRAME(stream)) || stream->id == RKISP_STREAM_VIR)
continue;
if (i == RKISP_STREAM_DMATX0)
--
Gitblit v1.6.2