public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "andriy.shevchenko@linux.intel.com" <andriy.shevchenko@linux.intel.com>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Aditya Garg <gargaditya08@live.com>,
	"maarten.lankhorst@linux.intel.com"
	<maarten.lankhorst@linux.intel.com>,
	"mripard@kernel.org" <mripard@kernel.org>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"simona@ffwll.ch" <simona@ffwll.ch>,
	Kerem Karabay <kekrby@gmail.com>,
	Atharva Tiwari <evepolonium@gmail.com>,
	Aun-Ali Zaidi <admin@kodeit.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH v4 1/2] drm/format-helper: Add conversion from XRGB8888 to BGR888
Date: Tue, 25 Feb 2025 12:24:48 +0200	[thread overview]
Message-ID: <Z72acJ0MoSOK5_RI@smile.fi.intel.com> (raw)
In-Reply-To: <466c38c3-7f74-46db-8270-bebafacf0007@suse.de>

On Tue, Feb 25, 2025 at 08:37:32AM +0100, Thomas Zimmermann wrote:
> Am 24.02.25 um 15:29 schrieb andriy.shevchenko@linux.intel.com:
> > On Mon, Feb 24, 2025 at 01:38:32PM +0000, Aditya Garg wrote:

...

> > > +static void drm_fb_xrgb8888_to_bgr888_line(void *dbuf, const void *sbuf, unsigned int pixels)
> > Okay the xrgb8888 is the actual pixel format independently on
> > the CPU endianess.
> > 
> > > +{
> > > +	u8 *dbuf8 = dbuf;
> > > +	const __le32 *sbuf32 = sbuf;
> > But here we assume that sbuf is __le32.
> > And I think we may benefit from the __be32 there.
> 
> No, please. XRGB is the logical order. The raw physical byte order for DRM
> formats is always* little endian, hence reversed from the logical one. sbuf
> points to raw memory and is therefore __le32. DRM-format byte order is
> impossible to understand, I know. But that code is correct.

Okay, so it's only about the colour (top-level) layout, the input and output
data is always in little endian?

> *) White lie: there's a DRM format flag signalling physical big endianess.
> That isn't the case here. So nothing here should ever indicate big
> endianess.

But should it indicate the little? To me sounds like neither...

> > > +	unsigned int x;
> > > +	u32 pix;
> > > +
> > > +	for (x = 0; x < pixels; x++) {
> > > +		pix = le32_to_cpu(sbuf32[x]);
> > > +		/* write red-green-blue to output in little endianness */
> > > +		*dbuf8++ = (pix & 0x00ff0000) >> 16;
> > > +		*dbuf8++ = (pix & 0x0000ff00) >> 8;
> > > +		*dbuf8++ = (pix & 0x000000ff) >> 0;
> > 		pix = be32_to_cpu(sbuf[4 * x]) >> 8;
> > 		put_unaligned_le24(pix, &dbuf[3 * x]);
> > 
> > > +	}
> > Or, after all, this __le32 magic might be not needed at all. Wouldn't the below
> > be the equivalent
> > 
> > static void drm_fb_xrgb8888_to_bgr888_line(void *dbuf, const void *sbuf, unsigned int pixels)
> > {
> > 	unsigned int x;
> > 	u32 pix;
> > 
> > 	for (x = 0; x < pixels; x++) {
> > 		/* Read red-green-blue from input in big endianess and... */
> > 		pix = get_unaligned_be24(sbuf + x * 4 + 1);
> > 		/* ...write it to output in little endianness. */
> > 		put_unaligned_le24(pix, dbuf + x * 3);
> > 	}
> > }
> > 
> > The comments can even be dropped as the code quite clear about what's going on.
> > 
> > > +}
> > But it's up to you. I don't know which solution gives better code generation
> > either.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-02-25 10:24 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24 13:37 [PATCH v4 0/2] Touch Bar DRM driver for x86 Macs Aditya Garg
2025-02-24 13:38 ` [PATCH v4 1/2] drm/format-helper: Add conversion from XRGB8888 to BGR888 Aditya Garg
2025-02-24 14:29   ` andriy.shevchenko
2025-02-24 14:54     ` Aditya Garg
2025-02-24 15:00       ` andriy.shevchenko
2025-02-24 15:03         ` Aditya Garg
2025-02-24 15:03         ` andriy.shevchenko
2025-02-25  7:37     ` Thomas Zimmermann
2025-02-25 10:24       ` andriy.shevchenko [this message]
2025-02-24 13:40 ` [PATCH v4 2/2] drm/tiny: add driver for Apple Touch Bars in x86 Macs Aditya Garg
2025-02-24 14:00   ` andriy.shevchenko
2025-02-24 14:32     ` Aditya Garg
2025-02-24 14:57       ` andriy.shevchenko
2025-02-24 15:03         ` Aditya Garg
2025-02-24 15:11           ` andriy.shevchenko
2025-02-24 15:20             ` Aditya Garg
2025-02-24 15:32               ` Aditya Garg
2025-02-24 15:38                 ` andriy.shevchenko
2025-02-24 15:40                   ` Aditya Garg
2025-02-24 15:52                     ` andriy.shevchenko
2025-02-24 15:56                       ` Aditya Garg
2025-02-24 16:14                         ` Aditya Garg
2025-02-24 16:14                         ` andriy.shevchenko
2025-02-24 16:38                           ` Aditya Garg
2025-02-24 15:36               ` andriy.shevchenko
2025-02-24 15:39                 ` Aditya Garg
2025-02-24 15:49                   ` andriy.shevchenko
2025-02-24 15:52                     ` Aditya Garg
2025-02-24 16:12                       ` andriy.shevchenko
2025-02-24 16:58   ` Aditya Garg
2025-02-25  7:56     ` Thomas Zimmermann
2025-02-25  8:02       ` Aditya Garg
2025-02-25  8:46         ` Thomas Zimmermann
2025-02-25  9:04       ` Aditya Garg
2025-02-25  9:07         ` Aditya Garg
2025-02-25  9:35           ` Thomas Zimmermann
2025-02-25  9:37             ` Aditya Garg
2025-02-25 10:01               ` Aditya Garg
2025-02-25  7:52   ` Thomas Zimmermann
2025-02-25  8:00     ` Aditya Garg
2025-02-25  8:48       ` Thomas Zimmermann
2025-02-25 10:28         ` andriy.shevchenko
2025-02-27 16:54   ` kernel test robot
2025-02-27 17:28     ` Aditya Garg
2025-02-28 12:25       ` andriy.shevchenko
2025-02-27 23:22   ` kernel test robot
2025-02-27 23:59   ` kernel test robot

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=Z72acJ0MoSOK5_RI@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=admin@kodeit.net \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=evepolonium@gmail.com \
    --cc=gargaditya08@live.com \
    --cc=kekrby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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