From patchwork Mon Sep 2 11:31:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11126451 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 756331398 for ; Mon, 2 Sep 2019 11:31:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D9482173E for ; Mon, 2 Sep 2019 11:31:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D9482173E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7753789C16; Mon, 2 Sep 2019 11:31:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id A5B7B89C09 for ; Mon, 2 Sep 2019 11:31:50 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id 30so2710065wrk.11 for ; Mon, 02 Sep 2019 04:31:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Da+vbmfhaJycNBymoZETIocQDocdZDLcYeBn4es5U/A=; b=U5Xb/APoiU70R+Hta+7IWAz8/uJqlid11Jv+BdPSt2KtCoABOilTP4/GmzGawYT6Ev Tnm+cXoejVc9UbDoEFkVUn+7nXhIXAyrH44Agt4XkJ7v/mAvLmwcdmVv9g18aTYAajjV /Of2erqvgaAaAqJ3xP5YP6KObF4ZY7GV66OedwXCiDrIrwqssfqW4bioUeKyE4hJOhoG KqYrjlUZuhgsxPLNhr+ilIfCOx9kO5MqXuGEsF6M26bTI8oNENvoV9YugBhM/xJ7GUee eaNCHkknixwJdZIjTGVDEPpqWOcczhnvE9PTqRKV1lEH0yj03e2YjIiP5JAwKyi3o0Pf 2GLg== X-Gm-Message-State: APjAAAUNmsZSaNJXv8IziEGZFBhhdqwn8RZ2Aku3gc/8vWoJ66RLvt2q 3sub/VgnGTtRhAxM+XLQA7nEs4Y2 X-Google-Smtp-Source: APXvYqz6s3ZvkhLttyYq6oqPP3A9ehy/EB2EJoRDq35gF3bh7MiyMNquBTeGEpgS7C0/kqCnrCVaBg== X-Received: by 2002:adf:ffca:: with SMTP id x10mr27181160wrs.190.1567423908747; Mon, 02 Sep 2019 04:31:48 -0700 (PDT) Received: from localhost (pD9E51890.dip0.t-ipconnect.de. [217.229.24.144]) by smtp.gmail.com with ESMTPSA id w1sm16998779wrm.38.2019.09.02.04.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2019 04:31:47 -0700 (PDT) From: Thierry Reding To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 12/21] drm/dp: Read AUX read interval from DPCD Date: Mon, 2 Sep 2019 13:31:12 +0200 Message-Id: <20190902113121.31323-13-thierry.reding@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190902113121.31323-1-thierry.reding@gmail.com> References: <20190902113121.31323-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Da+vbmfhaJycNBymoZETIocQDocdZDLcYeBn4es5U/A=; b=GPJ3DQthnM5FDVgqNSFvCzxxBL5g4FvFi6EWzl/1Xmt/ZqvF1f5wZyRycvku+ubtgy Y5+wPC8MdGV7Fh4xyvKfvFIALOrdeTbaWhjHIAzBHF+QTgQuqGBh5uUzJEfl4g7gMHWP uvm6ObbeJ5I+y6cX53VBtoWZUUU1+WrXxUrLCjQqZUq1ljONuyQmQwm6Hok5KRxjTOkt MoPZLExiUgIkTfkj9HJ4QOfjGDvVvQHuS9lH7PRM9UKHWTx6DpHABpzaSWtgwv2XpmaZ 7BhcAQnjqEs+NFFdzKqsJTi8bJSUMOFfQ1Dl+nZUd7CUSGpjkxN2AFgUKSqZOmgBfm1w 8HsQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding Store the AUX read interval from DPCD, so that it can be used to wait for the durations given in the specification during link training. v2: use USEC_PER_MSEC instead of MSEC_PER_SEC for clarity Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_dp_helper.c | 3 +++ include/drm/drm_dp_helper.h | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index 5b36e8e39ca7..4112570dbe67 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -382,6 +382,7 @@ static void drm_dp_link_reset(struct drm_dp_link *link) link->max_lanes = 0; drm_dp_link_caps_reset(&link->caps); + link->aux_rd_interval = 0; link->edp = 0; link->rate = 0; @@ -435,6 +436,8 @@ int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link) link->edp = edp_revs[value]; } + link->aux_rd_interval = drm_dp_aux_rd_interval(values); + link->rate = link->max_rate; link->lanes = link->max_lanes; diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index 13c50e905205..e28b0941a8be 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -25,8 +25,11 @@ #include #include +#include #include +#include + /* * Unless otherwise noted, all values are from the DP 1.1a spec. Note that * DP and DPCD versions are independent. Differences from 1.0 are not noted, @@ -1229,6 +1232,36 @@ drm_dp_alternate_scrambler_reset_cap(const u8 dpcd[DP_RECEIVER_CAP_SIZE]) DP_ALTERNATE_SCRAMBLER_RESET_CAP; } +/** + * drm_dp_read_aux_interval() - read the AUX read interval from the DPCD + * @dpcd: receiver capacity buffer + * + * Reads the AUX read interval (in microseconds) from the DPCD. Note that the + * TRAINING_AUX_RD_INTERVAL stores the value in units of 4 milliseconds. If no + * read interval is specified and for DPCD v1.4 and later, the read interval + * is always 100 microseconds. + * + * Returns: + * The read AUX interval in microseconds. + */ +static inline unsigned int +drm_dp_aux_rd_interval(const u8 dpcd[DP_RECEIVER_CAP_SIZE]) +{ + unsigned int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & + DP_TRAINING_AUX_RD_MASK; + + if (rd_interval > 4) + DRM_DEBUG_KMS("AUX interval %u, out of range (max: 4)\n", + rd_interval); + + if (rd_interval > 0 && dpcd[DP_DPCD_REV] < DP_DPCD_REV_14) + rd_interval *= 4 * USEC_PER_MSEC; + else + rd_interval = 100; + + return rd_interval; +} + /* * DisplayPort AUX channel */ @@ -1405,6 +1438,7 @@ void drm_dp_link_caps_copy(struct drm_dp_link_caps *dest, * @max_rate: maximum clock rate supported on the link * @max_lanes: maximum number of lanes supported on the link * @caps: capabilities supported on the link (see &drm_dp_link_caps) + * @aux_rd_interval: AUX read interval to use for training (in microseconds) * @edp: eDP revision (0x11: eDP 1.1, 0x12: eDP 1.2, ...) * @rate: currently configured link rate * @lanes: currently configured number of lanes @@ -1415,6 +1449,7 @@ struct drm_dp_link { unsigned int max_lanes; struct drm_dp_link_caps caps; + unsigned int aux_rd_interval; unsigned char edp; unsigned int rate;