1 From 261e3e2577768d848277489e26759f3f37b25aae 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 080/725] 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 sound/soc/bcm/dionaudio_loco-v2.c | 115 ++++++++++++++++++++++++++++++
18 1 file changed, 115 insertions(+)
19 create mode 100644 sound/soc/bcm/dionaudio_loco-v2.c
22 +++ b/sound/soc/bcm/dionaudio_loco-v2.c
25 + * ASoC Driver for Dion Audio LOCO-V2 DAC-AMP
27 + * Author: Miquel Blauw <info@dionaudio.nl>
30 + * Based on the software of the RPi-DAC writen by Florian Meier
32 + * This program is free software; you can redistribute it and/or
33 + * modify it under the terms of the GNU General Public License
34 + * version 2 as published by the Free Software Foundation.
36 + * This program is distributed in the hope that it will be useful, but
37 + * WITHOUT ANY WARRANTY; without even the implied warranty of
38 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39 + * General Public License for more details.
42 +#include <linux/module.h>
43 +#include <linux/platform_device.h>
45 +#include <sound/core.h>
46 +#include <sound/pcm.h>
47 +#include <sound/pcm_params.h>
48 +#include <sound/soc.h>
49 +#include <sound/jack.h>
51 +static bool digital_gain_0db_limit = true;
53 +static int snd_rpi_dionaudio_loco_v2_init(struct snd_soc_pcm_runtime *rtd)
55 + if (digital_gain_0db_limit) {
57 + struct snd_soc_card *card = rtd->card;
59 + ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
61 + dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
67 +static struct snd_soc_dai_link snd_rpi_dionaudio_loco_v2_dai[] = {
69 + .name = "DionAudio LOCO-V2",
70 + .stream_name = "DionAudio LOCO-V2 DAC-AMP",
71 + .cpu_dai_name = "bcm2708-i2s.0",
72 + .codec_dai_name = "pcm512x-hifi",
73 + .platform_name = "bcm2708-i2s.0",
74 + .codec_name = "pcm512x.1-004d",
75 + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
76 + SND_SOC_DAIFMT_CBS_CFS,
77 + .init = snd_rpi_dionaudio_loco_v2_init,
80 +/* audio machine driver */
81 +static struct snd_soc_card snd_rpi_dionaudio_loco_v2 = {
82 + .name = "Dion Audio LOCO-V2",
83 + .dai_link = snd_rpi_dionaudio_loco_v2_dai,
84 + .num_links = ARRAY_SIZE(snd_rpi_dionaudio_loco_v2_dai),
87 +static int snd_rpi_dionaudio_loco_v2_probe(struct platform_device *pdev)
91 + snd_rpi_dionaudio_loco_v2.dev = &pdev->dev;
93 + if (pdev->dev.of_node) {
94 + struct device_node *i2s_node;
95 + struct snd_soc_dai_link *dai =
96 + &snd_rpi_dionaudio_loco_v2_dai[0];
98 + i2s_node = of_parse_phandle(pdev->dev.of_node,
99 + "i2s-controller", 0);
101 + dai->cpu_dai_name = NULL;
102 + dai->cpu_of_node = i2s_node;
103 + dai->platform_name = NULL;
104 + dai->platform_of_node = i2s_node;
107 + digital_gain_0db_limit = !of_property_read_bool(
108 + pdev->dev.of_node, "dionaudio,24db_digital_gain");
111 + ret = devm_snd_soc_register_card(&pdev->dev, &snd_rpi_dionaudio_loco_v2);
113 + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
119 +static const struct of_device_id dionaudio_of_match[] = {
120 + { .compatible = "dionaudio,dionaudio-loco-v2", },
123 +MODULE_DEVICE_TABLE(of, dionaudio_of_match);
125 +static struct platform_driver snd_rpi_dionaudio_loco_v2_driver = {
127 + .name = "snd-rpi-dionaudio-loco-v2",
128 + .owner = THIS_MODULE,
129 + .of_match_table = dionaudio_of_match,
131 + .probe = snd_rpi_dionaudio_loco_v2_probe,
134 +module_platform_driver(snd_rpi_dionaudio_loco_v2_driver);
136 +MODULE_AUTHOR("Miquel Blauw <info@dionaudio.nl>");
137 +MODULE_DESCRIPTION("ASoC Driver for DionAudio LOCO-V2");
138 +MODULE_LICENSE("GPL v2");