Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1937895lqo; Mon, 13 May 2024 03:07:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyoozVeWUk01xHoK4qn0QZYRv0Vll+EDSPIQY0OlwrzcJaGBn6HjHh6CQFPaoK1uj1hUbCtah0bMUU9U6Mb7D8FeeLKbE7HjGWsJO1LQ== X-Google-Smtp-Source: AGHT+IEzRpfV8D+ad0zZxC+OV5Y52mTrU2AZykVH4HOftWv0qXftDacMCJSUwKQ32Q4QweujzwS6 X-Received: by 2002:a05:6808:2208:b0:3c7:4976:7953 with SMTP id 5614622812f47-3c99702a800mr11624739b6e.3.1715594838706; Mon, 13 May 2024 03:07:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715594838; cv=pass; d=google.com; s=arc-20160816; b=okxxN8EyZ+KpnbuXB5vY/iSHO8+olTbmfTmZHF7QliLmWJfNChK/xcMdNmcm5WkyDw wb5YVzNUqlhqQgftUnIJwSFF5vCagxcfbTCdW7RuxjrOGC77g9g/1GFV9aG0kDjsLOnI rrDqizK4JcEFtqwSHopQ4cGV1PqrHvLZgtZgXT2b5DQhzTuN5/9pcO3qZWpOZ1my6GDk /+IpSzSpuFmxP03tDlO3CuBT3DxfccyvRdr2SAhGdc6SKM4tlQFpCzQLqIQvKwh2bPnu 8WhBnvwgaSrxi5dP6BFUXDQWlKykMFIviMJut+Qwhb38jv1tvCGk2WMZEJmYf0aOMVgf CH3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JPO/k6joNNxeI6K44b9Ak6WRFzDVMEJ2GRlJXYMgiAM=; fh=CVQx+7RPF6ppal3M43O6JvbWnfYQb9BFDMwroilfMUY=; b=FBvZRMmWJyzafapOSLa8Z+MX+IFLEb2gzyqB7vPkMP/Y6NpB1zEswiD1OFtGYm5o1g bLrD6LdgXxSYzdsk7wWPBeG62cX8As9nkfkJWfxmtU6CPVT8gfOzQg2Il+6RFLPwBlqc K9hfybOlVlyHLZu5vwZ8x7BHjQ5/eeL96ZkxuH+6T6HmT3Xw4M9hhXRHkUf+XBkCt40F 0+cNLmx8B935Oq3mbGeGfFRlCsPv00LxBfFCmI909Cy86O1clSzPNWQtW+gUVoZrv0Tm /30BbwR7+vPkmg+vypC3/cK75gDPZ4Vj9qIjN8vMX83ViUaZYPi5iRar7Bl7ODA1RbRq swJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=F8LAzgVG; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-177440-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177440-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f1d72d1si93873436d6.79.2024.05.13.03.07.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 03:07:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177440-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=F8LAzgVG; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-177440-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177440-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 141F51C217D6 for ; Mon, 13 May 2024 10:07:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDD76149E01; Mon, 13 May 2024 10:06:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="F8LAzgVG" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BF63148852; Mon, 13 May 2024 10:06:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715594808; cv=none; b=i+ih4RT0Ia/++A6dbXXJ5ZDJ9odT0yKb9UDxyYhwtdfyCzxKF+MRxpTH5gyzdRVA4VG05xV/T7usuNW4lGmeT1UjMwFZEObQfRfM5mZqi1oYe/AJ/A/HfnJVkN5y41JgBlMyVJY4imAvgSNcW/ONslV7jB7YUK2h/1Ex4Ey4VMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715594808; c=relaxed/simple; bh=/u1BvXSx8Lv++d99CvsKZTPM/q6EViJhondoc5qg6x4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Vx7eTSPd9JnMl14kw7yNhJdktNuIlc4JecYD9NaveK72pzhB/XHL36TURit3wiN5yM73LMQeqf+RTCr5PdKY8UJEQB0nJh4HeI++Sg+5nakJy+GkR6I27catsu1iYSD7zC8dT7TPOILA2FDgRxr3l8pPQJm1+mJoNEwQeZ/pKvQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=F8LAzgVG; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1715594803; bh=/u1BvXSx8Lv++d99CvsKZTPM/q6EViJhondoc5qg6x4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F8LAzgVG2QWlfeItmfkvpmY4lb36FXLrtoBmVNV6zOHshIVF5JvNOnY0EjSoYZ/cB 9vqpsx6KdLXL3qv7wVbVQYMbjYNUho0DIuKi1ADO583HUAvyzL9J5cWK1xxtKGGsfy sOveSKRu8cQbvAbhSa8tRkoNsWT1xiQ8f6w7rlXJT77z98uERExQuJL+agD+67eabO fcrgDRB3FimdtLIPYZh6Rwvp9stbx+lqHp/8jJ25ZFXLgyzouaRNNHJkOr7YhauaiI dBEPGBhx2eI0ulcKy6erR41/+SVhL7PL1rNX6HFDGRX/SLu9Jm7SrCwj1hOLGF2mEm SukvNpPBwi+sA== Received: from localhost (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sebastianfricke) by madrid.collaboradmins.com (Postfix) with ESMTPSA id DDE383782121; Mon, 13 May 2024 10:06:42 +0000 (UTC) Date: Mon, 13 May 2024 12:06:41 +0200 From: Sebastian Fricke To: AngeloGioacchino Del Regno Cc: Yunfei Dong , =?utf-8?B?TsOtY29sYXMgRiAuIFIgLiBBIC4=?= Prado , Nicolas Dufresne , Hans Verkuil , Benjamin Gaignard , Nathan Hebert , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Project_Global_Chrome_Upstream_Group@mediatek.com Subject: Re: [PATCH v2] media: mediatek: vcodec: add decoder command to support stateless decoder Message-ID: <20240513100641.5irday5ej2v66jur@basti-XPS-13-9310> References: <20240316081344.4262-1-yunfei.dong@mediatek.com> <2aefd938-f70a-4133-a3a8-9c96464c9f5f@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: <2aefd938-f70a-4133-a3a8-9c96464c9f5f@collabora.com> Hey Angelo, On 09.05.2024 11:54, AngeloGioacchino Del Regno wrote: >Il 16/03/24 09:13, Yunfei Dong ha scritto: >>The supported decoder commands are different for stateless and >>stateful architecture. Add stateless decoder commands to fix >>the v4l2-compliance test error below. >> >>Codec ioctls: >> VIDIOC_ENCODER_CMD returned -1 (Inappropriate ioctl for device) >> VIDIOC_TRY_ENCODER_CMD returned -1 (Inappropriate ioctl for device) >> test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) >> VIDIOC_G_ENC_INDEX returned -1 (Inappropriate ioctl for device) >> test VIDIOC_G_ENC_INDEX: OK (Not Supported) >> VIDIOC_DECODER_CMD returned -1 (Invalid argument) >> VIDIOC_TRY_DECODER_CMD returned -1 (Invalid argument) >> VIDIOC_TRY_DECODER_CMD returned -1 (Invalid argument) >> fail: v4l2-test-codecs.cpp(126): ret >> test VIDIOC_(TRY_)DECODER_CMD: FAIL >> >>Signed-off-by: Yunfei Dong > >Reviewed-by: AngeloGioacchino Del Regno > >Nicolas, Sebastian, anything to add? No looks fine for me, this is on my list for the next round of pull requests. > >Cheers, >Angelo Greetings, Sebastian > >>--- >>changed with v1: >>- remove the static function prefix. >>- fix some messages not reasonable. >>--- >> .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 60 +++++++++++++++++-- >> 1 file changed, 54 insertions(+), 6 deletions(-) >> >>diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c >>index ba742f0e391d..c2b64a528028 100644 >>--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c >>+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c >>@@ -80,21 +80,18 @@ static struct mtk_q_data *mtk_vdec_get_q_data(struct mtk_vcodec_dec_ctx *ctx, >> return &ctx->q_data[MTK_Q_DATA_DST]; >> } >>-static int vidioc_try_decoder_cmd(struct file *file, void *priv, >>- struct v4l2_decoder_cmd *cmd) >>+static int stateful_try_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd) >> { >> return v4l2_m2m_ioctl_try_decoder_cmd(file, priv, cmd); >> } >>- >>-static int vidioc_decoder_cmd(struct file *file, void *priv, >>- struct v4l2_decoder_cmd *cmd) >>+static int stateful_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd) >> { >> struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv); >> struct vb2_queue *src_vq, *dst_vq; >> int ret; >>- ret = vidioc_try_decoder_cmd(file, priv, cmd); >>+ ret = stateful_try_decoder_cmd(file, priv, cmd); >> if (ret) >> return ret; >>@@ -128,6 +125,57 @@ static int vidioc_decoder_cmd(struct file *file, void *priv, >> return 0; >> } >>+static int stateless_try_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd) >>+{ >>+ return v4l2_m2m_ioctl_stateless_try_decoder_cmd(file, priv, cmd); >>+} >>+ >>+static int stateless_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd) >>+{ >>+ struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv); >>+ int ret; >>+ >>+ ret = v4l2_m2m_ioctl_stateless_try_decoder_cmd(file, priv, cmd); >>+ if (ret) >>+ return ret; >>+ >>+ mtk_v4l2_vdec_dbg(3, ctx, "decoder cmd=%u", cmd->cmd); >>+ switch (cmd->cmd) { >>+ case V4L2_DEC_CMD_FLUSH: >>+ /* >>+ * If the flag of the output buffer is equals V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF, >>+ * this command will prevent dequeueing the capture buffer containing the last >>+ * decoded frame. Or do nothing >>+ */ >>+ break; >>+ default: >>+ mtk_v4l2_vdec_err(ctx, "invalid stateless decoder cmd=%u", cmd->cmd); >>+ return -EINVAL; >>+ } >>+ >>+ return 0; >>+} >>+ >>+static int vidioc_try_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd) >>+{ >>+ struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv); >>+ >>+ if (ctx->dev->vdec_pdata->uses_stateless_api) >>+ return stateless_try_decoder_cmd(file, priv, cmd); >>+ >>+ return stateful_try_decoder_cmd(file, priv, cmd); >>+} >>+ >>+static int vidioc_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd) >>+{ >>+ struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv); >>+ >>+ if (ctx->dev->vdec_pdata->uses_stateless_api) >>+ return stateless_decoder_cmd(file, priv, cmd); >>+ >>+ return stateful_decoder_cmd(file, priv, cmd); >>+} >>+ >> void mtk_vdec_unlock(struct mtk_vcodec_dec_ctx *ctx) >> { >> mutex_unlock(&ctx->dev->dec_mutex[ctx->hw_id]); > > >