media: rockchip: isp: frame start to check and config next buf

Change-Id: I6329dc9638b9f4cef2b7fac3a8ba77c255723a38
Signed-off-by: Cai YiWei <cyw@rock-chips.com>
This commit is contained in:
Cai YiWei
2024-01-18 15:03:42 +08:00
committed by Tao Huang
parent e4e3454d08
commit ea5b7f59a7
4 changed files with 21 additions and 37 deletions

View File

@@ -1081,20 +1081,20 @@ static void update_mi(struct rkisp_stream *stream)
if (!ISP3X_ISP_OUT_LINE(rkisp_read(dev, ISP3X_ISP_DEBUG2, true))) { if (!ISP3X_ISP_OUT_LINE(rkisp_read(dev, ISP3X_ISP_DEBUG2, true))) {
stream->ops->enable_mi(stream); stream->ops->enable_mi(stream);
stream_self_update(stream); stream_self_update(stream);
if (!stream->curr_buf) {
stream->curr_buf = stream->next_buf;
stream->next_buf = NULL;
}
/* maybe no next buf to preclose mi */ /* maybe no next buf to preclose mi */
stream->ops->disable_mi(stream); stream->ops->disable_mi(stream);
} else if (stream->is_pause) { } else {
/* isp working and mi closed /* isp working and mi closed
* config buf and enable mi, capture at next frame * config buf and enable mi, capture at next frame
*/ */
stream->ops->enable_mi(stream); stream->ops->enable_mi(stream);
stream->is_pause = false; stream->is_pause = false;
} }
} else if (stream->is_pause) { if (!stream->curr_buf) {
stream->curr_buf = stream->next_buf;
stream->next_buf = NULL;
}
} else {
/* isp working and mi no to close /* isp working and mi no to close
* config buf will auto update at frame end * config buf will auto update at frame end
*/ */
@@ -1143,11 +1143,12 @@ static void update_mi(struct rkisp_stream *stream)
} }
v4l2_dbg(2, rkisp_debug, &dev->v4l2_dev, v4l2_dbg(2, rkisp_debug, &dev->v4l2_dev,
"%s stream:%d Y:0x%x CB:0x%x | Y_SHD:0x%x\n", "%s stream:%d cur:%p next:%p Y:0x%x CB:0x%x | Y_SHD:0x%x pause:%d stop:%d\n",
__func__, stream->id, __func__, stream->id, stream->curr_buf, stream->next_buf,
rkisp_read(dev, stream->config->mi.y_base_ad_init, false), rkisp_read(dev, stream->config->mi.y_base_ad_init, false),
rkisp_read(dev, stream->config->mi.cb_base_ad_init, false), rkisp_read(dev, stream->config->mi.cb_base_ad_init, false),
rkisp_read(dev, stream->config->mi.y_base_ad_shd, true)); rkisp_read(dev, stream->config->mi.y_base_ad_shd, true),
stream->is_pause, stream->ops->is_stream_stopped(stream));
} }
static int set_mirror_flip(struct rkisp_stream *stream) static int set_mirror_flip(struct rkisp_stream *stream)
@@ -1376,17 +1377,16 @@ static int mi_frame_start(struct rkisp_stream *stream, u32 mis)
rkisp_stream_config_rsz(stream, false); rkisp_stream_config_rsz(stream, false);
stream->is_crop_upd = false; stream->is_crop_upd = false;
} }
/* update buf for multi sensor at readback */ if (!list_empty(&stream->buf_queue) &&
if (!mis && !stream->ispdev->hw_dev->is_single && ((dev->hw_dev->is_single && !stream->next_buf) ||
!stream->curr_buf && (!dev->hw_dev->is_single && !stream->curr_buf))) {
!list_empty(&stream->buf_queue)) {
stream->next_buf = list_first_entry(&stream->buf_queue, stream->next_buf = list_first_entry(&stream->buf_queue,
struct rkisp_buffer, queue); struct rkisp_buffer, queue);
list_del(&stream->next_buf->queue); list_del(&stream->next_buf->queue);
stream->ops->update_mi(stream); stream->ops->update_mi(stream);
} }
/* check frame loss */ /* check frame loss */
if (mis && stream->ops->is_stream_stopped(stream)) if (stream->ops->is_stream_stopped(stream))
stream->dbg.frameloss++; stream->dbg.frameloss++;
} }
spin_unlock_irqrestore(&stream->vbq_lock, lock_flags); spin_unlock_irqrestore(&stream->vbq_lock, lock_flags);
@@ -1678,16 +1678,7 @@ static void rkisp_buf_queue(struct vb2_buffer *vb)
stream->id, ispbuf->buff_addr[0]); stream->id, ispbuf->buff_addr[0]);
spin_lock_irqsave(&stream->vbq_lock, lock_flags); spin_lock_irqsave(&stream->vbq_lock, lock_flags);
/* single sensor with pingpong buf, update next if need */ list_add_tail(&ispbuf->queue, &stream->buf_queue);
if (dev->hw_dev->is_single &&
stream->id != RKISP_STREAM_VIR &&
stream->id != RKISP_STREAM_LUMA &&
stream->streaming && !stream->next_buf) {
stream->next_buf = ispbuf;
stream->ops->update_mi(stream);
} else {
list_add_tail(&ispbuf->queue, &stream->buf_queue);
}
spin_unlock_irqrestore(&stream->vbq_lock, lock_flags); spin_unlock_irqrestore(&stream->vbq_lock, lock_flags);
} }

View File

@@ -1167,7 +1167,7 @@ static void rkisp_pm_complete(struct device *dev)
} }
for (i = 0; i < RKISP_MAX_STREAM; i++) { for (i = 0; i < RKISP_MAX_STREAM; i++) {
stream = &isp_dev->cap_dev.stream[i]; stream = &isp_dev->cap_dev.stream[i];
if (i == RKISP_STREAM_VIR || !stream->streaming || !stream->curr_buf) if (i == RKISP_STREAM_VIR || !stream->streaming)
continue; continue;
/* skip first frame due to hw no reference frame information */ /* skip first frame due to hw no reference frame information */
if (isp_dev->is_first_double) if (isp_dev->is_first_double)

View File

@@ -202,16 +202,7 @@ int rkisp_rockit_buf_queue(struct rockit_cfg *input_rockit_cfg)
stream->id, isprk_buf, stream->id, isprk_buf,
isprk_buf->isp_buf.buff_addr[0], isprk_buf->isp_buf.buff_addr[1]); isprk_buf->isp_buf.buff_addr[0], isprk_buf->isp_buf.buff_addr[1]);
/* single sensor with pingpong buf, update next if need */ list_add_tail(&isprk_buf->isp_buf.queue, &stream->buf_queue);
if (ispdev->hw_dev->is_single && !ispdev->is_suspend &&
stream->id != RKISP_STREAM_VIR &&
stream->id != RKISP_STREAM_LUMA &&
stream->streaming && !stream->next_buf) {
stream->next_buf = &isprk_buf->isp_buf;
stream->ops->update_mi(stream);
} else {
list_add_tail(&isprk_buf->isp_buf.queue, &stream->buf_queue);
}
spin_unlock_irqrestore(&stream->vbq_lock, lock_flags); spin_unlock_irqrestore(&stream->vbq_lock, lock_flags);
return 0; return 0;

View File

@@ -1075,6 +1075,9 @@ void rkisp_check_idle(struct rkisp_device *dev, u32 irq)
unsigned long lock_flags = 0; unsigned long lock_flags = 0;
u32 val = 0; u32 val = 0;
if (!IS_HDR_RDBK(dev->rd_mode))
return;
spin_lock_irqsave(&dev->hw_dev->rdbk_lock, lock_flags); spin_lock_irqsave(&dev->hw_dev->rdbk_lock, lock_flags);
dev->irq_ends |= (irq & dev->irq_ends_mask); dev->irq_ends |= (irq & dev->irq_ends_mask);
v4l2_dbg(3, rkisp_debug, &dev->v4l2_dev, v4l2_dbg(3, rkisp_debug, &dev->v4l2_dev,
@@ -1086,8 +1089,7 @@ void rkisp_check_idle(struct rkisp_device *dev, u32 irq)
if (!completion_done(&dev->hw_dev->monitor.cmpl)) if (!completion_done(&dev->hw_dev->monitor.cmpl))
complete(&dev->hw_dev->monitor.cmpl); complete(&dev->hw_dev->monitor.cmpl);
} }
if ((dev->irq_ends & dev->irq_ends_mask) != dev->irq_ends_mask || if ((dev->irq_ends & dev->irq_ends_mask) != dev->irq_ends_mask) {
!IS_HDR_RDBK(dev->rd_mode)) {
spin_unlock_irqrestore(&dev->hw_dev->rdbk_lock, lock_flags); spin_unlock_irqrestore(&dev->hw_dev->rdbk_lock, lock_flags);
return; return;
} }