346d32e2d68ea7264a30e494f35a36f9b5efae7f
[openwrt/staging/linusw.git] /
1 From dd99aa50a3ea7f7fe1ddfd59b1a2e969c744b8a0 Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.org>
3 Date: Tue, 28 May 2019 13:56:06 +0100
4 Subject: [PATCH] drm: vc4: handle the case where there are no
5 available displays
6
7 It's reasonable for the firmware to return zero as the number of
8 attached displays. Handle this case as otherwise drm thinks that
9 the DSI panel is attached, which is nonsense.
10
11 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
12 ---
13 drivers/gpu/drm/vc4/vc4_firmware_kms.c | 32 +++++++++++++++-----------
14 1 file changed, 18 insertions(+), 14 deletions(-)
15
16 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
17 +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
18 @@ -1309,13 +1309,13 @@ static int vc4_fkms_bind(struct device *
19 RPI_FIRMWARE_FRAMEBUFFER_GET_NUM_DISPLAYS,
20 &num_displays, sizeof(u32));
21
22 - /* If we fail to get the number of displays, or it returns 0, then
23 + /* If we fail to get the number of displays, then
24 * assume old firmware that doesn't have the mailbox call, so just
25 * set one display
26 */
27 - if (ret || num_displays == 0) {
28 + if (ret) {
29 num_displays = 1;
30 - DRM_WARN("Unable to determine number of displays's. Assuming 1\n");
31 + DRM_WARN("Unable to determine number of displays - assuming 1\n");
32 ret = 0;
33 }
34
35 @@ -1344,17 +1344,21 @@ static int vc4_fkms_bind(struct device *
36 display_num);
37 }
38
39 - /* Map the SMI interrupt reg */
40 - crtc_list[0]->regs = vc4_ioremap_regs(pdev, 0);
41 - if (IS_ERR(crtc_list[0]->regs))
42 - DRM_ERROR("Oh dear, failed to map registers\n");
43 -
44 - writel(0, crtc_list[0]->regs + SMICS);
45 - ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
46 - vc4_crtc_irq_handler, 0, "vc4 firmware kms",
47 - crtc_list);
48 - if (ret)
49 - DRM_ERROR("Oh dear, failed to register IRQ\n");
50 + if (num_displays > 0) {
51 + /* Map the SMI interrupt reg */
52 + crtc_list[0]->regs = vc4_ioremap_regs(pdev, 0);
53 + if (IS_ERR(crtc_list[0]->regs))
54 + DRM_ERROR("Oh dear, failed to map registers\n");
55 +
56 + writel(0, crtc_list[0]->regs + SMICS);
57 + ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
58 + vc4_crtc_irq_handler, 0,
59 + "vc4 firmware kms", crtc_list);
60 + if (ret)
61 + DRM_ERROR("Oh dear, failed to register IRQ\n");
62 + } else {
63 + DRM_WARN("No displays found. Consider forcing hotplug if HDMI is attached\n");
64 + }
65
66 platform_set_drvdata(pdev, crtc_list);
67