brcm2708: remove CMA_DEBUG
[openwrt.git] / target / linux / brcm2708 / patches-3.18 / 0033-ASoC-Add-support-for-HifiBerry-DAC.patch
1 From 77afe84c37210adb241e9b48f1a415f49f183a68 Mon Sep 17 00:00:00 2001
2 From: Florian Meier <florian.meier@koalo.de>
3 Date: Fri, 22 Nov 2013 19:19:08 +0100
4 Subject: [PATCH 033/114] ASoC: Add support for HifiBerry DAC
5
6 This adds a machine driver for the HifiBerry DAC.
7 It is a sound card that can
8 be stacked onto the Raspberry Pi.
9
10 Signed-off-by: Florian Meier <florian.meier@koalo.de>
11 ---
12  sound/soc/bcm/Kconfig         |   7 +++
13  sound/soc/bcm/Makefile        |   5 +++
14  sound/soc/bcm/hifiberry_dac.c | 100 ++++++++++++++++++++++++++++++++++++++++++
15  3 files changed, 112 insertions(+)
16  create mode 100644 sound/soc/bcm/hifiberry_dac.c
17
18 diff --git a/sound/soc/bcm/Kconfig b/sound/soc/bcm/Kconfig
19 index 7e5b945..b36a62f 100644
20 --- a/sound/soc/bcm/Kconfig
21 +++ b/sound/soc/bcm/Kconfig
22 @@ -18,3 +18,10 @@ config SND_BCM2708_SOC_I2S
23           Say Y or M if you want to add support for codecs attached to
24           the BCM2708 I2S interface. You will also need
25           to select the audio interfaces to support below.
26 +
27 +config SND_BCM2708_SOC_HIFIBERRY_DAC
28 +        tristate "Support for HifiBerry DAC"
29 +        depends on SND_BCM2708_SOC_I2S
30 +        select SND_SOC_PCM5102A
31 +        help
32 +         Say Y or M if you want to add support for HifiBerry DAC.
33 diff --git a/sound/soc/bcm/Makefile b/sound/soc/bcm/Makefile
34 index f8bbe1f..be90a49cb 100644
35 --- a/sound/soc/bcm/Makefile
36 +++ b/sound/soc/bcm/Makefile
37 @@ -7,3 +7,8 @@ obj-$(CONFIG_SND_BCM2835_SOC_I2S) += snd-soc-bcm2835-i2s.o
38  snd-soc-bcm2708-i2s-objs := bcm2708-i2s.o
39  
40  obj-$(CONFIG_SND_BCM2708_SOC_I2S) += snd-soc-bcm2708-i2s.o
41 +
42 +# BCM2708 Machine Support
43 +snd-soc-hifiberry-dac-objs := hifiberry_dac.o
44 +
45 +obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
46 diff --git a/sound/soc/bcm/hifiberry_dac.c b/sound/soc/bcm/hifiberry_dac.c
47 new file mode 100644
48 index 0000000..4b70b45
49 --- /dev/null
50 +++ b/sound/soc/bcm/hifiberry_dac.c
51 @@ -0,0 +1,100 @@
52 +/*
53 + * ASoC Driver for HifiBerry DAC
54 + *
55 + * Author:     Florian Meier <florian.meier@koalo.de>
56 + *             Copyright 2013
57 + *
58 + * This program is free software; you can redistribute it and/or
59 + * modify it under the terms of the GNU General Public License
60 + * version 2 as published by the Free Software Foundation.
61 + *
62 + * This program is distributed in the hope that it will be useful, but
63 + * WITHOUT ANY WARRANTY; without even the implied warranty of
64 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
65 + * General Public License for more details.
66 + */
67 +
68 +#include <linux/module.h>
69 +#include <linux/platform_device.h>
70 +
71 +#include <sound/core.h>
72 +#include <sound/pcm.h>
73 +#include <sound/pcm_params.h>
74 +#include <sound/soc.h>
75 +#include <sound/jack.h>
76 +
77 +static int snd_rpi_hifiberry_dac_init(struct snd_soc_pcm_runtime *rtd)
78 +{
79 +       return 0;
80 +}
81 +
82 +static int snd_rpi_hifiberry_dac_hw_params(struct snd_pcm_substream *substream,
83 +                                      struct snd_pcm_hw_params *params)
84 +{
85 +       struct snd_soc_pcm_runtime *rtd = substream->private_data;
86 +       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
87 +
88 +       unsigned int sample_bits =
89 +               snd_pcm_format_physical_width(params_format(params));
90 +
91 +       return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2);
92 +}
93 +
94 +/* machine stream operations */
95 +static struct snd_soc_ops snd_rpi_hifiberry_dac_ops = {
96 +       .hw_params = snd_rpi_hifiberry_dac_hw_params,
97 +};
98 +
99 +static struct snd_soc_dai_link snd_rpi_hifiberry_dac_dai[] = {
100 +{
101 +       .name           = "HifiBerry DAC",
102 +       .stream_name    = "HifiBerry DAC HiFi",
103 +       .cpu_dai_name   = "bcm2708-i2s.0",
104 +       .codec_dai_name = "pcm5102a-hifi",
105 +       .platform_name  = "bcm2708-i2s.0",
106 +       .codec_name     = "pcm5102a-codec",
107 +       .dai_fmt        = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
108 +                               SND_SOC_DAIFMT_CBS_CFS,
109 +       .ops            = &snd_rpi_hifiberry_dac_ops,
110 +       .init           = snd_rpi_hifiberry_dac_init,
111 +},
112 +};
113 +
114 +/* audio machine driver */
115 +static struct snd_soc_card snd_rpi_hifiberry_dac = {
116 +       .name         = "snd_rpi_hifiberry_dac",
117 +       .dai_link     = snd_rpi_hifiberry_dac_dai,
118 +       .num_links    = ARRAY_SIZE(snd_rpi_hifiberry_dac_dai),
119 +};
120 +
121 +static int snd_rpi_hifiberry_dac_probe(struct platform_device *pdev)
122 +{
123 +       int ret = 0;
124 +
125 +       snd_rpi_hifiberry_dac.dev = &pdev->dev;
126 +       ret = snd_soc_register_card(&snd_rpi_hifiberry_dac);
127 +       if (ret)
128 +               dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
129 +
130 +       return ret;
131 +}
132 +
133 +static int snd_rpi_hifiberry_dac_remove(struct platform_device *pdev)
134 +{
135 +       return snd_soc_unregister_card(&snd_rpi_hifiberry_dac);
136 +}
137 +
138 +static struct platform_driver snd_rpi_hifiberry_dac_driver = {
139 +        .driver = {
140 +                .name   = "snd-hifiberry-dac",
141 +                .owner  = THIS_MODULE,
142 +        },
143 +        .probe          = snd_rpi_hifiberry_dac_probe,
144 +        .remove         = snd_rpi_hifiberry_dac_remove,
145 +};
146 +
147 +module_platform_driver(snd_rpi_hifiberry_dac_driver);
148 +
149 +MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>");
150 +MODULE_DESCRIPTION("ASoC Driver for HifiBerry DAC");
151 +MODULE_LICENSE("GPL v2");
152 -- 
153 1.8.3.2
154