Skip to content

Commit 8fcec45

Browse files
committed
HACK-TO-REVERT: ASoC: simple-card: add support hp/mic detect for internal codec
This is a local patch, because our simple-card is too backward from upstream. This will take more time on the cherry-pick patch and verification. In order to speed up the progress, I put this local patch and please revert it after I merge the new patches of simple-card. Change-Id: If566cf66c69d3a4fccbffc423433e6b724a23c04 Signed-off-by: Xing Zheng <zhengxing@rock-chips.com>
1 parent 6530305 commit 8fcec45

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

include/sound/simple_card.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ struct asoc_simple_card_info {
3535
struct asoc_simple_dai codec_dai;
3636
};
3737

38+
struct snd_soc_jack *asoc_simple_card_get_hp_jack(void);
39+
3840
#endif /* __SIMPLE_CARD_H */

sound/soc/generic/simple-card.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct simple_card_data {
3333
int gpio_hp_det_invert;
3434
int gpio_mic_det;
3535
int gpio_mic_det_invert;
36+
bool codec_hp_det;
3637
struct snd_soc_dai_link dai_link[]; /* dynamically allocated */
3738
};
3839

@@ -137,6 +138,12 @@ static struct snd_soc_jack_gpio simple_card_mic_jack_gpio = {
137138
.debounce_time = 150,
138139
};
139140

141+
struct snd_soc_jack *asoc_simple_card_get_hp_jack(void)
142+
{
143+
return &simple_card_hp_jack;
144+
}
145+
EXPORT_SYMBOL_GPL(asoc_simple_card_get_hp_jack);
146+
140147
static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
141148
struct asoc_simple_dai *set)
142149
{
@@ -210,6 +217,14 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
210217
snd_soc_jack_add_gpios(&simple_card_mic_jack, 1,
211218
&simple_card_mic_jack_gpio);
212219
}
220+
221+
if (priv->codec_hp_det)
222+
snd_soc_card_jack_new(rtd->card, "Headphones",
223+
SND_JACK_HEADPHONE,
224+
&simple_card_hp_jack,
225+
simple_card_hp_jack_pins,
226+
ARRAY_SIZE(simple_card_hp_jack_pins));
227+
213228
return 0;
214229
}
215230

@@ -514,6 +529,9 @@ static int asoc_simple_card_parse_of(struct device_node *node,
514529
if (priv->gpio_mic_det == -EPROBE_DEFER)
515530
return -EPROBE_DEFER;
516531

532+
priv->codec_hp_det = of_property_read_bool(node,
533+
"simple-audio-card,codec-hp-det");
534+
517535
if (!priv->snd_card.name)
518536
priv->snd_card.name = priv->snd_card.dai_link->name;
519537

@@ -566,6 +584,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
566584
priv->gpio_hp_det = -ENOENT;
567585
priv->gpio_mic_det = -ENOENT;
568586

587+
priv->codec_hp_det = false;
588+
569589
/* Get room for the other properties */
570590
priv->dai_props = devm_kzalloc(dev,
571591
sizeof(*priv->dai_props) * num_links,

0 commit comments

Comments
 (0)