From patchwork Fri Apr 29 19:57:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 568223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F52FC4332F for ; Fri, 29 Apr 2022 19:57:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232481AbiD2UAz (ORCPT ); Fri, 29 Apr 2022 16:00:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380443AbiD2UAy (ORCPT ); Fri, 29 Apr 2022 16:00:54 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48744286D1 for ; Fri, 29 Apr 2022 12:57:35 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id s27so11751209ljd.2 for ; Fri, 29 Apr 2022 12:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yjiWSb36gHEJ1pupckIvzivsOKw4TFaRqlM2gJWlkeg=; b=lij9fO8pcjPHTrP1kFRt0lMkgTB2GXTjLFrp7Ml+bSuhx8qXYRZUUM42O0AINyVr+0 YKtq1VPjsf9iZScpJ/jqI8BVh9dlQIuuNZVp4agu1ayr/9awisvXtlEf5CVj4qEFwtYk hbrvGU2UZNRs33SNozRgh4I0hJzjwr05bDvPb/b4rABV8x6Y7vwaFMKF/vJlNoOL+abP 93JKf0x0F6qLx4GgZjgZ0q16HWPI4tMUXVJ0VLegU0IMtGIIaRR90fsS4h/lEMu39811 tzLiBEEzuQ7hDxPP5apqrXcg3aCUM4nOmfELNwNNkuBHScBAgWGDln5S166E0LeI1HnT J7rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yjiWSb36gHEJ1pupckIvzivsOKw4TFaRqlM2gJWlkeg=; b=1cWSAn+K6FCPGavGJYvIFa9TNLkmEYOgXtK3F8eBMn7N1Jd947v0Y5b1YL1EnQzwa5 wKWH4L/f+59FtRrSt7G8za87pTyovF0h3Lfx7VsWewJZr22tI6nV4jcTDHA+ReW5lgOK MHxpt51Xy7vW95VLGZKYMojklWkkUuXvhUCWNbR5+qu1k6yQ49VwKeo3rEayPRSPQuxH eEDBUW3aF/V1zcbQpi9SKDJTiZSicNmWMyOCxohdNe/MLUYiT0rBOHhRuGrGRchup/5y Kt6X/9emE+Ah9gM1idugRENQYk+Suj+V6IfmAQH+9+r71MLQihrkMB7YlHuVqSFa/0WO pbZA== X-Gm-Message-State: AOAM533rDhnBBercwKZzqSANT6EUHGlkXBFiQt/PsOGQXu6IY4UnzFcO uc7VC1ktu2ywda/O/m/0ThByu8UQ/qBSzQ== X-Google-Smtp-Source: ABdhPJzR5DzzxHAxz5dGqxksq45CF6WCBsx4G187PW4k6MkQh7rOCWAka06NGoLxJqkXPm4p4zoQ8A== X-Received: by 2002:a2e:a5cb:0:b0:24f:233b:d90e with SMTP id n11-20020a2ea5cb000000b0024f233bd90emr501851ljp.83.1651262253549; Fri, 29 Apr 2022 12:57:33 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b0047255d2118csm10601lfh.187.2022.04.29.12.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 12:57:33 -0700 (PDT) From: Dmitry Baryshkov To: Bjorn Andersson Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [RFC PATCH v2 1/5] drm/bridge_connector: stop filtering events in drm_bridge_connector_hpd_cb() Date: Fri, 29 Apr 2022 22:57:27 +0300 Message-Id: <20220429195731.3716446-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429195731.3716446-1-dmitry.baryshkov@linaro.org> References: <20220429195731.3716446-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In some cases the bridge drivers would like to receive hotplug events even in the case new status is equal to the old status. In the DP case this is used to deliver "attention" messages to the DP host. Stop filtering the events in the drm_bridge_connector_hpd_cb() and let drivers decide whether they would like to receive the event or not. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_bridge_connector.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c index 60923cdfe8e1..a0b742ebb330 100644 --- a/drivers/gpu/drm/drm_bridge_connector.c +++ b/drivers/gpu/drm/drm_bridge_connector.c @@ -113,16 +113,11 @@ static void drm_bridge_connector_hpd_cb(void *cb_data, struct drm_bridge_connector *drm_bridge_connector = cb_data; struct drm_connector *connector = &drm_bridge_connector->base; struct drm_device *dev = connector->dev; - enum drm_connector_status old_status; mutex_lock(&dev->mode_config.mutex); - old_status = connector->status; connector->status = status; mutex_unlock(&dev->mode_config.mutex); - if (old_status == status) - return; - drm_bridge_connector_hpd_notify(connector, status); drm_kms_helper_hotplug_event(dev); From patchwork Fri Apr 29 19:57:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 568222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48FE5C433F5 for ; Fri, 29 Apr 2022 19:57:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380460AbiD2UBB (ORCPT ); Fri, 29 Apr 2022 16:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380448AbiD2UA4 (ORCPT ); Fri, 29 Apr 2022 16:00:56 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E479A29CAF for ; Fri, 29 Apr 2022 12:57:36 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id x33so15899463lfu.1 for ; Fri, 29 Apr 2022 12:57:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3QARc1+yD0fnTMQkv8qdIG/5WzoseXPaiXdNk/KEbVY=; b=xFZVd2bt/jdvQDO3L+w/8QpJXwC5FYyQFpBfnWDKDDGS8/DTgoH3EFy2PJaDtj50ui jpGYNV1wHarLMnZf2ezetkpt+Qy4w4Pa9jWwjFaL7GG+jUAxyDis9dgXRZ1ApDf+bRfY nVJ714szCXK+ogWydZ/2HCNzgjZCkHlN54fl/PZ1L0xBWm6YmfRWWTFdZkmlnJ2Qfbse /arH+5tW2bdjLPaQubzF/zVXOtqA2HbhkfnrzHAmr9EFiTcQR1MDcsQbmycO9izgFueW JLlJlT5kr4hlKj8csfx7dK3rVkhBDEt1VFiOZKO9g0rTXMwTbjyYxyY1eCRdmPXDRAqi +zMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3QARc1+yD0fnTMQkv8qdIG/5WzoseXPaiXdNk/KEbVY=; b=YtBH4NsoJSbDkMrwZGAEn6UeMFXhcUg2JVuSgmPqsLh/qwAkvdsAGvePxVcNsLXbDi uJmnIISPTqnovQTYuZcdVLQ49ZPj5h4h0bsXUmCaKGRuTV7xI7QmLyhQqa9CaFMetO8o sn8WuzudpHifgvCIR3ySSBfpLbAtNZsepOXCygEsCGWnlS5bsS5Up7TfjqfdDylP1xbI Lw5nhtvsIUOtk+OCPu0S7axAWOj4VL5Em0F2kmH6/14byApN1Wy8K/AqrdF2PirCujzs w1OKi78+we3xBliaO+dQmNAWkIoAb5A/99QueDX4iat9zJPA2y/kbtEgJVx3Pzhq4Qyr KBhQ== X-Gm-Message-State: AOAM5302aDSZMT0GKMYWOsONNp8vYLA8UEafqRg8cbifybaKB+1C/Ua7 jyywvftHjuti7D/htOOUYTly6A== X-Google-Smtp-Source: ABdhPJzDxaVI/xjNvrok8cMEtLAWvbD4MFdwE0qrE2xl98idwuydEVGNHfLzh6KYwmTqvaXIlQ8IaQ== X-Received: by 2002:a05:6512:320c:b0:472:1060:ca29 with SMTP id d12-20020a056512320c00b004721060ca29mr639308lfe.280.1651262255251; Fri, 29 Apr 2022 12:57:35 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b0047255d2118csm10601lfh.187.2022.04.29.12.57.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 12:57:34 -0700 (PDT) From: Dmitry Baryshkov To: Bjorn Andersson Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [RFC PATCH v2 2/5] drm: Add HPD state to drm_connector_oob_hotplug_event() Date: Fri, 29 Apr 2022 22:57:28 +0300 Message-Id: <20220429195731.3716446-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429195731.3716446-1-dmitry.baryshkov@linaro.org> References: <20220429195731.3716446-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bjorn Andersson In some implementations, such as the Qualcomm platforms, the display driver has no way to query the current HPD state and as such it's impossible to distinguish between disconnect and attention events. Add a parameter to drm_connector_oob_hotplug_event() to pass the HPD state. Also push the test for unchanged state in the displayport altmode driver into the i915 driver, to allow other drivers to act upon each update. Signed-off-by: Bjorn Andersson [DB: replaced drm_connector_hpd_state with drm_connector_status] Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_connector.c | 6 ++++-- drivers/gpu/drm/i915/display/intel_dp.c | 17 ++++++++++++++--- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/usb/typec/altmodes/displayport.c | 10 +++------- include/drm/drm_connector.h | 6 ++++-- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 76a8c707c34b..ae8b80bc050d 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -2828,6 +2828,7 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode) /** * drm_connector_oob_hotplug_event - Report out-of-band hotplug event to connector * @connector_fwnode: fwnode_handle to report the event on + * @hpd_state: hot plug detect logical state * * On some hardware a hotplug event notification may come from outside the display * driver / device. An example of this is some USB Type-C setups where the hardware @@ -2837,7 +2838,8 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode) * This function can be used to report these out-of-band events after obtaining * a drm_connector reference through calling drm_connector_find_by_fwnode(). */ -void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode) +void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode, + enum drm_connector_status status) { struct drm_connector *connector; @@ -2846,7 +2848,7 @@ void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode) return; if (connector->funcs->oob_hotplug_event) - connector->funcs->oob_hotplug_event(connector); + connector->funcs->oob_hotplug_event(connector, status); drm_connector_put(connector); } diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index d667657e3606..2acfc068ff51 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -4825,15 +4825,26 @@ static int intel_dp_connector_atomic_check(struct drm_connector *conn, return intel_modeset_synced_crtcs(state, conn); } -static void intel_dp_oob_hotplug_event(struct drm_connector *connector) +static void intel_dp_oob_hotplug_event(struct drm_connector *connector, + enum drm_connector_hpd_state hpd_state) { struct intel_encoder *encoder = intel_attached_encoder(to_intel_connector(connector)); struct drm_i915_private *i915 = to_i915(connector->dev); + bool hpd_high = hpd_state == DRM_CONNECTOR_HPD_HIGH; + unsigned int hpd_pin = encoder->hpd_pin; + bool need_work = false; spin_lock_irq(&i915->irq_lock); - i915->hotplug.event_bits |= BIT(encoder->hpd_pin); + if (hpd_high != test_bit(hpd_pin, &i915->hotplug.oob_hotplug_last_state)) { + i915->hotplug.event_bits |= BIT(hpd_pin); + + __assign_bit(hpd_pin, &i915->hotplug.oob_hotplug_last_state, hpd_high); + need_work = true; + } spin_unlock_irq(&i915->irq_lock); - queue_delayed_work(system_wq, &i915->hotplug.hotplug_work, 0); + + if (need_work) + queue_delayed_work(system_wq, &i915->hotplug.hotplug_work, 0); } static const struct drm_connector_funcs intel_dp_connector_funcs = { diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index fa14da84362e..e1e4ee1ab7df 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -138,6 +138,9 @@ struct i915_hotplug { /* Whether or not to count short HPD IRQs in HPD storms */ u8 hpd_short_storm_enabled; + /* Last state reported by oob_hotplug_event for each encoder */ + unsigned long oob_hotplug_last_state; + /* * if we get a HPD irq from DP and a HPD irq from non-DP * the non-DP HPD could block the workqueue on a mode config diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index c1d8c23baa39..ea9cb1d71fd2 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -59,7 +59,6 @@ struct dp_altmode { struct typec_displayport_data data; enum dp_state state; - bool hpd; struct mutex lock; /* device lock */ struct work_struct work; @@ -143,10 +142,8 @@ static int dp_altmode_status_update(struct dp_altmode *dp) if (!ret) dp->state = DP_STATE_CONFIGURE; } else { - if (dp->hpd != hpd) { - drm_connector_oob_hotplug_event(dp->connector_fwnode); - dp->hpd = hpd; - } + drm_connector_oob_hotplug_event(dp->connector_fwnode, + hpd ? DRM_CONNECTOR_HPD_HIGH : DRM_CONNECTOR_HPD_LOW); } return ret; @@ -573,8 +570,7 @@ void dp_altmode_remove(struct typec_altmode *alt) cancel_work_sync(&dp->work); if (dp->connector_fwnode) { - if (dp->hpd) - drm_connector_oob_hotplug_event(dp->connector_fwnode); + drm_connector_oob_hotplug_event(dp->connector_fwnode, DRM_CONNECTOR_HPD_LOW); fwnode_handle_put(dp->connector_fwnode); } diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 5166186146f4..5670f7d18440 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1141,7 +1141,8 @@ struct drm_connector_funcs { * This will get called when a hotplug-event for a drm-connector * has been received from a source outside the display driver / device. */ - void (*oob_hotplug_event)(struct drm_connector *connector); + void (*oob_hotplug_event)(struct drm_connector *connector, + enum drm_connector_status status); /** * @debugfs_init: @@ -1749,7 +1750,8 @@ drm_connector_is_unregistered(struct drm_connector *connector) DRM_CONNECTOR_UNREGISTERED; } -void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode); +void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode, + enum drm_connector_status status); const char *drm_get_connector_type_name(unsigned int connector_type); const char *drm_get_connector_status_name(enum drm_connector_status status); const char *drm_get_subpixel_order_name(enum subpixel_order order); From patchwork Fri Apr 29 19:57:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 567550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C80EDC433FE for ; Fri, 29 Apr 2022 19:57:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380448AbiD2UBB (ORCPT ); Fri, 29 Apr 2022 16:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380444AbiD2UA5 (ORCPT ); Fri, 29 Apr 2022 16:00:57 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6D5694B0 for ; Fri, 29 Apr 2022 12:57:37 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id l19so11734102ljb.7 for ; Fri, 29 Apr 2022 12:57:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SqMz6+QA40GWihsDI2sybGR2gK7KNbiJwJGp8fjNk80=; b=MtCRAIFnfLZUrDUX5UFQZqf2hTBZYDYuPU1iAUIBIABeOJn6mQ/ulydY9I6+XwXAlh a+YJFB1B6V0UCJvEb1bk4uzcXfViufL71Woz3R/7aTKdSBmpkOEiztGmhrycjiB+/Ocj AqPnacpAjusZiSM9aI/5VlsYczvM59+jzoDErjspgXvmWoxeAtY3PjxaQue2Ti62uaMi z3RtlHH5NH1GvbXfOVZ1/vegXyOSlvGR+xNmnzPOlsfbNOBQG15LEeb5WXG92NJ/YWn6 ni2JtozGH8fXugekhAx5zjgy/VOcfF1j2YquUAw4EcNGbW/JSJ6DegHDhZCb/WJ9pv/+ wgpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SqMz6+QA40GWihsDI2sybGR2gK7KNbiJwJGp8fjNk80=; b=idugJI9j57+Z7WG9EUgscI6Bf8CFLZUeWPKl1ND2KXnrAu3Rr8k8AZQK4cxvlaDZLB 77s2vvwbciQxQIr1zD+iIkstg3hNHuBVnn8N5+OczUkGwbfXbt4e5z7RidrDQn5ff1A8 w+ecjHQ0pE+MhLRnZEETIzJzERbdT2E/h4vsjF+y6qqpn/Z/SV5DQXATqx2o9ElFT73Q 7jW8wvVhp9so3tBVHff6ioZtmsMsjJ8k0GJa9WTioDemmsj/DzVd+8mAWWJi2D178Dtd 3ieWDZX4wySOizJMtSWpscbbA8TgtfhQj6qJU34LQzhmB84FfEstieyprmmFj1AEfCnV CQnQ== X-Gm-Message-State: AOAM532o3UMYjhdX48R9mATO6rSqusaoHybA0JSi+U7BaOExziJmXn7t mAM1FyTdyHyKhRaM7ZR1qJK56L/qd56KRQ== X-Google-Smtp-Source: ABdhPJwutlRCQm7Ts3tuPRWgP036d46B10TsEYXjiWciXpakVkQ8/p7sXMJj+y6carkW0PXYyxz80A== X-Received: by 2002:a2e:bc0c:0:b0:24f:166c:9279 with SMTP id b12-20020a2ebc0c000000b0024f166c9279mr498455ljf.504.1651262256130; Fri, 29 Apr 2022 12:57:36 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b0047255d2118csm10601lfh.187.2022.04.29.12.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 12:57:35 -0700 (PDT) From: Dmitry Baryshkov To: Bjorn Andersson Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [RFC PATCH v2 3/5] drm/bridge_connector: implement oob_hotplug_event Date: Fri, 29 Apr 2022 22:57:29 +0300 Message-Id: <20220429195731.3716446-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429195731.3716446-1-dmitry.baryshkov@linaro.org> References: <20220429195731.3716446-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Implement the oob_hotplug_event() callback. Translate it to the the HPD notification sent to the HPD bridge in the chain. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_bridge_connector.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c index a0b742ebb330..b14af1c7ac07 100644 --- a/drivers/gpu/drm/drm_bridge_connector.c +++ b/drivers/gpu/drm/drm_bridge_connector.c @@ -123,6 +123,17 @@ static void drm_bridge_connector_hpd_cb(void *cb_data, drm_kms_helper_hotplug_event(dev); } +static void drm_bridge_connector_oob_hotplug_event(struct drm_connector *connector, + enum drm_connector_status status) +{ + struct drm_bridge_connector *bridge_connector = + to_drm_bridge_connector(connector); + struct drm_bridge *hpd = bridge_connector->bridge_hpd; + + if (hpd) + drm_bridge_hpd_notify(hpd, status); +} + /** * drm_bridge_connector_enable_hpd - Enable hot-plug detection for the connector * @connector: The DRM bridge connector @@ -233,6 +244,7 @@ static const struct drm_connector_funcs drm_bridge_connector_funcs = { .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, .debugfs_init = drm_bridge_connector_debugfs_init, + .oob_hotplug_event = drm_bridge_connector_oob_hotplug_event, }; /* ----------------------------------------------------------------------------- From patchwork Fri Apr 29 19:57:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 567549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A498DC4332F for ; Fri, 29 Apr 2022 19:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380452AbiD2UBD (ORCPT ); Fri, 29 Apr 2022 16:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380451AbiD2UA6 (ORCPT ); Fri, 29 Apr 2022 16:00:58 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFF12A5E8A for ; Fri, 29 Apr 2022 12:57:38 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id c15so11722144ljr.9 for ; Fri, 29 Apr 2022 12:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G7PbuXYKXlI64VMOZ2GSnxEyqdNqbhMYiveQLAlQZfs=; b=FKL6/d3WvwaWlVhUpHO20k5LvcxnN1F/KCMjndtRu7VWwPPRT13rEgIdGYUkrRbgZT pYNQtAsGBEQctm+loU1bkA045oMN0oEQaXDoBwFQaTt47f1iMT8DoQvZ+Dw1dUPdfeDt ir/cY8QQFEwU6T+o5CVrpJh/xnetwe4Sdt8U6DonJcHE9oAbCuay39Zzvy/1p5FkefJr Y+0YIPktabgil5WnafdgperzThDBWke6v+rG2oP8ypTRExn0q7LzLJIc/rn+k2cXV+Ls Tccotfup2kkp8XuwFVLP3KTDSfvHV4+r+MlRNLj6vqnCO8hPTpQtGJvwBxc6/v3EN9XL hOtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G7PbuXYKXlI64VMOZ2GSnxEyqdNqbhMYiveQLAlQZfs=; b=bhWJq/Toz+ITbgu4ZOolkbTlNgy/ZA1HDnOk8KQGM1JcdqspvA4EQqm1cFtx+gkqAY Pft+zqDLE2/byPgyWhYdkovZYGJQrthUfPmAnNNAGmg/akTjdjbIUOCawgqiFw1y9vow IJ42r27tpxJsHcThdyEDPZMtvGvza1NbcRD3Hd9Ob2gdS2VwVtschiKsz2V4x4DOGrir E5fb42RtB7+eaf+1VWDQrG/RXp3nWMvW1B5vKDyhCRuk9yGiS36HYCH50/QvQShlbsCX X+WZYvKvsSUaPM4z/6RYLahj1AEMDhgq/C1t8QUK+v8lNhEoSx0HR0X8f+EW/WsbbCLd Kmsw== X-Gm-Message-State: AOAM530BoHDePRFOmUo8kKSan6tBTrgT7tReI5LpPK33n0Kr9AKygtRF Xkny65uruCENX+9bSZy3hY5fYscHdpix2A== X-Google-Smtp-Source: ABdhPJwOFLNSXlfXXcWjTwVAPb1i8v2YxfySvMDChH5s2kqre1hVwU8rr7XDvPGNGCpBwh+uLiprHg== X-Received: by 2002:a2e:988a:0:b0:24f:364d:6d09 with SMTP id b10-20020a2e988a000000b0024f364d6d09mr497376ljj.49.1651262256983; Fri, 29 Apr 2022 12:57:36 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b0047255d2118csm10601lfh.187.2022.04.29.12.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 12:57:36 -0700 (PDT) From: Dmitry Baryshkov To: Bjorn Andersson Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [RFC PATCH v2 4/5] drm/msm/dp: remove most of usbpd-related remains Date: Fri, 29 Apr 2022 22:57:30 +0300 Message-Id: <20220429195731.3716446-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429195731.3716446-1-dmitry.baryshkov@linaro.org> References: <20220429195731.3716446-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Remove most of remains of downstream usbpd code. Mainline kernel uses different approach for managing Type-C / USB-PD, so this remains unused. Do not touch usbpd callbacks for now, since they look usefull enough as an example of how to handle connect/disconnect (to be rewritten into . Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/Makefile | 1 - drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 - drivers/gpu/drm/msm/dp/dp_debug.c | 6 +-- drivers/gpu/drm/msm/dp/dp_debug.h | 4 +- drivers/gpu/drm/msm/dp/dp_display.c | 42 +++------------- drivers/gpu/drm/msm/dp/dp_hpd.c | 67 ------------------------- drivers/gpu/drm/msm/dp/dp_hpd.h | 78 ----------------------------- drivers/gpu/drm/msm/dp/dp_panel.h | 1 - drivers/gpu/drm/msm/dp/dp_power.c | 2 +- drivers/gpu/drm/msm/dp/dp_power.h | 3 +- 10 files changed, 13 insertions(+), 192 deletions(-) delete mode 100644 drivers/gpu/drm/msm/dp/dp_hpd.c delete mode 100644 drivers/gpu/drm/msm/dp/dp_hpd.h diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile index 66395ee0862a..c417443168f6 100644 --- a/drivers/gpu/drm/msm/Makefile +++ b/drivers/gpu/drm/msm/Makefile @@ -123,7 +123,6 @@ msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \ dp/dp_ctrl.o \ dp/dp_display.o \ dp/dp_drm.o \ - dp/dp_hpd.o \ dp/dp_link.o \ dp/dp_panel.o \ dp/dp_parser.o \ diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h index 0745fde01b45..52648b56f54b 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.h +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h @@ -14,7 +14,6 @@ #include "dp_catalog.h" struct dp_ctrl { - bool orientation; atomic_t aborted; u32 pixel_rate; bool wide_bus_en; diff --git a/drivers/gpu/drm/msm/dp/dp_debug.c b/drivers/gpu/drm/msm/dp/dp_debug.c index 5e35033ba3e4..3bba901afe33 100644 --- a/drivers/gpu/drm/msm/dp/dp_debug.c +++ b/drivers/gpu/drm/msm/dp/dp_debug.c @@ -21,7 +21,6 @@ struct dp_debug_private { struct dentry *root; - struct dp_usbpd *usbpd; struct dp_link *link; struct dp_panel *panel; struct drm_connector *connector; @@ -232,14 +231,14 @@ static void dp_debug_init(struct dp_debug *dp_debug, struct drm_minor *minor) } struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, - struct dp_usbpd *usbpd, struct dp_link *link, + struct dp_link *link, struct drm_connector *connector, struct drm_minor *minor) { struct dp_debug_private *debug; struct dp_debug *dp_debug; int rc; - if (!dev || !panel || !usbpd || !link) { + if (!dev || !panel || !link) { DRM_ERROR("invalid input\n"); rc = -EINVAL; goto error; @@ -252,7 +251,6 @@ struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, } debug->dp_debug.debug_en = false; - debug->usbpd = usbpd; debug->link = link; debug->panel = panel; debug->dev = dev; diff --git a/drivers/gpu/drm/msm/dp/dp_debug.h b/drivers/gpu/drm/msm/dp/dp_debug.h index 8c0d0b5178fd..be350cb393ee 100644 --- a/drivers/gpu/drm/msm/dp/dp_debug.h +++ b/drivers/gpu/drm/msm/dp/dp_debug.h @@ -42,7 +42,7 @@ struct dp_debug { * for debugfs input to be communicated with existing modules */ struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, - struct dp_usbpd *usbpd, struct dp_link *link, + struct dp_link *link, struct drm_connector *connector, struct drm_minor *minor); @@ -59,7 +59,7 @@ void dp_debug_put(struct dp_debug *dp_debug); static inline struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, - struct dp_usbpd *usbpd, struct dp_link *link, + struct dp_link *link, struct drm_connector *connector, struct drm_minor *minor) { return ERR_PTR(-EINVAL); diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index c38832304353..454c21e702ae 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -14,7 +14,6 @@ #include "msm_drv.h" #include "msm_kms.h" -#include "dp_hpd.h" #include "dp_parser.h" #include "dp_power.h" #include "dp_catalog.h" @@ -88,7 +87,6 @@ struct dp_display_private { struct platform_device *pdev; struct dentry *root; - struct dp_usbpd *usbpd; struct dp_parser *parser; struct dp_power *power; struct dp_catalog *catalog; @@ -98,7 +96,6 @@ struct dp_display_private { struct dp_ctrl *ctrl; struct dp_debug *debug; - struct dp_usbpd_cb usbpd_cb; struct dp_display_mode dp_mode; struct msm_dp dp_display; @@ -442,7 +439,7 @@ static void dp_display_host_init(struct dp_display_private *dp) dp->dp_display.connector_type, dp->core_initialized, dp->phy_initialized); - dp_power_init(dp->power, false); + dp_power_init(dp->power); dp_ctrl_reset_irq_ctrl(dp->ctrl, true); dp_aux_init(dp->aux); dp->core_initialized = true; @@ -460,16 +457,14 @@ static void dp_display_host_deinit(struct dp_display_private *dp) dp->core_initialized = false; } -static int dp_display_usbpd_configure_cb(struct device *dev) +static int dp_display_usbpd_configure(struct dp_display_private *dp) { - struct dp_display_private *dp = dev_get_dp_display_private(dev); - dp_display_host_phy_init(dp); return dp_display_process_hpd_high(dp); } -static int dp_display_usbpd_disconnect_cb(struct device *dev) +static int dp_display_usbpd_disconnect(struct dp_display_private *dp) { return 0; } @@ -535,11 +530,10 @@ static int dp_display_handle_irq_hpd(struct dp_display_private *dp) return 0; } -static int dp_display_usbpd_attention_cb(struct device *dev) +static int dp_display_usbpd_attention(struct dp_display_private *dp) { int rc = 0; u32 sink_request; - struct dp_display_private *dp = dev_get_dp_display_private(dev); /* check for any test request issued by sink */ rc = dp_link_process_request(dp->link); @@ -558,13 +552,9 @@ static int dp_display_usbpd_attention_cb(struct device *dev) static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data) { - struct dp_usbpd *hpd = dp->usbpd; u32 state; int ret; - if (!hpd) - return 0; - mutex_lock(&dp->event_mutex); state = dp->hpd_state; @@ -588,7 +578,7 @@ static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data) return 0; } - ret = dp_display_usbpd_configure_cb(&dp->pdev->dev); + ret = dp_display_usbpd_configure(dp); if (ret) { /* link train failed */ dp->hpd_state = ST_DISCONNECTED; } else { @@ -626,12 +616,8 @@ static void dp_display_handle_plugged_change(struct msm_dp *dp_display, static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data) { - struct dp_usbpd *hpd = dp->usbpd; u32 state; - if (!hpd) - return 0; - mutex_lock(&dp->event_mutex); state = dp->hpd_state; @@ -719,7 +705,7 @@ static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data) return 0; } - dp_display_usbpd_attention_cb(&dp->pdev->dev); + dp_display_usbpd_attention(dp); drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n", dp->dp_display.connector_type, state); @@ -741,24 +727,10 @@ static int dp_init_sub_modules(struct dp_display_private *dp) { int rc = 0; struct device *dev = &dp->pdev->dev; - struct dp_usbpd_cb *cb = &dp->usbpd_cb; struct dp_panel_in panel_in = { .dev = dev, }; - /* Callback APIs used for cable status change event */ - cb->configure = dp_display_usbpd_configure_cb; - cb->disconnect = dp_display_usbpd_disconnect_cb; - cb->attention = dp_display_usbpd_attention_cb; - - dp->usbpd = dp_hpd_get(dev, cb); - if (IS_ERR(dp->usbpd)) { - rc = PTR_ERR(dp->usbpd); - DRM_ERROR("failed to initialize hpd, rc = %d\n", rc); - dp->usbpd = NULL; - goto error; - } - dp->parser = dp_parser_get(dp->pdev); if (IS_ERR(dp->parser)) { rc = PTR_ERR(dp->parser); @@ -1527,7 +1499,7 @@ void msm_dp_debugfs_init(struct msm_dp *dp_display, struct drm_minor *minor) dp = container_of(dp_display, struct dp_display_private, dp_display); dev = &dp->pdev->dev; - dp->debug = dp_debug_get(dev, dp->panel, dp->usbpd, + dp->debug = dp_debug_get(dev, dp->panel, dp->link, dp->dp_display.connector, minor); if (IS_ERR(dp->debug)) { diff --git a/drivers/gpu/drm/msm/dp/dp_hpd.c b/drivers/gpu/drm/msm/dp/dp_hpd.c deleted file mode 100644 index db98a1d431eb..000000000000 --- a/drivers/gpu/drm/msm/dp/dp_hpd.c +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. - */ - -#define pr_fmt(fmt) "[drm-dp] %s: " fmt, __func__ - -#include -#include - -#include "dp_hpd.h" - -/* DP specific VDM commands */ -#define DP_USBPD_VDM_STATUS 0x10 -#define DP_USBPD_VDM_CONFIGURE 0x11 - -/* USBPD-TypeC specific Macros */ -#define VDM_VERSION 0x0 -#define USB_C_DP_SID 0xFF01 - -struct dp_hpd_private { - struct device *dev; - struct dp_usbpd_cb *dp_cb; - struct dp_usbpd dp_usbpd; -}; - -int dp_hpd_connect(struct dp_usbpd *dp_usbpd, bool hpd) -{ - int rc = 0; - struct dp_hpd_private *hpd_priv; - - hpd_priv = container_of(dp_usbpd, struct dp_hpd_private, - dp_usbpd); - - if (!hpd_priv->dp_cb || !hpd_priv->dp_cb->configure - || !hpd_priv->dp_cb->disconnect) { - pr_err("hpd dp_cb not initialized\n"); - return -EINVAL; - } - if (hpd) - hpd_priv->dp_cb->configure(hpd_priv->dev); - else - hpd_priv->dp_cb->disconnect(hpd_priv->dev); - - return rc; -} - -struct dp_usbpd *dp_hpd_get(struct device *dev, struct dp_usbpd_cb *cb) -{ - struct dp_hpd_private *dp_hpd; - - if (!cb) { - pr_err("invalid cb data\n"); - return ERR_PTR(-EINVAL); - } - - dp_hpd = devm_kzalloc(dev, sizeof(*dp_hpd), GFP_KERNEL); - if (!dp_hpd) - return ERR_PTR(-ENOMEM); - - dp_hpd->dev = dev; - dp_hpd->dp_cb = cb; - - dp_hpd->dp_usbpd.connect = dp_hpd_connect; - - return &dp_hpd->dp_usbpd; -} diff --git a/drivers/gpu/drm/msm/dp/dp_hpd.h b/drivers/gpu/drm/msm/dp/dp_hpd.h deleted file mode 100644 index 8feec5aa5027..000000000000 --- a/drivers/gpu/drm/msm/dp/dp_hpd.h +++ /dev/null @@ -1,78 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. - */ - -#ifndef _DP_HPD_H_ -#define _DP_HPD_H_ - -//#include - -#include -#include - -enum plug_orientation { - ORIENTATION_NONE, - ORIENTATION_CC1, - ORIENTATION_CC2, -}; - -/** - * struct dp_usbpd - DisplayPort status - * - * @orientation: plug orientation configuration - * @low_pow_st: low power state - * @adaptor_dp_en: adaptor functionality enabled - * @multi_func: multi-function preferred - * @usb_config_req: request to switch to usb - * @exit_dp_mode: request exit from displayport mode - * @hpd_irq: Change in the status since last message - * @alt_mode_cfg_done: bool to specify alt mode status - * @debug_en: bool to specify debug mode - * @connect: simulate disconnect or connect for debug mode - */ -struct dp_usbpd { - enum plug_orientation orientation; - bool low_pow_st; - bool adaptor_dp_en; - bool multi_func; - bool usb_config_req; - bool exit_dp_mode; - bool hpd_irq; - bool alt_mode_cfg_done; - bool debug_en; - - int (*connect)(struct dp_usbpd *dp_usbpd, bool hpd); -}; - -/** - * struct dp_usbpd_cb - callback functions provided by the client - * - * @configure: called by usbpd module when PD communication has - * been completed and the usb peripheral has been configured on - * dp mode. - * @disconnect: notify the cable disconnect issued by usb. - * @attention: notify any attention message issued by usb. - */ -struct dp_usbpd_cb { - int (*configure)(struct device *dev); - int (*disconnect)(struct device *dev); - int (*attention)(struct device *dev); -}; - -/** - * dp_hpd_get() - setup hpd module - * - * @dev: device instance of the caller - * @cb: struct containing callback function pointers. - * - * This function allows the client to initialize the usbpd - * module. The module will communicate with HPD module. - */ -struct dp_usbpd *dp_hpd_get(struct device *dev, struct dp_usbpd_cb *cb); - -int dp_hpd_register(struct dp_usbpd *dp_usbpd); -void dp_hpd_unregister(struct dp_usbpd *dp_usbpd); -int dp_hpd_connect(struct dp_usbpd *dp_usbpd, bool hpd); - -#endif /* _DP_HPD_H_ */ diff --git a/drivers/gpu/drm/msm/dp/dp_panel.h b/drivers/gpu/drm/msm/dp/dp_panel.h index d861197ac1c8..7571c42d8f4e 100644 --- a/drivers/gpu/drm/msm/dp/dp_panel.h +++ b/drivers/gpu/drm/msm/dp/dp_panel.h @@ -10,7 +10,6 @@ #include "dp_aux.h" #include "dp_link.h" -#include "dp_hpd.h" struct edid; diff --git a/drivers/gpu/drm/msm/dp/dp_power.c b/drivers/gpu/drm/msm/dp/dp_power.c index d9e011775ad8..faa3bfbccc9e 100644 --- a/drivers/gpu/drm/msm/dp/dp_power.c +++ b/drivers/gpu/drm/msm/dp/dp_power.c @@ -352,7 +352,7 @@ void dp_power_client_deinit(struct dp_power *dp_power) } -int dp_power_init(struct dp_power *dp_power, bool flip) +int dp_power_init(struct dp_power *dp_power) { int rc = 0; struct dp_power_private *power = NULL; diff --git a/drivers/gpu/drm/msm/dp/dp_power.h b/drivers/gpu/drm/msm/dp/dp_power.h index e3f959ffae12..a3dec200785e 100644 --- a/drivers/gpu/drm/msm/dp/dp_power.h +++ b/drivers/gpu/drm/msm/dp/dp_power.h @@ -26,13 +26,12 @@ struct dp_power { * dp_power_init() - enable power supplies for display controller * * @power: instance of power module - * @flip: bool for flipping gpio direction * return: 0 if success or error if failure. * * This API will turn on the regulators and configures gpio's * aux/hpd. */ -int dp_power_init(struct dp_power *power, bool flip); +int dp_power_init(struct dp_power *power); /** * dp_power_deinit() - turn off regulators and gpios. From patchwork Fri Apr 29 19:57:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 568221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EFF3C433EF for ; Fri, 29 Apr 2022 19:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352482AbiD2UBC (ORCPT ); Fri, 29 Apr 2022 16:01:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380454AbiD2UBB (ORCPT ); Fri, 29 Apr 2022 16:01:01 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7523EA888F for ; Fri, 29 Apr 2022 12:57:39 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id w1so15856232lfa.4 for ; Fri, 29 Apr 2022 12:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eClHtbNiyjfQMFNU+LbIHUtg8OiaLij9Jf6MKVBO3/w=; b=O1EtoYK8JCQCkenpxDnCOCsTYxo0VODpEHOyZTQhHF1TGIPTVGLEpB9oTJBCQwCHcw nL5RYgymewRJddvp0vTxXU89g46rHg/An+VRKc20cW4Da6S////L2BBH1ubC0HulOMjY ADpOrnFgcrthGZK3nSq3f8pVdIML3q9Md5ZnR9agV07Y4G8Ntj5YJmGqKIUcWFP0tumR C3yJ2j3hk4Q8yaa4dFnqNLBB5dhHDWTkJZlGqwLqyTcGMhKW9T/pD/YmQzUzz97jegC+ AbjiPx7q0m0jHX/+QA9wHP2b31f7z+W39EhE9+fbUljLk7VXjtjIqDqYpMsDN4HeBZv1 y8jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eClHtbNiyjfQMFNU+LbIHUtg8OiaLij9Jf6MKVBO3/w=; b=H1WsEOejx/fArr1B0QZd62xvJD7a9968tUG0qpO7E9Fvi0o6tjgqtS27ePE3YH+Viw DXEjdiT2CfHxz2AIkZICO2OAyDsUjB72M1Sv2oxaoczIzlTB1fEnFUfhmEkBJOUOj8QY Vcj6ejAci5Z2mA5UUFzmSEUAF/3n3GJ4GLt6P8cjXFyquKBVdCn7tajrZu23QEFLOsPr S96NTc5h+ZovgFKnhAvznlmOARsPYRlRwmeZOYAgIDUtiYrTSXIsDsnEQ8PNMHnH9HLN plwlUyjd9SicqO5YP2I+YnLgX0+bmWk0aETwJibCdd8LLPsKzgTQaWxwf90JoJ1OXmgM bmbg== X-Gm-Message-State: AOAM532QzfqD2lFt0tJAVtkLDqMpdwjcapYAjCjQ6LB/TnkQzGwAgADS BfRfJkXMim05/2jE+YE8RsFdzA== X-Google-Smtp-Source: ABdhPJwSQtm1XQHdRHRT3NywhR9YSG/M+3nXg2H7ZIiOA8iyPR2tX8KWIRRjEJh+CAquDpPqswQddA== X-Received: by 2002:a05:6512:12c8:b0:471:c14e:1edf with SMTP id p8-20020a05651212c800b00471c14e1edfmr665903lfg.144.1651262257796; Fri, 29 Apr 2022 12:57:37 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b0047255d2118csm10601lfh.187.2022.04.29.12.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 12:57:37 -0700 (PDT) From: Dmitry Baryshkov To: Bjorn Andersson Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [RFC PATCH v2 5/5] drm/msm/dp: Implement hpd_notify() Date: Fri, 29 Apr 2022 22:57:31 +0300 Message-Id: <20220429195731.3716446-6-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429195731.3716446-1-dmitry.baryshkov@linaro.org> References: <20220429195731.3716446-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bjorn Andersson The Qualcomm DisplayPort driver contains traces of the necessary plumbing to hook up USB HPD, in the form of the dp_hpd module and the dp_usbpd_cb struct. Use this as basis for implementing the hpd_notify() callback, by amending the dp_hpd module with the missing logic. Overall the solution is similar to what's done downstream, but upstream all the code to disect the HPD notification lives on the calling side of drm_connector_oob_hotplug_event(). drm_connector_oob_hotplug_event() performs the lookup of the drm_connector based on fwnode, hence the need to assign the fwnode in dp_drm_connector_init(). Signed-off-by: Bjorn Andersson [DB: rebased to use drm_bridge_connector] Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_display.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_drm.c | 3 +++ drivers/gpu/drm/msm/dp/dp_drm.h | 2 ++ 4 files changed, 29 insertions(+) diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 454c21e702ae..35004640d42a 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -83,6 +83,8 @@ struct dp_display_private { bool hpd_irq_on; bool audio_supported; + bool connected; + struct drm_device *drm_dev; struct platform_device *pdev; struct dentry *root; @@ -1272,6 +1274,7 @@ static int dp_display_probe(struct platform_device *pdev) if (!desc) return -EINVAL; + dp->dp_display.dev = &pdev->dev; dp->pdev = pdev; dp->name = "drm_dp"; dp->dp_display.connector_type = desc->connector_type; @@ -1761,3 +1764,23 @@ void dp_bridge_mode_set(struct drm_bridge *drm_bridge, dp_display->dp_mode.h_active_low = !!(dp_display->dp_mode.drm_mode.flags & DRM_MODE_FLAG_NHSYNC); } + +void dp_bridge_hpd_notify(struct drm_bridge *bridge, + enum drm_connector_status status) +{ + struct msm_dp_bridge *dp_bridge = to_dp_bridge(bridge); + struct msm_dp *dp = dp_bridge->dp_display; + struct dp_display_private *dp_display = container_of(dp, struct dp_display_private, dp_display); + + drm_dbg_dp(dp_display->drm_dev, "status: %d connected: %d\n", status, dp_display->connected); + + if (!dp_display->connected && status == connector_status_connected) { + dp_display->connected = true; + dp_display_usbpd_configure(dp_display); + } else if (status != connector_status_connected) { + dp_display->connected = false; + dp_display_usbpd_disconnect(dp_display); + } else { + dp_display_usbpd_attention(dp_display); + } +} diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 4f9fe4d7610b..2d2614bc5a14 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.h +++ b/drivers/gpu/drm/msm/dp/dp_display.h @@ -11,6 +11,7 @@ #include "disp/msm_disp_snapshot.h" struct msm_dp { + struct device *dev; struct drm_device *drm_dev; struct device *codec_dev; struct drm_bridge *bridge; diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c index 62d58b9c4647..821cfd37b1fb 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.c +++ b/drivers/gpu/drm/msm/dp/dp_drm.c @@ -68,6 +68,7 @@ static const struct drm_bridge_funcs dp_bridge_ops = { .mode_valid = dp_bridge_mode_valid, .get_modes = dp_bridge_get_modes, .detect = dp_bridge_detect, + .hpd_notify = dp_bridge_hpd_notify, }; struct drm_bridge *dp_bridge_init(struct msm_dp *dp_display, struct drm_device *dev, @@ -138,6 +139,8 @@ struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display) if (IS_ERR(connector)) return connector; + connector->fwnode = fwnode_handle_get(dev_fwnode(dp_display->dev)); + drm_connector_attach_encoder(connector, dp_display->encoder); return connector; diff --git a/drivers/gpu/drm/msm/dp/dp_drm.h b/drivers/gpu/drm/msm/dp/dp_drm.h index f4b1ed1e24f7..3b7480a86844 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.h +++ b/drivers/gpu/drm/msm/dp/dp_drm.h @@ -32,5 +32,7 @@ enum drm_mode_status dp_bridge_mode_valid(struct drm_bridge *bridge, void dp_bridge_mode_set(struct drm_bridge *drm_bridge, const struct drm_display_mode *mode, const struct drm_display_mode *adjusted_mode); +void dp_bridge_hpd_notify(struct drm_bridge *bridge, + enum drm_connector_status status); #endif /* _DP_DRM_H_ */