summaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-6.1/950-0025-drm-panel-Add-and-initialise-an-orientation-field-to.patch
blob: 9cdbe6d7c800cb5af4cd3fffeb5db5c87676efaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
From 49d74639d19ec3ae9810a1d6ae6c0ff725c75881 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Tue, 1 Feb 2022 12:20:20 +0000
Subject: [PATCH] drm/panel: Add and initialise an orientation field to
 drm_panel

Current usage of drm_connector_set_panel_orientation is from a panel's
get_modes call. However if the panel orientation property doesn't
exist on the connector at this point, then drm_mode_object triggers
WARNs as the connector is already registered.

Add an orientation variable to struct drm_panel and initialise it from
drm_panel_init.
panel_bridge_attach can then create the property before the connector
is registered.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/gpu/drm/bridge/panel.c |  4 ++++
 drivers/gpu/drm/drm_panel.c    | 15 ++++++++++-----
 include/drm/drm_panel.h        |  8 ++++++++
 3 files changed, 22 insertions(+), 5 deletions(-)

--- a/drivers/gpu/drm/bridge/panel.c
+++ b/drivers/gpu/drm/bridge/panel.c
@@ -81,6 +81,10 @@ static int panel_bridge_attach(struct dr
 		return ret;
 	}
 
+	/* set up connector's "panel orientation" property */
+	drm_connector_set_panel_orientation(&panel_bridge->connector,
+					    panel_bridge->panel->orientation);
+
 	drm_connector_attach_encoder(&panel_bridge->connector,
 					  bridge->encoder);
 
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -61,6 +61,9 @@ void drm_panel_init(struct drm_panel *pa
 	panel->dev = dev;
 	panel->funcs = funcs;
 	panel->connector_type = connector_type;
+
+	panel->orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
+	of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
 }
 EXPORT_SYMBOL(drm_panel_init);
 
@@ -289,16 +292,18 @@ int of_drm_get_panel_orientation(const s
 	if (ret < 0)
 		return ret;
 
-	if (rotation == 0)
+	if (rotation == 0) {
 		*orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
-	else if (rotation == 90)
+	} else if (rotation == 90) {
 		*orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP;
-	else if (rotation == 180)
+	} else if (rotation == 180) {
 		*orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP;
-	else if (rotation == 270)
+	} else if (rotation == 270) {
 		*orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP;
-	else
+	} else {
+		DRM_ERROR("%pOF: invalid orientation %d\n", np, ret);
 		return -EINVAL;
+	}
 
 	return 0;
 }
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -183,6 +183,14 @@ struct drm_panel {
 	int connector_type;
 
 	/**
+	 * @orientation:
+	 *
+	 * Panel orientation at initialisation. This is used to initialise the
+	 * drm_connector property for panel orientation.
+	 */
+	enum drm_panel_orientation orientation;
+
+	/**
 	 * @list:
 	 *
 	 * Panel entry in registry.