treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / sound / soc / pxa / ttc-dkb.c
blobd8f79e2266b12b63cf51a40e4d238770293dfe8a
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * linux/sound/soc/pxa/ttc_dkb.c
5 * Copyright (C) 2012 Marvell International Ltd.
6 */
7 #include <linux/module.h>
8 #include <linux/moduleparam.h>
9 #include <sound/core.h>
10 #include <sound/pcm.h>
11 #include <sound/soc.h>
12 #include <sound/jack.h>
13 #include <asm/mach-types.h>
14 #include <sound/pcm_params.h>
15 #include "../codecs/88pm860x-codec.h"
17 static struct snd_soc_jack hs_jack, mic_jack;
19 static struct snd_soc_jack_pin hs_jack_pins[] = {
20 { .pin = "Headset Stereophone", .mask = SND_JACK_HEADPHONE, },
23 static struct snd_soc_jack_pin mic_jack_pins[] = {
24 { .pin = "Headset Mic 2", .mask = SND_JACK_MICROPHONE, },
27 /* ttc machine dapm widgets */
28 static const struct snd_soc_dapm_widget ttc_dapm_widgets[] = {
29 SND_SOC_DAPM_HP("Headset Stereophone", NULL),
30 SND_SOC_DAPM_LINE("Lineout Out 1", NULL),
31 SND_SOC_DAPM_LINE("Lineout Out 2", NULL),
32 SND_SOC_DAPM_SPK("Ext Speaker", NULL),
33 SND_SOC_DAPM_MIC("Ext Mic 1", NULL),
34 SND_SOC_DAPM_MIC("Headset Mic 2", NULL),
35 SND_SOC_DAPM_MIC("Ext Mic 3", NULL),
38 /* ttc machine audio map */
39 static const struct snd_soc_dapm_route ttc_audio_map[] = {
40 {"Headset Stereophone", NULL, "HS1"},
41 {"Headset Stereophone", NULL, "HS2"},
43 {"Ext Speaker", NULL, "LSP"},
44 {"Ext Speaker", NULL, "LSN"},
46 {"Lineout Out 1", NULL, "LINEOUT1"},
47 {"Lineout Out 2", NULL, "LINEOUT2"},
49 {"MIC1P", NULL, "Mic1 Bias"},
50 {"MIC1N", NULL, "Mic1 Bias"},
51 {"Mic1 Bias", NULL, "Ext Mic 1"},
53 {"MIC2P", NULL, "Mic1 Bias"},
54 {"MIC2N", NULL, "Mic1 Bias"},
55 {"Mic1 Bias", NULL, "Headset Mic 2"},
57 {"MIC3P", NULL, "Mic3 Bias"},
58 {"MIC3N", NULL, "Mic3 Bias"},
59 {"Mic3 Bias", NULL, "Ext Mic 3"},
62 static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
64 struct snd_soc_component *component = rtd->codec_dai->component;
66 /* Headset jack detection */
67 snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE |
68 SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2,
69 &hs_jack, hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
70 snd_soc_card_jack_new(rtd->card, "Microphone Jack", SND_JACK_MICROPHONE,
71 &mic_jack, mic_jack_pins,
72 ARRAY_SIZE(mic_jack_pins));
74 /* headphone, microphone detection & headset short detection */
75 pm860x_hs_jack_detect(component, &hs_jack, SND_JACK_HEADPHONE,
76 SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2);
77 pm860x_mic_jack_detect(component, &hs_jack, SND_JACK_MICROPHONE);
79 return 0;
82 /* ttc/td-dkb digital audio interface glue - connects codec <--> CPU */
83 SND_SOC_DAILINK_DEFS(i2s,
84 DAILINK_COMP_ARRAY(COMP_CPU("pxa-ssp-dai.1")),
85 DAILINK_COMP_ARRAY(COMP_CODEC("88pm860x-codec", "88pm860x-i2s")),
86 DAILINK_COMP_ARRAY(COMP_PLATFORM("mmp-pcm-audio")));
88 static struct snd_soc_dai_link ttc_pm860x_hifi_dai[] = {
90 .name = "88pm860x i2s",
91 .stream_name = "audio playback",
92 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
93 SND_SOC_DAIFMT_CBM_CFM,
94 .init = ttc_pm860x_init,
95 SND_SOC_DAILINK_REG(i2s),
99 /* ttc/td audio machine driver */
100 static struct snd_soc_card ttc_dkb_card = {
101 .name = "ttc-dkb-hifi",
102 .owner = THIS_MODULE,
103 .dai_link = ttc_pm860x_hifi_dai,
104 .num_links = ARRAY_SIZE(ttc_pm860x_hifi_dai),
106 .dapm_widgets = ttc_dapm_widgets,
107 .num_dapm_widgets = ARRAY_SIZE(ttc_dapm_widgets),
108 .dapm_routes = ttc_audio_map,
109 .num_dapm_routes = ARRAY_SIZE(ttc_audio_map),
112 static int ttc_dkb_probe(struct platform_device *pdev)
114 struct snd_soc_card *card = &ttc_dkb_card;
115 int ret;
117 card->dev = &pdev->dev;
119 ret = devm_snd_soc_register_card(&pdev->dev, card);
120 if (ret)
121 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
122 ret);
124 return ret;
127 static struct platform_driver ttc_dkb_driver = {
128 .driver = {
129 .name = "ttc-dkb-audio",
130 .pm = &snd_soc_pm_ops,
132 .probe = ttc_dkb_probe,
135 module_platform_driver(ttc_dkb_driver);
137 /* Module information */
138 MODULE_AUTHOR("Qiao Zhou, <zhouqiao@marvell.com>");
139 MODULE_DESCRIPTION("ALSA SoC TTC DKB");
140 MODULE_LICENSE("GPL");
141 MODULE_ALIAS("platform:ttc-dkb-audio");