Commit 73aea586 authored by Benjamin Gaignard's avatar Benjamin Gaignard Committed by Mauro Carvalho Chehab
Browse files

media: visl: Use vb2_get_buffer() instead of directly access to buffers array



Use vb2_get_buffer() instead of direct access to the vb2_queue bufs array.
This allows us to change the type of the bufs in the future.
After each call to vb2_get_buffer() we need to be sure that we get
a valid pointer so check the return value of all of them.

Signed-off-by: default avatarBenjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: default avatarAndrzej Pietrasiewicz <andrzej.p@collabora.com>
CC: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 7bce685b
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -290,13 +290,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run)
	for (i = 0; i < out_q->num_buffers; i++) {
		char entry[] = "index: %u, state: %s, request_fd: %d, ";
		u32 old_len = len;
		char *q_status = visl_get_vb2_state(out_q->bufs[i]->state);
		struct vb2_buffer *vb2;
		char *q_status;

		vb2 = vb2_get_buffer(out_q, i);
		if (!vb2)
			continue;

		q_status = visl_get_vb2_state(vb2->state);

		len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len,
				 entry, i, q_status,
				 to_vb2_v4l2_buffer(out_q->bufs[i])->request_fd);
				 to_vb2_v4l2_buffer(vb2)->request_fd);

		len += visl_fill_bytesused(to_vb2_v4l2_buffer(out_q->bufs[i]),
		len += visl_fill_bytesused(to_vb2_v4l2_buffer(vb2),
					   &buf[len],
					   TPG_STR_BUF_SZ - len);

@@ -342,13 +349,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run)
	len = 0;
	for (i = 0; i < cap_q->num_buffers; i++) {
		u32 old_len = len;
		char *q_status = visl_get_vb2_state(cap_q->bufs[i]->state);
		struct vb2_buffer *vb2;
		char *q_status;

		vb2 = vb2_get_buffer(cap_q, i);
		if (!vb2)
			continue;

		q_status = visl_get_vb2_state(vb2->state);

		len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len,
				 "index: %u, status: %s, timestamp: %llu, is_held: %d",
				 cap_q->bufs[i]->index, q_status,
				 cap_q->bufs[i]->timestamp,
				 to_vb2_v4l2_buffer(cap_q->bufs[i])->is_held);
				 vb2->index, q_status,
				 vb2->timestamp,
				 to_vb2_v4l2_buffer(vb2)->is_held);

		tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, &buf[old_len]);
		frame_dprintk(ctx->dev, run->dst->sequence, "%s", &buf[old_len]);