Add HDMI jack support on RK3288
Subsystems (6)
v4 cover Add HDMI jack support on RK3288
This patch series supports HDMI jack reporting on RK3288, which uses DRM dw-hdmi driver and hdmi-codec codec driver.
The previous discussion about reporting jack status using hdmi-notifier and drm_audio_component is at
https://lore.kernel.org/patchwork/patch/1083027/
The new approach is to use a callback mechanism that is specific to hdmi-codec.
Changes from v3 to v4:
- hdmi-codec.h: Modify the hook_plugged_cb ops to take an additional argument, that is, the pointer to struct device for codec device.
- dw-hdmi-i2s-audio.c: Simplify the registration of callback so it uses dw_hdmi_set_plugged_cb exported by dw-hdmi.c.
- dw-hdmi.c: Simplify the flow to invoke callback since now dw_hdmi has a pointer to codec device as callback argument. There is no need to rely on driver data of other driver.
- dw-hdmi.c: Minor change for readability.
- synopsys/Kconfig: Fix the dependency of hdmi-codec in Kconfig.
- Fixed the incorrect FROMLIST title of patch 5/5.
Cheng-Yi Chiang (5):
ASoC: hdmi-codec: Add an op to set callback function for plug event
drm: bridge: dw-hdmi: Report connector status using callback
drm: dw-hdmi-i2s: Use fixed id for codec device
ASoC: rockchip_max98090: Add dai_link for HDMI
ASoC: rockchip_max98090: Add HDMI jack support
drivers/gpu/drm/bridge/synopsys/Kconfig | 2 +- .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 13 +- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 41 ++++++- include/drm/bridge/dw_hdmi.h | 4 + include/sound/hdmi-codec.h | 17 +++ sound/soc/codecs/hdmi-codec.c | 46 +++++++ sound/soc/rockchip/Kconfig | 3 +- sound/soc/rockchip/rk3288_hdmi_analog.c | 3 +- sound/soc/rockchip/rockchip_max98090.c | 116 ++++++++++++++---- 9 files changed, 217 insertions(+), 28 deletions(-)
Signature · 1 line
2.22.0.510.g264f2c817a-goog
PATCH v4 1/5 ASoC: hdmi-codec: Add an op to set callback function for plug event
Add an op in hdmi_codec_ops so codec driver can register callback function to handle plug event.
Driver in DRM can use this callback function to report connector status.
--- include/sound/hdmi-codec.h | 17 +++++++++++++ sound/soc/codecs/hdmi-codec.c | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
include/sound/hdmi-codec.h +17 -0
@@ -47,6 +47,9 @@ struct hdmi_codec_params {int channels; }; +typedef void (*hdmi_codec_plugged_cb )(struct device *dev, +bool plugged); +struct hdmi_codec_pdata ;struct hdmi_codec_ops {/*
@@ -88,6 +91,14 @@ struct hdmi_codec_ops {*/ int (*get_dai_id)(struct snd_soc_component *comment,struct device_node *endpoint); + +/* +* Hook callback function to handle connector plug event. +* Optional +*/ +int (*hook_plugged_cb)(struct device *dev,void *data, +hdmi_codec_plugged_cb fn, +struct device *codec_dev); };/* HDMI codec initalization data */
@@ -99,6 +110,12 @@ struct hdmi_codec_pdata { void *data; }; +struct snd_soc_component ; +struct snd_soc_jack ; + +int hdmi_codec_set_jack_detect (struct snd_soc_component *component, +struct snd_soc_jack *jack); +#define HDMI_CODEC_DRV_NAME "hdmi-audio-codec"#endif /* __HDMI_CODEC_H__ */
sound/soc/codecs/hdmi-codec.c +46 -0
64 lines not on this page · raw message
Signature · 1 line
2.22.0.510.g264f2c817a-goog
PATCH v4 2/5 drm: bridge: dw-hdmi: Report connector status using callback
In reply to Cheng-Yi ChiangAllow codec driver register callback function for plug event.
The callback registration flow:
dw-hdmi <--- hw-hdmi-i2s-audio <--- hdmi-codec
dw-hdmi-i2s-audio implements hook_plugged_cb op
so codec driver can register the callback.
dw-hdmi exports a function dw_hdmi_set_plugged_cb so platform device can register the callback.
When connector plug/unplug event happens, report this event using the callback.
Make sure that audio and drm are using the single source of truth for connector status.
Change the Kconfig of DRM_DW_HDMI so it selects SND_SOC_HDMI_CODEC. This is for the typedef of hdmi_codec_plugged_cb to be used in dw-hdmi.c.
--- drivers/gpu/drm/bridge/synopsys/Kconfig | 2 +- .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 11 +++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 41 ++++++++++++++++++- include/drm/bridge/dw_hdmi.h | 4 ++ 4 files changed, 56 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/Kconfig +1 -1
@@ -4,6 +4,7 @@ config DRM_DW_HDMI select DRM_KMS_HELPER select REGMAP_MMIO select CEC_CORE if CEC_NOTIFIER + select SND_SOC_HDMI_CODEC config DRM_DW_HDMI_AHB_AUDIO tristate "Synopsys Designware AHB Audio interface"
@@ -20,7 +21,6 @@ config DRM_DW_HDMI_I2S_AUDIO tristate "Synopsys Designware I2S Audio interface" depends on SND_SOC depends on DRM_DW_HDMI - select SND_SOC_HDMI_CODEC help Support the I2S Audio interface which is part of the Synopsys Designware HDMI block.
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +11 -0
@@ -104,10 +104,21 @@ static int dw_hdmi_i2s_get_dai_id(struct snd_soc_component *component,return -EINVAL ; } +static int dw_hdmi_i2s_hook_plugged_cb (struct device *dev,void *data, +hdmi_codec_plugged_cb fn, +struct device *codec_dev) +{ +struct dw_hdmi_i2s_audio_data *audio = data; +struct dw_hdmi *hdmi = audio->hdmi; + +return dw_hdmi_set_plugged_cb (hdmi, fn, codec_dev); +} +static struct hdmi_codec_ops dw_hdmi_i2s_ops = { .hw_params = dw_hdmi_i2s_hw_params, .audio_shutdown = dw_hdmi_i2s_audio_shutdown, .get_dai_id = dw_hdmi_i2s_get_dai_id, + .hook_plugged_cb = dw_hdmi_i2s_hook_plugged_cb, };static int snd_dw_hdmi_probe (struct platform_device *pdev)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +40 -1
71 lines not on this page · raw message
include/drm/bridge/dw_hdmi.h +4 -0
@@ -6,6 +6,8 @@#ifndef __DW_HDMI__#define __DW_HDMI__ +#include <sound/hdmi-codec.h> +struct drm_connector ;struct drm_display_mode ;struct drm_encoder ;
@@ -152,6 +154,8 @@ struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev,void dw_hdmi_setup_rx_sense (struct dw_hdmi *hdmi,bool hpd,bool rx_sense); +int dw_hdmi_set_plugged_cb (struct dw_hdmi *hdmi,hdmi_codec_plugged_cb fn, +struct device *codec_dev);void dw_hdmi_set_sample_rate (struct dw_hdmi *hdmi,unsigned int rate);void dw_hdmi_audio_enable (struct dw_hdmi *hdmi);void dw_hdmi_audio_disable (struct dw_hdmi *hdmi);
Signature · 1 line
2.22.0.510.g264f2c817a-goog
Re: [PATCH v4 2/5] drm: bridge: dw-hdmi: Report connector status using callback
Quoted 3 lines · Cheng-Yi Chiang
Change the
KconfigofDRM_DW_HDMIso it selectsSND_SOC_HDMI_CODEC. This is for the typedef ofhdmi_codec_plugged_cbto be used indw-hdmi.c.
Not sure why you select SND_SOC_HDMI_CODEC in this patch. To have definition of hdmi_codec_plugged_cb, include hdmi-codec.h should be sufficient.
drivers/gpu/drm/bridge/synopsys/Kconfig config DRM_DW_HDMI · line 7
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/Kconfig +1
-0@@ -4,6 +4,7 @@ config DRM_DW_HDMI select DRM_KMS_HELPER select REGMAP_MMIO select CEC_CORE if CEC_NOTIFIER + select SND_SOC_HDMI_CODEC
So that it is weird to select this option.
drivers/gpu/drm/bridge/synopsys/Kconfig config DRM_DW_HDMI_I2S_AUDIO · line 23
Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/Kconfig +0
-1config DRM_DW_HDMI_AHB_AUDIO tristate "Synopsys Designware AHB Audio interface"@@ -20,7 +21,6 @@ config DRM_DW_HDMI_I2S_AUDIO tristate "Synopsys Designware I2S Audio interface" depends on SND_SOC depends on DRM_DW_HDMI - select SND_SOC_HDMI_CODEC
Also strange for deselecting the option. Should be in another commit for another reason?
Re: [PATCH v4 2/5] drm: bridge: dw-hdmi: Report connector status using callback
Quoted 9 lines · Tzung-Bi Shih
Quoted 3 lines · Cheng-Yi Chiang
Change the
KconfigofDRM_DW_HDMIso it selectsSND_SOC_HDMI_CODEC. This is for the typedef ofhdmi_codec_plugged_cbto be used indw-hdmi.c.Not sure why you select
SND_SOC_HDMI_CODECin this patch. To have definition ofhdmi_codec_plugged_cb, includehdmi-codec.hshould be sufficient.
Thank you for the review!
I misunderstood when to change Kconfig.
Will fix in v5.
Quoted 12 lines
drivers/gpu/drm/bridge/synopsys/Kconfig config DRM_DW_HDMI · line 7
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/Kconfig +1
-0@@ -4,6 +4,7 @@ config DRM_DW_HDMI select DRM_KMS_HELPER select REGMAP_MMIO select CEC_CORE if CEC_NOTIFIER + select SND_SOC_HDMI_CODECSo that it is weird to select this option.
Will be removed in v5.
Thanks!
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/Kconfig config DRM_DW_HDMI_I2S_AUDIO · line 23
Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/Kconfig +0
-1config DRM_DW_HDMI_AHB_AUDIO tristate "Synopsys Designware AHB Audio interface"@@ -20,7 +21,6 @@ config DRM_DW_HDMI_I2S_AUDIO tristate "Synopsys Designware I2S Audio interface" depends on SND_SOC depends on DRM_DW_HDMI - select SND_SOC_HDMI_CODECAlso strange for deselecting the option. Should be in another commit for another reason?
Will be removed in v5.
Thanks!
PATCH v4 3/5 drm: dw-hdmi-i2s: Use fixed id for codec device
In reply to Cheng-Yi ChiangThe problem of using auto ID is that the device name will be like hdmi-audio-codec.<id number>.auto.
The number might be changed when there are other platform devices being created before hdmi-audio-codec device.
Use a fixed name so machine driver can set codec name on the DAI link.
Using the fixed name should be fine because there will only be one hdmi-audio-codec device.
Fix the codec name in rockchip rk3288_hdmi_analog machine driver.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 2 +- sound/soc/rockchip/rk3288_hdmi_analog.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +1 -1
@@ -135,7 +135,7 @@ static int snd_dw_hdmi_probe(struct platform_device *pdev)memset (&pdevinfo,0 ,sizeof (pdevinfo)); pdevinfo.parent = pdev->dev.parent; - pdevinfo.id =PLATFORM_DEVID_AUTO ; + pdevinfo.id =PLATFORM_DEVID_NONE ; pdevinfo.name =HDMI_CODEC_DRV_NAME ; pdevinfo.data = &pdata; pdevinfo.size_data =sizeof (pdata);
sound/soc/rockchip/rk3288_hdmi_analog.c +2 -1
@@ -15,6 +15,7 @@#include <linux/gpio.h> #include <linux/of_gpio.h> #include <sound/core.h> +#include <sound/hdmi-codec.h> #include <sound/jack.h> #include <sound/pcm.h> #include <sound/pcm_params.h>
@@ -142,7 +143,7 @@ static const struct snd_soc_ops rk_ops = {SND_SOC_DAILINK_DEFS (audio,DAILINK_COMP_ARRAY (COMP_EMPTY ()),DAILINK_COMP_ARRAY (COMP_CODEC (NULL ,NULL ), -COMP_CODEC ("hdmi-audio-codec.2.auto" ,"i2s-hifi" )), +COMP_CODEC (HDMI_CODEC_DRV_NAME ,"i2s-hifi" )),DAILINK_COMP_ARRAY (COMP_EMPTY ()));static struct snd_soc_dai_link rk_dailink = {
Signature · 1 line
2.22.0.510.g264f2c817a-goog
PATCH v4 4/5 ASoC: rockchip_max98090: Add dai_link for HDMI
In reply to Cheng-Yi ChiangUse two dai_links. One for HDMI and one for max98090. With this setup, audio can play to speaker and HDMI selectively.
--- sound/soc/rockchip/Kconfig | 3 +- sound/soc/rockchip/rockchip_max98090.c | 96 ++++++++++++++++++++------ 2 files changed, 75 insertions(+), 24 deletions(-)
sound/soc/rockchip/Kconfig +2 -1
@@ -40,9 +40,10 @@ config SND_SOC_ROCKCHIP_MAX98090 select SND_SOC_ROCKCHIP_I2S select SND_SOC_MAX98090 select SND_SOC_TS3A227E + select SND_SOC_HDMI_CODEC help Say Y or M here if you want to add support for SoC audio on Rockchip - boards using the MAX98090 codec, such as Veyron. + boards using the MAX98090 codec and HDMI codec, such as Veyron. config SND_SOC_ROCKCHIP_RT5645 tristate "ASoC support for Rockchip boards using a RT5645/RT5650 codec"
sound/soc/rockchip/rockchip_max98090.c +73 -23
170 lines not on this page · raw message
Signature · 1 line
2.22.0.510.g264f2c817a-goog
Re: [PATCH v4 4/5] ASoC: rockchip_max98090: Add dai_link for HDMI
Quoted 6 lines · Cheng-Yi Chiang
sound/soc/rockchip/Kconfig +0
-0
sound/soc/rockchip/Kconfig config SND_SOC_ROCKCHIP_MAX98090 · line 46
Quoted 8 lines
sound/soc/rockchip/Kconfig +2
-1@@ -40,9 +40,10 @@ config SND_SOC_ROCKCHIP_MAX98090 select SND_SOC_ROCKCHIP_I2S select SND_SOC_MAX98090 select SND_SOC_TS3A227E + select SND_SOC_HDMI_CODEC help Say Y or M here if you want to add support for SoC audio on Rockchip - boards using the MAX98090 codec, such as Veyron. + boards using the MAX98090 codec and HDMI codec, such as Veyron.
You should not need to select the option in this patch (but in next patch), because this patch does not depend on anything from hdmi-codec.c.
Re: [PATCH v4 4/5] ASoC: rockchip_max98090: Add dai_link for HDMI
Quoted 19 lines · Tzung-Bi Shih
Quoted 6 lines · Cheng-Yi Chiang
sound/soc/rockchip/Kconfig +0
-0sound/soc/rockchip/Kconfig config SND_SOC_ROCKCHIP_MAX98090 · line 46
Quoted 8 lines
sound/soc/rockchip/Kconfig +2
-1@@ -40,9 +40,10 @@ config SND_SOC_ROCKCHIP_MAX98090 select SND_SOC_ROCKCHIP_I2S select SND_SOC_MAX98090 select SND_SOC_TS3A227E + select SND_SOC_HDMI_CODEC help Say Y or M here if you want to add support for SoC audio on Rockchip - boards using the MAX98090 codec, such as Veyron. + boards using the MAX98090 codec and HDMI codec, such as Veyron.You should not need to select the option in this patch (but in next patch), because this patch does not depend on anything from
hdmi-codec.c.
Thanks for the explanation.
I'll fix in v5.
PATCH v4 5/5 ASoC: rockchip_max98090: Add HDMI jack support
In reply to Cheng-Yi ChiangIn machine driver, create a jack and let hdmi-codec report jack status.
--- sound/soc/rockchip/rockchip_max98090.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
sound/soc/rockchip/rockchip_max98090.c +20 -0
@@ -134,6 +134,25 @@ enum { DAILINK_HDMI, }; +static struct snd_soc_jack rk_hdmi_jack; + +static int rk_hdmi_init (struct snd_soc_pcm_runtime *runtime) +{ +struct snd_soc_card *card = runtime->card; +struct snd_soc_component *component = runtime->codec_dai->component; +int ret; + +/* enable jack detection */ + ret =snd_soc_card_jack_new (card,"HDMI Jack" ,SND_JACK_LINEOUT , + &rk_hdmi_jack,NULL ,0 ); +if (ret) { +dev_err (card->dev,"Can't new HDMI Jack %d\n" , ret); +return ret; + } + +return hdmi_codec_set_jack_detect (component, &rk_hdmi_jack); +} +/* max98090 and HDMI codec dai_link */ static struct snd_soc_dai_link rk_dailinks[] = { [DAILINK_MAX98090 ] = {
@@ -151,6 +170,7 @@ static struct snd_soc_dai_link rk_dailinks[] = { .ops = &rk_aif1_ops, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, + .init = rk_hdmi_init, SND_SOC_DAILINK_REG(hdmi), } };
Signature · 1 line
2.22.0.510.g264f2c817a-goog
Re: [PATCH v4 5/5] ASoC: rockchip_max98090: Add HDMI jack support
Quoted 13 lines · Cheng-Yi Chiang
sound/soc/rockchip/rockchip_max98090.c +8
-0+static struct snd_soc_jack rk_hdmi_jack; + +static int rk_hdmi_init (struct snd_soc_pcm_runtime *runtime) +{ +struct snd_soc_card *card = runtime->card; +struct snd_soc_component *component = runtime->codec_dai->component; +int ret; +
sound/soc/rockchip/rockchip_max98090.c enum { · line 154
Quoted 10 lines
sound/soc/rockchip/rockchip_max98090.c +10
-0+/* enable jack detection */ + ret =snd_soc_card_jack_new (card,"HDMI Jack" ,SND_JACK_LINEOUT , + &rk_hdmi_jack,NULL ,0 ); +if (ret) { +dev_err (card->dev,"Can't new HDMI Jack %d\n" , ret); +return ret; + } + +return hdmi_codec_set_jack_detect (component, &rk_hdmi_jack); +}
In the patch, you should select SND_SOC_HDMI_CODEC, because the patch uses hdmi_codec_set_jack_detect which depends on hdmi-codec.c.
Re: [PATCH v4 5/5] ASoC: rockchip_max98090: Add HDMI jack support
Quoted 19 lines · Tzung-Bi Shih
Quoted 17 lines · Cheng-Yi Chiang
sound/soc/rockchip/rockchip_max98090.c +12
-0+static struct snd_soc_jack rk_hdmi_jack; + +static int rk_hdmi_init (struct snd_soc_pcm_runtime *runtime) +{ +struct snd_soc_card *card = runtime->card; +struct snd_soc_component *component = runtime->codec_dai->component; +int ret; + +/* enable jack detection */ + ret =snd_soc_card_jack_new (card,"HDMI Jack" ,SND_JACK_LINEOUT , + &rk_hdmi_jack,NULL ,0 ); +if (ret) {
Quoted 8 lines
sound/soc/rockchip/rockchip_max98090.c enum { · line 154
Quoted 6 lines
sound/soc/rockchip/rockchip_max98090.c +6
-0+dev_err (card->dev,"Can't new HDMI Jack %d\n" , ret); +return ret; + } + +return hdmi_codec_set_jack_detect (component, &rk_hdmi_jack); +}In the patch, you should select
SND_SOC_HDMI_CODEC, because the patch useshdmi_codec_set_jack_detectwhich depends onhdmi-codec.c.
Thanks! I'll fix in v5.