Skip to content

Commit 8a920e2

Browse files
committed
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: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190125181931.19482-2-ville.syrjala@linux.intel.com Reviewed-by: Imre Deak <imre.deak@intel.com>
1 parent 6a2a940 commit 8a920e2

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

drivers/gpu/drm/i915/i915_irq.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,9 @@ static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
10121012
int position;
10131013
int vbl_start, vbl_end, hsync_start, htotal, vtotal;
10141014
unsigned long irqflags;
1015+
bool use_scanline_counter = INTEL_GEN(dev_priv) >= 5 ||
1016+
IS_G4X(dev_priv) || IS_GEN(dev_priv, 2) ||
1017+
mode->private_flags & I915_MODE_FLAG_USE_SCANLINE_COUNTER;
10151018

10161019
if (WARN_ON(!mode->crtc_clock)) {
10171020
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,
10441047
if (stime)
10451048
*stime = ktime_get();
10461049

1047-
if (IS_GEN(dev_priv, 2) || IS_G4X(dev_priv) || INTEL_GEN(dev_priv) >= 5) {
1050+
if (use_scanline_counter) {
10481051
/* No obvious pixelcount register. Only query vertical
10491052
* scanout position from Display scan line register.
10501053
*/
@@ -1104,7 +1107,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
11041107
else
11051108
position += vtotal - vbl_end;
11061109

1107-
if (IS_GEN(dev_priv, 2) || IS_G4X(dev_priv) || INTEL_GEN(dev_priv) >= 5) {
1110+
if (use_scanline_counter) {
11081111
*vpos = position;
11091112
*hpos = 0;
11101113
} else {

drivers/gpu/drm/i915/intel_drv.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,9 +629,11 @@ struct intel_crtc_scaler_state {
629629
};
630630

631631
/* drm_mode->private_flags */
632-
#define I915_MODE_FLAG_INHERITED 1
632+
#define I915_MODE_FLAG_INHERITED (1<<0)
633633
/* Flag to get scanline using frame time stamps */
634634
#define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1)
635+
/* Flag to use the scanline counter instead of the pixel counter */
636+
#define I915_MODE_FLAG_USE_SCANLINE_COUNTER (1<<2)
635637

636638
struct intel_pipe_wm {
637639
struct intel_wm_level wm[5];

drivers/gpu/drm/i915/intel_tv.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,11 @@ intel_tv_get_config(struct intel_encoder *encoder,
11501150
ypos, mode.vdisplay - ysize - ypos);
11511151

11521152
adjusted_mode->crtc_clock = mode.clock;
1153+
1154+
/* pixel counter doesn't work on i965gm TV output */
1155+
if (IS_I965GM(dev_priv))
1156+
adjusted_mode->private_flags |=
1157+
I915_MODE_FLAG_USE_SCANLINE_COUNTER;
11531158
}
11541159

11551160
static int
@@ -1295,6 +1300,11 @@ intel_tv_compute_config(struct intel_encoder *encoder,
12951300
drm_mode_set_crtcinfo(adjusted_mode, 0);
12961301
adjusted_mode->name[0] = '\0';
12971302

1303+
/* pixel counter doesn't work on i965gm TV output */
1304+
if (IS_I965GM(dev_priv))
1305+
adjusted_mode->private_flags |=
1306+
I915_MODE_FLAG_USE_SCANLINE_COUNTER;
1307+
12981308
return 0;
12991309
}
13001310

0 commit comments

Comments
 (0)