Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2467989lqt; Mon, 22 Apr 2024 11:30:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4XosOVFWkAxmTFPRZSCcAN0xNgR2UcpC3gjvI80J/b5GDpdE80QhrV/7XtL3sQxFUgrb3sTUNLeqUZU8l4+aahkSMh47VhjSN2wfJeg== X-Google-Smtp-Source: AGHT+IFgFxudwIvtBeoQzMMIcdz5F0BOFfPBWR/Ic729Zln8tojaqnqxLwNQP0MsH/3Xwvy13vlf X-Received: by 2002:a05:6871:7784:b0:22e:a036:c33a with SMTP id ow4-20020a056871778400b0022ea036c33amr11059480oac.6.1713810633300; Mon, 22 Apr 2024 11:30:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713810633; cv=pass; d=google.com; s=arc-20160816; b=vqkQ2Hc8IAtYOvyr7d5xauuq6cnZ7a1uaqq8lDPnET2jd6EeSFWaADqpqG2aRQuKQ/ dIbsGgxt53b5OtwXNiTkg075WS6h388yBGIBCLWgd/d673Judn0SyJZU0t/o2H93dBS2 7v/YO8YZ4PTO78cASoWk9DL77cCpc2+KVDQeqkzA86BV+CrBnDRIQQkBUShguT4OFvE6 gYVpbTGMmo5hIxTt9BenBj8tsxy+69eeaXImt1pzISGnkFQYtEQAl90pk+W73yZOPJsN y/JR/FtbE0wx6sHy+U3FMwu+/SSQUN5Mzqo50ev+0AisjxajsdQdgJkamHBRzBrAv/wJ jj/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:content-transfer-encoding:autocrypt:references :in-reply-to:cc:to:from:subject:message-id:dkim-signature; bh=wcAwBrkJKREB7jA/SJzkIQLIhy8b58rnTKTXQcQuxnU=; fh=xQERF+eaMof5KNiI50+Wwdwyv1W2i2yFzz/V0JCkiu4=; b=xZMmja1r84g2uksgIpFJC64+fBk8KioTZuSAjuUgSpRXbMevlzIqn/RW++kM6jxGn1 nm8rPpfBT5+pCSEWUEbxyCpdVFjfCe+s+F/SuE18NUWHYhDox9X+/j9agjLfIa0Fo7x3 77W0XlpOGn1cBO9I8mbEPbqu6ReWQr1oSFOEDfp1lpRr3rBfN24eZqQ8Z+56U1KFUK0d LFS+Q64B0asUCBtSAnUd5Ns4hCXyMDMLeV9bpD83cOAJJE6AFmhpSwI0kwTUB0f+MKev b8IOcHvQ0iZRjoQxDjvBksEeAhFDd1mRUeksbRRwJ2rsSOYPkEZaOECqKMztkpUj3ev/ fIVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CEnsjZA0; 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-153835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153835-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e13-20020a63aa0d000000b005f41ecd9987si8067294pgf.823.2024.04.22.11.30.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 11:30:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CEnsjZA0; 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-153835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153835-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E0ACD2813FB for ; Mon, 22 Apr 2024 18:30:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07F27155340; Mon, 22 Apr 2024 18:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="CEnsjZA0" 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 8D348154C1E; Mon, 22 Apr 2024 18:29: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=1713810587; cv=none; b=i/JYfFsAhou61wCVINBFSgGxudeEAJgb1yJfL4k8K08XPfRNQdNxWp0ejVV+ogaOvswjkI5cpAiAmG9pc7eAAzCq7M0E5mv4obZ3XYWxuCxLM6AZtYIhtfTOIFpND8v9UPpO+yWkyBjxYLODiJiLXbw6UAX351mfsnfAOQeye54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713810587; c=relaxed/simple; bh=2ixnCGqL0IkSleO59d/pziF1WHGkr6y/66rgnEeHDHI=; h=Message-ID:Subject:From:To:Cc:In-Reply-To:References:Content-Type: Date:MIME-Version; b=kdJV9y16ZOYTlf6TngS8GHhUgxFRVv7VBXj/9wQ36ey5HZL8J4V6OArHtZ/j9JwqlDth9S+fA2I4kWWRS9eTY2OburPhJuwKKbYcVtCrSmRm0HkUr7vPFzqw53XeoA0wcEfVLOtQsiRrIo5z+t+Y3M+/KLHiSXo75GL9MeAuRi4= 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=CEnsjZA0; 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=1713810583; bh=2ixnCGqL0IkSleO59d/pziF1WHGkr6y/66rgnEeHDHI=; h=Subject:From:To:Cc:In-Reply-To:References:Date:From; b=CEnsjZA0NDjyeiH4rcjsdcjWCEn2qLVKgaDJ8QsECsjfUcnslNyc5csmTKUb4IDmJ +oT6k0mPzRY5EXYivhlPGaS922BnMw/ePdjzJsnJhzQOy06HqqSVILEc9hQBagdyzQ DshkQFQ3TEe0Cq1h98P8l0MN3K5GsG5qVDIk2S5tRMdCTT22avAuksgp/Yo4Sqmq/G q/awOt8OOgfnAOmB+K4iU4OIEPCtM8HMilm8AoVtDOLvyFtnTJyWiYLi94gf8E0f70 3jM5aHm5nTZRatXoOhtLeuQ1X7tjU3/NRGBmElkL7Y21Y+X2ZGVq0QJg5JOQeSnoUn oF0AXTP2M6d+A== Received: from nicolas-tpx395.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: nicolas) by madrid.collaboradmins.com (Postfix) with ESMTPSA id B3CAE3782134; Mon, 22 Apr 2024 18:29:41 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2,5/5] media: mediatek: vcodec: fix incorrect sizeimage for 10bit bitstream From: Nicolas Dufresne To: Yunfei Dong , =?ISO-8859-1?Q?N=EDcolas?= "F . R . A . Prado" , Hans Verkuil , AngeloGioacchino Del Regno , 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 In-Reply-To: <20240409064431.16909-6-yunfei.dong@mediatek.com> References: <20240409064431.16909-1-yunfei.dong@mediatek.com> <20240409064431.16909-6-yunfei.dong@mediatek.com> Autocrypt: addr=nicolas.dufresne@collabora.com; prefer-encrypt=mutual; keydata=mQGiBEUQN0MRBACQYceNSezSdMjx7sx6gwKkMghrrODgl3B0eXBTgNp6c431IfOOEsdvkoOh1kwoYcQgbg4MXw6beOltysX4e8fFWsiRkc2nvvRW9ir9kHDm49MkBLqaDjTqOkYKNMiurFW+gozpr/lUW15QqT6v68RYe0zRdtwGZqeLzX2LVuukGwCg4AISzswrrYHNV7vQLcbaUhPgIl0D+gILYT9TJgAEK4YHW+bFRcY+cgUFoLQqQayECMlctKoLOE69nIYOc/hDr9uih1wxrQ/yL0NJvQCohSPyoyLF9b2EuIGhQVp05XP7FzlTxhYvGO/DtO08ec85+bTfVBMV6eeY4MS3ZU+1z7ObD7Pf29YjyTehN2Dan6w1g2rBk5MoA/9nDocSlk4pbFpsYSFmVHsDiAOFje3+iY4ftVDKunKYWMhwRVBjAREOByBagmRau0cLEcElpf4hX5f978GoxSGIsiKoDAlXX+ICDOWC1/EXhEEmBR1gL0QJgiVviNyLfGJlZWnPjw6xhhmtHYWTDxBOP5peztyc2PqeKsLsLWzA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05pY29sYXMgRHVmcmVzbmUgKEIgU2MuIEluZm9ybWF0aXF1ZSkgPG5pY29sYXMuZHVmcmVzbmVAdXNoZXJicm9va2UuY2E+iGAEExECACAFAkUQN0MCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRBxUwItrAaoHPTnAJ0WGgJJVspoctAvEcI00mtp5WAFGgCgr+E7ItOqZEHAs+xabBgknYZIFPW5Ag0ERRA3UhAIAJ0rxl2HsVg/nSOAUt7U/T/W+RKzVAlD9orCB0pRVvyWNxSr8MHcHmWCxykLuB34ouM4GuDVRKfGnqLzJRBfjs7Ax9K2FI3Odund9xpviLCt1jFC0K XL04RebrFT7xjDfocDaSLFvgxMVs/Jr2/ckKPId1oKvgYgt/o+MzUabKyFB8wIvq4GMtj3LoBKLCie2nCaSt7uVUt6q2t5bNWrd3lO6/mWn7YMc5Hsn33H9pS0+9szw6m3dG08eMKNueDlt72QxiYl2rhjzkT4ltKEkFgYBdyrtIj1UO6eX+YXb4E1rCMJrdjBSgqDPK1sWHC7gliy+izr+XTHuFwlfy8gBpsAAwUIAJJNus64gri4HAL632eqVpza83EphX1IuHzLi1LlMnQ9Tm7XKag46NhmJbOByMG33LwBsBdLjjHQSVkYZFWUifq+NWSFC/kqlb72vW8rBAv64+i3QdfxK9FWbweiRsPpvuHjJQuecbPDJpubLaxKbu2aqLCN5LuHXvdQr6KiXwabT+OJ9AJAqHG7q4IEzg4RNUVn9AS6L8bxqMSocjqpWNBCY2efCVd/c6k4Acv6jXu+wDAZEbWXK+71uaUHExhigBYBpiHGrobe32YlTVE/XEIzKKywhm/Hkn5YKWzumLte6xiD9JhKabmD7uqIvLt2twUpz4BdPzj0dvGlSmvFcaaISQQYEQIACQUCRRA3UgIbDAAKCRBxUwItrAaoHJLyAKDeS3AFowM3f1Y3OFU6XRCTKK2ZhwCfT/7P9WDjkkmiq5AfeOiwVlpuHtM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Date: Thu, 18 Apr 2024 16:33:36 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) Le mardi 09 avril 2024 =C3=A0 14:44 +0800, Yunfei Dong a =C3=A9crit=C2=A0: > The sizeimage of each plane is calculated the same way for 8bit and > 10bit bitstream. Using v4l2 common interface v4l2_fill_pixfmt_mp to > separate. >=20 > Fixes: 9d86be9bda6c ("media: mediatek: vcodec: Add driver to support 10bi= t") > Signed-off-by: Yunfei Dong > --- > .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 28 ++++++------------- > 1 file changed, 8 insertions(+), 20 deletions(-) >=20 > diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_de= c.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c > index 9107707de6c4..fbfba69682ea 100644 > --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c > +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c > @@ -262,40 +262,28 @@ static int vidioc_try_fmt(struct mtk_vcodec_dec_ctx= *ctx, struct v4l2_format *f, > int tmp_w, tmp_h; > =20 > /* > - * Find next closer width align 64, height align 64, size align > - * 64 rectangle > + * Find next closer width align 64, heign align 64, size align 64 rect= angle > * Note: This only get default value, the real HW needed value > * only available when ctx in MTK_STATE_HEADER state > */ > tmp_w =3D pix_fmt_mp->width; > tmp_h =3D pix_fmt_mp->height; > + > v4l_bound_align_image(&pix_fmt_mp->width, MTK_VDEC_MIN_W, frmsize->max= _width, 6, > &pix_fmt_mp->height, MTK_VDEC_MIN_H, frmsize->max_height, 6, > 9); > =20 > - if (pix_fmt_mp->width < tmp_w && > - (pix_fmt_mp->width + 64) <=3D frmsize->max_width) > + if (pix_fmt_mp->width < tmp_w && (pix_fmt_mp->width + 64) <=3D frmsize= ->max_width) > pix_fmt_mp->width +=3D 64; > - if (pix_fmt_mp->height < tmp_h && > - (pix_fmt_mp->height + 64) <=3D frmsize->max_height) > + if (pix_fmt_mp->height < tmp_h && (pix_fmt_mp->height + 64) <=3D frmsi= ze->max_height) > pix_fmt_mp->height +=3D 64; This seems overlay complicated, make sure your frmsize is valid (with step_width/height set to 64 from your Mali requirement) and then simply cal= l: v4l2_apply_frmsize_constraints(...) All this hand written clamping code with hardcoded values should go away. > =20 > + v4l2_fill_pixfmt_mp(pix_fmt_mp, fmt->fourcc, pix_fmt_mp->width, pix_fm= t_mp->height); > mtk_v4l2_vdec_dbg(0, ctx, > - "before resize wxh=3D%dx%d, after resize wxh=3D%dx%d, sizeimage=3D= %d", > + "before resize:%dx%d, after resize:%dx%d, sizeimage=3D0x%x_0x%x", > tmp_w, tmp_h, pix_fmt_mp->width, pix_fmt_mp->height, > - pix_fmt_mp->width * pix_fmt_mp->height); > - > - pix_fmt_mp->num_planes =3D fmt->num_planes; > - pix_fmt_mp->plane_fmt[0].sizeimage =3D > - pix_fmt_mp->width * pix_fmt_mp->height; > - pix_fmt_mp->plane_fmt[0].bytesperline =3D pix_fmt_mp->width; > - > - if (pix_fmt_mp->num_planes =3D=3D 2) { > - pix_fmt_mp->plane_fmt[1].sizeimage =3D > - (pix_fmt_mp->width * pix_fmt_mp->height) / 2; > - pix_fmt_mp->plane_fmt[1].bytesperline =3D > - pix_fmt_mp->width; > - } > + pix_fmt_mp->plane_fmt[0].sizeimage, > + pix_fmt_mp->plane_fmt[1].sizeimage); > } > =20 > pix_fmt_mp->flags =3D 0;