[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <307be618-f25b-4400-8659-11c9837dae35@xs4all.nl>
Date: Tue, 19 Sep 2023 16:26:08 +0200
From: Hans Verkuil <hverkuil-cisco@...all.nl>
To: Benjamin Gaignard <benjamin.gaignard@...labora.com>,
mchehab@...nel.org, tfiga@...omium.org, m.szyprowski@...sung.com,
ming.qian@....com, ezequiel@...guardiasur.com.ar,
p.zabel@...gutronix.de, gregkh@...uxfoundation.org,
nicolas.dufresne@...labora.com
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linux-arm-msm@...r.kernel.org,
linux-rockchip@...ts.infradead.org, linux-staging@...ts.linux.dev,
kernel@...labora.com
Subject: Re: [PATCH v7 44/49] media: cedrus: Stop direct calls to queue
num_buffers field
On 14/09/2023 15:33, Benjamin Gaignard wrote:
> Use vb2_get_num_buffers() to avoid using queue num_buffer field directly.
>
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@...labora.com>
> ---
> drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 4 +++-
> drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 4 +++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
> index dfb401df138a..bbe5802ea861 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
> @@ -649,11 +649,13 @@ static void cedrus_h264_stop(struct cedrus_ctx *ctx)
> struct cedrus_dev *dev = ctx->dev;
> struct cedrus_buffer *buf;
> struct vb2_queue *vq;
> + unsigned int q_num_bufs;
> unsigned int i;
>
> vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
> + q_num_bufs = vb2_get_num_buffers(vq);
>
> - for (i = 0; i < vq->num_buffers; i++) {
> + for (i = 0; i < q_num_bufs; i++) {
Shouldn't this be vq->max_allowed_buffers?
> buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i));
And continue if vb2_get_buffer(vq, i) == NULL?
>
> if (buf->codec.h264.mv_col_buf_size > 0) {
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c
> index fc9297232456..533a38316686 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c
> @@ -865,11 +865,13 @@ static void cedrus_h265_stop(struct cedrus_ctx *ctx)
> struct cedrus_dev *dev = ctx->dev;
> struct cedrus_buffer *buf;
> struct vb2_queue *vq;
> + unsigned int q_num_bufs;
> unsigned int i;
>
> vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
> + q_num_bufs = vb2_get_num_buffers(vq);
>
> - for (i = 0; i < vq->num_buffers; i++) {
> + for (i = 0; i < q_num_bufs; i++) {
Ditto.
> buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i));
>
> if (buf->codec.h265.mv_col_buf_size > 0) {
If this driver starts supporting DELETE_BUF, then you can't use vb2_get_num_buffers(vq),
right?
Hans
Powered by blists - more mailing lists