From patchwork Mon May 3 15:46:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12236395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D674BC43460 for ; Mon, 3 May 2021 15:47:28 +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 87F26600CC for ; Mon, 3 May 2021 15:47:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87F26600CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E5F4A6E8E3; Mon, 3 May 2021 15:47:27 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id D931A6E8E1 for ; Mon, 3 May 2021 15:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620056845; 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=TeCeXUium7Wh3hsnPteAwXOlLceBZAZ917D6FzQcyzs=; b=KdjE2Ummkf5Pft3ImWbmLU63yhj2D6j8Xu9zBbr5GPByG/S34+rdU7bODVCC2XBrej9BcK AnxkQd/Te0lEEPkhHj0W5ZYMKQK4GBPmTz7Nf8cqDSXmauokKHyFBP9Se49tRjWdxHe1et Pm4vxWOYXTMV0OFc/xGtxvCTQ6BLDjc= 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-446-W99B98H3PeGhRKvsRLhGkQ-1; Mon, 03 May 2021 11:47:22 -0400 X-MC-Unique: W99B98H3PeGhRKvsRLhGkQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4F2AD818411; Mon, 3 May 2021 15:47:20 +0000 (UTC) Received: from x1.localdomain (ovpn-112-158.ams2.redhat.com [10.36.112.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DD811007610; Mon, 3 May 2021 15:47:17 +0000 (UTC) From: Hans de Goede To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Daniel Vetter , David Airlie , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Greg Kroah-Hartman , Guenter Roeck , Heikki Krogerus Date: Mon, 3 May 2021 17:46:46 +0200 Message-Id: <20210503154647.142551-9-hdegoede@redhat.com> In-Reply-To: <20210503154647.142551-1-hdegoede@redhat.com> References: <20210503154647.142551-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Subject: [Intel-gfx] [PATCH 8/9] usb: typec: altmodes/displayport: Notify drm subsys of hotplug events X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx , linux-usb@vger.kernel.org, dri-devel@lists.freedesktop.org, platform-driver-x86@vger.kernel.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Use the new drm_connector_find_by_fwnode() and drm_connector_oob_hotplug_event() functions to let drm/kms drivers know about DisplayPort over Type-C hotplug events. Signed-off-by: Hans de Goede --- Changes in v2: - Add missing depends on DRM to TYPEC_DP_ALTMODE Kconfig entry --- drivers/usb/typec/altmodes/Kconfig | 1 + drivers/usb/typec/altmodes/displayport.c | 40 +++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/altmodes/Kconfig b/drivers/usb/typec/altmodes/Kconfig index 60d375e9c3c7..1a6b5e872b0d 100644 --- a/drivers/usb/typec/altmodes/Kconfig +++ b/drivers/usb/typec/altmodes/Kconfig @@ -4,6 +4,7 @@ menu "USB Type-C Alternate Mode drivers" config TYPEC_DP_ALTMODE tristate "DisplayPort Alternate Mode driver" + depends on DRM help DisplayPort USB Type-C Alternate Mode allows DisplayPort displays and adapters to be attached to the USB Type-C diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index aa669b9cf70e..f00dfc5c14b6 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -11,8 +11,10 @@ #include #include #include +#include #include #include +#include #include "displayport.h" #define DP_HEADER(_dp, ver, cmd) (VDO((_dp)->alt->svid, 1, ver, cmd) \ @@ -62,12 +64,30 @@ struct dp_altmode { struct work_struct work; struct typec_altmode *alt; const struct typec_altmode *port; + struct fwnode_handle *connector_fwnode; }; +static void dp_altmode_notify_connector(struct dp_altmode *dp) +{ + struct drm_connector_oob_hotplug_event_data data = { }; + u8 pin_assign = DP_CONF_GET_PIN_ASSIGN(dp->data.conf); + + data.connected = dp->data.status & DP_STATUS_HPD_STATE; + data.orientation = typec_altmode_get_orientation(dp->alt); + + if (pin_assign & DP_PIN_ASSIGN_DP_ONLY_MASK) + data.dp_lanes = 4; + else if (pin_assign & DP_PIN_ASSIGN_MULTI_FUNC_MASK) + data.dp_lanes = 2; + + drm_connector_oob_hotplug_event(dp->connector_fwnode, &data); +} + static int dp_altmode_notify(struct dp_altmode *dp) { unsigned long conf; u8 state; + int ret; if (dp->data.conf) { state = get_count_order(DP_CONF_GET_PIN_ASSIGN(dp->data.conf)); @@ -76,7 +96,12 @@ static int dp_altmode_notify(struct dp_altmode *dp) conf = TYPEC_STATE_USB; } - return typec_altmode_notify(dp->alt, conf, &dp->data); + ret = typec_altmode_notify(dp->alt, conf, &dp->data); + if (ret) + return ret; + + dp_altmode_notify_connector(dp); + return 0; } static int dp_altmode_configure(struct dp_altmode *dp, u8 con) @@ -512,6 +537,7 @@ static const struct attribute_group dp_altmode_group = { int dp_altmode_probe(struct typec_altmode *alt) { const struct typec_altmode *port = typec_altmode_get_partner(alt); + struct fwnode_handle *fwnode; struct dp_altmode *dp; int ret; @@ -540,6 +566,11 @@ int dp_altmode_probe(struct typec_altmode *alt) alt->desc = "DisplayPort"; alt->ops = &dp_altmode_ops; + fwnode = dev_fwnode(alt->dev.parent->parent); /* typec_port fwnode */ + dp->connector_fwnode = fwnode_find_reference(fwnode, "displayport", 0); + if (IS_ERR(dp->connector_fwnode)) + dp->connector_fwnode = NULL; + typec_altmode_set_drvdata(alt, dp); dp->state = DP_STATE_ENTER; @@ -555,6 +586,13 @@ void dp_altmode_remove(struct typec_altmode *alt) sysfs_remove_group(&alt->dev.kobj, &dp_altmode_group); cancel_work_sync(&dp->work); + + if (dp->connector_fwnode) { + dp->data.conf = 0; + dp->data.status = 0; + dp_altmode_notify_connector(dp); + fwnode_handle_put(dp->connector_fwnode); + } } EXPORT_SYMBOL_GPL(dp_altmode_remove);