From patchwork Mon Feb 25 13:20:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10828571 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 B3BD91399 for ; Mon, 25 Feb 2019 13:20:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A39202B647 for ; Mon, 25 Feb 2019 13:20:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 970B02B65F; Mon, 25 Feb 2019 13:20:54 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 284902B663 for ; Mon, 25 Feb 2019 13:20:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727148AbfBYNUx (ORCPT ); Mon, 25 Feb 2019 08:20:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33946 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726921AbfBYNUx (ORCPT ); Mon, 25 Feb 2019 08:20:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB3C1307D978; Mon, 25 Feb 2019 13:20:52 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-17.ams2.redhat.com [10.36.117.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4234F60857; Mon, 25 Feb 2019 13:20:50 +0000 (UTC) From: Hans de Goede To: Maarten Lankhorst , Maxime Ripard , Sean Paul , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Greg Kroah-Hartman , Heikki Krogerus Cc: Hans de Goede , David Airlie , intel-gfx , dri-devel@lists.freedesktop.org, linux-usb@vger.kernel.org Subject: [PATCH 3/3] usb: typec: altmodes/displayport: Notify drm subsys of hotplug events Date: Mon, 25 Feb 2019 14:20:37 +0100 Message-Id: <20190225132037.31458-4-hdegoede@redhat.com> In-Reply-To: <20190225132037.31458-1-hdegoede@redhat.com> References: <20190225132037.31458-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 25 Feb 2019 13:20:52 +0000 (UTC) Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the new drm_kms_call_oob_hotplug_notifier_chain() function to load drm/kms drivers know about DisplayPort over Type-C hotplug events. Signed-off-by: Hans de Goede --- drivers/usb/typec/altmodes/displayport.c | 34 ++++++++++++++++-------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index 35161594e368..87760ea252d6 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -13,6 +13,7 @@ #include #include #include +#include #define DP_HEADER(cmd) (VDO(USB_TYPEC_DP_SID, 1, cmd) | \ VDO_OPOS(USB_TYPEC_DP_MODE)) @@ -67,12 +68,23 @@ struct dp_altmode { const struct typec_altmode *port; }; -static int dp_altmode_notify(struct dp_altmode *dp) +static int dp_altmode_notify(struct dp_altmode *dp, unsigned long conf) +{ + int ret; + + ret = typec_altmode_notify(dp->alt, conf, &dp->data); + if (ret) + return ret; + + drm_kms_call_oob_hotplug_notifier_chain(DRM_OOB_HOTPLUG_TYPE_C_DP); + return 0; +} + +static int dp_altmode_notify_dp(struct dp_altmode *dp) { u8 state = get_count_order(DP_CONF_GET_PIN_ASSIGN(dp->data.conf)); - return typec_altmode_notify(dp->alt, TYPEC_MODAL_STATE(state), - &dp->data); + return dp_altmode_notify(dp, TYPEC_MODAL_STATE(state)); } static int dp_altmode_configure(struct dp_altmode *dp, u8 con) @@ -145,10 +157,9 @@ static int dp_altmode_configured(struct dp_altmode *dp) sysfs_notify(&dp->alt->dev.kobj, "displayport", "configuration"); if (!dp->data.conf) - return typec_altmode_notify(dp->alt, TYPEC_STATE_USB, - &dp->data); + return dp_altmode_notify(dp, TYPEC_STATE_USB); - ret = dp_altmode_notify(dp); + ret = dp_altmode_notify_dp(dp); if (ret) return ret; @@ -162,7 +173,7 @@ static int dp_altmode_configure_vdm(struct dp_altmode *dp, u32 conf) u32 header = DP_HEADER(DP_CMD_CONFIGURE); int ret; - ret = typec_altmode_notify(dp->alt, TYPEC_STATE_SAFE, &dp->data); + ret = dp_altmode_notify(dp, TYPEC_STATE_SAFE); if (ret) { dev_err(&dp->alt->dev, "unable to put to connector to safe mode\n"); @@ -172,10 +183,9 @@ static int dp_altmode_configure_vdm(struct dp_altmode *dp, u32 conf) ret = typec_altmode_vdm(dp->alt, header, &conf, 2); if (ret) { if (DP_CONF_GET_PIN_ASSIGN(dp->data.conf)) - dp_altmode_notify(dp); + dp_altmode_notify_dp(dp); else - typec_altmode_notify(dp->alt, TYPEC_STATE_USB, - &dp->data); + dp_altmode_notify(dp, TYPEC_STATE_USB); } return ret; @@ -241,7 +251,7 @@ static void dp_altmode_attention(struct typec_altmode *alt, const u32 vdo) if (dp_altmode_status_update(dp)) dev_warn(&alt->dev, "%s: status update failed\n", __func__); - if (dp_altmode_notify(dp)) + if (dp_altmode_notify_dp(dp)) dev_err(&alt->dev, "%s: notification failed\n", __func__); if (old_state == DP_STATE_IDLE && dp->state != DP_STATE_IDLE) @@ -556,6 +566,8 @@ static void dp_altmode_remove(struct typec_altmode *alt) sysfs_remove_group(&alt->dev.kobj, &dp_altmode_group); cancel_work_sync(&dp->work); + + drm_kms_call_oob_hotplug_notifier_chain(DRM_OOB_HOTPLUG_TYPE_C_DP); } static const struct typec_device_id dp_typec_id[] = {