1 From 234b6a3cfd5bc1fb341c01f8ac773956f5af42cd Mon Sep 17 00:00:00 2001
2 From: DigitalDreamtime <clive.messer@digitaldreamtime.co.uk>
3 Date: Sat, 2 Jul 2016 16:26:19 +0100
4 Subject: [PATCH 074/806] Add support for Dion Audio LOCO DAC-AMP HAT
6 Using dedicated machine driver and pcm5102a codec driver.
8 Signed-off-by: DigitalDreamtime <clive.messer@digitaldreamtime.co.uk>
10 sound/soc/bcm/dionaudio_loco.c | 115 +++++++++++++++++++++++++++++++++
11 1 file changed, 115 insertions(+)
12 create mode 100644 sound/soc/bcm/dionaudio_loco.c
15 +++ b/sound/soc/bcm/dionaudio_loco.c
18 + * ASoC Driver for Dion Audio LOCO DAC-AMP
20 + * Author: Miquel Blauw <info@dionaudio.nl>
23 + * Based on the software of the RPi-DAC writen by Florian Meier
25 + * This program is free software; you can redistribute it and/or
26 + * modify it under the terms of the GNU General Public License
27 + * version 2 as published by the Free Software Foundation.
29 + * This program is distributed in the hope that it will be useful, but
30 + * WITHOUT ANY WARRANTY; without even the implied warranty of
31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 + * General Public License for more details.
35 +#include <linux/module.h>
36 +#include <linux/platform_device.h>
38 +#include <sound/core.h>
39 +#include <sound/pcm.h>
40 +#include <sound/pcm_params.h>
41 +#include <sound/soc.h>
42 +#include <sound/jack.h>
44 +static int snd_rpi_dionaudio_loco_hw_params(
45 + struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
47 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
48 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
50 + unsigned int sample_bits =
51 + snd_pcm_format_physical_width(params_format(params));
53 + return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2);
56 +/* machine stream operations */
57 +static struct snd_soc_ops snd_rpi_dionaudio_loco_ops = {
58 + .hw_params = snd_rpi_dionaudio_loco_hw_params,
61 +static struct snd_soc_dai_link snd_rpi_dionaudio_loco_dai[] = {
63 + .name = "DionAudio LOCO",
64 + .stream_name = "DionAudio LOCO DAC-AMP",
65 + .cpu_dai_name = "bcm2708-i2s.0",
66 + .codec_dai_name = "pcm5102a-hifi",
67 + .platform_name = "bcm2708-i2s.0",
68 + .codec_name = "pcm5102a-codec",
69 + .dai_fmt = SND_SOC_DAIFMT_I2S |
70 + SND_SOC_DAIFMT_NB_NF |
71 + SND_SOC_DAIFMT_CBS_CFS,
72 + .ops = &snd_rpi_dionaudio_loco_ops,
76 +/* audio machine driver */
77 +static struct snd_soc_card snd_rpi_dionaudio_loco = {
78 + .name = "snd_rpi_dionaudio_loco",
79 + .dai_link = snd_rpi_dionaudio_loco_dai,
80 + .num_links = ARRAY_SIZE(snd_rpi_dionaudio_loco_dai),
83 +static int snd_rpi_dionaudio_loco_probe(struct platform_device *pdev)
85 + struct device_node *np;
88 + snd_rpi_dionaudio_loco.dev = &pdev->dev;
90 + np = pdev->dev.of_node;
92 + struct snd_soc_dai_link *dai = &snd_rpi_dionaudio_loco_dai[0];
93 + struct device_node *i2s_np;
95 + i2s_np = of_parse_phandle(np, "i2s-controller", 0);
97 + dai->cpu_dai_name = NULL;
98 + dai->cpu_of_node = i2s_np;
99 + dai->platform_name = NULL;
100 + dai->platform_of_node = i2s_np;
104 + ret = devm_snd_soc_register_card(&pdev->dev, &snd_rpi_dionaudio_loco);
105 + if (ret && ret != -EPROBE_DEFER)
106 + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
112 +static const struct of_device_id snd_rpi_dionaudio_loco_of_match[] = {
113 + { .compatible = "dionaudio,loco-pcm5242-tpa3118", },
114 + { /* sentinel */ },
116 +MODULE_DEVICE_TABLE(of, snd_rpi_dionaudio_loco_of_match);
118 +static struct platform_driver snd_rpi_dionaudio_loco_driver = {
120 + .name = "snd-dionaudio-loco",
121 + .owner = THIS_MODULE,
122 + .of_match_table = snd_rpi_dionaudio_loco_of_match,
124 + .probe = snd_rpi_dionaudio_loco_probe,
127 +module_platform_driver(snd_rpi_dionaudio_loco_driver);
129 +MODULE_AUTHOR("Miquel Blauw <info@dionaudio.nl>");
130 +MODULE_DESCRIPTION("ASoC Driver for DionAudio LOCO");
131 +MODULE_LICENSE("GPL v2");