From patchwork Tue Dec 24 01:48:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13919649 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 57F73E7718B for ; Tue, 24 Dec 2024 02:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pT8kLYrCB5PCEoycFNDmtbXGVBvLDjFx+TZSQpeiF7Y=; b=hfXmJmL0h7e3IHFBT8rspsUWUg StByLAdRmISw+8IrUEIfVYhRmbjkdJ8wmX5uVNQqbiUXMStLxRcK9Ium1QHJhPiJo69FhEumFgbiS bNJeuHvm5NQ8j0+smdh26MHSRcELPAaczS6M5gxdpe8HQQAD8a53i6VDWUOebKRz1kdaZqY7EZL8O Z/DdG+FTz4cci3NxOZKtcIQZMim+MDrgDKcfbFcHF57Y5Mbax9UvOfrvYbcpcNog7XlPeew3OHrXj wKsI1BomgH504xl6Z5GSBUKncoW4l2JQsbaLBRRQ2MPicXmvFyS8ozD+ZnOH4FEkEHvgbb7uAK5wn wRO3yMew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tPuF9-0000000B3kT-1acK; Tue, 24 Dec 2024 02:01:55 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tPu22-0000000B1ZS-0wY1 for linux-mediatek@lists.infradead.org; Tue, 24 Dec 2024 01:48:24 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-53e3778bffdso5267232e87.0 for ; Mon, 23 Dec 2024 17:48:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735004900; x=1735609700; darn=lists.infradead.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=pT8kLYrCB5PCEoycFNDmtbXGVBvLDjFx+TZSQpeiF7Y=; b=PNwyQuW/tzpVUluMbZJCwRa2Gscf3Pq7U+m+aQ0qIYUewlnEZeC4p1+mz6KOsuzTDD KiSWLQgVPsgAxo/vkWOi4mx/REwRKh3XGgHVysl0HQmizWuJdFKS5JoIepTJKONnxFY9 AiX5z5nsWDZQhYwKEZB667VyLvcjKGXHAJQI+eNblqojAvNsNKodfvXkIa7E65fEzEaP 3Ka8Gq4y1XEYNqjk3wBs1QaamDy9mA0735W8x3uIYZucDspErO2ZkU4EHQJSeqb5ddAm 0Wfi477La/7hgVvWOwRRTVb8yIvDJqhMSNvLJoTeWD8piqxGy3akEVItnTnNgP95H08P KB2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735004900; x=1735609700; 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=pT8kLYrCB5PCEoycFNDmtbXGVBvLDjFx+TZSQpeiF7Y=; b=lYMFZKrx7SYoFJf4cfChR/xQanSJKhaLky/OleWC9+9y4MweNtv0TJPHjniucIRI1j xSNdKjmjMQg3gm77n9spohDtqVIoahBaYL/eYs6SL/8X9lESYppbAhq50+Hn1YnGr+iG H88A23CMn4ZrJzIYcc13Izge36tuiCjxYwfX8J2TXLgWf765qXmX+/YGQbA2DGpPtqU9 Npr+XCSqwGoOkjCdcE9zt/vECjNyD3u69eU0BQC8n00V9cc5MD7RhOtN2KIggQtKR6yK cY1LJC5GXC8XyJHwTBYBNtD2dbZiGekF4UgcIYQRLl3VtqSvgzcAcFdj62GFVXxbs6lB ztoQ== X-Forwarded-Encrypted: i=1; AJvYcCXBDRTJDVV7SbqWx3HSwby4Q9f0aBI2C6QjcwElczooQB1MQaBEMqLjIYeDGbnq2fvXJO3QZHVXYIjBE3wu8Q==@lists.infradead.org X-Gm-Message-State: AOJu0YxqC65HUFxg09bu33TMswCsUyfsxGKShTpdk9brzzRFmMebmM4k iP//ZACJ0+Gy5JlayOeuFtF0RXkeZ6RLSb87bW4RRoIHhrCfw8SKwUHIkztiYF4= X-Gm-Gg: ASbGncvPdueaN1C3e5sQ3lLIMNiUgG4xwkt07FVdqOTjl++/9uK+pFBdAiAommuxpsn KPwGnhLW8LSwoAirQpHUgiwIdhlb87y7E417aQ6bUIz453F1hIGcliwh64vIbWSwMcWZloqCfVY yREmbdfBNtWTEZPChl29BocP7aw1pO9v63EXJO6rqgu7RMZFwBrGVfWX3yZw4Mlfsjxd3Gbg/fj ntZsBBD4TwFixzgkBW9HcEI3Ok7p0ClYRttgQXq2F40UZLm8/RQhBJ0eIMopSNN X-Google-Smtp-Source: AGHT+IG8vUOhmVgUkB9r/gtmSUaisua3uAUV44IRvqJS3Ig+fU7HeUAYMWthZ0/qn2QCu92dmtuOfA== X-Received: by 2002:ac2:4c50:0:b0:542:29ec:d338 with SMTP id 2adb3069b0e04-54229ecd495mr3659153e87.39.1735004900269; Mon, 23 Dec 2024 17:48:20 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-542235f6509sm1425988e87.25.2024.12.23.17.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 17:48:18 -0800 (PST) From: Dmitry Baryshkov Date: Tue, 24 Dec 2024 03:48:00 +0200 Subject: [PATCH v10 08/10] drm/vc4: hdmi: switch to using generic HDMI Codec infrastructure MIME-Version: 1.0 Message-Id: <20241224-drm-bridge-hdmi-connector-v10-8-dc89577cd438@linaro.org> References: <20241224-drm-bridge-hdmi-connector-v10-0-dc89577cd438@linaro.org> In-Reply-To: <20241224-drm-bridge-hdmi-connector-v10-0-dc89577cd438@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_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=7670; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=n/24qvqqwFGUzmoaHOxX+WZSX99nmL45qjtItCdBJCU=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnahLNmcYqJbEfLmk/qt27tPnj07jedcXRSONtc OZ6G9BnP0yJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ2oSzQAKCRCLPIo+Aiko 1fdhB/9/GqduXlVyjS7Vjei5Ktt9LoM5qPGcPkMe8CPP1Xv2BWCQ4oiuAqONFomZxkuwYAbf1DB sbQ/FaiGhry11RMVTpYmPA2YqOZ5kITVf8u464UfHZ38Cthi4VfXzkwr5wAQfnPvQaJQETnQO5S FVmUfyBkrcVdXRwVp6331Okqicc/xyR1jhgYnqtckc/N8IJ7XVHwpwmumbrcHqnXAlx/aw85OeC zjEmknWLbnTXgcTgOtDqvUjMEizr2eZBZJoYYEsDcnAbP/QsMCAxxGUoXI4zVH1rzcKm+0eckJF qJVgzGhmqUXZreAmQyJeTEO59lSyhO/4BoD9OsrgDVoZgr1w X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241223_174822_290169_48FBAD69 X-CRM114-Status: GOOD ( 17.28 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Drop driver-specific implementation and use the generic HDMI Codec framework in order to implement the HDMI audio support. Acked-by: Maxime Ripard Tested-by: Dave Stevenson Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/vc4/Kconfig | 1 + drivers/gpu/drm/vc4/vc4_hdmi.c | 74 +++++++++++------------------------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 2 -- 3 files changed, 20 insertions(+), 57 deletions(-) diff --git a/drivers/gpu/drm/vc4/Kconfig b/drivers/gpu/drm/vc4/Kconfig index c5f30b317698a1285ae14c07c0f12a2ceb08dde4..6cc7b7e6294a1bfa54137ca65296cd47e46b1e1e 100644 --- a/drivers/gpu/drm/vc4/Kconfig +++ b/drivers/gpu/drm/vc4/Kconfig @@ -10,6 +10,7 @@ config DRM_VC4 depends on COMMON_CLK depends on PM select DRM_CLIENT_SELECTION + select DRM_DISPLAY_HDMI_AUDIO_HELPER select DRM_DISPLAY_HDMI_HELPER select DRM_DISPLAY_HDMI_STATE_HELPER select DRM_DISPLAY_HELPER diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 203293a8beca738dbfeaaf15f350026e263e646b..cc5fdb23f76f4a4730ab9eff9b47f5d1507aac8f 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -31,6 +31,7 @@ * encoder block has CEC support. */ +#include #include #include #include @@ -584,6 +585,7 @@ static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs = }; static const struct drm_connector_hdmi_funcs vc4_hdmi_hdmi_connector_funcs; +static const struct drm_connector_hdmi_audio_funcs vc4_hdmi_audio_funcs; static int vc4_hdmi_connector_init(struct drm_device *dev, struct vc4_hdmi *vc4_hdmi) @@ -609,6 +611,12 @@ static int vc4_hdmi_connector_init(struct drm_device *dev, if (ret) return ret; + ret = drm_connector_hdmi_audio_init(connector, dev->dev, + &vc4_hdmi_audio_funcs, + 8, false, -1); + if (ret) + return ret; + drm_connector_helper_add(connector, &vc4_hdmi_connector_helper_funcs); /* @@ -1921,9 +1929,9 @@ static bool vc4_hdmi_audio_can_stream(struct vc4_hdmi *vc4_hdmi) return true; } -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 = dev_get_drvdata(dev); + struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); struct drm_device *drm = vc4_hdmi->connector.dev; unsigned long flags; int ret = 0; @@ -1985,9 +1993,9 @@ static void vc4_hdmi_audio_reset(struct vc4_hdmi *vc4_hdmi) spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); } -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 = dev_get_drvdata(dev); + struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); struct drm_device *drm = vc4_hdmi->connector.dev; unsigned long flags; int idx; @@ -2057,13 +2065,12 @@ static int sample_rate_to_mai_fmt(int samplerate) } /* 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 = dev_get_drvdata(dev); + struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); struct drm_device *drm = vc4_hdmi->connector.dev; - struct drm_connector *connector = &vc4_hdmi->connector; struct vc4_dev *vc4 = to_vc4_dev(drm); unsigned int sample_rate = params->sample_rate; unsigned int channels = params->channels; @@ -2075,7 +2082,7 @@ static int vc4_hdmi_audio_prepare(struct device *dev, void *data, int ret = 0; int idx; - 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); mutex_lock(&vc4_hdmi->mutex); @@ -2214,40 +2221,12 @@ static const struct snd_dmaengine_pcm_config pcm_conf = { .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, }; -static int vc4_hdmi_audio_get_eld(struct device *dev, void *data, - uint8_t *buf, size_t len) -{ - struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); - struct drm_connector *connector = &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 = { - .get_eld = vc4_hdmi_audio_get_eld, +static const struct drm_connector_hdmi_audio_funcs vc4_hdmi_audio_funcs = { + .startup = vc4_hdmi_audio_startup, .prepare = vc4_hdmi_audio_prepare, - .audio_shutdown = vc4_hdmi_audio_shutdown, - .audio_startup = vc4_hdmi_audio_startup, -}; - -static struct hdmi_codec_pdata vc4_hdmi_codec_pdata = { - .ops = &vc4_hdmi_codec_ops, - .max_i2s_channels = 8, - .i2s = 1, + .shutdown = vc4_hdmi_audio_shutdown, }; -static void vc4_hdmi_audio_codec_release(void *ptr) -{ - struct vc4_hdmi *vc4_hdmi = ptr; - - platform_device_unregister(vc4_hdmi->audio.codec_pdev); - vc4_hdmi->audio.codec_pdev = NULL; -} - static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) { const struct vc4_hdmi_register *mai_data = @@ -2255,7 +2234,6 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) struct snd_soc_dai_link *dai_link = &vc4_hdmi->audio.link; struct snd_soc_card *card = &vc4_hdmi->audio.card; struct device *dev = &vc4_hdmi->pdev->dev; - struct platform_device *codec_pdev; const __be32 *addr; int index, len; int ret; @@ -2348,20 +2326,6 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) return ret; } - codec_pdev = 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_pdev)); - return PTR_ERR(codec_pdev); - } - vc4_hdmi->audio.codec_pdev = codec_pdev; - - ret = devm_add_action_or_reset(dev, vc4_hdmi_audio_codec_release, vc4_hdmi); - if (ret) - return ret; - dai_link->cpus = &vc4_hdmi->audio.cpu; dai_link->codecs = &vc4_hdmi->audio.codec; dai_link->platforms = &vc4_hdmi->audio.platform; @@ -2374,7 +2338,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) dai_link->stream_name = "MAI PCM"; dai_link->codecs->dai_name = "i2s-hifi"; dai_link->cpus->dai_name = dev_name(dev); - dai_link->codecs->name = dev_name(&codec_pdev->dev); + dai_link->codecs->name = dev_name(&vc4_hdmi->connector.hdmi_audio.codec_pdev->dev); dai_link->platforms->name = dev_name(dev); card->dai_link = dai_link; diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index b2424a21da230db99db207efa293417faccd254d..e3d989ca302b72533c374dfa3fd0d5bd7fe64a82 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; };