From nobody Thu Dec 18 15:40:40 2025 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 C7B6420E312 for ; Fri, 6 Dec 2024 10:17:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733480226; cv=none; b=o7MlntMI81HHfwrh91KVP+7XbEhp3QvFfvgUVFC/Hs0IEDd/P8uchm3S4QRq0O0HY1tRUvrW46Ul59h99fNn+acZFK6wYqPL3EP0vTqX3TqZCesPeQDNBM1D8qvlWAqtcZzTK+WFgN22VltkUP3XHsvd3T+3RLmPLVEkdFE8I4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733480226; c=relaxed/simple; bh=PRnZq4B5Ktw6BMnqK7ttcTjo3h2X+ci9xQT/AomNEvo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o0W0tGsWsFMKXtmvvxE/CzclMRGBbby5OCqJAq7VGZE9FKyrKzQXaLiyMu/7NymYYgqc15g4OckWsLoo826Tk3isOqtEVU6eYpsZP/VNdErDeVnw8zmedNCg/oGV6+AaBwm0/nQmwE5k+egjyeOkYZzmLWh0H3fJS8VWa84xcn8= 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=UHnoZO4j; arc=none smtp.client-ip=209.85.167.41 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="UHnoZO4j" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-53dde4f0f23so1730723e87.3 for ; Fri, 06 Dec 2024 02:17:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733480222; x=1734085022; 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=7E9JcfGQDN6ZUBFwEUPgAGm2RBAtRtCRdkRTCVbrXmE=; b=UHnoZO4jkU2xE/rYHTJrzjAyzA15yp+VE0n+Hxo8Xgwy5oxT//grTgrs7SYYA+UwSB zQVJc2VptprVCtB9m0ix9GRUaSo7qfyA3Rzm/9xcKlDsgqvJvqKKR55+eaw5ghJ6Sl8f 2O8QtZnbGvAu9DaWzV01I7NfE5YGj8gHOKTtivLsdd3a/HL3dGtGp+3at++vcTJGykob GLnBQBcGhVg5lnp4Osbi9ywEQctMNvuv4bD6SYNyFm7gu3VbEmoBp1XRNGqsXaF8NAye Bgt1dQuWb7231oPAHeo/BMpUoOHylLM1pimKV3sKCXwm0kgCp34mUBRqxe3KuxnLLooq oyjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733480222; x=1734085022; 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=7E9JcfGQDN6ZUBFwEUPgAGm2RBAtRtCRdkRTCVbrXmE=; b=VCcyTZ1VGmpafqKVCGCkzQLgBc9NQhgM2bFwJ0swJBCuML5P8K2W5PctZMoSzBmCH5 F53O2Wky19cEu88YJOIAgDiImJbZSCPYFfZ9cqCxLXCqiZVxkW/0QOK1PwmGceRjxQya hkySveboRDYQ0h3hJqVUxXaRw3gno31/+aZBIIVTaS4xpSXTjm0mai95jdi+9wIjzmZX BkXx91/K5rMPRRT8Cyr93OXwZZg1BpohiBsFCpFhVNBmKlBzi2HfYsXism2vLWwqy5d3 WDVZBLlL4lkUQv2GDB5MCjLd+D/NJKww4Ak3WOcmfq8KY0O5nXNdDg0FaEuu86owpS6K OvbA== X-Forwarded-Encrypted: i=1; AJvYcCXDYiUwBh9prsCALYCWYmX7TwamgJ8LxA/ggkqOGpFtHnjvtNWJFLzc08gNTL09dzYqcOmS64hK7/qX2Ks=@vger.kernel.org X-Gm-Message-State: AOJu0YybhypDtRSeErfc+LX8w2irIxEOpR7psl0W9w2fzYErK0bobl7r pWa3QNZi7V1xurOcvknah+ptwXmUGI+r0eUAKvZUoB017XlqoZQk7EeaBpFtXa4= X-Gm-Gg: ASbGnctTcLHImA+yPv5Rhamb+p5ksCZAuihsML3yhLJjTPqgIODwDLX/+Itfwyt7fF6 WILELhWVa5Iw4YCYRbZOff3nrIxdWej+odJKcHZjFGmlJ8ie6N2iVZczcaJi9huk4EUhmKoOs+s sz2Uas1A3K13OX43fdwTG05K4nupjnF1Opsvv2tMtjjNywdKS99m9c1Pb6hcImdBQJ+A47BL/IB 2ZTuFNNRmUpGnwgo98ZAzKdBwWu25wKN3M1vBpPEw7BZ5SKyyGBuyVJXg== X-Google-Smtp-Source: AGHT+IEC2BVOX/DQIuiiNOp1QiVCCXdIrMaFCzPJw0ZdKhdICHTciEnz1T4dSSvDlr0mcfJh/iz2YA== X-Received: by 2002:a05:6512:3caa:b0:53e:20d4:334a with SMTP id 2adb3069b0e04-53e2c2b5cd8mr720361e87.14.1733480221912; Fri, 06 Dec 2024 02:17:01 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53e2294738fsm462355e87.52.2024.12.06.02.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 02:17:00 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 06 Dec 2024 12:16:02 +0200 Subject: [PATCH v6 08/10] drm/vc4: hdmi: switch to using generic HDMI Codec infrastructure 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: <20241206-drm-bridge-hdmi-connector-v6-8-50dc145a9c06@linaro.org> References: <20241206-drm-bridge-hdmi-connector-v6-0-50dc145a9c06@linaro.org> In-Reply-To: <20241206-drm-bridge-hdmi-connector-v6-0-50dc145a9c06@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 , Raphael Gallais-Pou , Dave Stevenson , =?utf-8?q?Ma=C3=ADra_Canal?= , 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=6786; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=PRnZq4B5Ktw6BMnqK7ttcTjo3h2X+ci9xQT/AomNEvo=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnUs8KVLoDRWj7WH319W1w/RLnRtHsbGLHohYKm YKafWEqVteJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ1LPCgAKCRCLPIo+Aiko 1ZlpB/4p+HFTN+BLlwyeSaGSzwPfl2wlqAF1r0NTeHzTV/JwWEKIDfnYREmyj0YrVnGYlEG1JqL qdPqJAlp/ja/+cPL9zZ/iGOLkCUGL4V8VcP7EfYLMaZ+Yk6IIeOumHBGR5bGFL65k406ZWvOhzd 3eBO0Qhz2sn5sXYvbbrOs/TbsGaxxWtbuoW+ztbMXLku5aWUd1OuTnxPP9st2MZPL216+Ew8m8D 6h6LdN+VwtNtTZPJ/Dhcq4IyGr6R9r3BhW8wGL8yEX6FFU+iQrRjvVMXcaDwENCg1FpQ/Zla/af XmPA4WHMWIDyS24iXKlpWn6wxM0LmiRGftyAsw/pkUiQSLH4 X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Drop driver-specific implementation and use the generic HDMI Codec framework in order to implement the HDMI audio support. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/vc4/vc4_hdmi.c | 69 ++++++++++----------------------------= ---- drivers/gpu/drm/vc4/vc4_hdmi.h | 2 -- 2 files changed, 16 insertions(+), 55 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index f98617b8bf6cf9d92a806e35584e8f8ab0ac9f96..e5ab42f72f618b90f956482db6c= 9c8074c1e3bf1 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -609,6 +609,10 @@ static int vc4_hdmi_connector_init(struct drm_device *= dev, if (ret) return ret; =20 + ret =3D drm_connector_hdmi_codec_init(connector, dev->dev, 8, false, -1); + if (ret) + return ret; + drm_connector_helper_add(connector, &vc4_hdmi_connector_helper_funcs); =20 /* @@ -1707,9 +1711,12 @@ vc4_hdmi_connector_clock_valid(const struct drm_conn= ector *connector, return MODE_OK; } =20 +static const struct drm_connector_hdmi_codec_funcs vc4_hdmi_codec_funcs; + static const struct drm_connector_hdmi_funcs vc4_hdmi_hdmi_connector_funcs= =3D { .tmds_char_rate_valid =3D vc4_hdmi_connector_clock_valid, .write_infoframe =3D vc4_hdmi_write_infoframe, + .codec_funcs =3D &vc4_hdmi_codec_funcs, }; =20 #define WIFI_2_4GHz_CH1_MIN_FREQ 2400000000ULL @@ -1921,9 +1928,9 @@ static bool vc4_hdmi_audio_can_stream(struct vc4_hdmi= *vc4_hdmi) return true; } =20 -static int vc4_hdmi_audio_startup(struct device *dev, void *data) +static int vc4_hdmi_audio_startup(struct drm_connector *connector) { - struct vc4_hdmi *vc4_hdmi =3D dev_get_drvdata(dev); + struct vc4_hdmi *vc4_hdmi =3D connector_to_vc4_hdmi(connector); struct drm_device *drm =3D vc4_hdmi->connector.dev; unsigned long flags; int ret =3D 0; @@ -1985,9 +1992,9 @@ static void vc4_hdmi_audio_reset(struct vc4_hdmi *vc4= _hdmi) spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); } =20 -static void vc4_hdmi_audio_shutdown(struct device *dev, void *data) +static void vc4_hdmi_audio_shutdown(struct drm_connector *connector) { - struct vc4_hdmi *vc4_hdmi =3D dev_get_drvdata(dev); + struct vc4_hdmi *vc4_hdmi =3D connector_to_vc4_hdmi(connector); struct drm_device *drm =3D vc4_hdmi->connector.dev; unsigned long flags; int idx; @@ -2057,13 +2064,12 @@ static int sample_rate_to_mai_fmt(int samplerate) } =20 /* HDMI audio codec callbacks */ -static int vc4_hdmi_audio_prepare(struct device *dev, void *data, +static int vc4_hdmi_audio_prepare(struct drm_connector *connector, struct hdmi_codec_daifmt *daifmt, struct hdmi_codec_params *params) { - struct vc4_hdmi *vc4_hdmi =3D dev_get_drvdata(dev); + struct vc4_hdmi *vc4_hdmi =3D connector_to_vc4_hdmi(connector); struct drm_device *drm =3D vc4_hdmi->connector.dev; - struct drm_connector *connector =3D &vc4_hdmi->connector; struct vc4_dev *vc4 =3D to_vc4_dev(drm); unsigned int sample_rate =3D params->sample_rate; unsigned int channels =3D params->channels; @@ -2075,7 +2081,7 @@ static int vc4_hdmi_audio_prepare(struct device *dev,= void *data, int ret =3D 0; int idx; =20 - dev_dbg(dev, "%s: %u Hz, %d bit, %d channels\n", __func__, + dev_dbg(&vc4_hdmi->pdev->dev, "%s: %u Hz, %d bit, %d channels\n", __func_= _, sample_rate, params->sample_width, channels); =20 mutex_lock(&vc4_hdmi->mutex); @@ -2214,40 +2220,12 @@ static const struct snd_dmaengine_pcm_config pcm_co= nf =3D { .prepare_slave_config =3D snd_dmaengine_pcm_prepare_slave_config, }; =20 -static int vc4_hdmi_audio_get_eld(struct device *dev, void *data, - uint8_t *buf, size_t len) -{ - struct vc4_hdmi *vc4_hdmi =3D dev_get_drvdata(dev); - struct drm_connector *connector =3D &vc4_hdmi->connector; - - mutex_lock(&connector->eld_mutex); - memcpy(buf, connector->eld, min(sizeof(connector->eld), len)); - mutex_unlock(&connector->eld_mutex); - - return 0; -} - -static const struct hdmi_codec_ops vc4_hdmi_codec_ops =3D { - .get_eld =3D vc4_hdmi_audio_get_eld, +static const struct drm_connector_hdmi_codec_funcs vc4_hdmi_codec_funcs = =3D { .prepare =3D vc4_hdmi_audio_prepare, .audio_shutdown =3D vc4_hdmi_audio_shutdown, .audio_startup =3D vc4_hdmi_audio_startup, }; =20 -static struct hdmi_codec_pdata vc4_hdmi_codec_pdata =3D { - .ops =3D &vc4_hdmi_codec_ops, - .max_i2s_channels =3D 8, - .i2s =3D 1, -}; - -static void vc4_hdmi_audio_codec_release(void *ptr) -{ - struct vc4_hdmi *vc4_hdmi =3D ptr; - - platform_device_unregister(vc4_hdmi->audio.codec_pdev); - vc4_hdmi->audio.codec_pdev =3D NULL; -} - static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) { const struct vc4_hdmi_register *mai_data =3D @@ -2255,7 +2233,6 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_h= dmi) struct snd_soc_dai_link *dai_link =3D &vc4_hdmi->audio.link; struct snd_soc_card *card =3D &vc4_hdmi->audio.card; struct device *dev =3D &vc4_hdmi->pdev->dev; - struct platform_device *codec_pdev; const __be32 *addr; int index, len; int ret; @@ -2348,20 +2325,6 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_= hdmi) return ret; } =20 - codec_pdev =3D platform_device_register_data(dev, HDMI_CODEC_DRV_NAME, - PLATFORM_DEVID_AUTO, - &vc4_hdmi_codec_pdata, - sizeof(vc4_hdmi_codec_pdata)); - if (IS_ERR(codec_pdev)) { - dev_err(dev, "Couldn't register the HDMI codec: %ld\n", PTR_ERR(codec_pd= ev)); - return PTR_ERR(codec_pdev); - } - vc4_hdmi->audio.codec_pdev =3D codec_pdev; - - ret =3D devm_add_action_or_reset(dev, vc4_hdmi_audio_codec_release, vc4_h= dmi); - if (ret) - return ret; - dai_link->cpus =3D &vc4_hdmi->audio.cpu; dai_link->codecs =3D &vc4_hdmi->audio.codec; dai_link->platforms =3D &vc4_hdmi->audio.platform; @@ -2374,7 +2337,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_h= dmi) dai_link->stream_name =3D "MAI PCM"; dai_link->codecs->dai_name =3D "i2s-hifi"; dai_link->cpus->dai_name =3D dev_name(dev); - dai_link->codecs->name =3D dev_name(&codec_pdev->dev); + dai_link->codecs->name =3D dev_name(&vc4_hdmi->connector.hdmi_codec.codec= _pdev->dev); dai_link->platforms->name =3D dev_name(dev); =20 card->dai_link =3D dai_link; diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index b2424a21da230db99db207efa293417faccd254d..e3d989ca302b72533c374dfa3fd= 0d5bd7fe64a82 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -104,8 +104,6 @@ struct vc4_hdmi_audio { struct snd_soc_dai_link_component codec; struct snd_soc_dai_link_component platform; struct snd_dmaengine_dai_dma_data dma_data; - struct hdmi_audio_infoframe infoframe; - struct platform_device *codec_pdev; bool streaming; }; =20 --=20 2.39.5