linux/sound/soc/pxa/ttc-dkb.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-or-later
   2/*
   3 * linux/sound/soc/pxa/ttc_dkb.c
   4 *
   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"
  16
  17static struct snd_soc_jack hs_jack, mic_jack;
  18
  19static struct snd_soc_jack_pin hs_jack_pins[] = {
  20        { .pin = "Headset Stereophone", .mask = SND_JACK_HEADPHONE, },
  21};
  22
  23static struct snd_soc_jack_pin mic_jack_pins[] = {
  24        { .pin = "Headset Mic 2",       .mask = SND_JACK_MICROPHONE, },
  25};
  26
  27/* ttc machine dapm widgets */
  28static 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),
  36};
  37
  38/* ttc machine audio map */
  39static const struct snd_soc_dapm_route ttc_audio_map[] = {
  40        {"Headset Stereophone", NULL, "HS1"},
  41        {"Headset Stereophone", NULL, "HS2"},
  42
  43        {"Ext Speaker", NULL, "LSP"},
  44        {"Ext Speaker", NULL, "LSN"},
  45
  46        {"Lineout Out 1", NULL, "LINEOUT1"},
  47        {"Lineout Out 2", NULL, "LINEOUT2"},
  48
  49        {"MIC1P", NULL, "Mic1 Bias"},
  50        {"MIC1N", NULL, "Mic1 Bias"},
  51        {"Mic1 Bias", NULL, "Ext Mic 1"},
  52
  53        {"MIC2P", NULL, "Mic1 Bias"},
  54        {"MIC2N", NULL, "Mic1 Bias"},
  55        {"Mic1 Bias", NULL, "Headset Mic 2"},
  56
  57        {"MIC3P", NULL, "Mic3 Bias"},
  58        {"MIC3N", NULL, "Mic3 Bias"},
  59        {"Mic3 Bias", NULL, "Ext Mic 3"},
  60};
  61
  62static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
  63{
  64        struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
  65
  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));
  73
  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);
  78
  79        return 0;
  80}
  81
  82/* ttc/td-dkb digital audio interface glue - connects codec <--> CPU */
  83SND_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")));
  87
  88static struct snd_soc_dai_link ttc_pm860x_hifi_dai[] = {
  89{
  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),
  96},
  97};
  98
  99/* ttc/td audio machine driver */
 100static 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),
 105
 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),
 110};
 111
 112static int ttc_dkb_probe(struct platform_device *pdev)
 113{
 114        struct snd_soc_card *card = &ttc_dkb_card;
 115        int ret;
 116
 117        card->dev = &pdev->dev;
 118
 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);
 123
 124        return ret;
 125}
 126
 127static struct platform_driver ttc_dkb_driver = {
 128        .driver         = {
 129                .name   = "ttc-dkb-audio",
 130                .pm     = &snd_soc_pm_ops,
 131        },
 132        .probe          = ttc_dkb_probe,
 133};
 134
 135module_platform_driver(ttc_dkb_driver);
 136
 137/* Module information */
 138MODULE_AUTHOR("Qiao Zhou, <zhouqiao@marvell.com>");
 139MODULE_DESCRIPTION("ALSA SoC TTC DKB");
 140MODULE_LICENSE("GPL");
 141MODULE_ALIAS("platform:ttc-dkb-audio");
 142