0001
0002
0003
0004
0005
0006
0007 #include <linux/module.h>
0008 #include <linux/moduleparam.h>
0009 #include <sound/core.h>
0010 #include <sound/pcm.h>
0011 #include <sound/soc.h>
0012 #include <sound/jack.h>
0013 #include <asm/mach-types.h>
0014 #include <sound/pcm_params.h>
0015 #include "../codecs/88pm860x-codec.h"
0016
0017 static struct snd_soc_jack hs_jack, mic_jack;
0018
0019 static struct snd_soc_jack_pin hs_jack_pins[] = {
0020 { .pin = "Headset Stereophone", .mask = SND_JACK_HEADPHONE, },
0021 };
0022
0023 static struct snd_soc_jack_pin mic_jack_pins[] = {
0024 { .pin = "Headset Mic 2", .mask = SND_JACK_MICROPHONE, },
0025 };
0026
0027
0028 static const struct snd_soc_dapm_widget ttc_dapm_widgets[] = {
0029 SND_SOC_DAPM_HP("Headset Stereophone", NULL),
0030 SND_SOC_DAPM_LINE("Lineout Out 1", NULL),
0031 SND_SOC_DAPM_LINE("Lineout Out 2", NULL),
0032 SND_SOC_DAPM_SPK("Ext Speaker", NULL),
0033 SND_SOC_DAPM_MIC("Ext Mic 1", NULL),
0034 SND_SOC_DAPM_MIC("Headset Mic 2", NULL),
0035 SND_SOC_DAPM_MIC("Ext Mic 3", NULL),
0036 };
0037
0038
0039 static const struct snd_soc_dapm_route ttc_audio_map[] = {
0040 {"Headset Stereophone", NULL, "HS1"},
0041 {"Headset Stereophone", NULL, "HS2"},
0042
0043 {"Ext Speaker", NULL, "LSP"},
0044 {"Ext Speaker", NULL, "LSN"},
0045
0046 {"Lineout Out 1", NULL, "LINEOUT1"},
0047 {"Lineout Out 2", NULL, "LINEOUT2"},
0048
0049 {"MIC1P", NULL, "Mic1 Bias"},
0050 {"MIC1N", NULL, "Mic1 Bias"},
0051 {"Mic1 Bias", NULL, "Ext Mic 1"},
0052
0053 {"MIC2P", NULL, "Mic1 Bias"},
0054 {"MIC2N", NULL, "Mic1 Bias"},
0055 {"Mic1 Bias", NULL, "Headset Mic 2"},
0056
0057 {"MIC3P", NULL, "Mic3 Bias"},
0058 {"MIC3N", NULL, "Mic3 Bias"},
0059 {"Mic3 Bias", NULL, "Ext Mic 3"},
0060 };
0061
0062 static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
0063 {
0064 struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
0065
0066
0067 snd_soc_card_jack_new_pins(rtd->card, "Headphone Jack",
0068 SND_JACK_HEADPHONE | SND_JACK_BTN_0 |
0069 SND_JACK_BTN_1 | SND_JACK_BTN_2,
0070 &hs_jack,
0071 hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
0072 snd_soc_card_jack_new_pins(rtd->card, "Microphone Jack",
0073 SND_JACK_MICROPHONE, &mic_jack,
0074 mic_jack_pins, ARRAY_SIZE(mic_jack_pins));
0075
0076
0077 pm860x_hs_jack_detect(component, &hs_jack, SND_JACK_HEADPHONE,
0078 SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2);
0079 pm860x_mic_jack_detect(component, &hs_jack, SND_JACK_MICROPHONE);
0080
0081 return 0;
0082 }
0083
0084
0085 SND_SOC_DAILINK_DEFS(i2s,
0086 DAILINK_COMP_ARRAY(COMP_CPU("pxa-ssp-dai.1")),
0087 DAILINK_COMP_ARRAY(COMP_CODEC("88pm860x-codec", "88pm860x-i2s")),
0088 DAILINK_COMP_ARRAY(COMP_PLATFORM("mmp-pcm-audio")));
0089
0090 static struct snd_soc_dai_link ttc_pm860x_hifi_dai[] = {
0091 {
0092 .name = "88pm860x i2s",
0093 .stream_name = "audio playback",
0094 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
0095 SND_SOC_DAIFMT_CBM_CFM,
0096 .init = ttc_pm860x_init,
0097 SND_SOC_DAILINK_REG(i2s),
0098 },
0099 };
0100
0101
0102 static struct snd_soc_card ttc_dkb_card = {
0103 .name = "ttc-dkb-hifi",
0104 .owner = THIS_MODULE,
0105 .dai_link = ttc_pm860x_hifi_dai,
0106 .num_links = ARRAY_SIZE(ttc_pm860x_hifi_dai),
0107
0108 .dapm_widgets = ttc_dapm_widgets,
0109 .num_dapm_widgets = ARRAY_SIZE(ttc_dapm_widgets),
0110 .dapm_routes = ttc_audio_map,
0111 .num_dapm_routes = ARRAY_SIZE(ttc_audio_map),
0112 };
0113
0114 static int ttc_dkb_probe(struct platform_device *pdev)
0115 {
0116 struct snd_soc_card *card = &ttc_dkb_card;
0117 int ret;
0118
0119 card->dev = &pdev->dev;
0120
0121 ret = devm_snd_soc_register_card(&pdev->dev, card);
0122 if (ret)
0123 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
0124 ret);
0125
0126 return ret;
0127 }
0128
0129 static struct platform_driver ttc_dkb_driver = {
0130 .driver = {
0131 .name = "ttc-dkb-audio",
0132 .pm = &snd_soc_pm_ops,
0133 },
0134 .probe = ttc_dkb_probe,
0135 };
0136
0137 module_platform_driver(ttc_dkb_driver);
0138
0139
0140 MODULE_AUTHOR("Qiao Zhou, <zhouqiao@marvell.com>");
0141 MODULE_DESCRIPTION("ALSA SoC TTC DKB");
0142 MODULE_LICENSE("GPL");
0143 MODULE_ALIAS("platform:ttc-dkb-audio");