1 From 4c4b1a565322382b927927d6066735c7cd1ea188 Mon Sep 17 00:00:00 2001
2 From: Clive Messer <clive.m.messer@gmail.com>
3 Date: Mon, 19 Sep 2016 14:01:04 +0100
4 Subject: [PATCH 075/806] Allo Piano DAC boards: Initial 2 channel (stereo)
7 Add initial 2 channel (stereo) support for Allo Piano DAC (2.0/2.1) boards,
8 using allo-piano-dac-pcm512x-audio overlay and allo-piano-dac ALSA ASoC
11 NB. The initial support is 2 channel (stereo) ONLY!
12 (The Piano DAC 2.1 will only support 2 channel (stereo) left/right output,
13 pending an update to the upstream pcm512x codec driver, which will have
14 to be submitted via upstream. With the initial downstream support,
15 provided by this patch, the Piano DAC 2.1 subwoofer outputs will
18 Signed-off-by: Baswaraj K <jaikumar@cem-solutions.net>
19 Signed-off-by: Clive Messer <clive.messer@digitaldreamtime.co.uk>
20 Tested-by: Clive Messer <clive.messer@digitaldreamtime.co.uk>
22 ASoC: allo-piano-dac: fix S24_LE format
24 Remove set_bclk_ratio call so 24-bit data is transmitted in
27 Also remove hw_params and ops as they are no longer needed.
29 Signed-off-by: Matthias Reichl <hias@horus.com>
31 sound/soc/bcm/allo-piano-dac.c | 120 +++++++++++++++++++++++++++++++++
32 1 file changed, 120 insertions(+)
33 create mode 100644 sound/soc/bcm/allo-piano-dac.c
36 +++ b/sound/soc/bcm/allo-piano-dac.c
39 + * ALSA ASoC Machine Driver for Allo Piano DAC
41 + * Author: Baswaraj K <jaikumar@cem-solutions.net>
43 + * based on code by Daniel Matuschek <info@crazy-audio.com>
44 + * based on code by Florian Meier <florian.meier@koalo.de>
46 + * This program is free software; you can redistribute it and/or
47 + * modify it under the terms of the GNU General Public License
48 + * version 2 as published by the Free Software Foundation.
50 + * This program is distributed in the hope that it will be useful, but
51 + * WITHOUT ANY WARRANTY; without even the implied warranty of
52 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
53 + * General Public License for more details.
56 +#include <linux/module.h>
57 +#include <linux/platform_device.h>
59 +#include <sound/core.h>
60 +#include <sound/pcm.h>
61 +#include <sound/pcm_params.h>
62 +#include <sound/soc.h>
64 +static bool digital_gain_0db_limit = true;
66 +static int snd_allo_piano_dac_init(struct snd_soc_pcm_runtime *rtd)
68 + if (digital_gain_0db_limit) {
70 + struct snd_soc_card *card = rtd->card;
72 + ret = snd_soc_limit_volume(card, "Digital Playback Volume",
75 + dev_warn(card->dev, "Failed to set volume limit: %d\n",
82 +static struct snd_soc_dai_link snd_allo_piano_dac_dai[] = {
84 + .name = "Piano DAC",
85 + .stream_name = "Piano DAC HiFi",
86 + .cpu_dai_name = "bcm2708-i2s.0",
87 + .codec_dai_name = "pcm512x-hifi",
88 + .platform_name = "bcm2708-i2s.0",
89 + .codec_name = "pcm512x.1-004c",
90 + .dai_fmt = SND_SOC_DAIFMT_I2S |
91 + SND_SOC_DAIFMT_NB_NF |
92 + SND_SOC_DAIFMT_CBS_CFS,
93 + .init = snd_allo_piano_dac_init,
97 +/* audio machine driver */
98 +static struct snd_soc_card snd_allo_piano_dac = {
100 + .owner = THIS_MODULE,
101 + .dai_link = snd_allo_piano_dac_dai,
102 + .num_links = ARRAY_SIZE(snd_allo_piano_dac_dai),
105 +static int snd_allo_piano_dac_probe(struct platform_device *pdev)
109 + snd_allo_piano_dac.dev = &pdev->dev;
111 + if (pdev->dev.of_node) {
112 + struct device_node *i2s_node;
113 + struct snd_soc_dai_link *dai;
115 + dai = &snd_allo_piano_dac_dai[0];
116 + i2s_node = of_parse_phandle(pdev->dev.of_node,
117 + "i2s-controller", 0);
120 + dai->cpu_dai_name = NULL;
121 + dai->cpu_of_node = i2s_node;
122 + dai->platform_name = NULL;
123 + dai->platform_of_node = i2s_node;
126 + digital_gain_0db_limit = !of_property_read_bool(
127 + pdev->dev.of_node, "allo,24db_digital_gain");
130 + ret = devm_snd_soc_register_card(&pdev->dev, &snd_allo_piano_dac);
131 + if (ret && ret != -EPROBE_DEFER)
132 + dev_err(&pdev->dev,
133 + "snd_soc_register_card() failed: %d\n", ret);
138 +static const struct of_device_id snd_allo_piano_dac_of_match[] = {
139 + { .compatible = "allo,piano-dac", },
140 + { /* sentinel */ },
142 +MODULE_DEVICE_TABLE(of, snd_allo_piano_dac_of_match);
144 +static struct platform_driver snd_allo_piano_dac_driver = {
146 + .name = "snd-allo-piano-dac",
147 + .owner = THIS_MODULE,
148 + .of_match_table = snd_allo_piano_dac_of_match,
150 + .probe = snd_allo_piano_dac_probe,
153 +module_platform_driver(snd_allo_piano_dac_driver);
155 +MODULE_AUTHOR("Baswaraj K <jaikumar@cem-solutions.net>");
156 +MODULE_DESCRIPTION("ALSA ASoC Machine Driver for Allo Piano DAC");
157 +MODULE_LICENSE("GPL v2");