Skip to contentSkip to conversation

amd/display: enable panel orientation quirks

PATCH Applied Simon Ser 3 participants 3 messages Sep 10, 2021 – Sep 13, 2021

Subsystems (3)
lore
Share & tools
lore

Simon Ser

author
#0 lore raw

PATCH 1/1 amd/display: enable panel orientation quirks

This patch allows panel orientation quirks from DRM core to be used. They attach a DRM connector property "panel orientation" which indicates in which direction the panel has been mounted. Some machines have the internal screen mounted with a rotation.

Since the panel orientation quirks need the native mode from the EDID, check for it in amdgpu_dm_connector_ddc_get_modes.

Cc Alex Deucher <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +28 -0
index 53363728dbbd..a420602f1794 100644
@@ -7680,6 +7680,32 @@ static void amdgpu_dm_connector_add_common_modes(struct drm_encoder *encoder,
 	}
 }
 
+static void amdgpu_set_panel_orientation(struct drm_connector *connector)
+{
+	struct drm_encoder *encoder;
+	struct amdgpu_encoder *amdgpu_encoder;
+	const struct drm_display_mode *native_mode;
+
+	if (connector->connector_type != DRM_MODE_CONNECTOR_eDP &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_LVDS)
+		return;
+
+	encoder = amdgpu_dm_connector_to_encoder(connector);
+	if (!encoder)
+		return;
+
+	amdgpu_encoder = to_amdgpu_encoder(encoder);
+
+	native_mode = &amdgpu_encoder->native_mode;
+	if (native_mode->hdisplay == 0 || native_mode->vdisplay == 0)
+		return;
+
+	drm_connector_set_panel_orientation_with_quirk(connector,
+						       DRM_MODE_PANEL_ORIENTATION_UNKNOWN,
+						       native_mode->hdisplay,
+						       native_mode->vdisplay);
+}
+
 static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector,
 					      struct edid *edid)
 {
@@ -7708,6 +7734,8 @@ static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector,
 		 * restored here.
 		 */
 		amdgpu_dm_update_freesync_caps(connector, edid);
+
+		amdgpu_set_panel_orientation(connector);
 	} else {
 		amdgpu_dm_connector->num_modes = 0;
 	}
Signature · 1 line
2.33.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Simon Ser

This patch allows panel orientation quirks from DRM core to be used. They attach a DRM connector property "panel orientation" which indicates in which direction the panel has been mounted. Some machines have the internal screen mounted with a rotation.

Quoted 7 lines

Since the panel orientation quirks need the native mode from the EDID, check for it in amdgpu_dm_connector_ddc_get_modes.

Cc Alex Deucher <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>

Harry

Quoted 51 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +28 -0
index 53363728dbbd..a420602f1794 100644
@@ -7680,6 +7680,32 @@ static void amdgpu_dm_connector_add_common_modes(struct drm_encoder *encoder,
 	}
 }
 
+static void amdgpu_set_panel_orientation(struct drm_connector *connector)
+{
+	struct drm_encoder *encoder;
+	struct amdgpu_encoder *amdgpu_encoder;
+	const struct drm_display_mode *native_mode;
+
+	if (connector->connector_type != DRM_MODE_CONNECTOR_eDP &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_LVDS)
+		return;
+
+	encoder = amdgpu_dm_connector_to_encoder(connector);
+	if (!encoder)
+		return;
+
+	amdgpu_encoder = to_amdgpu_encoder(encoder);
+
+	native_mode = &amdgpu_encoder->native_mode;
+	if (native_mode->hdisplay == 0 || native_mode->vdisplay == 0)
+		return;
+
+	drm_connector_set_panel_orientation_with_quirk(connector,
+						       DRM_MODE_PANEL_ORIENTATION_UNKNOWN,
+						       native_mode->hdisplay,
+						       native_mode->vdisplay);
+}
+
 static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector,
 					      struct edid *edid)
 {
@@ -7708,6 +7734,8 @@ static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector,
 		 * restored here.
 		 */
 		amdgpu_dm_update_freesync_caps(connector, edid);
+
+		amdgpu_set_panel_orientation(connector);
 	} else {
 		amdgpu_dm_connector->num_modes = 0;
 	}
Applied
#2 lore raw

Applied. Thanks!

Alex

Quoted 71 lines · Harry Wentland
Quoted 5 lines · Simon Ser

This patch allows panel orientation quirks from DRM core to be used. They attach a DRM connector property "panel orientation" which indicates in which direction the panel has been mounted. Some machines have the internal screen mounted with a rotation.

Quoted 7 lines

Since the panel orientation quirks need the native mode from the EDID, check for it in amdgpu_dm_connector_ddc_get_modes.

Cc Alex Deucher <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>

Harry

Quoted 51 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +28 -0
index 53363728dbbd..a420602f1794 100644
@@ -7680,6 +7680,32 @@ static void amdgpu_dm_connector_add_common_modes(struct drm_encoder *encoder,
      }
 }
 
+static void amdgpu_set_panel_orientation(struct drm_connector *connector)
+{
+     struct drm_encoder *encoder;
+     struct amdgpu_encoder *amdgpu_encoder;
+     const struct drm_display_mode *native_mode;
+
+     if (connector->connector_type != DRM_MODE_CONNECTOR_eDP &&
+         connector->connector_type != DRM_MODE_CONNECTOR_LVDS)
+             return;
+
+     encoder = amdgpu_dm_connector_to_encoder(connector);
+     if (!encoder)
+             return;
+
+     amdgpu_encoder = to_amdgpu_encoder(encoder);
+
+     native_mode = &amdgpu_encoder->native_mode;
+     if (native_mode->hdisplay == 0 || native_mode->vdisplay == 0)
+             return;
+
+     drm_connector_set_panel_orientation_with_quirk(connector,
+                                                    DRM_MODE_PANEL_ORIENTATION_UNKNOWN,
+                                                    native_mode->hdisplay,
+                                                    native_mode->vdisplay);
+}
+
 static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector,
                                            struct edid *edid)
 {
@@ -7708,6 +7734,8 @@ static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector,
               * restored here.
               */
              amdgpu_dm_update_freesync_caps(connector, edid);
+
+             amdgpu_set_panel_orientation(connector);
      } else {
              amdgpu_dm_connector->num_modes = 0;
      }