From patchwork Thu Aug 24 09:21:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 13363812 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D567C27C40 for ; Thu, 24 Aug 2023 09:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=lY3SKOBEe+Tm0td8q7cGGhbQ6WPRuOZQA4+UgG2HyFo=; b=N4Vk25wv833P/HKECpwZEc2vSl rF/KECjDrUs6dzNxSmu9BHyTBrCj79g5MqM24wvUNkk1qzlrnhnSkBfLnfVHNMoPB1eAE8GS1+Fd6 OWzv0ik1jmWmGxzqAmNlLSZjCj4L1pxTTYapAZxVvm0Oh0J8KzYZyEnSLA9UDzV1S34fYylOKhTM+ F8Xa2OSikpkqe3OQwjiv9AWlrvpPRq7dVIZaf9x0E0vYf2zQzmljAoHT89+nzkrrvKQcaCp94bGtQ 99B94Q82fXhiNrF+jdeX+FjanRsV6NE3FB9h9+OrvxW48X6DYv9BMYFXY52JsniLMS2T6JZs/pqyr vYxKhLPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qZ6Xa-002gJE-0x; Thu, 24 Aug 2023 09:22:10 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qZ6XD-002g40-20; Thu, 24 Aug 2023 09:21:51 +0000 Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:672:c310:4c8a:3a97]) (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 9541A6607258; Thu, 24 Aug 2023 10:21:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1692868902; bh=97a+g3efIidtGcTZHHeZ+X2jVG7x/bgfTKTTmbRUcvY=; h=From:To:Cc:Subject:Date:From; b=Orh/iAMx3/nUXWSytzs0WnKL/qlPvNmhlqtiScLvTQv/Ywb+RxROkkv5eebgqZ6mw Jh7r3H2IAZRGwuSQl3DmqBr9jpjZNihpnYpLuE2+gmVwOIpkWLTZu1aFLoz71P5nKV /im5/p1sMMnEiT3lwvyAC3Z8GGrXIkVJTTBsd+p5mw/5vEawfHenv66TvfBOoMjO7e zZhkqxgMxUy6NspJwLu8nJpOfXB2ZHJHKTSDRjeHi/3GQ7ZKdU+RQv0HP8E/WMw4OI whhReVWqe9ZOpf85AS9JBpM66odPQ699+EtZ6AgxGmDNF+JOE1/lUv9NX+zlQg+xHI WLJt+PEBxR8dQ== From: Benjamin Gaignard To: mchehab@kernel.org, tfiga@chromium.org, m.szyprowski@samsung.com, ming.qian@nxp.com, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com 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, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v5 00/10] Add DELETE_BUF ioctl Date: Thu, 24 Aug 2023 11:21:23 +0200 Message-Id: <20230824092133.39510-1-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230824_022147_970801_951050FF X-CRM114-Status: GOOD ( 15.98 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Unlike when resolution change on keyframes, dynamic resolution change on inter frames doesn't allow to do a stream off/on sequence because it is need to keep all previous references alive to decode inter frames. This constraint have two main problems: - more memory consumption. - more buffers in use. To solve these issue this series introduce DELETE_BUFS ioctl and remove the 32 buffers limit per queue. VP9 conformance tests using fluster give a score of 210/305. The 24 resize inter tests (vp90-2-21-resize_inter_* files) are ok but require to use postprocessor. Kernel branch is available here: https://gitlab.collabora.com/benjamin.gaignard/for-upstream/-/commits/remove_vb2_queue_limit_v5 GStreamer branch to use DELETE_BUF ioctl and testing dynamic resolution change is here: https://gitlab.freedesktop.org/benjamin.gaignard1/gstreamer/-/commits/VP9_drc changes in version 5 - Rework offset cookie encoding pattern is n ow the first patch of the serie. - Use static array instead of allocated one for postprocessor buffers. changes in version 4: - Stop using Xarray, instead let queues decide about their own maximum number of buffer and allocate bufs array given that value. - Rework offset cookie encoding pattern. - Change DELETE_BUF to DELETE_BUFS because it now usable for range of buffer to be symetrical of CREATE_BUFS. - Add fixes tags on couple of Verisilicon related patches. - Be smarter in Verisilicon postprocessor buffers management. - Rebase on top of v6.4 changes in version 3: - Use Xarray API to store allocated video buffers. - No module parameter to limit the number of buffer per queue. - Use Xarray inside Verisilicon driver to store postprocessor buffers and remove VB2_MAX_FRAME limit. - Allow Versilicon driver to change of resolution while streaming - Various fixes the Verisilicon VP9 code to improve fluster score. changes in version 2: - Use a dynamic array and not a list to keep trace of allocated buffers. Not use IDR interface because it is marked as deprecated in kernel documentation. - Add a module parameter to limit the number of buffer per queue. - Add DELETE_BUF ioctl and m2m helpers. Regards, Benjamin Benjamin Gaignard (10): media: videobuf2: Rework offset 'cookie' encoding pattern media: videobuf2: Access vb2_queue bufs array through helper functions media: videobuf2: Be more flexible on the number of queue stored buffers media: verisilicon: Refactor postprocessor to store more buffers media: verisilicon: Store chroma and motion vectors offset media: verisilicon: vp9: Use destination buffer height to compute chroma offset media: verisilicon: postproc: Fix down scale test media: verisilicon: vp9: Allow to change resolution while streaming media: v4l2: Add DELETE_BUFS ioctl media: v4l2: Add mem2mem helpers for DELETE_BUFS ioctl .../userspace-api/media/v4l/user-func.rst | 1 + .../media/v4l/vidioc-delete-bufs.rst | 73 +++++ .../media/common/videobuf2/videobuf2-core.c | 304 +++++++++++++----- .../media/common/videobuf2/videobuf2-v4l2.c | 44 ++- drivers/media/platform/amphion/vpu_dbg.c | 22 +- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 6 +- .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 2 +- drivers/media/platform/st/sti/hva/hva-v4l2.c | 4 + drivers/media/platform/verisilicon/hantro.h | 9 +- .../media/platform/verisilicon/hantro_drv.c | 4 +- .../platform/verisilicon/hantro_g2_vp9_dec.c | 10 +- .../media/platform/verisilicon/hantro_hw.h | 4 +- .../platform/verisilicon/hantro_postproc.c | 95 ++++-- .../media/platform/verisilicon/hantro_v4l2.c | 27 +- drivers/media/test-drivers/vim2m.c | 1 + drivers/media/test-drivers/visl/visl-dec.c | 28 +- drivers/media/v4l2-core/v4l2-dev.c | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 17 + drivers/media/v4l2-core/v4l2-mem2mem.c | 20 ++ .../staging/media/atomisp/pci/atomisp_ioctl.c | 2 +- include/media/v4l2-ioctl.h | 4 + include/media/v4l2-mem2mem.h | 12 + include/media/videobuf2-core.h | 13 +- include/media/videobuf2-v4l2.h | 11 + include/uapi/linux/videodev2.h | 17 + 25 files changed, 584 insertions(+), 147 deletions(-) create mode 100644 Documentation/userspace-api/media/v4l/vidioc-delete-bufs.rst