ASoC: hdmi-codec: register hpd callback on component probe
PATCH 1/1 ASoC: hdmi-codec: register hpd callback on component probe
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.
--- sound/soc/codecs/hdmi-codec.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
sound/soc/codecs/hdmi-codec.c +19 -8
@@ -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),
Signature · 1 line
2.42.0
Mark Brown
maintainerQuoted 9 lines · Jerome Brunet
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
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?
Quoted 78 lines · Jerome Brunet
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 reportingplugged event")
Signed-off-by Jerome Brunet <[email protected]>--- sound/soc/codecs/hdmi-codec.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)sound/soc/codecs/hdmi-codec.c +3
-8@@ -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)sound/soc/codecs/hdmi-codec.c +15
-0@@ -982,6 +977,21 @@ static int hdmi_of_xlate_dai_id(structsnd_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){
structhdmi_codec_priv*hcp =snd_soc_component_get_drvdata(component);sound/soc/codecs/hdmi-codec.c +1
-0@@ -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),
Quoted 8 lines · Zhengqiao Xia
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 theplugged_cbto run inhdmi_probe, at this time hcp- > jack = NULL, the driver cannot reportSND_JACK_LINEOUTnormally.
static void hdmi_codec_jack_report(structhdmi_codec_priv*hcp,
unsigned intjack_status)
Quoted 8 lines
{ 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_cbinhdmi_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.
Quoted 73 lines · Jerome Brunet
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 <[email protected]>---
sound/soc/codecs/hdmi-codec.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)diff --git
a/sound/soc/codecs/hdmi-codec.cb/sound/soc/codecs/hdmi-codec.cindex09eef6042aad..20da1eaa4f1c100644
---a/sound/soc/codecs/hdmi-codec.c
+++b/sound/soc/codecs/hdmi-codec.c
@@ -877,18 +877,13 @@ static int hdmi_codec_set_jack(structsnd_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(structsnd_soc_component*component,return ret;}
+static int
hdmi_probe(struct snd_soc_component *component)+{
+ structhdmi_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_driverhdmi_driver= {+ .probe = hdmi_probe, .remove = hdmi_remove, .dapm_widgets = hdmi_widgets, .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets),
Signature · 1 line
Jerome
Quoted 40 lines · Jerome Brunet
Quoted 8 lines · Zhengqiao Xia
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 theplugged_cbto run inhdmi_probe, at this time hcp- > jack = NULL, the driver cannot reportSND_JACK_LINEOUTnormally.
static void hdmi_codec_jack_report(structhdmi_codec_priv*hcp,
unsigned intjack_status)Quoted 8 lines
{ 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_cbinhdmi_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.
Quoted 6 lines
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?
Quoted 77 lines
Quoted 65 lines · Jerome Brunet
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 <[email protected]>---
sound/soc/codecs/hdmi-codec.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)diff --git
a/sound/soc/codecs/hdmi-codec.cb/sound/soc/codecs/hdmi-codec.cindex09eef6042aad..20da1eaa4f1c100644
---a/sound/soc/codecs/hdmi-codec.c
+++b/sound/soc/codecs/hdmi-codec.c
@@ -877,18 +877,13 @@ static int hdmi_codec_set_jack(structsnd_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(structsnd_soc_component*component,return ret;}
+static int
hdmi_probe(struct snd_soc_component *component)+{
+ structhdmi_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);Quoted 8 lines
@@ -992,6 +1002,7 @@ static void
hdmi_remove(struct snd_soc_component *component)
}static const struct
snd_soc_component_driverhdmi_driver= {+ .probe = hdmi_probe, .remove = hdmi_remove, .dapm_widgets = hdmi_widgets, .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets),--
Jerome
Quoted 69 lines · Hsin-Yi Wang
Quoted 41 lines · Jerome Brunet
Quoted 8 lines · Zhengqiao Xia
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 theplugged_cbto run inhdmi_probe, at this time hcp- > jack = NULL, the driver cannot reportSND_JACK_LINEOUTnormally.
static void hdmi_codec_jack_report(structhdmi_codec_priv*hcp,
unsigned intjack_status)Quoted 8 lines
{ 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_cbinhdmi_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.
Quoted 6 lines
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. registerplugged_cb
2. callplugged_cb(bool plugged)bridge detect callback
it6505_detectwould also callplugged_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, theplugged_cb()was called bybridge_detect, which is expected.
Quoted 5 lines
Prior to this patch, the initial
plugged_cb()was called byhook_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 callplugged_cb()again when jack is set.
This is what thought
Quoted 4 lines
I checked the dw-hdmi.c's
bridge_detect, and it's similar in that it also checks thelast_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 ?
Quoted 78 lines
Quoted 78 lines
Quoted 66 lines · Jerome Brunet
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 <[email protected]>---
sound/soc/codecs/hdmi-codec.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)diff --git
a/sound/soc/codecs/hdmi-codec.cb/sound/soc/codecs/hdmi-codec.cindex09eef6042aad..20da1eaa4f1c100644
---a/sound/soc/codecs/hdmi-codec.c
+++b/sound/soc/codecs/hdmi-codec.c
@@ -877,18 +877,13 @@ static int hdmi_codec_set_jack(structsnd_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(structsnd_soc_component*component,return ret;}
+static int
hdmi_probe(struct snd_soc_component *component)+{
+ structhdmi_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);Quoted 8 lines
@@ -992,6 +1002,7 @@ static void
hdmi_remove(struct snd_soc_component *component)
}static const struct
snd_soc_component_driverhdmi_driver= {+ .probe = hdmi_probe, .remove = hdmi_remove, .dapm_widgets = hdmi_widgets, .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets),--
Jerome
Signature · 1 line
Jerome
Quoted 100 lines · Jerome Brunet
Quoted 1 line · Hsin-Yi Wang
On Fri, Dec 15, 2023 at 12:40 AM Jerome Brunet <[email protected]>
Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 3 lines · Zhengqiao Xia
Hi Jerome,
After my testing, I found that this patch will cause the audio on the
external display to not work properly after
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
restart.
You move theplugged_cbto run inhdmi_probe, at this time hcp- >jack = NULL, the driver cannot report `SND_JACK_LINEOUT
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
` normally.
static void hdmi_codec_jack_report(structhdmi_codec_priv*hcp,
unsigned intjack_status){ printk("xzq-866 hdmi_codec_jack_report: jack=%x,jack_status=%d",
hcp->jack,jack_status!=hcp->jack_status);Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
if (hcp->jack && jack_status != hcp->jack_status) { snd_soc_jack_report(hcp->jack, jack_status,
SND_JACK_LINEOUT);Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
hcp->jack_status = jack_status; } }So we must call
plugged_cbinhdmi_codec_set_jack, Can you makesome changes?
Quoted 16 lines
Quoted 16 lines
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 ?Quoted 8 lines
Quoted 8 lines
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
Quoted 16 lines
Quoted 2 lines
the hdmi jack register, but there are not many of these AFAIK.
The driver is it6505. The implementation of
hook_plugged_cb():
1. registerplugged_cb
2. callplugged_cb(bool plugged)bridge detect callback
it6505_detectwould also callplugged_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_cbQuoted 8 lines
}
}Unfortunately the first time after boot that hpd status changed was detected before
set_jack. If we replug hdmi, theplugged_cb()was called bybridge_detect, which is expected.Prior to this patch, the initial
plugged_cb()was called by
hook_plugged_cb().Quoted 4 lines
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 callplugged_cb()again when jack is set.This is what thought
Quoted 4 lines
I checked the dw-hdmi.c's
bridge_detect, and it's similar in that it also checks thelast_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.
Quoted 5 lines
I've only seen 2 cards doing that at the moment:
*imx-hdmi.c
*mt8188-mt6359.cCould you point me to yours ?
it is mt8186-mt6366-rt1019-rt5682s.c :
https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/third_party/kernel/v5.15/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c
Quoted 99 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
On Mon, Nov 6, 2023 at 6:40 PM Jerome Brunet <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
The HDMI hotplug callback to the hdmi-codec is currently registered
when
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
jack is set.
The hotplug not only serves to report the ASoC jack state but also
to get
Quoted 1 line
Quoted 1 line
Quoted 1 line
the ELD. It should be registered when the component probes instead,
so it
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
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 reportingplugged event")
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signed-off-by Jerome Brunet <[email protected]>---
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.cQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
index
09eef6042aad..20da1eaa4f1c100644
---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,Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
void *data)
{
structhdmi_codec_priv*hcp =
snd_soc_component_get_drvdata(component);Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
- int ret =
-ENOTSUPP;if (hcp->hcd.ops->hook_plugged_cb) { hcp->jack = jack;- ret =
hcp->hcd.ops->hook_plugged_cb(component->dev->parent,
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
- hcp->hcd.data, - plugged_cb, - component->dev); - if (ret) - hcp->jack = NULL; + return 0; }- return ret;
+
+ return-ENOTSUPP;
}Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
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,Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
return ret;}
+static int
hdmi_probe(struct snd_soc_component *component)+{
+ structhdmi_codec_priv*hcp =
snd_soc_component_get_drvdata(component);Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
+ int ret = 0;
+
+ if (hcp->hcd.ops->hook_plugged_cb) {
+ ret =hcp->hcd.ops->hook_plugged_cb(component->dev->parent,
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
+ hcp->hcd.data, + plugged_cb, + component->dev);+ }
+
+ return ret;
+}
+
static voidhdmi_remove(struct snd_soc_component *component){
structhdmi_codec_priv*hcp =
snd_soc_component_get_drvdata(component);Quoted 1 line
Quoted 1 line
Quoted 1 line
@@ -992,6 +1002,7 @@ static void hdmi_remove(struct
snd_soc_component*component)Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
}static const struct
snd_soc_component_driverhdmi_driver= {+ .probe = hdmi_probe, .remove = hdmi_remove, .dapm_widgets = hdmi_widgets, .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets),--
Jerome--
Jerome