@@ -559,18 +559,6 @@ static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigne
559559 drm_fb_xfrm_line_32to16 (dbuf , sbuf , pixels , drm_pixel_xrgb8888_to_rgb565 );
560560}
561561
562- static __always_inline u32 drm_xrgb8888_to_rgb565_swab (u32 pix )
563- {
564- return swab16 (drm_pixel_xrgb8888_to_rgb565 (pix ));
565- }
566-
567- /* TODO: implement this helper as conversion to RGB565|BIG_ENDIAN */
568- static void drm_fb_xrgb8888_to_rgb565_swab_line (void * dbuf , const void * sbuf ,
569- unsigned int pixels )
570- {
571- drm_fb_xfrm_line_32to16 (dbuf , sbuf , pixels , drm_xrgb8888_to_rgb565_swab );
572- }
573-
574562/**
575563 * drm_fb_xrgb8888_to_rgb565 - Convert XRGB8888 to RGB565 clip buffer
576564 * @dst: Array of RGB565 destination buffers
@@ -580,7 +568,6 @@ static void drm_fb_xrgb8888_to_rgb565_swab_line(void *dbuf, const void *sbuf,
580568 * @fb: DRM framebuffer
581569 * @clip: Clip rectangle area to copy
582570 * @state: Transform and conversion state
583- * @swab: Swap bytes
584571 *
585572 * This function copies parts of a framebuffer to display memory and converts the
586573 * color format during the process. Destination and framebuffer formats must match. The
@@ -595,23 +582,56 @@ static void drm_fb_xrgb8888_to_rgb565_swab_line(void *dbuf, const void *sbuf,
595582 */
596583void drm_fb_xrgb8888_to_rgb565 (struct iosys_map * dst , const unsigned int * dst_pitch ,
597584 const struct iosys_map * src , const struct drm_framebuffer * fb ,
598- const struct drm_rect * clip , struct drm_format_conv_state * state ,
599- bool swab )
585+ const struct drm_rect * clip , struct drm_format_conv_state * state )
600586{
601587 static const u8 dst_pixsize [DRM_FORMAT_MAX_PLANES ] = {
602588 2 ,
603589 };
604590
605- void (* xfrm_line )(void * dbuf , const void * sbuf , unsigned int npixels );
591+ drm_fb_xfrm (dst , dst_pitch , dst_pixsize , src , fb , clip , false, state ,
592+ drm_fb_xrgb8888_to_rgb565_line );
593+ }
594+ EXPORT_SYMBOL (drm_fb_xrgb8888_to_rgb565 );
595+
596+ static void drm_fb_xrgb8888_to_rgb565be_line (void * dbuf , const void * sbuf ,
597+ unsigned int pixels )
598+ {
599+ drm_fb_xfrm_line_32to16 (dbuf , sbuf , pixels , drm_pixel_xrgb8888_to_rgb565be );
600+ }
606601
607- if (swab )
608- xfrm_line = drm_fb_xrgb8888_to_rgb565_swab_line ;
609- else
610- xfrm_line = drm_fb_xrgb8888_to_rgb565_line ;
602+ /**
603+ * drm_fb_xrgb8888_to_rgb565be - Convert XRGB8888 to RGB565|DRM_FORMAT_BIG_ENDIAN clip buffer
604+ * @dst: Array of RGB565BE destination buffers
605+ * @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
606+ * within @dst; can be NULL if scanlines are stored next to each other.
607+ * @src: Array of XRGB8888 source buffer
608+ * @fb: DRM framebuffer
609+ * @clip: Clip rectangle area to copy
610+ * @state: Transform and conversion state
611+ *
612+ * This function copies parts of a framebuffer to display memory and converts the
613+ * color format during the process. Destination and framebuffer formats must match. The
614+ * parameters @dst, @dst_pitch and @src refer to arrays. Each array must have at
615+ * least as many entries as there are planes in @fb's format. Each entry stores the
616+ * value for the format's respective color plane at the same index.
617+ *
618+ * This function does not apply clipping on @dst (i.e. the destination is at the
619+ * top-left corner).
620+ *
621+ * Drivers can use this function for RGB565BE devices that don't support XRGB8888 natively.
622+ */
623+ void drm_fb_xrgb8888_to_rgb565be (struct iosys_map * dst , const unsigned int * dst_pitch ,
624+ const struct iosys_map * src , const struct drm_framebuffer * fb ,
625+ const struct drm_rect * clip , struct drm_format_conv_state * state )
626+ {
627+ static const u8 dst_pixsize [DRM_FORMAT_MAX_PLANES ] = {
628+ 2 ,
629+ };
611630
612- drm_fb_xfrm (dst , dst_pitch , dst_pixsize , src , fb , clip , false, state , xfrm_line );
631+ drm_fb_xfrm (dst , dst_pitch , dst_pixsize , src , fb , clip , false, state ,
632+ drm_fb_xrgb8888_to_rgb565be_line );
613633}
614- EXPORT_SYMBOL (drm_fb_xrgb8888_to_rgb565 );
634+ EXPORT_SYMBOL (drm_fb_xrgb8888_to_rgb565be );
615635
616636static void drm_fb_xrgb8888_to_xrgb1555_line (void * dbuf , const void * sbuf , unsigned int pixels )
617637{
@@ -1188,7 +1208,7 @@ int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t d
11881208 return 0 ;
11891209 } else if (fb_format == DRM_FORMAT_XRGB8888 ) {
11901210 if (dst_format == DRM_FORMAT_RGB565 ) {
1191- drm_fb_xrgb8888_to_rgb565 (dst , dst_pitch , src , fb , clip , state , false );
1211+ drm_fb_xrgb8888_to_rgb565 (dst , dst_pitch , src , fb , clip , state );
11921212 return 0 ;
11931213 } else if (dst_format == DRM_FORMAT_XRGB1555 ) {
11941214 drm_fb_xrgb8888_to_xrgb1555 (dst , dst_pitch , src , fb , clip , state );
0 commit comments