From patchwork Mon Aug 26 14:09:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Francis, David" X-Patchwork-Id: 11114717 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 13F8614E5 for ; Mon, 26 Aug 2019 14:09: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 F02572053B for ; Mon, 26 Aug 2019 14:09:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F02572053B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.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 2F22B89805; Mon, 26 Aug 2019 14:09:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-eopbgr820075.outbound.protection.outlook.com [40.107.82.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8A5E895B6 for ; Mon, 26 Aug 2019 14:09:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dYaGtiytEB2T5tZzL69I4kA1wTqa5o1o+7lJ269spdg0gRstQhBPqjWTtmqrck6bJppHPLXDmYMtH9EeTUU0o7SDVYxeTpNm11xkBtZtkd4rpRxgTGmUpI7LzoY4Q6Hbg/zj+KhgWFAMyfCX8mEdwtyTJSJzRXk2nif59RwQfKoG2BJgVo4F5jENR5Vc5vhYqKkVb9MF/RLoUU6znrobltQpHw4CpzxIeJYR/E61qoALNQ2YtpTD7nUOtH0945jtJ1jOLmnzeA+qph9Dvxlo0CdjS9uqKfC9Rvu7docNwiGGwDZ4Fm4lA2JhWEZwOOdgYbVlHPVyPoE3FYt0UTN8nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=do0GegXStg4vmaYaSslgKlGk6tjM7gVKYb5ZJn1ybdw=; b=amrEVBTlkDyO14iMY5th0a/x7t3jpeqgvOHI9xqzvN3bCy8PWozijQmv7qqg2o2YxIdXFK1saeXdreMyJ0mCrj6es9z7ofA/lAvk/LTtBuylUPOcEoJwXWnZ8+uhZWeG+yawIWquTK9RGOKLqCCYEvTfOjeMlkXdvLdE2pVaOieRgkhF2Eo9O2npN0eSe8p5bI3mDqPxutgdUFKc0L8vKI3w+mHnSR0wdwMbuS/84o7Q23XlrenUyzkx4LJlaPMa8Fp6h48e0T17XBmqnx6qJWJ9SZFYxNV7Jkl37KDCAiNbE1qnWl9bnY4oRoNGbt1yN9zZU2Ec+FMuFYkcNeoezA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from MWHPR1201CA0005.namprd12.prod.outlook.com (2603:10b6:301:4a::15) by SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:70::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.21; Mon, 26 Aug 2019 14:09:37 +0000 Received: from BY2NAM03FT064.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::201) by MWHPR1201CA0005.outlook.office365.com (2603:10b6:301:4a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2199.14 via Frontend Transport; Mon, 26 Aug 2019 14:09:37 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by BY2NAM03FT064.mail.protection.outlook.com (10.152.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Mon, 26 Aug 2019 14:09:36 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.389.1; Mon, 26 Aug 2019 09:09:08 -0500 From: David Francis To: Subject: [PATCH v6 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux Date: Mon, 26 Aug 2019 10:09:03 -0400 Message-ID: <20190826140903.12580-7-David.Francis@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190826140903.12580-1-David.Francis@amd.com> References: <20190826140903.12580-1-David.Francis@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(346002)(376002)(136003)(39860400002)(396003)(2980300002)(428003)(199004)(189003)(36756003)(76176011)(51416003)(86362001)(2351001)(1076003)(53936002)(49486002)(8936002)(305945005)(356004)(50226002)(6666004)(316002)(8676002)(48376002)(81156014)(54906003)(16586007)(4326008)(50466002)(81166006)(336012)(5660300002)(426003)(5024004)(14444005)(478600001)(6916009)(26005)(2906002)(70206006)(70586007)(47776003)(486006)(446003)(11346002)(2616005)(476003)(186003)(126002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR12MB2718; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c94d572d-b3dc-40d6-a71f-08d72a2f0747 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(4618075)(2017052603328); SRVR:SN6PR12MB2718; X-MS-TrafficTypeDiagnostic: SN6PR12MB2718: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 01415BB535 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: hrWHdMLVpYzpx2f4DQG1jTIJ2iFQr+cX6dcJqWDSf3my3H3HAFq0yjUNZDhk0lXvlk81nGa2cRBUWJrTW0x0jmc6Y7VNA414eViw2MAcWIf8TIAwkOL+AMwduV/jDTrg387kdEE9HzNyh5GGKddj/fXYtuL6CmPXm+oK0tWf1oVBuCFFTfFmj6o1ShGB7nXG6jYT+Mfb627KjbWE7he9XDYYV1RUIBaWbQ42n4/r9E8fJ+GegJOB8ymPv/Zev3/zKpyW4fLbc1vNoZlAbuivDQpcG/4J+0qep6LV7LVbGPxY7SmWwVHYJ81Q3EPAxACxSZlQ9VbIU47mAqOPs8NR7hzj58VUD+e55HcRe0VaAkGQN7gQp0HxTFY6xahK2/qPcADr6CFXWqp6fRBRkn5rXQH7ewZW6Ro6EHgACM1SN/U= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2019 14:09:36.8709 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c94d572d-b3dc-40d6-a71f-08d72a2f0747 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2718 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=do0GegXStg4vmaYaSslgKlGk6tjM7gVKYb5ZJn1ybdw=; b=J6X8iUaTTb448stYktvipjf43sNyW9HhsRkkL27zUbBW6n8AouDmCmGBJDSSVuKaoCFHPtHJG+3J+GEDt3wZ6LWCC3jYNwuUciF4t1GCuFclBPJ+RhiEvAnp29eFkkDbdJkQoH4WAIv4cKlqPhyaiphBGmb4oocziDE57gSB5Lw= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; linux.intel.com; dkim=none (message not signed) header.d=none;linux.intel.com; dmarc=permerror action=none header.from=amd.com; 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: , Cc: David Francis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add drm_dp_mst_dsc_aux_for_port. To enable DSC, the DSC_ENABLED register might have to be written on the leaf port's DPCD, its parent's DPCD, or the MST manager's DPCD. This function finds the correct aux for the job. As part of this, add drm_dp_mst_is_virtual_dpcd. Virtual DPCD is a DP feature new in DP v1.4, which exposes certain DPCD registers on virtual ports. Cc: Lyude Paul Cc: Jani Nikula Signed-off-by: David Francis --- drivers/gpu/drm/drm_dp_mst_topology.c | 148 ++++++++++++++++++++++++++ include/drm/drm_dp_mst_helper.h | 2 + 2 files changed, 150 insertions(+) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 502923c24450..976808fa577a 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -4150,3 +4150,151 @@ static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux) { i2c_del_adapter(&aux->ddc); } + +/** + * drm_dp_mst_is_virtual_dpcd() - Is the given port a virtual DP Peer Device + * @port: The port to check + * + * A single physical MST hub object can be represented in the topology + * by multiple branches, with virtual ports between those branches. + * + * As of DP1.4, An MST hub with internal (virtual) ports must expose + * certain DPCD registers over those ports. See sections 2.6.1.1.1 + * and 2.6.1.1.2 of Display Port specification v1.4 for details. + * + * May acquire mgr->lock + * + * Returns: + * true if the port is a virtual DP peer device, false otherwise + */ +static bool drm_dp_mst_is_virtual_dpcd(struct drm_dp_mst_port *port) +{ + struct drm_dp_mst_port *downstream_port; + + if (!port) + return false; + + /* Virtual DP Sink (Internal Display Panel) */ + if (port->port_num >= 8 && port->dpcd_rev >= DP_DPCD_REV_14) + return true; + + /* DP-to-HDMI Protocol Converter */ + if (port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV && + !port->mcs && + port->ldps && + port->dpcd_rev >= DP_DPCD_REV_14) + return true; + + /* DP-to-DP */ + mutex_lock(&port->mgr->lock); + if (port->pdt == DP_PEER_DEVICE_MST_BRANCHING && + port->mstb && + port->dpcd_rev >= DP_DPCD_REV_14 && + port->mstb->num_ports == 2) { + list_for_each_entry(downstream_port, &port->mstb->ports, next) { + if (!downstream_port->input && + downstream_port->pdt == DP_PEER_DEVICE_SST_SINK) + return true; + } + } + mutex_unlock(&port->mgr->lock); + + return false; +} + +/** + * drm_dp_mst_dsc_aux_for_port() - Find the correct aux for DSC + * @port: The port to check. A leaf of the MST tree with an attached display. + * + * Depending on the situation, DSC may be enabled via the endpoint aux, + * the immediately upstream aux, or the connector's physical aux. + * + * This is both the correct aux to read DSC_CAPABILITY and the + * correct aux to write DSC_ENABLED. + * + * This operation can be expensive (up to four aux reads), so + * the caller should cache the return. + * + * Returns: + * NULL if DSC cannot be enabled on this port, otherwise the aux device + */ +struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port) +{ + struct drm_dp_mst_port *immediate_upstream_port; + struct drm_dp_mst_port *fec_port; + struct drm_dp_desc *desc; + + if (port && port->parent) + immediate_upstream_port = port->parent->port_parent; + else + immediate_upstream_port = NULL; + + fec_port = immediate_upstream_port; + while (fec_port) { + /* + * Each physical link (i.e. not a virtual port) between the + * output and the primary device must support FEC + */ + if (!drm_dp_mst_is_virtual_dpcd(fec_port) && + !fec_port->fec_capable) + return NULL; + + fec_port = fec_port->parent->port_parent; + } + + /* DP-to-DP peer device */ + if (drm_dp_mst_is_virtual_dpcd(immediate_upstream_port)) { + u8 upstream_dsc; + u8 endpoint_dsc; + u8 endpoint_fec; + + if (drm_dp_dpcd_read(&port->aux, + DP_DSC_SUPPORT, &endpoint_dsc, 1) < 0) + return NULL; + if (drm_dp_dpcd_read(&port->aux, + DP_FEC_CAPABILITY, &endpoint_fec, 1) < 0) + return NULL; + if (drm_dp_dpcd_read(&immediate_upstream_port->aux, + DP_DSC_SUPPORT, &upstream_dsc, 1) < 0) + return NULL; + + /* Enpoint decompression with DP-to-DP peer device */ + if ((endpoint_dsc & DP_DSC_DECOMPRESSION_IS_SUPPORTED) + && (endpoint_fec & DP_FEC_CAPABLE) + && (upstream_dsc & 0x2) /* DSC passthrough */) + return &port->aux; + + /* Virtual DPCD decompression with DP-to-DP peer device */ + return &immediate_upstream_port->aux; + } + + /* Virtual DPCD decompression with DP-to-HDMI or Virtual DP Sink */ + if (drm_dp_mst_is_virtual_dpcd(port)) + return &port->aux; + + /* + * Synaptics quirk + * Applies to ports for which: + * - Physical aux has Synaptics OUI + * - DPv1.4 or higher + * - Port is on primary branch device + * - Not a VGA adapter (DP_DWN_STRM_PORT_TYPE_ANALOG) + */ + drm_dp_read_desc(port->mgr->aux, desc, true); + if (drm_dp_has_quirk(desc, DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD && + port->mgr->dpcd[DP_DPCD_REV] >= DP_DPCD_REV_14) && + port->parent == port->mgr->mst_primary) { + u8 downstreamport; + + drm_dp_dpcd_read(&port->aux, DP_DOWNSTREAMPORT_PRESENT, + &downstreamport, 1); + + if ((downstreamport & DP_DWN_STRM_PORT_PRESENT) && + (downstreamport & DP_DWN_STRM_PORT_TYPE_MASK + != DP_DWN_STRM_PORT_TYPE_ANALOG)) + return port->mgr->aux; + } + + return NULL; +} +EXPORT_SYMBOL(drm_dp_mst_dsc_aux_for_port); diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index f113ae04fa88..4cf738545dfb 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -673,6 +673,8 @@ int __must_check drm_dp_mst_atomic_check(struct drm_atomic_state *state); void drm_dp_mst_get_port_malloc(struct drm_dp_mst_port *port); void drm_dp_mst_put_port_malloc(struct drm_dp_mst_port *port); +struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port); + extern const struct drm_private_state_funcs drm_dp_mst_topology_state_funcs; /**