00585a983b627f6873d5e76e94bc16adc3ce5b2b
[openwrt/staging/blogic.git] /
1 From 2e4ad74553a929623fd09b2baf2ac73bc4adcd80 Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Fri, 9 Mar 2018 15:32:56 -0800
4 Subject: [PATCH 349/454] drm/vc4: Fix oops dereferencing DPI's connector since
5 panel_bridge.
6
7 In the cleanup, I didn't notice that we needed to dereference the
8 connector for the bus_format. Fix the regression by looking up the
9 first (and only) connector attached to us, and assume that its
10 bus_format is what we want. Some day it would be good to have that
11 part of display_info attached to the bridge, instead.
12
13 v2: Fix stray whitespace change
14
15 Signed-off-by: Eric Anholt <eric@anholt.net>
16 Fixes: 7b1298e05310 ("drm/vc4: Switch DPI to using the panel-bridge helper.")
17 Link: https://patchwork.freedesktop.org/patch/msgid/20180309233256.1667-1-eric@anholt.net
18 Reviewed-by: Sean Paul <seanpaul@chromium.org>
19 Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
20 (cherry picked from commit 721fe38db2010e8d475abf2c1d2bafb6dc031741)
21 ---
22 drivers/gpu/drm/vc4/vc4_dpi.c | 25 ++++++++++++++++++++++---
23 1 file changed, 22 insertions(+), 3 deletions(-)
24
25 --- a/drivers/gpu/drm/vc4/vc4_dpi.c
26 +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
27 @@ -96,7 +96,6 @@ struct vc4_dpi {
28 struct platform_device *pdev;
29
30 struct drm_encoder *encoder;
31 - struct drm_connector *connector;
32 struct drm_bridge *bridge;
33 bool is_panel_bridge;
34
35 @@ -166,14 +165,31 @@ static void vc4_dpi_encoder_disable(stru
36
37 static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
38 {
39 + struct drm_device *dev = encoder->dev;
40 struct drm_display_mode *mode = &encoder->crtc->mode;
41 struct vc4_dpi_encoder *vc4_encoder = to_vc4_dpi_encoder(encoder);
42 struct vc4_dpi *dpi = vc4_encoder->dpi;
43 + struct drm_connector_list_iter conn_iter;
44 + struct drm_connector *connector = NULL, *connector_scan;
45 u32 dpi_c = DPI_ENABLE | DPI_OUTPUT_ENABLE_MODE;
46 int ret;
47
48 - if (dpi->connector->display_info.num_bus_formats) {
49 - u32 bus_format = dpi->connector->display_info.bus_formats[0];
50 + /* Look up the connector attached to DPI so we can get the
51 + * bus_format. Ideally the bridge would tell us the
52 + * bus_format we want, but it doesn't yet, so assume that it's
53 + * uniform throughout the bridge chain.
54 + */
55 + drm_connector_list_iter_begin(dev, &conn_iter);
56 + drm_for_each_connector_iter(connector_scan, &conn_iter) {
57 + if (connector_scan->encoder == encoder) {
58 + connector = connector_scan;
59 + break;
60 + }
61 + }
62 + drm_connector_list_iter_end(&conn_iter);
63 +
64 + if (connector && connector->display_info.num_bus_formats) {
65 + u32 bus_format = connector->display_info.bus_formats[0];
66
67 switch (bus_format) {
68 case MEDIA_BUS_FMT_RGB888_1X24:
69 @@ -201,6 +217,9 @@ static void vc4_dpi_encoder_enable(struc
70 DRM_ERROR("Unknown media bus format %d\n", bus_format);
71 break;
72 }
73 + } else {
74 + /* Default to 24bit if no connector found. */
75 + dpi_c |= VC4_SET_FIELD(DPI_FORMAT_24BIT_888_RGB, DPI_FORMAT);
76 }
77
78 if (mode->flags & DRM_MODE_FLAG_NHSYNC)