From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 2F8D61C5F28 for ; Thu, 27 Mar 2025 22:35:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743114920; cv=none; b=Lf336j24v65QngfPzuQZl4OxgINY9tCJZlQUsn7pXwvH7mZZ19lGlrERVArlG4YNkwBFyQXVMJkZErsu9kGJD09OG6aF2bmGvW2Vs0q5MZlYNsr3eQaLVkFKmReyNEmweSNAWXY0SXl+wpBcvH/uBjRVtQnDMut93pxonrlhfEI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743114920; c=relaxed/simple; bh=SaJOk6M4y4yQuYGOGvlYpvYsC/4YT1F7z+qnV1nCrQs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LErtiMcJeyr5c5qIxcj3Om3ipws1nY+98uziXNQNb4Yto3DSHc59AuCIKYHJ6RJMkpCB2COB1TXvb6DNfXOz9+aQetFA03qE1nxrrOnaX/DDKvpLb3ssff9fsQM4vAlimWLwik9T5sCfgbr928LRDSE5Le7sWpjHrDO/w3kZwIM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=RSByoPiO; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RSByoPiO" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 77CF9446; Thu, 27 Mar 2025 23:33:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1743114803; bh=SaJOk6M4y4yQuYGOGvlYpvYsC/4YT1F7z+qnV1nCrQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RSByoPiOsIOgZeWaXOPH8jRhYyw712i8uC2SHV03xtZefNxXYg9irW9s70kPYDDbl RV3qkz2EECH8+QysvoGNn6LovnTOZNzwtdlJ4qdgd/2368kb2WJKFjwz7YsYOF1p2e iOe/FUKru50IZUoECNnLSyKXDyDmczuME5UX8YW0= Date: Fri, 28 Mar 2025 00:34:49 +0200 From: Laurent Pinchart To: Tomi Valkeinen Cc: Vishal Sagar , Anatoliy Klymenko , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Michal Simek , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Geert Uytterhoeven , Dmitry Baryshkov , Dmitry Baryshkov Subject: Re: [PATCH v4 02/11] drm/fourcc: Add DRM_FORMAT_XV15/XV20 Message-ID: <20250327223449.GA16629@pendragon.ideasonboard.com> References: <20250326-xilinx-formats-v4-0-322a300c6d72@ideasonboard.com> <20250326-xilinx-formats-v4-2-322a300c6d72@ideasonboard.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 Content-Disposition: inline In-Reply-To: <20250326-xilinx-formats-v4-2-322a300c6d72@ideasonboard.com> Hi Tomi, Thank you for the patch. On Wed, Mar 26, 2025 at 03:22:45PM +0200, Tomi Valkeinen wrote: > Add two new pixel formats: > > DRM_FORMAT_XV15 ("XV15") > DRM_FORMAT_XV20 ("XV20") > > The formats are 2 plane 10 bit per component YCbCr, with the XV15 2x2 > subsampled whereas XV20 is 2x1 subsampled. > > Reviewed-by: Dmitry Baryshkov > Signed-off-by: Tomi Valkeinen > --- > drivers/gpu/drm/drm_fourcc.c | 6 ++++++ > include/uapi/drm/drm_fourcc.h | 8 ++++++++ > 2 files changed, 14 insertions(+) > > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c > index 2f5781f5dcda..e101d1b99aeb 100644 > --- a/drivers/gpu/drm/drm_fourcc.c > +++ b/drivers/gpu/drm/drm_fourcc.c > @@ -346,6 +346,12 @@ const struct drm_format_info *__drm_format_info(u32 format) > { .format = DRM_FORMAT_P030, .depth = 0, .num_planes = 2, > .char_per_block = { 4, 8, 0 }, .block_w = { 3, 3, 0 }, .block_h = { 1, 1, 0 }, > .hsub = 2, .vsub = 2, .is_yuv = true}, > + { .format = DRM_FORMAT_XV15, .depth = 0, .num_planes = 2, > + .char_per_block = { 4, 8, 0 }, .block_w = { 3, 3, 0 }, .block_h = { 1, 1, 0 }, > + .hsub = 2, .vsub = 2, .is_yuv = true }, > + { .format = DRM_FORMAT_XV20, .depth = 0, .num_planes = 2, > + .char_per_block = { 4, 8, 0 }, .block_w = { 3, 3, 0 }, .block_h = { 1, 1, 0 }, > + .hsub = 2, .vsub = 1, .is_yuv = true }, It appears we can never have too much (or enough) documentation, as reading the format info documentation leaves me with unanswered questions. Looking at drm_format_info_min_pitch(): uint64_t drm_format_info_min_pitch(const struct drm_format_info *info, int plane, unsigned int buffer_width) { if (!info || plane < 0 || plane >= info->num_planes) return 0; return DIV_ROUND_UP_ULL((u64)buffer_width * info->char_per_block[plane], drm_format_info_block_width(info, plane) * drm_format_info_block_height(info, plane)); } For the first plane, the function will return `buffer_width * 4 / 3` (rouding up), which I think is right. For the second plane, it will return `buffer_width * 8 / 3`, which I believe is wrong as the format is subsampled by a factor 2 horizontally. It seems that either char_per_block and block_w need to take horizontal subsampling into account (and therefore be 8 and 6 for the second plane), or drm_format_info_min_pitch() should consider .hsub. Or there's something else I'm missing :-) > }; > > unsigned int i; > diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h > index 81202a50dc9e..1247b814bd66 100644 > --- a/include/uapi/drm/drm_fourcc.h > +++ b/include/uapi/drm/drm_fourcc.h > @@ -304,6 +304,14 @@ extern "C" { > #define DRM_FORMAT_RGB565_A8 fourcc_code('R', '5', 'A', '8') > #define DRM_FORMAT_BGR565_A8 fourcc_code('B', '5', 'A', '8') > > +/* > + * 2 plane 10 bit per component YCrCb > + * index 0 = Y plane, [31:0] x:Y2:Y1:Y0 2:10:10:10 little endian > + * index 1 = Cb:Cr plane, [63:0] x:Cr2:Cb2:Cr1:x:Cb1:Cr0:Cb0 2:10:10:10:2:10:10:10 little endian I believe this is right, but I have a hard time validating it, as I think the corresponding figures in UG1085 are incorrect (they show a 8bpp format as far as I can tell). Do I assume correctly that you've tested the formats ? > + */ > +#define DRM_FORMAT_XV15 fourcc_code('X', 'V', '1', '5') /* 2x2 subsampled Cr:Cb plane 2:10:10:10 */ > +#define DRM_FORMAT_XV20 fourcc_code('X', 'V', '2', '0') /* 2x1 subsampled Cr:Cb plane 2:10:10:10 */ > + > /* > * 2 plane YCbCr > * index 0 = Y plane, [7:0] Y -- Regards, Laurent Pinchart