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/cif/subdev-itf.c | 155 +++++++++++++++++++++++++++++++++++++--------------
1 files changed, 112 insertions(+), 43 deletions(-)
diff --git a/kernel/drivers/media/platform/rockchip/cif/subdev-itf.c b/kernel/drivers/media/platform/rockchip/cif/subdev-itf.c
index 01aefd4..441b7df 100644
--- a/kernel/drivers/media/platform/rockchip/cif/subdev-itf.c
+++ b/kernel/drivers/media/platform/rockchip/cif/subdev-itf.c
@@ -283,14 +283,14 @@
struct rkcif_device *cif_dev = priv->cif_dev;
if (priv->hdr_cfg.hdr_mode == HDR_X2) {
- rkcif_free_rx_buf(&cif_dev->stream[0], priv->buf_num);
- rkcif_free_rx_buf(&cif_dev->stream[1], priv->buf_num);
+ rkcif_free_rx_buf(&cif_dev->stream[0], cif_dev->stream[0].rx_buf_num);
+ rkcif_free_rx_buf(&cif_dev->stream[1], cif_dev->stream[1].rx_buf_num);
} else if (priv->hdr_cfg.hdr_mode == HDR_X3) {
- rkcif_free_rx_buf(&cif_dev->stream[0], priv->buf_num);
- rkcif_free_rx_buf(&cif_dev->stream[1], priv->buf_num);
- rkcif_free_rx_buf(&cif_dev->stream[2], priv->buf_num);
+ rkcif_free_rx_buf(&cif_dev->stream[0], cif_dev->stream[0].rx_buf_num);
+ rkcif_free_rx_buf(&cif_dev->stream[1], cif_dev->stream[1].rx_buf_num);
+ rkcif_free_rx_buf(&cif_dev->stream[2], cif_dev->stream[2].rx_buf_num);
} else {
- rkcif_free_rx_buf(&cif_dev->stream[0], priv->buf_num);
+ rkcif_free_rx_buf(&cif_dev->stream[0], cif_dev->stream[0].rx_buf_num);
}
if (cif_dev->is_thunderboot) {
cif_dev->wait_line_cache = 0;
@@ -327,6 +327,7 @@
__func__, mode->rdbk_mode, mode->name, priv->toisp_inf.link_mode);
}
+static void sditf_channel_disable(struct sditf_priv *priv, int user);
static long sditf_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
{
struct sditf_priv *priv = to_sditf_priv(sd);
@@ -336,11 +337,14 @@
struct v4l2_subdev *sensor_sd;
int *pbuf_num = NULL;
int ret = 0;
+ int *on = NULL;
switch (cmd) {
case RKISP_VICAP_CMD_MODE:
mode = (struct rkisp_vicap_mode *)arg;
+ mutex_lock(&cif_dev->stream_lock);
memcpy(&priv->mode, mode, sizeof(*mode));
+ mutex_unlock(&cif_dev->stream_lock);
sditf_reinit_mode(priv, &priv->mode);
if (priv->is_combine_mode)
mode->input.merge_num = cif_dev->sditf_cnt;
@@ -363,6 +367,28 @@
return v4l2_subdev_call(sensor_sd, core, ioctl, cmd, arg);
}
break;
+ case RKISP_VICAP_CMD_QUICK_STREAM:
+ on = (int *)arg;
+ if (*on) {
+ rkcif_stream_resume(cif_dev, RKCIF_RESUME_ISP);
+ } else {
+ if (priv->toisp_inf.link_mode == TOISP0) {
+ sditf_channel_disable(priv, 0);
+ } else if (priv->toisp_inf.link_mode == TOISP1) {
+ sditf_channel_disable(priv, 1);
+ } else if (priv->toisp_inf.link_mode == TOISP_UNITE) {
+ sditf_channel_disable(priv, 0);
+ sditf_channel_disable(priv, 1);
+ }
+ rkcif_stream_suspend(cif_dev, RKCIF_RESUME_ISP);
+ }
+ break;
+ case RKISP_VICAP_CMD_SET_RESET:
+ if (priv->mode.rdbk_mode == RKISP_VICAP_ONLINE) {
+ cif_dev->is_toisp_reset = true;
+ return 0;
+ }
+ break;
default:
break;
}
@@ -382,6 +408,7 @@
struct rkmodule_hdr_cfg *hdr_cfg;
int buf_num;
int ret = 0;
+ int on;
switch (cmd) {
case RKISP_VICAP_CMD_MODE:
@@ -413,6 +440,14 @@
return -EFAULT;
}
ret = sditf_ioctl(sd, cmd, hdr_cfg);
+ return ret;
+ case RKISP_VICAP_CMD_QUICK_STREAM:
+ if (copy_from_user(&on, up, sizeof(int)))
+ return -EFAULT;
+ ret = sditf_ioctl(sd, cmd, &on);
+ return ret;
+ case RKISP_VICAP_CMD_SET_RESET:
+ ret = sditf_ioctl(sd, cmd, NULL);
return ret;
default:
break;
@@ -464,9 +499,9 @@
ch0 = 24;//dvp
ctrl_val = (ch0 << 3) | 0x1;
if (user == 0)
- int_en = CIF_TOISP0_FS(0);
+ int_en = CIF_TOISP0_FS(0) | CIF_TOISP0_FE(0);
else
- int_en = CIF_TOISP1_FS(0);
+ int_en = CIF_TOISP1_FS(0) | CIF_TOISP1_FE(0);
priv->toisp_inf.ch_info[0].is_valid = true;
priv->toisp_inf.ch_info[0].id = ch0;
} else if (priv->hdr_cfg.hdr_mode == HDR_X2) {
@@ -475,9 +510,11 @@
ctrl_val = (ch0 << 3) | 0x1;
ctrl_val |= (ch1 << 11) | 0x100;
if (user == 0)
- int_en = CIF_TOISP0_FS(0) | CIF_TOISP0_FS(1);
+ int_en = CIF_TOISP0_FS(0) | CIF_TOISP0_FS(1) |
+ CIF_TOISP0_FE(0) | CIF_TOISP0_FE(1);
else
- int_en = CIF_TOISP1_FS(0) | CIF_TOISP1_FS(1);
+ int_en = CIF_TOISP1_FS(0) | CIF_TOISP1_FS(1) |
+ CIF_TOISP1_FE(0) | CIF_TOISP1_FE(1);
priv->toisp_inf.ch_info[0].is_valid = true;
priv->toisp_inf.ch_info[0].id = ch0;
priv->toisp_inf.ch_info[1].is_valid = true;
@@ -490,9 +527,11 @@
ctrl_val |= (ch1 << 11) | 0x100;
ctrl_val |= (ch2 << 19) | 0x10000;
if (user == 0)
- int_en = CIF_TOISP0_FS(0) | CIF_TOISP0_FS(1) | CIF_TOISP0_FS(2);
+ int_en = CIF_TOISP0_FS(0) | CIF_TOISP0_FS(1) | CIF_TOISP0_FS(2) |
+ CIF_TOISP0_FE(0) | CIF_TOISP0_FE(1) | CIF_TOISP0_FE(2);
else
- int_en = CIF_TOISP1_FS(0) | CIF_TOISP1_FS(1) | CIF_TOISP1_FS(2);
+ int_en = CIF_TOISP1_FS(0) | CIF_TOISP1_FS(1) | CIF_TOISP1_FS(2) |
+ CIF_TOISP1_FE(0) | CIF_TOISP1_FE(1) | CIF_TOISP1_FE(2);
priv->toisp_inf.ch_info[0].is_valid = true;
priv->toisp_inf.ch_info[0].id = ch0;
priv->toisp_inf.ch_info[1].is_valid = true;
@@ -587,22 +626,41 @@
sditf_channel_enable(priv, 0);
sditf_channel_enable(priv, 1);
}
- if (priv->hdr_cfg.hdr_mode == NO_HDR) {
- rkcif_free_rx_buf(&cif_dev->stream[0], priv->buf_num);
- cif_dev->stream[0].is_line_wake_up = false;
- } else if (priv->hdr_cfg.hdr_mode == HDR_X2) {
- rkcif_free_rx_buf(&cif_dev->stream[1], priv->buf_num);
- cif_dev->stream[0].is_line_wake_up = false;
- cif_dev->stream[1].is_line_wake_up = false;
- } else if (priv->hdr_cfg.hdr_mode == HDR_X3) {
- rkcif_free_rx_buf(&cif_dev->stream[2], priv->buf_num);
- cif_dev->stream[0].is_line_wake_up = false;
- cif_dev->stream[1].is_line_wake_up = false;
- cif_dev->stream[2].is_line_wake_up = false;
+
+ if (cif_dev->is_thunderboot) {
+ if (priv->hdr_cfg.hdr_mode == NO_HDR) {
+ rkcif_free_rx_buf(&cif_dev->stream[0], cif_dev->stream[0].rx_buf_num);
+ cif_dev->stream[0].is_line_wake_up = false;
+ } else if (priv->hdr_cfg.hdr_mode == HDR_X2) {
+ rkcif_free_rx_buf(&cif_dev->stream[1], cif_dev->stream[1].rx_buf_num);
+ cif_dev->stream[0].is_line_wake_up = false;
+ cif_dev->stream[1].is_line_wake_up = false;
+ } else if (priv->hdr_cfg.hdr_mode == HDR_X3) {
+ rkcif_free_rx_buf(&cif_dev->stream[2], cif_dev->stream[2].rx_buf_num);
+ cif_dev->stream[0].is_line_wake_up = false;
+ cif_dev->stream[1].is_line_wake_up = false;
+ cif_dev->stream[2].is_line_wake_up = false;
+ }
+ cif_dev->wait_line_cache = 0;
+ cif_dev->wait_line = 0;
+ cif_dev->wait_line_bak = 0;
+ cif_dev->is_thunderboot = false;
}
- cif_dev->wait_line_cache = 0;
- cif_dev->wait_line = 0;
- cif_dev->wait_line_bak = 0;
+}
+
+void sditf_disable_immediately(struct sditf_priv *priv)
+{
+ struct rkcif_device *cif_dev = priv->cif_dev;
+ u32 ctrl_val = 0x10101;
+
+ if (priv->toisp_inf.link_mode == TOISP0) {
+ rkcif_write_register_and(cif_dev, CIF_REG_TOISP0_CTRL, ~ctrl_val);
+ } else if (priv->toisp_inf.link_mode == TOISP1) {
+ rkcif_write_register_and(cif_dev, CIF_REG_TOISP1_CTRL, ~ctrl_val);
+ } else if (priv->toisp_inf.link_mode == TOISP_UNITE) {
+ rkcif_write_register_and(cif_dev, CIF_REG_TOISP0_CTRL, ~ctrl_val);
+ rkcif_write_register_and(cif_dev, CIF_REG_TOISP1_CTRL, ~ctrl_val);
+ }
}
static void sditf_check_capture_mode(struct rkcif_device *cif_dev)
@@ -627,39 +685,36 @@
struct rkcif_device *cif_dev = priv->cif_dev;
struct v4l2_subdev_format fmt;
unsigned int mode = RKCIF_STREAM_MODE_TOISP;
- int ret = 0;
sditf_check_capture_mode(cif_dev);
sditf_get_set_fmt(&priv->sd, NULL, &fmt);
if (priv->mode.rdbk_mode == RKISP_VICAP_ONLINE) {
if (priv->toisp_inf.link_mode == TOISP0) {
- ret = sditf_channel_enable(priv, 0);
+ sditf_channel_enable(priv, 0);
} else if (priv->toisp_inf.link_mode == TOISP1) {
- ret = sditf_channel_enable(priv, 1);
+ sditf_channel_enable(priv, 1);
} else if (priv->toisp_inf.link_mode == TOISP_UNITE) {
- ret = sditf_channel_enable(priv, 0);
- ret |= sditf_channel_enable(priv, 1);
+ sditf_channel_enable(priv, 0);
+ sditf_channel_enable(priv, 1);
}
mode = RKCIF_STREAM_MODE_TOISP;
} else if (priv->mode.rdbk_mode == RKISP_VICAP_RDBK_AUTO) {
mode = RKCIF_STREAM_MODE_TOISP_RDBK;
}
- if (ret)
- return ret;
if (priv->hdr_cfg.hdr_mode == NO_HDR ||
priv->hdr_cfg.hdr_mode == HDR_COMPR) {
- ret = rkcif_do_start_stream(&cif_dev->stream[0], mode);
+ rkcif_do_start_stream(&cif_dev->stream[0], mode);
} else if (priv->hdr_cfg.hdr_mode == HDR_X2) {
- ret = rkcif_do_start_stream(&cif_dev->stream[0], mode);
- ret |= rkcif_do_start_stream(&cif_dev->stream[1], mode);
+ rkcif_do_start_stream(&cif_dev->stream[0], mode);
+ rkcif_do_start_stream(&cif_dev->stream[1], mode);
} else if (priv->hdr_cfg.hdr_mode == HDR_X3) {
- ret = rkcif_do_start_stream(&cif_dev->stream[0], mode);
- ret |= rkcif_do_start_stream(&cif_dev->stream[1], mode);
- ret |= rkcif_do_start_stream(&cif_dev->stream[2], mode);
+ rkcif_do_start_stream(&cif_dev->stream[0], mode);
+ rkcif_do_start_stream(&cif_dev->stream[1], mode);
+ rkcif_do_start_stream(&cif_dev->stream[2], mode);
}
INIT_LIST_HEAD(&priv->buf_free_list);
- return ret;
+ return 0;
}
static int sditf_stop_stream(struct sditf_priv *priv)
@@ -718,6 +773,7 @@
} else {
ret = sditf_stop_stream(priv);
sditf_free_buf(priv);
+ priv->mode.rdbk_mode = RKISP_VICAP_RDBK_AIQ;
}
}
@@ -806,7 +862,7 @@
return -EINVAL;
rx_buf = to_cif_rx_buf(dbufs);
- v4l2_dbg(rkcif_debug, 3, &cif_dev->v4l2_dev, "buf back to vicap 0x%x\n",
+ v4l2_dbg(3, rkcif_debug, &cif_dev->v4l2_dev, "buf back to vicap 0x%x\n",
(u32)rx_buf->dummy.dma_addr);
spin_lock_irqsave(&stream->vbq_lock, flags);
stream->last_rx_buf_idx = dbufs->sequence + 1;
@@ -814,6 +870,7 @@
if (!list_empty(&stream->rx_buf_head) &&
cif_dev->is_thunderboot &&
+ (!cif_dev->is_rtt_suspend) &&
(dbufs->type == BUF_SHORT ||
(dbufs->type != BUF_SHORT && (!dbufs->is_switch)))) {
spin_lock_irqsave(&cif_dev->buffree_lock, buffree_flags);
@@ -827,7 +884,15 @@
if (!is_free && (!dbufs->is_switch)) {
list_add_tail(&rx_buf->list, &stream->rx_buf_head);
- rkcif_assign_check_buffer_update_toisp(stream);
+ if (cif_dev->resume_mode != RKISP_RTT_MODE_ONE_FRAME) {
+ rkcif_assign_check_buffer_update_toisp(stream);
+ if (!stream->dma_en) {
+ stream->to_en_dma = RKCIF_DMAEN_BY_ISP;
+ rkcif_enable_dma_capture(stream, true);
+ cif_dev->sensor_work.on = 1;
+ schedule_work(&cif_dev->sensor_work.work);
+ }
+ }
if (cif_dev->rdbk_debug) {
u32 offset = 0;
@@ -855,6 +920,10 @@
}
spin_unlock_irqrestore(&stream->vbq_lock, flags);
+ if (!cif_dev->is_thunderboot ||
+ cif_dev->is_rdbk_to_online == false)
+ return 0;
+
if (dbufs->runtime_us && cif_dev->early_line == 0) {
if (!cif_dev->sensor_linetime)
cif_dev->sensor_linetime = rkcif_get_linetime(stream);
--
Gitblit v1.6.2