[PATCH v14 32/56] media: meson: vdec: Stop direct calls to queue num_buffers field

Andrzej Pietrasiewicz andrzej.p at collabora.com
Thu Nov 9 03:17:58 PST 2023


W dniu 31.10.2023 o 17:30, Benjamin Gaignard pisze:
> Use vb2_get_num_buffers() to avoid using queue num_buffers field directly.
> This allows us to change how the number of buffers is computed in the
> future.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard at collabora.com>

Reviewed-by: Andrzej Pietrasiewicz <andrzej.p at collabora.com>

> CC: Neil Armstrong <neil.armstrong at linaro.org>
> ---
>   drivers/staging/media/meson/vdec/vdec.c | 13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c
> index 219185aaa588..1e2369f104c8 100644
> --- a/drivers/staging/media/meson/vdec/vdec.c
> +++ b/drivers/staging/media/meson/vdec/vdec.c
> @@ -167,22 +167,23 @@ static void process_num_buffers(struct vb2_queue *q,
>   				bool is_reqbufs)
>   {
>   	const struct amvdec_format *fmt_out = sess->fmt_out;
> -	unsigned int buffers_total = q->num_buffers + *num_buffers;
> +	unsigned int q_num_bufs = vb2_get_num_buffers(q);
> +	unsigned int buffers_total = q_num_bufs + *num_buffers;
>   	u32 min_buf_capture = v4l2_ctrl_g_ctrl(sess->ctrl_min_buf_capture);
>   
> -	if (q->num_buffers + *num_buffers < min_buf_capture)
> -		*num_buffers = min_buf_capture - q->num_buffers;
> +	if (q_num_bufs + *num_buffers < min_buf_capture)
> +		*num_buffers = min_buf_capture - q_num_bufs;
>   	if (is_reqbufs && buffers_total < fmt_out->min_buffers)
> -		*num_buffers = fmt_out->min_buffers - q->num_buffers;
> +		*num_buffers = fmt_out->min_buffers - q_num_bufs;
>   	if (buffers_total > fmt_out->max_buffers)
> -		*num_buffers = fmt_out->max_buffers - q->num_buffers;
> +		*num_buffers = fmt_out->max_buffers - q_num_bufs;
>   
>   	/* We need to program the complete CAPTURE buffer list
>   	 * in registers during start_streaming, and the firmwares
>   	 * are free to choose any of them to write frames to. As such,
>   	 * we need all of them to be queued into the driver
>   	 */
> -	sess->num_dst_bufs = q->num_buffers + *num_buffers;
> +	sess->num_dst_bufs = q_num_bufs + *num_buffers;
>   	q->min_buffers_needed = max(fmt_out->min_buffers, sess->num_dst_bufs);
>   }
>   




More information about the Linux-rockchip mailing list