From patchwork Thu Nov 9 20:16:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 13451680 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 D14D5C4332F for ; Thu, 9 Nov 2023 20:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344411AbjKIUQz (ORCPT ); Thu, 9 Nov 2023 15:16:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbjKIUQy (ORCPT ); Thu, 9 Nov 2023 15:16:54 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FBD83AAC; Thu, 9 Nov 2023 12:16:51 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0F1D21C0004; Thu, 9 Nov 2023 20:16:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699561010; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qlw7B5/Bx/59SQf3CbtCdO7WmqSG7NYa1WOTVO0Qk80=; b=WgEq9pmqEnbuW6waH6m/ZSGL/NBzEuXlBpDxFBA2lGrCWWtOe/4nwymHgzG3MSGAZiSxlS J0ch5GA0xJRwfSm2GEJ4Hcy4TPCj9ZYmkExXAJYP/Zw6HmbvX64xuRhpUo80hriotvgVNk hhKX5A+o6QIGwuqX/WaPyLI+knh0Vnv+KVnOFA3471FomaQ71k+NrClfDNCRga5SYRH/CA xtZAp3SVnpGXsk5Y1SIaNqfagMAEn9nCrFiBbRUcp7WuOsp4i2v52aF4JeWJ6WE7quUx5I 1/8xWkx1HCfNbs9XY4ylpXB9sQWlEsLzOwckLPo9PTn4tgPvXv/uz2wm8gB6YQ== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Ezequiel Garcia , Philipp Zabel , Mauro Carvalho Chehab , Hans Verkuil , Daniel Almeida , Greg Kroah-Hartman , Nicolas Dufresne , Sebastian Fricke , Thomas Petazzoni , Paul Kocialkowski Subject: [PATCH 1/4] media: vicodec: Disable (TRY_)DECODER_CMD for the stateless case Date: Thu, 9 Nov 2023 21:16:37 +0100 Message-ID: <20231109201640.340556-1-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.42.1 MIME-Version: 1.0 X-GND-Sasl: paul.kocialkowski@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The (TRY_)DECODER_CMD ioctls are only useful for stateful decoders and for stateless decoders that support holding capture buffers (which is not the case for this driver). Disable them when registering the stateless decoder. Signed-off-by: Paul Kocialkowski Reviewed-by: Daniel Almeida --- .../media/test-drivers/vicodec/vicodec-core.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c index 6f0e20df74e9..8f7a2b153ee9 100644 --- a/drivers/media/test-drivers/vicodec/vicodec-core.c +++ b/drivers/media/test-drivers/vicodec/vicodec-core.c @@ -1240,6 +1240,12 @@ static int vicodec_decoder_cmd(struct file *file, void *fh, struct vicodec_ctx *ctx = file2ctx(file); int ret; + /* + * This ioctl should not be used with a stateless codec that doesn't + * support holding buffers and the associated flush command. + */ + WARN_ON(ctx->is_stateless); + ret = v4l2_m2m_ioctl_try_decoder_cmd(file, fh, dc); if (ret < 0) return ret; @@ -2025,7 +2031,7 @@ static const struct v4l2_m2m_ops m2m_ops = { static int register_instance(struct vicodec_dev *dev, struct vicodec_dev_instance *dev_instance, - const char *name, bool is_enc) + const char *name, bool is_enc, bool is_stateless) { struct video_device *vfd; int ret; @@ -2045,10 +2051,11 @@ static int register_instance(struct vicodec_dev *dev, strscpy(vfd->name, name, sizeof(vfd->name)); vfd->device_caps = V4L2_CAP_STREAMING | (multiplanar ? V4L2_CAP_VIDEO_M2M_MPLANE : V4L2_CAP_VIDEO_M2M); - if (is_enc) { + if (is_enc || is_stateless) { v4l2_disable_ioctl(vfd, VIDIOC_DECODER_CMD); v4l2_disable_ioctl(vfd, VIDIOC_TRY_DECODER_CMD); - } else { + } + if (!is_enc) { v4l2_disable_ioctl(vfd, VIDIOC_ENCODER_CMD); v4l2_disable_ioctl(vfd, VIDIOC_TRY_ENCODER_CMD); } @@ -2107,17 +2114,17 @@ static int vicodec_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dev); ret = register_instance(dev, &dev->stateful_enc, "stateful-encoder", - true); + true, false); if (ret) goto unreg_dev; ret = register_instance(dev, &dev->stateful_dec, "stateful-decoder", - false); + false, false); if (ret) goto unreg_sf_enc; ret = register_instance(dev, &dev->stateless_dec, "stateless-decoder", - false); + false, true); if (ret) goto unreg_sf_dec; From patchwork Thu Nov 9 20:16:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 13451682 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 5531FC4332F for ; Thu, 9 Nov 2023 20:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345135AbjKIUQ7 (ORCPT ); Thu, 9 Nov 2023 15:16:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230398AbjKIUQ5 (ORCPT ); Thu, 9 Nov 2023 15:16:57 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75E8644B0; Thu, 9 Nov 2023 12:16:54 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 93FD01C0006; Thu, 9 Nov 2023 20:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699561011; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zbTVYuvmRUaQtmj4VIv+6MHR+6X+gUKoXAkYu3nSfeI=; b=ZK5e/wDc09qPgtZXCY6x5stZszvLgejTsenovmCcTYYN//u7hv//TDM2gA3Jw3bYHIHuF+ rjIHacq6EC/gtVzTHzcGpbb8DKHjRTnFlQunL08hd+GiWHKs9ezS4SISbT9Qjnnai2DIVN 7RAf7X40ynDSQreWM5dcNUTA2skN5UkEGkyj4Ayi75H/irUJ5uqyCSkJ0ZF0DpKYPiaTL0 oPjp205T8rEmqMUAZ/MOpudemsoEW1oW85DlbLW2pOWo81VHoxr6yUL/0DMc3HA4viHbCG tYOi0Hy8p3grRakL3cCTKL6Aqx+9LYhVnYD15zmD7rjAB2Z1ci+X0W8CwD9LIQ== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Ezequiel Garcia , Philipp Zabel , Mauro Carvalho Chehab , Hans Verkuil , Daniel Almeida , Greg Kroah-Hartman , Nicolas Dufresne , Sebastian Fricke , Thomas Petazzoni , Paul Kocialkowski Subject: [PATCH 2/4] media: visl: Hook the (TRY_)DECODER_CMD stateless ioctls Date: Thu, 9 Nov 2023 21:16:38 +0100 Message-ID: <20231109201640.340556-2-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231109201640.340556-1-paul.kocialkowski@bootlin.com> References: <20231109201640.340556-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: paul.kocialkowski@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The (TRY_)DECODER_CMD ioctls are used to support flushing when holding capture buffers is supported. This is the case of this driver but the ioctls were never hooked to the ioctl ops. Add them to correctly support flushing. Fixes: 0c078e310b6d ("media: visl: add virtual stateless decoder driver") Signed-off-by: Paul Kocialkowski Reviewed-by: Daniel Almeida --- drivers/media/test-drivers/visl/visl-video.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/test-drivers/visl/visl-video.c b/drivers/media/test-drivers/visl/visl-video.c index 7cac6a6456eb..9303a3e118d7 100644 --- a/drivers/media/test-drivers/visl/visl-video.c +++ b/drivers/media/test-drivers/visl/visl-video.c @@ -525,6 +525,9 @@ const struct v4l2_ioctl_ops visl_ioctl_ops = { .vidioc_streamon = v4l2_m2m_ioctl_streamon, .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, + .vidioc_decoder_cmd = v4l2_m2m_ioctl_stateless_decoder_cmd, + .vidioc_try_decoder_cmd = v4l2_m2m_ioctl_stateless_try_decoder_cmd, + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; From patchwork Thu Nov 9 20:16:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 13451681 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 0F999C4167D for ; Thu, 9 Nov 2023 20:16:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345127AbjKIUQ5 (ORCPT ); Thu, 9 Nov 2023 15:16:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344991AbjKIUQz (ORCPT ); Thu, 9 Nov 2023 15:16:55 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 594AD3AAC; Thu, 9 Nov 2023 12:16:53 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 64E131C0007; Thu, 9 Nov 2023 20:16:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699561012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vohYVUqiHx/VJkZ5ChoIsoqSMZl/JxxjgWPaTNjl7Z8=; b=K7iX93iQAYkSIAOK6uA/pCnI4bQvim9546Ov6EY6ycp/Ugotz1C9pJiADg+nP+DZ+zL0Z9 s7JvFag+jbUW2nxf8PiNVoFOqDCTkS1DUxHlVb7t5t3fmEXdVjmppAsqVOg5GtmWLar7yJ xXWBknp3TIkNEiTJ2IchXqb2TBZMA0bdWYC4r6NiwcPl4+wh2KotAuBhAtaas//kS6Y5S4 TxyoKg/RRj/38UgVerobG/RJe7zrCKqCQlHFTRlY7J3WNwEHlrcqLQmCOv5abPnHb0m09D V9ndFOSboXhVpZXo+GUB7QukkF96TVlgciWbtUJe5lr7jF/1Tf/0PVWVITXK/A== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Ezequiel Garcia , Philipp Zabel , Mauro Carvalho Chehab , Hans Verkuil , Daniel Almeida , Greg Kroah-Hartman , Nicolas Dufresne , Sebastian Fricke , Thomas Petazzoni , Paul Kocialkowski Subject: [PATCH 3/4] media: verisilicon: Hook the (TRY_)DECODER_CMD stateless ioctls Date: Thu, 9 Nov 2023 21:16:39 +0100 Message-ID: <20231109201640.340556-3-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231109201640.340556-1-paul.kocialkowski@bootlin.com> References: <20231109201640.340556-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: paul.kocialkowski@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The (TRY_)DECODER_CMD ioctls are used to support flushing when holding capture buffers is supported. This is the case of this driver but the ioctls were never hooked to the ioctl ops. Add them to correctly support flushing. Fixes: 340ce50f75a6 ("media: hantro: Enable HOLD_CAPTURE_BUF for H.264") Signed-off-by: Paul Kocialkowski Reviewed-by: Daniel Almeida --- drivers/media/platform/verisilicon/hantro_drv.c | 2 ++ drivers/media/platform/verisilicon/hantro_v4l2.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index a9fa05ac56a9..3a2a0f28cbfe 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -905,6 +905,8 @@ static int hantro_add_func(struct hantro_dev *vpu, unsigned int funcid) if (funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER) { vpu->encoder = func; + v4l2_disable_ioctl(vfd, VIDIOC_TRY_DECODER_CMD); + v4l2_disable_ioctl(vfd, VIDIOC_DECODER_CMD); } else { vpu->decoder = func; v4l2_disable_ioctl(vfd, VIDIOC_TRY_ENCODER_CMD); diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index b3ae037a50f6..db145519fc5d 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -785,6 +785,9 @@ const struct v4l2_ioctl_ops hantro_ioctl_ops = { .vidioc_g_selection = vidioc_g_selection, .vidioc_s_selection = vidioc_s_selection, + .vidioc_decoder_cmd = v4l2_m2m_ioctl_stateless_decoder_cmd, + .vidioc_try_decoder_cmd = v4l2_m2m_ioctl_stateless_try_decoder_cmd, + .vidioc_try_encoder_cmd = v4l2_m2m_ioctl_try_encoder_cmd, .vidioc_encoder_cmd = vidioc_encoder_cmd, }; From patchwork Thu Nov 9 20:16:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 13451683 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 C50ADC4167B for ; Thu, 9 Nov 2023 20:16:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345139AbjKIURA (ORCPT ); Thu, 9 Nov 2023 15:17:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbjKIUQ5 (ORCPT ); Thu, 9 Nov 2023 15:16:57 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75D643AAC; Thu, 9 Nov 2023 12:16:54 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 21C8F1C0008; Thu, 9 Nov 2023 20:16:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699561012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g44nGM0ulGdPmsKjAGuOOVpTRwfyVkwDcA7l+uwsI6Y=; b=j4y3CJaxX8sR0enPCYnGV1fGz8oN1sM4XbJlVX4NqPWbVT5itq0mQqJKJ3qb65iombJ0Qg U0SBXeRsB0rdLBHMCcibN7qfOGH751/DVhyjiNW1uMYec8gaOW+PHWN30NQqUEGGd59Im4 GeIuTsJVRL0xDEslefgltpHiis5nVxQAzQxWTYou9/IZQ2rww6Q2RLiSMBO8lgPjBSwEhT VxdQVRGUwuEcHjVwiAQBpKLAozY0L5Ehu0XshlsF11RN0z3Kvfm8dsILxjzK+E406YFmK4 FI2GZEBO3R5WjEbx+CY0g3d6avWTlHAK2U63zjw6u81ikBCoAxHzX8unGdhzvQ== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Ezequiel Garcia , Philipp Zabel , Mauro Carvalho Chehab , Hans Verkuil , Daniel Almeida , Greg Kroah-Hartman , Nicolas Dufresne , Sebastian Fricke , Thomas Petazzoni , Paul Kocialkowski Subject: [PATCH 4/4] media: rkvdec: Hook the (TRY_)DECODER_CMD stateless ioctls Date: Thu, 9 Nov 2023 21:16:40 +0100 Message-ID: <20231109201640.340556-4-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231109201640.340556-1-paul.kocialkowski@bootlin.com> References: <20231109201640.340556-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: paul.kocialkowski@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The (TRY_)DECODER_CMD ioctls are used to support flushing when holding capture buffers is supported. This is the case of this driver but the ioctls were never hooked to the ioctl ops. Add them to correctly support flushing. Fixes: ed7bb87d3d03 ("media: rkvdec: Enable capture buffer holding for H264") Signed-off-by: Paul Kocialkowski Reviewed-by: Daniel Almeida --- drivers/staging/media/rkvdec/rkvdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c index 84a41792cb4b..ac398b5a9736 100644 --- a/drivers/staging/media/rkvdec/rkvdec.c +++ b/drivers/staging/media/rkvdec/rkvdec.c @@ -461,6 +461,9 @@ static const struct v4l2_ioctl_ops rkvdec_ioctl_ops = { .vidioc_streamon = v4l2_m2m_ioctl_streamon, .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, + + .vidioc_decoder_cmd = v4l2_m2m_ioctl_stateless_decoder_cmd, + .vidioc_try_decoder_cmd = v4l2_m2m_ioctl_stateless_try_decoder_cmd, }; static int rkvdec_queue_setup(struct vb2_queue *vq, unsigned int *num_buffers,