diff --git a/drivers/media/platform/rockchip/cif/capture.c b/drivers/media/platform/rockchip/cif/capture.c index 6b0029ca41be..80931645af5e 100644 --- a/drivers/media/platform/rockchip/cif/capture.c +++ b/drivers/media/platform/rockchip/cif/capture.c @@ -12461,11 +12461,24 @@ static int rkcif_stop_dma_capture(struct rkcif_stream *stream) return 0; } +static bool rkcif_check_frame_active(struct rkcif_device *cif_dev) +{ + if (cif_dev->sditf[0] && + cif_dev->sditf[0]->mode.rdbk_mode < RKISP_VICAP_RDBK_AIQ && + cif_dev->sditf[0]->is_toisp_off) + return false; + + return true; +} + static void rkcif_send_sof(struct rkcif_device *cif_dev) { struct v4l2_mbus_config *mbus = &cif_dev->active_sensor->mbus; struct csi2_dev *csi; + if (!rkcif_check_frame_active(cif_dev)) + return; + if (mbus->type == V4L2_MBUS_CSI2_DPHY || mbus->type == V4L2_MBUS_CSI2_CPHY) { csi = container_of(cif_dev->active_sensor->sd, struct csi2_dev, sd); @@ -12475,6 +12488,7 @@ static void rkcif_send_sof(struct rkcif_device *cif_dev) } else { rkcif_dvp_event_inc_sof(cif_dev); } + v4l2_dbg(3, rkcif_debug, &cif_dev->v4l2_dev, "send sof %d\n\n", rkcif_get_sof(cif_dev)); } static int rkcif_g_toisp_ch(unsigned int intstat_glb, int index) @@ -13008,6 +13022,8 @@ static void rkcif_toisp_check_stop_status(struct sditf_priv *priv, break; } } + if (priv->is_toisp_off) + continue; if (priv->cif_dev->chip_id < CHIP_RK3576_CIF) ch = rkcif_g_toisp_fs(intstat_glb, index); else @@ -13142,25 +13158,22 @@ static int rkcif_check_group_sync_state(struct rkcif_device *cif_dev) sync_config->update_cache, detect_stream->readout.fs_timestamp); - if (sync_config->sync_code != sync_config->sync_mask || - (!detect_stream->dma_en)) + if (sync_config->sync_code != sync_config->sync_mask) return -EINVAL; for (i = 0; i < sync_config->dev_cnt; i++) { if (sync_config->mode == RKCIF_MASTER_MASTER) { if (i < sync_config->ext_master.count) - next_stream = &sync_config->ext_master.cif_dev[i]->stream - [0]; + next_stream = &sync_config->ext_master.cif_dev[i]->stream[0]; else - next_stream = &sync_config->int_master.cif_dev[0]->stream - [0]; + next_stream = &sync_config->int_master.cif_dev[0]->stream[0]; } else if (sync_config->mode == RKCIF_MASTER_SLAVE) { if (i < sync_config->slave.count) - next_stream = &sync_config->slave.cif_dev[i]->stream - [0]; + next_stream = &sync_config->slave.cif_dev[i]->stream[0]; else - next_stream = &sync_config->int_master.cif_dev[0]->stream - [0]; + next_stream = &sync_config->int_master.cif_dev[0]->stream[0]; + } else if (sync_config->mode == RKCIF_SOFT_SYNC) { + next_stream = &sync_config->soft_sync.cif_dev[i]->stream[0]; } else { v4l2_err(&cif_dev->v4l2_dev, "ERROR: invalid group sync mode\n"); @@ -13170,8 +13183,7 @@ static int rkcif_check_group_sync_state(struct rkcif_device *cif_dev) if (detect_stream == next_stream) continue; fs_interval = abs(detect_stream->readout.fs_timestamp - next_stream->readout.fs_timestamp); - if (fs_interval > RKCIF_MAX_INTERVAL_NS || - (!next_stream->dma_en)) { + if (fs_interval > RKCIF_MAX_INTERVAL_NS) { ret = -EINVAL; break; } @@ -13259,7 +13271,13 @@ static void rkcif_deal_sof(struct rkcif_device *cif_dev) rkcif_get_sof(tmp_dev), tmp_dev->stream[0].frame_idx); } - tmp_dev->stream[0].frame_idx = sync_config->frame_idx; + if (tmp_dev->sditf[0] && + tmp_dev->sditf[0]->mode.rdbk_mode < RKISP_VICAP_RDBK_AIQ) { + if (!tmp_dev->sditf[0]->is_toisp_off) + tmp_dev->stream[0].frame_idx++; + } else { + tmp_dev->stream[0].frame_idx = sync_config->frame_idx; + } spin_unlock_irqrestore(&tmp_dev->stream[0].vbq_lock, flags); } } @@ -13285,7 +13303,8 @@ static void rkcif_deal_sof(struct rkcif_device *cif_dev) rkcif_get_sof(cif_dev), detect_stream->frame_idx); } - detect_stream->frame_idx++; + if (rkcif_check_frame_active(cif_dev)) + detect_stream->frame_idx++; spin_unlock_irqrestore(&detect_stream->vbq_lock, flags); if (detect_stream->cifdev->rdbk_debug && detect_stream->frame_idx < 15 && diff --git a/drivers/media/platform/rockchip/cif/subdev-itf.c b/drivers/media/platform/rockchip/cif/subdev-itf.c index fb519b634434..ce0378e60105 100644 --- a/drivers/media/platform/rockchip/cif/subdev-itf.c +++ b/drivers/media/platform/rockchip/cif/subdev-itf.c @@ -845,8 +845,6 @@ static int sditf_channel_enable_rv1103b(struct sditf_priv *priv, int user) width | (height << 16)); } } - if (priv->mode.rdbk_mode == RKISP_VICAP_ONLINE_MULTI) - rkcif_write_register_or(cif_dev, CIF_REG_MIPI_LVDS_CTRL, CSI_ENABLE_CAPTURE); read_ctrl_ch0 = rkcif_read_register(cif_dev, CIF_REG_TOISP0_CTRL); v4l2_dbg(3, rkcif_debug, &cif_dev->v4l2_dev, "isp%d, toisp ch0 %d, width %d, height %d, reg w:0x%x r:0x%x\n", user, ch0, width, height, ctrl_ch0, read_ctrl_ch0); @@ -1013,9 +1011,6 @@ static void sditf_channel_disable_rv1103b(struct sditf_priv *priv, int user) u32 ctrl_val = 0x1; u32 read_ctrl_ch0 = 0; - if (priv->mode.rdbk_mode == RKISP_VICAP_ONLINE_MULTI) - rkcif_write_register_and(cif_dev, CIF_REG_MIPI_LVDS_CTRL, ~CSI_ENABLE_CAPTURE); - rkcif_write_register_and(cif_dev, CIF_REG_TOISP0_CTRL, ~ctrl_val); read_ctrl_ch0 = rkcif_read_register(cif_dev, CIF_REG_TOISP0_CTRL); v4l2_dbg(3, rkcif_debug, &cif_dev->v4l2_dev, "isp%d, toisp disable reg w_and:0x%x r:0x%x\n",