Commit f15cb865 authored by Dikshita Agarwal's avatar Dikshita Agarwal Committed by Hans Verkuil
Browse files

media: iris: Improve last flag handling



Improve the handling of the V4L2_BUF_FLAG_LAST flag in the driver:
- Ensure that the last flag is not sent multiple times.
- Attach the last flag to the first capture buffer returned during
  flush, triggered by a sequence change, addressing cases where the
  firmware does not set the last flag.

Reviewed-by: default avatarVikash Garodia <quic_vgarodia@quicinc.com>
Reviewed-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-HDK
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-QRD
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-HDK
Signed-off-by: default avatarDikshita Agarwal <quic_dikshita@quicinc.com>
Tested-by: Vikash Garodia <quic_vgarodia@quicinc.com> # on sa8775p-ride
Signed-off-by: default avatarBryan O'Donoghue <bod@kernel.org>
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
parent ac72ad9d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -636,6 +636,7 @@ int iris_vb2_buffer_done(struct iris_inst *inst, struct iris_buffer *buf)
			v4l2_event_queue_fh(&inst->fh, &ev);
			v4l2_m2m_mark_stopped(m2m_ctx);
		}
		inst->last_buffer_dequeued = true;
	}

	state = VB2_BUF_STATE_DONE;
+6 −1
Original line number Diff line number Diff line
@@ -457,7 +457,12 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_inst *inst, void *packet)
		timestamp_us = timestamp_hi;
		timestamp_us = (timestamp_us << 32) | timestamp_lo;
	} else {
		if (pkt->stream_id == 1 && !inst->last_buffer_dequeued) {
			if (iris_drc_pending(inst)) {
				flags |= V4L2_BUF_FLAG_LAST;
				inst->last_buffer_dequeued = true;
			}
		}
	}
	buf->timestamp = timestamp_us;

+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
 * @sequence_out: a sequence counter for output queue
 * @tss: timestamp metadata
 * @metadata_idx: index for metadata buffer
 * @last_buffer_dequeued: a flag to indicate that last buffer is sent by driver
 */

struct iris_inst {
@@ -74,6 +75,7 @@ struct iris_inst {
	u32				sequence_out;
	struct iris_ts_metadata		tss[VIDEO_MAX_FRAME];
	u32				metadata_idx;
	bool				last_buffer_dequeued;
};

#endif
+2 −1
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ void iris_vb2_buf_queue(struct vb2_buffer *vb2)
		goto exit;
	}

	if (V4L2_TYPE_IS_CAPTURE(vb2->vb2_queue->type)) {
	if (!inst->last_buffer_dequeued && V4L2_TYPE_IS_CAPTURE(vb2->vb2_queue->type)) {
		if ((inst->sub_state & IRIS_INST_SUB_DRC &&
		     inst->sub_state & IRIS_INST_SUB_DRC_LAST) ||
		    (inst->sub_state & IRIS_INST_SUB_DRAIN &&
@@ -319,6 +319,7 @@ void iris_vb2_buf_queue(struct vb2_buffer *vb2)
				v4l2_event_queue_fh(&inst->fh, &eos);
				v4l2_m2m_mark_stopped(m2m_ctx);
			}
			inst->last_buffer_dequeued = true;
			goto exit;
		}
	}
+2 −0
Original line number Diff line number Diff line
@@ -487,6 +487,8 @@ static int iris_vdec_process_streamon_output(struct iris_inst *inst)
	if (ret)
		return ret;

	inst->last_buffer_dequeued = false;

	return iris_inst_change_sub_state(inst, clear_sub_state, 0);
}