Commit adf00b26 authored by Paulo Zanoni's avatar Paulo Zanoni Committed by Daniel Vetter

drm/i915: make sure we write all the DIP data bytes

... even if the actual infoframe is smaller than the maximum possible
size.

If we don't write all the 32 DIP data bytes the InfoFrame ECC may not
be correctly calculated in some cases (e.g., when changing the port),
and this will lead to black screens on HDMI monitors. The ECC value is
generated by the hardware.

I don't see how this should break anything since we're writing 0 and
that should be the correct value, so this patch should be safe.

Notice that on IVB and older we actually have 64 bytes available for
VIDEO_DIP_DATA, but only bytes 0-31 actually store infoframe data: the
others are either read-only ECC values or marked as "reserved". On HSW
we only have 32 bytes, and the ECC value is stored on its own separate
read-only register. See BSpec.

This patch fixes bug #46761, which is marked as a regression
introduced by commit 4e89ee17:
    drm/i915: set the DIP port on ibx_write_infoframe

Before commit 4e89 we were just failing to send AVI infoframes when we
needed to change the port, which can lead to black screens in some
cases. After commit 4e89 we started sending infoframes, but with a
possibly wrong ECC value. After this patch I hope we start sending
correct infoframes.

Version 2:
  - Improve commit message
  - Try to make the code more clear

Cc: stable@vger.kernel.org
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=46761Signed-off-by: default avatarPaulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@gmail.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 398b7a1b
...@@ -1794,6 +1794,10 @@ ...@@ -1794,6 +1794,10 @@
/* Video Data Island Packet control */ /* Video Data Island Packet control */
#define VIDEO_DIP_DATA 0x61178 #define VIDEO_DIP_DATA 0x61178
/* Read the description of VIDEO_DIP_DATA (before Haswel) or VIDEO_DIP_ECC
* (Haswell and newer) to see which VIDEO_DIP_DATA byte corresponds to each byte
* of the infoframe structure specified by CEA-861. */
#define VIDEO_DIP_DATA_SIZE 32
#define VIDEO_DIP_CTL 0x61170 #define VIDEO_DIP_CTL 0x61170
/* Pre HSW: */ /* Pre HSW: */
#define VIDEO_DIP_ENABLE (1 << 31) #define VIDEO_DIP_ENABLE (1 << 31)
......
...@@ -151,6 +151,9 @@ static void g4x_write_infoframe(struct drm_encoder *encoder, ...@@ -151,6 +151,9 @@ static void g4x_write_infoframe(struct drm_encoder *encoder,
I915_WRITE(VIDEO_DIP_DATA, *data); I915_WRITE(VIDEO_DIP_DATA, *data);
data++; data++;
} }
/* Write every possible data byte to force correct ECC calculation. */
for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
I915_WRITE(VIDEO_DIP_DATA, 0);
mmiowb(); mmiowb();
val |= g4x_infoframe_enable(frame); val |= g4x_infoframe_enable(frame);
...@@ -186,6 +189,9 @@ static void ibx_write_infoframe(struct drm_encoder *encoder, ...@@ -186,6 +189,9 @@ static void ibx_write_infoframe(struct drm_encoder *encoder,
I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data);
data++; data++;
} }
/* Write every possible data byte to force correct ECC calculation. */
for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0);
mmiowb(); mmiowb();
val |= g4x_infoframe_enable(frame); val |= g4x_infoframe_enable(frame);
...@@ -224,6 +230,9 @@ static void cpt_write_infoframe(struct drm_encoder *encoder, ...@@ -224,6 +230,9 @@ static void cpt_write_infoframe(struct drm_encoder *encoder,
I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data);
data++; data++;
} }
/* Write every possible data byte to force correct ECC calculation. */
for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0);
mmiowb(); mmiowb();
val |= g4x_infoframe_enable(frame); val |= g4x_infoframe_enable(frame);
...@@ -259,6 +268,9 @@ static void vlv_write_infoframe(struct drm_encoder *encoder, ...@@ -259,6 +268,9 @@ static void vlv_write_infoframe(struct drm_encoder *encoder,
I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), *data); I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), *data);
data++; data++;
} }
/* Write every possible data byte to force correct ECC calculation. */
for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), 0);
mmiowb(); mmiowb();
val |= g4x_infoframe_enable(frame); val |= g4x_infoframe_enable(frame);
...@@ -292,6 +304,9 @@ static void hsw_write_infoframe(struct drm_encoder *encoder, ...@@ -292,6 +304,9 @@ static void hsw_write_infoframe(struct drm_encoder *encoder,
I915_WRITE(data_reg + i, *data); I915_WRITE(data_reg + i, *data);
data++; data++;
} }
/* Write every possible data byte to force correct ECC calculation. */
for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
I915_WRITE(data_reg + i, 0);
mmiowb(); mmiowb();
val |= hsw_infoframe_enable(frame); val |= hsw_infoframe_enable(frame);
......
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