From patchwork Mon Aug 5 12:23:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11076711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 716F217E0 for ; Mon, 5 Aug 2019 12:24:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F32028498 for ; Mon, 5 Aug 2019 12:24:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53C432880C; Mon, 5 Aug 2019 12:24:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EAC1728498 for ; Mon, 5 Aug 2019 12:24:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F7F66E432; Mon, 5 Aug 2019 12:24:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6B7F76E42D for ; Mon, 5 Aug 2019 12:24:11 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id m10so78452819edv.6 for ; Mon, 05 Aug 2019 05:24:11 -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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/e7DjitOM7CDVgGqudBSXhZQ0r8IgkvSf5RpcQrhnQk=; b=hR+AG20COMmLJWl/eJQT06ub5jcGj1vNRtSUfxJp9sFVXw6/1Pwr8lnh7Fm+4oUH8G iWRF5mFBIO6He2IatXs0SJ6Qmh3D0w9eJZQ2EW+GO5XyZi9/lo2bnrRdqsovkXU761ml UoDxRwQkjaStRibSyyyy0as33z/RDnyw5yeMbTPlbYIb9wmourLb899aDA9ZjeoTXt8w sb5pzKFLWpsBarXs95KS2+95FPgri+CGSFvr+RFWXFhzHbHnya9JDcmbttn3NPPYJymk pmZiphrJklvqvKWTFmbcxxzLlKgNOL90/GWFxrBqkNEHM8fjdv5trc3znx3pPjGDgL19 FkuQ== X-Gm-Message-State: APjAAAXM2TuQFHblegfAcRKRCqnoG3PCKpj8EBqT2OPjlb2Ea63eF4GR ywsOqz4Rtfhq+RqsmbDmrnzgKllj X-Google-Smtp-Source: APXvYqw08INdWmQ9mS8Lwmjpa8K//tKviyeOlT1d1w7R0kLeDDMO2IPm30C/sj7Xc/h4OH6XLEK9uA== X-Received: by 2002:a17:907:384:: with SMTP id ss4mr117958503ejb.166.1565007848160; Mon, 05 Aug 2019 05:24:08 -0700 (PDT) Received: from localhost (pD9E51890.dip0.t-ipconnect.de. [217.229.24.144]) by smtp.gmail.com with ESMTPSA id qq13sm14351107ejb.27.2019.08.05.05.24.07 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 05:24:07 -0700 (PDT) From: Thierry Reding To: dri-devel@lists.freedesktop.org Subject: [PATCH 12/21] drm/dp: Read AUX read interval from DPCD Date: Mon, 5 Aug 2019 14:23:41 +0200 Message-Id: <20190805122350.8838-12-thierry.reding@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805122350.8838-1-thierry.reding@gmail.com> References: <20190805122350.8838-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:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/e7DjitOM7CDVgGqudBSXhZQ0r8IgkvSf5RpcQrhnQk=; b=H2Szy9WFG6ehuv4mrbpRwTB6GvbwR9wcUsdhcC4mzXw4+kb7lgdWzAQb1AmovWVWP/ iWon7Bft2Jp1GuHlhT33gtqPkA6lXtQjx9nLteuYXWz7xMcxyvdBkJaFSkza2pJjwOCZ 4VXz+OGs3yjiWMRzK1mzxvXVuGSoRnvGvBgVW8LcgIwgv8ow2cDdrSX9P3GaO/0KE8DL QYRK5x7GaeqhOJ1UxSWcEcIHxN3atPq4QRdmknXdt2HFtlw4FNHjWKm1TBGV5v4dEcWh 2e0L2v5sp62YCcgEtKIKobRgMq16IV3Fs7fYeUy/uSDD0dl5FUOTy7UwvjbLZTmxqYdY sGDw== 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" X-Virus-Scanned: ClamAV using ClamSMTP 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. 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..fcfd2b19d5bd 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 * MSEC_PER_SEC; + 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;