Skip to contentSkip to conversation

drm/i915: make user mode sync polarity setting explicit

PATCH Applied Imre Deak 3 participants 5 messages Jul 30, 2013 – Aug 5, 2013

Subsystems (2)
lore
Share & tools
lore

Imre Deak

author
#0 lore raw

PATCH 1/1 drm/i915: make user mode sync polarity setting explicit

Userspace can pass a mode with an unspecified vsync/hsync polarity setting. All encoders in the Intel driver take this to mean a negative polarity setting. The HW readout/state checker code on the other hand needs these flags to be explicitly set, otherwise the state checker will WARN about the mismatch.

Get rid of the WARN by making the polarity setting explicit in the adjusted mode flags based on the requested mode flags. This will keep the existing behavior otherwise.

Note that we could guess from the other timing parameters whether the user wanted a VESA or other standard mode and set the polarity accordingly. This is what the NV driver does (drivers/gpu/drm/nouveau/dispnv04/crtc.c), but I think that's not very exact and would change the existing behavior of the Intel driver.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65442

---
 drivers/gpu/drm/i915/intel_display.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/gpu/drm/i915/intel_display.c +13 -0
index baaefd7..98f0fa6 100644
@@ -8058,6 +8058,19 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,
 		(enum transcoder) to_intel_crtc(crtc)->pipe;
 	pipe_config->shared_dpll = DPLL_ID_PRIVATE;
 
+	/*
+	 * Sanitize sync polarity flags based on requested ones. If neither
+	 * positive or negative polarity is requested, treat this as meaning
+	 * negative polarity.
+	 */
+	if (!(pipe_config->adjusted_mode.flags &
+	      (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NHSYNC)))
+		pipe_config->adjusted_mode.flags |= DRM_MODE_FLAG_NHSYNC;
+
+	if (!(pipe_config->adjusted_mode.flags &
+	      (DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC)))
+		pipe_config->adjusted_mode.flags |= DRM_MODE_FLAG_NVSYNC;
+
 	/* Compute a starting value for pipe_config->pipe_bpp taking the source
 	 * plane pixel format and any sink constraints into account. Returns the
 	 * source plane bpp so that dithering can be selected on mismatches
Signature · 1 line
1.8.3.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Imre Deak

Userspace can pass a mode with an unspecified vsync/hsync polarity setting. All encoders in the Intel driver take this to mean a negative polarity setting. The HW readout/state checker code on the other hand needs these flags to be explicitly set, otherwise the state checker will WARN about the mismatch.

Get rid of the WARN by making the polarity setting explicit in the adjusted mode flags based on the requested mode flags. This will keep the existing behavior otherwise.

Quoted 5 lines

Note that we could guess from the other timing parameters whether the user wanted a VESA or other standard mode and set the polarity accordingly. This is what the NV driver does (drivers/gpu/drm/nouveau/dispnv04/crtc.c), but I think that's not very exact and would change the existing behavior of the Intel driver.

Right, don't guess. If the user wanted the standard mode, then the flags would have been taken from the standard modeline.

Quoted 1 line

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65442

You can add a tested-by here for qa.

Quoted 1 line

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
author Tested-by Cancan Feng
#2 lore raw
Quoted 17 lines · Chris Wilson
Quoted 10 lines · Imre Deak

Userspace can pass a mode with an unspecified vsync/hsync polarity setting. All encoders in the Intel driver take this to mean a negative polarity setting. The HW readout/state checker code on the other hand needs these flags to be explicitly set, otherwise the state checker will WARN about the mismatch.

Get rid of the WARN by making the polarity setting explicit in the adjusted mode flags based on the requested mode flags. This will keep the existing behavior otherwise.

Quoted 5 lines

Note that we could guess from the other timing parameters whether the user wanted a VESA or other standard mode and set the polarity accordingly. This is what the NV driver does (drivers/gpu/drm/nouveau/dispnv04/crtc.c), but I think that's not very exact and would change the existing behavior of the Intel driver.

Quoted 6 lines

Right, don't guess. If the user wanted the standard mode, then the flags would have been taken from the standard modeline.

Quoted 1 line

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65442

You can add a tested-by here for qa.

Quoted 2 lines
Quoted 1 line

CC'ing people who might be interested.

After some discussion with Ville, we could refine this further at the drm core level by enforcing the Intel behavior - defaulting to negative polarity and also checking/sanitizing the PHSYNC/PVSYNC flags. PHSYNC/PVSYNC isn't used by the Intel driver so we could still go with the above patch for now and follow-up with a drm core fix.

We should probably also reject modes at drm core level where both positive and negative flags are set, again in a separate follow-up patch.

--Imre

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

author
#3 lore raw
Quoted 28 lines · Imre Deak
Quoted 17 lines · Chris Wilson
Quoted 10 lines · Imre Deak

Userspace can pass a mode with an unspecified vsync/hsync polarity setting. All encoders in the Intel driver take this to mean a negative polarity setting. The HW readout/state checker code on the other hand needs these flags to be explicitly set, otherwise the state checker will WARN about the mismatch.

Get rid of the WARN by making the polarity setting explicit in the adjusted mode flags based on the requested mode flags. This will keep the existing behavior otherwise.

Quoted 5 lines

Note that we could guess from the other timing parameters whether the user wanted a VESA or other standard mode and set the polarity accordingly. This is what the NV driver does (drivers/gpu/drm/nouveau/dispnv04/crtc.c), but I think that's not very exact and would change the existing behavior of the Intel driver.

Quoted 6 lines

Right, don't guess. If the user wanted the standard mode, then the flags would have been taken from the standard modeline.

Quoted 1 line

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65442

You can add a tested-by here for qa.

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 1 line

CC'ing people who might be interested.

After some discussion with Ville, we could refine this further at the drm core level by enforcing the Intel behavior - defaulting to negative polarity and also checking/sanitizing the PHSYNC/PVSYNC flags. PHSYNC/PVSYNC isn't used by the Intel driver so we could still go with

Sorry, I meant PCSYNC/NCSYNC above.

--Imre

Quoted 7 lines

the above patch for now and follow-up with a drm core fix.

We should probably also reject modes at drm core level where both positive and negative flags are set, again in a separate follow-up patch.

--Imre

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

#4 lore raw
In reply to Chris Wilson
Quoted 20 lines · Chris Wilson
Quoted 10 lines · Imre Deak

Userspace can pass a mode with an unspecified vsync/hsync polarity setting. All encoders in the Intel driver take this to mean a negative polarity setting. The HW readout/state checker code on the other hand needs these flags to be explicitly set, otherwise the state checker will WARN about the mismatch.

Get rid of the WARN by making the polarity setting explicit in the adjusted mode flags based on the requested mode flags. This will keep the existing behavior otherwise.

Quoted 5 lines

Note that we could guess from the other timing parameters whether the user wanted a VESA or other standard mode and set the polarity accordingly. This is what the NV driver does (drivers/gpu/drm/nouveau/dispnv04/crtc.c), but I think that's not very exact and would change the existing behavior of the Intel driver.

Right, don't guess. If the user wanted the standard mode, then the flags would have been taken from the standard modeline.

Quoted 6 lines
Quoted 1 line

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65442

You can add a tested-by here for qa.

Quoted 1 line

Queued for -next, thanks for the patch.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch