diff mbox series

[v4,1/4] drm/format-helper: Export line conversion helper for drm_panic

Message ID 20231003142508.190246-2-jfalempe@redhat.com (mailing list archive)
State New, archived
Headers show
Series drm/panic: Add a drm panic handler | expand

Commit Message

Jocelyn Falempe Oct. 3, 2023, 2:22 p.m. UTC
drm_panic will need the low-level drm_fb_xxxx_line functions.
Also add drm_fb_r1_to_xrgb8888 to render the fonts.

Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
---
 drivers/gpu/drm/drm_format_helper.c | 88 ++++++++++++++++++++++++++---
 include/drm/drm_format_helper.h     |  9 +++
 2 files changed, 89 insertions(+), 8 deletions(-)

Comments

kernel test robot Oct. 3, 2023, 3:56 p.m. UTC | #1
Hi Jocelyn,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 2dde18cd1d8fac735875f2e4987f11817cc0bc2c]

url:    https://github.com/intel-lab-lkp/linux/commits/Jocelyn-Falempe/drm-format-helper-Export-line-conversion-helper-for-drm_panic/20231003-222642
base:   2dde18cd1d8fac735875f2e4987f11817cc0bc2c
patch link:    https://lore.kernel.org/r/20231003142508.190246-2-jfalempe%40redhat.com
patch subject: [PATCH v4 1/4] drm/format-helper: Export line conversion helper for drm_panic
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231003/202310032302.DqsgLDE3-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231003/202310032302.DqsgLDE3-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310032302.DqsgLDE3-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_format_helper.c:436: warning: expecting prototype for drm_fb_xrgb8888_to_rgb565_line(). Prototype was for drm_fb_xrgb8888_to_xrgb1555_line() instead
>> drivers/gpu/drm/drm_format_helper.c:494: warning: expecting prototype for drm_fb_xrgb8888_to_rgb565_line(). Prototype was for drm_fb_xrgb8888_to_argb1555_line() instead
>> drivers/gpu/drm/drm_format_helper.c:777: warning: expecting prototype for drm_fb_xrgb8888_to_rgb888_line(). Prototype was for drm_fb_xrgb8888_to_xrgb2101010_line() instead
>> drivers/gpu/drm/drm_format_helper.c:836: warning: expecting prototype for drm_fb_xrgb8888_to_rgb888_line(). Prototype was for drm_fb_xrgb8888_to_argb2101010_line() instead


vim +436 drivers/gpu/drm/drm_format_helper.c

7415287e1f3675 Gerd Hoffmann     2019-04-05  428  
ce913131bdeb03 Jocelyn Falempe   2023-10-03  429  /**
ce913131bdeb03 Jocelyn Falempe   2023-10-03  430   * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to XRGB1555
ce913131bdeb03 Jocelyn Falempe   2023-10-03  431   * @dbuf: Pointer to the destination line (in XRGB1555)
ce913131bdeb03 Jocelyn Falempe   2023-10-03  432   * @sbuf: Pointer to the source line (in XRGB8888)
ce913131bdeb03 Jocelyn Falempe   2023-10-03  433   * @pixels: Number of pixels to convert.
ce913131bdeb03 Jocelyn Falempe   2023-10-03  434   */
ce913131bdeb03 Jocelyn Falempe   2023-10-03  435  void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
10cd592e639edc Thomas Zimmermann 2023-01-02 @436  {
10cd592e639edc Thomas Zimmermann 2023-01-02  437  	__le16 *dbuf16 = dbuf;
10cd592e639edc Thomas Zimmermann 2023-01-02  438  	const __le32 *sbuf32 = sbuf;
10cd592e639edc Thomas Zimmermann 2023-01-02  439  	unsigned int x;
10cd592e639edc Thomas Zimmermann 2023-01-02  440  	u16 val16;
10cd592e639edc Thomas Zimmermann 2023-01-02  441  	u32 pix;
10cd592e639edc Thomas Zimmermann 2023-01-02  442  
10cd592e639edc Thomas Zimmermann 2023-01-02  443  	for (x = 0; x < pixels; x++) {
10cd592e639edc Thomas Zimmermann 2023-01-02  444  		pix = le32_to_cpu(sbuf32[x]);
10cd592e639edc Thomas Zimmermann 2023-01-02  445  		val16 = ((pix & 0x00f80000) >> 9) |
10cd592e639edc Thomas Zimmermann 2023-01-02  446  			((pix & 0x0000f800) >> 6) |
10cd592e639edc Thomas Zimmermann 2023-01-02  447  			((pix & 0x000000f8) >> 3);
10cd592e639edc Thomas Zimmermann 2023-01-02  448  		dbuf16[x] = cpu_to_le16(val16);
10cd592e639edc Thomas Zimmermann 2023-01-02  449  	}
10cd592e639edc Thomas Zimmermann 2023-01-02  450  }
ce913131bdeb03 Jocelyn Falempe   2023-10-03  451  EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555_line);
10cd592e639edc Thomas Zimmermann 2023-01-02  452  
10cd592e639edc Thomas Zimmermann 2023-01-02  453  /**
10cd592e639edc Thomas Zimmermann 2023-01-02  454   * drm_fb_xrgb8888_to_xrgb1555 - Convert XRGB8888 to XRGB1555 clip buffer
10cd592e639edc Thomas Zimmermann 2023-01-02  455   * @dst: Array of XRGB1555 destination buffers
10cd592e639edc Thomas Zimmermann 2023-01-02  456   * @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
10cd592e639edc Thomas Zimmermann 2023-01-02  457   *             within @dst; can be NULL if scanlines are stored next to each other.
10cd592e639edc Thomas Zimmermann 2023-01-02  458   * @src: Array of XRGB8888 source buffer
10cd592e639edc Thomas Zimmermann 2023-01-02  459   * @fb: DRM framebuffer
10cd592e639edc Thomas Zimmermann 2023-01-02  460   * @clip: Clip rectangle area to copy
10cd592e639edc Thomas Zimmermann 2023-01-02  461   *
10cd592e639edc Thomas Zimmermann 2023-01-02  462   * This function copies parts of a framebuffer to display memory and converts
10cd592e639edc Thomas Zimmermann 2023-01-02  463   * the color format during the process. The parameters @dst, @dst_pitch and
10cd592e639edc Thomas Zimmermann 2023-01-02  464   * @src refer to arrays. Each array must have at least as many entries as
10cd592e639edc Thomas Zimmermann 2023-01-02  465   * there are planes in @fb's format. Each entry stores the value for the
10cd592e639edc Thomas Zimmermann 2023-01-02  466   * format's respective color plane at the same index.
10cd592e639edc Thomas Zimmermann 2023-01-02  467   *
10cd592e639edc Thomas Zimmermann 2023-01-02  468   * This function does not apply clipping on @dst (i.e. the destination is at the
10cd592e639edc Thomas Zimmermann 2023-01-02  469   * top-left corner).
10cd592e639edc Thomas Zimmermann 2023-01-02  470   *
10cd592e639edc Thomas Zimmermann 2023-01-02  471   * Drivers can use this function for XRGB1555 devices that don't support
10cd592e639edc Thomas Zimmermann 2023-01-02  472   * XRGB8888 natively.
10cd592e639edc Thomas Zimmermann 2023-01-02  473   */
10cd592e639edc Thomas Zimmermann 2023-01-02  474  void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
10cd592e639edc Thomas Zimmermann 2023-01-02  475  				 const struct iosys_map *src, const struct drm_framebuffer *fb,
10cd592e639edc Thomas Zimmermann 2023-01-02  476  				 const struct drm_rect *clip)
10cd592e639edc Thomas Zimmermann 2023-01-02  477  {
10cd592e639edc Thomas Zimmermann 2023-01-02  478  	static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
10cd592e639edc Thomas Zimmermann 2023-01-02  479  		2,
10cd592e639edc Thomas Zimmermann 2023-01-02  480  	};
10cd592e639edc Thomas Zimmermann 2023-01-02  481  
10cd592e639edc Thomas Zimmermann 2023-01-02  482  	drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
10cd592e639edc Thomas Zimmermann 2023-01-02  483  		    drm_fb_xrgb8888_to_xrgb1555_line);
10cd592e639edc Thomas Zimmermann 2023-01-02  484  }
10cd592e639edc Thomas Zimmermann 2023-01-02  485  EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555);
10cd592e639edc Thomas Zimmermann 2023-01-02  486  
ce913131bdeb03 Jocelyn Falempe   2023-10-03  487  /**
ce913131bdeb03 Jocelyn Falempe   2023-10-03  488   * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to ARGB1555
ce913131bdeb03 Jocelyn Falempe   2023-10-03  489   * @dbuf: Pointer to the destination line (in ARGB1555)
ce913131bdeb03 Jocelyn Falempe   2023-10-03  490   * @sbuf: Pointer to the source line (in XRGB8888)
ce913131bdeb03 Jocelyn Falempe   2023-10-03  491   * @pixels: Number of pixels to convert.
ce913131bdeb03 Jocelyn Falempe   2023-10-03  492   */
ce913131bdeb03 Jocelyn Falempe   2023-10-03  493  void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
10cd592e639edc Thomas Zimmermann 2023-01-02 @494  {
10cd592e639edc Thomas Zimmermann 2023-01-02  495  	__le16 *dbuf16 = dbuf;
10cd592e639edc Thomas Zimmermann 2023-01-02  496  	const __le32 *sbuf32 = sbuf;
10cd592e639edc Thomas Zimmermann 2023-01-02  497  	unsigned int x;
10cd592e639edc Thomas Zimmermann 2023-01-02  498  	u16 val16;
10cd592e639edc Thomas Zimmermann 2023-01-02  499  	u32 pix;
10cd592e639edc Thomas Zimmermann 2023-01-02  500  
10cd592e639edc Thomas Zimmermann 2023-01-02  501  	for (x = 0; x < pixels; x++) {
10cd592e639edc Thomas Zimmermann 2023-01-02  502  		pix = le32_to_cpu(sbuf32[x]);
10cd592e639edc Thomas Zimmermann 2023-01-02  503  		val16 = BIT(15) | /* set alpha bit */
10cd592e639edc Thomas Zimmermann 2023-01-02  504  			((pix & 0x00f80000) >> 9) |
10cd592e639edc Thomas Zimmermann 2023-01-02  505  			((pix & 0x0000f800) >> 6) |
10cd592e639edc Thomas Zimmermann 2023-01-02  506  			((pix & 0x000000f8) >> 3);
10cd592e639edc Thomas Zimmermann 2023-01-02  507  		dbuf16[x] = cpu_to_le16(val16);
10cd592e639edc Thomas Zimmermann 2023-01-02  508  	}
10cd592e639edc Thomas Zimmermann 2023-01-02  509  }
ce913131bdeb03 Jocelyn Falempe   2023-10-03  510  EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb1555_line);
10cd592e639edc Thomas Zimmermann 2023-01-02  511
nerdopolis Oct. 4, 2023, 1:45 a.m. UTC | #2
On Tuesday, October 3, 2023 10:22:44 AM EDT Jocelyn Falempe wrote:
> drm_panic will need the low-level drm_fb_xxxx_line functions.
> Also add drm_fb_r1_to_xrgb8888 to render the fonts.
> 
> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
> ---
>  drivers/gpu/drm/drm_format_helper.c | 88 ++++++++++++++++++++++++++---
>  include/drm/drm_format_helper.h     |  9 +++
>  2 files changed, 89 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
> index f93a4efcee90..c238e5d84f1f 100644
> --- a/drivers/gpu/drm/drm_format_helper.c
> +++ b/drivers/gpu/drm/drm_format_helper.c
> @@ -270,7 +270,30 @@ void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
>  
>  	drm_fb_xfrm(dst, dst_pitch, &cpp, src, fb, clip, cached, swab_line);
>  }
> -EXPORT_SYMBOL(drm_fb_swab);
I had to add this line back to get it to build, but once I did, it worked. 
> +
> +/**
> + * drm_fb_r1_to_32bit_line - Convert one line from monochrome to any 32bit pixel format
> + * @dbuf: Pointer to the destination line (in any 32bit format)
> + * @sbuf: Pointer to the source line (in monochrome)
> + * @pixels: Number of pixels to convert.
> + * @fg_color: Foreground color, applied when R1 is 1
> + * @bg_color: Background color, applied when R1 is 0
> + *
> + * Convert monochrome to any format with 32bit pixel.
> + * There is a limitation, as sbuf is a pointer, it can only points to a multiple
> + * of 8 pixels in the source buffer.
> + */
> +void drm_fb_r1_to_32bit_line(void *dbuf, const void *sbuf, unsigned int pixels,
> +				u32 fg_color, u32 bg_color)
> +{
> +	unsigned int x;
> +	const u8 *sbuf8 = sbuf;
> +	u32 *dubf32 = dbuf;
> +
> +	for (x = 0; x < pixels; x++)
> +		dubf32[x] = (sbuf8[x / 8] & (0x80 >> (x % 8))) ? fg_color : bg_color;
> +}
> +EXPORT_SYMBOL(drm_fb_r1_to_32bit_line);
>  
>  static void drm_fb_xrgb8888_to_rgb332_line(void *dbuf, const void *sbuf, unsigned int pixels)
>  {
> @@ -320,7 +343,13 @@ void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pi
>  }
>  EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb332);
>  
> -static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to RGB565
> + * @dbuf: Pointer to the destination line (in RGB565)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels)
>  {
>  	__le16 *dbuf16 = dbuf;
>  	const __le32 *sbuf32 = sbuf;
> @@ -336,6 +365,7 @@ static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigne
>  		dbuf16[x] = cpu_to_le16(val16);
>  	}
>  }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_line);
>  
>  /* TODO: implement this helper as conversion to RGB565|BIG_ENDIAN */
>  static void drm_fb_xrgb8888_to_rgb565_swab_line(void *dbuf, const void *sbuf,
> @@ -396,7 +426,13 @@ void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pi
>  }
>  EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565);
>  
> -static void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to XRGB1555
> + * @dbuf: Pointer to the destination line (in XRGB1555)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
>  {
>  	__le16 *dbuf16 = dbuf;
>  	const __le32 *sbuf32 = sbuf;
> @@ -412,6 +448,7 @@ static void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsig
>  		dbuf16[x] = cpu_to_le16(val16);
>  	}
>  }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555_line);
>  
>  /**
>   * drm_fb_xrgb8888_to_xrgb1555 - Convert XRGB8888 to XRGB1555 clip buffer
> @@ -447,7 +484,13 @@ void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_
>  }
>  EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555);
>  
> -static void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to ARGB1555
> + * @dbuf: Pointer to the destination line (in ARGB1555)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
>  {
>  	__le16 *dbuf16 = dbuf;
>  	const __le32 *sbuf32 = sbuf;
> @@ -464,6 +507,7 @@ static void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsig
>  		dbuf16[x] = cpu_to_le16(val16);
>  	}
>  }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb1555_line);
>  
>  /**
>   * drm_fb_xrgb8888_to_argb1555 - Convert XRGB8888 to ARGB1555 clip buffer
> @@ -499,7 +543,13 @@ void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_
>  }
>  EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb1555);
>  
> -static void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgba5551_line - Convert one line from XRGB8888 to ARGB5551
> + * @dbuf: Pointer to the destination line (in ARGB5551)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsigned int pixels)
>  {
>  	__le16 *dbuf16 = dbuf;
>  	const __le32 *sbuf32 = sbuf;
> @@ -516,6 +566,7 @@ static void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsig
>  		dbuf16[x] = cpu_to_le16(val16);
>  	}
>  }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgba5551_line);
>  
>  /**
>   * drm_fb_xrgb8888_to_rgba5551 - Convert XRGB8888 to RGBA5551 clip buffer
> @@ -551,7 +602,13 @@ void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_
>  }
>  EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgba5551);
>  
> -static void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to RGB888
> + * @dbuf: Pointer to the destination line (in RGB888)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigned int pixels)
>  {
>  	u8 *dbuf8 = dbuf;
>  	const __le32 *sbuf32 = sbuf;
> @@ -566,6 +623,7 @@ static void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigne
>  		*dbuf8++ = (pix & 0x00FF0000) >> 16;
>  	}
>  }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888_line);
>  
>  /**
>   * drm_fb_xrgb8888_to_rgb888 - Convert XRGB8888 to RGB888 clip buffer
> @@ -709,7 +767,13 @@ static void drm_fb_xrgb8888_to_xbgr8888(struct iosys_map *dst, const unsigned in
>  		    drm_fb_xrgb8888_to_xbgr8888_line);
>  }
>  
> -static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to XRGB2101010
> + * @dbuf: Pointer to the destination line (in XRGB2101010)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
>  {
>  	__le32 *dbuf32 = dbuf;
>  	const __le32 *sbuf32 = sbuf;
> @@ -726,6 +790,7 @@ static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, un
>  		*dbuf32++ = cpu_to_le32(pix);
>  	}
>  }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010_line);
>  
>  /**
>   * drm_fb_xrgb8888_to_xrgb2101010 - Convert XRGB8888 to XRGB2101010 clip buffer
> @@ -761,7 +826,13 @@ void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *d
>  }
>  EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010);
>  
> -static void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to ARGB2101010
> + * @dbuf: Pointer to the destination line (in ARGB2101010)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
>  {
>  	__le32 *dbuf32 = dbuf;
>  	const __le32 *sbuf32 = sbuf;
> @@ -779,6 +850,7 @@ static void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, un
>  		*dbuf32++ = cpu_to_le32(pix);
>  	}
>  }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb2101010_line);
>  
>  /**
>   * drm_fb_xrgb8888_to_argb2101010 - Convert XRGB8888 to ARGB2101010 clip buffer
> diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
> index 291deb09475b..31ab699128d5 100644
> --- a/include/drm/drm_format_helper.h
> +++ b/include/drm/drm_format_helper.h
> @@ -24,30 +24,39 @@ void drm_fb_memcpy(struct iosys_map *dst, const unsigned int *dst_pitch,
>  void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
>  		 const struct iosys_map *src, const struct drm_framebuffer *fb,
>  		 const struct drm_rect *clip, bool cached);
> +void drm_fb_r1_to_32bit_line(void *dbuf, const void *sbuf, unsigned int pixels,
> +			     u32 fg_color, u32 bg_color);
>  void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch,
>  			       const struct iosys_map *src, const struct drm_framebuffer *fb,
>  			       const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels);
>  void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pitch,
>  			       const struct iosys_map *src, const struct drm_framebuffer *fb,
>  			       const struct drm_rect *clip, bool swab);
> +void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels);
>  void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
>  				 const struct iosys_map *src, const struct drm_framebuffer *fb,
>  				 const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels);
>  void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
>  				 const struct iosys_map *src, const struct drm_framebuffer *fb,
>  				 const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsigned int pixels);
>  void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_pitch,
>  				 const struct iosys_map *src, const struct drm_framebuffer *fb,
>  				 const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigned int pixels);
>  void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch,
>  			       const struct iosys_map *src, const struct drm_framebuffer *fb,
>  			       const struct drm_rect *clip);
>  void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const unsigned int *dst_pitch,
>  				 const struct iosys_map *src, const struct drm_framebuffer *fb,
>  				 const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels);
>  void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
>  				    const struct iosys_map *src, const struct drm_framebuffer *fb,
>  				    const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels);
>  void drm_fb_xrgb8888_to_argb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
>  				    const struct iosys_map *src, const struct drm_framebuffer *fb,
>  				    const struct drm_rect *clip);
>
Jocelyn Falempe Oct. 5, 2023, 7:37 a.m. UTC | #3
On 04/10/2023 03:45, nerdopolis wrote:
> On Tuesday, October 3, 2023 10:22:44 AM EDT Jocelyn Falempe wrote:
>> drm_panic will need the low-level drm_fb_xxxx_line functions.
>> Also add drm_fb_r1_to_xrgb8888 to render the fonts.
>>
>> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
>> ---
>>   drivers/gpu/drm/drm_format_helper.c | 88 ++++++++++++++++++++++++++---
>>   include/drm/drm_format_helper.h     |  9 +++
>>   2 files changed, 89 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
>> index f93a4efcee90..c238e5d84f1f 100644
>> --- a/drivers/gpu/drm/drm_format_helper.c
>> +++ b/drivers/gpu/drm/drm_format_helper.c
>> @@ -270,7 +270,30 @@ void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
>>   
>>   	drm_fb_xfrm(dst, dst_pitch, &cpp, src, fb, clip, cached, swab_line);
>>   }
>> -EXPORT_SYMBOL(drm_fb_swab);
> I had to add this line back to get it to build, but once I did, it worked.

Thanks, you're right that line shouldn't be removed.

Best regards,
Thomas Zimmermann Oct. 16, 2023, 10:47 a.m. UTC | #4
Hi

Am 03.10.23 um 16:22 schrieb Jocelyn Falempe:
> drm_panic will need the low-level drm_fb_xxxx_line functions.

It seems like premature optimization to not use drm_fb_blit(); 
especially since drm_panic is not performance critical.

> Also add drm_fb_r1_to_xrgb8888 to render the fonts.

I think we should provide a helper function that returns a pointer to 
the correct function for each supported case. Essentially, it would move 
that if-else branching from drm_fb_blit() into its own function.  It's 
not typical DRM style, but cleaner than retyping the if-elses in drm_panic.

Something like:

typedef int (*drm_format_conv_func)(/* args here */);

drm_format_conv_func  drm_format_conv(u32 dst_fourcc, u32 src_fourcc)
{
	// do if-else from drm_fb_blit here
	
	return <correct-format-conv-helper>
}
EXPORT_SYMBOL(drm_format_conv)

That would be callable from anywhere. You can integrate any helpers for 
_R1 here as well.

Best regards
Thomas

> 
> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
> ---
>   drivers/gpu/drm/drm_format_helper.c | 88 ++++++++++++++++++++++++++---
>   include/drm/drm_format_helper.h     |  9 +++
>   2 files changed, 89 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
> index f93a4efcee90..c238e5d84f1f 100644
> --- a/drivers/gpu/drm/drm_format_helper.c
> +++ b/drivers/gpu/drm/drm_format_helper.c
> @@ -270,7 +270,30 @@ void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
>   
>   	drm_fb_xfrm(dst, dst_pitch, &cpp, src, fb, clip, cached, swab_line);
>   }
> -EXPORT_SYMBOL(drm_fb_swab);
> +
> +/**
> + * drm_fb_r1_to_32bit_line - Convert one line from monochrome to any 32bit pixel format
> + * @dbuf: Pointer to the destination line (in any 32bit format)
> + * @sbuf: Pointer to the source line (in monochrome)
> + * @pixels: Number of pixels to convert.
> + * @fg_color: Foreground color, applied when R1 is 1
> + * @bg_color: Background color, applied when R1 is 0
> + *
> + * Convert monochrome to any format with 32bit pixel.
> + * There is a limitation, as sbuf is a pointer, it can only points to a multiple
> + * of 8 pixels in the source buffer.
> + */
> +void drm_fb_r1_to_32bit_line(void *dbuf, const void *sbuf, unsigned int pixels,
> +				u32 fg_color, u32 bg_color)
> +{
> +	unsigned int x;
> +	const u8 *sbuf8 = sbuf;
> +	u32 *dubf32 = dbuf;
> +
> +	for (x = 0; x < pixels; x++)
> +		dubf32[x] = (sbuf8[x / 8] & (0x80 >> (x % 8))) ? fg_color : bg_color;
> +}
> +EXPORT_SYMBOL(drm_fb_r1_to_32bit_line);
>   
>   static void drm_fb_xrgb8888_to_rgb332_line(void *dbuf, const void *sbuf, unsigned int pixels)
>   {
> @@ -320,7 +343,13 @@ void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pi
>   }
>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb332);
>   
> -static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to RGB565
> + * @dbuf: Pointer to the destination line (in RGB565)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels)
>   {
>   	__le16 *dbuf16 = dbuf;
>   	const __le32 *sbuf32 = sbuf;
> @@ -336,6 +365,7 @@ static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigne
>   		dbuf16[x] = cpu_to_le16(val16);
>   	}
>   }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_line);
>   
>   /* TODO: implement this helper as conversion to RGB565|BIG_ENDIAN */
>   static void drm_fb_xrgb8888_to_rgb565_swab_line(void *dbuf, const void *sbuf,
> @@ -396,7 +426,13 @@ void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pi
>   }
>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565);
>   
> -static void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to XRGB1555
> + * @dbuf: Pointer to the destination line (in XRGB1555)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
>   {
>   	__le16 *dbuf16 = dbuf;
>   	const __le32 *sbuf32 = sbuf;
> @@ -412,6 +448,7 @@ static void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsig
>   		dbuf16[x] = cpu_to_le16(val16);
>   	}
>   }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555_line);
>   
>   /**
>    * drm_fb_xrgb8888_to_xrgb1555 - Convert XRGB8888 to XRGB1555 clip buffer
> @@ -447,7 +484,13 @@ void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_
>   }
>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555);
>   
> -static void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to ARGB1555
> + * @dbuf: Pointer to the destination line (in ARGB1555)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
>   {
>   	__le16 *dbuf16 = dbuf;
>   	const __le32 *sbuf32 = sbuf;
> @@ -464,6 +507,7 @@ static void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsig
>   		dbuf16[x] = cpu_to_le16(val16);
>   	}
>   }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb1555_line);
>   
>   /**
>    * drm_fb_xrgb8888_to_argb1555 - Convert XRGB8888 to ARGB1555 clip buffer
> @@ -499,7 +543,13 @@ void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_
>   }
>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb1555);
>   
> -static void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgba5551_line - Convert one line from XRGB8888 to ARGB5551
> + * @dbuf: Pointer to the destination line (in ARGB5551)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsigned int pixels)
>   {
>   	__le16 *dbuf16 = dbuf;
>   	const __le32 *sbuf32 = sbuf;
> @@ -516,6 +566,7 @@ static void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsig
>   		dbuf16[x] = cpu_to_le16(val16);
>   	}
>   }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgba5551_line);
>   
>   /**
>    * drm_fb_xrgb8888_to_rgba5551 - Convert XRGB8888 to RGBA5551 clip buffer
> @@ -551,7 +602,13 @@ void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_
>   }
>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgba5551);
>   
> -static void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to RGB888
> + * @dbuf: Pointer to the destination line (in RGB888)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigned int pixels)
>   {
>   	u8 *dbuf8 = dbuf;
>   	const __le32 *sbuf32 = sbuf;
> @@ -566,6 +623,7 @@ static void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigne
>   		*dbuf8++ = (pix & 0x00FF0000) >> 16;
>   	}
>   }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888_line);
>   
>   /**
>    * drm_fb_xrgb8888_to_rgb888 - Convert XRGB8888 to RGB888 clip buffer
> @@ -709,7 +767,13 @@ static void drm_fb_xrgb8888_to_xbgr8888(struct iosys_map *dst, const unsigned in
>   		    drm_fb_xrgb8888_to_xbgr8888_line);
>   }
>   
> -static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to XRGB2101010
> + * @dbuf: Pointer to the destination line (in XRGB2101010)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
>   {
>   	__le32 *dbuf32 = dbuf;
>   	const __le32 *sbuf32 = sbuf;
> @@ -726,6 +790,7 @@ static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, un
>   		*dbuf32++ = cpu_to_le32(pix);
>   	}
>   }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010_line);
>   
>   /**
>    * drm_fb_xrgb8888_to_xrgb2101010 - Convert XRGB8888 to XRGB2101010 clip buffer
> @@ -761,7 +826,13 @@ void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *d
>   }
>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010);
>   
> -static void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
> +/**
> + * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to ARGB2101010
> + * @dbuf: Pointer to the destination line (in ARGB2101010)
> + * @sbuf: Pointer to the source line (in XRGB8888)
> + * @pixels: Number of pixels to convert.
> + */
> +void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
>   {
>   	__le32 *dbuf32 = dbuf;
>   	const __le32 *sbuf32 = sbuf;
> @@ -779,6 +850,7 @@ static void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, un
>   		*dbuf32++ = cpu_to_le32(pix);
>   	}
>   }
> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb2101010_line);
>   
>   /**
>    * drm_fb_xrgb8888_to_argb2101010 - Convert XRGB8888 to ARGB2101010 clip buffer
> diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
> index 291deb09475b..31ab699128d5 100644
> --- a/include/drm/drm_format_helper.h
> +++ b/include/drm/drm_format_helper.h
> @@ -24,30 +24,39 @@ void drm_fb_memcpy(struct iosys_map *dst, const unsigned int *dst_pitch,
>   void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
>   		 const struct iosys_map *src, const struct drm_framebuffer *fb,
>   		 const struct drm_rect *clip, bool cached);
> +void drm_fb_r1_to_32bit_line(void *dbuf, const void *sbuf, unsigned int pixels,
> +			     u32 fg_color, u32 bg_color);
>   void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch,
>   			       const struct iosys_map *src, const struct drm_framebuffer *fb,
>   			       const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels);
>   void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pitch,
>   			       const struct iosys_map *src, const struct drm_framebuffer *fb,
>   			       const struct drm_rect *clip, bool swab);
> +void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels);
>   void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
>   				 const struct iosys_map *src, const struct drm_framebuffer *fb,
>   				 const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels);
>   void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
>   				 const struct iosys_map *src, const struct drm_framebuffer *fb,
>   				 const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsigned int pixels);
>   void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_pitch,
>   				 const struct iosys_map *src, const struct drm_framebuffer *fb,
>   				 const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigned int pixels);
>   void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch,
>   			       const struct iosys_map *src, const struct drm_framebuffer *fb,
>   			       const struct drm_rect *clip);
>   void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const unsigned int *dst_pitch,
>   				 const struct iosys_map *src, const struct drm_framebuffer *fb,
>   				 const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels);
>   void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
>   				    const struct iosys_map *src, const struct drm_framebuffer *fb,
>   				    const struct drm_rect *clip);
> +void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels);
>   void drm_fb_xrgb8888_to_argb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
>   				    const struct iosys_map *src, const struct drm_framebuffer *fb,
>   				    const struct drm_rect *clip);
Thomas Zimmermann Oct. 16, 2023, 10:50 a.m. UTC | #5
Hi

Am 16.10.23 um 12:47 schrieb Thomas Zimmermann:
> Hi
> 
> Am 03.10.23 um 16:22 schrieb Jocelyn Falempe:
>> drm_panic will need the low-level drm_fb_xxxx_line functions.
> 
> It seems like premature optimization to not use drm_fb_blit(); 
> especially since drm_panic is not performance critical.

We should especially not export any _line fnctions. Those are callbacks 
for drm_fb_xfrm(). They are artifacts of the implementation.

Best regards
Thomas

> 
>> Also add drm_fb_r1_to_xrgb8888 to render the fonts.
> 
> I think we should provide a helper function that returns a pointer to 
> the correct function for each supported case. Essentially, it would move 
> that if-else branching from drm_fb_blit() into its own function.  It's 
> not typical DRM style, but cleaner than retyping the if-elses in drm_panic.
> 
> Something like:
> 
> typedef int (*drm_format_conv_func)(/* args here */);
> 
> drm_format_conv_func  drm_format_conv(u32 dst_fourcc, u32 src_fourcc)
> {
>      // do if-else from drm_fb_blit here
> 
>      return <correct-format-conv-helper>
> }
> EXPORT_SYMBOL(drm_format_conv)
> 
> That would be callable from anywhere. You can integrate any helpers for 
> _R1 here as well.
> 
> Best regards
> Thomas
> 
>>
>> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
>> ---
>>   drivers/gpu/drm/drm_format_helper.c | 88 ++++++++++++++++++++++++++---
>>   include/drm/drm_format_helper.h     |  9 +++
>>   2 files changed, 89 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_format_helper.c 
>> b/drivers/gpu/drm/drm_format_helper.c
>> index f93a4efcee90..c238e5d84f1f 100644
>> --- a/drivers/gpu/drm/drm_format_helper.c
>> +++ b/drivers/gpu/drm/drm_format_helper.c
>> @@ -270,7 +270,30 @@ void drm_fb_swab(struct iosys_map *dst, const 
>> unsigned int *dst_pitch,
>>       drm_fb_xfrm(dst, dst_pitch, &cpp, src, fb, clip, cached, 
>> swab_line);
>>   }
>> -EXPORT_SYMBOL(drm_fb_swab);
>> +
>> +/**
>> + * drm_fb_r1_to_32bit_line - Convert one line from monochrome to any 
>> 32bit pixel format
>> + * @dbuf: Pointer to the destination line (in any 32bit format)
>> + * @sbuf: Pointer to the source line (in monochrome)
>> + * @pixels: Number of pixels to convert.
>> + * @fg_color: Foreground color, applied when R1 is 1
>> + * @bg_color: Background color, applied when R1 is 0
>> + *
>> + * Convert monochrome to any format with 32bit pixel.
>> + * There is a limitation, as sbuf is a pointer, it can only points to 
>> a multiple
>> + * of 8 pixels in the source buffer.
>> + */
>> +void drm_fb_r1_to_32bit_line(void *dbuf, const void *sbuf, unsigned 
>> int pixels,
>> +                u32 fg_color, u32 bg_color)
>> +{
>> +    unsigned int x;
>> +    const u8 *sbuf8 = sbuf;
>> +    u32 *dubf32 = dbuf;
>> +
>> +    for (x = 0; x < pixels; x++)
>> +        dubf32[x] = (sbuf8[x / 8] & (0x80 >> (x % 8))) ? fg_color : 
>> bg_color;
>> +}
>> +EXPORT_SYMBOL(drm_fb_r1_to_32bit_line);
>>   static void drm_fb_xrgb8888_to_rgb332_line(void *dbuf, const void 
>> *sbuf, unsigned int pixels)
>>   {
>> @@ -320,7 +343,13 @@ void drm_fb_xrgb8888_to_rgb332(struct iosys_map 
>> *dst, const unsigned int *dst_pi
>>   }
>>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb332);
>> -static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void 
>> *sbuf, unsigned int pixels)
>> +/**
>> + * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to 
>> RGB565
>> + * @dbuf: Pointer to the destination line (in RGB565)
>> + * @sbuf: Pointer to the source line (in XRGB8888)
>> + * @pixels: Number of pixels to convert.
>> + */
>> +void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, 
>> unsigned int pixels)
>>   {
>>       __le16 *dbuf16 = dbuf;
>>       const __le32 *sbuf32 = sbuf;
>> @@ -336,6 +365,7 @@ static void drm_fb_xrgb8888_to_rgb565_line(void 
>> *dbuf, const void *sbuf, unsigne
>>           dbuf16[x] = cpu_to_le16(val16);
>>       }
>>   }
>> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_line);
>>   /* TODO: implement this helper as conversion to RGB565|BIG_ENDIAN */
>>   static void drm_fb_xrgb8888_to_rgb565_swab_line(void *dbuf, const 
>> void *sbuf,
>> @@ -396,7 +426,13 @@ void drm_fb_xrgb8888_to_rgb565(struct iosys_map 
>> *dst, const unsigned int *dst_pi
>>   }
>>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565);
>> -static void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void 
>> *sbuf, unsigned int pixels)
>> +/**
>> + * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to 
>> XRGB1555
>> + * @dbuf: Pointer to the destination line (in XRGB1555)
>> + * @sbuf: Pointer to the source line (in XRGB8888)
>> + * @pixels: Number of pixels to convert.
>> + */
>> +void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, 
>> unsigned int pixels)
>>   {
>>       __le16 *dbuf16 = dbuf;
>>       const __le32 *sbuf32 = sbuf;
>> @@ -412,6 +448,7 @@ static void drm_fb_xrgb8888_to_xrgb1555_line(void 
>> *dbuf, const void *sbuf, unsig
>>           dbuf16[x] = cpu_to_le16(val16);
>>       }
>>   }
>> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555_line);
>>   /**
>>    * drm_fb_xrgb8888_to_xrgb1555 - Convert XRGB8888 to XRGB1555 clip 
>> buffer
>> @@ -447,7 +484,13 @@ void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map 
>> *dst, const unsigned int *dst_
>>   }
>>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555);
>> -static void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void 
>> *sbuf, unsigned int pixels)
>> +/**
>> + * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to 
>> ARGB1555
>> + * @dbuf: Pointer to the destination line (in ARGB1555)
>> + * @sbuf: Pointer to the source line (in XRGB8888)
>> + * @pixels: Number of pixels to convert.
>> + */
>> +void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, 
>> unsigned int pixels)
>>   {
>>       __le16 *dbuf16 = dbuf;
>>       const __le32 *sbuf32 = sbuf;
>> @@ -464,6 +507,7 @@ static void drm_fb_xrgb8888_to_argb1555_line(void 
>> *dbuf, const void *sbuf, unsig
>>           dbuf16[x] = cpu_to_le16(val16);
>>       }
>>   }
>> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb1555_line);
>>   /**
>>    * drm_fb_xrgb8888_to_argb1555 - Convert XRGB8888 to ARGB1555 clip 
>> buffer
>> @@ -499,7 +543,13 @@ void drm_fb_xrgb8888_to_argb1555(struct iosys_map 
>> *dst, const unsigned int *dst_
>>   }
>>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb1555);
>> -static void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void 
>> *sbuf, unsigned int pixels)
>> +/**
>> + * drm_fb_xrgb8888_to_rgba5551_line - Convert one line from XRGB8888 
>> to ARGB5551
>> + * @dbuf: Pointer to the destination line (in ARGB5551)
>> + * @sbuf: Pointer to the source line (in XRGB8888)
>> + * @pixels: Number of pixels to convert.
>> + */
>> +void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, 
>> unsigned int pixels)
>>   {
>>       __le16 *dbuf16 = dbuf;
>>       const __le32 *sbuf32 = sbuf;
>> @@ -516,6 +566,7 @@ static void drm_fb_xrgb8888_to_rgba5551_line(void 
>> *dbuf, const void *sbuf, unsig
>>           dbuf16[x] = cpu_to_le16(val16);
>>       }
>>   }
>> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgba5551_line);
>>   /**
>>    * drm_fb_xrgb8888_to_rgba5551 - Convert XRGB8888 to RGBA5551 clip 
>> buffer
>> @@ -551,7 +602,13 @@ void drm_fb_xrgb8888_to_rgba5551(struct iosys_map 
>> *dst, const unsigned int *dst_
>>   }
>>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgba5551);
>> -static void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void 
>> *sbuf, unsigned int pixels)
>> +/**
>> + * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to 
>> RGB888
>> + * @dbuf: Pointer to the destination line (in RGB888)
>> + * @sbuf: Pointer to the source line (in XRGB8888)
>> + * @pixels: Number of pixels to convert.
>> + */
>> +void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, 
>> unsigned int pixels)
>>   {
>>       u8 *dbuf8 = dbuf;
>>       const __le32 *sbuf32 = sbuf;
>> @@ -566,6 +623,7 @@ static void drm_fb_xrgb8888_to_rgb888_line(void 
>> *dbuf, const void *sbuf, unsigne
>>           *dbuf8++ = (pix & 0x00FF0000) >> 16;
>>       }
>>   }
>> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888_line);
>>   /**
>>    * drm_fb_xrgb8888_to_rgb888 - Convert XRGB8888 to RGB888 clip buffer
>> @@ -709,7 +767,13 @@ static void drm_fb_xrgb8888_to_xbgr8888(struct 
>> iosys_map *dst, const unsigned in
>>               drm_fb_xrgb8888_to_xbgr8888_line);
>>   }
>> -static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const 
>> void *sbuf, unsigned int pixels)
>> +/**
>> + * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to 
>> XRGB2101010
>> + * @dbuf: Pointer to the destination line (in XRGB2101010)
>> + * @sbuf: Pointer to the source line (in XRGB8888)
>> + * @pixels: Number of pixels to convert.
>> + */
>> +void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void 
>> *sbuf, unsigned int pixels)
>>   {
>>       __le32 *dbuf32 = dbuf;
>>       const __le32 *sbuf32 = sbuf;
>> @@ -726,6 +790,7 @@ static void 
>> drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, un
>>           *dbuf32++ = cpu_to_le32(pix);
>>       }
>>   }
>> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010_line);
>>   /**
>>    * drm_fb_xrgb8888_to_xrgb2101010 - Convert XRGB8888 to XRGB2101010 
>> clip buffer
>> @@ -761,7 +826,13 @@ void drm_fb_xrgb8888_to_xrgb2101010(struct 
>> iosys_map *dst, const unsigned int *d
>>   }
>>   EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010);
>> -static void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const 
>> void *sbuf, unsigned int pixels)
>> +/**
>> + * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to 
>> ARGB2101010
>> + * @dbuf: Pointer to the destination line (in ARGB2101010)
>> + * @sbuf: Pointer to the source line (in XRGB8888)
>> + * @pixels: Number of pixels to convert.
>> + */
>> +void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void 
>> *sbuf, unsigned int pixels)
>>   {
>>       __le32 *dbuf32 = dbuf;
>>       const __le32 *sbuf32 = sbuf;
>> @@ -779,6 +850,7 @@ static void 
>> drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, un
>>           *dbuf32++ = cpu_to_le32(pix);
>>       }
>>   }
>> +EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb2101010_line);
>>   /**
>>    * drm_fb_xrgb8888_to_argb2101010 - Convert XRGB8888 to ARGB2101010 
>> clip buffer
>> diff --git a/include/drm/drm_format_helper.h 
>> b/include/drm/drm_format_helper.h
>> index 291deb09475b..31ab699128d5 100644
>> --- a/include/drm/drm_format_helper.h
>> +++ b/include/drm/drm_format_helper.h
>> @@ -24,30 +24,39 @@ void drm_fb_memcpy(struct iosys_map *dst, const 
>> unsigned int *dst_pitch,
>>   void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
>>            const struct iosys_map *src, const struct drm_framebuffer *fb,
>>            const struct drm_rect *clip, bool cached);
>> +void drm_fb_r1_to_32bit_line(void *dbuf, const void *sbuf, unsigned 
>> int pixels,
>> +                 u32 fg_color, u32 bg_color);
>>   void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned 
>> int *dst_pitch,
>>                      const struct iosys_map *src, const struct 
>> drm_framebuffer *fb,
>>                      const struct drm_rect *clip);
>> +void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, 
>> unsigned int pixels);
>>   void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned 
>> int *dst_pitch,
>>                      const struct iosys_map *src, const struct 
>> drm_framebuffer *fb,
>>                      const struct drm_rect *clip, bool swab);
>> +void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, 
>> unsigned int pixels);
>>   void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const 
>> unsigned int *dst_pitch,
>>                    const struct iosys_map *src, const struct 
>> drm_framebuffer *fb,
>>                    const struct drm_rect *clip);
>> +void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, 
>> unsigned int pixels);
>>   void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const 
>> unsigned int *dst_pitch,
>>                    const struct iosys_map *src, const struct 
>> drm_framebuffer *fb,
>>                    const struct drm_rect *clip);
>> +void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, 
>> unsigned int pixels);
>>   void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const 
>> unsigned int *dst_pitch,
>>                    const struct iosys_map *src, const struct 
>> drm_framebuffer *fb,
>>                    const struct drm_rect *clip);
>> +void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, 
>> unsigned int pixels);
>>   void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned 
>> int *dst_pitch,
>>                      const struct iosys_map *src, const struct 
>> drm_framebuffer *fb,
>>                      const struct drm_rect *clip);
>>   void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const 
>> unsigned int *dst_pitch,
>>                    const struct iosys_map *src, const struct 
>> drm_framebuffer *fb,
>>                    const struct drm_rect *clip);
>> +void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void 
>> *sbuf, unsigned int pixels);
>>   void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const 
>> unsigned int *dst_pitch,
>>                       const struct iosys_map *src, const struct 
>> drm_framebuffer *fb,
>>                       const struct drm_rect *clip);
>> +void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void 
>> *sbuf, unsigned int pixels);
>>   void drm_fb_xrgb8888_to_argb2101010(struct iosys_map *dst, const 
>> unsigned int *dst_pitch,
>>                       const struct iosys_map *src, const struct 
>> drm_framebuffer *fb,
>>                       const struct drm_rect *clip);
>
Jocelyn Falempe Oct. 16, 2023, 4:22 p.m. UTC | #6
On 16/10/2023 12:47, Thomas Zimmermann wrote:
> Hi
> 
> Am 03.10.23 um 16:22 schrieb Jocelyn Falempe:
>> drm_panic will need the low-level drm_fb_xxxx_line functions.
> 
> It seems like premature optimization to not use drm_fb_blit(); 
> especially since drm_panic is not performance critical.
> 
>> Also add drm_fb_r1_to_xrgb8888 to render the fonts.
> 
> I think we should provide a helper function that returns a pointer to 
> the correct function for each supported case. Essentially, it would move 
> that if-else branching from drm_fb_blit() into its own function.  It's 
> not typical DRM style, but cleaner than retyping the if-elses in drm_panic.
> 
> Something like:
> 
> typedef int (*drm_format_conv_func)(/* args here */);
> 
> drm_format_conv_func  drm_format_conv(u32 dst_fourcc, u32 src_fourcc)
> {
>      // do if-else from drm_fb_blit here
> 
>      return <correct-format-conv-helper>
> }
> EXPORT_SYMBOL(drm_format_conv)
> 
> That would be callable from anywhere. You can integrate any helpers for 
> _R1 here as well.

Regarding the color conversion approach, I think we don't need to 
convert the whole buffer, like drm_fb_blit() or the xxxx_line() do. Just 
converting the fg_color and bg_color is enough, and then only the pixel 
size matters, when converting from R1.

So instead of having plenty of conversion functions, I will only need
R1_to_8bit(), R1_to_16bit(), R1_to_24bit() and R1_to_32bit()

I can encapsulate this in a drm_blit_from_r1(), that will also take the 
fg_color and bg_color as parameter.

If you agree with that, I will do it for the v5.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index f93a4efcee90..c238e5d84f1f 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -270,7 +270,30 @@  void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
 
 	drm_fb_xfrm(dst, dst_pitch, &cpp, src, fb, clip, cached, swab_line);
 }
-EXPORT_SYMBOL(drm_fb_swab);
+
+/**
+ * drm_fb_r1_to_32bit_line - Convert one line from monochrome to any 32bit pixel format
+ * @dbuf: Pointer to the destination line (in any 32bit format)
+ * @sbuf: Pointer to the source line (in monochrome)
+ * @pixels: Number of pixels to convert.
+ * @fg_color: Foreground color, applied when R1 is 1
+ * @bg_color: Background color, applied when R1 is 0
+ *
+ * Convert monochrome to any format with 32bit pixel.
+ * There is a limitation, as sbuf is a pointer, it can only points to a multiple
+ * of 8 pixels in the source buffer.
+ */
+void drm_fb_r1_to_32bit_line(void *dbuf, const void *sbuf, unsigned int pixels,
+				u32 fg_color, u32 bg_color)
+{
+	unsigned int x;
+	const u8 *sbuf8 = sbuf;
+	u32 *dubf32 = dbuf;
+
+	for (x = 0; x < pixels; x++)
+		dubf32[x] = (sbuf8[x / 8] & (0x80 >> (x % 8))) ? fg_color : bg_color;
+}
+EXPORT_SYMBOL(drm_fb_r1_to_32bit_line);
 
 static void drm_fb_xrgb8888_to_rgb332_line(void *dbuf, const void *sbuf, unsigned int pixels)
 {
@@ -320,7 +343,13 @@  void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pi
 }
 EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb332);
 
-static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels)
+/**
+ * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to RGB565
+ * @dbuf: Pointer to the destination line (in RGB565)
+ * @sbuf: Pointer to the source line (in XRGB8888)
+ * @pixels: Number of pixels to convert.
+ */
+void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels)
 {
 	__le16 *dbuf16 = dbuf;
 	const __le32 *sbuf32 = sbuf;
@@ -336,6 +365,7 @@  static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigne
 		dbuf16[x] = cpu_to_le16(val16);
 	}
 }
+EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_line);
 
 /* TODO: implement this helper as conversion to RGB565|BIG_ENDIAN */
 static void drm_fb_xrgb8888_to_rgb565_swab_line(void *dbuf, const void *sbuf,
@@ -396,7 +426,13 @@  void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pi
 }
 EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565);
 
-static void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
+/**
+ * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to XRGB1555
+ * @dbuf: Pointer to the destination line (in XRGB1555)
+ * @sbuf: Pointer to the source line (in XRGB8888)
+ * @pixels: Number of pixels to convert.
+ */
+void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
 {
 	__le16 *dbuf16 = dbuf;
 	const __le32 *sbuf32 = sbuf;
@@ -412,6 +448,7 @@  static void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsig
 		dbuf16[x] = cpu_to_le16(val16);
 	}
 }
+EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555_line);
 
 /**
  * drm_fb_xrgb8888_to_xrgb1555 - Convert XRGB8888 to XRGB1555 clip buffer
@@ -447,7 +484,13 @@  void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_
 }
 EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555);
 
-static void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
+/**
+ * drm_fb_xrgb8888_to_rgb565_line - Convert one line from XRGB8888 to ARGB1555
+ * @dbuf: Pointer to the destination line (in ARGB1555)
+ * @sbuf: Pointer to the source line (in XRGB8888)
+ * @pixels: Number of pixels to convert.
+ */
+void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
 {
 	__le16 *dbuf16 = dbuf;
 	const __le32 *sbuf32 = sbuf;
@@ -464,6 +507,7 @@  static void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsig
 		dbuf16[x] = cpu_to_le16(val16);
 	}
 }
+EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb1555_line);
 
 /**
  * drm_fb_xrgb8888_to_argb1555 - Convert XRGB8888 to ARGB1555 clip buffer
@@ -499,7 +543,13 @@  void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_
 }
 EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb1555);
 
-static void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsigned int pixels)
+/**
+ * drm_fb_xrgb8888_to_rgba5551_line - Convert one line from XRGB8888 to ARGB5551
+ * @dbuf: Pointer to the destination line (in ARGB5551)
+ * @sbuf: Pointer to the source line (in XRGB8888)
+ * @pixels: Number of pixels to convert.
+ */
+void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsigned int pixels)
 {
 	__le16 *dbuf16 = dbuf;
 	const __le32 *sbuf32 = sbuf;
@@ -516,6 +566,7 @@  static void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsig
 		dbuf16[x] = cpu_to_le16(val16);
 	}
 }
+EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgba5551_line);
 
 /**
  * drm_fb_xrgb8888_to_rgba5551 - Convert XRGB8888 to RGBA5551 clip buffer
@@ -551,7 +602,13 @@  void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_
 }
 EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgba5551);
 
-static void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigned int pixels)
+/**
+ * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to RGB888
+ * @dbuf: Pointer to the destination line (in RGB888)
+ * @sbuf: Pointer to the source line (in XRGB8888)
+ * @pixels: Number of pixels to convert.
+ */
+void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigned int pixels)
 {
 	u8 *dbuf8 = dbuf;
 	const __le32 *sbuf32 = sbuf;
@@ -566,6 +623,7 @@  static void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigne
 		*dbuf8++ = (pix & 0x00FF0000) >> 16;
 	}
 }
+EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888_line);
 
 /**
  * drm_fb_xrgb8888_to_rgb888 - Convert XRGB8888 to RGB888 clip buffer
@@ -709,7 +767,13 @@  static void drm_fb_xrgb8888_to_xbgr8888(struct iosys_map *dst, const unsigned in
 		    drm_fb_xrgb8888_to_xbgr8888_line);
 }
 
-static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
+/**
+ * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to XRGB2101010
+ * @dbuf: Pointer to the destination line (in XRGB2101010)
+ * @sbuf: Pointer to the source line (in XRGB8888)
+ * @pixels: Number of pixels to convert.
+ */
+void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
 {
 	__le32 *dbuf32 = dbuf;
 	const __le32 *sbuf32 = sbuf;
@@ -726,6 +790,7 @@  static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, un
 		*dbuf32++ = cpu_to_le32(pix);
 	}
 }
+EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010_line);
 
 /**
  * drm_fb_xrgb8888_to_xrgb2101010 - Convert XRGB8888 to XRGB2101010 clip buffer
@@ -761,7 +826,13 @@  void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *d
 }
 EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010);
 
-static void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
+/**
+ * drm_fb_xrgb8888_to_rgb888_line - Convert one line from XRGB8888 to ARGB2101010
+ * @dbuf: Pointer to the destination line (in ARGB2101010)
+ * @sbuf: Pointer to the source line (in XRGB8888)
+ * @pixels: Number of pixels to convert.
+ */
+void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
 {
 	__le32 *dbuf32 = dbuf;
 	const __le32 *sbuf32 = sbuf;
@@ -779,6 +850,7 @@  static void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, un
 		*dbuf32++ = cpu_to_le32(pix);
 	}
 }
+EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb2101010_line);
 
 /**
  * drm_fb_xrgb8888_to_argb2101010 - Convert XRGB8888 to ARGB2101010 clip buffer
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
index 291deb09475b..31ab699128d5 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -24,30 +24,39 @@  void drm_fb_memcpy(struct iosys_map *dst, const unsigned int *dst_pitch,
 void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
 		 const struct iosys_map *src, const struct drm_framebuffer *fb,
 		 const struct drm_rect *clip, bool cached);
+void drm_fb_r1_to_32bit_line(void *dbuf, const void *sbuf, unsigned int pixels,
+			     u32 fg_color, u32 bg_color);
 void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch,
 			       const struct iosys_map *src, const struct drm_framebuffer *fb,
 			       const struct drm_rect *clip);
+void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels);
 void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pitch,
 			       const struct iosys_map *src, const struct drm_framebuffer *fb,
 			       const struct drm_rect *clip, bool swab);
+void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels);
 void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
 				 const struct iosys_map *src, const struct drm_framebuffer *fb,
 				 const struct drm_rect *clip);
+void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels);
 void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
 				 const struct iosys_map *src, const struct drm_framebuffer *fb,
 				 const struct drm_rect *clip);
+void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsigned int pixels);
 void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_pitch,
 				 const struct iosys_map *src, const struct drm_framebuffer *fb,
 				 const struct drm_rect *clip);
+void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigned int pixels);
 void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch,
 			       const struct iosys_map *src, const struct drm_framebuffer *fb,
 			       const struct drm_rect *clip);
 void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const unsigned int *dst_pitch,
 				 const struct iosys_map *src, const struct drm_framebuffer *fb,
 				 const struct drm_rect *clip);
+void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels);
 void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
 				    const struct iosys_map *src, const struct drm_framebuffer *fb,
 				    const struct drm_rect *clip);
+void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels);
 void drm_fb_xrgb8888_to_argb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
 				    const struct iosys_map *src, const struct drm_framebuffer *fb,
 				    const struct drm_rect *clip);