Lines Matching +full:headset +full:- +full:detect
1 // SPDX-License-Identifier: GPL-2.0-only
3 * omap-abe-twl6040.c -- SoC audio for TI OMAP based boards with ABE and
20 #include "omap-dmic.h"
21 #include "omap-mcpdm.h"
26 DAILINK_COMP_ARRAY(COMP_CODEC("twl6040-codec",
27 "twl6040-legacy")),
32 DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec",
33 "dmic-hifi")),
39 int jack_detection; /* board can detect jack events */
50 struct snd_soc_card *card = rtd->card; in omap_abe_hw_params()
55 clk_id = twl6040_get_clk_id(codec_dai->component); in omap_abe_hw_params()
57 freq = priv->mclk_freq; in omap_abe_hw_params()
61 return -EINVAL; in omap_abe_hw_params()
103 /* Headset jack */
106 /*Headset jack detection DAPM pins */
109 .pin = "Headset Mic",
113 .pin = "Headset Stereophone",
121 SND_SOC_DAPM_HP("Headset Stereophone", NULL),
128 SND_SOC_DAPM_MIC("Headset Mic", NULL),
139 {"Headset Stereophone", NULL, "HSOL"},
140 {"Headset Stereophone", NULL, "HSOR"},
154 {"HSMIC", NULL, "Headset Mic"},
155 {"Headset Mic", NULL, "Headset Mic Bias"},
169 struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; in omap_abe_twl6040_init()
170 struct snd_soc_card *card = rtd->card; in omap_abe_twl6040_init()
183 /* Headset jack detection only if it is supported */ in omap_abe_twl6040_init()
184 if (priv->jack_detection) { in omap_abe_twl6040_init()
185 ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack", in omap_abe_twl6040_init()
205 struct snd_soc_dapm_context *dapm = &rtd->card->dapm; in omap_abe_dmic_init()
213 struct device_node *node = pdev->dev.of_node; in omap_abe_probe()
221 dev_err(&pdev->dev, "of node is missing.\n"); in omap_abe_probe()
222 return -ENODEV; in omap_abe_probe()
225 priv = devm_kzalloc(&pdev->dev, sizeof(struct abe_twl6040), GFP_KERNEL); in omap_abe_probe()
227 return -ENOMEM; in omap_abe_probe()
229 card = &priv->card; in omap_abe_probe()
230 card->dev = &pdev->dev; in omap_abe_probe()
231 card->owner = THIS_MODULE; in omap_abe_probe()
232 card->dapm_widgets = twl6040_dapm_widgets; in omap_abe_probe()
233 card->num_dapm_widgets = ARRAY_SIZE(twl6040_dapm_widgets); in omap_abe_probe()
234 card->dapm_routes = audio_map; in omap_abe_probe()
235 card->num_dapm_routes = ARRAY_SIZE(audio_map); in omap_abe_probe()
238 dev_err(&pdev->dev, "Card name is not provided\n"); in omap_abe_probe()
239 return -ENODEV; in omap_abe_probe()
242 ret = snd_soc_of_parse_audio_routing(card, "ti,audio-routing"); in omap_abe_probe()
244 dev_err(&pdev->dev, "Error while parsing DAPM routing\n"); in omap_abe_probe()
250 dev_err(&pdev->dev, "McPDM node is not provided\n"); in omap_abe_probe()
251 return -EINVAL; in omap_abe_probe()
254 priv->dai_links[0].name = "DMIC"; in omap_abe_probe()
255 priv->dai_links[0].stream_name = "TWL6040"; in omap_abe_probe()
256 priv->dai_links[0].cpus = link0_cpus; in omap_abe_probe()
257 priv->dai_links[0].num_cpus = 1; in omap_abe_probe()
258 priv->dai_links[0].cpus->of_node = dai_node; in omap_abe_probe()
259 priv->dai_links[0].platforms = link0_platforms; in omap_abe_probe()
260 priv->dai_links[0].num_platforms = 1; in omap_abe_probe()
261 priv->dai_links[0].platforms->of_node = dai_node; in omap_abe_probe()
262 priv->dai_links[0].codecs = link0_codecs; in omap_abe_probe()
263 priv->dai_links[0].num_codecs = 1; in omap_abe_probe()
264 priv->dai_links[0].init = omap_abe_twl6040_init; in omap_abe_probe()
265 priv->dai_links[0].ops = &omap_abe_ops; in omap_abe_probe()
270 priv->dai_links[1].name = "TWL6040"; in omap_abe_probe()
271 priv->dai_links[1].stream_name = "DMIC Capture"; in omap_abe_probe()
272 priv->dai_links[1].cpus = link1_cpus; in omap_abe_probe()
273 priv->dai_links[1].num_cpus = 1; in omap_abe_probe()
274 priv->dai_links[1].cpus->of_node = dai_node; in omap_abe_probe()
275 priv->dai_links[1].platforms = link1_platforms; in omap_abe_probe()
276 priv->dai_links[1].num_platforms = 1; in omap_abe_probe()
277 priv->dai_links[1].platforms->of_node = dai_node; in omap_abe_probe()
278 priv->dai_links[1].codecs = link1_codecs; in omap_abe_probe()
279 priv->dai_links[1].num_codecs = 1; in omap_abe_probe()
280 priv->dai_links[1].init = omap_abe_dmic_init; in omap_abe_probe()
281 priv->dai_links[1].ops = &omap_abe_dmic_ops; in omap_abe_probe()
286 priv->jack_detection = of_property_read_bool(node, "ti,jack-detection"); in omap_abe_probe()
287 of_property_read_u32(node, "ti,mclk-freq", &priv->mclk_freq); in omap_abe_probe()
288 if (!priv->mclk_freq) { in omap_abe_probe()
289 dev_err(&pdev->dev, "MCLK frequency not provided\n"); in omap_abe_probe()
290 return -EINVAL; in omap_abe_probe()
293 card->fully_routed = 1; in omap_abe_probe()
295 card->dai_link = priv->dai_links; in omap_abe_probe()
296 card->num_links = num_links; in omap_abe_probe()
300 ret = devm_snd_soc_register_card(&pdev->dev, card); in omap_abe_probe()
302 dev_err(&pdev->dev, "devm_snd_soc_register_card() failed: %d\n", in omap_abe_probe()
309 {.compatible = "ti,abe-twl6040", },
316 .name = "omap-abe-twl6040",
327 dmic_codec_dev = platform_device_register_simple("dmic-codec", -1, NULL, in omap_abe_init()
330 pr_err("%s: dmic-codec device registration failed\n", __func__); in omap_abe_init()
354 MODULE_ALIAS("platform:omap-abe-twl6040");