dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Thierry Reding <thierry.reding@gmail.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Cc: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org,
	dri-devel@lists.freedesktop.org,
	Jon Hunter <jonathanh@nvidia.com>
Subject: Re: [PATCH 4/6] drm/format-helper: Support the AB24 format
Date: Wed, 7 Sep 2022 09:23:01 +0200	[thread overview]
Message-ID: <d4e76fbc-bb75-4b1a-c345-5dc7670d6a14@suse.de> (raw)
In-Reply-To: <20220905163300.391692-5-thierry.reding@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 3078 bytes --]

Hi

Am 05.09.22 um 18:32 schrieb Thierry Reding:
> From: Thierry Reding <treding@nvidia.com>
> 
> Add a conversion helper for the AB24 format to use in drm_fb_blit().
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>   drivers/gpu/drm/drm_format_helper.c | 35 +++++++++++++++++++++++++++++
>   1 file changed, 35 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
> index 56642816fdff..d564412a816b 100644
> --- a/drivers/gpu/drm/drm_format_helper.c
> +++ b/drivers/gpu/drm/drm_format_helper.c
> @@ -503,6 +503,36 @@ static void drm_fb_rgb888_to_xrgb8888(struct iosys_map *dst, const unsigned int
>   		    drm_fb_rgb888_to_xrgb8888_line);
>   }
>   
> +static void drm_fb_xrgb8888_to_abgr8888_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +{
> +	__le32 *dbuf32 = dbuf;
> +	const __le32 *sbuf32 = sbuf;
> +	unsigned int x;
> +	u32 pix;
> +
> +	for (x = 0; x < pixels; x++) {
> +		pix = le32_to_cpu(sbuf32[x]);
> +		pix = ((pix & 0xff000000) >> 24) << 24 |
> +		      ((pix & 0x00ff0000) >> 16) <<  0 |
> +		      ((pix & 0x0000ff00) >>  8) <<  8 |
> +		      ((pix & 0x000000ff) >>  0) << 16;
> +		*dbuf32++ = cpu_to_le32(pix);
> +	}
> +}

What does the Jetson device do with these alpha bits?

AFAIK the X channel's content is undefined. Shifting the bits into the A 
channel might result in wrong results in the general case. Better just 
set the alpha to 0xff unconditionally.

> +
> +static void drm_fb_xrgb8888_to_abgr8888(struct iosys_map *dst, const unsigned int *dst_pitch,
> +					const struct iosys_map *src,
> +					const struct drm_framebuffer *fb,
> +					const struct drm_rect *clip)
> +{
> +	static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
> +		4,
> +	};
> +
> +	drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
> +		    drm_fb_xrgb8888_to_abgr8888_line);
> +}
> +
>   static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
>   {
>   	__le32 *dbuf32 = dbuf;
> @@ -672,6 +702,11 @@ int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t d
>   			drm_fb_rgb565_to_xrgb8888(dst, dst_pitch, src, fb, clip);
>   			return 0;
>   		}
> +	} else if (dst_format == DRM_FORMAT_ABGR8888) {
> +		if (fb_format == DRM_FORMAT_XRGB8888) {
> +			drm_fb_xrgb8888_to_abgr8888(dst, dst_pitch, src, fb, clip);
> +			return 0;
> +		}

For the other alpha-containing formats, we treat them like non-alpha 
formats (see the top of this function). Maybe just do the same here and 
then implement the conversion as drm_fb_xrgb8888_to_xbgr8888() helpers?

Best regards
Thomas

>   	} else if (dst_format == DRM_FORMAT_XRGB2101010) {
>   		if (fb_format == DRM_FORMAT_XRGB8888) {
>   			drm_fb_xrgb8888_to_xrgb2101010(dst, dst_pitch, src, fb, clip);

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2022-09-07  7:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05 16:32 [PATCH 0/6] drm/simpledrm: Support system memory framebuffers Thierry Reding
2022-09-05 16:32 ` [PATCH 1/6] dt-bindings: display: simple-framebuffer: " Thierry Reding
2022-09-05 16:32 ` [PATCH 2/6] dt-bindings: reserved-memory: Support framebuffer reserved memory Thierry Reding
2022-09-06  2:29   ` Rob Herring
2022-09-06 14:27   ` Rob Herring
2022-09-14 16:05     ` Thierry Reding
2022-09-05 16:32 ` [PATCH 3/6] drm/simpledrm: Add support for system memory framebuffers Thierry Reding
2022-09-24 11:43   ` kernel test robot
2022-09-05 16:32 ` [PATCH 4/6] drm/format-helper: Support the AB24 format Thierry Reding
2022-09-07  7:23   ` Thomas Zimmermann [this message]
2022-09-14 16:09     ` Thierry Reding
2022-09-05 16:32 ` [PATCH 5/6] drm/simpledrm: " Thierry Reding
2022-09-07  7:12   ` Thomas Zimmermann
2022-09-05 16:33 ` [PATCH 6/6] arm64: tegra: Add simple framebuffer on Jetson Xavier NX Thierry Reding

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=d4e76fbc-bb75-4b1a-c345-5dc7670d6a14@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jonathanh@nvidia.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.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