aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Vivi <rodrigo.vivi@gmail.com>2014-09-16 19:18:12 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-09-30 03:18:37 -0400
commitad9dc91b6e21266bfc6f466db4b95e10211f31ee (patch)
tree43c97a6a4f8710ea3f1a4c6dd5ad760dbfb7a76e
parent6805b2a7434daaede07969ed5877300b2a0783e7 (diff)
drm/i915: Fix Sink CRC
In some cases like when PSR just got enabled the panel need more vblank times to calculate CRC. I figured that out with the new PSR test cases facing some cases that I had a green screen but a blank CRC. Even with 2 vblank waits on kernel + 2 vblank waits on test case. So let's give up to 6 vblank wait time. However we now check for TEST_CRC_COUNT that shows when panel finished to calculate CRC and has it ready. v2: Jani pointed out attempts decrements was wrong and should never reach the error condition. And Daniel pointed out that EIO is more appropriated than EGAIN. Also I realized that I have to read test_crc_count after setting test_sink v3: Rebase and adding error message Cc: Todd Previte <tprevite@gmail.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Todd Previte <tprevite@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c23
-rw-r--r--include/drm/drm_dp_helper.h5
2 files changed, 20 insertions, 8 deletions
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 6f42d9568049..3caac0f01265 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -3807,21 +3807,32 @@ int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc)
3807 struct drm_device *dev = intel_dig_port->base.base.dev; 3807 struct drm_device *dev = intel_dig_port->base.base.dev;
3808 struct intel_crtc *intel_crtc = 3808 struct intel_crtc *intel_crtc =
3809 to_intel_crtc(intel_dig_port->base.base.crtc); 3809 to_intel_crtc(intel_dig_port->base.base.crtc);
3810 u8 buf[1]; 3810 u8 buf;
3811 int test_crc_count;
3812 int attempts = 6;
3811 3813
3812 if (drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK_MISC, buf) < 0) 3814 if (drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK_MISC, &buf) < 0)
3813 return -EIO; 3815 return -EIO;
3814 3816
3815 if (!(buf[0] & DP_TEST_CRC_SUPPORTED)) 3817 if (!(buf & DP_TEST_CRC_SUPPORTED))
3816 return -ENOTTY; 3818 return -ENOTTY;
3817 3819
3818 if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_TEST_SINK, 3820 if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_TEST_SINK,
3819 DP_TEST_SINK_START) < 0) 3821 DP_TEST_SINK_START) < 0)
3820 return -EIO; 3822 return -EIO;
3821 3823
3822 /* Wait 2 vblanks to be sure we will have the correct CRC value */ 3824 drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK_MISC, &buf);
3823 intel_wait_for_vblank(dev, intel_crtc->pipe); 3825 test_crc_count = buf & DP_TEST_COUNT_MASK;
3824 intel_wait_for_vblank(dev, intel_crtc->pipe); 3826
3827 do {
3828 drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK_MISC, &buf);
3829 intel_wait_for_vblank(dev, intel_crtc->pipe);
3830 } while (--attempts && (buf & DP_TEST_COUNT_MASK) == test_crc_count);
3831
3832 if (attempts == 0) {
3833 DRM_ERROR("Panel is unable to calculate CRC after 6 vblanks\n");
3834 return -EIO;
3835 }
3825 3836
3826 if (drm_dp_dpcd_read(&intel_dp->aux, DP_TEST_CRC_R_CR, crc, 6) < 0) 3837 if (drm_dp_dpcd_read(&intel_dp->aux, DP_TEST_CRC_R_CR, crc, 6) < 0)
3827 return -EIO; 3838 return -EIO;
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 9305c718d789..8edeed00c082 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -303,7 +303,8 @@
303#define DP_TEST_CRC_B_CB 0x244 303#define DP_TEST_CRC_B_CB 0x244
304 304
305#define DP_TEST_SINK_MISC 0x246 305#define DP_TEST_SINK_MISC 0x246
306#define DP_TEST_CRC_SUPPORTED (1 << 5) 306# define DP_TEST_CRC_SUPPORTED (1 << 5)
307# define DP_TEST_COUNT_MASK 0x7
307 308
308#define DP_TEST_RESPONSE 0x260 309#define DP_TEST_RESPONSE 0x260
309# define DP_TEST_ACK (1 << 0) 310# define DP_TEST_ACK (1 << 0)
@@ -313,7 +314,7 @@
313#define DP_TEST_EDID_CHECKSUM 0x261 314#define DP_TEST_EDID_CHECKSUM 0x261
314 315
315#define DP_TEST_SINK 0x270 316#define DP_TEST_SINK 0x270
316#define DP_TEST_SINK_START (1 << 0) 317# define DP_TEST_SINK_START (1 << 0)
317 318
318#define DP_PAYLOAD_TABLE_UPDATE_STATUS 0x2c0 /* 1.2 MST */ 319#define DP_PAYLOAD_TABLE_UPDATE_STATUS 0x2c0 /* 1.2 MST */
319# define DP_PAYLOAD_TABLE_UPDATED (1 << 0) 320# define DP_PAYLOAD_TABLE_UPDATED (1 << 0)