1 From 49d74639d19ec3ae9810a1d6ae6c0ff725c75881 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 1 Feb 2022 12:20:20 +0000
4 Subject: [PATCH] drm/panel: Add and initialise an orientation field to
7 Current usage of drm_connector_set_panel_orientation is from a panel's
8 get_modes call. However if the panel orientation property doesn't
9 exist on the connector at this point, then drm_mode_object triggers
10 WARNs as the connector is already registered.
12 Add an orientation variable to struct drm_panel and initialise it from
14 panel_bridge_attach can then create the property before the connector
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
19 drivers/gpu/drm/bridge/panel.c | 4 ++++
20 drivers/gpu/drm/drm_panel.c | 15 ++++++++++-----
21 include/drm/drm_panel.h | 8 ++++++++
22 3 files changed, 22 insertions(+), 5 deletions(-)
24 --- a/drivers/gpu/drm/bridge/panel.c
25 +++ b/drivers/gpu/drm/bridge/panel.c
26 @@ -81,6 +81,10 @@ static int panel_bridge_attach(struct dr
30 + /* set up connector's "panel orientation" property */
31 + drm_connector_set_panel_orientation(&panel_bridge->connector,
32 + panel_bridge->panel->orientation);
34 drm_connector_attach_encoder(&panel_bridge->connector,
37 --- a/drivers/gpu/drm/drm_panel.c
38 +++ b/drivers/gpu/drm/drm_panel.c
39 @@ -61,6 +61,9 @@ void drm_panel_init(struct drm_panel *pa
42 panel->connector_type = connector_type;
44 + panel->orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
45 + of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
47 EXPORT_SYMBOL(drm_panel_init);
49 @@ -294,16 +297,18 @@ int of_drm_get_panel_orientation(const s
54 + if (rotation == 0) {
55 *orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
56 - else if (rotation == 90)
57 + } else if (rotation == 90) {
58 *orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP;
59 - else if (rotation == 180)
60 + } else if (rotation == 180) {
61 *orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP;
62 - else if (rotation == 270)
63 + } else if (rotation == 270) {
64 *orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP;
67 + DRM_ERROR("%pOF: invalid orientation %d\n", np, ret);
73 --- a/include/drm/drm_panel.h
74 +++ b/include/drm/drm_panel.h
75 @@ -183,6 +183,14 @@ struct drm_panel {
81 + * Panel orientation at initialisation. This is used to initialise the
82 + * drm_connector property for panel orientation.
84 + enum drm_panel_orientation orientation;
89 * Panel entry in registry.