Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2467672lqt; Mon, 22 Apr 2024 11:30:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpZ0aKqUAWS3cvtMrijddwILshu/EdjURu1J1Dn8mDVYxR4abnZKyRw78+Kj1ACG2ifY24OMq+SRcwObzUkjDV4cj8bhYbFLZi2+dIZQ== X-Google-Smtp-Source: AGHT+IHZOI4LD8VDkxlMXSQeMOCHMcuZ7dDbdE3MiZ5kdNxO2zku+Hhnki7bD39wfLAbufYRcXUa X-Received: by 2002:a50:9e05:0:b0:570:369:3e06 with SMTP id z5-20020a509e05000000b0057003693e06mr6969259ede.19.1713810602389; Mon, 22 Apr 2024 11:30:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713810602; cv=pass; d=google.com; s=arc-20160816; b=CKpjIXHSVUyCbn2YK2016osyiqNPQw+8aXbsBlv2ehTPkmD3z4mCr9fiL4Z7lvViVT vFnKr/MPyB+ytTzpRuRc6+sbCuEZUCZ2ensp0Yzrh2mL9en8SCv0NtWVGmFFW4QIfvMK CaccKkRmuhMkIe+UV2hYrq04/SrHavLMiJKj0SJfPK8dq1AkzySnrB9u8kH1u9N6js1V sOciwuIDK1HqYW4pugNh1jdj5GGxTpEbhoHl7LMKbgBKInublFD5CcCnNmGPs+Lv+bqv YF1WO+QtPNwfdUGg9Q3U7f6BRBmr3kmA9SyDnd2OksfPcmEnh5S7rZBPvwQVCiLCi4gd 5OBg== 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=IRd5d/6ItoWaQFashnY5yCc8o0lGG6zGkujr2DrEiIk=; fh=xQERF+eaMof5KNiI50+Wwdwyv1W2i2yFzz/V0JCkiu4=; b=i88oQOCJqZm06HKNf76QydvYzmuR2QH3Eru5WJIxOFo40QacDPFijrKr47IFWoajo/ DFjnlGIhmqRDiKXuXOS2VH6X8hp08oZIqIhFmJKYwrbE+oo8ktWNGBxKFD9IyiFSU2b7 C5mkT4d7TcPBMfKZNxdooPFH5+H6JO7PB06Z2BoIEJtQaJLmvduKIZA62/AiMv7lpppt f0TQCo5+oJoy6o+gJ5F9WTtabGbXR7YhZ2q7peKUOjmy7EVxOA7UYXhzdlx6OuT/ryHW dtGhOeitjFszgfIHhCvMCFpG6alxkicy22dXN6/XX4/AC5+SwP/Rw9FRl8/H+gHU6N7M LCQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KyLetmpf; 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-153833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n19-20020a509353000000b00571b9f228a0si6370400eda.8.2024.04.22.11.30.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 11:30:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KyLetmpf; 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-153833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153833-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 am.mirrors.kernel.org (Postfix) with ESMTPS id DABC91F2182D for ; Mon, 22 Apr 2024 18:30:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C075154BF6; Mon, 22 Apr 2024 18:29:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="KyLetmpf" 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 C69C7153BFE; Mon, 22 Apr 2024 18:29:31 +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=1713810573; cv=none; b=R8Zz4dsfotqa1nHvJqitZjuyCnkLikOb1dBrOMo+QdKBsvFu/iffegkMapClw3GsqO2VJDfFco+V8QxSSM9kxka1VbhuHeg4jCM6cIEvdqy5JbNJ8Nozj2FqJ9tZ/Cd++7G/BAqXtjngTfDsaIqTDT88sCBpl3GQ9lplQy6BvNU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713810573; c=relaxed/simple; bh=lFyqqsTbvpBevoPN6/NMC90GOUXMW6KIKKFAoQiAmFs=; h=Message-ID:Subject:From:To:Cc:In-Reply-To:References:Content-Type: Date:MIME-Version; b=n4SjjcZkcajU7Xtr1Otw5QR8bO8J/iFJHFKQ/e/8CCxsuY0Yhuhc2OnmADBW4TkFRYbhKweYvpXKgfXvBSRR7Kj24zz9Luu1zFEwLaMAZCsgpKLRgLuuY0JCOhoa0atADrNTa0FGCC5JHCu7D6rdtBB3cfiN/GzAz7CpEd+P5r0= 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=KyLetmpf; 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=1713810570; bh=lFyqqsTbvpBevoPN6/NMC90GOUXMW6KIKKFAoQiAmFs=; h=Subject:From:To:Cc:In-Reply-To:References:Date:From; b=KyLetmpfhfD1CxoIRlN05i1koDUuorqGDIwBeQ6ZOKcqCiovB94RRm45TZ9YUy2SD Bs8DpHi+gVhLVVGm66EZXc49DACSnsYF//3WRj2sSehAdCOP9sZrXjbLTW5C/fQ+ZI l/+3dgVEJp1YzHGak+pZ1nx6/0WsmiFC2h3vrb3kbkqfRib35sRAiBnRXZ4PgmBMPu hWrTYCPiDnFfGs8EveixzyGMTRAicRjDbFuI4FAj2jS6x+tMPpRLcxxA/VJLJXCfad Dr4dXAuSPgo0tihp+8cGPWJu4Svu7pp9Jdnsnl7h536iIPeZQ/8Xlql54Si6J9LXgU AkDzdSyTckINw== 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 EF1D13782139; Mon, 22 Apr 2024 18:29:27 +0000 (UTC) Message-ID: <345e7b0ce96b900725e086f550aafd6ecf0dbc7f.camel@collabora.com> Subject: Re: [PATCH v2,1/5] media: mediatek: vcodec: fix incorrect MT2T format information 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-2-yunfei.dong@mediatek.com> References: <20240409064431.16909-1-yunfei.dong@mediatek.com> <20240409064431.16909-2-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/EXhEEmBR1gL0QJgiVviNyLfGJlZWnPjw6xhhmtHYWTDxBOP5peztyc2PqeKsLsLWzAr7RDTmlj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MgRHVmcmVzbmUgKEIgU2MuIEluZm9ybWF0aXF1ZSkgPG5pY29sYXMuZHVmcmVzbmVAdXNoZXJicm9va2UuY2E+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:17:46 -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: > Changing the bpp and hdiv values to make sure the bytesperline > of plane[0] and plane[1] are the same. The width and height are > 64 align. >=20 > Fixes: 6afcc2b0aebf ("media: mediatek: vcodec: Add capture format to supp= ort 10bit tile mode") > Signed-off-by: Yunfei Dong > --- > drivers/media/v4l2-core/v4l2-common.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-c= ore/v4l2-common.c > index d34d210908d9..8587cd14741c 100644 > --- a/drivers/media/v4l2-core/v4l2-common.c > +++ b/drivers/media/v4l2-core/v4l2-common.c > @@ -265,8 +265,8 @@ const struct v4l2_format_info *v4l2_format_info(u32 f= ormat) > { .format =3D V4L2_PIX_FMT_VYUY, .pixel_enc =3D V4L2_PIXEL_ENC_YUV,= .mem_planes =3D 1, .comp_planes =3D 1, .bpp =3D { 2, 0, 0, 0 }, .bpp_div = =3D { 1, 1, 1, 1 }, .hdiv =3D 2, .vdiv =3D 1 }, > { .format =3D V4L2_PIX_FMT_Y212, .pixel_enc =3D V4L2_PIXEL_ENC_YUV,= .mem_planes =3D 1, .comp_planes =3D 1, .bpp =3D { 4, 0, 0, 0 }, .bpp_div = =3D { 1, 1, 1, 1 }, .hdiv =3D 2, .vdiv =3D 1 }, > { .format =3D V4L2_PIX_FMT_YUV48_12, .pixel_enc =3D V4L2_PIXEL_ENC_YUV= , .mem_planes =3D 1, .comp_planes =3D 1, .bpp =3D { 6, 0, 0, 0 }, .bpp_div = =3D { 1, 1, 1, 1 }, .hdiv =3D 1, .vdiv =3D 1 }, > - { .format =3D V4L2_PIX_FMT_MT2110T, .pixel_enc =3D V4L2_PIXEL_ENC_YUV,= .mem_planes =3D 2, .comp_planes =3D 2, .bpp =3D { 5, 10, 0, 0 }, .bpp_div = =3D { 4, 4, 1, 1 }, .hdiv =3D 2, .vdiv =3D 2, > - .block_w =3D { 16, 8, 0, 0 }, .block_h =3D { 32, 16, 0, 0 }}, > + { .format =3D V4L2_PIX_FMT_MT2110T, .pixel_enc =3D V4L2_PIXEL_ENC_YUV,= .mem_planes =3D 2, .comp_planes =3D 2, .bpp =3D { 5, 5, 0, 0 }, .bpp_div = =3D { 4, 4, 1, 1 }, .hdiv =3D 1, .vdiv =3D 2, > + .block_w =3D { 64, 64, 0, 0 }, .block_h =3D { 64, 64, 0, 0 }}, The code that calculate the info you are fixing: plane->bytesperline =3D info->bpp[i] * DIV_ROUND_UP(aligned_width, hdiv) / info->bpp_div[i]; plane->sizeimage =3D plane->bytesperline * DIV_ROUND_UP(aligned_height, vdi= v); hdiv is 1 for the first plane, and 2 for second plane. Let say we have 1920= x1080 video, bytesperline for that first planes would be 5 * (1920 / 1) / 4 =3D 2= 400. But for the second plane with your change we have 5 * (1920 / 2) / 4 =3D 12= 00. For me, you failed to achieve your goal, or there is a bug elsewhere. The second change should have its own commit, but I think it should be drop= ped. The driver is hacked to be compatible with the Mali GPUs (64x64 textures), = but does not need this alignment. And in any case, the block should represent t= he pixel format required alignment, so I'd suggest to leave it like this, and simply align width/height before calling the function to calculate stride/sizeimage. The 64x64 alignment can be applied using v4l2_apply_frmsize_constraints() during try fmt (or v4l_bound_align_image()= , but first is preferred). Same comments apply to the following patch, which should be squashed. > { .format =3D V4L2_PIX_FMT_MT2110R, .pixel_enc =3D V4L2_PIXEL_ENC_YUV,= .mem_planes =3D 2, .comp_planes =3D 2, .bpp =3D { 5, 10, 0, 0 }, .bpp_div = =3D { 4, 4, 1, 1 }, .hdiv =3D 2, .vdiv =3D 2, > .block_w =3D { 16, 8, 0, 0 }, .block_h =3D { 32, 16, 0, 0 }}, > =20