From nobody Sun Nov 24 23:42:49 2024 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.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 5971B194ACC for ; Fri, 1 Nov 2024 10:19:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730456371; cv=none; b=IWH597e5WIqRyE1aVxDdJtjn96gSAalNYsVLffjdzWexdIojfXQDHvXSWC3UrhErKO3KUWQvx/eZZqmWU8ka8ceh23m/yVC5grVcFR3TcQ20C9lMocnvNQst0Bd7zGWNyF4Jm4xkWQ0eVQ0fOoxWYOcqIgnC9vVFfdgpzFHGaDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730456371; c=relaxed/simple; bh=Pbf6ekV+i45DFn0vAhN81yq5JTl3TzjpRpOOR4scnrw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j0FOt3QnkzcEP65ZwgEkSgVnDr4QFQcfHL3kbPP9onfR6NTjN4jeL4pXYc13Evji4Q1j7TdDdCRk/FBMM81k5KPIzytT0NydN8C2dFQcamWMiBWOMYDfvjfNL6LUUNfFvwarlg1iGjb4DYOovhfg3oYWjbdJajfeXDYuuJkM6wY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=LPDq0nWU; arc=none smtp.client-ip=209.85.208.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LPDq0nWU" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2fb3c3d5513so16626451fa.1 for ; Fri, 01 Nov 2024 03:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730456367; x=1731061167; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=SSyJnhqtzNGB7l1kz5uHZfxocs7V67foS6FdivcD7DM=; b=LPDq0nWUy3/bWgb9gOAemPwNFv7ME4/jBhY5+xIMxjCg7sryILu6836hANayqdZUIu gs1u7LR0CM1GRbZ3uBKuNeooNh/Pw8lOzAl/7+Zqmkp8a/rgzAYmkmzt/rLhFiBWN4LC esF7VSCioNml39fZQqDEXdYaE+g2pNqVFUe5nwIK6dlssJ6MfHM/923WP4GxAx4TdTwN QK20If0rUdSD9q6nC3qPFwDn4Uut6syd6G+jUkwMWPnROkOV++jZcTVPsmQjqgxrc/JN 9dvDV3udKScbJ9yHyZ4fuRYhqFcaekkDSu15AsbnXbBvkFVqO53ByABHrA9XKSAMy+tE 2Dkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730456367; x=1731061167; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SSyJnhqtzNGB7l1kz5uHZfxocs7V67foS6FdivcD7DM=; b=Vd9tkiSXzLGn3CWrunxsZX2AOgPMlr0zm+fJpKeenNAN2iZYwNxGzK4SAMSYdi/wAa vUcgFlz/449Wk5Hp89kVcL3aRO0cDXpl6vyNg518A8l4UGCLLcT84MpuW3eiwP64rTHt piYsVBAJt3PHyIHD0kat8oQ8Ku7nQyAwFABxZI6FhUwoelX8fk22eakRUmIYsd+uxkTa bKZZQorwC64GHak24vP/9Ayx9ASdrgdB5FqpokQ7foOG2OKMt6hEh72R24tYOyQJauY6 dNv4jIzZJB1T0xQhdP6yqz/K75gAkZ4owHQW1GE8txNTDt4FkJSRscHQ5OqiPXqYN1j9 EVAQ== X-Forwarded-Encrypted: i=1; AJvYcCUO9gN8PmZHVDoc3PnZt1TcXrYxew/AvBZcI79HiZ42ZrFXUPIK9qhKJkSuK/XnaBwvegyE1aaJGmxNOsU=@vger.kernel.org X-Gm-Message-State: AOJu0YwqSkAmP9DPYHYhjxoZi72cpT1MVp1k5Db7VvoBJzcRsEXJ9uiy uz68YB3t9ULobSOqgF1gzn82DlaKQ93TSTjOYS1Y1KYVpPR1Vmh2RInNXwxYdIA= X-Google-Smtp-Source: AGHT+IGhSWfH6euhYW2znlkFK+r3govgY1LuFIe7fOuMV+C37e3QgH0MbPED7GtFqocAeau78Vvz7w== X-Received: by 2002:a2e:4c12:0:b0:2f6:6074:db71 with SMTP id 38308e7fff4ca-2fdec5f831amr26624951fa.17.1730456367449; Fri, 01 Nov 2024 03:19:27 -0700 (PDT) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fdef5d6ef4sm5197031fa.48.2024.11.01.03.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 03:19:25 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 01 Nov 2024 12:19:08 +0200 Subject: [PATCH RFC v2 7/7] drm/bridge_connector: hook __drm_atomic_helper_connector_hdmi_update_edid() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241101-drm-bridge-hdmi-connector-v2-7-739ef9addf9e@linaro.org> References: <20241101-drm-bridge-hdmi-connector-v2-0-739ef9addf9e@linaro.org> In-Reply-To: <20241101-drm-bridge-hdmi-connector-v2-0-739ef9addf9e@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Phong LE , Inki Dae , Seung-Woo Kim , Kyungmin Park , Krzysztof Kozlowski , Alim Akhtar , Russell King , Chun-Kuang Hu , Philipp Zabel , Matthias Brugger , AngeloGioacchino Del Regno , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Andy Yan , Alain Volmat Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4075; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=Pbf6ekV+i45DFn0vAhN81yq5JTl3TzjpRpOOR4scnrw=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnJKsZAyyzFUbIF1GNuLd1ZpLZ1B2KWEi1m5jD4 rBI+bHjpFKJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZySrGQAKCRCLPIo+Aiko 1bv9B/9aAzBx6TyAdD0HiTY84ACPnO30AoIMqz4lY2qeZr1j/AXgrWjWY+hZqDi6N6X6s8F7ArV QOhiCSvJ/wBqX2oIw4oG6kn/StwLHzUzjvdq5q4vVKjwGKIh6cc8LzyoJi5L1/eI7L59vUDpn0U qHPk1TWzpjbuGNKpe/rT/Ds0c7458AmhADW48RgNU0NAjvbZYvcLT1IKTfs0ZTNtJlqnZnGSnA4 KD+5OOhfX5lF5o9KH9K9DnZFeaL7wehWOzHLWlqjaWakWwIgCQzluX4lK5NCstgZnkT9XyOHW0q YWrQ6YVSm+zTkO8F578PtuXJBzB9WY50mHLRzLH1cDQL1qdN X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Extend drm_bridge_connector code to read the EDID and use it to update connector status if the bridge chain implements HDMI bridge. Performing it from the generic location minimizes individual bridge's code and enforces standard behaviour from all corresponding drivers. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/display/drm_bridge_connector.c | 65 ++++++++++++++++++++--= ---- 1 file changed, 51 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/d= rm/display/drm_bridge_connector.c index 12ab9f14cc8a8672478ae2804c9a68d766d88ea5..4069e0f972d5fcabf7e07238583= fc9ea89ab113f 100644 --- a/drivers/gpu/drm/display/drm_bridge_connector.c +++ b/drivers/gpu/drm/display/drm_bridge_connector.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include =20 @@ -175,17 +176,53 @@ static void drm_bridge_connector_disable_hpd(struct d= rm_connector *connector) * Bridge Connector Functions */ =20 +static const struct drm_edid * +drm_bridge_connector_read_edid(struct drm_connector *connector, + enum drm_connector_status status) +{ + struct drm_bridge_connector *bridge_connector =3D + to_drm_bridge_connector(connector); + const struct drm_edid *drm_edid; + struct drm_bridge *bridge; + + bridge =3D bridge_connector->bridge_edid; + if (!bridge) + return NULL; + + if (status !=3D connector_status_connected) + return NULL; + + drm_edid =3D drm_bridge_edid_read(bridge, connector); + if (!drm_edid_valid(drm_edid)) { + drm_edid_free(drm_edid); + return NULL; + } + + return drm_edid; +} + static enum drm_connector_status drm_bridge_connector_detect(struct drm_connector *connector, bool force) { struct drm_bridge_connector *bridge_connector =3D to_drm_bridge_connector(connector); struct drm_bridge *detect =3D bridge_connector->bridge_detect; + struct drm_bridge *hdmi =3D bridge_connector->bridge_hdmi; enum drm_connector_status status; =20 if (detect) { status =3D detect->funcs->detect(detect); =20 + if (hdmi) { + const struct drm_edid *drm_edid =3D drm_bridge_connector_read_edid(conn= ector, + status); + int ret; + + ret =3D __drm_atomic_helper_connector_hdmi_update_edid(connector, drm_e= did); + if (ret) + drm_warn(connector->dev, "updating EDID failed with %d\n", ret); + } + drm_bridge_connector_hpd_notify(connector, status); } else { switch (connector->connector_type) { @@ -246,29 +283,29 @@ static const struct drm_connector_funcs drm_bridge_co= nnector_funcs =3D { static int drm_bridge_connector_get_modes_edid(struct drm_connector *conne= ctor, struct drm_bridge *bridge) { + struct drm_bridge_connector *bridge_connector =3D + to_drm_bridge_connector(connector); + struct drm_bridge *hdmi =3D bridge_connector->bridge_hdmi; enum drm_connector_status status; const struct drm_edid *drm_edid; - int n; =20 status =3D drm_bridge_connector_detect(connector, false); if (status !=3D connector_status_connected) - goto no_edid; + return 0; =20 - drm_edid =3D drm_bridge_edid_read(bridge, connector); - if (!drm_edid_valid(drm_edid)) { + /* In HDMI setup the EDID has been read and handled as a part of .detect(= ) */ + if (!hdmi) { + drm_edid =3D drm_bridge_connector_read_edid(connector, status); + if (!drm_edid) { + drm_edid_connector_update(connector, NULL); + return 0; + } + + drm_edid_connector_update(connector, drm_edid); drm_edid_free(drm_edid); - goto no_edid; } =20 - drm_edid_connector_update(connector, drm_edid); - n =3D drm_edid_connector_add_modes(connector); - - drm_edid_free(drm_edid); - return n; - -no_edid: - drm_edid_connector_update(connector, NULL); - return 0; + return drm_edid_connector_add_modes(connector); } =20 static int drm_bridge_connector_get_modes(struct drm_connector *connector) --=20 2.39.5