Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1037261lqo; Thu, 9 May 2024 02:54:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1nuDlHxe/NjmO95fuYuJ3TXvR4x9Uw1utFnc2dtWcjWBpQeATL1hj51r8sd1s/QNFmF7wLYZVxtz5vfT4A18gviZdzutXBEZCrtIckQ== X-Google-Smtp-Source: AGHT+IE2zJ9deAWqBG8aoomn2z7uHtWqg/I5k4PIUji4eHE/X2LDSNZ0h1mqT4gMidbd+DKklj8h X-Received: by 2002:a9d:6442:0:b0:6f0:497e:84ad with SMTP id 46e09a7af769-6f0b7fb6a46mr5872761a34.38.1715248487324; Thu, 09 May 2024 02:54:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715248487; cv=pass; d=google.com; s=arc-20160816; b=QDv1zOcGpkrMJAzXiwI2OgxoPKhq4Mr21in+sf2LqOgjJ1FZ49dePl7jmo7HVWylWw PjPIorq4UrqgIPH+AElrAnTs434Zo+cXEkkeo862kU3c0dyIYaYUmHdwxDRWcMX81rq4 3cDD0h1/RRHXMff1sgdrQYARmLUvpDYqE587CqcauHAzjiTLeQZApAvbQulTEcoZv0sd h7SXxbsSckkbsLgdGyt5ivJLgoUMAFcL20iZlrBQ3xDUoKdPLRc+IT6bZsdYkxoV5xhr 3Oytm4PLTTClj2c4ci7XxgT84tDwyyaslWhW69rwkwgXb8cQ/Ei4XYcqILPIIRHul9oC eCWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=j4A/xX1yuoTXQPJxZSU++qe3x9DPYpUYp1GCrfLK9Ek=; fh=a6LEtUke36IFjkXzi3PfkW2XK1dmP9fc2vN4Zati2Og=; b=YdAydINKoZTgAI0zsQXIXS0Ywv3RgM8WbVbCEsCqJKciwiAzuryQ/sT+nymDGF52gq 3aqjiiH6oCutmmvaiEqtq+EDYSjnIFML4xKvPWHVfBBc45fNrrnqnalKLc8OaTo6om6k M7mr49UZ8ZyHgSyxwOx9IUi3oOqgQP8FHdxyW1APvtOSfvkrYOOJsMI/9Og8og2tQQAS Tgw28yt2nrBBPvUINhWqbk836TiOmvPGKQ/fVYb5E8WDzIp6dY6BO4NP6oEvHY9PiUFb PUOZH1dyqA1xDNHu4DFSgRHRbUtJMxvxIXbqR5BT0Jf6SUlwIEEjSG52hVIauzMyablC DvWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=njHpLvDQ; 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-174376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174376-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 af79cd13be357-792bf309973si95121585a.231.2024.05.09.02.54.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 02:54:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174376-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=njHpLvDQ; 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-174376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174376-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 0077D1C21EBD for ; Thu, 9 May 2024 09:54:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4325F14AD37; Thu, 9 May 2024 09:54:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="njHpLvDQ" 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 B4047101E3; Thu, 9 May 2024 09:54:34 +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=1715248476; cv=none; b=Guu6eaTEROBgKXlsQoj+TA/Kp8F63KXz3S3d4yjEJF201czMZ4Da+kGBeomFlVu5dbYTVgNsq6Ul4pZJYme7Dl93fWePXdaY53HGXwWmNEVHvPTy1pdCAUhP4ymSxNCWe4b613Q0rZd2QUzR5MNdVvN6Bjl/PpKO6nBmOVUf6gU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715248476; c=relaxed/simple; bh=vlum46Tb8PK1ROm2H5JtmPI6YiTvRNegUq7mRooArb4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=vBilxlkS8ZkAg5+KwBg4vdsHY+tSGFDjhMjXL2KuV3Pca4eGFFJY+WSlh1IMgiiDqAwCwCTysmt2EBlO5yE6Ui11zHqf4e50pEVHLVVaH31u2dareE/Wcis5gPQ7m7w0mD48jBZ38NdGmBf+x0108JkyL15Kz79vufA2RsFoZEY= 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=njHpLvDQ; 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=1715248472; bh=vlum46Tb8PK1ROm2H5JtmPI6YiTvRNegUq7mRooArb4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=njHpLvDQoHLR62SJqkphCa4t2y6tge0nUhsPjiEp71pkNWsyrAN9BxUS304Kx7X7p gNzc+DR86MGpZTq+PcN5NGK7RqX1XBRruJSACmb0wweYeaAXtNL9djgi9y32NYf7Fp z7IBKnI5nwAd7fhzO8nGjt/Kl/UTDQaQRXAETNW7sYcIYYl3xj6ufid1lfBQmy9dOr 1JKijGa9ezVTF6Aj3opG0KkReV/MAVHTvZx24CDxcp7a9nysq14/ymKDQ+MAVnSeez 9hsjM1FNr3fdjZEE7DZu18QYbwQvt3fFVSNeBM7HbE06eEI+geyYFFWJQoOCfG+UVr 1szJShnvwrpvA== Received: from [100.113.186.2] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id C518637820FA; Thu, 9 May 2024 09:54:31 +0000 (UTC) Message-ID: <2aefd938-f70a-4133-a3a8-9c96464c9f5f@collabora.com> Date: Thu, 9 May 2024 11:54:31 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] media: mediatek: vcodec: add decoder command to support stateless decoder To: Yunfei Dong , =?UTF-8?Q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Nicolas Dufresne , Hans Verkuil , Benjamin Gaignard , Nathan Hebert , Sebastian Fricke Cc: 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 References: <20240316081344.4262-1-yunfei.dong@mediatek.com> From: AngeloGioacchino Del Regno Content-Language: en-US In-Reply-To: <20240316081344.4262-1-yunfei.dong@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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? Cheers, Angelo > --- > 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]);