Skip to contentSkip to conversation

drm: Set crtc->invert_dimensions from the atomic helpers

PATCH In review [email protected] 2 participants 3 messages Oct 15, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm: Set crtc->invert_dimensions from the atomic helpers

From: Ville Syrjälä <[email protected]>

Pull the crtc->invert_dimensions setting from omapdrm into the atomic helpers so that all drivers will check viewport correctly in setcrtc() after rotating the primary plane,

---
 drivers/gpu/drm/drm_atomic_helper.c | 8 ++++++++
 drivers/gpu/drm/omapdrm/omap_crtc.c | 3 ---
 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +8 -0
index 87a2a44..d0d11dbf 100644
@@ -1272,6 +1272,11 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 
 		funcs->atomic_flush(crtc, old_crtc_state);
 	}
+
+	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+		crtc->invert_dimensions = (crtc->primary->state->rotation &
+					   (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270)));
+	}
 }
 EXPORT_SYMBOL(drm_atomic_helper_commit_planes);
 
@@ -1330,6 +1335,9 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state)
 
 	if (crtc_funcs && crtc_funcs->atomic_flush)
 		crtc_funcs->atomic_flush(crtc, old_crtc_state);
+
+	crtc->invert_dimensions = (crtc->primary->state->rotation &
+				   (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270)));
 }
 EXPORT_SYMBOL(drm_atomic_helper_commit_planes_on_crtc);
 
drivers/gpu/drm/omapdrm/omap_crtc.c +0 -3
index 9a4ba4f..ad09590 100644
@@ -412,9 +412,6 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 		dispc_mgr_go(omap_crtc->channel);
 		omap_irq_register(crtc->dev, &omap_crtc->vblank_irq);
 	}
-
-	crtc->invert_dimensions = !!(crtc->primary->state->rotation &
-				    (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270)));
 }
 
 static int omap_crtc_atomic_set_property(struct drm_crtc *crtc,
Signature · 6 lines
2.4.9

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/2 drm: Swap w/h when converting the mode to src coordidates for a rotated primary plane

From: Ville Syrjälä <[email protected]>

When converting the mode hdisplay/vdisplay to primary plane src coordinates we need to take into account the current plane rotation.

---
 drivers/gpu/drm/drm_atomic_helper.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +7 -2
index d0d11dbf..b119a29 100644
@@ -1798,8 +1798,13 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,
 	primary_state->crtc_w = set->mode->hdisplay;
 	primary_state->src_x = set->x << 16;
 	primary_state->src_y = set->y << 16;
-	primary_state->src_h = set->mode->vdisplay << 16;
-	primary_state->src_w = set->mode->hdisplay << 16;
+	if (primary_state->rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270))) {
+		primary_state->src_h = set->mode->hdisplay << 16;
+		primary_state->src_w = set->mode->vdisplay << 16;
+	} else {
+		primary_state->src_h = set->mode->vdisplay << 16;
+		primary_state->src_w = set->mode->hdisplay << 16;
+	}
 
 commit:
 	ret = update_output_state(state, set);
Signature · 6 lines
2.4.9

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
In reply to [email protected]
Quoted 29 lines · On Thu, Oct 15, 2015 at 04:53:00PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Pull the crtc->invert_dimensions setting from omapdrm into the atomic helpers so that all drivers will check viewport correctly in setcrtc() after rotating the primary plane,

---
 drivers/gpu/drm/drm_atomic_helper.c | 8 ++++++++
 drivers/gpu/drm/omapdrm/omap_crtc.c | 3 ---
 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +5 -0
index 87a2a44..d0d11dbf 100644
@@ -1272,6 +1272,11 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 
 		funcs->atomic_flush(crtc, old_crtc_state);
 	}
+
+	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+		crtc->invert_dimensions = (crtc->primary->state->rotation &
+					   (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270)));
+	}
 }
 EXPORT_SYMBOL(drm_atomic_helper_commit_planes);
 

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state) · line 1340

Quoted 6 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -0
@@ -1330,6 +1335,9 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state)
 
 	if (crtc_funcs && crtc_funcs->atomic_flush)
 		crtc_funcs->atomic_flush(crtc, old_crtc_state);
+
+	crtc->invert_dimensions = (crtc->primary->state->rotation &
+				   (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270)));

This is racy for async atomic commits since it's only set in the tail part of the commit, but we read it synchronously from ioctl code. So we'd need to either state-ify this properly or do something else. Best might be to ditch crtc->invert_dimensions (so no non-atomic driver uses it), push the check for legacy drivers down into driver callbacks and for atomic drivers into the generic check parts of drm_atomic_check.

Not pretty, but probably about the best we can do. -Daniel

Quoted 24 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
 }
 EXPORT_SYMBOL(drm_atomic_helper_commit_planes_on_crtc);
 
drivers/gpu/drm/omapdrm/omap_crtc.c +0 -3
index 9a4ba4f..ad09590 100644
@@ -412,9 +412,6 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 		dispc_mgr_go(omap_crtc->channel);
 		omap_irq_register(crtc->dev, &omap_crtc->vblank_irq);
 	}
-
-	crtc->invert_dimensions = !!(crtc->primary->state->rotation &
-				    (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270)));
 }
 
 static int omap_crtc_atomic_set_property(struct drm_crtc *crtc,
Signature · 6 lines
2.4.9

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel