From nobody Sat Sep 21 00:03:02 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D82BC6FD19 for ; Mon, 13 Mar 2023 14:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230047AbjCMOAY (ORCPT ); Mon, 13 Mar 2023 10:00:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230520AbjCMN7u (ORCPT ); Mon, 13 Mar 2023 09:59:50 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB0B61EFF3; Mon, 13 Mar 2023 06:59:26 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7a7b:d0cc:67e9:4297]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id C59C56602135; Mon, 13 Mar 2023 13:59:24 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1678715965; bh=fYbh9eWBlH82GpVa0osaPO2w/83ZN0IkmNq2BIo9WGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ODOeruRxZnAx+yyzC9IWRvTMpZsONRilbXRxmorQPADldpBHdua5ixEkbBwoy9GBM 5I/RV99ByNdJ9Kx9bItFWkYNLGse22JMpsc76pw6OpHGd1A9qxQCw80th39Jei0bXF zjCE2/dlTo/Pjq31PrVgIwg016Zgaorj7I7REsAQHNd9wWE4kfoXwgbfg38JirtFoz nW8sKpFGY3h29Qol6NH4oZDc3VPN+noNLBm/OMep1KX7aPEY1apHoxIG5mbHDVNEfB Zp/aU+PJBi/oGL9nJ73bgLMcvhANttYQpG7cqvBsP5Di1ZmPXLLOOJLX1pXTachOY3 5Fwn1c9HW87ng== From: Benjamin Gaignard To: tfiga@chromium.org, m.szyprowski@samsung.com, mchehab@kernel.org, ming.qian@nxp.com, shijie.qin@nxp.com, eagle.zhou@nxp.com, bin.liu@mediatek.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, tiffany.lin@mediatek.com, andrew-ct.chen@mediatek.com, yunfei.dong@mediatek.com, stanimir.k.varbanov@gmail.com, quic_vgarodia@quicinc.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, daniel.almeida@collabora.com, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, jerbel@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [RFC 1/4] media: videobuf2: Use vb2_get_buffer() as helper everywhere Date: Mon, 13 Mar 2023 14:59:13 +0100 Message-Id: <20230313135916.862852-2-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230313135916.862852-1-benjamin.gaignard@collabora.com> References: <20230313135916.862852-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The first step before changing how vb2 buffers are stored into queue is to avoid direct call to bufs arrays. This patch add 2 helpers functions to set and delete vb2 buffers from a queue. With these 2 and vb2_get_buffer(), bufs field of struct vb2_queue becomes like a private member of the structure. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 69 ++++++++++--------- .../media/common/videobuf2/videobuf2-v4l2.c | 17 +++-- drivers/media/platform/amphion/vpu_dbg.c | 4 +- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 2 +- .../vcodec/vdec/vdec_vp9_req_lat_if.c | 2 +- drivers/media/test-drivers/visl/visl-dec.c | 16 +++-- include/media/videobuf2-core.h | 20 ++++++ 7 files changed, 81 insertions(+), 49 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index cf6727d9c81f..b51152ace763 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -359,7 +359,7 @@ static void __setup_offsets(struct vb2_buffer *vb) unsigned long off =3D 0; =20 if (vb->index) { - struct vb2_buffer *prev =3D q->bufs[vb->index - 1]; + struct vb2_buffer *prev =3D vb2_get_buffer(q, vb->index - 1); struct vb2_plane *p =3D &prev->planes[prev->num_planes - 1]; =20 off =3D PAGE_ALIGN(p->m.offset + p->length); @@ -437,7 +437,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum = vb2_memory memory, } call_void_bufop(q, init_buffer, vb); =20 - q->bufs[vb->index] =3D vb; + vb2_set_buffer(q, vb); =20 /* Allocate video buffer memory for the MMAP type */ if (memory =3D=3D VB2_MEMORY_MMAP) { @@ -445,7 +445,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum = vb2_memory memory, if (ret) { dprintk(q, 1, "failed allocating memory for buffer %d\n", buffer); - q->bufs[vb->index] =3D NULL; + vb2_del_buffer(q, vb); kfree(vb); break; } @@ -460,7 +460,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum = vb2_memory memory, dprintk(q, 1, "buffer %d %p initialization failed\n", buffer, vb); __vb2_buf_mem_free(vb); - q->bufs[vb->index] =3D NULL; + vb2_del_buffer(q, vb); kfree(vb); break; } @@ -483,7 +483,7 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigne= d int buffers) =20 for (buffer =3D q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { - vb =3D q->bufs[buffer]; + vb =3D vb2_get_buffer(q, buffer); if (!vb) continue; =20 @@ -511,7 +511,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsig= ned int buffers) /* Call driver-provided cleanup function for each buffer, if provided */ for (buffer =3D q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { - struct vb2_buffer *vb =3D q->bufs[buffer]; + struct vb2_buffer *vb =3D vb2_get_buffer(q, buffer); =20 if (vb && vb->planes[0].mem_priv) call_void_vb_qop(vb, buf_cleanup, vb); @@ -591,8 +591,10 @@ static void __vb2_queue_free(struct vb2_queue *q, unsi= gned int buffers) /* Free vb2 buffers */ for (buffer =3D q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { - kfree(q->bufs[buffer]); - q->bufs[buffer] =3D NULL; + struct vb2_buffer *vb2 =3D vb2_get_buffer(q, buffer); + + vb2_del_buffer(q, vb2); + kfree(vb2); } =20 q->num_buffers -=3D buffers; @@ -628,7 +630,7 @@ static bool __buffers_in_use(struct vb2_queue *q) { unsigned int buffer; for (buffer =3D 0; buffer < q->num_buffers; ++buffer) { - if (vb2_buffer_in_use(q, q->bufs[buffer])) + if (vb2_buffer_in_use(q, vb2_get_buffer(q, buffer))) return true; } return false; @@ -636,7 +638,7 @@ static bool __buffers_in_use(struct vb2_queue *q) =20 void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb) { - call_void_bufop(q, fill_user_buffer, q->bufs[index], pb); + call_void_bufop(q, fill_user_buffer, vb2_get_buffer(q, index), pb); } EXPORT_SYMBOL_GPL(vb2_core_querybuf); =20 @@ -1547,7 +1549,7 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigne= d int index, void *pb) struct vb2_buffer *vb; int ret; =20 - vb =3D q->bufs[index]; + vb =3D vb2_get_buffer(q, index); if (vb->state !=3D VB2_BUF_STATE_DEQUEUED) { dprintk(q, 1, "invalid buffer state %s\n", vb2_state_name(vb->state)); @@ -1618,7 +1620,7 @@ static int vb2_start_streaming(struct vb2_queue *q) * correctly return them to vb2. */ for (i =3D 0; i < q->num_buffers; ++i) { - vb =3D q->bufs[i]; + vb =3D vb2_get_buffer(q, i); if (vb->state =3D=3D VB2_BUF_STATE_ACTIVE) vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED); } @@ -1646,7 +1648,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int i= ndex, void *pb, return -EIO; } =20 - vb =3D q->bufs[index]; + vb =3D vb2_get_buffer(q, index); =20 if (!req && vb->state !=3D VB2_BUF_STATE_IN_REQUEST && q->requires_requests) { @@ -2022,12 +2024,15 @@ static void __vb2_queue_cancel(struct vb2_queue *q) * to vb2 in stop_streaming(). */ if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { - for (i =3D 0; i < q->num_buffers; ++i) - if (q->bufs[i]->state =3D=3D VB2_BUF_STATE_ACTIVE) { + for (i =3D 0; i < q->num_buffers; ++i) { + struct vb2_buffer *vb2 =3D vb2_get_buffer(q, i); + + if (vb2->state =3D=3D VB2_BUF_STATE_ACTIVE) { pr_warn("driver bug: stop_streaming operation is leaving buf %p in act= ive state\n", - q->bufs[i]); - vb2_buffer_done(q->bufs[i], VB2_BUF_STATE_ERROR); + vb2); + vb2_buffer_done(vb2, VB2_BUF_STATE_ERROR); } + } /* Must be zero now */ WARN_ON(atomic_read(&q->owned_by_drv_count)); } @@ -2061,7 +2066,7 @@ static void __vb2_queue_cancel(struct vb2_queue *q) * be changed, so we can't move the buf_finish() to __vb2_dqbuf(). */ for (i =3D 0; i < q->num_buffers; ++i) { - struct vb2_buffer *vb =3D q->bufs[i]; + struct vb2_buffer *vb =3D vb2_get_buffer(q, i); struct media_request *req =3D vb->req_obj.req; =20 /* @@ -2215,7 +2220,7 @@ static int __find_plane_by_offset(struct vb2_queue *q= , unsigned long off, * return its buffer and plane numbers. */ for (buffer =3D 0; buffer < q->num_buffers; ++buffer) { - vb =3D q->bufs[buffer]; + vb =3D vb2_get_buffer(q, buffer); =20 for (plane =3D 0; plane < vb->num_planes; ++plane) { if (vb->planes[plane].m.offset =3D=3D off) { @@ -2262,7 +2267,7 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, uns= igned int type, return -EINVAL; } =20 - vb =3D q->bufs[index]; + vb =3D vb2_get_buffer(q, index); =20 if (plane >=3D vb->num_planes) { dprintk(q, 1, "buffer plane out of range\n"); @@ -2339,7 +2344,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_stru= ct *vma) if (ret) goto unlock; =20 - vb =3D q->bufs[buffer]; + vb =3D vb2_get_buffer(q, buffer); =20 /* * MMAP requires page_aligned buffers. @@ -2679,7 +2684,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int= read) * Check if plane_count is correct * (multiplane buffers are not supported). */ - if (q->bufs[0]->num_planes !=3D 1) { + if (vb2_get_buffer(q, 0)->num_planes !=3D 1) { ret =3D -EBUSY; goto err_reqbufs; } @@ -2688,12 +2693,14 @@ static int __vb2_init_fileio(struct vb2_queue *q, i= nt read) * Get kernel address of each buffer. */ for (i =3D 0; i < q->num_buffers; i++) { - fileio->bufs[i].vaddr =3D vb2_plane_vaddr(q->bufs[i], 0); + struct vb2_buffer *vb2 =3D vb2_get_buffer(q, i); + + fileio->bufs[i].vaddr =3D vb2_plane_vaddr(vb2, 0); if (fileio->bufs[i].vaddr =3D=3D NULL) { ret =3D -EINVAL; goto err_reqbufs; } - fileio->bufs[i].size =3D vb2_plane_size(q->bufs[i], 0); + fileio->bufs[i].size =3D vb2_plane_size(vb2, 0); } =20 /* @@ -2821,15 +2828,15 @@ static size_t __vb2_perform_fileio(struct vb2_queue= *q, char __user *data, size_ =20 fileio->cur_index =3D index; buf =3D &fileio->bufs[index]; - b =3D q->bufs[index]; + b =3D vb2_get_buffer(q, index); =20 /* * Get number of bytes filled by the driver */ buf->pos =3D 0; buf->queued =3D 0; - buf->size =3D read ? vb2_get_plane_payload(q->bufs[index], 0) - : vb2_plane_size(q->bufs[index], 0); + buf->size =3D read ? vb2_get_plane_payload(b, 0) + : vb2_plane_size(b, 0); /* Compensate for data_offset on read in the multiplanar case. */ if (is_multiplanar && read && b->planes[0].data_offset < buf->size) { @@ -2872,7 +2879,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *= q, char __user *data, size_ * Queue next buffer if required. */ if (buf->pos =3D=3D buf->size || (!read && fileio->write_immediately)) { - struct vb2_buffer *b =3D q->bufs[index]; + struct vb2_buffer *b =3D vb2_get_buffer(q, index); =20 /* * Check if this is the last buffer to read. @@ -2899,7 +2906,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *= q, char __user *data, size_ */ buf->pos =3D 0; buf->queued =3D 1; - buf->size =3D vb2_plane_size(q->bufs[index], 0); + buf->size =3D vb2_plane_size(vb2_get_buffer(q, index), 0); fileio->q_count +=3D 1; /* * If we are queuing up buffers for the first time, then @@ -2970,7 +2977,7 @@ static int vb2_thread(void *data) * Call vb2_dqbuf to get buffer back. */ if (prequeue) { - vb =3D q->bufs[index++]; + vb =3D vb2_get_buffer(q, index++); prequeue--; } else { call_void_qop(q, wait_finish, q); @@ -2979,7 +2986,7 @@ static int vb2_thread(void *data) call_void_qop(q, wait_prepare, q); dprintk(q, 5, "file io: vb2_dqbuf result: %d\n", ret); if (!ret) - vb =3D q->bufs[index]; + vb =3D vb2_get_buffer(q, index); } if (ret || threadio->stop) break; diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/medi= a/common/videobuf2/videobuf2-v4l2.c index 1f5d235a8441..01b2bb957239 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -383,7 +383,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q= , struct media_device *md return -EINVAL; } =20 - if (q->bufs[b->index] =3D=3D NULL) { + if (!vb2_get_buffer(q, b->index)) { /* Should never happen */ dprintk(q, 1, "%s: buffer is NULL\n", opname); return -EINVAL; @@ -394,7 +394,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q= , struct media_device *md return -EINVAL; } =20 - vb =3D q->bufs[b->index]; + vb =3D vb2_get_buffer(q, b->index); vbuf =3D to_vb2_v4l2_buffer(vb); ret =3D __verify_planes_array(vb, b); if (ret) @@ -628,11 +628,14 @@ static const struct vb2_buf_ops v4l2_buf_ops =3D { struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp) { unsigned int i; + struct vb2_buffer *vb2; =20 - for (i =3D 0; i < q->num_buffers; i++) - if (q->bufs[i]->copied_timestamp && - q->bufs[i]->timestamp =3D=3D timestamp) - return vb2_get_buffer(q, i); + for (i =3D 0; i < q->num_buffers; i++) { + vb2 =3D vb2_get_buffer(q, i); + if (vb2->copied_timestamp && + vb2->timestamp =3D=3D timestamp) + return vb2; + } return NULL; } EXPORT_SYMBOL_GPL(vb2_find_buffer); @@ -664,7 +667,7 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffe= r *b) dprintk(q, 1, "buffer index out of range\n"); return -EINVAL; } - vb =3D q->bufs[b->index]; + vb =3D vb2_get_buffer(q, b->index); ret =3D __verify_planes_array(vb, b); if (!ret) vb2_core_querybuf(q, b->index, b); diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platf= orm/amphion/vpu_dbg.c index 44b830ae01d8..8a423c1f6b55 100644 --- a/drivers/media/platform/amphion/vpu_dbg.c +++ b/drivers/media/platform/amphion/vpu_dbg.c @@ -133,7 +133,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *d= ata) =20 vq =3D v4l2_m2m_get_src_vq(inst->fh.m2m_ctx); for (i =3D 0; i < vq->num_buffers; i++) { - struct vb2_buffer *vb =3D vq->bufs[i]; + struct vb2_buffer *vb =3D vb2_get_buffer(vq, i); struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb); =20 if (vb->state =3D=3D VB2_BUF_STATE_DEQUEUED) @@ -148,7 +148,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *d= ata) =20 vq =3D v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); for (i =3D 0; i < vq->num_buffers; i++) { - struct vb2_buffer *vb =3D vq->bufs[i]; + struct vb2_buffer *vb =3D vb2_get_buffer(vq, i); struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb); =20 if (vb->state =3D=3D VB2_BUF_STATE_DEQUEUED) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers= /media/platform/mediatek/jpeg/mtk_jpeg_core.c index 969516a940ba..0be07f691d9a 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -603,7 +603,7 @@ static int mtk_jpeg_qbuf(struct file *file, void *priv,= struct v4l2_buffer *buf) return -EINVAL; } =20 - vb =3D vq->bufs[buf->index]; + vb =3D vb2_get_buffer(vq, buf->index); jpeg_src_buf =3D mtk_jpeg_vb2_to_srcbuf(vb); jpeg_src_buf->bs_size =3D buf->m.planes[0].bytesused; =20 diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_i= f.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c index cbb6728b8a40..f5958b6d834a 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c @@ -1701,7 +1701,7 @@ static int vdec_vp9_slice_setup_core_buffer(struct vd= ec_vp9_slice_instance *inst =20 /* update internal buffer's width/height */ for (i =3D 0; i < vq->num_buffers; i++) { - if (vb =3D=3D vq->bufs[i]) { + if (vb =3D=3D vb2_get_buffer(vq, i)) { instance->dpb[i].width =3D w; instance->dpb[i].height =3D h; break; diff --git a/drivers/media/test-drivers/visl/visl-dec.c b/drivers/media/tes= t-drivers/visl/visl-dec.c index 318d675e5668..328016b456ba 100644 --- a/drivers/media/test-drivers/visl/visl-dec.c +++ b/drivers/media/test-drivers/visl/visl-dec.c @@ -290,13 +290,14 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struc= t visl_run *run) for (i =3D 0; i < out_q->num_buffers; i++) { char entry[] =3D "index: %u, state: %s, request_fd: %d, "; u32 old_len =3D len; - char *q_status =3D visl_get_vb2_state(out_q->bufs[i]->state); + struct vb2_buffer *vb2 =3D vb2_get_buffer(out_q, i); + char *q_status =3D visl_get_vb2_state(vb2->state); =20 len +=3D 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); =20 - len +=3D visl_fill_bytesused(to_vb2_v4l2_buffer(out_q->bufs[i]), + len +=3D visl_fill_bytesused(to_vb2_v4l2_buffer(vb2), &buf[len], TPG_STR_BUF_SZ - len); =20 @@ -342,13 +343,14 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struc= t visl_run *run) len =3D 0; for (i =3D 0; i < cap_q->num_buffers; i++) { u32 old_len =3D len; - char *q_status =3D visl_get_vb2_state(cap_q->bufs[i]->state); + struct vb2_buffer *vb2 =3D vb2_get_buffer(cap_q, i); + char *q_status =3D visl_get_vb2_state(vb2->state); =20 len +=3D 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); =20 tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, &buf[old_len]); frame_dprintk(ctx->dev, run->dst->sequence, "%s", &buf[old_len]); diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 4b6a9d2ea372..d18c57e7aef0 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -1244,6 +1244,26 @@ static inline struct vb2_buffer *vb2_get_buffer(stru= ct vb2_queue *q, return NULL; } =20 +/** + * vb2_set_buffer() - set a buffer to a queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @vb: pointer to &struct vb2_buffer to be added to the queue. + */ +static inline void vb2_set_buffer(struct vb2_queue *q, struct vb2_buffer *= vb) +{ + q->bufs[vb->index] =3D vb; +} + +/** + * vb2_del_buffer() - remove a buffer from a queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @vb: pointer to &struct vb2_buffer to be removed from the queue. + */ +static inline void vb2_del_buffer(struct vb2_queue *q, struct vb2_buffer *= vb) +{ + q->bufs[vb->index] =3D NULL; +} + /* * The following functions are not part of the vb2 core API, but are useful * functions for videobuf2-*. --=20 2.34.1 From nobody Sat Sep 21 00:03:02 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 903C1C7618D for ; Mon, 13 Mar 2023 14:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbjCMOAH (ORCPT ); Mon, 13 Mar 2023 10:00:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbjCMN7v (ORCPT ); Mon, 13 Mar 2023 09:59:51 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CEDA42BE3; Mon, 13 Mar 2023 06:59:27 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7a7b:d0cc:67e9:4297]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 9B626660309C; Mon, 13 Mar 2023 13:59:25 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1678715966; bh=fqWhcs4/GgMdLp8whmAet1ILuF0Z1TgMuHnhZmsdzWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B/nUDWbvXGP1nhnuaY+/zpVS6ko+1IReLDTzh5bY6HAcciS+Cu82iJBYTKbLCCIJY Hl1gU1LyLOMdzaoIrAk1TuOZ2jmuuUgDqhQUeC4HjjujeJEWK3GRMM6zmsK7N3H0+u DAY0qmXucvqPN0G0PDuRJ8iVmx4nvAiprZgDVG8BPEzmgE1VetFkbzjnFMOh50G1Vf 9mLFlURp50N6ZN/OompkgTF13b87ywg+2kEt1dTRrWuGvi5hOUrhFoq8KccgnUzr6O OnmnuA9VSsG2ERu0Lgft+2gFEKy7IcTqRwTPgm9HiwL0omwDjsfkx30ySiNGGyEk5d kowrlfWWytOuQ== From: Benjamin Gaignard To: tfiga@chromium.org, m.szyprowski@samsung.com, mchehab@kernel.org, ming.qian@nxp.com, shijie.qin@nxp.com, eagle.zhou@nxp.com, bin.liu@mediatek.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, tiffany.lin@mediatek.com, andrew-ct.chen@mediatek.com, yunfei.dong@mediatek.com, stanimir.k.varbanov@gmail.com, quic_vgarodia@quicinc.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, daniel.almeida@collabora.com, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, jerbel@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [RFC 2/4] media: videobuf2: Replace bufs array by a list Date: Mon, 13 Mar 2023 14:59:14 +0100 Message-Id: <20230313135916.862852-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230313135916.862852-1-benjamin.gaignard@collabora.com> References: <20230313135916.862852-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replacing bufs array by a list allows to remove the 32 buffers limit per queue. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 14 ++------------ include/media/videobuf2-core.h | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index b51152ace763..96597d339a07 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -412,10 +412,6 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum= vb2_memory memory, struct vb2_buffer *vb; int ret; =20 - /* Ensure that q->num_buffers+num_buffers is below VB2_MAX_FRAME */ - num_buffers =3D min_t(unsigned int, num_buffers, - VB2_MAX_FRAME - q->num_buffers); - for (buffer =3D 0; buffer < num_buffers; ++buffer) { /* Allocate vb2 buffer structures */ vb =3D kzalloc(q->buf_struct_size, GFP_KERNEL); @@ -797,9 +793,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memo= ry memory, /* * Make sure the requested values and current defaults are sane. */ - WARN_ON(q->min_buffers_needed > VB2_MAX_FRAME); num_buffers =3D max_t(unsigned int, *count, q->min_buffers_needed); - num_buffers =3D min_t(unsigned int, num_buffers, VB2_MAX_FRAME); memset(q->alloc_devs, 0, sizeof(q->alloc_devs)); /* * Set this now to ensure that drivers see the correct q->memory value @@ -915,11 +909,6 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2= _memory memory, bool no_previous_buffers =3D !q->num_buffers; int ret; =20 - if (q->num_buffers =3D=3D VB2_MAX_FRAME) { - dprintk(q, 1, "maximum number of buffers already allocated\n"); - return -ENOBUFS; - } - if (no_previous_buffers) { if (q->waiting_in_dqbuf && *count) { dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n"); @@ -944,7 +933,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_= memory memory, return -EINVAL; } =20 - num_buffers =3D min(*count, VB2_MAX_FRAME - q->num_buffers); + num_buffers =3D *count; =20 if (requested_planes && requested_sizes) { num_planes =3D requested_planes; @@ -2444,6 +2433,7 @@ int vb2_core_queue_init(struct vb2_queue *q) =20 INIT_LIST_HEAD(&q->queued_list); INIT_LIST_HEAD(&q->done_list); + INIT_LIST_HEAD(&q->allocated_bufs); spin_lock_init(&q->done_lock); mutex_init(&q->mmap_lock); init_waitqueue_head(&q->done_wq); diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index d18c57e7aef0..47f1f35eb9cb 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -276,6 +276,8 @@ struct vb2_buffer { * done_entry: entry on the list that stores all buffers ready * to be dequeued to userspace * vb2_plane: per-plane information; do not change + * allocated_entry: entry on the list that stores all buffers allocated + * for the queue. */ enum vb2_buffer_state state; unsigned int synced:1; @@ -287,6 +289,7 @@ struct vb2_buffer { struct vb2_plane planes[VB2_MAX_PLANES]; struct list_head queued_entry; struct list_head done_entry; + struct list_head allocated_entry; #ifdef CONFIG_VIDEO_ADV_DEBUG /* * Counters for how often these buffer-related ops are @@ -556,7 +559,7 @@ struct vb2_buf_ops { * @mmap_lock: private mutex used when buffers are allocated/freed/mmapped * @memory: current memory type used * @dma_dir: DMA mapping direction. - * @bufs: videobuf2 buffer structures + * @allocated_bufs: list of buffer allocated for the queue. * @num_buffers: number of allocated/used buffers * @queued_list: list of buffers currently queued from userspace * @queued_count: number of buffers queued and ready for streaming. @@ -619,7 +622,7 @@ struct vb2_queue { struct mutex mmap_lock; unsigned int memory; enum dma_data_direction dma_dir; - struct vb2_buffer *bufs[VB2_MAX_FRAME]; + struct list_head allocated_bufs; unsigned int num_buffers; =20 struct list_head queued_list; @@ -1239,8 +1242,12 @@ static inline void vb2_clear_last_buffer_dequeued(st= ruct vb2_queue *q) static inline struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, unsigned int index) { - if (index < q->num_buffers) - return q->bufs[index]; + struct vb2_buffer *vb; + + list_for_each_entry(vb, &q->allocated_bufs, allocated_entry) + if (vb->index =3D=3D index) + return vb; + return NULL; } =20 @@ -1251,7 +1258,7 @@ static inline struct vb2_buffer *vb2_get_buffer(struc= t vb2_queue *q, */ static inline void vb2_set_buffer(struct vb2_queue *q, struct vb2_buffer *= vb) { - q->bufs[vb->index] =3D vb; + list_add_tail(&vb->allocated_entry, &q->allocated_bufs); } =20 /** @@ -1261,7 +1268,7 @@ static inline void vb2_set_buffer(struct vb2_queue *q= , struct vb2_buffer *vb) */ static inline void vb2_del_buffer(struct vb2_queue *q, struct vb2_buffer *= vb) { - q->bufs[vb->index] =3D NULL; + list_del(&vb->allocated_entry); } =20 /* --=20 2.34.1 From nobody Sat Sep 21 00:03:02 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EA52C74A4B for ; Mon, 13 Mar 2023 14:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230063AbjCMOAO (ORCPT ); Mon, 13 Mar 2023 10:00:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbjCMN7v (ORCPT ); Mon, 13 Mar 2023 09:59:51 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4294E6F607; Mon, 13 Mar 2023 06:59:28 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7a7b:d0cc:67e9:4297]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 5D5CE66030C0; Mon, 13 Mar 2023 13:59:26 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1678715967; bh=n8cd6a2Nzlrp0LhIUmAbPhk3AaD6uOUzcXdTUoEPFoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hQA9+Y0Q7jQEFOF6N106zJxZ7ElPQ5jSqBF2FraL9yIdBvCl5ioYf6L4eIVz0k6Mb GULf+Dy9D36r7WA1lwfyNJtwPdGcsIE/ymYgD58rc9TWwwQv7r3gr2y7NnRUw10BaC /94NI79rkreKD0ayKtAnuAw0KaHM6x5MmDf5gE0xVW0x2Rc2JSVoC3ypQJ8lZE+VtQ MwhECKHjyTgTF/QHixfEX7NTNGLSXcpBRqglldpIlfaJPS7stvWauByREi/Qjw/5Og VvIVGZ75IE+rm+KVTpnypcfvcN+mkl73CkPTZHy0BYzeZ2HNBXMpjpwxsLaxo4MIcu 9+CcUP4aCGGrg== From: Benjamin Gaignard To: tfiga@chromium.org, m.szyprowski@samsung.com, mchehab@kernel.org, ming.qian@nxp.com, shijie.qin@nxp.com, eagle.zhou@nxp.com, bin.liu@mediatek.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, tiffany.lin@mediatek.com, andrew-ct.chen@mediatek.com, yunfei.dong@mediatek.com, stanimir.k.varbanov@gmail.com, quic_vgarodia@quicinc.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, daniel.almeida@collabora.com, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, jerbel@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [RFC 3/4] media: videobuf2: Use bitmap to manage vb2 index Date: Mon, 13 Mar 2023 14:59:15 +0100 Message-Id: <20230313135916.862852-4-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230313135916.862852-1-benjamin.gaignard@collabora.com> References: <20230313135916.862852-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Using a bitmap to get vb2 index will allow to avoid holes in the indexes when introducing DELETE_BUF ioctl. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 22 ++++++++++++++++++- include/media/videobuf2-core.h | 6 +++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index 96597d339a07..3554811ec06a 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -397,6 +397,22 @@ static void init_buffer_cache_hints(struct vb2_queue *= q, struct vb2_buffer *vb) vb->skip_cache_sync_on_finish =3D 1; } =20 +/* + * __vb2_get_index() - find a free index in the queue for vb2 buffer. + * + * Returns an index for vb2 buffer. + */ +static int __vb2_get_index(struct vb2_queue *q) +{ + unsigned long index; + + index =3D bitmap_find_next_zero_area(q->bmap, q->idx_max, 0, 1, 0); + if (index > q->idx_max) + dprintk(q, 1, "no index available for buffer\n"); + + return index; +} + /* * __vb2_queue_alloc() - allocate vb2 buffer structures and (for MMAP type) * video buffer memory for all buffers/planes on the queue and initializes= the @@ -423,7 +439,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum = vb2_memory memory, vb->state =3D VB2_BUF_STATE_DEQUEUED; vb->vb2_queue =3D q; vb->num_planes =3D num_planes; - vb->index =3D q->num_buffers + buffer; + vb->index =3D __vb2_get_index(q); vb->type =3D q->type; vb->memory =3D memory; init_buffer_cache_hints(q, vb); @@ -2438,6 +2454,9 @@ int vb2_core_queue_init(struct vb2_queue *q) mutex_init(&q->mmap_lock); init_waitqueue_head(&q->done_wq); =20 + q->idx_max =3D ALIGN(256, BITS_PER_LONG); + q->bmap =3D bitmap_zalloc(q->idx_max, GFP_KERNEL); + q->memory =3D VB2_MEMORY_UNKNOWN; =20 if (q->buf_struct_size =3D=3D 0) @@ -2465,6 +2484,7 @@ void vb2_core_queue_release(struct vb2_queue *q) mutex_lock(&q->mmap_lock); __vb2_queue_free(q, q->num_buffers); mutex_unlock(&q->mmap_lock); + bitmap_free(q->bmap); } EXPORT_SYMBOL_GPL(vb2_core_queue_release); =20 diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 47f1f35eb9cb..4fddc6ae9f20 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -561,6 +561,8 @@ struct vb2_buf_ops { * @dma_dir: DMA mapping direction. * @allocated_bufs: list of buffer allocated for the queue. * @num_buffers: number of allocated/used buffers + * @bmap: Bitmap of buffers index + * @idx_max: number of bits in bmap * @queued_list: list of buffers currently queued from userspace * @queued_count: number of buffers queued and ready for streaming. * @owned_by_drv_count: number of buffers owned by the driver @@ -624,6 +626,8 @@ struct vb2_queue { enum dma_data_direction dma_dir; struct list_head allocated_bufs; unsigned int num_buffers; + unsigned long *bmap; + int idx_max; =20 struct list_head queued_list; unsigned int queued_count; @@ -1259,6 +1263,7 @@ static inline struct vb2_buffer *vb2_get_buffer(struc= t vb2_queue *q, static inline void vb2_set_buffer(struct vb2_queue *q, struct vb2_buffer *= vb) { list_add_tail(&vb->allocated_entry, &q->allocated_bufs); + __set_bit(vb->index, q->bmap); } =20 /** @@ -1268,6 +1273,7 @@ static inline void vb2_set_buffer(struct vb2_queue *q= , struct vb2_buffer *vb) */ static inline void vb2_del_buffer(struct vb2_queue *q, struct vb2_buffer *= vb) { + __clear_bit(vb->index, q->bmap); list_del(&vb->allocated_entry); } =20 --=20 2.34.1 From nobody Sat Sep 21 00:03:02 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3769DC61DA4 for ; Mon, 13 Mar 2023 14:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231366AbjCMOAU (ORCPT ); Mon, 13 Mar 2023 10:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbjCMN7w (ORCPT ); Mon, 13 Mar 2023 09:59:52 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3D116F4BF; Mon, 13 Mar 2023 06:59:28 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7a7b:d0cc:67e9:4297]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 1A4FA66030DE; Mon, 13 Mar 2023 13:59:27 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1678715967; bh=MTvegXhMpPXwPhoNdwtKrByhIzVdZZIQRvTrqjWmlRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=chTWqyXASFpt6tnIK/8K9JTWlQI4YkXIJ6ZvZZ+ygtTEj5OvN1vIJDUQW4e0kv1Xv CQfqtkjrYr5fWDOOaQAHSwUZ5iB3yOEdGjr7sZAuXGkrhkf3dsFGfHNxcCmT5/lomU lHn5c4e7S/Poq6kx8qmp6tmwq+w9E1d3ZZcNuDQv99bPnW867GbL9QbsFHteS2OqOZ bsJCB/ylaxG02Ug/9LFyxpkwUBgjZqV4ERSlN/1JLJJpPyCuGCEpPF445ePH8Gg6uI B6DyrEcEQJ0PJZQJiTc4YpSdHnZOaMZ1d2G68CwklT8WMoW1BmgmHTp+msHyeJXE4k KcYAHeGlf6vmg== From: Benjamin Gaignard To: tfiga@chromium.org, m.szyprowski@samsung.com, mchehab@kernel.org, ming.qian@nxp.com, shijie.qin@nxp.com, eagle.zhou@nxp.com, bin.liu@mediatek.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, tiffany.lin@mediatek.com, andrew-ct.chen@mediatek.com, yunfei.dong@mediatek.com, stanimir.k.varbanov@gmail.com, quic_vgarodia@quicinc.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, daniel.almeida@collabora.com, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, jerbel@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [RFC 4/4] media: videobuf2: Stop define VB2_MAX_FRAME as global Date: Mon, 13 Mar 2023 14:59:16 +0100 Message-Id: <20230313135916.862852-5-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230313135916.862852-1-benjamin.gaignard@collabora.com> References: <20230313135916.862852-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" After changing bufs arrays to a list VB2_MAX_FRAME doesn't mean anything for videobuf2 core. Remove it from the core definitions but keep it for drivers internal needs. Signed-off-by: Benjamin Gaignard --- drivers/media/common/videobuf2/videobuf2-core.c | 2 ++ drivers/media/platform/amphion/vdec.c | 1 + .../media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c | 2 ++ drivers/media/platform/qcom/venus/hfi.h | 2 ++ drivers/media/platform/verisilicon/hantro_hw.h | 2 ++ include/media/videobuf2-core.h | 1 - include/media/videobuf2-v4l2.h | 4 ---- 7 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index 3554811ec06a..754570ab23b3 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -31,6 +31,8 @@ =20 #include =20 +#define VB2_MAX_FRAME 32 + static int debug; module_param(debug, int, 0644); =20 diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform= /amphion/vdec.c index 87f9f8e90ab1..bef0c1b869be 100644 --- a/drivers/media/platform/amphion/vdec.c +++ b/drivers/media/platform/amphion/vdec.c @@ -28,6 +28,7 @@ =20 #define VDEC_MIN_BUFFER_CAP 8 #define VDEC_MIN_BUFFER_OUT 8 +#define VB2_MAX_FRAME 32 =20 struct vdec_fs_info { char name[8]; diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_i= f.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c index f5958b6d834a..ba208caf3043 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c @@ -16,6 +16,8 @@ #include "../vdec_drv_if.h" #include "../vdec_vpu_if.h" =20 +#define VB2_MAX_FRAME 32 + /* reset_frame_context defined in VP9 spec */ #define VP9_RESET_FRAME_CONTEXT_NONE0 0 #define VP9_RESET_FRAME_CONTEXT_NONE1 1 diff --git a/drivers/media/platform/qcom/venus/hfi.h b/drivers/media/platfo= rm/qcom/venus/hfi.h index f25d412d6553..bd5ca5a8b945 100644 --- a/drivers/media/platform/qcom/venus/hfi.h +++ b/drivers/media/platform/qcom/venus/hfi.h @@ -10,6 +10,8 @@ =20 #include "hfi_helper.h" =20 +#define VB2_MAX_FRAME 32 + #define VIDC_SESSION_TYPE_VPE 0 #define VIDC_SESSION_TYPE_ENC 1 #define VIDC_SESSION_TYPE_DEC 2 diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media= /platform/verisilicon/hantro_hw.h index e83f0c523a30..9e8faf7ba6fb 100644 --- a/drivers/media/platform/verisilicon/hantro_hw.h +++ b/drivers/media/platform/verisilicon/hantro_hw.h @@ -15,6 +15,8 @@ #include #include =20 +#define VB2_MAX_FRAME 32 + #define DEC_8190_ALIGN_MASK 0x07U =20 #define MB_DIM 16 diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 4fddc6ae9f20..92f5b5e16003 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -20,7 +20,6 @@ #include #include =20 -#define VB2_MAX_FRAME (32) #define VB2_MAX_PLANES (8) =20 /** diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 5a845887850b..88a7a565170e 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -15,10 +15,6 @@ #include #include =20 -#if VB2_MAX_FRAME !=3D VIDEO_MAX_FRAME -#error VB2_MAX_FRAME !=3D VIDEO_MAX_FRAME -#endif - #if VB2_MAX_PLANES !=3D VIDEO_MAX_PLANES #error VB2_MAX_PLANES !=3D VIDEO_MAX_PLANES #endif --=20 2.34.1