summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRayyan Ansari <rayyan@ansari.sh>2023-01-26 18:24:34 +0000
committerThomas Zimmermann <tzimmermann@suse.de>2023-01-31 10:38:59 +0100
commit2a6d731a8f16192ece8e1649ca13e55d80561594 (patch)
tree9c81e331734944ca14d63d4d4344aa6e49e34678
parent3524c96a121952f214271622bb372661ced86101 (diff)
drm/simpledrm: Allow physical width and height configuration via panel node
Parse the width-mm and height-mm devicetree properties of the panel node, and use this to set the DRM Display Mode instead of calculating it based on a hardcoded DPI. Signed-off-by: Rayyan Ansari <rayyan@ansari.sh> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patchwork.freedesktop.org/patch/msgid/20230126182435.70544-2-rayyan@ansari.sh
-rw-r--r--drivers/gpu/drm/tiny/simpledrm.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
index 63881a3754f8..c38d85848af8 100644
--- a/drivers/gpu/drm/tiny/simpledrm.c
+++ b/drivers/gpu/drm/tiny/simpledrm.c
@@ -606,16 +606,12 @@ static const struct drm_mode_config_funcs simpledrm_mode_config_funcs = {
*/
static struct drm_display_mode simpledrm_mode(unsigned int width,
- unsigned int height)
+ unsigned int height,
+ unsigned int width_mm,
+ unsigned int height_mm)
{
- /*
- * Assume a monitor resolution of 96 dpi to
- * get a somewhat reasonable screen size.
- */
const struct drm_display_mode mode = {
- DRM_MODE_INIT(60, width, height,
- DRM_MODE_RES_MM(width, 96ul),
- DRM_MODE_RES_MM(height, 96ul))
+ DRM_MODE_INIT(60, width, height, width_mm, height_mm)
};
return mode;
@@ -629,6 +625,8 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
struct simpledrm_device *sdev;
struct drm_device *dev;
int width, height, stride;
+ int width_mm = 0, height_mm = 0;
+ struct device_node *panel_node;
const struct drm_format_info *format;
struct resource *res, *mem = NULL;
struct drm_plane *primary_plane;
@@ -685,6 +683,12 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
mem = simplefb_get_memory_of(dev, of_node);
if (IS_ERR(mem))
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);
+ of_node_put(panel_node);
+ }
} else {
drm_err(dev, "no simplefb configuration found\n");
return ERR_PTR(-ENODEV);
@@ -695,7 +699,16 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
return ERR_PTR(-EINVAL);
}
- sdev->mode = simpledrm_mode(width, height);
+ /*
+ * Assume a monitor resolution of 96 dpi if physical dimensions
+ * are not specified to get a somewhat reasonable screen size.
+ */
+ if (!width_mm)
+ width_mm = DRM_MODE_RES_MM(width, 96ul);
+ if (!height_mm)
+ height_mm = DRM_MODE_RES_MM(height, 96ul);
+
+ sdev->mode = simpledrm_mode(width, height, width_mm, height_mm);
sdev->format = format;
sdev->pitch = stride;