drm: vc4: Query the display ID for each display in FKMS
authorDave Stevenson <dave.stevenson@raspberrypi.org>
Tue, 9 Apr 2019 11:37:28 +0000 (12:37 +0100)
committerpopcornmix <popcornmix@gmail.com>
Wed, 1 Jul 2020 15:32:59 +0000 (16:32 +0100)
Replace the hard coded list of display IDs for a mailbox call
that returns the display ID for each display that has been
detected.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
drivers/gpu/drm/vc4/vc4_firmware_kms.c
include/soc/bcm2835/raspberrypi-firmware.h

index 1155680..38b09f5 100644 (file)
@@ -944,7 +944,7 @@ static int vc4_fkms_bind(struct device *dev, struct device *master, void *data)
        struct vc4_crtc **crtc_list;
        u32 num_displays, display_num;
        int ret;
-       const u32 display_num_lookup[] = {2, 7, 1};
+       u32 display_id;
 
        vc4->firmware_kms = true;
 
@@ -983,8 +983,18 @@ static int vc4_fkms_bind(struct device *dev, struct device *master, void *data)
                return -ENOMEM;
 
        for (display_num = 0; display_num < num_displays; display_num++) {
-               ret = vc4_fkms_create_screen(dev, drm, display_num,
-                                            display_num_lookup[display_num],
+               display_id = display_num;
+               ret = rpi_firmware_property(vc4->firmware,
+                                           RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_ID,
+                                           &display_id, sizeof(display_id));
+               /* FIXME: Determine the correct error handling here.
+                * Should we fail to create the one "screen" but keep the
+                * others, or fail the whole thing?
+                */
+               if (ret)
+                       DRM_ERROR("Failed to get display id %u\n", display_num);
+
+               ret = vc4_fkms_create_screen(dev, drm, display_num, display_id,
                                             &crtc_list[display_num]);
                if (ret)
                        DRM_ERROR("Oh dear, failed to create display %u\n",
index f0c15ee..10f5dc5 100644 (file)
@@ -114,6 +114,7 @@ enum rpi_firmware_property_tag {
        RPI_FIRMWARE_FRAMEBUFFER_GET_TOUCHBUF =               0x0004000f,
        RPI_FIRMWARE_FRAMEBUFFER_GET_GPIOVIRTBUF =            0x00040010,
        RPI_FIRMWARE_FRAMEBUFFER_RELEASE =                    0x00048001,
+       RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_ID =             0x00040016,
        RPI_FIRMWARE_FRAMEBUFFER_SET_DISPLAY_NUM =            0x00048013,
        RPI_FIRMWARE_FRAMEBUFFER_GET_NUM_DISPLAYS =           0x00040013,
        RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_SETTINGS =       0x00040014,