drm/fb-helper: Look up preferred fbdev node number from DT
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Mon, 9 Oct 2023 15:34:36 +0000 (16:34 +0100)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:35:07 +0000 (11:35 +0000)
For situations where there are multiple DRM cards in a system,
add a query of DT for "drm_fb" designations for cards to set
their preferred /dev/fbN designation.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/gpu/drm/drm_fb_helper.c

index d612133..a0fcb8a 100644 (file)
@@ -1837,7 +1837,7 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper)
        struct drm_device *dev = fb_helper->dev;
        struct fb_info *info;
        unsigned int width, height;
-       int ret;
+       int ret, id;
 
        width = dev->mode_config.max_width;
        height = dev->mode_config.max_height;
@@ -1868,6 +1868,15 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper)
         * register the fbdev emulation instance in kernel_fb_helper_list. */
        mutex_unlock(&fb_helper->lock);
 
+       id = of_alias_get_highest_id("drm_fb");
+       if (id >= 0)
+               fb_set_lowest_dynamic_fb(id + 1);
+
+       id = of_alias_get_id(dev->dev->of_node, "drm_fb");
+       if (id >= 0) {
+               info->node = id;
+               info->custom_fb_num = true;
+       }
        ret = register_framebuffer(info);
        if (ret < 0)
                return ret;