kernel: bump 6.1 to 6.1.84
[openwrt/staging/stintel.git] / target / linux / bcm27xx / patches-6.1 / 950-0025-drm-panel-Add-and-initialise-an-orientation-field-to.patch
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
5 drm_panel
6
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.
11
12 Add an orientation variable to struct drm_panel and initialise it from
13 drm_panel_init.
14 panel_bridge_attach can then create the property before the connector
15 is registered.
16
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
18 ---
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(-)
23
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
27 return ret;
28 }
29
30 + /* set up connector's "panel orientation" property */
31 + drm_connector_set_panel_orientation(&panel_bridge->connector,
32 + panel_bridge->panel->orientation);
33 +
34 drm_connector_attach_encoder(&panel_bridge->connector,
35 bridge->encoder);
36
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
40 panel->dev = dev;
41 panel->funcs = funcs;
42 panel->connector_type = connector_type;
43 +
44 + panel->orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
45 + of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
46 }
47 EXPORT_SYMBOL(drm_panel_init);
48
49 @@ -294,16 +297,18 @@ int of_drm_get_panel_orientation(const s
50 if (ret < 0)
51 return ret;
52
53 - if (rotation == 0)
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;
65 - else
66 + } else {
67 + DRM_ERROR("%pOF: invalid orientation %d\n", np, ret);
68 return -EINVAL;
69 + }
70
71 return 0;
72 }
73 --- a/include/drm/drm_panel.h
74 +++ b/include/drm/drm_panel.h
75 @@ -183,6 +183,14 @@ struct drm_panel {
76 int connector_type;
77
78 /**
79 + * @orientation:
80 + *
81 + * Panel orientation at initialisation. This is used to initialise the
82 + * drm_connector property for panel orientation.
83 + */
84 + enum drm_panel_orientation orientation;
85 +
86 + /**
87 * @list:
88 *
89 * Panel entry in registry.