From nobody Mon Feb 9 18:43:17 2026 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F86A1E7A42 for ; Mon, 19 Aug 2024 22:38:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107139; cv=none; b=cDQu1JRNbmtiCKh+sxwO5x4Y8ZwFnyC0ki9iH1VarIek0QVjEBLVHN3peltIx1ISJrrkBhWbL3PUmD8L38K/MTiZGURJ7Z1UYQS+inIDVcfrGcqB+rhdU0501oKnL50OG/XDqMOuhECFNSBhoBJTy5xzAIgnM/gB5Vs76UpqmTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107139; c=relaxed/simple; bh=4V2ipobc0QJANgLcRKLlZNLcULLuLPLzgIJNP1W0OjA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qcbGMdIOpMaY+M2oeEtpUj+qPfM0dXd/ElTEKkio6/K2fdOglxz0/iZBTQO6H04qexeH83dQLKml3gFBEqh3y61cDYChiggbep1fhf0+TjJuOe38+jS/ZqeAZQ8EqCNcsalFcVWAbDTzMc73d6SfEg1+sjFNZ+iMjqBxnuWsH38= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=cLXSIE7i; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="cLXSIE7i" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2021537a8e6so27598065ad.2 for ; Mon, 19 Aug 2024 15:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1724107137; x=1724711937; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ywA8OaX1lKwB+QkeZviPO0tfv2glr07Z2pzYI3lLnXA=; b=cLXSIE7i3A5rPEePFBioba0Q6cg5DedcUbRQ5Ep89kFgATSdN8YkOJM4JdTTwtfd3f eiYd8bZfUBVRYy7icKJ+tDidWF8qqiOGOhip+2q1xnsPopErGzT6bWwK9zzRqe1RgTBv AxgRQDdCl2eUsVeXopvwwoRugsApweDA7vcGk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724107137; x=1724711937; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ywA8OaX1lKwB+QkeZviPO0tfv2glr07Z2pzYI3lLnXA=; b=McIu283rvPu3gVGLyYZbotiznUm7FJ2LRSlEgTgDFiUnOQxVz8+YEfP0jOAmf7jLAz 1NrLTG5meelzbnvEUO/nY1axcattQ1Yovje8hJXzy2O6JN0Y0st0rbEjPhMK7qNv9EF6 o6HoM8HLhe/3Kv7OcU6DnMAoqX0N+JlHqIxheHvJhjx8JxZv6XtzaCp95LlynEz3NPca twCyGuyR8TbkDV6XArfyrHcApmJGZjIopfx/3dMiuF67h4eAfbdcnbjcRCmCJjWOrDIb 8qbSm6cB+X4mEXXxS4Y6f6QEOcXkdrRg38kywps1HamUgRBdozgH3qRdepj0LTYJJNNX NxzQ== X-Gm-Message-State: AOJu0Yzh5W3z82ni8rMEbuUpfPTf8jGkxRIVmVbEkY82pEf9TLsZxe/8 tAsdYlt879ax41G7Z+TnOOD3edCrqKF8SESgImdTXzXspMXgof7SYk1gl3GdKg== X-Google-Smtp-Source: AGHT+IHU3fWl4J6FiNvoKYuzaU+U5zGX0CHN6uE8R8CkbVuBd7tiKsG0Va+2cgyvp5/pf3qE90i/nA== X-Received: by 2002:a17:902:d503:b0:201:f5e3:e36d with SMTP id d9443c01a7336-20203ea05d2mr143563805ad.25.1724107136555; Mon, 19 Aug 2024 15:38:56 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-201f03b2874sm66740535ad.308.2024.08.19.15.38.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Aug 2024 15:38:56 -0700 (PDT) From: Stephen Boyd To: chrome-platform@lists.linux.dev Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, devicetree@vger.kernel.org, Douglas Anderson , Pin-yen Lin , Andrzej Hajda , Benson Leung , Conor Dooley , Daniel Vetter , David Airlie , Dmitry Baryshkov , dri-devel@lists.freedesktop.org, Guenter Roeck , Jernej Skrabec , Jonas Karlman , Krzysztof Kozlowski , Laurent Pinchart , Lee Jones , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Prashant Malani , Robert Foss , Rob Herring , Thomas Zimmermann , Tzung-Bi Shih , Alexandre Belloni , Andy Shevchenko , Daniel Scally , Greg Kroah-Hartman , Heikki Krogerus , Ivan Orlov , linux-acpi@vger.kernel.org, linux-usb@vger.kernel.org, Mika Westerberg , "Rafael J . Wysocki" , Sakari Ailus , Vinod Koul Subject: [PATCH v3 09/17] drm/bridge: dp_typec: Allow users to hook hpd notify path Date: Mon, 19 Aug 2024 15:38:23 -0700 Message-ID: <20240819223834.2049862-10-swboyd@chromium.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819223834.2049862-1-swboyd@chromium.org> References: <20240819223834.2049862-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The previous patch added support for no-hpd to drm_dp_typec_bridge code. Allow users of this bridge to hook the HPD notification path of the bridge chain so that they can be made aware of the connector status changing. This helps HPD-less users of the bridge inject the HPD state into their code by using the connector status as a proxy for HPD being asserted or deasserted. In particular, this will help Trogdor/Strongbad boards that need to read the EC's analog mux which steers the DP signal to one or the other USB type-c ports to figure out which type-c port has HPD asserted. Cc: Prashant Malani Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Cc: Dmitry Baryshkov Signed-off-by: Stephen Boyd --- drivers/gpu/drm/bridge/aux-hpd-bridge.c | 30 +++++++++++++++++++++++++ include/drm/bridge/aux-bridge.h | 9 ++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/brid= ge/aux-hpd-bridge.c index adafda4f128f..815dc026718b 100644 --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c @@ -92,6 +92,8 @@ struct drm_dp_typec_bridge_dev { struct auxiliary_device adev; size_t max_lanes; size_t num_typec_ports; + void (*hpd_notify)(void *data, enum drm_connector_status status); + void *hpd_data; }; =20 static inline struct drm_dp_typec_bridge_dev * @@ -323,6 +325,20 @@ devm_drm_dp_typec_bridge_alloc(struct device *parent, = struct device_node *np) } EXPORT_SYMBOL_GPL(devm_drm_dp_typec_bridge_alloc); =20 +/** + * drm_dp_typec_bridge_add_hpd_notify: Register a callback called when the + * bridge chain hpd state changes + * @hpd_notify: callback for bridge hot plug detect events + * @hpd_data: data passed to @hpd_notify callback + */ +void drm_dp_typec_bridge_add_hpd_notify(struct drm_dp_typec_bridge_dev *ty= pec_bridge_dev, + hpd_notify_fn_t hpd_notify, void *hpd_data) +{ + typec_bridge_dev->hpd_notify =3D hpd_notify; + typec_bridge_dev->hpd_data =3D hpd_data; +} +EXPORT_SYMBOL_GPL(drm_dp_typec_bridge_add_hpd_notify); + /** * devm_drm_dp_typec_bridge_add - register a USB type-c DisplayPort bridge * @dev: struct device to tie registration lifetime to @@ -362,6 +378,19 @@ void drm_aux_hpd_bridge_notify(struct device *dev, enu= m drm_connector_status sta } EXPORT_SYMBOL_GPL(drm_aux_hpd_bridge_notify); =20 +static void drm_dp_typec_bridge_hpd_notify(struct drm_bridge *bridge, + enum drm_connector_status status) +{ + struct drm_dp_typec_bridge_data *data; + struct drm_dp_typec_bridge_dev *typec_bridge_dev; + + data =3D to_drm_dp_typec_bridge_data(bridge); + typec_bridge_dev =3D to_drm_dp_typec_bridge_dev(data->hpd_bridge.dev); + + if (typec_bridge_dev->hpd_notify) + typec_bridge_dev->hpd_notify(typec_bridge_dev->hpd_data, status); +} + static int drm_aux_hpd_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -519,6 +548,7 @@ static const struct drm_bridge_funcs drm_dp_typec_bridg= e_funcs =3D { .atomic_reset =3D drm_atomic_helper_bridge_reset, .atomic_duplicate_state =3D drm_atomic_helper_bridge_duplicate_state, .atomic_destroy_state =3D drm_atomic_helper_bridge_destroy_state, + .hpd_notify =3D drm_dp_typec_bridge_hpd_notify, }; =20 static int drm_dp_typec_bridge_orientation_set(struct typec_switch_dev *sw, diff --git a/include/drm/bridge/aux-bridge.h b/include/drm/bridge/aux-bridg= e.h index 73fc8582ec07..300f4a203a9b 100644 --- a/include/drm/bridge/aux-bridge.h +++ b/include/drm/bridge/aux-bridge.h @@ -22,6 +22,8 @@ static inline int drm_aux_bridge_register(struct device *= parent) =20 struct drm_dp_typec_bridge_dev; =20 +typedef void (*hpd_notify_fn_t)(void *data, enum drm_connector_status stat= us); + #if IS_ENABLED(CONFIG_DRM_AUX_HPD_BRIDGE) struct auxiliary_device *devm_drm_dp_hpd_bridge_alloc(struct device *paren= t, struct device_node *np); int devm_drm_dp_hpd_bridge_add(struct device *dev, struct auxiliary_device= *adev); @@ -30,6 +32,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *= parent, void drm_aux_hpd_bridge_notify(struct device *dev, enum drm_connector_stat= us status); struct drm_dp_typec_bridge_dev *devm_drm_dp_typec_bridge_alloc(struct devi= ce *parent, struct device_node *np); +void drm_dp_typec_bridge_add_hpd_notify(struct drm_dp_typec_bridge_dev *ty= pec_bridge_dev, + hpd_notify_fn_t hpd_notify, void *hpd_data); int devm_drm_dp_typec_bridge_add(struct device *dev, struct drm_dp_typec_b= ridge_dev *typec_bridge_dev); #else static inline struct auxiliary_device *devm_drm_dp_hpd_bridge_alloc(struct= device *parent, @@ -55,6 +59,11 @@ devm_drm_dp_typec_bridge_alloc(struct device *parent, st= ruct device_node *np) return NULL; } =20 +static inline void drm_dp_typec_bridge_add_hpd_notify(struct drm_dp_typec_= bridge_dev *typec_bridge_dev, + hpd_notify_fn_t hpd_notify, void *hpd_data) +{ +} + static inline int devm_drm_dp_typec_bridge_add(struct device *dev, struct drm_dp_typec_bridge_dev *typec_bridge_dev) { --=20 https://chromeos.dev