From patchwork Fri Dec 20 19:16:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13917253 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 EB17521CFF0 for ; Fri, 20 Dec 2024 19:17:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734722231; cv=none; b=a/JwEODZn7gBrSl59V6WYn4DFAOGzYVtVn1j1H7/VBO5mp144yoP2mnrmjnSIWFBIX2+tccCXgYARI218/ZZeQ5ORC/A1jVySQZZDoXGB2Jx8oJxxPN+i9gn6ghvBAEJfSUm5LQ8N9E+PR+S945q82pdtc0mNecO87qpUivd6FM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734722231; c=relaxed/simple; bh=giLohpM0BRvWhMYAR/wf1lzclRNU18yQ7AASBU7KAiw=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=SmnN7U+wMdvBclED9Xyl8WH7EMJImURQSVz9kKGs0RLoM23m1Hkku1s+9gXzi3Nzr2BXdv+XRVosWOXunxP2BSR8TQmDZF8ScHI6jkQm9hs+J7gABy/poZWpN5p/+CyROB2y3BbfAhbfYapwy964NhForrZGygbo60LsxlakVD8= 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=Z8qo+5/O; arc=none smtp.client-ip=209.85.208.172 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="Z8qo+5/O" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-300479ca5c6so24106611fa.3 for ; Fri, 20 Dec 2024 11:17:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734722226; x=1735327026; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=3NH9o3sRUQc2TBuzCNn4xd0xwtaijH4zEiuuPAl8O+Y=; b=Z8qo+5/OUBNKdogrMndxEdFcl+Wm/kWxJvgXD+hzebUkXyLBsyYzg8rYUVxLA+/3GK kHG/VjSd9ActjRjsWcBbG3E4TP4KhN2o59eEJEVFMGyeFxgpWDtqR0S8UQFCGKRix0/B mxFHfyRGxvH1mzRsoErEgNwbtJ6lRQnv13u+cnKC7d7ARSofJ9qdXvKVI/Z0Z0CcdbNr r1Tabr/fk/xMaYonNbW9bljvqGVzCvUNFyR6Khvtr0GAajvT6cecDOOv6ejRX1oYLoTM bDLQsgkC2LoWR20X+sKYel/7HhIEW0ZaDKog/9Je98dhc4hCcGa7chrvnE1shMT+ehm+ 8bVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734722226; x=1735327026; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3NH9o3sRUQc2TBuzCNn4xd0xwtaijH4zEiuuPAl8O+Y=; b=m5lJnuJhHQsLnmdmUUfpYk96WBesCM1948Zigspt7qKVJhqVCK2LSc7PBdeuvPJ0C1 BhZyDVfs3LDG1OKosjr/e33U4RpmGfUwNQadv1JUEgHy8MWigebTKIKRIPuRW+uCBJl6 K9UytW7fgrU3dp0krI8HE7+7C/Nbx2wt7LP+lsg8CUwHx9p4r0ws4k/apvnWCmfz+sgv dXvgvYPV48rSm7Kb0AC3HHUAhKIgmvdXZBrc+j1DcC8BO7QkT5ZKRhByzqJXr73XF5Nz Db62fuNXsh4x88SbMsWTM67VFc7uHHW0g7o4UWz8rPF3sv8FMsFg5SABOEIsnnQz1k9t /9BA== X-Forwarded-Encrypted: i=1; AJvYcCXNayLdNMHy38WJ3fpBXyFx9+DDpDpKPLCHwMQgHrjuvQTIs64ZcXlgMha+opT7ubd3vTvi21i5wFir5Q==@vger.kernel.org X-Gm-Message-State: AOJu0Yw+d8dDZkF/MyjCyB7xp1G7k/wtT7dZwcW/F3wnJ1qwkkToLhIw pDMz9D2glkt086GG1CJXp+vNv617EyvUJcacKXq2hWL3ZZsB3S1eIazwiAR8Ajo= X-Gm-Gg: ASbGncsoiLQvTNAMC45Q+SpMTc/9dChk8tBZ2uH8q1KfNxzh7gD5wPqqG1a7APF7bwq 2e6VuTq7I0a8NtO76P6A0FXNuu8xZdRJamVB8PSe4xZnacJjSmad3shfqkZWcBLn+K7Bt2a2KCM tTQkLc3z47Upy4AAZrKbKBiIl6LFvGem04h2V82eQL9fumjHD5ivAMjsiYGTTvDGS6tvMIQK5EJ fzPSNd4HG/N15N0/wfLmZTJZbYvpHBjtgLrXeaFLQ6q15ug8Z7SJZnLlhz3urni X-Google-Smtp-Source: AGHT+IEwbdV0vqS0CbZsf9gavU/S6dsgiTym1Hj3ImdXSFJiHjGHsRoZIPzHljOSqCM570WwNxfbig== X-Received: by 2002:a05:6512:1055:b0:53e:39e6:a1c1 with SMTP id 2adb3069b0e04-54229560360mr1595277e87.43.1734722225396; Fri, 20 Dec 2024 11:17:05 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54223813877sm545141e87.149.2024.12.20.11.17.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 11:17:04 -0800 (PST) From: Dmitry Baryshkov Subject: [PATCH v8 00/10] drm: add DRM HDMI Codec framework Date: Fri, 20 Dec 2024 21:16:57 +0200 Message-Id: <20241220-drm-bridge-hdmi-connector-v8-0-2399dbae2990@linaro.org> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAKnCZWcC/33S207EIBAG4FfZcC3KoUDZK9/DeMFh2CWxrdLar NnsuzvdRq1pwh0/MN8EMlcyQskwkuPhSgrMecxDj6F9OJBwdv0JaI6YiWCiYUoyGktHfckRT86 xyzQMfQ9hGgq1niVthLJGAsH69wIpX+72yyvmcx7x2te91cyX3VXVXFXUmVNsqmwKptXKefH8l ntXhsehnMjCzuKX4pzxGiWQMtJCsi7GZGFHyS1la5REKnDlUgxOtW2zo5oNJUSNapDyTdQ2apA +2h2l/ihRf6BaKCW5hlYkzd2O0ltK1yiNlGIx8EY5G5jeUWZDcVOjzPJX3sYkvHaKq3/UbZ2UA h+fOHzTOi7EuxGQ6Lo8HQ8L3eUxPP0saA+XCUtv35WVZBK/AgAA X-Change-ID: 20240530-drm-bridge-hdmi-connector-9b0f6725973e 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 , Raphael Gallais-Pou , Dave Stevenson , =?utf-8?q?Ma=C3=ADra_Cana?= =?utf-8?q?l?= , Raspberry Pi Kernel Maintenance Cc: Jani Nikula , 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=7525; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=giLohpM0BRvWhMYAR/wf1lzclRNU18yQ7AASBU7KAiw=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnZcKtk+PPS9ufezpvTTjC4kTqVhFjjhD5e9vOj 0BznWorBwiJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ2XCrQAKCRCLPIo+Aiko 1TAiB/9wLaUi6L1U0wm9kaQGolW2F/JocJmm7XmS2xhVk+EutMK+TI68eC0FFtEFQOTPNa0grFr BU27z3zSFRsJO9H3uAi5rvJE+A3WirWbzGhomKwyls/EHSjQ6zzrz4m38LdZXI37jKQ4oCQJkz1 mMfIxU5NvmIQfPyTifwZ3NuZwsQeo4CxNguZ+EbSZCCXW0uVivlx/W9y0wX3wexEF+LlOdMtuw9 2rA1nGLaBjhsAxlc1YDMzCs2vElD7xprsAwL621D8TE5r92DUlBbgzdZrwX2mHf+VVRsj0ktHkn gxmNAiIe70Fgr8rhAbp/jFHW/SGfLzvFuwyzbwkG0wvSWyzz X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A While porting lt9611 DSI-to-HDMI bridge driver to use HDMI Connector framework, I stumbled upon an issue while handling the Audio InfoFrames. The HDMI codec callbacks weren't receiving the drm_atomic_state, so there was no simple way to get the drm_connector that stayed at the end of the bridge chain. At the same point the drm_hdmi_connector functions expected to get drm_connector instance. While looking for a way to solve the issue, I stumbled upon several deficiencies in existing hdmi_codec_ops implementations. Only few of the implementations were able to handle codec's 'plugged' callback. One third of the drivers didn't implement the get_eld() callback. Most of the issues can be solved if drm_connector handles hdmi-audio-codec on its own, delegating functionality to the actual implementation, be it a driver that implements drm_connector or drm_bridge. Implement such high-level framework, adding proper support for Audio InfoFrame generation to the LT9611 driver. Several design decisions to be kept in mind: - drm_connector_hdmi_codec is kept as simple as possible. It implements generic functionality (ELD, hotplug, registration). - drm_hdmi_connector sets up HDMI codec device if the connector is setup correspondingly (either I2S or S/PDIF is marked as supported). - drm_bridge_connector provides a way to link HDMI audio codec funcionality in the drm_bridge with the drm_connector_hdmi_codec framework. - It might be worth reverting the no_i2s_capture / no_spdif_capture bits. Only TDA889x driver sets them, while it's safe to assume that most of HDMI / DP devices do not support ARC / capture. I think the drivers should opt-in capture support rather than having to opt-out of it. Signed-off-by: Dmitry Baryshkov --- Changes in v8: - Mass rename hdmi_codec -> hdmi_audio, drop redundant audio_ prefixes from several callbacks (Maxime) - Fix the commit message to stop mentioning drm_atomic_helper_connector_hdmi_update_edid() (Maxime) - Link to v7: https://lore.kernel.org/r/20241217-drm-bridge-hdmi-connector-v7-0-cb9df2b6a515@linaro.org Changes in v7: - Renamed drm_connector_hdmi_codec_init() to drm_connector_hdmi_audio_init() (Maxime) - Added extra empty line in struct drm_connector_hdmi_codec_funcs (Maxime) - Dropped if/else from drm_bridge_connector_audio_startup() (Maxime) - Added optional .read_edid() callback and reworked drm_atomic_helper_connector_hdmi_hotplug() to use that callback instead of having an internal function which accepts EDID (Maxime) - Made VC4 and drm_bridge_connector use .force() in addition to .detect() and .detect_ctx(). - Moved HDMI codec functions out of struct drm_connector_hdmi_funcs. Assign them from drm_connector_hdmi_audio_init(). - Documented struct drm_connector_hdmi_codec and its fields. - Link to v6: https://lore.kernel.org/r/20241206-drm-bridge-hdmi-connector-v6-0-50dc145a9c06@linaro.org Changes in v6: - Dropped extra checks on the EDID (Jani) - Reworked drmm_connector_hdmi_init(), splitting the codec init to a separate optional function rather than passing arguments through drm_connector (Maxime) - Reworked EDID update functions (Maxime, Jani) - No longer refresh the EDID in vc4_hdmi_connector_get_modes(), it is redundant as vc4_hdmi_connector_detect_cxtx() already does that. - Link to v5: https://lore.kernel.org/r/20241201-drm-bridge-hdmi-connector-v5-0-b5316e82f61a@linaro.org Changes in v5: - Moved prototypes from drm_internal.h to drm_connector_hdmi_codec_internal.h (Jani) - Rebased on top of ELD mutex series, resolving the long-standing FIXME - Converted the VC4 driver (compile-tested only) - Link to v4: https://lore.kernel.org/r/20241122-drm-bridge-hdmi-connector-v4-0-b4d69d6e3bd9@linaro.org Changes in v4: - Added forward declaration of struct drm_edid (LKP) - Fixed kerneldoc for drm_atomic_helper_connector_hdmi_update_edid(). - Link to v3: https://lore.kernel.org/r/20241109-drm-bridge-hdmi-connector-v3-0-c15afdca5884@linaro.org Changes in v3: - Dropped RFC status - Fixed drm_connector_hdmi_codec_init() kerneldoc (LKP) - Dropped double underscore prefix from __drm_atomic_helper_connector_hdmi_update_edid() (Jani) - Moved drm_edid_free() from drm_atomic_helper_connector_hdmi_update_edid() to the caller's side (Jani) - Link to v2: https://lore.kernel.org/r/20241101-drm-bridge-hdmi-connector-v2-0-739ef9addf9e@linaro.org Changes in v2: - Use drm_atomic_get_old_connector_for_encoder in atomic_disable() to prevent it from crashing - Reworked HDMI codec init/exit, removing drmm_ calls (Maxime) - Drafted the helper to be called from .detect_ctx() that performs HDMI Connector maintenance duties (Maxime) - Moved no_capture_mute to struct hdmi_codec_pdata - Link to v1: https://lore.kernel.org/r/20240615-drm-bridge-hdmi-connector-v1-0-d59fc7865ab2@linaro.org --- Dmitry Baryshkov (10): ASoC: hdmi-codec: pass data to get_dai_id too ASoC: hdmi-codec: move no_capture_mute to struct hdmi_codec_pdata drm/connector: implement generic HDMI audio helpers drm/bridge: connector: add support for HDMI codec framework drm/bridge: lt9611: switch to using the DRM HDMI codec framework drm/display/hdmi: implement hotplug functions drm/bridge_connector: hook drm_atomic_helper_connector_hdmi_hotplug() drm/vc4: hdmi: switch to using generic HDMI Codec infrastructure drm/vc4: hdmi: stop rereading EDID in get_modes() drm/vc4: hdmi: use drm_atomic_helper_connector_hdmi_hotplug() drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/bridge/adv7511/adv7511_audio.c | 3 +- drivers/gpu/drm/bridge/analogix/anx7625.c | 3 +- drivers/gpu/drm/bridge/ite-it66121.c | 2 +- drivers/gpu/drm/bridge/lontium-lt9611.c | 169 ++++++++---------- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 3 +- drivers/gpu/drm/bridge/sii902x.c | 5 +- .../gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 3 +- drivers/gpu/drm/display/drm_bridge_connector.c | 137 ++++++++++++++- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 56 ++++++ drivers/gpu/drm/drm_connector.c | 5 + drivers/gpu/drm/drm_connector_hdmi_audio.c | 189 +++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_hdmi.c | 2 +- drivers/gpu/drm/i2c/tda998x_drv.c | 2 +- drivers/gpu/drm/mediatek/mtk_dp.c | 2 +- drivers/gpu/drm/mediatek/mtk_hdmi.c | 2 +- drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +- drivers/gpu/drm/sti/sti_hdmi.c | 2 +- drivers/gpu/drm/vc4/vc4_hdmi.c | 103 +++-------- drivers/gpu/drm/vc4/vc4_hdmi.h | 2 - include/drm/display/drm_hdmi_state_helper.h | 5 + include/drm/drm_bridge.h | 74 ++++++++ include/drm/drm_connector.h | 141 +++++++++++++++ include/sound/hdmi-codec.h | 7 +- sound/soc/codecs/hdmi-codec.c | 4 +- 25 files changed, 716 insertions(+), 208 deletions(-) --- base-commit: 74ef9527bd87ead62deabe749a6d867af748d448 change-id: 20240530-drm-bridge-hdmi-connector-9b0f6725973e Best regards,