diff mbox series

[2/5] ASoC: mediatek: mt8188-mt6359: register hdmi/dp jack pins

Message ID 20230517111534.32630-3-trevor.wu@mediatek.com (mailing list archive)
State New, archived
Headers show
Series ASoC: mt8188: add new board support | expand

Commit Message

Trevor Wu (吳文良) May 17, 2023, 11:15 a.m. UTC
Some userspace applications need jack control events, so register hdmi
and dp jack pins to activate jack control events.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
---
 sound/soc/mediatek/mt8188/mt8188-mt6359.c | 27 +++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

Comments

AngeloGioacchino Del Regno May 17, 2023, 11:31 a.m. UTC | #1
Il 17/05/23 13:15, Trevor Wu ha scritto:
> Some userspace applications need jack control events, so register hdmi
> and dp jack pins to activate jack control events.
> 
> Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
> ---
>   sound/soc/mediatek/mt8188/mt8188-mt6359.c | 27 +++++++++++++++++++----
>   1 file changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> index 833bc362dad2..6c3f36e2fffd 100644
> --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> @@ -151,6 +151,20 @@ struct mt8188_mt6359_priv {
>   	struct snd_soc_jack hdmi_jack;
>   };
>   
> +static struct snd_soc_jack_pin mt8188_hdmi_jack_pins[] = {
> +	{
> +		.pin = "HDMI",

"HDMI Jack" is more consistent with the snd_soc_jack_new_pins() call performed
later.

> +		.mask = SND_JACK_LINEOUT,
> +	},
> +};
> +
> +static struct snd_soc_jack_pin mt8188_dp_jack_pins[] = {
> +	{
> +		.pin = "DP",

Same here: "DP Jack"

> +		.mask = SND_JACK_LINEOUT,
> +	},
> +};
> +

Regards,
Angelo
Trevor Wu (吳文良) May 17, 2023, 12:10 p.m. UTC | #2
On Wed, 2023-05-17 at 13:31 +0200, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Il 17/05/23 13:15, Trevor Wu ha scritto:
> > Some userspace applications need jack control events, so register
> > hdmi
> > and dp jack pins to activate jack control events.
> > 
> > Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
> > ---
> >   sound/soc/mediatek/mt8188/mt8188-mt6359.c | 27
> > +++++++++++++++++++----
> >   1 file changed, 23 insertions(+), 4 deletions(-)
> > 
> > diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> > b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> > index 833bc362dad2..6c3f36e2fffd 100644
> > --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> > +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> > @@ -151,6 +151,20 @@ struct mt8188_mt6359_priv {
> >       struct snd_soc_jack hdmi_jack;
> >   };
> > 
> > +static struct snd_soc_jack_pin mt8188_hdmi_jack_pins[] = {
> > +     {
> > +             .pin = "HDMI",
> 
> "HDMI Jack" is more consistent with the snd_soc_jack_new_pins() call
> performed
> later.

Hi Angelo,

I see jack_kctl_name_gen() will append "Jack" to the name if I don't
name the pin "HDMI Jack". Do you mean that I could directly use "HDMI
Jack" because ALSA uses the name finally?

Thanks,
Trevor

> 
> > +             .mask = SND_JACK_LINEOUT,
> > +     },
> > +};
> > +
> > +static struct snd_soc_jack_pin mt8188_dp_jack_pins[] = {
> > +     {
> > +             .pin = "DP",
> 
> Same here: "DP Jack"
> 
> > +             .mask = SND_JACK_LINEOUT,
> > +     },
> > +};
> > +
> 
> Regards,
> Angelo
>
AngeloGioacchino Del Regno May 17, 2023, 3:10 p.m. UTC | #3
Il 17/05/23 14:10, Trevor Wu (吳文良) ha scritto:
> On Wed, 2023-05-17 at 13:31 +0200, AngeloGioacchino Del Regno wrote:
>> External email : Please do not click links or open attachments until
>> you have verified the sender or the content.
>>
>>
>> Il 17/05/23 13:15, Trevor Wu ha scritto:
>>> Some userspace applications need jack control events, so register
>>> hdmi
>>> and dp jack pins to activate jack control events.
>>>
>>> Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
>>> ---
>>>    sound/soc/mediatek/mt8188/mt8188-mt6359.c | 27
>>> +++++++++++++++++++----
>>>    1 file changed, 23 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
>>> b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
>>> index 833bc362dad2..6c3f36e2fffd 100644
>>> --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
>>> +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
>>> @@ -151,6 +151,20 @@ struct mt8188_mt6359_priv {
>>>        struct snd_soc_jack hdmi_jack;
>>>    };
>>>
>>> +static struct snd_soc_jack_pin mt8188_hdmi_jack_pins[] = {
>>> +     {
>>> +             .pin = "HDMI",
>>
>> "HDMI Jack" is more consistent with the snd_soc_jack_new_pins() call
>> performed
>> later.
> 
> Hi Angelo,
> 
> I see jack_kctl_name_gen() will append "Jack" to the name if I don't
> name the pin "HDMI Jack". Do you mean that I could directly use "HDMI
> Jack" because ALSA uses the name finally?
> 

You're right and I just checked; the comment even says
'remove redundant " Jack" from src_name'

So yes, the current names are fine. Sorry about that.

Regards,
Angelo
Trevor Wu (吳文良) May 18, 2023, 2:01 a.m. UTC | #4
On Wed, 2023-05-17 at 17:10 +0200, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Il 17/05/23 14:10, Trevor Wu (吳文良) ha scritto:
> > On Wed, 2023-05-17 at 13:31 +0200, AngeloGioacchino Del Regno
> > wrote:
> > > External email : Please do not click links or open attachments
> > > until
> > > you have verified the sender or the content.
> > > 
> > > 
> > > Il 17/05/23 13:15, Trevor Wu ha scritto:
> > > > Some userspace applications need jack control events, so
> > > > register
> > > > hdmi
> > > > and dp jack pins to activate jack control events.
> > > > 
> > > > Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
> > > > ---
> > > >    sound/soc/mediatek/mt8188/mt8188-mt6359.c | 27
> > > > +++++++++++++++++++----
> > > >    1 file changed, 23 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> > > > b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> > > > index 833bc362dad2..6c3f36e2fffd 100644
> > > > --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> > > > +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> > > > @@ -151,6 +151,20 @@ struct mt8188_mt6359_priv {
> > > >        struct snd_soc_jack hdmi_jack;
> > > >    };
> > > > 
> > > > +static struct snd_soc_jack_pin mt8188_hdmi_jack_pins[] = {
> > > > +     {
> > > > +             .pin = "HDMI",
> > > 
> > > "HDMI Jack" is more consistent with the snd_soc_jack_new_pins()
> > > call
> > > performed
> > > later.
> > 
> > Hi Angelo,
> > 
> > I see jack_kctl_name_gen() will append "Jack" to the name if I
> > don't
> > name the pin "HDMI Jack". Do you mean that I could directly use
> > "HDMI
> > Jack" because ALSA uses the name finally?
> > 
> 
> You're right and I just checked; the comment even says
> 'remove redundant " Jack" from src_name'
> 
> So yes, the current names are fine. Sorry about that.
> 
> Regards,
> Angelo

I checked the original commit[1] for the function. The purpose of
jack_kctl_name_gen() is to ensure only one "Jack" shown in kctrl_name.
If "Jack" is already found in src_name, don't append "Jack" again.

I'm not sure which is better for pin name, but it's certain they get
the same kctrl_name finally.

[1] 
https://lore.kernel.org/all/1430140862-17207-3-git-send-email-yang.jie@intel.com


Thanks,
Trevor
diff mbox series

Patch

diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
index 833bc362dad2..6c3f36e2fffd 100644
--- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
+++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
@@ -151,6 +151,20 @@  struct mt8188_mt6359_priv {
 	struct snd_soc_jack hdmi_jack;
 };
 
+static struct snd_soc_jack_pin mt8188_hdmi_jack_pins[] = {
+	{
+		.pin = "HDMI",
+		.mask = SND_JACK_LINEOUT,
+	},
+};
+
+static struct snd_soc_jack_pin mt8188_dp_jack_pins[] = {
+	{
+		.pin = "DP",
+		.mask = SND_JACK_LINEOUT,
+	},
+};
+
 struct mt8188_card_data {
 	const char *name;
 	unsigned long quirk;
@@ -159,6 +173,8 @@  struct mt8188_card_data {
 static const struct snd_soc_dapm_widget mt8188_mt6359_widgets[] = {
 	SND_SOC_DAPM_HP("Headphone", NULL),
 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
+	SND_SOC_DAPM_SINK("HDMI"),
+	SND_SOC_DAPM_SINK("DP"),
 };
 
 static const struct snd_kcontrol_new mt8188_mt6359_controls[] = {
@@ -396,8 +412,10 @@  static int mt8188_hdmi_codec_init(struct snd_soc_pcm_runtime *rtd)
 	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
 	int ret = 0;
 
-	ret = snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT,
-				    &priv->hdmi_jack);
+	ret = snd_soc_card_jack_new_pins(rtd->card, "HDMI Jack",
+					 SND_JACK_LINEOUT, &priv->hdmi_jack,
+					 mt8188_hdmi_jack_pins,
+					 ARRAY_SIZE(mt8188_hdmi_jack_pins));
 	if (ret) {
 		dev_info(rtd->dev, "%s, new jack failed: %d\n", __func__, ret);
 		return ret;
@@ -417,8 +435,9 @@  static int mt8188_dptx_codec_init(struct snd_soc_pcm_runtime *rtd)
 	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
 	int ret = 0;
 
-	ret = snd_soc_card_jack_new(rtd->card, "DP Jack", SND_JACK_LINEOUT,
-				    &priv->dp_jack);
+	ret = snd_soc_card_jack_new_pins(rtd->card, "DP Jack", SND_JACK_LINEOUT,
+					 &priv->dp_jack, mt8188_dp_jack_pins,
+					 ARRAY_SIZE(mt8188_dp_jack_pins));
 	if (ret) {
 		dev_info(rtd->dev, "%s, new jack failed: %d\n", __func__, ret);
 		return ret;