#include <linux/of.h>
#include <linux/clk.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <sound/core.h>
#include <sound/dmaengine_pcm.h>
#include <sound/pcm_params.h>
#include <sound/tlv.h>
#include "atmel-classd.h"
struct atmel_classd_pdata { … };
struct atmel_classd { … };
#ifdef CONFIG_OF
static const struct of_device_id atmel_classd_of_match[] = …;
MODULE_DEVICE_TABLE(of, atmel_classd_of_match);
static struct atmel_classd_pdata *atmel_classd_dt_init(struct device *dev)
{ … }
#else
static inline struct atmel_classd_pdata *
atmel_classd_dt_init(struct device *dev)
{
return ERR_PTR(-EINVAL);
}
#endif
#define ATMEL_CLASSD_RATES …
static const struct snd_pcm_hardware atmel_classd_hw = …;
#define ATMEL_CLASSD_PREALLOC_BUF_SIZE …
static int atmel_classd_cpu_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai)
{ … }
static int
atmel_classd_platform_configure_dma(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct dma_slave_config *slave_config)
{ … }
static const struct snd_dmaengine_pcm_config
atmel_classd_dmaengine_pcm_config = …;
static const char * const mono_mode_text[] = …;
static SOC_ENUM_SINGLE_DECL(classd_mono_mode_enum,
CLASSD_INTPMR, CLASSD_INTPMR_MONO_MODE_SHIFT,
mono_mode_text);
static const char * const eqcfg_text[] = …;
static const unsigned int eqcfg_value[] = …;
static SOC_VALUE_ENUM_SINGLE_DECL(classd_eqcfg_enum,
CLASSD_INTPMR, CLASSD_INTPMR_EQCFG_SHIFT, 0xf,
eqcfg_text, eqcfg_value);
static const DECLARE_TLV_DB_SCALE(classd_digital_tlv, -7800, 100, 1);
static const struct snd_kcontrol_new atmel_classd_snd_controls[] = …;
static const char * const pwm_type[] = …;
static int atmel_classd_component_probe(struct snd_soc_component *component)
{ … }
static int atmel_classd_component_resume(struct snd_soc_component *component)
{ … }
static int atmel_classd_cpu_dai_mute_stream(struct snd_soc_dai *cpu_dai,
int mute, int direction)
{ … }
#define CLASSD_GCLK_RATE_11M2896_MPY_8 …
#define CLASSD_GCLK_RATE_12M288_MPY_8 …
static struct { … } const sample_rates[] = …;
static int
atmel_classd_cpu_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *cpu_dai)
{ … }
static void
atmel_classd_cpu_dai_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai)
{ … }
static int atmel_classd_cpu_dai_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai)
{ … }
static int atmel_classd_cpu_dai_trigger(struct snd_pcm_substream *substream,
int cmd, struct snd_soc_dai *cpu_dai)
{ … }
static const struct snd_soc_dai_ops atmel_classd_cpu_dai_ops = …;
static struct snd_soc_dai_driver atmel_classd_cpu_dai = …;
static const struct snd_soc_component_driver atmel_classd_cpu_dai_component = …;
static int atmel_classd_asoc_card_init(struct device *dev,
struct snd_soc_card *card)
{
struct snd_soc_dai_link *dai_link;
struct atmel_classd *dd = snd_soc_card_get_drvdata(card);
struct snd_soc_dai_link_component *comp;
dai_link = devm_kzalloc(dev, sizeof(*dai_link), GFP_KERNEL);
if (!dai_link)
return -ENOMEM;
comp = devm_kzalloc(dev, 2 * sizeof(*comp), GFP_KERNEL);
if (!comp)
return -ENOMEM;
dai_link->cpus = &comp[0];
dai_link->codecs = &snd_soc_dummy_dlc;
dai_link->platforms = &comp[1];
dai_link->num_cpus = 1;
dai_link->num_codecs = 1;
dai_link->num_platforms = 1;
dai_link->name = "CLASSD";
dai_link->stream_name = "CLASSD PCM";
dai_link->cpus->dai_name = dev_name(dev);
dai_link->platforms->name = dev_name(dev);
card->dai_link = dai_link;
card->num_links = 1;
card->name = dd->pdata->card_name;
card->dev = dev;
return 0;
};
static const struct reg_default atmel_classd_reg_defaults[] = …;
#define ATMEL_CLASSD_REG_MAX …
static const struct regmap_config atmel_classd_regmap_config = …;
static int atmel_classd_probe(struct platform_device *pdev)
{ … }
static struct platform_driver atmel_classd_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;