drm/sysfb: simpledrm: Various improvements
Subsystems (13)
Thomas Zimmermann
maintainerv3 cover drm/sysfb: simpledrm: Various improvements
Patches 1 to 5 improve validation of the values provided by the device firmware.
Patches 6 and 7 improve support for panel orientation. There's a rotation property in the DT panel node. Read the value and set the connector's orientation property accordingly. To do so, patch 6 moves the existing code for parsing the rotation to drm_of.c. This makes it available to simpledrm without introducing a dependency on DRM_PANEL.
v3:
- use shared helper for parsing the panel orentation (Thierry)
- fix framebuffer size checks (Sashiko)
- minor improvements
v2:
- further improve input validation (Sashiko)
Thomas Zimmermann (7):
drm/sysfb: simpledrm: Improve framebuffer-size validation drm/sysfb: simpledrm: Improve panel-size validation drm/sysfb: simpledrm: Inline simplefb_get_validated_int() drm/sysfb: simpledrm: Improve stride validation drm/sysfb: simpledrm: Validate mmap size against framebuffer size drm/of: Implement drm_of_get_panel_orientation() drm/sysfb: simpledrm: Read panel orientation from DT node
drivers/gpu/drm/drm_of.c | 44 +++++++++++ drivers/gpu/drm/drm_panel.c | 26 +------ drivers/gpu/drm/sysfb/simpledrm.c | 120 +++++++++++++++++++++++------- include/drm/drm_of.h | 11 +++ 4 files changed, 150 insertions(+), 51 deletions(-)
base-commit: fc59f76558703febba8056be87d1c97d14f7485e
Signature · 1 line
2.54.0
Thomas Zimmermann
maintainerPATCH v3 1/7 drm/sysfb: simpledrm: Improve framebuffer-size validation
Validate the framebuffer size from the firmware against the limitations of struct drm_display_mode. The type only stores sizes in 16-bit fields. Fail probing on errors.
v2:
- remove unused function simplefb_get_validated_int0() (Sashiko)
--- drivers/gpu/drm/sysfb/simpledrm.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/sysfb/simpledrm.c +4 -11
@@ -48,13 +48,6 @@ simplefb_get_validated_int(struct drm_device *dev, const char *name,return drm_sysfb_get_validated_int (dev, name, value,INT_MAX ); } -static int -simplefb_get_validated_int0 (struct drm_device *dev,const char *name, -uint32_t value) -{ -return drm_sysfb_get_validated_int0 (dev, name, value,INT_MAX ); -} -static const struct drm_format_info *simplefb_get_validated_format (struct drm_device *dev,const char *format_name) {
@@ -88,14 +81,14 @@ static int simplefb_get_width_pd(struct drm_device *dev, const struct simplefb_platform_data *pd) { - return simplefb_get_validated_int0(dev, "width", pd->width); + return drm_sysfb_get_validated_int0(dev, "width", pd->width, U16_MAX); }static int simplefb_get_height_pd (struct drm_device *dev,const struct simplefb_platform_data *pd) { -return simplefb_get_validated_int0 (dev,"height" , pd->height); +return drm_sysfb_get_validated_int0 (dev,"height" , pd->height,U16_MAX ); } static int
@@ -144,7 +137,7 @@ simplefb_get_width_of(struct drm_device *dev, struct device_node *of_node)if (ret)return ret; -return simplefb_get_validated_int0 (dev,"width" , width); +return drm_sysfb_get_validated_int0 (dev,"width" , width,U16_MAX ); } static int
@@ -155,7 +148,7 @@ simplefb_get_height_of(struct drm_device *dev, struct device_node *of_node)if (ret)return ret; -return simplefb_get_validated_int0 (dev,"height" , height); +return drm_sysfb_get_validated_int0 (dev,"height" , height,U16_MAX ); } static int
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v3 1/7] drm/sysfb: simpledrm: Improve framebuffer-size validation
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing validation for device tree provided stride against width * bpp allows out-of-bounds memory writes. --
commit daaa8ad78a371c66bd2324aa7a47d551084fe671
Author: Thomas Zimmermann <[email protected]> drm/sysfb: simpledrm: Improve framebuffer-size validation
This commit validates the framebuffer dimensions provided by firmware against the 16-bit limits of struct drm_display_mode, failing the probe on errors.
[ ... ]
Quoted 10 lines
drivers/gpu/drm/sysfb/simpledrm.c +1
-1@@ -144,7 +137,7 @@ simplefb_get_width_of(struct drm_device *dev, struct device_node *of_node)if (ret)return ret; -return simplefb_get_validated_int0 (dev,"width" , width); +return drm_sysfb_get_validated_int0 (dev,"width" , width,U16_MAX ); } static int
drivers/gpu/drm/sysfb/simpledrm.c simplefb_get_height_of(struct drm_device *dev, struct device_node *of_node) · line 152
Quoted 6 lines
drivers/gpu/drm/sysfb/simpledrm.c +1
-1@@ -155,7 +148,7 @@ simplefb_get_height_of(struct drm_device *dev, struct device_node *of_node)if (ret)return ret; -return simplefb_get_validated_int0 (dev,"height" , height); +return drm_sysfb_get_validated_int0 (dev,"height" , height,U16_MAX ); }
[Severity: High]
This is a pre-existing issue, but does this code need to ensure a provided stride is at least large enough for the given width and pixel format?
In simpledrm_device_create(), if the device tree or platform data provides a non-zero stride, it bypasses the minimum pitch calculation:
if (!stride) {
u64 pitch = drm_format_info_min_pitch(format, 0, width);
...
stride = pitch;
}The driver then calculates the required size using this stride:
if (check_mul_overflow(height, stride, &size)) {
...
if (size > resource_size(mem)) {If firmware provides a small but non-zero stride (for example, 1), the size calculation yields a small value, which easily passes the resource size check.
However, rendering and clearing operations write width * bpp bytes per line. For example, in drm_sysfb_plane_helper_atomic_disable():
for (i = 0; i < lines; ++i) {
memset_io(dst_vmap, 0, linepixels * dst_format->cpp[0]);
dst_vmap += dst_pitch;
}Can this lead to out-of-bounds memory writes if the firmware provides a stride that is smaller than width * bpp?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Thomas Zimmermann
maintainerPATCH v3 2/7 drm/sysfb: simpledrm: Improve panel-size validation
In reply to Thomas ZimmermannValidate the panel size from the device-tree node against the limitations of struct drm_display_mode. The type only stores sizes in 16-bit fields. Fail transparently on errors; do not warn.
v3:
- move comments to a more prominent place (Thierry) v2:
- only use initialized values in debugging output (Sashiko)
--- drivers/gpu/drm/sysfb/simpledrm.c | 49 +++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-)
drivers/gpu/drm/sysfb/simpledrm.c +46 -3
@@ -193,6 +193,39 @@ simplefb_get_memory_of(struct drm_device *dev, struct device_node *of_node)return res; } +static int __simplefb_get_panel_size_mm_of (struct drm_device *dev, +struct device_node *of_panel_node, +const char *name) +{ +int ret; +u32 value; + + ret =of_property_read_u32 (of_panel_node, name, &value); +if (ret) { +drm_dbg (dev,"simplefb: cannot parse panel %s: error %d\n" , + name, ret); +return ret; + }else if (value >U16_MAX ) { +drm_dbg (dev,"simplefb: panel %s of %u exceeds maximum value\n" , + name, value); +return -EINVAL ; + } + +return value; +} + +static int simplefb_get_panel_width_mm_of (struct drm_device *dev, +struct device_node *of_panel_node) +{ +return __simplefb_get_panel_size_mm_of (dev, of_panel_node,"width-mm" ); +} + +static int simplefb_get_panel_height_mm_of (struct drm_device *dev, +struct device_node *of_panel_node) +{ +return __simplefb_get_panel_size_mm_of (dev, of_panel_node,"height-mm" ); +} +/* * Simple Framebuffer device */
@@ -594,7 +627,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,struct drm_sysfb_device *sysfb;struct drm_device *dev;int width, height, stride; -int width_mm =0 , height_mm =0 ; +u16 width_mm =0 , height_mm =0 ;struct device_node *panel_node;const struct drm_format_info *format;struct resource *res, *mem =NULL ;
@@ -658,8 +691,18 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,return ERR_CAST (mem); panel_node =of_parse_phandle (of_node,"panel" ,0 );if (panel_node) { -simplefb_read_u32_of (dev, panel_node,"width-mm" , &width_mm); -simplefb_read_u32_of (dev, panel_node,"height-mm" , &height_mm); +/* +* Ignore errors from parsing the physical panel +* size. Using the pre-initialized sizes of 0 will +* make drm_sysfb_mode() calculate a default physical +* size based on a resolution of 96 dpi. +*/ + ret =simplefb_get_panel_width_mm_of (dev, panel_node); +if (ret >0 ) + width_mm = ret; + ret =simplefb_get_panel_height_mm_of (dev, panel_node); +if (ret >0 ) + height_mm = ret;of_node_put (panel_node); } }else {
Signature · 1 line
2.54.0
Thomas Zimmermann
maintainerPATCH v3 3/7 drm/sysfb: simpledrm: Inline simplefb_get_validated_int()
In reply to Thomas ZimmermannThe helper simplefb_get_validated_int() is only a wrapper around drm_sysfb_get_validated_int(). Inline the function into its callers.
--- drivers/gpu/drm/sysfb/simpledrm.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/sysfb/simpledrm.c +2 -9
@@ -41,13 +41,6 @@* Helpers for simplefb */ -static int -simplefb_get_validated_int (struct drm_device *dev,const char *name, -uint32_t value) -{ -return drm_sysfb_get_validated_int (dev, name, value,INT_MAX ); -} -static const struct drm_format_info *simplefb_get_validated_format (struct drm_device *dev,const char *format_name) {
@@ -95,7 +88,7 @@ static int simplefb_get_stride_pd(struct drm_device *dev, const struct simplefb_platform_data *pd) { - return simplefb_get_validated_int(dev, "stride", pd->stride); + return drm_sysfb_get_validated_int(dev, "stride", pd->stride, INT_MAX); } static const struct drm_format_info *
@@ -159,7 +152,7 @@ simplefb_get_stride_of(struct drm_device *dev, struct device_node *of_node)if (ret)return ret; -return simplefb_get_validated_int (dev,"stride" , stride); +return drm_sysfb_get_validated_int (dev,"stride" , stride,INT_MAX ); } static const struct drm_format_info *
Signature · 1 line
2.54.0
Thomas Zimmermann
maintainerPATCH v3 4/7 drm/sysfb: simpledrm: Improve stride validation
In reply to Thomas ZimmermannValidate the computed stride against the maximum value INT_MAX.
--- drivers/gpu/drm/sysfb/simpledrm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/sysfb/simpledrm.c +8 -2
@@ -703,9 +703,15 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,return ERR_PTR (-ENODEV ); }if (!stride) { - stride =drm_format_info_min_pitch (format,0 , width); -if (drm_WARN_ON (dev, !stride)) +u64 pitch =drm_format_info_min_pitch (format,0 , width); + +if (drm_WARN_ON (dev, !pitch)) { +return ERR_PTR (-EINVAL );/* driver bug */ + }else if (pitch >INT_MAX ) { +drm_warn (dev,"stride of %llu exceeds maximum\n" , pitch);return ERR_PTR (-EINVAL ); + } + stride = pitch; } sysfb->fb_mode =drm_sysfb_mode (width, height, width_mm, height_mm);
Signature · 1 line
2.54.0
Thomas Zimmermann
maintainerPATCH v3 5/7 drm/sysfb: simpledrm: Validate mmap size against framebuffer size
In reply to Thomas ZimmermannThe size of the mmap'ed framebuffer could be smaller than the minimum required framebuffer size. Validate the resource size against the framebuffer size.
Buggy firmware that triggers this check should be fixed up with a quirk on a case-by-case base.
v3:
- fix size checks (Sashiko)
- improve error message for alignment check (Thierry)
- do not store aligned size value
--- drivers/gpu/drm/sysfb/simpledrm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/gpu/drm/sysfb/simpledrm.c +24 -0
@@ -6,6 +6,7 @@#include <linux/of_address.h> #include <linux/of_clk.h> #include <linux/of_reserved_mem.h> +#include <linux/overflow.h> #include <linux/platform_data/simplefb.h> #include <linux/platform_device.h> #include <linux/pm.h>
@@ -623,6 +624,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,u16 width_mm =0 , height_mm =0 ;struct device_node *panel_node;const struct drm_format_info *format; +u64 size;struct resource *res, *mem =NULL ;struct drm_plane *primary_plane;struct drm_crtc *crtc;
@@ -713,6 +715,14 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, } stride = pitch; } +if (check_mul_overflow (height, stride, &size)) { +drm_err (dev,"framebuffer size exceeds maximum\n" ); +return ERR_PTR (-EINVAL ); + } +if (ALIGN (size,PAGE_SIZE ) <PAGE_SIZE ) { +drm_err (dev,"page-aligned framebuffer exceeds maximum\n" ); +return ERR_PTR (-EINVAL ); + } sysfb->fb_mode =drm_sysfb_mode (width, height, width_mm, height_mm); sysfb->fb_format = format;
@@ -738,6 +748,13 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,drm_dbg (dev,"using system memory framebuffer at %pr\n" , mem); +if (size >resource_size (mem)) { +drm_err (dev, +"framebuffer size of %llu exceeds memory range %pr\n" , + size, mem); +return ERR_PTR (-EINVAL ); + } + screen_base =devm_memremap (dev->dev, mem->start,resource_size (mem),MEMREMAP_WC );if (IS_ERR (screen_base))return screen_base;
@@ -771,6 +788,13 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, mem = res; } +if (size >resource_size (mem)) { +drm_err (dev, +"framebuffer size of %llu exceeds memory range %pr\n" , + size, mem); +return ERR_PTR (-EINVAL ); + } + screen_base =devm_ioremap_wc (&pdev->dev, mem->start,resource_size (mem));if (!screen_base)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v3 5/7] drm/sysfb: simpledrm: Validate mmap size against framebuffer size
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] Dead code in mathematical overflow checks for framebuffer size and alignment
Pre-existing issues:
- [High] Missing bounds check for explicitly provided stride allows out-of-bounds writes --
commit 192f927f236077dbe56914205861b2c980ca71ec
Author: Thomas Zimmermann <[email protected]>
drm/sysfb: simpledrm: Validate mmap size against framebuffer size
The size of the mmap'ed framebuffer could be smaller than the minimum required framebuffer size. Validate the resource size against the framebuffer size.
Quoted 4 lines
drivers/gpu/drm/sysfb/simpledrm.c +0
-0
[ ... ]
Quoted 8 lines
drivers/gpu/drm/sysfb/simpledrm.c +1
-0@@ -623,6 +624,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,u16 width_mm =0 , height_mm =0 ;struct device_node *panel_node;const struct drm_format_info *format; +u64 size;struct resource *res, *mem =NULL ;struct drm_plane *primary_plane;struct drm_crtc *crtc;
[ ... ]
drivers/gpu/drm/sysfb/simpledrm.c static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, · line 725
Quoted 12 lines
drivers/gpu/drm/sysfb/simpledrm.c +8
-0@@ -713,6 +715,14 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, } stride = pitch; } +if (check_mul_overflow (height, stride, &size)) { +drm_err (dev,"framebuffer size exceeds maximum\n" ); +return ERR_PTR (-EINVAL ); + } +if (ALIGN (size,PAGE_SIZE ) <PAGE_SIZE ) { +drm_err (dev,"page-aligned framebuffer exceeds maximum\n" ); +return ERR_PTR (-EINVAL ); + }
[Severity: Medium]
Are these overflow checks functioning as intended?
Looking at simpledrm_device_create() in drivers/gpu/drm/sysfb/simpledrm.c, height and stride are 32-bit integers while size is a u64. Their maximum possible product (~1.4e14) easily fits into size (~1.8e19), meaning check_mul_overflow() mathematically cannot overflow here.
Additionally, the alignment check ALIGN(size, PAGE_SIZE) < PAGE_SIZE only evaluates to true if size == 0. Since both height and stride are guaranteed to be strictly greater than 0 by earlier validation, size cannot be 0. As a u64, the PAGE_SIZE alignment cannot wrap around, making this check dead code.
Quoted 3 lines
drivers/gpu/drm/sysfb/simpledrm.c +0
-0sysfb->fb_mode =drm_sysfb_mode (width, height, width_mm, height_mm); sysfb->fb_format = format;
[ ... ]
drivers/gpu/drm/sysfb/simpledrm.c static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, · line 757
Quoted 11 lines
drivers/gpu/drm/sysfb/simpledrm.c +7
-0@@ -738,6 +748,13 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,drm_dbg (dev,"using system memory framebuffer at %pr\n" , mem); +if (size >resource_size (mem)) { +drm_err (dev, +"framebuffer size of %llu exceeds memory range %pr\n" , + size, mem); +return ERR_PTR (-EINVAL ); + } +
[Severity: High]
This isn't a bug introduced by this patch, but does the size calculation allow out-of-bounds writes if the device tree provides an artificially small stride?
Looking at simpledrm_device_create() in drivers/gpu/drm/sysfb/simpledrm.c, if stride is provided explicitly by the device tree, it is never validated against the minimum required pitch (width * bytes_per_pixel). A buggy or malicious device tree could provide a stride of 1, resulting in an artificially small computed size that easily passes this new size > resource_size(mem) check.
During atomic updates, DRM shadow plane blitting functions like drm_fb_memcpy() copy width * bytes_per_pixel bytes per row. The total memory offset accessed would reach:
(height - 1) * stride + width * bytes_per_pixel
With an artificially small stride, this could greatly exceed the validated size and mapped resource_size(mem), leading to an out-of-bounds write into kernel or I/O memory.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Thomas Zimmermann
maintainerPATCH v3 6/7 drm/of: Implement drm_of_get_panel_orientation()
In reply to Thomas ZimmermannImplement drm_of_get_panel_orientation() to retrieve a panel's rotation property as enum drm_panel_orientation. The code has been taken from of_drm_get_panel_orientation(), so convert that helper over. Callers of the old helper can be converted as well.
--- drivers/gpu/drm/drm_of.c | 44 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 26 ++-------------------- include/drm/drm_of.h | 11 ++++++++++ 3 files changed, 57 insertions(+), 24 deletions(-)
drivers/gpu/drm/drm_of.c +44 -0
@@ -7,6 +7,7 @@#include <linux/of_graph.h> #include <drm/drm_bridge.h> +#include <drm/drm_connector.h> #include <drm/drm_crtc.h> #include <drm/drm_device.h> #include <drm/drm_encoder.h>
@@ -220,6 +221,49 @@ int drm_of_encoder_active_endpoint(struct device_node *node, }EXPORT_SYMBOL_GPL (drm_of_encoder_active_endpoint); +/** +* drm_of_get_panel_orientation - look up the orientation of the panel through +* the "rotation" binding from a device tree node +* @np: device tree node of the panel +* @orientation: orientation enum to be filled in +* +* Looks up the rotation of a panel in the device tree. The orientation of the +* panel is expressed as a property name "rotation" in the device tree. The +* rotation in the device tree is counter clockwise. +* +* Return: 0 when a valid rotation value (0, 90, 180, or 270) is read or the +* rotation property doesn't exist. Return a negative error code on failure. +*/ +int drm_of_get_panel_orientation (const struct device_node *np, +enum drm_panel_orientation *orientation) +{ +int rotation, ret; + + ret =of_property_read_u32 (np,"rotation" , &rotation); +if (ret == -EINVAL ) { +/* Don't return an error if there's no rotation property. */ + *orientation =DRM_MODE_PANEL_ORIENTATION_UNKNOWN ; +return 0 ; + } + +if (ret <0 ) +return ret; + +if (rotation ==0 ) + *orientation =DRM_MODE_PANEL_ORIENTATION_NORMAL ; +else if (rotation ==90 ) + *orientation =DRM_MODE_PANEL_ORIENTATION_RIGHT_UP ; +else if (rotation ==180 ) + *orientation =DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP ; +else if (rotation ==270 ) + *orientation =DRM_MODE_PANEL_ORIENTATION_LEFT_UP ; +else +return -EINVAL ; + +return 0 ; +} +EXPORT_SYMBOL_GPL (drm_of_get_panel_orientation); +/** * drm_of_find_panel_or_bridge - return connected panel or bridge device * @np: device tree node containing encoder output ports
drivers/gpu/drm/drm_panel.c +2 -24
@@ -28,6 +28,7 @@#include <linux/of.h> #include <drm/drm_crtc.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <drm/drm_print.h>
@@ -508,30 +509,7 @@ EXPORT_SYMBOL(of_drm_find_panel);int of_drm_get_panel_orientation (const struct device_node *np,enum drm_panel_orientation *orientation) { -int rotation, ret; - - ret =of_property_read_u32 (np,"rotation" , &rotation); -if (ret == -EINVAL ) { -/* Don't return an error if there's no rotation property. */ - *orientation =DRM_MODE_PANEL_ORIENTATION_UNKNOWN ; -return 0 ; - } - -if (ret <0 ) -return ret; - -if (rotation ==0 ) - *orientation =DRM_MODE_PANEL_ORIENTATION_NORMAL ; -else if (rotation ==90 ) - *orientation =DRM_MODE_PANEL_ORIENTATION_RIGHT_UP ; -else if (rotation ==180 ) - *orientation =DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP ; -else if (rotation ==270 ) - *orientation =DRM_MODE_PANEL_ORIENTATION_LEFT_UP ; -else -return -EINVAL ; - -return 0 ; +return drm_of_get_panel_orientation (np, orientation); }EXPORT_SYMBOL (of_drm_get_panel_orientation);#endif
include/drm/drm_of.h +11 -0
@@ -20,6 +20,8 @@ struct device_node;struct mipi_dsi_device_info ;struct mipi_dsi_host ; +enum drm_panel_orientation ; +/** * enum drm_lvds_dual_link_pixels - Pixel order of an LVDS dual-link connection * @DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS: Even pixels are expected to be generated
@@ -47,6 +49,8 @@ int drm_of_component_probe(struct device *dev,int drm_of_encoder_active_endpoint (struct device_node *node,struct drm_encoder *encoder,struct of_endpoint *endpoint); +int drm_of_get_panel_orientation (const struct device_node *np, +enum drm_panel_orientation *orientation); int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel,
@@ -101,6 +105,13 @@ static inline int drm_of_encoder_active_endpoint(struct device_node *node, {return -EINVAL ; } + +static inline int drm_of_get_panel_orientation (const struct device_node *np, +enum drm_panel_orientation *orientation) +{ +return -EINVAL ; +} + static inline int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel,
Signature · 1 line
2.54.0
Re: [PATCH v3 6/7] drm/of: Implement drm_of_get_panel_orientation()
Quoted 11 lines · Thomas Zimmermann
Implement
drm_of_get_panel_orientation()to retrieve a panel's rotation property as enumdrm_panel_orientation. The code has been taken fromof_drm_get_panel_orientation(), so convert that helper over. Callers of the old helper can be converted as well.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/drm_of.c | 44 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 26 ++-------------------- include/drm/drm_of.h | 11 ++++++++++ 3 files changed, 57 insertions(+), 24 deletions(-)
So you're effectively renaming of_drm_get_panel_orientation() to drm_of_get_panel_orientation(), while moving it to drm_of.c, and then you keep of_drm_get_panel_orientation() as an alias.
I don't understand the use of this. Maybe if we really need to move this out of drm_panel.c to make it more widely available, fine. Maybe we also want the drm_of_ prefix instead of of_drm_, also fine, I suppose. But in that case we should just go ahead and update all callers of the old helper and get rid of it while we're at it. No use in keeping around aliases/duplicates.
I've attached a patch to do just that. Feel free to integrate it into the series, or we can apply after your series is merged.
Thierry
From 2aabb20fd3c8666fd9a8635e28cf6e398de7e717 Mon Sep 17 00:00:00 2001
From: Thierry Reding <[email protected]>
Date: Mon, 29 Jun 2026 14:23:27 +0200
Subject: [PATCH] drm/panel: Use drm_of_get_panel_orientation()
The old of_drm_get_panel_orientation() function was replaced by the drm_of_get_panel_orientation() in the core DRM OF helpers. Replace all uses of the old helper and remove it.
--- drivers/gpu/drm/drm_panel.c | 20 ------------------- .../drm/panel/panel-boe-th101mb31ig002-28a.c | 2 +- .../gpu/drm/panel/panel-boe-tv101wum-nl6.c | 2 +- .../gpu/drm/panel/panel-chipwealth-ch13726a.c | 2 +- drivers/gpu/drm/panel/panel-edp.c | 2 +- drivers/gpu/drm/panel/panel-elida-kd35t133.c | 2 +- .../gpu/drm/panel/panel-focaltech-ota7290b.c | 2 +- drivers/gpu/drm/panel/panel-himax-hx83102.c | 2 +- drivers/gpu/drm/panel/panel-himax-hx8394.c | 2 +- .../gpu/drm/panel/panel-ilitek-ili9806e-dsi.c | 2 +- drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 2 +- drivers/gpu/drm/panel/panel-ilitek-ili9882t.c | 2 +- .../gpu/drm/panel/panel-jadard-jd9365da-h3.c | 2 +- drivers/gpu/drm/panel/panel-lvds.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt36523.c | 2 +- drivers/gpu/drm/panel/panel-simple.c | 2 +- drivers/gpu/drm/panel/panel-sitronix-st7701.c | 2 +- drivers/gpu/drm/panel/panel-sitronix-st7703.c | 2 +- .../gpu/drm/panel/panel-sitronix-st7789v.c | 2 +- include/drm/drm_panel.h | 8 -------- 20 files changed, 18 insertions(+), 46 deletions(-)
drivers/gpu/drm/drm_panel.c +0 -20
@@ -492,26 +492,6 @@ struct drm_panel *of_drm_find_panel(const struct device_node *np) return ERR_PTR(-EPROBE_DEFER); }EXPORT_SYMBOL (of_drm_find_panel); - -/** -* of_drm_get_panel_orientation - look up the orientation of the panel through -* the "rotation" binding from a device tree node -* @np: device tree node of the panel -* @orientation: orientation enum to be filled in -* -* Looks up the rotation of a panel in the device tree. The orientation of the -* panel is expressed as a property name "rotation" in the device tree. The -* rotation in the device tree is counter clockwise. -* -* Return: 0 when a valid rotation value (0, 90, 180, or 270) is read or the -* rotation property doesn't exist. Return a negative error code on failure. -*/ -int of_drm_get_panel_orientation (const struct device_node *np, -enum drm_panel_orientation *orientation) -{ -return drm_of_get_panel_orientation (np, orientation); -} -EXPORT_SYMBOL (of_drm_get_panel_orientation);#endif /* Find panel by fwnode. This should be identical to of_drm_find_panel(). */
drivers/gpu/drm/panel/panel-boe-th101mb31ig002-28a.c +1 -1
@@ -380,7 +380,7 @@ static int boe_th101mb31ig002_dsi_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (ctx->reset),"Failed to get reset GPIO\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret) return dev_err_probe(&dsi->dev, ret,
drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c +1 -1
@@ -1722,7 +1722,7 @@ static int boe_panel_add(struct boe_panel *boe) boe->base.prepare_prev_first = true; - err =of_drm_get_panel_orientation (dev->of_node, &boe->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &boe->orientation);if (err <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return err;
drivers/gpu/drm/panel/panel-chipwealth-ch13726a.c +1 -1
@@ -268,7 +268,7 @@ static int ch13726a_probe(struct mipi_dsi_device *dsi)return dev_err_probe (dev,PTR_ERR (ctx->reset_gpio),"Failed to get reset-gpios\n" ); - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;
drivers/gpu/drm/panel/panel-edp.c +1 -1
@@ -865,7 +865,7 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,return dev_err_probe (dev,PTR_ERR (panel->enable_gpio),"failed to request GPIO\n" ); - err =of_drm_get_panel_orientation (dev->of_node, &panel->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &panel->orientation);if (err) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return err;
drivers/gpu/drm/panel/panel-elida-kd35t133.c +1 -1
@@ -233,7 +233,7 @@ static int kd35t133_probe(struct mipi_dsi_device *dsi)return ret; } - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;
drivers/gpu/drm/panel/panel-focaltech-ota7290b.c +1 -1
@@ -181,7 +181,7 @@ static int ota7290b_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (ctx->vdd),"Couldn't get our VDD supply\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret) {dev_err (&dsi->dev,"%pOF: failed to get orientation: %d\n" , dsi->dev.of_node, ret);
drivers/gpu/drm/panel/panel-himax-hx83102.c +1 -1
@@ -1264,7 +1264,7 @@ static int hx83102_panel_add(struct hx83102 *ctx) ctx->base.prepare_prev_first = true; - err =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (err <0 )return dev_err_probe (dev, err,"failed to get orientation\n" );
drivers/gpu/drm/panel/panel-himax-hx8394.c +1 -1
@@ -992,7 +992,7 @@ static int hx8394_probe(struct mipi_dsi_device *dsi)return dev_err_probe (dev,PTR_ERR (ctx->reset_gpio),"Failed to get reset gpio\n" ); - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;
drivers/gpu/drm/panel/panel-ilitek-ili9806e-dsi.c +1 -1
@@ -132,7 +132,7 @@ static int ili9806e_dsi_probe(struct mipi_dsi_device *dsi) dsi->format = ctx->desc->format; dsi->lanes = ctx->desc->lanes; - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret)return dev_err_probe (dev, ret,"Failed to get orientation\n" );
drivers/gpu/drm/panel/panel-ilitek-ili9881c.c +1 -1
@@ -2571,7 +2571,7 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (ctx->reset),"Couldn't get our reset GPIO\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret) {dev_err (&dsi->dev,"%pOF: failed to get orientation: %d\n" , dsi->dev.of_node, ret);
drivers/gpu/drm/panel/panel-ilitek-ili9882t.c +1 -1
@@ -795,7 +795,7 @@ static int ili9882t_add(struct ili9882t *ili)gpiod_set_value_cansleep (ili->enable_gpio,0 ); - err =of_drm_get_panel_orientation (dev->of_node, &ili->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &ili->orientation);if (err <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return err;
drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c +1 -1
@@ -2992,7 +2992,7 @@ static int jadard_dsi_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (jadard->vccio),"failed to get vccio regulator\n" ); - ret =of_drm_get_panel_orientation (dev->of_node, &jadard->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &jadard->orientation);if (ret <0 )return dev_err_probe (dev, ret,"failed to get orientation\n" );
drivers/gpu/drm/panel/panel-lvds.c +1 -1
@@ -126,7 +126,7 @@ static int panel_lvds_parse_dt(struct panel_lvds *lvds)struct device_node *np = lvds->dev->of_node;int ret; - ret =of_drm_get_panel_orientation (np, &lvds->orientation); + ret =drm_of_get_panel_orientation (np, &lvds->orientation);if (ret <0 ) {dev_err (lvds->dev,"%pOF: failed to get orientation %d\n" , np, ret);return ret;
drivers/gpu/drm/panel/panel-novatek-nt36523.c +1 -1
@@ -1206,7 +1206,7 @@ static int nt36523_probe(struct mipi_dsi_device *dsi) pinfo->dsi[0 ] = dsi;mipi_dsi_set_drvdata (dsi, pinfo); - ret =of_drm_get_panel_orientation (dev->of_node, &pinfo->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &pinfo->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;
drivers/gpu/drm/panel/panel-simple.c +1 -1
@@ -693,7 +693,7 @@ static struct panel_simple *panel_simple_probe(struct device *dev)return dev_err_cast_probe (dev, panel->enable_gpio,"failed to request GPIO\n" ); - err =of_drm_get_panel_orientation (dev->of_node, &panel->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &panel->orientation);if (err) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return ERR_PTR (err);
drivers/gpu/drm/panel/panel-sitronix-st7701.c +1 -1
@@ -1296,7 +1296,7 @@ static int st7701_probe(struct device *dev, int connector_type)return PTR_ERR (st7701->reset); } - ret =of_drm_get_panel_orientation (dev->of_node, &st7701->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &st7701->orientation);if (ret <0 )return dev_err_probe (dev, ret,"Failed to get orientation\n" );
drivers/gpu/drm/panel/panel-sitronix-st7703.c +1 -1
@@ -874,7 +874,7 @@ static int st7703_probe(struct mipi_dsi_device *dsi)return dev_err_probe (dev,PTR_ERR (ctx->iovcc),"Failed to request iovcc regulator\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret <0 )return dev_err_probe (&dsi->dev, ret,"Failed to get orientation\n" );
drivers/gpu/drm/panel/panel-sitronix-st7789v.c +1 -1
@@ -646,7 +646,7 @@ static int st7789v_probe(struct spi_device *spi)if (ret)return dev_err_probe (dev, ret,"Failed to get backlight\n" ); - ret =of_drm_get_panel_orientation (spi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (spi->dev.of_node, &ctx->orientation);if (ret)return dev_err_probe (&spi->dev, ret,"Failed to get orientation\n" );
include/drm/drm_panel.h +0 -8
@@ -337,19 +337,11 @@ int drm_panel_get_modes(struct drm_panel *panel, struct drm_connector *connector#if defined(CONFIG_OF ) && defined(CONFIG_DRM_PANEL )struct drm_panel *of_drm_find_panel (const struct device_node *np); -int of_drm_get_panel_orientation (const struct device_node *np, -enum drm_panel_orientation *orientation);#else static inline struct drm_panel *of_drm_find_panel (const struct device_node *np) {return ERR_PTR (-ENODEV ); } - -static inline int of_drm_get_panel_orientation (const struct device_node *np, -enum drm_panel_orientation *orientation) -{ -return -ENODEV ; -}#endif #if defined(CONFIG_DRM_PANEL )
Signature · 1 line
2.54.0
Thomas Zimmermann
maintainerRe: [PATCH v3 6/7] drm/of: Implement drm_of_get_panel_orientation()
Hi
Am 29.06.26 um 14:27 schrieb Thierry Reding:
Quoted 16 lines · Thomas Zimmermann
Quoted 11 lines
Implement
drm_of_get_panel_orientation()to retrieve a panel's rotation property as enumdrm_panel_orientation. The code has been taken fromof_drm_get_panel_orientation(), so convert that helper over. Callers of the old helper can be converted as well.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/drm_of.c | 44 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 26 ++-------------------- include/drm/drm_of.h | 11 ++++++++++ 3 files changed, 57 insertions(+), 24 deletions(-)So you're effectively renaming
of_drm_get_panel_orientation()todrm_of_get_panel_orientation(), while moving it todrm_of.c, and then you keepof_drm_get_panel_orientation()as an alias.
Quoted 6 lines
I don't understand the use of this. Maybe if we really need to move this out of
drm_panel.cto make it more widely available, fine. Maybe we also want thedrm_of_prefix instead ofof_drm_, also fine, I suppose. But in that case we should just go ahead and update all callers of the old helper and get rid of it while we're at it. No use in keeping around aliases/duplicates.
I'm all for it. i though this would be a different issue.
Quoted 3 lines
I've attached a patch to do just that. Feel free to integrate it into the series, or we can apply after your series is merged.
Thanks.
Let me split of the first 5 patches in series and merge them. They are the fixes and hardening patches and seem ready to be merged. I'll prepare a separate series for the panel orientation with your changes and it can go in separately. If we touch all the panel drivers, we should make sure that the panel maintainers get another chance of looking over it.
Best regards
Thomas
Quoted 325 lines
Thierry
From
2aabb20fd3c8666fd9a8635e28cf6e398de7e717Mon Sep 17 00:00:00 2001
From: Thierry Reding <[email protected]>
Date: Mon, 29 Jun 2026 14:23:27 +0200
Subject: [PATCH] drm/panel: Usedrm_of_get_panel_orientation()The old
of_drm_get_panel_orientation()function was replaced by thedrm_of_get_panel_orientation()in the core DRM OF helpers. Replace all uses of the old helper and remove it.Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/drm_panel.c | 20 ------------------- .../drm/panel/panel-boe-th101mb31ig002-28a.c | 2 +- .../gpu/drm/panel/panel-boe-tv101wum-nl6.c | 2 +- .../gpu/drm/panel/panel-chipwealth-ch13726a.c | 2 +- drivers/gpu/drm/panel/panel-edp.c | 2 +- drivers/gpu/drm/panel/panel-elida-kd35t133.c | 2 +- .../gpu/drm/panel/panel-focaltech-ota7290b.c | 2 +- drivers/gpu/drm/panel/panel-himax-hx83102.c | 2 +- drivers/gpu/drm/panel/panel-himax-hx8394.c | 2 +- .../gpu/drm/panel/panel-ilitek-ili9806e-dsi.c | 2 +- drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 2 +- drivers/gpu/drm/panel/panel-ilitek-ili9882t.c | 2 +- .../gpu/drm/panel/panel-jadard-jd9365da-h3.c | 2 +- drivers/gpu/drm/panel/panel-lvds.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt36523.c | 2 +- drivers/gpu/drm/panel/panel-simple.c | 2 +- drivers/gpu/drm/panel/panel-sitronix-st7701.c | 2 +- drivers/gpu/drm/panel/panel-sitronix-st7703.c | 2 +- .../gpu/drm/panel/panel-sitronix-st7789v.c | 2 +- include/drm/drm_panel.h | 8 -------- 20 files changed, 18 insertions(+), 46 deletions(-)drivers/gpu/drm/drm_panel.c +0
-20@@ -492,26 +492,6 @@ struct drm_panel *of_drm_find_panel(const struct device_node *np) return ERR_PTR(-EPROBE_DEFER); }EXPORT_SYMBOL (of_drm_find_panel); - -/** -* of_drm_get_panel_orientation - look up the orientation of the panel through -* the "rotation" binding from a device tree node -* @np: device tree node of the panel -* @orientation: orientation enum to be filled in -* -* Looks up the rotation of a panel in the device tree. The orientation of the -* panel is expressed as a property name "rotation" in the device tree. The -* rotation in the device tree is counter clockwise. -* -* Return: 0 when a valid rotation value (0, 90, 180, or 270) is read or the -* rotation property doesn't exist. Return a negative error code on failure. -*/ -int of_drm_get_panel_orientation (const struct device_node *np, -enum drm_panel_orientation *orientation) -{ -return drm_of_get_panel_orientation (np, orientation); -} -EXPORT_SYMBOL (of_drm_get_panel_orientation);#endif /* Find panel by fwnode. This should be identical to of_drm_find_panel(). */ drivers/gpu/drm/panel/panel-boe-th101mb31ig002-28a.c +1
-1@@ -380,7 +380,7 @@ static int boe_th101mb31ig002_dsi_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (ctx->reset),"Failed to get reset GPIO\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret) return dev_err_probe(&dsi->dev, ret,drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c +1
-1@@ -1722,7 +1722,7 @@ static int boe_panel_add(struct boe_panel *boe) boe->base.prepare_prev_first = true; - err =of_drm_get_panel_orientation (dev->of_node, &boe->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &boe->orientation);if (err <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return err;drivers/gpu/drm/panel/panel-chipwealth-ch13726a.c +1
-1@@ -268,7 +268,7 @@ static int ch13726a_probe(struct mipi_dsi_device *dsi)return dev_err_probe (dev,PTR_ERR (ctx->reset_gpio),"Failed to get reset-gpios\n" ); - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;drivers/gpu/drm/panel/panel-edp.c +1
-1@@ -865,7 +865,7 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,return dev_err_probe (dev,PTR_ERR (panel->enable_gpio),"failed to request GPIO\n" ); - err =of_drm_get_panel_orientation (dev->of_node, &panel->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &panel->orientation);if (err) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return err;drivers/gpu/drm/panel/panel-elida-kd35t133.c +1
-1@@ -233,7 +233,7 @@ static int kd35t133_probe(struct mipi_dsi_device *dsi)return ret; } - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;drivers/gpu/drm/panel/panel-focaltech-ota7290b.c +1
-1@@ -181,7 +181,7 @@ static int ota7290b_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (ctx->vdd),"Couldn't get our VDD supply\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret) {dev_err (&dsi->dev,"%pOF: failed to get orientation: %d\n" , dsi->dev.of_node, ret);drivers/gpu/drm/panel/panel-himax-hx83102.c +1
-1@@ -1264,7 +1264,7 @@ static int hx83102_panel_add(struct hx83102 *ctx) ctx->base.prepare_prev_first = true; - err =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (err <0 )return dev_err_probe (dev, err,"failed to get orientation\n" );drivers/gpu/drm/panel/panel-himax-hx8394.c +1
-1@@ -992,7 +992,7 @@ static int hx8394_probe(struct mipi_dsi_device *dsi)return dev_err_probe (dev,PTR_ERR (ctx->reset_gpio),"Failed to get reset gpio\n" ); - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;drivers/gpu/drm/panel/panel-ilitek-ili9806e-dsi.c +1
-1@@ -132,7 +132,7 @@ static int ili9806e_dsi_probe(struct mipi_dsi_device *dsi) dsi->format = ctx->desc->format; dsi->lanes = ctx->desc->lanes; - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret)return dev_err_probe (dev, ret,"Failed to get orientation\n" );drivers/gpu/drm/panel/panel-ilitek-ili9881c.c +1
-1@@ -2571,7 +2571,7 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (ctx->reset),"Couldn't get our reset GPIO\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret) {dev_err (&dsi->dev,"%pOF: failed to get orientation: %d\n" , dsi->dev.of_node, ret);drivers/gpu/drm/panel/panel-ilitek-ili9882t.c +1
-1@@ -795,7 +795,7 @@ static int ili9882t_add(struct ili9882t *ili)gpiod_set_value_cansleep (ili->enable_gpio,0 ); - err =of_drm_get_panel_orientation (dev->of_node, &ili->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &ili->orientation);if (err <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return err;drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c +1
-1@@ -2992,7 +2992,7 @@ static int jadard_dsi_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (jadard->vccio),"failed to get vccio regulator\n" ); - ret =of_drm_get_panel_orientation (dev->of_node, &jadard->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &jadard->orientation);if (ret <0 )return dev_err_probe (dev, ret,"failed to get orientation\n" );drivers/gpu/drm/panel/panel-lvds.c +1
-1@@ -126,7 +126,7 @@ static int panel_lvds_parse_dt(struct panel_lvds *lvds)struct device_node *np = lvds->dev->of_node;int ret; - ret =of_drm_get_panel_orientation (np, &lvds->orientation); + ret =drm_of_get_panel_orientation (np, &lvds->orientation);if (ret <0 ) {dev_err (lvds->dev,"%pOF: failed to get orientation %d\n" , np, ret);return ret;drivers/gpu/drm/panel/panel-novatek-nt36523.c +1
-1@@ -1206,7 +1206,7 @@ static int nt36523_probe(struct mipi_dsi_device *dsi) pinfo->dsi[0 ] = dsi;mipi_dsi_set_drvdata (dsi, pinfo); - ret =of_drm_get_panel_orientation (dev->of_node, &pinfo->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &pinfo->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;drivers/gpu/drm/panel/panel-simple.c +1
-1@@ -693,7 +693,7 @@ static struct panel_simple *panel_simple_probe(struct device *dev)return dev_err_cast_probe (dev, panel->enable_gpio,"failed to request GPIO\n" ); - err =of_drm_get_panel_orientation (dev->of_node, &panel->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &panel->orientation);if (err) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return ERR_PTR (err);drivers/gpu/drm/panel/panel-sitronix-st7701.c +1
-1@@ -1296,7 +1296,7 @@ static int st7701_probe(struct device *dev, int connector_type)return PTR_ERR (st7701->reset); } - ret =of_drm_get_panel_orientation (dev->of_node, &st7701->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &st7701->orientation);if (ret <0 )return dev_err_probe (dev, ret,"Failed to get orientation\n" );drivers/gpu/drm/panel/panel-sitronix-st7703.c +1
-1@@ -874,7 +874,7 @@ static int st7703_probe(struct mipi_dsi_device *dsi)return dev_err_probe (dev,PTR_ERR (ctx->iovcc),"Failed to request iovcc regulator\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret <0 )return dev_err_probe (&dsi->dev, ret,"Failed to get orientation\n" );drivers/gpu/drm/panel/panel-sitronix-st7789v.c +1
-1@@ -646,7 +646,7 @@ static int st7789v_probe(struct spi_device *spi)if (ret)return dev_err_probe (dev, ret,"Failed to get backlight\n" ); - ret =of_drm_get_panel_orientation (spi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (spi->dev.of_node, &ctx->orientation);if (ret)return dev_err_probe (&spi->dev, ret,"Failed to get orientation\n" );include/drm/drm_panel.h +0
-8@@ -337,19 +337,11 @@ int drm_panel_get_modes(struct drm_panel *panel, struct drm_connector *connector#if defined(CONFIG_OF ) && defined(CONFIG_DRM_PANEL )struct drm_panel *of_drm_find_panel (const struct device_node *np); -int of_drm_get_panel_orientation (const struct device_node *np, -enum drm_panel_orientation *orientation);#else static inline struct drm_panel *of_drm_find_panel (const struct device_node *np) {return ERR_PTR (-ENODEV ); } - -static inline int of_drm_get_panel_orientation (const struct device_node *np, -enum drm_panel_orientation *orientation) -{ -return -ENODEV ; -}#endif #if defined(CONFIG_DRM_PANEL )
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
Re: [PATCH v3 6/7] drm/of: Implement drm_of_get_panel_orientation()
Quoted 19 lines · Thomas Zimmermann
Hi
Am 29.06.26 um 14:27 schrieb Thierry Reding:
Quoted 16 lines · Thomas Zimmermann
Quoted 11 lines
Implement
drm_of_get_panel_orientation()to retrieve a panel's rotation property as enumdrm_panel_orientation. The code has been taken fromof_drm_get_panel_orientation(), so convert that helper over. Callers of the old helper can be converted as well.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/drm_of.c | 44 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 26 ++-------------------- include/drm/drm_of.h | 11 ++++++++++ 3 files changed, 57 insertions(+), 24 deletions(-)So you're effectively renaming
of_drm_get_panel_orientation()todrm_of_get_panel_orientation(), while moving it todrm_of.c, and then you keepof_drm_get_panel_orientation()as an alias.
Quoted 8 lines
Quoted 6 lines
I don't understand the use of this. Maybe if we really need to move this out of
drm_panel.cto make it more widely available, fine. Maybe we also want thedrm_of_prefix instead ofof_drm_, also fine, I suppose. But in that case we should just go ahead and update all callers of the old helper and get rid of it while we're at it. No use in keeping around aliases/duplicates.I'm all for it. i though this would be a different issue.
Yeah, understandably. Can't always do everything within one series. In this case it seems fairly simple to do and we're early in the release cycle, so there shouldn't be too much in terms of conflicts or new users yet, so seems like an opportune time.
Quoted 11 lines
Quoted 3 lines
I've attached a patch to do just that. Feel free to integrate it into the series, or we can apply after your series is merged.
Thanks.
Let me split of the first 5 patches in series and merge them. They are the fixes and hardening patches and seem ready to be merged. I'll prepare a separate series for the panel orientation with your changes and it can go in separately. If we touch all the panel drivers, we should make sure that the panel maintainers get another chance of looking over it.
I think I'll need to send a new version which explicitly includes drm_of.h for all the panels that use the new function. My build tests were missing some drivers and others include the file implicitly via some other headers.
Not sure if maintainers really need to look at these since it's literally just switching out the of_drm prefix for drm_of, but yeah, can't hurt to send out a series for review.
Thierry
Re: [PATCH v3 6/7] drm/of: Implement drm_of_get_panel_orientation()
In reply to Thomas ZimmermannQuoted 32 lines · Thomas Zimmermann
Hi
Am 29.06.26 um 14:27 schrieb Thierry Reding:
Quoted 16 lines · Thomas Zimmermann
Quoted 11 lines
Implement
drm_of_get_panel_orientation()to retrieve a panel's rotation property as enumdrm_panel_orientation. The code has been taken fromof_drm_get_panel_orientation(), so convert that helper over. Callers of the old helper can be converted as well.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/drm_of.c | 44 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 26 ++-------------------- include/drm/drm_of.h | 11 ++++++++++ 3 files changed, 57 insertions(+), 24 deletions(-)So you're effectively renaming
of_drm_get_panel_orientation()todrm_of_get_panel_orientation(), while moving it todrm_of.c, and then you keepof_drm_get_panel_orientation()as an alias.Quoted 6 lines
I don't understand the use of this. Maybe if we really need to move this out of
drm_panel.cto make it more widely available, fine. Maybe we also want thedrm_of_prefix instead ofof_drm_, also fine, I suppose. But in that case we should just go ahead and update all callers of the old helper and get rid of it while we're at it. No use in keeping around aliases/duplicates.I'm all for it. i though this would be a different issue.
Quoted 3 lines
I've attached a patch to do just that. Feel free to integrate it into the series, or we can apply after your series is merged.
Quoted 7 lines
Thanks.
Let me split of the first 5 patches in series and merge them. They are the fixes and hardening patches and seem ready to be merged. I'll prepare a separate series for the panel orientation with your changes and it can go in separately. If we touch all the panel drivers, we should make sure that the panel maintainers get another chance of looking over it.
Here's the updated patch with all the modified drivers build-tested and checked that the build covers all of them.
Thierry
From 31901850ebf521afc0b24bc90e97dd4af660df9b Mon Sep 17 00:00:00 2001
From: Thierry Reding <[email protected]>
Date: Mon, 29 Jun 2026 14:23:27 +0200
Subject: [PATCH v2] drm/panel: Use drm_of_get_panel_orientation()
The old of_drm_get_panel_orientation() function was replaced by the drm_of_get_panel_orientation() in the core DRM OF helpers. Replace all uses of the old helper and remove it.
Changes in v2:
- include drm_of.h in all drivers to make sure the new symbol is defined
--- drivers/gpu/drm/drm_panel.c | 20 ------------------- .../drm/panel/panel-boe-th101mb31ig002-28a.c | 3 ++- .../gpu/drm/panel/panel-boe-tv101wum-nl6.c | 3 ++- .../gpu/drm/panel/panel-chipwealth-ch13726a.c | 3 ++- drivers/gpu/drm/panel/panel-edp.c | 3 ++- drivers/gpu/drm/panel/panel-elida-kd35t133.c | 3 ++- .../gpu/drm/panel/panel-focaltech-ota7290b.c | 3 ++- drivers/gpu/drm/panel/panel-himax-hx83102.c | 3 ++- drivers/gpu/drm/panel/panel-himax-hx8394.c | 3 ++- .../gpu/drm/panel/panel-ilitek-ili9806e-dsi.c | 3 ++- drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 3 ++- drivers/gpu/drm/panel/panel-ilitek-ili9882t.c | 3 ++- .../gpu/drm/panel/panel-jadard-jd9365da-h3.c | 2 +- drivers/gpu/drm/panel/panel-lvds.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt36523.c | 3 ++- drivers/gpu/drm/panel/panel-simple.c | 2 +- drivers/gpu/drm/panel/panel-sitronix-st7701.c | 3 ++- drivers/gpu/drm/panel/panel-sitronix-st7703.c | 3 ++- .../gpu/drm/panel/panel-sitronix-st7789v.c | 3 ++- include/drm/drm_panel.h | 8 -------- 20 files changed, 33 insertions(+), 46 deletions(-)
drivers/gpu/drm/drm_panel.c +0 -20
@@ -492,26 +492,6 @@ struct drm_panel *of_drm_find_panel(const struct device_node *np) return ERR_PTR(-EPROBE_DEFER); }EXPORT_SYMBOL (of_drm_find_panel); - -/** -* of_drm_get_panel_orientation - look up the orientation of the panel through -* the "rotation" binding from a device tree node -* @np: device tree node of the panel -* @orientation: orientation enum to be filled in -* -* Looks up the rotation of a panel in the device tree. The orientation of the -* panel is expressed as a property name "rotation" in the device tree. The -* rotation in the device tree is counter clockwise. -* -* Return: 0 when a valid rotation value (0, 90, 180, or 270) is read or the -* rotation property doesn't exist. Return a negative error code on failure. -*/ -int of_drm_get_panel_orientation (const struct device_node *np, -enum drm_panel_orientation *orientation) -{ -return drm_of_get_panel_orientation (np, orientation); -} -EXPORT_SYMBOL (of_drm_get_panel_orientation);#endif /* Find panel by fwnode. This should be identical to of_drm_find_panel(). */
drivers/gpu/drm/panel/panel-boe-th101mb31ig002-28a.c +2 -1
@@ -15,6 +15,7 @@#include <drm/drm_connector.h> #include <drm/drm_mipi_dsi.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <drm/drm_probe_helper.h>
@@ -380,7 +381,7 @@ static int boe_th101mb31ig002_dsi_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (ctx->reset),"Failed to get reset GPIO\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret) return dev_err_probe(&dsi->dev, ret,
drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c +2 -1
@@ -13,6 +13,7 @@#include <drm/drm_connector.h> #include <drm/drm_crtc.h> #include <drm/drm_mipi_dsi.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <video/mipi_display.h>
@@ -1722,7 +1723,7 @@ static int boe_panel_add(struct boe_panel *boe) boe->base.prepare_prev_first = true; - err =of_drm_get_panel_orientation (dev->of_node, &boe->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &boe->orientation);if (err <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return err;
drivers/gpu/drm/panel/panel-chipwealth-ch13726a.c +2 -1
@@ -13,6 +13,7 @@#include <drm/drm_mipi_dsi.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <video/mipi_display.h>
@@ -268,7 +269,7 @@ static int ch13726a_probe(struct mipi_dsi_device *dsi)return dev_err_probe (dev,PTR_ERR (ctx->reset_gpio),"Failed to get reset-gpios\n" ); - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;
drivers/gpu/drm/panel/panel-edp.c +2 -1
@@ -40,6 +40,7 @@#include <drm/drm_crtc.h> #include <drm/drm_device.h> #include <drm/drm_edid.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> /**
@@ -865,7 +866,7 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,return dev_err_probe (dev,PTR_ERR (panel->enable_gpio),"failed to request GPIO\n" ); - err =of_drm_get_panel_orientation (dev->of_node, &panel->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &panel->orientation);if (err) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return err;
drivers/gpu/drm/panel/panel-elida-kd35t133.c +2 -1
@@ -21,6 +21,7 @@#include <drm/drm_mipi_dsi.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> /* Manufacturer specific Commands send via DSI */
@@ -233,7 +234,7 @@ static int kd35t133_probe(struct mipi_dsi_device *dsi)return ret; } - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;
drivers/gpu/drm/panel/panel-focaltech-ota7290b.c +2 -1
@@ -17,6 +17,7 @@#include <drm/drm_mipi_dsi.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <drm/drm_probe_helper.h>
@@ -181,7 +182,7 @@ static int ota7290b_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (ctx->vdd),"Couldn't get our VDD supply\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret) {dev_err (&dsi->dev,"%pOF: failed to get orientation: %d\n" , dsi->dev.of_node, ret);
drivers/gpu/drm/panel/panel-himax-hx83102.c +2 -1
@@ -17,6 +17,7 @@#include <drm/drm_connector.h> #include <drm/drm_crtc.h> #include <drm/drm_mipi_dsi.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <video/mipi_display.h>
@@ -1264,7 +1265,7 @@ static int hx83102_panel_add(struct hx83102 *ctx) ctx->base.prepare_prev_first = true; - err =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (err <0 )return dev_err_probe (dev, err,"failed to get orientation\n" );
drivers/gpu/drm/panel/panel-himax-hx8394.c +2 -1
@@ -22,6 +22,7 @@#include <drm/drm_mipi_dsi.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #define DRV_NAME "panel-himax-hx8394"
@@ -992,7 +993,7 @@ static int hx8394_probe(struct mipi_dsi_device *dsi)return dev_err_probe (dev,PTR_ERR (ctx->reset_gpio),"Failed to get reset gpio\n" ); - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;
drivers/gpu/drm/panel/panel-ilitek-ili9806e-dsi.c +2 -1
@@ -10,6 +10,7 @@#include <drm/drm_mipi_dsi.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <drm/drm_probe_helper.h>
@@ -132,7 +133,7 @@ static int ili9806e_dsi_probe(struct mipi_dsi_device *dsi) dsi->format = ctx->desc->format; dsi->lanes = ctx->desc->lanes; - ret =of_drm_get_panel_orientation (dev->of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &ctx->orientation);if (ret)return dev_err_probe (dev, ret,"Failed to get orientation\n" );
drivers/gpu/drm/panel/panel-ilitek-ili9881c.c +2 -1
@@ -16,6 +16,7 @@#include <drm/drm_mipi_dsi.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <video/mipi_display.h>
@@ -2571,7 +2572,7 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (ctx->reset),"Couldn't get our reset GPIO\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret) {dev_err (&dsi->dev,"%pOF: failed to get orientation: %d\n" , dsi->dev.of_node, ret);
drivers/gpu/drm/panel/panel-ilitek-ili9882t.c +2 -1
@@ -13,6 +13,7 @@#include <drm/drm_connector.h> #include <drm/drm_crtc.h> #include <drm/drm_mipi_dsi.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <video/mipi_display.h>
@@ -795,7 +796,7 @@ static int ili9882t_add(struct ili9882t *ili)gpiod_set_value_cansleep (ili->enable_gpio,0 ); - err =of_drm_get_panel_orientation (dev->of_node, &ili->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &ili->orientation);if (err <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return err;
drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c +1 -1
@@ -2992,7 +2992,7 @@ static int jadard_dsi_probe(struct mipi_dsi_device *dsi)return dev_err_probe (&dsi->dev,PTR_ERR (jadard->vccio),"failed to get vccio regulator\n" ); - ret =of_drm_get_panel_orientation (dev->of_node, &jadard->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &jadard->orientation);if (ret <0 )return dev_err_probe (dev, ret,"failed to get orientation\n" );
drivers/gpu/drm/panel/panel-lvds.c +1 -1
@@ -126,7 +126,7 @@ static int panel_lvds_parse_dt(struct panel_lvds *lvds)struct device_node *np = lvds->dev->of_node;int ret; - ret =of_drm_get_panel_orientation (np, &lvds->orientation); + ret =drm_of_get_panel_orientation (np, &lvds->orientation);if (ret <0 ) {dev_err (lvds->dev,"%pOF: failed to get orientation %d\n" , np, ret);return ret;
drivers/gpu/drm/panel/panel-novatek-nt36523.c +2 -1
@@ -19,6 +19,7 @@#include <drm/drm_crtc.h> #include <drm/drm_mipi_dsi.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #define DSI_NUM_MIN 1
@@ -1206,7 +1207,7 @@ static int nt36523_probe(struct mipi_dsi_device *dsi) pinfo->dsi[0 ] = dsi;mipi_dsi_set_drvdata (dsi, pinfo); - ret =of_drm_get_panel_orientation (dev->of_node, &pinfo->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &pinfo->orientation);if (ret <0 ) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, ret);return ret;
drivers/gpu/drm/panel/panel-simple.c +1 -1
@@ -693,7 +693,7 @@ static struct panel_simple *panel_simple_probe(struct device *dev)return dev_err_cast_probe (dev, panel->enable_gpio,"failed to request GPIO\n" ); - err =of_drm_get_panel_orientation (dev->of_node, &panel->orientation); + err =drm_of_get_panel_orientation (dev->of_node, &panel->orientation);if (err) {dev_err (dev,"%pOF: failed to get orientation %d\n" , dev->of_node, err);return ERR_PTR (err);
drivers/gpu/drm/panel/panel-sitronix-st7701.c +2 -1
@@ -7,6 +7,7 @@#include <drm/drm_mipi_dbi.h> #include <drm/drm_mipi_dsi.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <linux/bitfield.h>
@@ -1296,7 +1297,7 @@ static int st7701_probe(struct device *dev, int connector_type)return PTR_ERR (st7701->reset); } - ret =of_drm_get_panel_orientation (dev->of_node, &st7701->orientation); + ret =drm_of_get_panel_orientation (dev->of_node, &st7701->orientation);if (ret <0 )return dev_err_probe (dev, ret,"Failed to get orientation\n" );
drivers/gpu/drm/panel/panel-sitronix-st7703.c +2 -1
@@ -21,6 +21,7 @@#include <drm/drm_mipi_dsi.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #define DRV_NAME "panel-sitronix-st7703"
@@ -874,7 +875,7 @@ static int st7703_probe(struct mipi_dsi_device *dsi)return dev_err_probe (dev,PTR_ERR (ctx->iovcc),"Failed to request iovcc regulator\n" ); - ret =of_drm_get_panel_orientation (dsi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (dsi->dev.of_node, &ctx->orientation);if (ret <0 )return dev_err_probe (&dsi->dev, ret,"Failed to get orientation\n" );
drivers/gpu/drm/panel/panel-sitronix-st7789v.c +2 -1
@@ -14,6 +14,7 @@#include <drm/drm_device.h> #include <drm/drm_modes.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #define ST7789V_RAMCTRL_CMD 0xb0
@@ -646,7 +647,7 @@ static int st7789v_probe(struct spi_device *spi)if (ret)return dev_err_probe (dev, ret,"Failed to get backlight\n" ); - ret =of_drm_get_panel_orientation (spi->dev.of_node, &ctx->orientation); + ret =drm_of_get_panel_orientation (spi->dev.of_node, &ctx->orientation);if (ret)return dev_err_probe (&spi->dev, ret,"Failed to get orientation\n" );
include/drm/drm_panel.h +0 -8
@@ -337,19 +337,11 @@ int drm_panel_get_modes(struct drm_panel *panel, struct drm_connector *connector#if defined(CONFIG_OF ) && defined(CONFIG_DRM_PANEL )struct drm_panel *of_drm_find_panel (const struct device_node *np); -int of_drm_get_panel_orientation (const struct device_node *np, -enum drm_panel_orientation *orientation);#else static inline struct drm_panel *of_drm_find_panel (const struct device_node *np) {return ERR_PTR (-ENODEV ); } - -static inline int of_drm_get_panel_orientation (const struct device_node *np, -enum drm_panel_orientation *orientation) -{ -return -ENODEV ; -}#endif #if defined(CONFIG_DRM_PANEL )
Signature · 1 line
2.54.0
Re: [PATCH v3 6/7] drm/of: Implement drm_of_get_panel_orientation()
In reply to Thomas ZimmermannQuoted 11 lines · Thomas Zimmermann
Implement
drm_of_get_panel_orientation()to retrieve a panel's rotation property as enumdrm_panel_orientation. The code has been taken fromof_drm_get_panel_orientation(), so convert that helper over. Callers of the old helper can be converted as well.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/drm_of.c | 44 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 26 ++-------------------- include/drm/drm_of.h | 11 ++++++++++ 3 files changed, 57 insertions(+), 24 deletions(-)
Thomas Zimmermann
maintainerPATCH v3 7/7 drm/sysfb: simpledrm: Read panel orientation from DT node
In reply to Thomas ZimmermannA device-tree panel node can specify the panel's rotation in steps of 90 degrees. Set the DRM connector orientation accordingly. Use UNKNOWN for the orientation if the field is missing or invalid.
v3:
- read the orientation with drm_of_get_panel_orientation() (Thierry)
--- drivers/gpu/drm/sysfb/simpledrm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/sysfb/simpledrm.c +9 -2
@@ -28,6 +28,7 @@#include <drm/drm_managed.h> #include <drm/drm_modeset_helper.h> #include <drm/drm_modeset_helper_vtables.h> +#include <drm/drm_of.h> #include <drm/drm_print.h> #include <drm/drm_probe_helper.h>
@@ -623,6 +624,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,int width, height, stride;u16 width_mm =0 , height_mm =0 ;struct device_node *panel_node; +enum drm_panel_orientation orientation =DRM_MODE_PANEL_ORIENTATION_UNKNOWN ;const struct drm_format_info *format;u64 size;struct resource *res, *mem =NULL ;
@@ -698,6 +700,12 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, ret =simplefb_get_panel_height_mm_of (dev, panel_node);if (ret >0 ) height_mm = ret; +/* +* Ignore errors from parsing the panel orientation. With +* the orientation initialized to UNKNOWN, the connector +* helpers will do the right thing. +*/ +drm_of_get_panel_orientation (panel_node, &orientation);of_node_put (panel_node); } }else {
@@ -861,8 +869,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,if (ret)return ERR_PTR (ret);drm_connector_helper_add (connector, &simpledrm_connector_helper_funcs); -drm_connector_set_panel_orientation_with_quirk (connector, -DRM_MODE_PANEL_ORIENTATION_UNKNOWN , +drm_connector_set_panel_orientation_with_quirk (connector, orientation, width, height); ret =drm_connector_attach_encoder (connector, encoder);
Signature · 1 line
2.54.0
Re: [PATCH v3 7/7] drm/sysfb: simpledrm: Read panel orientation from DT node
Quoted 11 lines · Thomas Zimmermann
A device-tree panel node can specify the panel's rotation in steps of 90 degrees. Set the DRM connector orientation accordingly. Use UNKNOWN for the orientation if the field is missing or invalid.
v3:
- read the orientation withdrm_of_get_panel_orientation()(Thierry)Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/sysfb/simpledrm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
Quoted 7 lines · Thomas Zimmermann
Patches 1 to 5 improve validation of the values provided by the device firmware.
Patches 6 and 7 improve support for panel orientation. There's a rotation property in the DT panel node. Read the value and set the connector's
[ ... ]
Thanks!
Maxime
Thomas Zimmermann <[email protected]> writes:
Hello Thomas,
Quoted 9 lines
Patches 1 to 5 improve validation of the values provided by the device firmware.
Patches 6 and 7 improve support for panel orientation. There's a rotation property in the DT panel node. Read the value and set the connector's orientation property accordingly. To do so, patch 6 moves the existing code for parsing the rotation to
drm_of.c. This makes it available to simpledrm without introducing a dependency onDRM_PANEL.
Quoted 7 lines
v3:
- use shared helper for parsing the panel orentation (Thierry)
- fix framebuffer size checks (Sashiko)
- minor improvements
v2:
- further improve input validation (Sashiko)
The whole series looks good to me.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat