All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Noralf Trønnes" <noralf@tronnes.org>
To: Gerd Hoffmann <kraxel@redhat.com>, dri-devel@lists.freedesktop.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	Sean Paul <sean@poorly.run>, David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel@ffwll.ch>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 3/6] drm: move tinydrm_xrgb8888_to_rgb565() to drm_fb_helper.c
Date: Thu, 4 Apr 2019 20:42:03 +0200	[thread overview]
Message-ID: <e7a4a6e7-7e31-6172-dee1-7f52a4274588@tronnes.org> (raw)
In-Reply-To: <20190404152430.8263-4-kraxel@redhat.com>



Den 04.04.2019 17.24, skrev Gerd Hoffmann:
> Also rename to drm_fb_xrgb8888_to_rgb565().
> Pure code motion, no functional change.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---


> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index fabeb408dce6..087e49741094 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -3380,3 +3380,48 @@ void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb,
>  	}
>  }
>  EXPORT_SYMBOL(drm_fb_memcpy);
> +
> +/**
> + * drm_fb_xrgb8888_to_rgb565 - Convert XRGB8888 to RGB565 clip buffer
> + * @dst: RGB565 destination buffer
> + * @vaddr: XRGB8888 source buffer
> + * @fb: DRM framebuffer
> + * @clip: Clip rectangle area to copy
> + * @swap: Swap bytes
> + *
> + * Drivers can use this function for RGB565 devices that don't natively
> + * support XRGB8888.
> + */
> +void drm_fb_xrgb8888_to_rgb565(u16 *dst, void *vaddr,
> +			       struct drm_framebuffer *fb,
> +			       struct drm_rect *clip, bool swap)
> +{
> +	size_t len = (clip->x2 - clip->x1) * sizeof(u32);
> +	unsigned int x, y;
> +	u32 *src, *buf;
> +	u16 val16;
> +
> +	buf = kmalloc(len, GFP_KERNEL);

It's not obvious what purpose this buffer serves and there's no help
from the surrounding functions either (tinydrm_swab16() has a comment).

I think we need a comment, something along these lines:

	/*
	 * Write-combined buffers have uncached reads.
	 * Speed up by fetching one line at a time.
	 */

Noralf.

> +	if (!buf)
> +		return;
> +
> +	for (y = clip->y1; y < clip->y2; y++) {
> +		src = vaddr + (y * fb->pitches[0]);
> +		src += clip->x1;
> +		memcpy(buf, src, len);
> +		src = buf;
> +		for (x = clip->x1; x < clip->x2; x++) {
> +			val16 = ((*src & 0x00F80000) >> 8) |
> +				((*src & 0x0000FC00) >> 5) |
> +				((*src & 0x000000F8) >> 3);
> +			src++;
> +			if (swap)
> +				*dst++ = swab16(val16);
> +			else
> +				*dst++ = val16;
> +		}
> +	}
> +
> +	kfree(buf);
> +}
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565);
> diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> index f5c6f35e6161..f4b84b15da75 100644
> --- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> @@ -61,51 +61,6 @@ void tinydrm_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
>  }
>  EXPORT_SYMBOL(tinydrm_swab16);
>  
> -/**
> - * tinydrm_xrgb8888_to_rgb565 - Convert XRGB8888 to RGB565 clip buffer
> - * @dst: RGB565 destination buffer
> - * @vaddr: XRGB8888 source buffer
> - * @fb: DRM framebuffer
> - * @clip: Clip rectangle area to copy
> - * @swap: Swap bytes
> - *
> - * Drivers can use this function for RGB565 devices that don't natively
> - * support XRGB8888.
> - */
> -void tinydrm_xrgb8888_to_rgb565(u16 *dst, void *vaddr,
> -				struct drm_framebuffer *fb,
> -				struct drm_rect *clip, bool swap)
> -{
> -	size_t len = (clip->x2 - clip->x1) * sizeof(u32);
> -	unsigned int x, y;
> -	u32 *src, *buf;
> -	u16 val16;
> -
> -	buf = kmalloc(len, GFP_KERNEL);
> -	if (!buf)
> -		return;
> -
> -	for (y = clip->y1; y < clip->y2; y++) {
> -		src = vaddr + (y * fb->pitches[0]);
> -		src += clip->x1;
> -		memcpy(buf, src, len);
> -		src = buf;
> -		for (x = clip->x1; x < clip->x2; x++) {
> -			val16 = ((*src & 0x00F80000) >> 8) |
> -				((*src & 0x0000FC00) >> 5) |
> -				((*src & 0x000000F8) >> 3);
> -			src++;
> -			if (swap)
> -				*dst++ = swab16(val16);
> -			else
> -				*dst++ = val16;
> -		}
> -	}
> -
> -	kfree(buf);
> -}
> -EXPORT_SYMBOL(tinydrm_xrgb8888_to_rgb565);
> -
>  /**
>   * tinydrm_xrgb8888_to_gray8 - Convert XRGB8888 to grayscale
>   * @dst: 8-bit grayscale destination buffer
> diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c
> index e26fd61360a3..cf8df5fb7494 100644
> --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c
> +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c
> @@ -224,7 +224,7 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,
>  			drm_fb_memcpy(dst, src, fb, clip, false);
>  		break;
>  	case DRM_FORMAT_XRGB8888:
> -		tinydrm_xrgb8888_to_rgb565(dst, src, fb, clip, swap);
> +		drm_fb_xrgb8888_to_rgb565(dst, src, fb, clip, swap);
>  		break;
>  	default:
>  		dev_err_once(fb->dev->dev, "Format is not supported: %s\n",
> 

  parent reply	other threads:[~2019-04-04 18:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04 15:24 [PATCH v2 0/6] drm/cirrus: rewrite and modernize driver Gerd Hoffmann
2019-04-04 15:24 ` [PATCH v2 1/6] drm: move tinydrm_memcpy() to drm_fb_helper.c Gerd Hoffmann
2019-04-04 15:24   ` Gerd Hoffmann
2019-04-04 17:04   ` Sam Ravnborg
2019-04-04 18:37   ` Noralf Trønnes
2019-04-04 15:24 ` [PATCH v2 2/6] drm: add dstclip parameter to drm_fb_memcpy() Gerd Hoffmann
2019-04-04 15:24   ` Gerd Hoffmann
2019-04-04 17:09   ` Sam Ravnborg
2019-04-04 17:09     ` Sam Ravnborg
2019-04-04 15:24 ` [PATCH v2 3/6] drm: move tinydrm_xrgb8888_to_rgb565() to drm_fb_helper.c Gerd Hoffmann
2019-04-04 15:24   ` Gerd Hoffmann
2019-04-04 17:11   ` Sam Ravnborg
2019-04-04 18:42   ` Noralf Trønnes [this message]
2019-04-04 15:24 ` [PATCH v2 4/6] drm: add dstclip parameter to drm_fb_xrgb8888_to_rgb565() Gerd Hoffmann
2019-04-04 15:24   ` Gerd Hoffmann
2019-04-04 17:17   ` Sam Ravnborg
2019-04-04 17:17     ` Sam Ravnborg
2019-04-04 15:24 ` [PATCH v2 5/6] drm: add drm_fb_xrgb8888_to_rgb888() function to drm_fb_helper.c Gerd Hoffmann
2019-04-04 15:24   ` Gerd Hoffmann
2019-04-04 17:16   ` Sam Ravnborg
2019-04-04 15:24 ` [PATCH v2 6/6] drm/cirrus: rewrite and modernize driver Gerd Hoffmann
2019-04-04 15:24 ` Gerd Hoffmann
2019-04-04 15:24   ` Gerd Hoffmann
2019-04-04 17:41   ` Sam Ravnborg
2019-04-04 17:41   ` Sam Ravnborg
2019-04-04 17:41     ` Sam Ravnborg

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=e7a4a6e7-7e31-6172-dee1-7f52a4274588@tronnes.org \
    --to=noralf@tronnes.org \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=sean@poorly.run \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.