Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp233267lqp; Thu, 4 Apr 2024 11:29:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUkK8fvZvknp7qiTdMonV8+PUke8B2B6zREYYWX3bMHDPBpgLpVgo0L08pJ/5Zj4hd02yMOve6QjL8ObRyDpTpwilFlHCzAbXpcBk8NGQ== X-Google-Smtp-Source: AGHT+IH15Wg5vz1fxU6lX8ARv3ajzrbIfQdScj47DgrFIPgQIwfaOmLl7tNJMCVAqxdO2YQBVlbK X-Received: by 2002:a50:c305:0:b0:56e:de1:f427 with SMTP id a5-20020a50c305000000b0056e0de1f427mr2169248edb.25.1712255363215; Thu, 04 Apr 2024 11:29:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712255363; cv=pass; d=google.com; s=arc-20160816; b=flzMUxtvLzF4CBFO/kBHStKC40JuAhxcI5O+CfcEf2QqLiutCjufIQsJQQcL6yTW7u KpHVwA4LKFt8GzNXpMDqd/CONwL+YgcJHZd1QQVTtZbA8URaU6k3IrPAnRlempL/jgvw xkvbQRkg4C2aFQJr4XPG6LGdEHzj9e6IK4jzxLjiZaBc0axWziYb6z65LDMhq9K9KwaW wtHX1kCvt07iakLf4yag3QDb0dmanXAUS3qMDA7nyXrLSrR6nWwt0UQsEdAlEXca/TkP SkwFMv5PoZWs39AgbqxHo/XMRlBsjOlUnM8kGz0HWEaI1tPMa0YR7kq9RLgoYJlOyI8+ 1dmw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:autocrypt:references :in-reply-to:date:cc:to:from:subject:message-id:dkim-signature; bh=cjEZP/PNLWTKZkjySuBXmesFi8isoCc88gy4I1lUyiE=; fh=W8Bbjif/nSIECnZoFBOjN/7V3OkEFoCMSbU94TWnuVI=; b=aF8hglneoxWNSix8X7xIyji8oqJPjtBNpe1zhDLaLFYaLMELBGe6vLj9iGN2+tk0SB +1NGdVqGm3X3SafczUkgmMOzWCXO6EIn2dFY97RDg/J5ba/J45k+d5CeCI/IXYWoA37C nT8gHC/UJFw82EbOR6H+pB76d0YsgC9qtGf99UKoXNGg2sM60DEYZeZOEsey4ZilWHBa z/y+e+aG0fy80/OUN0LptAQaeDBnvGndfuBhFr0qg7ZpSVpO6wHcpw4QPmW3Lx0SDabK nCQfiD3jf0sCpgTOo5Ora4bsEA95UvdvxKRvvOwPkC4GZdXeGZQSWGAgH4cVk3wDfDCg zuBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=2wirKzlL; 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-131957-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131957-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u14-20020a50950e000000b0056e237c99c0si410723eda.433.2024.04.04.11.29.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 11:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131957-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=2wirKzlL; 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-131957-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131957-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 C31971F2258D for ; Thu, 4 Apr 2024 18:29:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CE54130ADE; Thu, 4 Apr 2024 18:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="2wirKzlL" 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 5E13212CD9C; Thu, 4 Apr 2024 18:29:07 +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=1712255349; cv=none; b=R9srwrApNSKihKJo47pv7gwC9ouzWH14bBRgEq/hrm+c5elV36LnmyWVD/MabbQTPl7hiWRALxzk2ij7Sv1QKnFg65ExuZXJKqpjnLagybb285UB/OXcEl1nzkXD+cwY1TLOoQgtP0XdnPuHva87SMHm9Ipf5u9nsbNgVbJYWLg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712255349; c=relaxed/simple; bh=NmU8KFMfNoUMM9NLhO7uk8bPhscbUNMmBYEZDzGYqCA=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=VzCKI0N5X1ogPw4eK5WadrDRIxaDHLZflCtPfC1vEia2lHvmvkxBelTyWIOuu4071KWBiFm1i+zbGVWfmxI7JPYain9D0AeUTyS6FqZ4l/VRTZb/aBYWvi3Y099qeBq30DjQ3YEhZ93+MzQhFBBa3t6sr9ZpzpX69IL7Laj3Kwg= 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=2wirKzlL; 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=1712255345; bh=NmU8KFMfNoUMM9NLhO7uk8bPhscbUNMmBYEZDzGYqCA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=2wirKzlL2FX0E2q3XU0W+0S+XRZK0fL7JC5B3/y0ikWxuSRC2BWz3bBMYaiNJB+qX ppaoLO1WHmCDbQHNzduxpH44j2ZZqXVfdDDZa37l4BjeQuedjR7rwtr2rE3VBcVBTn tONu6WKfKo5GxGQcssYfnwL8Eyvr/XnmitdSgOOKuTg8QocxhkNWtcYCmRiQecWfz4 Pkl+l+PyVN1U0rPTeToNOFyRVCFr4z+NI6DWzW8Zb6lvU/FakrDh9IKpr+HeL+N5HY wR5T5lcdTQ6oGmq0pqRGLHiXFl0Tr2RKBLsOUPXofgL7NIFFr2pWBhFt1mj+GcpAJn gAi9278YX4vHw== 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) server-digest SHA256) (No client certificate requested) (Authenticated sender: nicolas) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 387EA37813DF; Thu, 4 Apr 2024 18:29:03 +0000 (UTC) Message-ID: <1ca5278d8c15b45ebd6f28b9043a98f28b5ae128.camel@collabora.com> Subject: Re: [PATCH] media: mediatek: vcodec: fix the error sizeimage for 10bit bitstream From: Nicolas Dufresne To: Yunfei Dong , =?ISO-8859-1?Q?N=EDcolas?= "F . R . A . Prado" , Sebastian Fricke , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert 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 Date: Thu, 04 Apr 2024 14:28:59 -0400 In-Reply-To: <20240403093018.13168-1-yunfei.dong@mediatek.com> References: <20240403093018.13168-1-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/EXhEEmBR1gL0QJgiVviNyLfGJlZWnPjw6xhhmtHYW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er-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi, Le mercredi 03 avril 2024 =C3=A0 17:30 +0800, Yunfei Dong a =C3=A9crit=C2= =A0: > The sizeimage of each plane are calculated the same way for 8bit and > 10bit bitstream. Need to enlarge the sizeimage with simeimage*5/4 for > 10bit bitstream when try and set fmt. Can we stop adding more layers of custom code and port to v4l2-common helpe= rs please. regards, Nicolas >=20 > Fixes: 9d86be9bda6c ("media: mediatek: vcodec: Add driver to support 10bi= t") > Signed-off-by: Yunfei Dong > --- > .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 47 ++++++++++++++----- > 1 file changed, 34 insertions(+), 13 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..45209894f1fe 100644 > --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c > +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c > @@ -259,6 +259,7 @@ static int vidioc_try_fmt(struct mtk_vcodec_dec_ctx *= ctx, struct v4l2_format *f, > pix_fmt_mp->num_planes =3D 1; > pix_fmt_mp->plane_fmt[0].bytesperline =3D 0; > } else if (f->type =3D=3D V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { > + unsigned int dram_y, dram_c, dram_y_10bit, dram_c_10bit; > int tmp_w, tmp_h; > =20 > /* > @@ -280,22 +281,42 @@ static int vidioc_try_fmt(struct mtk_vcodec_dec_ctx= *ctx, struct v4l2_format *f, > (pix_fmt_mp->height + 64) <=3D frmsize->max_height) > pix_fmt_mp->height +=3D 64; > =20 > - mtk_v4l2_vdec_dbg(0, ctx, > - "before resize wxh=3D%dx%d, after resize wxh=3D%dx%d, sizeimage=3D= %d", > - tmp_w, tmp_h, pix_fmt_mp->width, pix_fmt_mp->height, > - pix_fmt_mp->width * pix_fmt_mp->height); > + dram_y =3D pix_fmt_mp->width * pix_fmt_mp->height; > + dram_c =3D dram_y / 2; > + > + dram_y_10bit =3D dram_y * 5 / 4; > + dram_c_10bit =3D dram_y_10bit / 2; > =20 > 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; > + if (pix_fmt_mp->num_planes =3D=3D 1) { > + if (ctx->is_10bit_bitstream) { > + pix_fmt_mp->plane_fmt[0].bytesperline =3D pix_fmt_mp->width * 5 / 4; > + pix_fmt_mp->plane_fmt[0].sizeimage =3D dram_y_10bit + dram_c_10bit; > + } else { > + pix_fmt_mp->plane_fmt[0].bytesperline =3D pix_fmt_mp->width; > + pix_fmt_mp->plane_fmt[0].sizeimage =3D dram_y + dram_c; > + } > + } else { > + if (ctx->is_10bit_bitstream) { > + pix_fmt_mp->plane_fmt[0].bytesperline =3D pix_fmt_mp->width * 5 / 4; > + pix_fmt_mp->plane_fmt[1].bytesperline =3D pix_fmt_mp->width * 5 / 4; > + > + pix_fmt_mp->plane_fmt[0].sizeimage =3D dram_y_10bit; > + pix_fmt_mp->plane_fmt[1].sizeimage =3D dram_c_10bit; > + } else { > + pix_fmt_mp->plane_fmt[0].bytesperline =3D pix_fmt_mp->width; > + pix_fmt_mp->plane_fmt[1].bytesperline =3D pix_fmt_mp->width; > + > + pix_fmt_mp->plane_fmt[0].sizeimage =3D dram_y; > + pix_fmt_mp->plane_fmt[1].sizeimage =3D dram_c; > + } > } > + > + mtk_v4l2_vdec_dbg(0, ctx, > + "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->plane_fmt[0].sizeimage, > + pix_fmt_mp->plane_fmt[1].sizeimage); > } > =20 > pix_fmt_mp->flags =3D 0;