drm/gud: Add some more pixel formats
Subsystems (3)
v3 cover drm/gud: Add some more pixel formats
Hi,
I'd appreciate if someone could review the 3 small driver patches.
Changes since version 2:
- Drop the patch adding module parameter 'xrgb8888'. Both Daniel and Thomas had some comments that eventually led me to to drop this for now.
Noralf.
Noralf Trønnes (6):
drm/fourcc: Add R8 to drm_format_info drm/format-helper: Add drm_fb_xrgb8888_to_rgb332() drm/format-helper: Add drm_fb_xrgb8888_to_rgb888() drm/gud: Add GUD_PIXEL_FORMAT_R8
drm/gud: Add GUD_PIXEL_FORMAT_RGB332 drm/gud: Add GUD_PIXEL_FORMAT_RGB888
drivers/gpu/drm/drm_format_helper.c | 88 +++++++++++++++++++++++++++++ drivers/gpu/drm/drm_fourcc.c | 1 + drivers/gpu/drm/gud/gud_drv.c | 6 ++ drivers/gpu/drm/gud/gud_internal.h | 12 ++++ drivers/gpu/drm/gud/gud_pipe.c | 6 ++ include/drm/drm_format_helper.h | 4 ++ include/drm/gud.h | 6 +- 7 files changed, 121 insertions(+), 2 deletions(-)
Signature · 1 line
2.32.0
PATCH v3 1/6 drm/fourcc: Add R8 to drm_format_info
Add an entry in drm_format_info for the existing format DRM_FORMAT_R8.
--- drivers/gpu/drm/drm_fourcc.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_fourcc.c +1 -0
@@ -133,6 +133,7 @@ const struct drm_format_info *__drm_format_info(u32 format) {static const struct drm_format_info formats[] = { { .format =DRM_FORMAT_C8 , .depth =8 , .num_planes =1 , .cpp = {1 ,0 ,0 }, .hsub =1 , .vsub =1 }, + { .format =DRM_FORMAT_R8 , .depth =8 , .num_planes =1 , .cpp = {1 ,0 ,0 }, .hsub =1 , .vsub =1 }, { .format =DRM_FORMAT_RGB332 , .depth =8 , .num_planes =1 , .cpp = {1 ,0 ,0 }, .hsub =1 , .vsub =1 }, { .format =DRM_FORMAT_BGR233 , .depth =8 , .num_planes =1 , .cpp = {1 ,0 ,0 }, .hsub =1 , .vsub =1 }, { .format =DRM_FORMAT_XRGB4444 , .depth =0 , .num_planes =1 , .cpp = {2 ,0 ,0 }, .hsub =1 , .vsub =1 },
Signature · 1 line
2.32.0
PATCH v3 2/6 drm/format-helper: Add drm_fb_xrgb8888_to_rgb332()
In reply to Noralf TrønnesAdd XRGB8888 emulation support for devices that can only do RGB332.
v2:
- Support Big Endian (Daniel)
--- drivers/gpu/drm/drm_format_helper.c | 50 +++++++++++++++++++++++++++++ include/drm/drm_format_helper.h | 2 ++ 2 files changed, 52 insertions(+)
drivers/gpu/drm/drm_format_helper.c +50 -0
@@ -135,6 +135,56 @@ void drm_fb_swab(void *dst, void *src, struct drm_framebuffer *fb, }EXPORT_SYMBOL (drm_fb_swab); +static void drm_fb_xrgb8888_to_rgb332_line (u8 *dbuf,__le32 *sbuf,unsigned int pixels) +{ +unsigned int x; +u32 pix; + +for (x =0 ; x < pixels; x++) { + pix =le32_to_cpu (sbuf[x]); + dbuf[x] = ((pix &0x00e00000 ) >>16 ) | + ((pix &0x0000e000 ) >>11 ) | + ((pix &0x000000c0 ) >>6 ); + } +} + +/** +* drm_fb_xrgb8888_to_rgb332 - Convert XRGB8888 to RGB332 clip buffer +* @dst: RGB332 destination buffer +* @src: XRGB8888 source buffer +* @fb: DRM framebuffer +* @clip: Clip rectangle area to copy +* +* Drivers can use this function for RGB332 devices that don't natively support XRGB8888. +* +* This function does not apply clipping on dst, i.e. the destination is a small buffer +* containing the clip rect only. +*/ +void drm_fb_xrgb8888_to_rgb332 (void *dst,void *src,struct drm_framebuffer *fb, +struct drm_rect *clip) +{ +size_t width =drm_rect_width (clip); +size_t src_len = width *sizeof (u32); +unsigned int y; +void *sbuf; + +/* Use a buffer to speed up access on buffers with uncached read mapping (i.e. WC) */ + sbuf =kmalloc (src_len,GFP_KERNEL ); +if (!sbuf) +return ; + + src +=clip_offset (clip, fb->pitches[0 ],sizeof (u32)); +for (y =0 ; y <drm_rect_height (clip); y++) { +memcpy (sbuf, src, src_len); +drm_fb_xrgb8888_to_rgb332_line (dst, sbuf, width); + src += fb->pitches[0 ]; + dst += width; + } + +kfree (sbuf); +} +EXPORT_SYMBOL (drm_fb_xrgb8888_to_rgb332); +static void drm_fb_xrgb8888_to_rgb565_line (u16 *dbuf,u32 *sbuf,unsigned int pixels,bool swab)
include/drm/drm_format_helper.h +2 -0
@@ -16,6 +16,8 @@ void drm_fb_memcpy_dstclip(void __iomem *dst, unsigned int dst_pitch, void *vadd struct drm_rect *clip);void drm_fb_swab (void *dst,void *src,struct drm_framebuffer *fb,struct drm_rect *clip,bool cached); +void drm_fb_xrgb8888_to_rgb332 (void *dst,void *vaddr,struct drm_framebuffer *fb, +struct drm_rect *clip);void drm_fb_xrgb8888_to_rgb565 (void *dst,void *vaddr,struct drm_framebuffer *fb,struct drm_rect *clip,bool swab);
Signature · 1 line
2.32.0
PATCH v3 3/6 drm/format-helper: Add drm_fb_xrgb8888_to_rgb888()
In reply to Noralf TrønnesAdd XRGB8888 emulation support for devices that can only do RGB888.
--- drivers/gpu/drm/drm_format_helper.c | 38 +++++++++++++++++++++++++++++ include/drm/drm_format_helper.h | 2 ++ 2 files changed, 40 insertions(+)
drivers/gpu/drm/drm_format_helper.c +38 -0
@@ -300,6 +300,44 @@ static void drm_fb_xrgb8888_to_rgb888_line(u8 *dbuf, u32 *sbuf, } } +/** +* drm_fb_xrgb8888_to_rgb888 - Convert XRGB8888 to RGB888 clip buffer +* @dst: RGB888 destination buffer +* @src: XRGB8888 source buffer +* @fb: DRM framebuffer +* @clip: Clip rectangle area to copy +* +* Drivers can use this function for RGB888 devices that don't natively +* support XRGB8888. +* +* This function does not apply clipping on dst, i.e. the destination +* is a small buffer containing the clip rect only. +*/ +void drm_fb_xrgb8888_to_rgb888 (void *dst,void *src,struct drm_framebuffer *fb, +struct drm_rect *clip) +{ +size_t width =drm_rect_width (clip); +size_t src_len = width *sizeof (u32); +unsigned int y; +void *sbuf; + +/* Use a buffer to speed up access on buffers with uncached read mapping (i.e. WC) */ + sbuf =kmalloc (src_len,GFP_KERNEL ); +if (!sbuf) +return ; + + src +=clip_offset (clip, fb->pitches[0 ],sizeof (u32)); +for (y =0 ; y <drm_rect_height (clip); y++) { +memcpy (sbuf, src, src_len); +drm_fb_xrgb8888_to_rgb888_line (dst, sbuf, width); + src += fb->pitches[0 ]; + dst += width *3 ; + } + +kfree (sbuf); +} +EXPORT_SYMBOL (drm_fb_xrgb8888_to_rgb888); +/** * drm_fb_xrgb8888_to_rgb888_dstclip - Convert XRGB8888 to RGB888 clip buffer * @dst: RGB565 destination buffer (iomem)
include/drm/drm_format_helper.h +2 -0
@@ -24,6 +24,8 @@ void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr,void drm_fb_xrgb8888_to_rgb565_dstclip (void __iomem *dst,unsigned int dst_pitch,void *vaddr,struct drm_framebuffer *fb,struct drm_rect *clip,bool swab); +void drm_fb_xrgb8888_to_rgb888 (void *dst,void *src,struct drm_framebuffer *fb, +struct drm_rect *clip);void drm_fb_xrgb8888_to_rgb888_dstclip (void __iomem *dst,unsigned int dst_pitch,void *vaddr,struct drm_framebuffer *fb,struct drm_rect *clip);
Signature · 1 line
2.32.0
PATCH v3 4/6 drm/gud: Add GUD_PIXEL_FORMAT_R8
In reply to Noralf TrønnesAdd support for 8-bit greyscale format.
--- drivers/gpu/drm/gud/gud_drv.c | 2 ++ drivers/gpu/drm/gud/gud_internal.h | 4 ++++ drivers/gpu/drm/gud/gud_pipe.c | 2 ++ include/drm/gud.h | 4 ++-- 4 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/gud/gud_drv.c +2 -0
@@ -523,6 +523,8 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)switch (format) {case GUD_DRM_FORMAT_R1 : fallthrough; +case DRM_FORMAT_R8 : + fallthrough;case GUD_DRM_FORMAT_XRGB1111 :if (!xrgb8888_emulation_format) xrgb8888_emulation_format = info;
drivers/gpu/drm/gud/gud_internal.h +4 -0
@@ -80,6 +80,8 @@ static inline u8 gud_from_fourcc(u32 fourcc)switch (fourcc) {case GUD_DRM_FORMAT_R1 :return GUD_PIXEL_FORMAT_R1 ; +case DRM_FORMAT_R8 : +return GUD_PIXEL_FORMAT_R8 ;case GUD_DRM_FORMAT_XRGB1111 :return GUD_PIXEL_FORMAT_XRGB1111 ;case DRM_FORMAT_RGB565 :
@@ -98,6 +100,8 @@ static inline u32 gud_to_fourcc(u8 format)switch (format) {case GUD_PIXEL_FORMAT_R1 :return GUD_DRM_FORMAT_R1 ; +case GUD_PIXEL_FORMAT_R8 : +return DRM_FORMAT_R8 ;case GUD_PIXEL_FORMAT_XRGB1111 :return GUD_DRM_FORMAT_XRGB1111 ;case GUD_PIXEL_FORMAT_RGB565 :
drivers/gpu/drm/gud/gud_pipe.c +2 -0
@@ -189,6 +189,8 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb, ret = -ENOMEM ; goto end_cpu_access; } + }else if (format->format ==DRM_FORMAT_R8 ) { +drm_fb_xrgb8888_to_gray8 (buf, vaddr, fb, rect); }else if (format->format ==DRM_FORMAT_RGB565 ) {drm_fb_xrgb8888_to_rgb565 (buf, vaddr, fb, rect,gud_is_big_endian ()); }else {
include/drm/gud.h +2 -2
@@ -246,8 +246,8 @@ struct gud_state_req {/* Get supported pixel formats as a byte array of GUD_PIXEL_FORMAT_* */ #define GUD_REQ_GET_FORMATS 0x40#define GUD_FORMATS_MAX_NUM 32 -/* R1 is a 1-bit monochrome transfer format presented to userspace as XRGB8888 */ -#define GUD_PIXEL_FORMAT_R1 0x01 +#define GUD_PIXEL_FORMAT_R1 0x01/* 1-bit monochrome */ +#define GUD_PIXEL_FORMAT_R8 0x08/* 8-bit greyscale */ #define GUD_PIXEL_FORMAT_XRGB1111 0x20#define GUD_PIXEL_FORMAT_RGB565 0x40#define GUD_PIXEL_FORMAT_XRGB8888 0x80
Signature · 1 line
2.32.0
PATCH v3 5/6 drm/gud: Add GUD_PIXEL_FORMAT_RGB332
In reply to Noralf TrønnesAdd support for the RGB332 pixel format.
--- drivers/gpu/drm/gud/gud_drv.c | 2 ++ drivers/gpu/drm/gud/gud_internal.h | 4 ++++ drivers/gpu/drm/gud/gud_pipe.c | 2 ++ include/drm/gud.h | 1 + 4 files changed, 9 insertions(+)
drivers/gpu/drm/gud/gud_drv.c +2 -0
@@ -526,6 +526,8 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)case DRM_FORMAT_R8 : fallthrough;case GUD_DRM_FORMAT_XRGB1111 : + fallthrough; +case DRM_FORMAT_RGB332 :if (!xrgb8888_emulation_format) xrgb8888_emulation_format = info;break ;
drivers/gpu/drm/gud/gud_internal.h +4 -0
@@ -84,6 +84,8 @@ static inline u8 gud_from_fourcc(u32 fourcc)return GUD_PIXEL_FORMAT_R8 ;case GUD_DRM_FORMAT_XRGB1111 :return GUD_PIXEL_FORMAT_XRGB1111 ; +case DRM_FORMAT_RGB332 : +return GUD_PIXEL_FORMAT_RGB332 ;case DRM_FORMAT_RGB565 :return GUD_PIXEL_FORMAT_RGB565 ;case DRM_FORMAT_XRGB8888 :
@@ -104,6 +106,8 @@ static inline u32 gud_to_fourcc(u8 format)return DRM_FORMAT_R8 ;case GUD_PIXEL_FORMAT_XRGB1111 :return GUD_DRM_FORMAT_XRGB1111 ; +case GUD_PIXEL_FORMAT_RGB332 : +return DRM_FORMAT_RGB332 ;case GUD_PIXEL_FORMAT_RGB565 :return DRM_FORMAT_RGB565 ;case GUD_PIXEL_FORMAT_XRGB8888 :
drivers/gpu/drm/gud/gud_pipe.c +2 -0
@@ -191,6 +191,8 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb, } }else if (format->format ==DRM_FORMAT_R8 ) {drm_fb_xrgb8888_to_gray8 (buf, vaddr, fb, rect); + }else if (format->format ==DRM_FORMAT_RGB332 ) { +drm_fb_xrgb8888_to_rgb332 (buf, vaddr, fb, rect); }else if (format->format ==DRM_FORMAT_RGB565 ) {drm_fb_xrgb8888_to_rgb565 (buf, vaddr, fb, rect,gud_is_big_endian ()); }else {
include/drm/gud.h +1 -0
@@ -249,6 +249,7 @@ struct gud_state_req {#define GUD_PIXEL_FORMAT_R1 0x01/* 1-bit monochrome */ #define GUD_PIXEL_FORMAT_R8 0x08/* 8-bit greyscale */ #define GUD_PIXEL_FORMAT_XRGB1111 0x20 +#define GUD_PIXEL_FORMAT_RGB332 0x30#define GUD_PIXEL_FORMAT_RGB565 0x40#define GUD_PIXEL_FORMAT_XRGB8888 0x80#define GUD_PIXEL_FORMAT_ARGB8888 0x81
Signature · 1 line
2.32.0
PATCH v3 6/6 drm/gud: Add GUD_PIXEL_FORMAT_RGB888
In reply to Noralf TrønnesAdd support for the RGB888 pixel format.
--- drivers/gpu/drm/gud/gud_drv.c | 2 ++ drivers/gpu/drm/gud/gud_internal.h | 4 ++++ drivers/gpu/drm/gud/gud_pipe.c | 2 ++ include/drm/gud.h | 1 + 4 files changed, 9 insertions(+)
drivers/gpu/drm/gud/gud_drv.c +2 -0
@@ -528,6 +528,8 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)case GUD_DRM_FORMAT_XRGB1111 : fallthrough;case DRM_FORMAT_RGB332 : + fallthrough; +case DRM_FORMAT_RGB888 :if (!xrgb8888_emulation_format) xrgb8888_emulation_format = info;break ;
drivers/gpu/drm/gud/gud_internal.h +4 -0
@@ -88,6 +88,8 @@ static inline u8 gud_from_fourcc(u32 fourcc)return GUD_PIXEL_FORMAT_RGB332 ;case DRM_FORMAT_RGB565 :return GUD_PIXEL_FORMAT_RGB565 ; +case DRM_FORMAT_RGB888 : +return GUD_PIXEL_FORMAT_RGB888 ;case DRM_FORMAT_XRGB8888 :return GUD_PIXEL_FORMAT_XRGB8888 ;case DRM_FORMAT_ARGB8888 :
@@ -110,6 +112,8 @@ static inline u32 gud_to_fourcc(u8 format)return DRM_FORMAT_RGB332 ;case GUD_PIXEL_FORMAT_RGB565 :return DRM_FORMAT_RGB565 ; +case GUD_PIXEL_FORMAT_RGB888 : +return DRM_FORMAT_RGB888 ;case GUD_PIXEL_FORMAT_XRGB8888 :return DRM_FORMAT_XRGB8888 ;case GUD_PIXEL_FORMAT_ARGB8888 :
drivers/gpu/drm/gud/gud_pipe.c +2 -0
@@ -195,6 +195,8 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb,drm_fb_xrgb8888_to_rgb332 (buf, vaddr, fb, rect); }else if (format->format ==DRM_FORMAT_RGB565 ) {drm_fb_xrgb8888_to_rgb565 (buf, vaddr, fb, rect,gud_is_big_endian ()); + }else if (format->format ==DRM_FORMAT_RGB888 ) { +drm_fb_xrgb8888_to_rgb888 (buf, vaddr, fb, rect); }else { len =gud_xrgb8888_to_color (buf, format, vaddr, fb, rect); }
include/drm/gud.h +1 -0
@@ -251,6 +251,7 @@ struct gud_state_req {#define GUD_PIXEL_FORMAT_XRGB1111 0x20#define GUD_PIXEL_FORMAT_RGB332 0x30#define GUD_PIXEL_FORMAT_RGB565 0x40 +#define GUD_PIXEL_FORMAT_RGB888 0x50#define GUD_PIXEL_FORMAT_XRGB8888 0x80#define GUD_PIXEL_FORMAT_ARGB8888 0x81
Signature · 1 line
2.32.0
Hi
Am 29.09.21 um 21:11 schrieb Noralf Trønnes:
Quoted 3 lines
Hi,
I'd appreciate if someone could review the 3 small driver patches.
Series is
Best regards
Thomas
Quoted 25 lines
Changes since version 2:
- Drop the patch adding module parameter 'xrgb8888'. Both Daniel and Thomas had some comments that eventually led me to to drop this for now.Noralf.
Noralf Trønnes (6):
drm/fourcc: Add R8 todrm_format_infodrm/format-helper: Adddrm_fb_xrgb8888_to_rgb332()drm/format-helper: Adddrm_fb_xrgb8888_to_rgb888()drm/gud: AddGUD_PIXEL_FORMAT_R8
drm/gud: AddGUD_PIXEL_FORMAT_RGB332drm/gud: AddGUD_PIXEL_FORMAT_RGB888drivers/gpu/drm/drm_format_helper.c | 88 +++++++++++++++++++++++++++++ drivers/gpu/drm/drm_fourcc.c | 1 + drivers/gpu/drm/gud/gud_drv.c | 6 ++ drivers/gpu/drm/gud/gud_internal.h | 12 ++++ drivers/gpu/drm/gud/gud_pipe.c | 6 ++ include/drm/drm_format_helper.h | 4 ++ include/drm/gud.h | 6 +- 7 files changed, 121 insertions(+), 2 deletions(-)
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
Den 30.09.2021 11.10, skrev Thomas Zimmermann:
Quoted 11 lines
Hi
Am 29.09.21 um 21:11 schrieb Noralf Trønnes:
Quoted 3 lines
Hi,
I'd appreciate if someone could review the 3 small driver patches.
Series is
Many thanks Thomas!
Noralf.
Quoted 29 lines
Best regards
ThomasQuoted 25 lines
Changes since version 2:
- Drop the patch adding module parameter 'xrgb8888'. Both Daniel and Thomas had some comments that eventually led me to to drop this for now.Noralf.
Noralf Trønnes (6):
drm/fourcc: Add R8 todrm_format_infodrm/format-helper: Adddrm_fb_xrgb8888_to_rgb332()drm/format-helper: Adddrm_fb_xrgb8888_to_rgb888()drm/gud: AddGUD_PIXEL_FORMAT_R8
drm/gud: AddGUD_PIXEL_FORMAT_RGB332drm/gud: AddGUD_PIXEL_FORMAT_RGB888
drivers/gpu/drm/drm_format_helper.c| 88 +++++++++++++++++++++++++++++ drivers/gpu/drm/drm_fourcc.c | 1 + drivers/gpu/drm/gud/gud_drv.c | 6 ++ drivers/gpu/drm/gud/gud_internal.h | 12 ++++ drivers/gpu/drm/gud/gud_pipe.c | 6 ++ include/drm/drm_format_helper.h | 4 ++ include/drm/gud.h | 6 +-7 files changed, 121 insertions(+), 2 deletions(-)