root/sound/soc/cirrus/snappercl15.c

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

DEFINITIONS

This source file includes following definitions.
  1. snappercl15_hw_params
  2. snappercl15_probe
  3. snappercl15_remove

   1 // SPDX-License-Identifier: GPL-2.0-or-later
   2 /*
   3  * snappercl15.c -- SoC audio for Bluewater Systems Snapper CL15 module
   4  *
   5  * Copyright (C) 2008 Bluewater Systems Ltd
   6  * Author: Ryan Mallon
   7  */
   8 
   9 #include <linux/platform_device.h>
  10 #include <linux/module.h>
  11 #include <linux/soc/cirrus/ep93xx.h>
  12 #include <sound/core.h>
  13 #include <sound/pcm.h>
  14 #include <sound/soc.h>
  15 
  16 #include <asm/mach-types.h>
  17 
  18 #include "../codecs/tlv320aic23.h"
  19 
  20 #define CODEC_CLOCK 5644800
  21 
  22 static int snappercl15_hw_params(struct snd_pcm_substream *substream,
  23                                  struct snd_pcm_hw_params *params)
  24 {
  25         struct snd_soc_pcm_runtime *rtd = substream->private_data;
  26         struct snd_soc_dai *codec_dai = rtd->codec_dai;
  27         struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  28         int err;
  29 
  30         err = snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_CLOCK, 
  31                                      SND_SOC_CLOCK_IN);
  32         if (err)
  33                 return err;
  34 
  35         err = snd_soc_dai_set_sysclk(cpu_dai, 0, CODEC_CLOCK, 
  36                                      SND_SOC_CLOCK_OUT);
  37         if (err)
  38                 return err;
  39 
  40         return 0;
  41 }
  42 
  43 static const struct snd_soc_ops snappercl15_ops = {
  44         .hw_params      = snappercl15_hw_params,
  45 };
  46 
  47 static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = {
  48         SND_SOC_DAPM_HP("Headphone Jack", NULL),
  49         SND_SOC_DAPM_LINE("Line In", NULL),
  50         SND_SOC_DAPM_MIC("Mic Jack", NULL),
  51 };
  52 
  53 static const struct snd_soc_dapm_route audio_map[] = {
  54         {"Headphone Jack", NULL, "LHPOUT"},
  55         {"Headphone Jack", NULL, "RHPOUT"},
  56 
  57         {"LLINEIN", NULL, "Line In"},
  58         {"RLINEIN", NULL, "Line In"},
  59 
  60         {"MICIN", NULL, "Mic Jack"},
  61 };
  62 
  63 SND_SOC_DAILINK_DEFS(aic23,
  64         DAILINK_COMP_ARRAY(COMP_CPU("ep93xx-i2s")),
  65         DAILINK_COMP_ARRAY(COMP_CODEC("tlv320aic23-codec.0-001a",
  66                                       "tlv320aic23-hifi")),
  67         DAILINK_COMP_ARRAY(COMP_PLATFORM("ep93xx-i2s")));
  68 
  69 static struct snd_soc_dai_link snappercl15_dai = {
  70         .name           = "tlv320aic23",
  71         .stream_name    = "AIC23",
  72         .dai_fmt        = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  73                           SND_SOC_DAIFMT_CBS_CFS,
  74         .ops            = &snappercl15_ops,
  75         SND_SOC_DAILINK_REG(aic23),
  76 };
  77 
  78 static struct snd_soc_card snd_soc_snappercl15 = {
  79         .name           = "Snapper CL15",
  80         .owner          = THIS_MODULE,
  81         .dai_link       = &snappercl15_dai,
  82         .num_links      = 1,
  83 
  84         .dapm_widgets           = tlv320aic23_dapm_widgets,
  85         .num_dapm_widgets       = ARRAY_SIZE(tlv320aic23_dapm_widgets),
  86         .dapm_routes            = audio_map,
  87         .num_dapm_routes        = ARRAY_SIZE(audio_map),
  88 };
  89 
  90 static int snappercl15_probe(struct platform_device *pdev)
  91 {
  92         struct snd_soc_card *card = &snd_soc_snappercl15;
  93         int ret;
  94 
  95         ret = ep93xx_i2s_acquire();
  96         if (ret)
  97                 return ret;
  98 
  99         card->dev = &pdev->dev;
 100 
 101         ret = snd_soc_register_card(card);
 102         if (ret) {
 103                 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
 104                         ret);
 105                 ep93xx_i2s_release();
 106         }
 107 
 108         return ret;
 109 }
 110 
 111 static int snappercl15_remove(struct platform_device *pdev)
 112 {
 113         struct snd_soc_card *card = platform_get_drvdata(pdev);
 114 
 115         snd_soc_unregister_card(card);
 116         ep93xx_i2s_release();
 117 
 118         return 0;
 119 }
 120 
 121 static struct platform_driver snappercl15_driver = {
 122         .driver         = {
 123                 .name   = "snappercl15-audio",
 124         },
 125         .probe          = snappercl15_probe,
 126         .remove         = snappercl15_remove,
 127 };
 128 
 129 module_platform_driver(snappercl15_driver);
 130 
 131 MODULE_AUTHOR("Ryan Mallon");
 132 MODULE_DESCRIPTION("ALSA SoC Snapper CL15");
 133 MODULE_LICENSE("GPL");
 134 MODULE_ALIAS("platform:snappercl15-audio");

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