Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp714414pxa; Tue, 11 Aug 2020 13:09:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNkZsvtNhMfYPzxykLvMlDZs0V/oLYyFi/qHEI8LbGa8PK8Pp/PiYSuGkuDqrtbDNkPBSf X-Received: by 2002:aa7:d5d0:: with SMTP id d16mr27213699eds.212.1597176563933; Tue, 11 Aug 2020 13:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597176563; cv=none; d=google.com; s=arc-20160816; b=nAjN10K0u1pN0+8YXqwn+c1Inp7vPTeXVyW97gxxbr854KE1KaPKg9/eS53adpEjaW /m5q1YM+48Q2VlVw6Tam0Zo+rE86OXe6Xwg8nHr1Z03gYMBmAdp5uCtqvEfI9DU3mamg ZqSbh6GVFUB7A86Da7CfVbovmQxc7x/+w4aWU/KeeZN8YrojsWh8dIRIBGZBg/dQuErQ sKiBY5ewqbodB3wPDWajyYMuOlQdrWBHMOgVW8xtcsyvXoOdaX8XX489NQjQ5V9sc2OP VPuus7uuRG8+h87pnnORyIM308BMtUvw82THfcVRJ4k2vSrXNydd9Th9l4Ri3eTNz4JA ViUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AhcvER536skwh1frvQT5MeeGfBQaW3XChUL6+sO3t0s=; b=umX+zbxNuSdTqqN1lsAhcXmdR5+5JOv6lMARBeb6UzK2Q1dAapF5qWwv94FV/j2dcz p1dLj0MQAwtiiHPW9jZEuI+cTbOmNsKxOc+Aeiwd8JRw6B6xJcqtu2IBAwymUrIzdjWx cVt79mn1VKfDCP6eNTzMNGyvW+lcG38uYdaQC+4xf6Io5jPYq/j2xjIboawpnHXA0Ndm uH8GUQLqSg8H0ZUHQ+WkCMQw0kBnnf6x9NFcQjy8aG+fZr641nbw81qQieaXT1jiHkoc u5KfEVwnQoyPRkDtlsopjL/yCu94DeFHe/U33st+s1Nxapt4bxfOrIy3w9ZmsKaJcv// GRcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gt9J2xi2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kt20si13715016ejb.491.2020.08.11.13.09.00; Tue, 11 Aug 2020 13:09:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gt9J2xi2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726917AbgHKUGt (ORCPT + 99 others); Tue, 11 Aug 2020 16:06:49 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:52871 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726846AbgHKUGr (ORCPT ); Tue, 11 Aug 2020 16:06:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597176405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AhcvER536skwh1frvQT5MeeGfBQaW3XChUL6+sO3t0s=; b=gt9J2xi20NY6Q3lJXiUaDWGPa3MbCaJPYd8KospPSkqz0OuEpsrzzkz2itL51k80JIDuwv rdJxB6p/DSOqcvFHWTecmUah4BFZR6BQUs75m+hZSbM7u7NqIG+n1q6WBlGqiHKRmGOZzK mvWAD5RaxATogLCo2o2Ly3sGqFDoRmo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-WOfAwr5KPz-iuXpgqm4tMw-1; Tue, 11 Aug 2020 16:06:43 -0400 X-MC-Unique: WOfAwr5KPz-iuXpgqm4tMw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6BCDC800479; Tue, 11 Aug 2020 20:06:41 +0000 (UTC) Received: from Ruby.redhat.com (ovpn-119-184.rdu2.redhat.com [10.10.119.184]) by smtp.corp.redhat.com (Postfix) with ESMTP id E67B05D9DD; Tue, 11 Aug 2020 20:06:35 +0000 (UTC) From: Lyude Paul To: nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= , Manasi Navare , Uma Shankar , Gwan-gyeong Mun , Imre Deak , Wambui Karuga , Lucas De Marchi , linux-kernel@vger.kernel.org (open list) Subject: [RFC 15/20] drm/i915/dp: Extract drm_dp_has_sink_count() Date: Tue, 11 Aug 2020 16:04:52 -0400 Message-Id: <20200811200457.134743-16-lyude@redhat.com> In-Reply-To: <20200811200457.134743-1-lyude@redhat.com> References: <20200811200457.134743-1-lyude@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since other drivers are also going to need to be aware of the sink count in order to do proper dongle detection, we might as well steal i915's DP_SINK_COUNT helpers and move them into DRM helpers so that other dirvers can use them as well. Note that this also starts using intel_dp_has_sink_count() in intel_dp_detect_dpcd(), which is a functional change. Signed-off-by: Lyude Paul --- drivers/gpu/drm/drm_dp_helper.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/i915/display/intel_dp.c | 21 ++++++++++++--------- include/drm/drm_dp_helper.h | 8 +++++++- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index 9703b33599c3b..05bb47e589731 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -700,6 +700,28 @@ void drm_dp_set_subconnector_property(struct drm_connector *connector, } EXPORT_SYMBOL(drm_dp_set_subconnector_property); +/** + * drm_dp_has_sink_count() - Check whether a given connector has a valid sink + * count + * @connector: The DRM connector to check + * @dpcd: A cached copy of the connector's DPCD RX capabilities + * @desc: A cached copy of the connector's DP descriptor + * + * Returns: %True if the (e)DP connector has a valid sink count that should + * be probed, %false otherwise. + */ +bool drm_dp_has_sink_count(struct drm_connector *connector, + const u8 dpcd[DP_RECEIVER_CAP_SIZE], + const struct drm_dp_desc *desc) +{ + /* Some eDP panels don't set a valid value for the sink count */ + return connector->connector_type != DRM_MODE_CONNECTOR_eDP && + dpcd[DP_DPCD_REV] >= DP_DPCD_REV_11 && + dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT && + !drm_dp_has_quirk(desc, 0, DP_DPCD_QUIRK_NO_SINK_COUNT); +} +EXPORT_SYMBOL(drm_dp_has_sink_count); + /* * I2C-over-AUX implementation */ diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 984e49194ca31..35a4779a442e2 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -4634,6 +4634,16 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp) return true; } +static bool +intel_dp_has_sink_count(struct intel_dp *intel_dp) +{ + if (!intel_dp->attached_connector) + return false; + + return drm_dp_has_sink_count(&intel_dp->attached_connector->base, + intel_dp->dpcd, + &intel_dp->desc); +} static bool intel_dp_get_dpcd(struct intel_dp *intel_dp) @@ -4653,13 +4663,7 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp) intel_dp_set_common_rates(intel_dp); } - /* - * Some eDP panels do not set a valid value for sink count, that is why - * it don't care about read it here and in intel_edp_init_dpcd(). - */ - if (!intel_dp_is_edp(intel_dp) && - !drm_dp_has_quirk(&intel_dp->desc, 0, - DP_DPCD_QUIRK_NO_SINK_COUNT)) { + if (intel_dp_has_sink_count(intel_dp)) { u8 count; ssize_t r; @@ -5939,9 +5943,8 @@ intel_dp_detect_dpcd(struct intel_dp *intel_dp) return connector_status_connected; /* If we're HPD-aware, SINK_COUNT changes dynamically */ - if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 && + if (intel_dp_has_sink_count(intel_dp) && intel_dp->downstream_ports[0] & DP_DS_PORT_HPD) { - return intel_dp->sink_count ? connector_status_connected : connector_status_disconnected; } diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index 1349f16564ace..a1413a531eaf4 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -1631,6 +1631,11 @@ void drm_dp_set_subconnector_property(struct drm_connector *connector, const u8 *dpcd, const u8 port_cap[4]); +struct drm_dp_desc; +bool drm_dp_has_sink_count(struct drm_connector *connector, + const u8 dpcd[DP_RECEIVER_CAP_SIZE], + const struct drm_dp_desc *desc); + void drm_dp_remote_aux_init(struct drm_dp_aux *aux); void drm_dp_aux_init(struct drm_dp_aux *aux); int drm_dp_aux_register(struct drm_dp_aux *aux); @@ -1689,7 +1694,8 @@ enum drm_dp_quirk { * @DP_DPCD_QUIRK_NO_SINK_COUNT: * * The device does not set SINK_COUNT to a non-zero value. - * The driver should ignore SINK_COUNT during detection. + * The driver should ignore SINK_COUNT during detection. Note that + * drm_dp_has_sink_count() automatically checks for this quirk. */ DP_DPCD_QUIRK_NO_SINK_COUNT, /** -- 2.26.2