From nobody Sun Nov 24 00:30:08 2024 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 3C9F41917C2 for ; Sat, 9 Nov 2024 12:48:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731156528; cv=none; b=msh8kUd5ayqJVxU/ltBYpou9ht/A8dvS4r7ZJdccMRw2sQ2vAnipVtic8lgOhCrCvTW8s/yD7E1FwoRMP5O+IME0TNZd/Aro12J9IezWTOiOMX3wPbaylhR071/HVP019DhqkXlhnGBoBgYfIX6fRM3wX/ijZOMI46oDI3wKz20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731156528; c=relaxed/simple; bh=VCAvQVMxBhx8BnYWztLsVnSCZi3RzfwM/RTfomnZ9hc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Nori2RO9wl4FvzVMu99qWt/H3JoosO/UAm+EDGOC7FfOvRM/NMqLt5gEuUAL9wti7j5SIZr65xXnd4i7KA+RrIZVu/sVBXAfQ64xqtEfxBrHejWPEXmiaUHXDZDuX87Tx3UsfEZkxLQI98IO9at4/t7l2JUr26eljwUoHqtvsxI= 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=XND1iwjQ; arc=none smtp.client-ip=209.85.167.52 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="XND1iwjQ" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-53a0c160b94so3820950e87.2 for ; Sat, 09 Nov 2024 04:48:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731156523; x=1731761323; 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=UmsNhbcOu0CL1PS3KGzwEdaRMJlXKDzwHWxwdzXZd0g=; b=XND1iwjQlZ8IcWu3A0A37if5I1s3WizYeV2VyS7hWeNjhpPly7J/g5D6DQQrsUemZL puChlSaSonjGPMoFbBacqy9FtXQvbHBiArHSb90bJXusuhrUROLenRkwZrCQCrgzKPgI Q8jFxFmL+HCksKh/TlVG1EudcbhJ7KSxMw5qjbwbBvvslgLI1GoQ01OTwfs83CH7lTXB A3Zk2SuFIGqOG1vzaKSHOdiGx2VVtbtNTgJaX7uOpxNaAjvY37gfjNuIPEazm98P1ZE5 v36bz9oYZlwqvyvkSPHrN7ald9YKyDGLVYZf3IqnircuXkBYnBqnGTqoGrzHva8wXAuN Kz6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731156523; x=1731761323; 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=UmsNhbcOu0CL1PS3KGzwEdaRMJlXKDzwHWxwdzXZd0g=; b=tbfobgBW7nWRTtalo2gmx1R63dlOptDHSi3OcqQ6Vbm2+Pq0uFnEAvfiHCCiWeWBgG ZIHcDUYsYpV7eiaD6int3KsXWTX/b6UukHker+S+RlKGyh5fUpKVmttxGIv41Ai3oKrl fh9B6m0RQsoHBIVBWd6xQidZjiHzbYxdADabMB6Hp6B5BRz758KBWKS/0Hbn+oLD8HQ9 FMYFuieE5eZxu9UHsbxekdGRMWKHvo+cm55KTOJU4K/AhRoWNsWhFAtskKE8jU7bKHVi 08Oj13QfbXNpxR0+x1cKZopgUZBP2FxC0e3pFfnDs5/rgkKF+TM5PUqaMLzcbaort6p9 0Hcw== X-Forwarded-Encrypted: i=1; AJvYcCUk6XM1JFBKQhSNOZ988kYMh+X2gor9rWUfZNGhrYX+lLykrJrLLssU6r4S7omW7deT4XrWwSiFa9o9AfU=@vger.kernel.org X-Gm-Message-State: AOJu0YyHUPkky2BKk9bR+7xTaiZq2DFvYa41E208ktSdslirE7r728Cj puGcEs7S6S57b15hi2VoXQpi8b4IeRI9ry3p513UcgMmzyidetwLtjFc/T7mqFg= X-Google-Smtp-Source: AGHT+IE6kTLTu/veurmVOodgPhU+7P7sFJTvQhZmfzzsua+fQiIV+PK+Bv9UdgdlQKwp2JiCvYUHrw== X-Received: by 2002:a05:6512:2389:b0:53c:7526:e18a with SMTP id 2adb3069b0e04-53d862c5757mr3016794e87.30.1731156523224; Sat, 09 Nov 2024 04:48:43 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53d826a9b76sm929967e87.172.2024.11.09.04.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 04:48:41 -0800 (PST) From: Dmitry Baryshkov Date: Sat, 09 Nov 2024 14:48:30 +0200 Subject: [PATCH v3 4/7] drm/bridge: connector: add support for HDMI codec framework 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: <20241109-drm-bridge-hdmi-connector-v3-4-c15afdca5884@linaro.org> References: <20241109-drm-bridge-hdmi-connector-v3-0-c15afdca5884@linaro.org> In-Reply-To: <20241109-drm-bridge-hdmi-connector-v3-0-c15afdca5884@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: 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=6723; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=VCAvQVMxBhx8BnYWztLsVnSCZi3RzfwM/RTfomnZ9hc=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnL1odOLzMUKfl5eHI5bjyKcUtRMaLgeTACflZr 5w28n5DOk+JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZy9aHQAKCRCLPIo+Aiko 1WEZB/9fOdqsvsC/JajVKhnkYPMFOMEQu8c4Cozx0O+GeTqyy2c0Gfu7wERPC0GYSi80tTgshdW VLOFMhn45/5pnsvTa2aW0mMpxACjTJp1nflhG3jkc+lz0k5OPxWDI1IGn7diveUOCMnaBVyMuTu iSRV9T5NSdyLprmttaov27fUnHhwTN2QpfNJ8a1Lxo15V2mzD839FuWr5Je4H1/5oPJin9jAQjr GjkcFHMifZiCNscZlNleciqSY+0zP19knISWe+SfdQQzWl7Fw7NRW6Ak0eBjfDwtBLjha7UrE/V qBgi+7KEmS9N/HoC0P8hNElSpNYYr59cs7i5Zxdl8kgDdgzk X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Add necessary glue code to be able to use new HDMI codec framework from the DRM bridge drivers. The drm_bridge implements a limited set of the hdmi_codec_ops interface, with the functions accepting both drm_connector and drm_bridge instead of just a generic void pointer. This framework is integrated with the DRM HDMI Connector framework, but can also be used for DisplayPort connectors. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/display/drm_bridge_connector.c | 95 ++++++++++++++++++++++= +++- include/drm/drm_bridge.h | 23 +++++++ 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/d= rm/display/drm_bridge_connector.c index 320c297008aaa8b6ef5b1f4c71928849b202e8ac..12ab9f14cc8a8672478ae2804c9= a68d766d88ea5 100644 --- a/drivers/gpu/drm/display/drm_bridge_connector.c +++ b/drivers/gpu/drm/display/drm_bridge_connector.c @@ -20,6 +20,8 @@ #include #include =20 +#include + /** * DOC: overview * @@ -354,10 +356,80 @@ static int drm_bridge_connector_write_infoframe(struc= t drm_connector *connector, return bridge->funcs->hdmi_write_infoframe(bridge, type, buffer, len); } =20 +static int drm_bridge_connector_audio_startup(struct drm_connector *connec= tor) +{ + struct drm_bridge_connector *bridge_connector =3D + to_drm_bridge_connector(connector); + struct drm_bridge *bridge; + + bridge =3D bridge_connector->bridge_hdmi; + if (!bridge) + return -EINVAL; + + if (bridge->funcs->hdmi_codec_audio_startup) + return bridge->funcs->hdmi_codec_audio_startup(connector, bridge); + else + return 0; +} + +static int drm_bridge_connector_prepare(struct drm_connector *connector, + struct hdmi_codec_daifmt *fmt, + struct hdmi_codec_params *hparms) +{ + struct drm_bridge_connector *bridge_connector =3D + to_drm_bridge_connector(connector); + struct drm_bridge *bridge; + + bridge =3D bridge_connector->bridge_hdmi; + if (!bridge) + return -EINVAL; + + return bridge->funcs->hdmi_codec_prepare(connector, bridge, fmt, hparms); +} + +static void drm_bridge_connector_audio_shutdown(struct drm_connector *conn= ector) +{ + struct drm_bridge_connector *bridge_connector =3D + to_drm_bridge_connector(connector); + struct drm_bridge *bridge; + + bridge =3D bridge_connector->bridge_hdmi; + if (!bridge) + return; + + bridge->funcs->hdmi_codec_audio_shutdown(connector, bridge); +} + +static int drm_bridge_connector_mute_stream(struct drm_connector *connecto= r, + bool enable, int direction) +{ + struct drm_bridge_connector *bridge_connector =3D + to_drm_bridge_connector(connector); + struct drm_bridge *bridge; + + bridge =3D bridge_connector->bridge_hdmi; + if (!bridge) + return -EINVAL; + + if (bridge->funcs->hdmi_codec_mute_stream) + return bridge->funcs->hdmi_codec_mute_stream(connector, bridge, + enable, direction); + else + return -ENOTSUPP; +} + +static const struct drm_connector_hdmi_codec_funcs drm_bridge_connector_hd= mi_codec_funcs =3D { + .audio_startup =3D drm_bridge_connector_audio_startup, + .prepare =3D drm_bridge_connector_prepare, + .audio_shutdown =3D drm_bridge_connector_audio_shutdown, + .mute_stream =3D drm_bridge_connector_mute_stream, +}; + static const struct drm_connector_hdmi_funcs drm_bridge_connector_hdmi_fun= cs =3D { .tmds_char_rate_valid =3D drm_bridge_connector_tmds_char_rate_valid, .clear_infoframe =3D drm_bridge_connector_clear_infoframe, .write_infoframe =3D drm_bridge_connector_write_infoframe, + .codec_funcs =3D &drm_bridge_connector_hdmi_codec_funcs, }; =20 /* -----------------------------------------------------------------------= ------ @@ -459,7 +531,25 @@ struct drm_connector *drm_bridge_connector_init(struct= drm_device *drm, if (connector_type =3D=3D DRM_MODE_CONNECTOR_Unknown) return ERR_PTR(-EINVAL); =20 - if (bridge_connector->bridge_hdmi) + if (bridge_connector->bridge_hdmi) { + bridge =3D bridge_connector->bridge_hdmi; + + if (bridge->hdmi_codec_i2s || + bridge->hdmi_codec_spdif) { + if (!bridge->funcs->hdmi_codec_prepare || + !bridge->funcs->hdmi_codec_audio_shutdown) + return ERR_PTR(-EINVAL); + + bridge_connector->bridge_hdmi =3D bridge; + + connector->hdmi_codec.dev =3D bridge->hdmi_codec_dev; + connector->hdmi_codec.i2s =3D bridge->hdmi_codec_i2s; + connector->hdmi_codec.spdif =3D bridge->hdmi_codec_spdif; + connector->hdmi_codec.max_i2s_channels =3D + bridge->hdmi_codec_max_i2s_channels; + connector->hdmi_codec.sound_dai_port =3D bridge->hdmi_codec_dai_port; + } + ret =3D drmm_connector_hdmi_init(drm, connector, bridge_connector->bridge_hdmi->vendor, bridge_connector->bridge_hdmi->product, @@ -468,10 +558,11 @@ struct drm_connector *drm_bridge_connector_init(struc= t drm_device *drm, connector_type, ddc, supported_formats, max_bpc); - else + } else { ret =3D drmm_connector_init(drm, connector, &drm_bridge_connector_funcs, connector_type, ddc); + } if (ret) return ERR_PTR(ret); =20 diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index e8d735b7f6a480468c88287e2517b387ceec0f22..0ef9580ef6669f84327bdcb85a2= 4fc83f76541bb 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -41,6 +41,8 @@ struct drm_display_info; struct drm_minor; struct drm_panel; struct edid; +struct hdmi_codec_daifmt; +struct hdmi_codec_params; struct i2c_adapter; =20 /** @@ -676,6 +678,21 @@ struct drm_bridge_funcs { enum hdmi_infoframe_type type, const u8 *buffer, size_t len); =20 + int (*hdmi_codec_audio_startup)(struct drm_connector *connector, + struct drm_bridge *bridge); + + int (*hdmi_codec_prepare)(struct drm_connector *connector, + struct drm_bridge *bridge, + struct hdmi_codec_daifmt *fmt, + struct hdmi_codec_params *hparms); + + void (*hdmi_codec_audio_shutdown)(struct drm_connector *connector, + struct drm_bridge *bridge); + + int (*hdmi_codec_mute_stream)(struct drm_connector *connector, + struct drm_bridge *bridge, + bool enable, int direction); + /** * @debugfs_init: * @@ -859,6 +876,12 @@ struct drm_bridge { * @DRM_BRIDGE_OP_HDMI is set. */ unsigned int max_bpc; + + struct device *hdmi_codec_dev; + int hdmi_codec_max_i2s_channels; + unsigned int hdmi_codec_i2s : 1; + unsigned int hdmi_codec_spdif : 1; + int hdmi_codec_dai_port; }; =20 static inline struct drm_bridge * --=20 2.39.5