Commit 8a920e24 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915/tv: Use the scanline counter for timestamps on i965gm TV output

Just like the frame counter, the pixel counter also reads zero
all the time when the TV encoder is used. Fortunately the
scanline counter still works sufficiently well so let's use that
to correct the vblank timestamps. Otherwise the timestamps may
en up out of whack, and since we use them to guesstimate the
vblank counter value that may end up incorrect as well.

Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190125181931.19482-2-ville.syrjala@linux.intel.comReviewed-by: default avatarImre Deak <imre.deak@intel.com>
parent 6a2a9404
...@@ -1012,6 +1012,9 @@ static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, ...@@ -1012,6 +1012,9 @@ static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
int position; int position;
int vbl_start, vbl_end, hsync_start, htotal, vtotal; int vbl_start, vbl_end, hsync_start, htotal, vtotal;
unsigned long irqflags; unsigned long irqflags;
bool use_scanline_counter = INTEL_GEN(dev_priv) >= 5 ||
IS_G4X(dev_priv) || IS_GEN(dev_priv, 2) ||
mode->private_flags & I915_MODE_FLAG_USE_SCANLINE_COUNTER;
if (WARN_ON(!mode->crtc_clock)) { if (WARN_ON(!mode->crtc_clock)) {
DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled " DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled "
...@@ -1044,7 +1047,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, ...@@ -1044,7 +1047,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
if (stime) if (stime)
*stime = ktime_get(); *stime = ktime_get();
if (IS_GEN(dev_priv, 2) || IS_G4X(dev_priv) || INTEL_GEN(dev_priv) >= 5) { if (use_scanline_counter) {
/* No obvious pixelcount register. Only query vertical /* No obvious pixelcount register. Only query vertical
* scanout position from Display scan line register. * scanout position from Display scan line register.
*/ */
...@@ -1104,7 +1107,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, ...@@ -1104,7 +1107,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
else else
position += vtotal - vbl_end; position += vtotal - vbl_end;
if (IS_GEN(dev_priv, 2) || IS_G4X(dev_priv) || INTEL_GEN(dev_priv) >= 5) { if (use_scanline_counter) {
*vpos = position; *vpos = position;
*hpos = 0; *hpos = 0;
} else { } else {
......
...@@ -629,9 +629,11 @@ struct intel_crtc_scaler_state { ...@@ -629,9 +629,11 @@ struct intel_crtc_scaler_state {
}; };
/* drm_mode->private_flags */ /* drm_mode->private_flags */
#define I915_MODE_FLAG_INHERITED 1 #define I915_MODE_FLAG_INHERITED (1<<0)
/* Flag to get scanline using frame time stamps */ /* Flag to get scanline using frame time stamps */
#define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1) #define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1)
/* Flag to use the scanline counter instead of the pixel counter */
#define I915_MODE_FLAG_USE_SCANLINE_COUNTER (1<<2)
struct intel_pipe_wm { struct intel_pipe_wm {
struct intel_wm_level wm[5]; struct intel_wm_level wm[5];
......
...@@ -1150,6 +1150,11 @@ intel_tv_get_config(struct intel_encoder *encoder, ...@@ -1150,6 +1150,11 @@ intel_tv_get_config(struct intel_encoder *encoder,
ypos, mode.vdisplay - ysize - ypos); ypos, mode.vdisplay - ysize - ypos);
adjusted_mode->crtc_clock = mode.clock; adjusted_mode->crtc_clock = mode.clock;
/* pixel counter doesn't work on i965gm TV output */
if (IS_I965GM(dev_priv))
adjusted_mode->private_flags |=
I915_MODE_FLAG_USE_SCANLINE_COUNTER;
} }
static int static int
...@@ -1295,6 +1300,11 @@ intel_tv_compute_config(struct intel_encoder *encoder, ...@@ -1295,6 +1300,11 @@ intel_tv_compute_config(struct intel_encoder *encoder,
drm_mode_set_crtcinfo(adjusted_mode, 0); drm_mode_set_crtcinfo(adjusted_mode, 0);
adjusted_mode->name[0] = '\0'; adjusted_mode->name[0] = '\0';
/* pixel counter doesn't work on i965gm TV output */
if (IS_I965GM(dev_priv))
adjusted_mode->private_flags |=
I915_MODE_FLAG_USE_SCANLINE_COUNTER;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment