13d8214183e12f0ff3ed01514bc203ace5abd1f4
[AGL/meta-agl.git] / meta-agl-bsp / meta-raspberrypi / recipes-kernel / linux / linux-raspberrypi / dsi / 0002-drm-vc4-Make-DSI-call-into-the-bridge-after-the-DSI-.patch
1 From ab06860f2361a3750ec3a62347e0fdd7873cb30d Mon Sep 17 00:00:00 2001
2 From: Kevin Quigley <kevin@kquigley.co.uk>
3 Date: Mon, 24 Sep 2018 18:07:40 +0000
4 Subject: [PATCH 2/4] drm/vc4: Make DSI call into the bridge after the DSI link
5  is enabled. bring this patch https://patchwork.kernel.org/patch/10480937/ to
6  Linux rpi-4.14.y
7
8 This allows panels or bridges that need to send DSI commands during
9 pre_enable() to successfully send them.  We delay DISP0 (aka the
10 actual display) enabling until after pre_enable so that pixels aren't
11 streaming before then.
12
13 v2: Just clear out the encoder->bridge value to disable the midlayer
14     calls (idea by Andrzej Hajda).
15 ---
16  drivers/gpu/drm/vc4/vc4_dsi.c | 48 ++++++++++++++++++++++++-----------
17  1 file changed, 33 insertions(+), 15 deletions(-)
18
19 diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
20 index a3f416cbd1d6..3fa2db18d70f 100644
21 --- a/drivers/gpu/drm/vc4/vc4_dsi.c
22 +++ b/drivers/gpu/drm/vc4/vc4_dsi.c
23 @@ -814,7 +814,9 @@ static void vc4_dsi_encoder_disable(struct drm_encoder *encoder)
24         struct vc4_dsi *dsi = vc4_encoder->dsi;
25         struct device *dev = &dsi->pdev->dev;
26  
27 +       drm_bridge_disable(dsi->bridge);
28         vc4_dsi_ulps(dsi, true);
29 +       drm_bridge_post_disable(dsi->bridge);
30  
31         clk_disable_unprepare(dsi->pll_phy_clock);
32         clk_disable_unprepare(dsi->escape_clock);
33 @@ -1089,21 +1091,6 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)
34         /* Display reset sequence timeout */
35         DSI_PORT_WRITE(PR_TO_CNT, 100000);
36  
37 -       if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) {
38 -               DSI_PORT_WRITE(DISP0_CTRL,
39 -                              VC4_SET_FIELD(dsi->divider,
40 -                                            DSI_DISP0_PIX_CLK_DIV) |
41 -                              VC4_SET_FIELD(dsi->format, DSI_DISP0_PFORMAT) |
42 -                              VC4_SET_FIELD(DSI_DISP0_LP_STOP_PERFRAME,
43 -                                            DSI_DISP0_LP_STOP_CTRL) |
44 -                              DSI_DISP0_ST_END |
45 -                              DSI_DISP0_ENABLE);
46 -       } else {
47 -               DSI_PORT_WRITE(DISP0_CTRL,
48 -                              DSI_DISP0_COMMAND_MODE |
49 -                              DSI_DISP0_ENABLE);
50 -       }
51 -
52         /* Set up DISP1 for transferring long command payloads through
53          * the pixfifo.
54          */
55 @@ -1128,6 +1115,25 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)
56  
57         vc4_dsi_ulps(dsi, false);
58  
59 +       drm_bridge_pre_enable(dsi->bridge);
60 +
61 +       if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) {
62 +               DSI_PORT_WRITE(DISP0_CTRL,
63 +                              VC4_SET_FIELD(dsi->divider,
64 +                                            DSI_DISP0_PIX_CLK_DIV) |
65 +                              VC4_SET_FIELD(dsi->format, DSI_DISP0_PFORMAT) |
66 +                              VC4_SET_FIELD(DSI_DISP0_LP_STOP_PERFRAME,
67 +                                            DSI_DISP0_LP_STOP_CTRL) |
68 +                              DSI_DISP0_ST_END |
69 +                              DSI_DISP0_ENABLE);
70 +       } else {
71 +               DSI_PORT_WRITE(DISP0_CTRL,
72 +                              DSI_DISP0_COMMAND_MODE |
73 +                              DSI_DISP0_ENABLE);
74 +       }
75 +
76 +       drm_bridge_enable(dsi->bridge);
77 +
78         if (debug_dump_regs) {
79                 DRM_INFO("DSI regs after:\n");
80                 vc4_dsi_dump_regs(dsi);
81 @@ -1656,6 +1662,18 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
82  
83         dev_set_drvdata(dev, dsi);
84  
85 +       ret = drm_bridge_attach(dsi->encoder, dsi->bridge, NULL);
86 +       if (ret) {
87 +               dev_err(dev, "bridge attach failed: %d\n", ret);
88 +               return ret;
89 +       }
90 +       /* Disable the atomic helper calls into the bridge.  We
91 +        * manually call the bridge pre_enable / enable / etc. calls
92 +        * from our driver, since we need to sequence them within the
93 +        * encoder's enable/disable paths.
94 +        */
95 +       dsi->encoder->bridge = NULL;
96 +
97         pm_runtime_enable(dev);
98  
99         return 0;
100 -- 
101 2.21.0
102