From patchwork Thu Jul 23 01:34:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 2741 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 9F1231C2B5B for ; Thu, 23 Jul 2026 03:37:52 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=collabora.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-24646-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-24646-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 75246309317F for ; Thu, 23 Jul 2026 01:35:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53FB42FD7C3; Thu, 23 Jul 2026 01:35:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="LCBZaNg1" X-Original-To: linux-sunxi@lists.linux.dev Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94469304976 for ; Thu, 23 Jul 2026 01:35:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784770513; cv=none; b=ejJbTXycK/1gUa79L5JcYophaAmyZbhnoYLhZ0sbGS7Y72fIaEyFsxTeva+1L6pLBJY6jTAo0ovNGJykXoW7Ku0s7lmfh/eZfjKBQ7IU2kmCViN3sil37ObgCzQZuoYYEi1yWviuIs7M+0Ky2C8r2Px79aif3OoR6qoZK+LphI8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784770513; c=relaxed/simple; bh=OFVB7kb6sKOuqbakZrPQltL575RF6J7clPMcHjhnDi8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QTXREsnaVHBMTupGOqH4ELPKyKO1xRPqb7WATe/C8vE3XPxzqgKBIMkVVMqO61bo7MYdgXZmnVxZgRto9in3VPEt+s+6m1kJHMrxstMzOI3a7zkIqTUKBvGykPqlQqBgVeAKoXDxP/Z0ozWAmdhedu7jJYL38HcziUK9xMI7yWs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=LCBZaNg1; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784770505; bh=OFVB7kb6sKOuqbakZrPQltL575RF6J7clPMcHjhnDi8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LCBZaNg1QZJITqISqxRfaLl6TcOzN0OktBfXPaDbJwNiEKGIXLf36/9UzZ+EmnKht imr8cIbRLqzK5ZuWUzw24FfxAUaqP/1+CfOk7x1pYXZR+7osnvFEP9W1eJrnqGu8N1 vuAXPdwTtrHMFgoi/ndaBFmO91hKx9CiFgqvJDXxnpngoqHxsD6dE3tRHbIcwCC2f5 woAcKMj/BFvYXHvFIoMfRNEfKZ/knckkCmr2+LO+glyfYJwNS6bH1E19lPG9kHMCU/ XBxm5YKxPUs4pYsZmOybk/mr2hl8hMsaNRyEEfrSHICNXLlip2vcorTX2y3eEzAoF/ Pfre9qKHcCu3Q== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 83DD117E151D; Thu, 23 Jul 2026 03:35:05 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 04:34:54 +0300 Subject: [PATCH v9 05/61] drm/connector: Add HDMI 2.0 scrambler infrastructure Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260723-dw-hdmi-qp-scramb-v9-5-4fb12ea22ac9@collabora.com> References: <20260723-dw-hdmi-qp-scramb-v9-0-4fb12ea22ac9@collabora.com> In-Reply-To: <20260723-dw-hdmi-qp-scramb-v9-0-4fb12ea22ac9@collabora.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Luca Ceresoli , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chen-Yu Tsai , Samuel Holland , Dave Stevenson , =?utf-8?q?Ma=C3=ADra_Canal?= , Raspberry Pi Kernel Maintenance , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Andy Yan , Algea Cao , Daniel Stone , Liu Ying , Phong LE Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-rockchip@lists.infradead.org, Maud Spierings X-Mailer: b4 0.15.2 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Add the connector-level infrastructure to support HDMI 2.0 scrambling: - A drm_connector_hdmi_scrambler_supported() helper to report whether the source supports the scrambling capability, based on the presence of the newly introduced .scrambler_{enable|disable}() callbacks in drm_connector_hdmi_funcs are mandatory - A scrambler_needed flag to be managed by the hdmi state helpers based on the negotiated TMDS character rate and the source/sink scrambling capabilities - A scrambler_enabled flag to track whether scrambling is currently active - A delayed work item (scdc_work) to monitor sink-side scrambling status and retry the setup if the sink resets it - A scdc_work_initialized flag to support lazy initialization of the work item on the first scrambling enable and guard the teardown paths These are intended to be used by SCDC scrambling helpers to coordinate scrambling setup and teardown between the source driver and the DRM core. Tested-by: Maud Spierings Signed-off-by: Cristian Ciocaltea --- drivers/gpu/drm/drm_connector.c | 31 ++++++++++++--- include/drm/drm_connector.h | 83 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 72b630434802..96cca0ca64bd 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -622,12 +622,29 @@ int drmm_connector_hdmi_init(struct drm_device *dev, * default with the actual controller capability. A value of zero keeps * the limit inferred from supported_hdmi_ver. */ - if (hdmi_funcs->supported_hdmi_ver >= HDMI_VERSION_2_0) + if (hdmi_funcs->supported_hdmi_ver >= HDMI_VERSION_2_0) { + if (!hdmi_funcs->scrambler_enable || !hdmi_funcs->scrambler_disable) { + drm_err(dev, "Scrambler callbacks missing for HDMI 2.x\n"); + return -EINVAL; + } + connector->hdmi.max_tmds_char_rate = HDMI_2_0_TMDS_CHAR_RATE_MAX_HZ; - else if (hdmi_funcs->supported_hdmi_ver >= HDMI_VERSION_1_3) - connector->hdmi.max_tmds_char_rate = HDMI_1_3_TMDS_CHAR_RATE_MAX_HZ; - else if (hdmi_funcs->supported_hdmi_ver >= HDMI_VERSION_1_0) - connector->hdmi.max_tmds_char_rate = HDMI_1_0_TMDS_CHAR_RATE_MAX_HZ; + } else { + /* + * Scrambler callbacks are only valid for connectors advertising + * HDMI 2.0 capability. drm_connector_hdmi_scrambler_supported() + * relies on their presence to report scrambling support. + */ + if (hdmi_funcs->scrambler_enable || hdmi_funcs->scrambler_disable) { + drm_err(dev, "Scrambler callbacks unexpected for HDMI 1.x\n"); + return -EINVAL; + } + + if (hdmi_funcs->supported_hdmi_ver >= HDMI_VERSION_1_3) + connector->hdmi.max_tmds_char_rate = HDMI_1_3_TMDS_CHAR_RATE_MAX_HZ; + else if (hdmi_funcs->supported_hdmi_ver >= HDMI_VERSION_1_0) + connector->hdmi.max_tmds_char_rate = HDMI_1_0_TMDS_CHAR_RATE_MAX_HZ; + } if (hdmi_funcs->supported_tmds_char_rate) { if (hdmi_funcs->supported_tmds_char_rate > connector->hdmi.max_tmds_char_rate) { @@ -635,6 +652,7 @@ int drmm_connector_hdmi_init(struct drm_device *dev, connector->hdmi.max_tmds_char_rate); return -EINVAL; } + connector->hdmi.max_tmds_char_rate = hdmi_funcs->supported_tmds_char_rate; } @@ -914,6 +932,9 @@ void drm_connector_cleanup(struct drm_connector *connector) DRM_CONNECTOR_REGISTERED)) drm_connector_unregister(connector); + if (connector->hdmi.scdc_work_initialized) + cancel_delayed_work_sync(&connector->hdmi.scdc_work); + platform_device_unregister(connector->hdmi_audio.codec_pdev); if (connector->privacy_screen) { diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 2a49c4d55f77..61ba20296f6a 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -1131,6 +1132,17 @@ struct drm_connector_hdmi_state { * @tmds_char_rate: TMDS Character Rate, in Hz. */ unsigned long long tmds_char_rate; + + /** + * @scrambler_needed: Whether HDMI 2.0 SCDC scrambling is required + * for the negotiated mode/bpc/format. + * + * Computed by drm_atomic_helper_connector_hdmi_check() according to + * the HDMI 2.0 specification: scrambling is mandatory above a 340 MHz + * TMDS character rate. Optional scrambling at lower rates is + * deliberately not requested by the helper. + */ + bool scrambler_needed; }; /** @@ -1481,6 +1493,36 @@ struct drm_connector_hdmi_funcs { */ const struct drm_edid *(*read_edid)(struct drm_connector *connector); + /** + * @scrambler_enable: + * + * The callback is invoked via @drm_connector_hdmi_enable_scrambling + * during commit to setup SCDC scrambling and high TMDS clock ratio on + * the source side. + * + * The @scrambler_enable callback is mandatory if HDMI 2.0 is to be + * supported. + * + * Returns: + * 0 on success, a negative error code otherwise + */ + int (*scrambler_enable)(struct drm_connector *connector); + + /** + * @scrambler_disable: + * + * The callback is invoked via @drm_connector_hdmi_disable_scrambling + * during commit to tear down SCDC scrambling and high TMDS clock ratio + * on the source side. + * + * The @scrambler_disable callback is mandatory if HDMI 2.0 is to be + * supported. + * + * Returns: + * 0 on success, a negative error code otherwise + */ + int (*scrambler_disable)(struct drm_connector *connector); + /** * @avi: * @@ -2105,6 +2147,25 @@ struct drm_connector_hdmi { */ unsigned long long max_tmds_char_rate; + /** + * @scrambler_enabled: Tracks whether HDMI 2.0 scrambler is currently enabled. + */ + bool scrambler_enabled; + + /** + * @scdc_work: Work item currently used to monitor sink-side scrambling + * status and retry setup if the sink resets it. + */ + struct delayed_work scdc_work; + + /** + * @scdc_work_initialized: Tracks whether @scdc_work has been set up via + * INIT_DELAYED_WORK(). The work item is initialized lazily on the first + * scrambling enable, so this guards the teardown paths against touching + * an uninitialized work item. + */ + bool scdc_work_initialized; + /** * @funcs: HDMI connector Control Functions and controller capabilities */ @@ -2696,6 +2757,28 @@ drm_connector_is_unregistered(struct drm_connector *connector) DRM_CONNECTOR_UNREGISTERED; } +/** + * drm_connector_hdmi_scrambler_supported - does connector support HDMI + * scrambling? + * @connector: DRM connector + * + * Checks whether or not @connector driver supports HDMI scrambling. When + * controller advertises HDMI_VERSION_2_0 support, the + * @drm_connector_hdmi_funcs.scrambler_enable and + * @drm_connector_hdmi_funcs.scrambler_disable callbacks are mandatory and + * enforced during drmm_connector_hdmi_init(). + * + * Returns: + * True if the connector supports scrambling, false otherwise. + */ +static inline bool +drm_connector_hdmi_scrambler_supported(struct drm_connector *connector) +{ + return connector->hdmi.funcs && + connector->hdmi.funcs->scrambler_enable && + connector->hdmi.funcs->scrambler_disable; +} + void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode, enum drm_connector_status status); enum drm_connector_color_format