OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | From 9698288ce060841ca673ed296cc931130a566a12 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 084/454] sound: Support for Dion Audio LOCO-V2 DAC-AMP HAT |
||
5 | |||
6 | Signed-off-by: Miquel Blauw <info@dionaudio.nl> |
||
7 | --- |
||
8 | sound/soc/bcm/Kconfig | 7 ++ |
||
9 | sound/soc/bcm/Makefile | 2 + |
||
10 | sound/soc/bcm/dionaudio_loco-v2.c | 140 ++++++++++++++++++++++++++++++ |
||
11 | 3 files changed, 149 insertions(+) |
||
12 | create mode 100644 sound/soc/bcm/dionaudio_loco-v2.c |
||
13 | |||
14 | --- a/sound/soc/bcm/Kconfig |
||
15 | +++ b/sound/soc/bcm/Kconfig |
||
16 | @@ -134,6 +134,13 @@ config SND_BCM2708_SOC_DIONAUDIO_LOCO |
||
17 | help |
||
18 | Say Y or M if you want to add support for Dion Audio LOCO. |
||
19 | |||
20 | +config SND_BCM2708_SOC_DIONAUDIO_LOCO_V2 |
||
21 | + tristate "Support for Dion Audio LOCO-V2 DAC-AMP" |
||
22 | + depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S |
||
23 | + select SND_SOC_PCM5122 |
||
24 | + help |
||
25 | + Say Y or M if you want to add support for Dion Audio LOCO-V2. |
||
26 | + |
||
27 | config SND_BCM2708_SOC_ALLO_PIANO_DAC |
||
28 | tristate "Support for Allo Piano DAC" |
||
29 | depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S |
||
30 | --- a/sound/soc/bcm/Makefile |
||
31 | +++ b/sound/soc/bcm/Makefile |
||
32 | @@ -25,6 +25,7 @@ snd-soc-raspidac3-objs := raspidac3.o |
||
33 | snd-soc-audioinjector-pi-soundcard-objs := audioinjector-pi-soundcard.o |
||
34 | snd-soc-digidac1-soundcard-objs := digidac1-soundcard.o |
||
35 | snd-soc-dionaudio-loco-objs := dionaudio_loco.o |
||
36 | +snd-soc-dionaudio-loco-v2-objs := dionaudio_loco-v2.o |
||
37 | snd-soc-allo-boss-dac-objs := allo-boss-dac.o |
||
38 | snd-soc-allo-piano-dac-objs := allo-piano-dac.o |
||
39 | snd-soc-allo-piano-dac-plus-objs := allo-piano-dac-plus.o |
||
40 | @@ -46,6 +47,7 @@ obj-$(CONFIG_SND_BCM2708_SOC_RASPIDAC3) |
||
41 | obj-$(CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD) += snd-soc-audioinjector-pi-soundcard.o |
||
42 | obj-$(CONFIG_SND_DIGIDAC1_SOUNDCARD) += snd-soc-digidac1-soundcard.o |
||
43 | obj-$(CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO) += snd-soc-dionaudio-loco.o |
||
44 | +obj-$(CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO_V2) += snd-soc-dionaudio-loco-v2.o |
||
45 | obj-$(CONFIG_SND_BCM2708_SOC_ALLO_BOSS_DAC) += snd-soc-allo-boss-dac.o |
||
46 | obj-$(CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC) += snd-soc-allo-piano-dac.o |
||
47 | obj-$(CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC_PLUS) += snd-soc-allo-piano-dac-plus.o |
||
48 | --- /dev/null |
||
49 | +++ b/sound/soc/bcm/dionaudio_loco-v2.c |
||
50 | @@ -0,0 +1,140 @@ |
||
51 | +/* |
||
52 | + * ASoC Driver for Dion Audio LOCO-V2 DAC-AMP |
||
53 | + * |
||
54 | + * Author: Miquel Blauw <info@dionaudio.nl> |
||
55 | + * Copyright 2017 |
||
56 | + * |
||
57 | + * Based on the software of the RPi-DAC writen by Florian Meier |
||
58 | + * |
||
59 | + * This program is free software; you can redistribute it and/or |
||
60 | + * modify it under the terms of the GNU General Public License |
||
61 | + * version 2 as published by the Free Software Foundation. |
||
62 | + * |
||
63 | + * This program is distributed in the hope that it will be useful, but |
||
64 | + * WITHOUT ANY WARRANTY; without even the implied warranty of |
||
65 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
66 | + * General Public License for more details. |
||
67 | + */ |
||
68 | + |
||
69 | +#include <linux/module.h> |
||
70 | +#include <linux/platform_device.h> |
||
71 | + |
||
72 | +#include <sound/core.h> |
||
73 | +#include <sound/pcm.h> |
||
74 | +#include <sound/pcm_params.h> |
||
75 | +#include <sound/soc.h> |
||
76 | +#include <sound/jack.h> |
||
77 | + |
||
78 | +static bool digital_gain_0db_limit = true; |
||
79 | + |
||
80 | +static int snd_rpi_dionaudio_loco_v2_init(struct snd_soc_pcm_runtime *rtd) |
||
81 | +{ |
||
82 | + if (digital_gain_0db_limit) { |
||
83 | + int ret; |
||
84 | + struct snd_soc_card *card = rtd->card; |
||
85 | + |
||
86 | + ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207); |
||
87 | + if (ret < 0) |
||
88 | + dev_warn(card->dev, "Failed to set volume limit: %d\n", ret); |
||
89 | + } |
||
90 | + |
||
91 | + return 0; |
||
92 | +} |
||
93 | + |
||
94 | +static int snd_rpi_dionaudio_loco_v2_hw_params( |
||
95 | + struct snd_pcm_substream *substream, |
||
96 | + struct snd_pcm_hw_params *params) |
||
97 | +{ |
||
98 | + struct snd_soc_pcm_runtime *rtd = substream->private_data; |
||
99 | + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
||
100 | + |
||
101 | + unsigned int sample_bits = |
||
102 | + snd_pcm_format_physical_width(params_format(params)); |
||
103 | + |
||
104 | + return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2); |
||
105 | +} |
||
106 | + |
||
107 | +/* machine stream operations */ |
||
108 | +static struct snd_soc_ops snd_rpi_dionaudio_loco_v2_ops = { |
||
109 | + .hw_params = snd_rpi_dionaudio_loco_v2_hw_params, |
||
110 | +}; |
||
111 | + |
||
112 | +static struct snd_soc_dai_link snd_rpi_dionaudio_loco_v2_dai[] = { |
||
113 | +{ |
||
114 | + .name = "DionAudio LOCO-V2", |
||
115 | + .stream_name = "DionAudio LOCO-V2 DAC-AMP", |
||
116 | + .cpu_dai_name = "bcm2708-i2s.0", |
||
117 | + .codec_dai_name = "pcm512x-hifi", |
||
118 | + .platform_name = "bcm2708-i2s.0", |
||
119 | + .codec_name = "pcm512x.1-004d", |
||
120 | + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
||
121 | + SND_SOC_DAIFMT_CBS_CFS, |
||
122 | + .ops = &snd_rpi_dionaudio_loco_v2_ops, |
||
123 | + .init = snd_rpi_dionaudio_loco_v2_init, |
||
124 | +},}; |
||
125 | + |
||
126 | +/* audio machine driver */ |
||
127 | +static struct snd_soc_card snd_rpi_dionaudio_loco_v2 = { |
||
128 | + .name = "Dion Audio LOCO-V2", |
||
129 | + .dai_link = snd_rpi_dionaudio_loco_v2_dai, |
||
130 | + .num_links = ARRAY_SIZE(snd_rpi_dionaudio_loco_v2_dai), |
||
131 | +}; |
||
132 | + |
||
133 | +static int snd_rpi_dionaudio_loco_v2_probe(struct platform_device *pdev) |
||
134 | +{ |
||
135 | + int ret = 0; |
||
136 | + |
||
137 | + snd_rpi_dionaudio_loco_v2.dev = &pdev->dev; |
||
138 | + |
||
139 | + if (pdev->dev.of_node) { |
||
140 | + struct device_node *i2s_node; |
||
141 | + struct snd_soc_dai_link *dai = |
||
142 | + &snd_rpi_dionaudio_loco_v2_dai[0]; |
||
143 | + |
||
144 | + i2s_node = of_parse_phandle(pdev->dev.of_node, |
||
145 | + "i2s-controller", 0); |
||
146 | + if (i2s_node) { |
||
147 | + dai->cpu_dai_name = NULL; |
||
148 | + dai->cpu_of_node = i2s_node; |
||
149 | + dai->platform_name = NULL; |
||
150 | + dai->platform_of_node = i2s_node; |
||
151 | + } |
||
152 | + |
||
153 | + digital_gain_0db_limit = !of_property_read_bool( |
||
154 | + pdev->dev.of_node, "dionaudio,24db_digital_gain"); |
||
155 | + } |
||
156 | + |
||
157 | + ret = snd_soc_register_card(&snd_rpi_dionaudio_loco_v2); |
||
158 | + if (ret) |
||
159 | + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", |
||
160 | + ret); |
||
161 | + |
||
162 | + return ret; |
||
163 | +} |
||
164 | + |
||
165 | +static int snd_rpi_dionaudio_loco_v2_remove(struct platform_device *pdev) |
||
166 | +{ |
||
167 | + return snd_soc_unregister_card(&snd_rpi_dionaudio_loco_v2); |
||
168 | +} |
||
169 | + |
||
170 | +static const struct of_device_id dionaudio_of_match[] = { |
||
171 | + { .compatible = "dionaudio,dionaudio-loco-v2", }, |
||
172 | + {}, |
||
173 | +}; |
||
174 | +MODULE_DEVICE_TABLE(of, dionaudio_of_match); |
||
175 | + |
||
176 | +static struct platform_driver snd_rpi_dionaudio_loco_v2_driver = { |
||
177 | + .driver = { |
||
178 | + .name = "snd-rpi-dionaudio-loco-v2", |
||
179 | + .owner = THIS_MODULE, |
||
180 | + .of_match_table = dionaudio_of_match, |
||
181 | + }, |
||
182 | + .probe = snd_rpi_dionaudio_loco_v2_probe, |
||
183 | + .remove = snd_rpi_dionaudio_loco_v2_remove, |
||
184 | +}; |
||
185 | + |
||
186 | +module_platform_driver(snd_rpi_dionaudio_loco_v2_driver); |
||
187 | + |
||
188 | +MODULE_AUTHOR("Miquel Blauw <info@dionaudio.nl>"); |
||
189 | +MODULE_DESCRIPTION("ASoC Driver for DionAudio LOCO-V2"); |
||
190 | +MODULE_LICENSE("GPL v2"); |