1 From a1a8a4fb0f50f92f1c42164827dbdfb57007f183 Mon Sep 17 00:00:00 2001
2 From: Miquel <miquelblauw@hotmail.com>
3 Date: Fri, 24 Feb 2017 20:51:06 +0100
4 Subject: [PATCH] sound: Support for Dion Audio LOCO-V2 DAC-AMP HAT
6 Signed-off-by: Miquel Blauw <info@dionaudio.nl>
8 ASoC: dionaudio_loco-v2: fix S24_LE format
10 Remove set_bclk_ratio call so 24-bit data is transmitted in
13 Also remove hw_params and ops as they are no longer needed.
15 Signed-off-by: Matthias Reichl <hias@horus.com>
17 ASoC: dionaudio_loco-v2: use modern dai_link style
19 Signed-off-by: Hui Wang <hui.wang@canonical.com>
21 sound/soc/bcm/dionaudio_loco-v2.c | 117 ++++++++++++++++++++++++++++++
22 1 file changed, 117 insertions(+)
23 create mode 100644 sound/soc/bcm/dionaudio_loco-v2.c
26 +++ b/sound/soc/bcm/dionaudio_loco-v2.c
29 + * ASoC Driver for Dion Audio LOCO-V2 DAC-AMP
31 + * Author: Miquel Blauw <info@dionaudio.nl>
34 + * Based on the software of the RPi-DAC writen by Florian Meier
36 + * This program is free software; you can redistribute it and/or
37 + * modify it under the terms of the GNU General Public License
38 + * version 2 as published by the Free Software Foundation.
40 + * This program is distributed in the hope that it will be useful, but
41 + * WITHOUT ANY WARRANTY; without even the implied warranty of
42 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43 + * General Public License for more details.
46 +#include <linux/module.h>
47 +#include <linux/platform_device.h>
49 +#include <sound/core.h>
50 +#include <sound/pcm.h>
51 +#include <sound/pcm_params.h>
52 +#include <sound/soc.h>
53 +#include <sound/jack.h>
55 +static bool digital_gain_0db_limit = true;
57 +static int snd_rpi_dionaudio_loco_v2_init(struct snd_soc_pcm_runtime *rtd)
59 + if (digital_gain_0db_limit) {
61 + struct snd_soc_card *card = rtd->card;
63 + ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
65 + dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
71 +SND_SOC_DAILINK_DEFS(dionaudio_loco_v2,
72 + DAILINK_COMP_ARRAY(COMP_CPU("bcm2708-i2s.0")),
73 + DAILINK_COMP_ARRAY(COMP_CODEC("pcm512x.1-004d", "pcm512x-hifi")),
74 + DAILINK_COMP_ARRAY(COMP_PLATFORM("bcm2708-i2s.0")));
76 +static struct snd_soc_dai_link snd_rpi_dionaudio_loco_v2_dai[] = {
78 + .name = "DionAudio LOCO-V2",
79 + .stream_name = "DionAudio LOCO-V2 DAC-AMP",
80 + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
81 + SND_SOC_DAIFMT_CBS_CFS,
82 + .init = snd_rpi_dionaudio_loco_v2_init,
83 + SND_SOC_DAILINK_REG(dionaudio_loco_v2),
86 +/* audio machine driver */
87 +static struct snd_soc_card snd_rpi_dionaudio_loco_v2 = {
88 + .name = "Dion Audio LOCO-V2",
89 + .dai_link = snd_rpi_dionaudio_loco_v2_dai,
90 + .num_links = ARRAY_SIZE(snd_rpi_dionaudio_loco_v2_dai),
93 +static int snd_rpi_dionaudio_loco_v2_probe(struct platform_device *pdev)
97 + snd_rpi_dionaudio_loco_v2.dev = &pdev->dev;
99 + if (pdev->dev.of_node) {
100 + struct device_node *i2s_node;
101 + struct snd_soc_dai_link *dai =
102 + &snd_rpi_dionaudio_loco_v2_dai[0];
104 + i2s_node = of_parse_phandle(pdev->dev.of_node,
105 + "i2s-controller", 0);
107 + dai->cpus->dai_name = NULL;
108 + dai->cpus->of_node = i2s_node;
109 + dai->platforms->name = NULL;
110 + dai->platforms->of_node = i2s_node;
113 + digital_gain_0db_limit = !of_property_read_bool(
114 + pdev->dev.of_node, "dionaudio,24db_digital_gain");
117 + ret = devm_snd_soc_register_card(&pdev->dev, &snd_rpi_dionaudio_loco_v2);
119 + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
125 +static const struct of_device_id dionaudio_of_match[] = {
126 + { .compatible = "dionaudio,dionaudio-loco-v2", },
129 +MODULE_DEVICE_TABLE(of, dionaudio_of_match);
131 +static struct platform_driver snd_rpi_dionaudio_loco_v2_driver = {
133 + .name = "snd-rpi-dionaudio-loco-v2",
134 + .owner = THIS_MODULE,
135 + .of_match_table = dionaudio_of_match,
137 + .probe = snd_rpi_dionaudio_loco_v2_probe,
140 +module_platform_driver(snd_rpi_dionaudio_loco_v2_driver);
142 +MODULE_AUTHOR("Miquel Blauw <info@dionaudio.nl>");
143 +MODULE_DESCRIPTION("ASoC Driver for DionAudio LOCO-V2");
144 +MODULE_LICENSE("GPL v2");