linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Vishal Sagar <vishal.sagar@amd.com>,
	Anatoliy Klymenko <anatoliy.klymenko@amd.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Michal Simek <michal.simek@amd.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Subject: Re: [PATCH v4 02/11] drm/fourcc: Add DRM_FORMAT_XV15/XV20
Date: Fri, 28 Mar 2025 12:27:52 +0200	[thread overview]
Message-ID: <20250328102752.GA2639@pendragon.ideasonboard.com> (raw)
In-Reply-To: <5282b9f9-edef-45fd-8228-16096981a11a@ideasonboard.com>

On Fri, Mar 28, 2025 at 12:05:40PM +0200, Tomi Valkeinen wrote:
> On 28/03/2025 00:34, Laurent Pinchart wrote:
> > 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 <dmitry.baryshkov@linaro.org>
> >> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> >> ---
> >>   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 :-)
> 
> The buffer_width is already divided by the hsub, in 
> drm_format_info_plane_width().

The function documentation doesn't clearly indicate if buffer_width is
the width of the buffer (as in the width of the first plane), or the
width of the requested plane. The variable name implies (for me) that
it's the width of the buffer, not the plane.

I've checked users of the function, and it seems to be a mess. The
following users pass the plane width to the function:

drivers/gpu/drm/drm_framebuffer.c
drivers/gpu/drm/drm_gem_framebuffer_helper.c
drivers/gpu/drm/tests/drm_format_test.c

However, the following users seem to pass the full buffer width:

drivers/gpu/drm/rockchip/rockchip_drm_vop.c
drivers/gpu/drm/tests/drm_format_helper_test.c

> >>   	};
> >>   
> >>   	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 ?
> 
> Yes. kms++'s master branch has support for all the formats in this series.
> 
>   Tomi

-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2025-03-28 10:35 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-26 13:22 [PATCH v4 00/11] drm: Add new pixel formats for Xilinx Zynqmp Tomi Valkeinen
2025-03-26 13:22 ` [PATCH v4 01/11] drm/fourcc: Add warning for bad bpp Tomi Valkeinen
2025-03-26 13:22 ` [PATCH v4 02/11] drm/fourcc: Add DRM_FORMAT_XV15/XV20 Tomi Valkeinen
2025-03-27 22:34   ` Laurent Pinchart
2025-03-28 10:05     ` Tomi Valkeinen
2025-03-28 10:27       ` Laurent Pinchart [this message]
2025-03-26 13:22 ` [PATCH v4 03/11] drm/fourcc: Add DRM_FORMAT_Y8 Tomi Valkeinen
2025-03-26 13:52   ` Geert Uytterhoeven
2025-03-26 13:55     ` Tomi Valkeinen
2025-03-27  9:20       ` Pekka Paalanen
2025-03-27 14:21         ` Tomi Valkeinen
2025-03-27 15:58           ` Pekka Paalanen
2025-03-27 16:35             ` Geert Uytterhoeven
2025-03-31  7:54               ` Pekka Paalanen
2025-03-31  8:21                 ` Laurent Pinchart
2025-03-31 10:53                   ` Pekka Paalanen
2025-03-31 14:54                     ` Laurent Pinchart
2025-04-01  6:49                       ` Pekka Paalanen
2025-04-01 13:27                     ` Pekka Paalanen
2025-04-16  8:59                       ` Tomi Valkeinen
2025-04-17  8:13                         ` Pekka Paalanen
2025-04-21 14:50                           ` Laurent Pinchart
2025-04-22  9:11                             ` Pekka Paalanen
2025-04-22  9:41                               ` Geert Uytterhoeven
2025-04-22 10:01                                 ` Pekka Paalanen
2025-04-22 10:12                                   ` Geert Uytterhoeven
2025-04-22 11:00                                     ` Pekka Paalanen
2025-04-25  8:38                           ` Tomi Valkeinen
2025-04-25 10:18                             ` Pekka Paalanen
2025-03-26 13:22 ` [PATCH v4 04/11] drm/fourcc: Add DRM_FORMAT_Y10_P32 Tomi Valkeinen
2025-03-27 22:53   ` Laurent Pinchart
2025-03-26 13:22 ` [PATCH v4 05/11] drm/fourcc: Add DRM_FORMAT_X403 Tomi Valkeinen
2025-03-27 22:55   ` Laurent Pinchart
2025-03-26 13:22 ` [PATCH v4 06/11] drm/fourcc: Add DRM_FORMAT_XVUY2101010 Tomi Valkeinen
2025-03-27 23:07   ` Laurent Pinchart
2025-03-26 13:22 ` [PATCH v4 07/11] drm: xlnx: zynqmp: Use drm helpers when calculating buffer sizes Tomi Valkeinen
2025-03-26 13:22 ` [PATCH v4 08/11] drm: xlnx: zynqmp: Add support for XV15 & XV20 Tomi Valkeinen
2025-03-27 22:35   ` Laurent Pinchart
2025-03-26 13:22 ` [PATCH v4 09/11] drm: xlnx: zynqmp: Add support for Y8 and Y10_P32 Tomi Valkeinen
2025-03-27 22:52   ` Laurent Pinchart
2025-03-31 11:37     ` Tomi Valkeinen
2025-03-26 13:22 ` [PATCH v4 10/11] drm: xlnx: zynqmp: Add support for X403 Tomi Valkeinen
2025-03-27 22:59   ` Laurent Pinchart
2025-03-26 13:22 ` [PATCH v4 11/11] drm: xlnx: zynqmp: Add support for XVUY2101010 Tomi Valkeinen
2025-03-27 23:06   ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250328102752.GA2639@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=anatoliy.klymenko@amd.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=michal.simek@amd.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tomi.valkeinen@ideasonboard.com \
    --cc=tzimmermann@suse.de \
    --cc=vishal.sagar@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).