From patchwork Fri Nov 1 10:19:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13859128 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BCA02E6B243 for ; Fri, 1 Nov 2024 10:19:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28D5510E98C; Fri, 1 Nov 2024 10:19:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="hLx4f9zb"; dkim-atps=neutral Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9D3EF10E98C for ; Fri, 1 Nov 2024 10:19:26 +0000 (UTC) Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-539f72c8fc1so3077592e87.1 for ; Fri, 01 Nov 2024 03:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730456365; x=1731061165; darn=lists.freedesktop.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=nGgjAKyLcDyP//XG7JzBSUmff5/dvBkAhC31JU8OV0g=; b=hLx4f9zbZg+qz1wnRsaWdixnQrKIlhURbZsp7ur/iB7ncGdACBl9KWEFowdPHaGmWR o67/lRC8VqBjP/u6q3aKc1umoMNLukvB5gGY4+ge411J3LSHb9Rp8y0VaNGdYBW+kTal A8MuNSBNmt0Sbx3mPz3ck5H332BRkUdRp0WTg7FaoPQ8O7tpAjMmt+PG+KnWNu/tDb6o PV8uqn4bOKKFbsPG+qX4FsYLjclzIhyd5EfDfhNJI4hAhVcz7FEZfM+0t9vrcpoaXwWj rzEPbgX6lR9VtUOinVQSc0idIUYYxxeaa0pLEOTIXsUeIwOufAVLBcsRDnDsZCtX9K66 LB+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730456365; x=1731061165; 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=nGgjAKyLcDyP//XG7JzBSUmff5/dvBkAhC31JU8OV0g=; b=nnXj6u6dGom32069G+mI/fDy92X7/lfm+tQg2962UJglybbu+/W6TS5rM4yPRDgbjd v5KX/BBWEyfpdLSetxVzIdGuCsoZOlSv6Ah3COsmxiTs18rvWBTOlay55FXNkaBhJCEe Kfn7sUwqNcoK3fmWAwcue/IeCICDAK1Y8vTpdW+M5adkHWJzCTwhKGm/zmKkC3mU8FTV yKGnuQ3hppZ/uUSVnn5LTawESgszdkyNkdviTQ7mL9DSLbKSYCx0O/ZAG/z5DgZiUdWB lUYvH5aJyZD3VmMASMAu0uKgoRYdg0b6JNu9yX9uqWuAJfv/tHQ+1QjyYYaIutWGQLvm OMjw== X-Gm-Message-State: AOJu0YysRerIVDmc1ULsN37uMefpGElvZrAIBGtbXF+xECpNx6QRPxP/ 9Qvjm6d8ep4LSLL+H+kx19K0q0Xc+4cNOAsxJESLxbr0eX0+ObO6M5ZSzezun4s= X-Google-Smtp-Source: AGHT+IGrg+MWNfrCkOop6SzsPvLBRfWp/DqEaW2dXOspXiW0SLaKOKmN4JT+lZ8wzfmuDxerrXaXhA== X-Received: by 2002:a2e:bc0b:0:b0:2fb:403c:268b with SMTP id 38308e7fff4ca-2fd059d28c8mr58307211fa.34.1730456364657; Fri, 01 Nov 2024 03:19:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 03:19:23 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 01 Nov 2024 12:19:07 +0200 Subject: [PATCH RFC v2 6/7] drm/display/hdmi: implement connector update functions MIME-Version: 1.0 Message-Id: <20241101-drm-bridge-hdmi-connector-v2-6-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=3910; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=o8zF22Q3lPENAEm/ZYvkUJMiXNxulV8OozkqO4RXQvk=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnJKsZVEQyQuPw+HstvVa+ywD0DzMiBOlZfnHVE KF1rHV9ULuJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZySrGQAKCRCLPIo+Aiko 1fMQCACgMN9amTdAcyKL+du1jF5SGu+FJ0bpmOX/kii6kS9fkFmW3LameFMLXWArrtscsYb0BjH aDoCZmihQEAP8h2xj6l8plf0wv8gfO6BMDn/iXRyNNPoDy+V6aFvFwpm5tVCGyHHghH0z4obR+V pE4Y5Osy7/1lliErcrZZgpCgoOTgIRlGiL1BafbuEgz+0qG5wFZfQO0mcz6c876TN9ml+Uo/ezl tVuxyHU4FxXr/WsNhnV2H5HimCa55xnzoLoHnAU8c1tX5S6FcvR9PR1OBbVO9RcyouOgv8Ky/Id fu2VYo2hsea/slZ4EpRbcAWw1S16Zcmcf4ZKPK+rJq80q2cX X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The HDMI Connectors need to perform a variety of tasks when the HDMI connector state changes. Such tasks include setting or invalidating CEC address, notifying HDMI codec driver, updating scrambler data, etc. Implementing such tasks in a driver-specific callbacks is error prone. Start implementing the generic helper function (currently handling only the HDMI Codec framework) to be used by driver utilizing HDMI Connector framework. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 56 +++++++++++++++++++++++++ include/drm/display/drm_hdmi_state_helper.h | 4 ++ 2 files changed, 60 insertions(+) diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c index feb7a3a759811aed70c679be8704072093e2a79b..dc9d0cc162b2197dcbadda26686a9c5652e74107 100644 --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c @@ -748,3 +748,59 @@ drm_atomic_helper_connector_hdmi_clear_audio_infoframe(struct drm_connector *con return ret; } EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_clear_audio_infoframe); + +/** + * __drm_atomic_helper_connector_hdmi_update_edid - Update the HDMI Connector basing on passed EDID + * @connector: A pointer to the HDMI connector + * @drm_edid: EDID to process + * + * This function should be called as a part of the .detect() / .detect_ctx() + * and .force() callbacks, updating the HDMI-specific connector's data. The + * function consumes passed EDID, there is no need to free it afterwards. Most + * of the drivers should be able to use + * @drm_atomic_helper_connector_hdmi_update() instead. + * + * Returns: + * Zero on success, error code on failure. + */ +int +__drm_atomic_helper_connector_hdmi_update_edid(struct drm_connector *connector, + const struct drm_edid *drm_edid) +{ + drm_edid_connector_update(connector, drm_edid); + drm_edid_free(drm_edid); + + if (!drm_edid) { + drm_connector_hdmi_codec_plugged_notify(connector, false); + + // TODO: also handle CEC and scramber, HDMI sink disconnected. + + return 0; + } + + drm_connector_hdmi_codec_plugged_notify(connector, true); + + // TODO: also handle CEC and scramber, HDMI sink is now connected. + + return 0; +} +EXPORT_SYMBOL(__drm_atomic_helper_connector_hdmi_update_edid); + +/** + * drm_atomic_helper_connector_hdmi_update - Update the HDMI Connector after reading the EDID + * @connector: A pointer to the HDMI connector + * + * This function should be called as a part of the .detect() / .detect_ctx() + * and .force() callbacks, updating the HDMI-specific connector's data. + * + * Returns: + * Zero on success, error code on failure. + */ +int +drm_atomic_helper_connector_hdmi_update(struct drm_connector *connector) +{ + const struct drm_edid *drm_edid = drm_edid_read(connector); + + return __drm_atomic_helper_connector_hdmi_update_edid(connector, drm_edid); +} +EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update); diff --git a/include/drm/display/drm_hdmi_state_helper.h b/include/drm/display/drm_hdmi_state_helper.h index 2d45fcfa461985065a5e5ad67eddc0b1c556d526..ea0980aa25cbbfdd36f44201888c139b0ee943da 100644 --- a/include/drm/display/drm_hdmi_state_helper.h +++ b/include/drm/display/drm_hdmi_state_helper.h @@ -20,4 +20,8 @@ int drm_atomic_helper_connector_hdmi_clear_audio_infoframe(struct drm_connector int drm_atomic_helper_connector_hdmi_update_infoframes(struct drm_connector *connector, struct drm_atomic_state *state); +int __drm_atomic_helper_connector_hdmi_update_edid(struct drm_connector *connector, + const struct drm_edid *drm_edid); +int drm_atomic_helper_connector_hdmi_update(struct drm_connector *connector); + #endif // DRM_HDMI_STATE_HELPER_H_