2 * ASoC Driver for Dion Audio LOCO-V2 DAC-AMP
4 * Author: Miquel Blauw <info@dionaudio.nl>
7 * Based on the software of the RPi-DAC writen by Florian Meier
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
22 #include <sound/core.h>
23 #include <sound/pcm.h>
24 #include <sound/pcm_params.h>
25 #include <sound/soc.h>
26 #include <sound/jack.h>
28 static bool digital_gain_0db_limit = true;
30 static int snd_rpi_dionaudio_loco_v2_init(struct snd_soc_pcm_runtime *rtd)
32 if (digital_gain_0db_limit) {
34 struct snd_soc_card *card = rtd->card;
36 ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
38 dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
44 SND_SOC_DAILINK_DEFS(dionaudio_loco_v2,
45 DAILINK_COMP_ARRAY(COMP_CPU("bcm2708-i2s.0")),
46 DAILINK_COMP_ARRAY(COMP_CODEC("pcm512x.1-004d", "pcm512x-hifi")),
47 DAILINK_COMP_ARRAY(COMP_PLATFORM("bcm2708-i2s.0")));
49 static struct snd_soc_dai_link snd_rpi_dionaudio_loco_v2_dai[] = {
51 .name = "DionAudio LOCO-V2",
52 .stream_name = "DionAudio LOCO-V2 DAC-AMP",
53 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
54 SND_SOC_DAIFMT_CBS_CFS,
55 .init = snd_rpi_dionaudio_loco_v2_init,
56 SND_SOC_DAILINK_REG(dionaudio_loco_v2),
59 /* audio machine driver */
60 static struct snd_soc_card snd_rpi_dionaudio_loco_v2 = {
61 .name = "Dion Audio LOCO-V2",
62 .dai_link = snd_rpi_dionaudio_loco_v2_dai,
63 .num_links = ARRAY_SIZE(snd_rpi_dionaudio_loco_v2_dai),
66 static int snd_rpi_dionaudio_loco_v2_probe(struct platform_device *pdev)
70 snd_rpi_dionaudio_loco_v2.dev = &pdev->dev;
72 if (pdev->dev.of_node) {
73 struct device_node *i2s_node;
74 struct snd_soc_dai_link *dai =
75 &snd_rpi_dionaudio_loco_v2_dai[0];
77 i2s_node = of_parse_phandle(pdev->dev.of_node,
80 dai->cpus->dai_name = NULL;
81 dai->cpus->of_node = i2s_node;
82 dai->platforms->name = NULL;
83 dai->platforms->of_node = i2s_node;
86 digital_gain_0db_limit = !of_property_read_bool(
87 pdev->dev.of_node, "dionaudio,24db_digital_gain");
90 ret = devm_snd_soc_register_card(&pdev->dev, &snd_rpi_dionaudio_loco_v2);
92 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
98 static const struct of_device_id dionaudio_of_match[] = {
99 { .compatible = "dionaudio,dionaudio-loco-v2", },
102 MODULE_DEVICE_TABLE(of, dionaudio_of_match);
104 static struct platform_driver snd_rpi_dionaudio_loco_v2_driver = {
106 .name = "snd-rpi-dionaudio-loco-v2",
107 .owner = THIS_MODULE,
108 .of_match_table = dionaudio_of_match,
110 .probe = snd_rpi_dionaudio_loco_v2_probe,
113 module_platform_driver(snd_rpi_dionaudio_loco_v2_driver);
115 MODULE_AUTHOR("Miquel Blauw <info@dionaudio.nl>");
116 MODULE_DESCRIPTION("ASoC Driver for DionAudio LOCO-V2");
117 MODULE_LICENSE("GPL v2");