From patchwork Fri Apr 10 17:42:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Previte X-Patchwork-Id: 6198111 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 543D99F2EC for ; Fri, 10 Apr 2015 17:43:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5287220430 for ; Fri, 10 Apr 2015 17:43:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4307C2042C for ; Fri, 10 Apr 2015 17:43:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A8D96E9EA; Fri, 10 Apr 2015 10:43:03 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by gabe.freedesktop.org (Postfix) with ESMTP id 679D46E9EB for ; Fri, 10 Apr 2015 10:43:02 -0700 (PDT) Received: by paboj16 with SMTP id oj16so28134411pab.0 for ; Fri, 10 Apr 2015 10:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F9OooTqUTecYi7j+WG/rZeAEfks3EQDZEARAjSrYWUU=; b=sUoSFTAt2Qi/rS6ohRFdCl2oxTpLZyfIr4rcnSRD2AlE4mORyFMu5loJD70WJPCOb8 fYPNQz60qkzvN+krbs75O0dOLfUyDjgFqkYLvPzVd6BbmGKw7qZfIUiq6oYQ6vb3Cu9d wE7oYyiTQK9Zn3oeJ9Q4VBk2FZbo+05wYEJ/zaWFCGZPbToKlbv9+XmhGd7MTnpasvcp vmw7QyXJDTiCvIBDn7Hz5+Z8BsQozDgPf6RGIVgPFbbMOBXzl2l3/CpHl9+M0IGEFoeA G+4JDoESep5GT57Uj/ntc0hhQmX67GX2mwMmb5awpj39y/CSK/eTJilX5OX2pJu5D++3 WGaQ== X-Received: by 10.70.88.68 with SMTP id be4mr4585579pdb.97.1428687782225; Fri, 10 Apr 2015 10:43:02 -0700 (PDT) Received: from localhost.localdomain (ip70-162-72-208.ph.ph.cox.net. [70.162.72.208]) by mx.google.com with ESMTPSA id w9sm2873579pdm.89.2015.04.10.10.43.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Apr 2015 10:43:01 -0700 (PDT) From: Todd Previte To: intel-gfx@lists.freedesktop.org Date: Fri, 10 Apr 2015 10:42:51 -0700 Message-Id: <1428687771-27275-1-git-send-email-tprevite@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428682372-21586-9-git-send-email-tprevite@gmail.com> References: <1428682372-21586-9-git-send-email-tprevite@gmail.com> Subject: [Intel-gfx] [PATCH 08/13] drm/i915: Support EDID compliance tests with the intel_dp_autotest_edid() function X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Updates the EDID compliance test function to perform the EDID read as required by the tests. This read needs to take place in the kernel for reasons of speed and efficiency. The results of the EDID read operations are handed off to userspace so that the userspace app can set the display mode appropriately for the test response. The compliance_test_active flag now appears at the end of the individual test handling functions. This is so that the kernel-side operations can be completed without the risk of interruption from the userspace app that is polling on that flag. V2: - Addressed mailing list feedback - Removed excess debug messages - Removed extraneous comments - Fixed formatting issues (line length > 80) - Updated the debug message in compute_edid_checksum to output hex values instead of decimal V3: - Addressed more list feedback - Added the test_active flag to the autotest function - Removed test_active flag from handler - Added failsafe check on the compliance test active flag at the end of the test handler - Fixed checkpatch.pl issues V4: - Removed the checksum computation function and its use as it has been rendered superfluous by changes to the core DRM EDID functions - Updated to use the raw header corruption detection mechanism - Moved the declaration of the test_data variable here V5: - Update test active flag variable name to match the change in the first patch of the series. - Relocated the test active flag declaration and initialization to this patch V6: - Updated to use the new flag for raw EDID header corruption - Removed the extra EDID read from the autotest function - Added the edid_checksum variable to struct intel_dp so that the autotest function can write it to the sink device - Moved the update to the hpd_pulse function to another patch - Removed extraneous constants V7: - Fixed erroneous placement of the checksum assignment. In some cases such as when the EDID read fails and is NULL, this causes a NULL ptr dereference in the kernel. Bad news. Fixed now. Signed-off-by: Todd Previte --- drivers/gpu/drm/i915/intel_dp.c | 46 ++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_drv.h | 4 ++++ 2 files changed, 50 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index ba2da44..3bfdc40 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -41,6 +41,12 @@ #define DP_LINK_CHECK_TIMEOUT (10 * 1000) +/* Compliance test status bits */ +#define INTEL_DP_RESOLUTION_SHIFT_MASK 4 +#define INTEL_DP_RESOLUTION_PREFERRED (1 << INTEL_DP_RESOLUTION_SHIFT_MASK) +#define INTEL_DP_RESOLUTION_STANDARD (2 << INTEL_DP_RESOLUTION_SHIFT_MASK) +#define INTEL_DP_RESOLUTION_FAILSAFE (3 << INTEL_DP_RESOLUTION_SHIFT_MASK) + struct dp_link_dpll { int link_bw; struct dpll dpll; @@ -3770,6 +3776,35 @@ static uint8_t intel_dp_autotest_video_pattern(struct intel_dp *intel_dp) static uint8_t intel_dp_autotest_edid(struct intel_dp *intel_dp) { uint8_t test_result = DP_TEST_NAK; + uint32_t ret = 0; + + if (intel_dp->compliance_edid_invalid || + intel_dp->aux.i2c_defer_count > 6) { + /* Check for NACKs/DEFERs, use failsafe if detected + * (DP CTS 1.2 Core Rev 1.1, 4.2.2.4, 4.2.2.5) + */ + if (intel_dp->aux.i2c_nack_count > 0 || + intel_dp->aux.i2c_defer_count > 0) + DRM_DEBUG_KMS("EDID read had %d NACKs, %d DEFERs\n", + intel_dp->aux.i2c_nack_count, + intel_dp->aux.i2c_defer_count); + intel_dp->compliance_test_data = INTEL_DP_RESOLUTION_FAILSAFE; + } else { + ret = drm_dp_dpcd_write(&intel_dp->aux, + DP_TEST_EDID_CHECKSUM, + &intel_dp->compliance_edid_checksum, 1); + if (ret <= 0) + DRM_DEBUG_DRIVER("Failed to write EDID checksum\n"); + else + DRM_DEBUG_DRIVER("EDID checksum written to sink\n"); + + test_result = DP_TEST_ACK | DP_TEST_EDID_CHECKSUM_WRITE; + intel_dp->compliance_test_data = INTEL_DP_RESOLUTION_STANDARD; + } + + /* Set test active flag here so userspace doesn't interrupt things */ + intel_dp->compliance_test_active = 1; + return test_result; } @@ -3785,7 +3820,10 @@ static void intel_dp_handle_test_request(struct intel_dp *intel_dp) uint8_t rxdata = 0; int status = 0; + intel_dp->compliance_test_active = 0; intel_dp->compliance_test_type = 0; + intel_dp->compliance_test_data = 0; + intel_dp->aux.i2c_nack_count = 0; intel_dp->aux.i2c_defer_count = 0; @@ -3920,11 +3958,19 @@ intel_dp_check_link_status(struct intel_dp *intel_dp) /* Displayport Link CTS Core 1.2 rev1.1 EDID testing * 4.2.2.1 - EDID read required for all HPD events + * Also used for 4.2.2.3, 4.2.2.4 4.2.2.5 and 4.2.2.6 + * - compliance_edid_invalid flag used for 4.2.2.6 + * - compliance_edid_checksum used for 4.2.2.3 */ + intel_dp->compliance_edid_invalid = 0; edid_read = drm_get_edid(connector, adapter); if (!edid_read || connector->edid_header_corrupt == 1) { DRM_DEBUG_DRIVER("Invalid EDID detected\n"); + intel_dp->compliance_edid_invalid = 1; + intel_dp->compliance_edid_checksum = 0; } + else + intel_dp->compliance_edid_checksum = edid_read->checksum; /* Try to read the source of the interrupt */ if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 && diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index ab811e5..23030a1 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -650,6 +650,10 @@ struct intel_dp { /* Displayport compliance testing */ unsigned long compliance_test_type; + unsigned long compliance_test_data; + bool compliance_test_active; + bool compliance_edid_invalid; + uint8_t compliance_edid_checksum; }; struct intel_digital_port {