Message ID | 20231106104013.704356-1-jbrunet@baylibre.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2567042vqu; Mon, 6 Nov 2023 02:41:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1nQWqTunq5/iIWOSGJjKf1pOT6JsKmE+dbkvBbwq/YPCYmqg7RcMM/jUb+JAX+T6wGYvU X-Received: by 2002:a05:6358:1203:b0:168:ff1a:8804 with SMTP id h3-20020a056358120300b00168ff1a8804mr28175781rwi.20.1699267267284; Mon, 06 Nov 2023 02:41:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699267266; cv=none; d=google.com; s=arc-20160816; b=o7AWNCV0Ct3x3x7KDf1Ow4RiXcrIsZrJDaLf1o+ILoJZIotEX23ySBNkOyrKf1irQa hc10xCVEs5RkhKM3ZE/1pbUIpXy8nHN/wbgoz7/kTBM6qzjzzx5pRHvkjOLB4kQg0MWH V85ZT1dE4CsFKJIvg3mRPzAvEg571qXb+RcTybyzDCOs7VRw8at0vDfrBMLX6oG4Fcxr dBQLGBtLsf2KppmqJ7juX5gf2Mi3s9yBv6Ox3JMEWvzsrcQ9j3eFNBC4yc7/2tW/G3yO oXpz2nQyoV47Fz5Inm55wOOqZ2HMuipbDW2sBTfCV7Mn3H3KOSdEfOy0wPOemDagy0Yz Mvmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Nbjwm+H7hl2EuKWl07XyZwpvz3KlHSIgvjF5mlsdjpY=; fh=2iCxWoL4OHRTYWxOu09ZXK1Hw9S9eoIvoOrUzdkRCpQ=; b=gPr0ihVsdFVd0jTqUBmwnENhCUgEXzmp7CvTUMcKCywEvvimkBtPhe2HYuOdMJVhcz CH1U9e5b6u9OKrqZ7JDEsUoahdoLxGeMlQOxbUeYdzg3C2XULbB/zEMOxSs1Xj8gAhTX wrpCqzxcBGMiyyRJEZYCAdkG6TLELcODWEiFWS/D5yQCVTeu3ENAr4ewAHgtRj4RP0A3 3ioQ2665zeqqnidDgPvIIZwR606zmCPc2Gk2YgaCayM6QeFQDYFufDK7XGApcGCmJBjq dPHMBo2yqt+CeyHpsKZhWdTpZOE7y8e008b1EuPAy/K8wwaxhHjB3mEXWG9eKekLA8Tu CB/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=HzgAQoRe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id l196-20020a633ecd000000b005acf0458523si7375807pga.612.2023.11.06.02.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 02:41:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=HzgAQoRe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4DEB2808A90B; Mon, 6 Nov 2023 02:40:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231215AbjKFKk1 (ORCPT <rfc822;jaysivo@gmail.com> + 36 others); Mon, 6 Nov 2023 05:40:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjKFKkZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Nov 2023 05:40:25 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDD78123 for <linux-kernel@vger.kernel.org>; Mon, 6 Nov 2023 02:40:22 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-9d0b4dfd60dso630841366b.1 for <linux-kernel@vger.kernel.org>; Mon, 06 Nov 2023 02:40:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1699267221; x=1699872021; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Nbjwm+H7hl2EuKWl07XyZwpvz3KlHSIgvjF5mlsdjpY=; b=HzgAQoReIO7E2ynjMLhUeBp/tgKupCoSNcnxbeOi+O9/8kI+0PZNPwWGK1Nag+gc18 I1tsN4syUu33mGGZ4/Jdsjy7Ibc8wOGvHRXgZDPgJt4LIuwlUfPbJTTK13ldn3BvH07Z ArqHF9AeaHWwWai8zVdxdiAshy678NmRAAz1lFU2oFzF4lITWRwD5Q3pBKy8Ej2AxedY 0PigVGF+ju5g9qDw+DK/oGwGgEoO0Fp5x3P/sCSeK1o/wAm8FOd2ThE0kzYLnNXgQC87 kYNTi8RXKFWNpL08R5aO20Twxhf5aW+6PRJWZMnd9XZsAjZ9koORHrWwUjhSG9qtRbY7 IXbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699267221; x=1699872021; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Nbjwm+H7hl2EuKWl07XyZwpvz3KlHSIgvjF5mlsdjpY=; b=RyYcSnWyCcR9Qx2Kd6yLCX4+MoP/zFDkPvnrleH3ftKqNwKc4v4t1X3avNdDnDh8Jo 3wC3ftiSCmcc3B1bLwVHzK+hhUPZgBCI7R62GsXdBZJZmsVS/8EB2obBTL12W8mtq8jN Ft1ITiS18257uxbV/AM1UEw0NoINLfhjESakPKOTQWXPVAfApEv3KYuvLJwY7VItvjD7 NTyT6WSbGUQAyXJ4zsBDGoAaAoQn8Q+lPB62/1YXvLK+EOfL7OD6AlDu3GObpJoX7mLC +2XUIcQ9z0+yXnWZgtSbWTbcugjJC46S9KbCHBhqTfmFjCo6m8Gx7G6skwU1vzI0PqPb DdfQ== X-Gm-Message-State: AOJu0YyA7IkQxmVFVKgFAeeoiV1kzh29zd3UWyyAoDXzpeh1gSbzR7fN 6oAMCdxKMaeCRQZcIkxFL5hNho1hCJ5I1Q/Uq/A= X-Received: by 2002:a17:906:d554:b0:9ae:5db5:13d with SMTP id cr20-20020a170906d55400b009ae5db5013dmr14948952ejc.72.1699267221002; Mon, 06 Nov 2023 02:40:21 -0800 (PST) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:fabf:ec8c:b644:5d3]) by smtp.googlemail.com with ESMTPSA id jg2-20020a05600ca00200b004065daba6casm11876137wmb.46.2023.11.06.02.40.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 02:40:20 -0800 (PST) From: Jerome Brunet <jbrunet@baylibre.com> To: Mark Brown <broonie@kernel.org> Cc: Jerome Brunet <jbrunet@baylibre.com>, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: hdmi-codec: register hpd callback on component probe Date: Mon, 6 Nov 2023 11:40:11 +0100 Message-ID: <20231106104013.704356-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 06 Nov 2023 02:40:46 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781810873559223863 X-GMAIL-MSGID: 1781810873559223863 |
Series |
ASoC: hdmi-codec: register hpd callback on component probe
|
|
Commit Message
Jerome Brunet
Nov. 6, 2023, 10:40 a.m. UTC
The HDMI hotplug callback to the hdmi-codec is currently registered when
jack is set.
The hotplug not only serves to report the ASoC jack state but also to get
the ELD. It should be registered when the component probes instead, so it
does not depend on the card driver registering a jack for the HDMI to
properly report the ELD.
Fixes: 25ce4f2b3593 ("ASoC: hdmi-codec: Get ELD in before reporting plugged event")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
sound/soc/codecs/hdmi-codec.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
Comments
On Mon, 06 Nov 2023 11:40:11 +0100, Jerome Brunet wrote: > The HDMI hotplug callback to the hdmi-codec is currently registered when > jack is set. > > The hotplug not only serves to report the ASoC jack state but also to get > the ELD. It should be registered when the component probes instead, so it > does not depend on the card driver registering a jack for the HDMI to > properly report the ELD. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/1] ASoC: hdmi-codec: register hpd callback on component probe commit: 15be353d55f9e12e34f9a819f51eb41fdef5eda8 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
On Fri 15 Dec 2023 at 12:51, Zhengqiao Xia <xiazhengqiao@huaqin.corp-partner.google.com> wrote: > Hi Jerome, > > After my testing, I found that this patch will cause the audio on the external display to not work properly after > restart. > You move the plugged_cb to run in hdmi_probe, at this time hcp- > jack = NULL, the driver cannot report `SND_JACK_LINEOUT > ` normally. > static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp, > unsigned int jack_status) > { > printk("xzq-866 hdmi_codec_jack_report: jack=%x, jack_status=%d", hcp->jack, jack_status != hcp->jack_status); > if (hcp->jack && jack_status != hcp->jack_status) { > snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT); > hcp->jack_status = jack_status; > } > } > So we must call plugged_cb in hdmi_codec_set_jack, Can you make some changes? Hi Zhengqiao, That is unfortunate. Sorry. This patch has changed when the hpd callback is registered, no when it comes in effect. This is still dependent on calling .set_jack() and it is not happening any later than it was before. So, in theory, it should not have changed anything, if your driver actually relies on the HPD event. Trying to guess what is happening for you, I suppose your HDMI driver is "faking" an HPD event to report the initial jack status when the hook_plugged_cb() is called. Could you point me to the hdmi driver you are using so I can have a look ? My reference when testing this was dw-hdmi-i2s-audio and it does not do that, it just registers the callback. I think this is what it supposed to do TBH. An idea I have been thinking about for a while is have the hdmi-codec insert the jack in the card itself, instead of the card doing. That would give the jack "for free" to any user of the HDMI codec and might also solve your issue. It would require a small rework of the cards doing the hdmi jack register, but there are not many of these AFAIK. > > On Mon, Nov 6, 2023 at 6:40 PM Jerome Brunet <jbrunet@baylibre.com> wrote: > > The HDMI hotplug callback to the hdmi-codec is currently registered when > jack is set. > > The hotplug not only serves to report the ASoC jack state but also to get > the ELD. It should be registered when the component probes instead, so it > does not depend on the card driver registering a jack for the HDMI to > properly report the ELD. > > Fixes: 25ce4f2b3593 ("ASoC: hdmi-codec: Get ELD in before reporting plugged event") > Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> > --- > sound/soc/codecs/hdmi-codec.c | 27 +++++++++++++++++++-------- > 1 file changed, 19 insertions(+), 8 deletions(-) > > diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c > index 09eef6042aad..20da1eaa4f1c 100644 > --- a/sound/soc/codecs/hdmi-codec.c > +++ b/sound/soc/codecs/hdmi-codec.c > @@ -877,18 +877,13 @@ static int hdmi_codec_set_jack(struct snd_soc_component *component, > void *data) > { > struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); > - int ret = -ENOTSUPP; > > if (hcp->hcd.ops->hook_plugged_cb) { > hcp->jack = jack; > - ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, > - hcp->hcd.data, > - plugged_cb, > - component->dev); > - if (ret) > - hcp->jack = NULL; > + return 0; > } > - return ret; > + > + return -ENOTSUPP; > } > > static int hdmi_dai_spdif_probe(struct snd_soc_dai *dai) > @@ -982,6 +977,21 @@ static int hdmi_of_xlate_dai_id(struct snd_soc_component *component, > return ret; > } > > +static int hdmi_probe(struct snd_soc_component *component) > +{ > + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); > + int ret = 0; > + > + if (hcp->hcd.ops->hook_plugged_cb) { > + ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, > + hcp->hcd.data, > + plugged_cb, > + component->dev); > + } > + > + return ret; > +} > + > static void hdmi_remove(struct snd_soc_component *component) > { > struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); > @@ -992,6 +1002,7 @@ static void hdmi_remove(struct snd_soc_component *component) > } > > static const struct snd_soc_component_driver hdmi_driver = { > + .probe = hdmi_probe, > .remove = hdmi_remove, > .dapm_widgets = hdmi_widgets, > .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets),
On Fri, Dec 15, 2023 at 12:40 AM Jerome Brunet <jbrunet@baylibre.com> wrote: > > > On Fri 15 Dec 2023 at 12:51, Zhengqiao Xia <xiazhengqiao@huaqin.corp-partner.google.com> wrote: > > > Hi Jerome, > > > > After my testing, I found that this patch will cause the audio on the external display to not work properly after > > restart. > > You move the plugged_cb to run in hdmi_probe, at this time hcp- > jack = NULL, the driver cannot report `SND_JACK_LINEOUT > > ` normally. > > static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp, > > unsigned int jack_status) > > { > > printk("xzq-866 hdmi_codec_jack_report: jack=%x, jack_status=%d", hcp->jack, jack_status != hcp->jack_status); > > if (hcp->jack && jack_status != hcp->jack_status) { > > snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT); > > hcp->jack_status = jack_status; > > } > > } > > So we must call plugged_cb in hdmi_codec_set_jack, Can you make some changes? > > Hi Zhengqiao, > > That is unfortunate. Sorry. > > This patch has changed when the hpd callback is registered, no when it > comes in effect. This is still dependent on calling .set_jack() and it > is not happening any later than it was before. So, in theory, it should > not have changed anything, if your driver actually relies on the HPD > event. > > Trying to guess what is happening for you, I suppose your HDMI driver is > "faking" an HPD event to report the initial jack status when the > hook_plugged_cb() is called. Could you point me to the hdmi driver you > are using so I can have a look ? > > My reference when testing this was dw-hdmi-i2s-audio and it does not do > that, it just registers the callback. I think this is what it supposed > to do TBH. > > An idea I have been thinking about for a while is have the hdmi-codec > insert the jack in the card itself, instead of the card doing. That > would give the jack "for free" to any user of the HDMI codec and might > also solve your issue. It would require a small rework of the cards doing > the hdmi jack register, but there are not many of these AFAIK. > The driver is it6505. The implementation of hook_plugged_cb(): 1. register plugged_cb 2. call plugged_cb(bool plugged) bridge detect callback it6505_detect would also call plugged_cb, but only on the first time hpd status changed (eg. changed from connect <--> disconnect) it6505_detect() { status = it6505->hpd_state ... ... if (it6505->connector_status != status) { it6505->connector_status = status; it6505_plugged_status_to_codec(it6505); // this will call plugged_cb } } Unfortunately the first time after boot that hpd status changed was detected before set_jack. If we replug hdmi, the plugged_cb() was called by bridge_detect, which is expected. Prior to this patch, the initial plugged_cb() was called by hook_plugged_cb(). After the patch, plugged_cb() should be called by hpd change (by bridge detect), but due to the driver logic only calling it on the first hpd state change, it fails to call plugged_cb() again when jack is set. I checked the dw-hdmi.c's bridge_detect, and it's similar in that it also checks the last_connector_result, so maybe it's due to a timing difference? > > > > On Mon, Nov 6, 2023 at 6:40 PM Jerome Brunet <jbrunet@baylibre.com> wrote: > > > > The HDMI hotplug callback to the hdmi-codec is currently registered when > > jack is set. > > > > The hotplug not only serves to report the ASoC jack state but also to get > > the ELD. It should be registered when the component probes instead, so it > > does not depend on the card driver registering a jack for the HDMI to > > properly report the ELD. > > > > Fixes: 25ce4f2b3593 ("ASoC: hdmi-codec: Get ELD in before reporting plugged event") > > Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> > > --- > > sound/soc/codecs/hdmi-codec.c | 27 +++++++++++++++++++-------- > > 1 file changed, 19 insertions(+), 8 deletions(-) > > > > diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c > > index 09eef6042aad..20da1eaa4f1c 100644 > > --- a/sound/soc/codecs/hdmi-codec.c > > +++ b/sound/soc/codecs/hdmi-codec.c > > @@ -877,18 +877,13 @@ static int hdmi_codec_set_jack(struct snd_soc_component *component, > > void *data) > > { > > struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); > > - int ret = -ENOTSUPP; > > > > if (hcp->hcd.ops->hook_plugged_cb) { > > hcp->jack = jack; > > - ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, > > - hcp->hcd.data, > > - plugged_cb, > > - component->dev); > > - if (ret) > > - hcp->jack = NULL; > > + return 0; > > } > > - return ret; > > + > > + return -ENOTSUPP; > > } > > > > static int hdmi_dai_spdif_probe(struct snd_soc_dai *dai) > > @@ -982,6 +977,21 @@ static int hdmi_of_xlate_dai_id(struct snd_soc_component *component, > > return ret; > > } > > > > +static int hdmi_probe(struct snd_soc_component *component) > > +{ > > + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); > > + int ret = 0; > > + > > + if (hcp->hcd.ops->hook_plugged_cb) { > > + ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, > > + hcp->hcd.data, > > + plugged_cb, > > + component->dev); > > + } > > + > > + return ret; > > +} > > + > > static void hdmi_remove(struct snd_soc_component *component) > > { > > struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); > > @@ -992,6 +1002,7 @@ static void hdmi_remove(struct snd_soc_component *component) > > } > > > > static const struct snd_soc_component_driver hdmi_driver = { > > + .probe = hdmi_probe, > > .remove = hdmi_remove, > > .dapm_widgets = hdmi_widgets, > > .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets), > > > -- > Jerome
On Fri 15 Dec 2023 at 14:55, Hsin-Yi Wang <hsinyi@google.com> wrote: > On Fri, Dec 15, 2023 at 12:40 AM Jerome Brunet <jbrunet@baylibre.com> wrote: >> >> >> On Fri 15 Dec 2023 at 12:51, Zhengqiao Xia >> <xiazhengqiao@huaqin.corp-partner.google.com> wrote: >> >> > Hi Jerome, >> > >> > After my testing, I found that this patch will cause the audio on the external display to not work properly after >> > restart. >> > You move the plugged_cb to run in hdmi_probe, at this time hcp- > jack = NULL, the driver cannot report `SND_JACK_LINEOUT >> > ` normally. >> > static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp, >> > unsigned int jack_status) >> > { >> > printk("xzq-866 hdmi_codec_jack_report: jack=%x, jack_status=%d", hcp->jack, jack_status != hcp->jack_status); >> > if (hcp->jack && jack_status != hcp->jack_status) { >> > snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT); >> > hcp->jack_status = jack_status; >> > } >> > } >> > So we must call plugged_cb in hdmi_codec_set_jack, Can you make some changes? >> >> Hi Zhengqiao, >> >> That is unfortunate. Sorry. >> >> This patch has changed when the hpd callback is registered, no when it >> comes in effect. This is still dependent on calling .set_jack() and it >> is not happening any later than it was before. So, in theory, it should >> not have changed anything, if your driver actually relies on the HPD >> event. >> >> Trying to guess what is happening for you, I suppose your HDMI driver is >> "faking" an HPD event to report the initial jack status when the >> hook_plugged_cb() is called. Could you point me to the hdmi driver you >> are using so I can have a look ? >> >> My reference when testing this was dw-hdmi-i2s-audio and it does not do >> that, it just registers the callback. I think this is what it supposed >> to do TBH. >> >> An idea I have been thinking about for a while is have the hdmi-codec >> insert the jack in the card itself, instead of the card doing. That >> would give the jack "for free" to any user of the HDMI codec and might >> also solve your issue. It would require a small rework of the cards doing >> the hdmi jack register, but there are not many of these AFAIK. >> > > The driver is it6505. The implementation of hook_plugged_cb(): > 1. register plugged_cb > 2. call plugged_cb(bool plugged) > > bridge detect callback it6505_detect would also call plugged_cb, but > only on the first time hpd status changed (eg. changed from connect > <--> disconnect) > it6505_detect() { > status = it6505->hpd_state ... > ... > if (it6505->connector_status != status) { > it6505->connector_status = status; > it6505_plugged_status_to_codec(it6505); // this will call plugged_cb > } > } > > Unfortunately the first time after boot that hpd status changed was > detected before set_jack. If we replug hdmi, the plugged_cb() was > called by bridge_detect, which is expected. > > Prior to this patch, the initial plugged_cb() was called by hook_plugged_cb(). > After the patch, plugged_cb() should be called by hpd change (by > bridge detect), but due to the driver logic only calling it on the > first hpd state change, it fails to call plugged_cb() again when jack > is set. This is what thought > > I checked the dw-hdmi.c's bridge_detect, and it's similar in that it > also checks the last_connector_result, so maybe it's due to a timing > difference? No, I have overlooked that. I'm preparing a fix. I'll Cc you. Eventually, I still would like to make it easier for cards to use the HDMI jack and have to codec do that registration on its own. It will require some rework of cards already doing it. I've only seen 2 cards doing that at the moment: * imx-hdmi.c * mt8188-mt6359.c Could you point me to yours ? > >> > >> > On Mon, Nov 6, 2023 at 6:40 PM Jerome Brunet <jbrunet@baylibre.com> wrote: >> > >> > The HDMI hotplug callback to the hdmi-codec is currently registered when >> > jack is set. >> > >> > The hotplug not only serves to report the ASoC jack state but also to get >> > the ELD. It should be registered when the component probes instead, so it >> > does not depend on the card driver registering a jack for the HDMI to >> > properly report the ELD. >> > >> > Fixes: 25ce4f2b3593 ("ASoC: hdmi-codec: Get ELD in before reporting plugged event") >> > Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> >> > --- >> > sound/soc/codecs/hdmi-codec.c | 27 +++++++++++++++++++-------- >> > 1 file changed, 19 insertions(+), 8 deletions(-) >> > >> > diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c >> > index 09eef6042aad..20da1eaa4f1c 100644 >> > --- a/sound/soc/codecs/hdmi-codec.c >> > +++ b/sound/soc/codecs/hdmi-codec.c >> > @@ -877,18 +877,13 @@ static int hdmi_codec_set_jack(struct snd_soc_component *component, >> > void *data) >> > { >> > struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); >> > - int ret = -ENOTSUPP; >> > >> > if (hcp->hcd.ops->hook_plugged_cb) { >> > hcp->jack = jack; >> > - ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, >> > - hcp->hcd.data, >> > - plugged_cb, >> > - component->dev); >> > - if (ret) >> > - hcp->jack = NULL; >> > + return 0; >> > } >> > - return ret; >> > + >> > + return -ENOTSUPP; >> > } >> > >> > static int hdmi_dai_spdif_probe(struct snd_soc_dai *dai) >> > @@ -982,6 +977,21 @@ static int hdmi_of_xlate_dai_id(struct snd_soc_component *component, >> > return ret; >> > } >> > >> > +static int hdmi_probe(struct snd_soc_component *component) >> > +{ >> > + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); >> > + int ret = 0; >> > + >> > + if (hcp->hcd.ops->hook_plugged_cb) { >> > + ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, >> > + hcp->hcd.data, >> > + plugged_cb, >> > + component->dev); >> > + } >> > + >> > + return ret; >> > +} >> > + >> > static void hdmi_remove(struct snd_soc_component *component) >> > { >> > struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); >> > @@ -992,6 +1002,7 @@ static void hdmi_remove(struct snd_soc_component *component) >> > } >> > >> > static const struct snd_soc_component_driver hdmi_driver = { >> > + .probe = hdmi_probe, >> > .remove = hdmi_remove, >> > .dapm_widgets = hdmi_widgets, >> > .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets), >> >> >> -- >> Jerome
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 09eef6042aad..20da1eaa4f1c 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -877,18 +877,13 @@ static int hdmi_codec_set_jack(struct snd_soc_component *component, void *data) { struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); - int ret = -ENOTSUPP; if (hcp->hcd.ops->hook_plugged_cb) { hcp->jack = jack; - ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, - hcp->hcd.data, - plugged_cb, - component->dev); - if (ret) - hcp->jack = NULL; + return 0; } - return ret; + + return -ENOTSUPP; } static int hdmi_dai_spdif_probe(struct snd_soc_dai *dai) @@ -982,6 +977,21 @@ static int hdmi_of_xlate_dai_id(struct snd_soc_component *component, return ret; } +static int hdmi_probe(struct snd_soc_component *component) +{ + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + int ret = 0; + + if (hcp->hcd.ops->hook_plugged_cb) { + ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, + hcp->hcd.data, + plugged_cb, + component->dev); + } + + return ret; +} + static void hdmi_remove(struct snd_soc_component *component) { struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); @@ -992,6 +1002,7 @@ static void hdmi_remove(struct snd_soc_component *component) } static const struct snd_soc_component_driver hdmi_driver = { + .probe = hdmi_probe, .remove = hdmi_remove, .dapm_widgets = hdmi_widgets, .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets),