root/sound/soc/pxa/e750_wm9705.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. e750_spk_amp_event
  2. e750_hp_amp_event
  3. e750_probe
  4. e750_remove

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * e750-wm9705.c  --  SoC audio for e750
   4  *
   5  * Copyright 2007 (c) Ian Molton <spyro@f2s.com>
   6  */
   7 
   8 #include <linux/module.h>
   9 #include <linux/moduleparam.h>
  10 #include <linux/gpio.h>
  11 
  12 #include <sound/core.h>
  13 #include <sound/pcm.h>
  14 #include <sound/soc.h>
  15 
  16 #include <mach/audio.h>
  17 #include <mach/eseries-gpio.h>
  18 
  19 #include <asm/mach-types.h>
  20 
  21 static int e750_spk_amp_event(struct snd_soc_dapm_widget *w,
  22                                 struct snd_kcontrol *kcontrol, int event)
  23 {
  24         if (event & SND_SOC_DAPM_PRE_PMU)
  25                 gpio_set_value(GPIO_E750_SPK_AMP_OFF, 0);
  26         else if (event & SND_SOC_DAPM_POST_PMD)
  27                 gpio_set_value(GPIO_E750_SPK_AMP_OFF, 1);
  28 
  29         return 0;
  30 }
  31 
  32 static int e750_hp_amp_event(struct snd_soc_dapm_widget *w,
  33                                 struct snd_kcontrol *kcontrol, int event)
  34 {
  35         if (event & SND_SOC_DAPM_PRE_PMU)
  36                 gpio_set_value(GPIO_E750_HP_AMP_OFF, 0);
  37         else if (event & SND_SOC_DAPM_POST_PMD)
  38                 gpio_set_value(GPIO_E750_HP_AMP_OFF, 1);
  39 
  40         return 0;
  41 }
  42 
  43 static const struct snd_soc_dapm_widget e750_dapm_widgets[] = {
  44         SND_SOC_DAPM_HP("Headphone Jack", NULL),
  45         SND_SOC_DAPM_SPK("Speaker", NULL),
  46         SND_SOC_DAPM_MIC("Mic (Internal)", NULL),
  47         SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
  48                         e750_hp_amp_event, SND_SOC_DAPM_PRE_PMU |
  49                         SND_SOC_DAPM_POST_PMD),
  50         SND_SOC_DAPM_PGA_E("Speaker Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
  51                         e750_spk_amp_event, SND_SOC_DAPM_PRE_PMU |
  52                         SND_SOC_DAPM_POST_PMD),
  53 };
  54 
  55 static const struct snd_soc_dapm_route audio_map[] = {
  56         {"Headphone Amp", NULL, "HPOUTL"},
  57         {"Headphone Amp", NULL, "HPOUTR"},
  58         {"Headphone Jack", NULL, "Headphone Amp"},
  59 
  60         {"Speaker Amp", NULL, "MONOOUT"},
  61         {"Speaker", NULL, "Speaker Amp"},
  62 
  63         {"MIC1", NULL, "Mic (Internal)"},
  64 };
  65 
  66 SND_SOC_DAILINK_DEFS(ac97,
  67         DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97")),
  68         DAILINK_COMP_ARRAY(COMP_CODEC("wm9705-codec", "wm9705-hifi")),
  69         DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
  70 
  71 SND_SOC_DAILINK_DEFS(ac97_aux,
  72         DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97-aux")),
  73         DAILINK_COMP_ARRAY(COMP_CODEC("wm9705-codec", "wm9705-aux")),
  74         DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
  75 
  76 static struct snd_soc_dai_link e750_dai[] = {
  77         {
  78                 .name = "AC97",
  79                 .stream_name = "AC97 HiFi",
  80                 SND_SOC_DAILINK_REG(ac97),
  81                 /* use ops to check startup state */
  82         },
  83         {
  84                 .name = "AC97 Aux",
  85                 .stream_name = "AC97 Aux",
  86                 SND_SOC_DAILINK_REG(ac97_aux),
  87         },
  88 };
  89 
  90 static struct snd_soc_card e750 = {
  91         .name = "Toshiba e750",
  92         .owner = THIS_MODULE,
  93         .dai_link = e750_dai,
  94         .num_links = ARRAY_SIZE(e750_dai),
  95 
  96         .dapm_widgets = e750_dapm_widgets,
  97         .num_dapm_widgets = ARRAY_SIZE(e750_dapm_widgets),
  98         .dapm_routes = audio_map,
  99         .num_dapm_routes = ARRAY_SIZE(audio_map),
 100         .fully_routed = true,
 101 };
 102 
 103 static struct gpio e750_audio_gpios[] = {
 104         { GPIO_E750_HP_AMP_OFF, GPIOF_OUT_INIT_HIGH, "Headphone amp" },
 105         { GPIO_E750_SPK_AMP_OFF, GPIOF_OUT_INIT_HIGH, "Speaker amp" },
 106 };
 107 
 108 static int e750_probe(struct platform_device *pdev)
 109 {
 110         struct snd_soc_card *card = &e750;
 111         int ret;
 112 
 113         ret = gpio_request_array(e750_audio_gpios,
 114                                  ARRAY_SIZE(e750_audio_gpios));
 115         if (ret)
 116                 return ret;
 117 
 118         card->dev = &pdev->dev;
 119 
 120         ret = devm_snd_soc_register_card(&pdev->dev, card);
 121         if (ret) {
 122                 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
 123                         ret);
 124                 gpio_free_array(e750_audio_gpios, ARRAY_SIZE(e750_audio_gpios));
 125         }
 126         return ret;
 127 }
 128 
 129 static int e750_remove(struct platform_device *pdev)
 130 {
 131         gpio_free_array(e750_audio_gpios, ARRAY_SIZE(e750_audio_gpios));
 132         return 0;
 133 }
 134 
 135 static struct platform_driver e750_driver = {
 136         .driver         = {
 137                 .name   = "e750-audio",
 138                 .pm     = &snd_soc_pm_ops,
 139         },
 140         .probe          = e750_probe,
 141         .remove         = e750_remove,
 142 };
 143 
 144 module_platform_driver(e750_driver);
 145 
 146 /* Module information */
 147 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
 148 MODULE_DESCRIPTION("ALSA SoC driver for e750");
 149 MODULE_LICENSE("GPL v2");
 150 MODULE_ALIAS("platform:e750-audio");

/* [<][>][^][v][top][bottom][index][help] */