drm/arm/hdlcd: Replace struct simplefb_format with custom type
Subsystems (4)
Thomas Zimmermann
maintainerPATCH v2 1/1 drm/arm/hdlcd: Replace struct simplefb_format with custom type
Map DRM FourCC codes to pixel descriptions with an internal struct type. Avoid simplefb's struct simplefb_format, which is for parsing "simple-framebuffer" DT nodes. Drop the unsupported formats with alpha channel from the list.
The HDLCD drivers uses struct simplefb_format and its default initializer SIMPLEFB_FORMATS to map DRM_FORMAT_ constants to pixel descriptions. The simplefb helpers are for parsing "simple-framebuffer" DT nodes and should be avoided in other context. Therefore replace it in hdlcd with a custom struct type and pixel descriptions from PIXEL_FORMAT_ constants.
This change also removes including <linux/platform_data/simplefb.h>, which includes several unrelated headers, such as <linux/fb.h>.
v2:
- drop unsupported alpha formats (Liviu)
- keep original sorting of formats (Javier)
- use anonymous type for supported_formats
--- drivers/gpu/drm/arm/hdlcd_crtc.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/arm/hdlcd_crtc.c +15 -8
@@ -11,8 +11,8 @@#include <linux/clk.h> #include <linux/of_graph.h> -#include <linux/platform_data/simplefb.h> +#include <video/pixel_format.h> #include <video/videomode.h> #include <drm/drm_atomic.h>
@@ -73,7 +73,17 @@ static const struct drm_crtc_funcs hdlcd_crtc_funcs = { .disable_vblank = hdlcd_crtc_disable_vblank, }; -static struct simplefb_format supported_formats[] =SIMPLEFB_FORMATS ; +static const struct { +u32 fourcc; +struct pixel_format pixel; +} supported_formats[] = { + {DRM_FORMAT_RGB565 ,PIXEL_FORMAT_RGB565 }, + {DRM_FORMAT_XRGB1555 ,PIXEL_FORMAT_XRGB1555 }, + {DRM_FORMAT_RGB888 ,PIXEL_FORMAT_RGB888 }, + {DRM_FORMAT_XRGB8888 ,PIXEL_FORMAT_XRGB8888 }, + {DRM_FORMAT_XBGR8888 ,PIXEL_FORMAT_XBGR8888 }, + {DRM_FORMAT_XRGB2101010 ,PIXEL_FORMAT_XRGB2101010 }, +};/* * Setup the HDLCD registers for decoding the pixels out of the framebuffer
@@ -83,15 +93,12 @@ static int hdlcd_set_pxl_fmt(struct drm_crtc *crtc)unsigned int btpp;struct hdlcd_drm_private *hdlcd =crtc_to_hdlcd_priv (crtc);const struct drm_framebuffer *fb = crtc->primary->state->fb; -uint32_t pixel_format; -struct simplefb_format *format =NULL ; +const struct pixel_format *format =NULL ;int i; - pixel_format = fb->format->format; -for (i =0 ; i <ARRAY_SIZE (supported_formats); i++) { -if (supported_formats[i].fourcc == pixel_format) - format = &supported_formats[i]; +if (supported_formats[i].fourcc == fb->format->format) + format = &supported_formats[i].pixel; }if (WARN_ON (!format))
Signature · 1 line
2.49.0
Quoted 15 lines · Thomas Zimmermann
Map DRM FourCC codes to pixel descriptions with an internal struct type. Avoid simplefb's struct
simplefb_format, which is for parsing "simple-framebuffer" DT nodes. Drop the unsupported formats with alpha channel from the list.The HDLCD drivers uses struct
simplefb_formatand its default initializerSIMPLEFB_FORMATSto mapDRM_FORMAT_constants to pixel descriptions. The simplefb helpers are for parsing "simple-framebuffer" DT nodes and should be avoided in other context. Therefore replace it in hdlcd with a custom struct type and pixel descriptions fromPIXEL_FORMAT_constants.This change also removes including <
linux/platform_data/simplefb.h>, which includes several unrelated headers, such as <linux/fb.h>.
Quoted 7 lines
v2:
- drop unsupported alpha formats (Liviu)
- keep original sorting of formats (Javier)
- use anonymous type forsupported_formatsSigned-off-by Thomas Zimmermann <[email protected]>Reviewed-by Javier Martinez Canillas <[email protected]>
Are you happy to merge this yourself?
Best regards,
Liviu
Quoted 59 lines
--- drivers/gpu/drm/arm/hdlcd_crtc.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)drivers/gpu/drm/arm/hdlcd_crtc.c +15
-8@@ -11,8 +11,8 @@#include <linux/clk.h> #include <linux/of_graph.h> -#include <linux/platform_data/simplefb.h> +#include <video/pixel_format.h> #include <video/videomode.h> #include <drm/drm_atomic.h> @@ -73,7 +73,17 @@ static const struct drm_crtc_funcs hdlcd_crtc_funcs = { .disable_vblank = hdlcd_crtc_disable_vblank, }; -static struct simplefb_format supported_formats[] =SIMPLEFB_FORMATS ; +static const struct { +u32 fourcc; +struct pixel_format pixel; +} supported_formats[] = { + {DRM_FORMAT_RGB565 ,PIXEL_FORMAT_RGB565 }, + {DRM_FORMAT_XRGB1555 ,PIXEL_FORMAT_XRGB1555 }, + {DRM_FORMAT_RGB888 ,PIXEL_FORMAT_RGB888 }, + {DRM_FORMAT_XRGB8888 ,PIXEL_FORMAT_XRGB8888 }, + {DRM_FORMAT_XBGR8888 ,PIXEL_FORMAT_XBGR8888 }, + {DRM_FORMAT_XRGB2101010 ,PIXEL_FORMAT_XRGB2101010 }, +};/* * Setup the HDLCD registers for decoding the pixels out of the framebuffer @@ -83,15 +93,12 @@ static int hdlcd_set_pxl_fmt(struct drm_crtc *crtc)unsigned int btpp;struct hdlcd_drm_private *hdlcd =crtc_to_hdlcd_priv (crtc);const struct drm_framebuffer *fb = crtc->primary->state->fb; -uint32_t pixel_format; -struct simplefb_format *format =NULL ; +const struct pixel_format *format =NULL ;int i; - pixel_format = fb->format->format; -for (i =0 ; i <ARRAY_SIZE (supported_formats); i++) { -if (supported_formats[i].fourcc == pixel_format) - format = &supported_formats[i]; +if (supported_formats[i].fourcc == fb->format->format) + format = &supported_formats[i].pixel; }if (WARN_ON (!format))Signature · 1 line
2.49.0
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Thomas Zimmermann
maintainerHi
Am 10.06.25 um 18:42 schrieb Liviu Dudau:
Quoted 21 lines · Thomas Zimmermann
Quoted 20 lines
Map DRM FourCC codes to pixel descriptions with an internal struct type. Avoid simplefb's struct
simplefb_format, which is for parsing "simple-framebuffer" DT nodes. Drop the unsupported formats with alpha channel from the list.The HDLCD drivers uses struct
simplefb_formatand its default initializerSIMPLEFB_FORMATSto mapDRM_FORMAT_constants to pixel descriptions. The simplefb helpers are for parsing "simple-framebuffer" DT nodes and should be avoided in other context. Therefore replace it in hdlcd with a custom struct type and pixel descriptions fromPIXEL_FORMAT_constants.This change also removes including <
linux/platform_data/simplefb.h>, which includes several unrelated headers, such as <linux/fb.h>.v2:
- drop unsupported alpha formats (Liviu)
- keep original sorting of formats (Javier)
- use anonymous type forsupported_formats
Quoted 5 lines
Quoted 2 lines
Signed-off-by Thomas Zimmermann <[email protected]>Reviewed-by Javier Martinez Canillas <[email protected]>Reviewed-by Liviu Dudau <[email protected]>Are you happy to merge this yourself?
Yes, merged now.
Best regards
Thomas
Quoted 63 lines
Best regards,
LiviuQuoted 59 lines
--- drivers/gpu/drm/arm/hdlcd_crtc.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)drivers/gpu/drm/arm/hdlcd_crtc.c +15
-8@@ -11,8 +11,8 @@#include <linux/clk.h> #include <linux/of_graph.h> -#include <linux/platform_data/simplefb.h> +#include <video/pixel_format.h> #include <video/videomode.h> #include <drm/drm_atomic.h> @@ -73,7 +73,17 @@ static const struct drm_crtc_funcs hdlcd_crtc_funcs = { .disable_vblank = hdlcd_crtc_disable_vblank, }; -static struct simplefb_format supported_formats[] =SIMPLEFB_FORMATS ; +static const struct { +u32 fourcc; +struct pixel_format pixel; +} supported_formats[] = { + {DRM_FORMAT_RGB565 ,PIXEL_FORMAT_RGB565 }, + {DRM_FORMAT_XRGB1555 ,PIXEL_FORMAT_XRGB1555 }, + {DRM_FORMAT_RGB888 ,PIXEL_FORMAT_RGB888 }, + {DRM_FORMAT_XRGB8888 ,PIXEL_FORMAT_XRGB8888 }, + {DRM_FORMAT_XBGR8888 ,PIXEL_FORMAT_XBGR8888 }, + {DRM_FORMAT_XRGB2101010 ,PIXEL_FORMAT_XRGB2101010 }, +};/* * Setup the HDLCD registers for decoding the pixels out of the framebuffer @@ -83,15 +93,12 @@ static int hdlcd_set_pxl_fmt(struct drm_crtc *crtc)unsigned int btpp;struct hdlcd_drm_private *hdlcd =crtc_to_hdlcd_priv (crtc);const struct drm_framebuffer *fb = crtc->primary->state->fb; -uint32_t pixel_format; -struct simplefb_format *format =NULL ; +const struct pixel_format *format =NULL ;int i; - pixel_format = fb->format->format; -for (i =0 ; i <ARRAY_SIZE (supported_formats); i++) { -if (supported_formats[i].fourcc == pixel_format) - format = &supported_formats[i]; +if (supported_formats[i].fourcc == fb->format->format) + format = &supported_formats[i].pixel; }if (WARN_ON (!format))Signature · 1 line
2.49.0
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)