From patchwork Tue Dec 31 18:44:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13923924 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 37FAD1ACEB8; Tue, 31 Dec 2024 18:44:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735670673; cv=none; b=Fd0xZl29K80yWhm5hqmnlWbgE68wWtDb0tXniyHLd6iiLhwb6Z6leeHACJja8/3TQ0l0vfJ0X2xu28HOgsRTgp14EI5QSGvCYIBvQOEq5/fXk1KUarJUH0YWrxOcOoM7Id5SnmqV/JwBHlDFFSIjnnKZCmHcM0l+7vRslS4+P6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735670673; c=relaxed/simple; bh=GZmHbEywkh+T4AaS2osYF2FBNuq2j3qC3zbefBSNVrw=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=RKWfck2wrrUC93yKo5nHHNTpTQmYN7MhaOWblixfKvtc5WncSiBgQOwVqChd6MpZoczIf9gqRFYwnPK3Lmk+ZS57dZy5vbN0XDLM4wbuYl8exZ2uARQVBBPWBVKYUX3L5U6WorrYCudtKJP82uTKnG2PER8XvaKMWRB5rZLVHZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com; spf=pass smtp.mailfrom=googlemail.com; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b=GDWcKmmP; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="GDWcKmmP" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-21680814d42so117930435ad.2; Tue, 31 Dec 2024 10:44:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1735670671; x=1736275471; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=rx/BAtYz+YSmLVs6o5kW+gu0D5xRt+OIkNVnblY2Dys=; b=GDWcKmmPtZevr+8XTKhCT+nrcmd7DqFJOUc1gI4A+w49viBqUFgZUlVRXHsn73zhGD Jn9fPGoV4UpMVy7AkIb3SiacR1J3ixcZDlfIfetC5u7urEQdVPxd3a4zQNClkHl3a4Lp 6DeJtRkpGjqGTGqu7M448Rh3vaS9u/gtKGk5ViRzA0HvRuI2iX+TqW9d1F+GCK02p2hV IgZF+YDwgZrem1a3SpG2SGGfTkKg9HCn0iJoycIR0Tt7q8s65hVY57RHHGHQcwNck8ag GHi2qdkv0etsxDcVuFO2mfTNLjMxGPok0UoBIcLSvMtiIYX5ulz7y5923aN9EvM7ymmg g/5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735670671; x=1736275471; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rx/BAtYz+YSmLVs6o5kW+gu0D5xRt+OIkNVnblY2Dys=; b=JwhRbPJKWdHv8USnCI/GFWmrWdQQk8tcnHvGReEIhG/ksV5ILxpHBsOYBDFS6XZMhZ B4zIJcE7cuP5xN2segszG1lyfgH0aUspDGzwRpXlf+eIyCcL10QHz2mY+ysZy6EZ4Ad0 OtDtQhewzYK3CRPOiW0xRs754hR/iiDhVHWFIH0CgqZCVWI/kJAhobDgfPoaWIDygLSd BZU7CdG7Y6CRNBus6tuoIqouj06OhxQkzaztIpc+sS/d3NimHwJY1R6f/JsM3ASCaaH/ G7pNwVlAMadBwT7vsB7vh+0Fvf7eD399hh4qPF4csn8elXGHa0v/m1smls5dklVZRwRJ mFag== X-Forwarded-Encrypted: i=1; AJvYcCWIj3b3kqLwx+BhEJmj6fTh2IuKJjUfcQ6yT93tUWYNaVxx/JDsibZLDZYlDH8dGbPsVsD++ZQSfnJ22VY=@vger.kernel.org X-Gm-Message-State: AOJu0YzgYuKA4uS7EZskCmpoNunrEClNMUNo3KsCKyfjq1GHRmAqQYO/ X2bMo6Kh7aOQOM52NmvuNSvqnveS+BKw3fpwFYsoupoep6jBFWkYfo/+Mnuzu7Yft9Jl80esJOn Yx8PtguTIAozjlwitKnYibouyxe0= X-Gm-Gg: ASbGncuJjN671lP5TiUv8rE+njU0rrLqZ4CDaya1L2rqgF/03NsLX6fa2AROd5XzyRM kKFofutOSvlCgMiBMAXVnmf4Ph2XUck/iI2B+66eYzpCCivLV2703JYDil4F30oerOzbM3vY= X-Google-Smtp-Source: AGHT+IH0eYkv9jMWnNWk5clNdXDiJhTdGXywUxzL8uXyNgWAEqJCW8pgacoyM8OKkm7iaQpFDbJb+dG7SSGKuIkyu6Q= X-Received: by 2002:a17:903:32c5:b0:215:bb50:6a05 with SMTP id d9443c01a7336-219e6e894f4mr583339975ad.9.1735670671350; Tue, 31 Dec 2024 10:44:31 -0800 (PST) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Martin Blumenstingl Date: Tue, 31 Dec 2024 19:44:20 +0100 Message-ID: Subject: meson-aiu: HDMI codec .prepare() callback not called To: linux-amlogic@lists.infradead.org, jbrunet@baylibre.com Cc: linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmitry.baryshkov@linaro.org Hi Jerome, I am still working on a HDMI controller driver for Meson8/8b/8m2. HDMI output would be incomplete without audio. There's a great series from Dmitry [0] which simplifies the HDMI controller driver implementation by moving all the hdmi-codec related management to a generic framework. I tried integrating Dmitry's work [0] into my HDMI controller driver. While testing I found that hdmi-codec's .prepare() callback is not called at all and asked Dmitry for help [1]. All other callbacks (.hw_params, .startup, .shutdown, ...) however are called. On his board (Qualcomm SDM845, sdm845-db845c.dts) hdmi_codec_prepare() is called by snd_soc_pcm_dai_prepare() (core sound framework, not platform specific). However, on my Odroid-C1 this is not happening. Looking further snd_soc_pcm_dai_prepare() I can see that for_each_rtd_dais() has three entries: snd_soc_pcm_dai_prepare(), dai name=I2S Encoder, id=2 snd_soc_pcm_dai_prepare(), dai name=CODEC CTRL HDMI I2S IN, id=0 snd_soc_pcm_dai_prepare(), dai name=I2S FIFO, id=0 What I'm missing here is a dai name "i2s-hifi" (from sound/soc/codecs/hdmi-codec.c, see hdmi_i2s_dai) My hdmi_tx node looks like this (abbreviated): hdmi_tx: hdmi-tx@42000 { compatible = "amlogic,meson8b-hdmi-tx"; reg = <0x42000 0xc>; #sound-dai-cells = <1>; ... }; Then I have a "amlogic,gx-sound-card" instance with the following dai-links: dai-link-0 { sound-dai = <&aiu AIU_CPU CPU_I2S_FIFO>; }; dai-link-1 { sound-dai = <&aiu AIU_CPU CPU_I2S_ENCODER>; dai-format = "i2s"; mclk-fs = <256>; codec-0 { sound-dai = <&aiu AIU_HDMI CTRL_I2S>; }; }; dai-link-2 { sound-dai = <&aiu AIU_HDMI CTRL_OUT>; codec-0 { sound-dai = <&hdmi_tx 0>; }; }; So apart from the additional cell in the sound-dai towards hdmi_tx (Meson8/8b/8m2's HDMI controller has two inputs: I2C and SPDIF. I2C is the first one, hence &hdmi_tx 0) this is identical to arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts. I have further verified that the gx-card parsing does find the HDMi controller and links it correctly. To me it's odd that only the .prepare() callback is not called, all others (as mentioned above: .hw_params, .startup, ...) are working fine. I'm not familiar with the sound stack and I'm hoping that you have some ideas on how to either debug or fix it. Thanks in advance and best regards, Martin [0] https://lore.kernel.org/dri-devel/20241224-drm-bridge-hdmi-connector-v10-0-dc89577cd438@linaro.org/ [1] https://lore.kernel.org/dri-devel/20241231004311.2574720-1-martin.blumenstingl@googlemail.com/ [2] https://lore.kernel.org/dri-devel/l3u3wtnxyhrwjynevkwfjwarisc4yt4xy2rbzf5kb7k5l5dw3n@lxqtimymyjg6/ diff --git a/drivers/gpu/drm/display/drm_hdmi_audio_helper.c b/drivers/gpu/drm/display/drm_hdmi_audio_helper.c index aa3a5d0329dc..05afc9f0bdd6 100644 --- a/drivers/gpu/drm/display/drm_hdmi_audio_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_audio_helper.c @@ -129,7 +129,6 @@ EXPORT_SYMBOL(drm_connector_hdmi_audio_plugged_notify); static const struct hdmi_codec_ops drm_connector_hdmi_audio_ops = { .audio_startup = drm_connector_hdmi_audio_startup, .prepare = drm_connector_hdmi_audio_prepare, - .hw_params = drm_connector_hdmi_audio_prepare, .audio_shutdown = drm_connector_hdmi_audio_shutdown, .mute_stream = drm_connector_hdmi_audio_mute_stream, .get_eld = drm_connector_hdmi_audio_get_eld, diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 69f98975e14a..a931d05ba89e 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -570,13 +570,13 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, }; int ret; - if (!hcp->hcd.ops->hw_params) - return 0; - - dev_dbg(dai->dev, "%s() width %d rate %d channels %d\n", __func__, + dev_info(dai->dev, "%s() width %d rate %d channels %d\n", __func__, params_width(params), params_rate(params), params_channels(params)); + if (!hcp->hcd.ops->hw_params) + return 0; + ret = hdmi_codec_fill_codec_params(dai, params_width(params), params_rate(params), @@ -611,12 +611,12 @@ static int hdmi_codec_prepare(struct snd_pcm_substream *substream, struct hdmi_codec_params hp; int ret; + dev_info(dai->dev, "%s() width %d rate %d channels %d\n", __func__, + width, rate, channels); + if (!hcp->hcd.ops->prepare) return 0; - dev_dbg(dai->dev, "%s() width %d rate %d channels %d\n", __func__, - width, rate, channels); - ret = hdmi_codec_fill_codec_params(dai, width, rate, channels, &hp); if (ret < 0) return ret; diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index 34ba1a93a4c9..030c573753cc 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -577,6 +577,7 @@ int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream) int i, ret; for_each_rtd_dais(rtd, i, dai) { + pr_info("%s(), dai name=%s, id=%d\n", __func__, dai->name, dai->id); if (!snd_soc_dai_stream_valid(dai, substream->stream)) continue; if (dai->driver->ops &&