diff --git a/include/sound/simple_card.h b/include/sound/simple_card.h index 0399352f3a62..69c66991eb1e 100644 --- a/include/sound/simple_card.h +++ b/include/sound/simple_card.h @@ -35,4 +35,6 @@ struct asoc_simple_card_info { struct asoc_simple_dai codec_dai; }; +struct snd_soc_jack *asoc_simple_card_get_hp_jack(void); + #endif /* __SIMPLE_CARD_H */ diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index ce55ed74c619..974bfaa3f271 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -33,6 +33,7 @@ struct simple_card_data { int gpio_hp_det_invert; int gpio_mic_det; int gpio_mic_det_invert; + bool codec_hp_det; struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ }; @@ -137,6 +138,12 @@ static struct snd_soc_jack_gpio simple_card_mic_jack_gpio = { .debounce_time = 150, }; +struct snd_soc_jack *asoc_simple_card_get_hp_jack(void) +{ + return &simple_card_hp_jack; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_get_hp_jack); + static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, struct asoc_simple_dai *set) { @@ -210,6 +217,14 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) snd_soc_jack_add_gpios(&simple_card_mic_jack, 1, &simple_card_mic_jack_gpio); } + + if (priv->codec_hp_det) + snd_soc_card_jack_new(rtd->card, "Headphones", + SND_JACK_HEADPHONE, + &simple_card_hp_jack, + simple_card_hp_jack_pins, + ARRAY_SIZE(simple_card_hp_jack_pins)); + return 0; } @@ -514,6 +529,9 @@ static int asoc_simple_card_parse_of(struct device_node *node, if (priv->gpio_mic_det == -EPROBE_DEFER) return -EPROBE_DEFER; + priv->codec_hp_det = of_property_read_bool(node, + "simple-audio-card,codec-hp-det"); + if (!priv->snd_card.name) priv->snd_card.name = priv->snd_card.dai_link->name; @@ -566,6 +584,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev) priv->gpio_hp_det = -ENOENT; priv->gpio_mic_det = -ENOENT; + priv->codec_hp_det = false; + /* Get room for the other properties */ priv->dai_props = devm_kzalloc(dev, sizeof(*priv->dai_props) * num_links,