]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - sound/soc/bcm/rpi-dac.c
sound: Suppress error message about deferrals
[mirror_ubuntu-zesty-kernel.git] / sound / soc / bcm / rpi-dac.c
CommitLineData
d268c871
FM
1/*
2 * ASoC Driver for RPi-DAC.
3 *
4 * Author: Florian Meier <florian.meier@koalo.de>
5 * Copyright 2013
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 */
16
17#include <linux/module.h>
18#include <linux/platform_device.h>
19
20#include <sound/core.h>
21#include <sound/pcm.h>
22#include <sound/pcm_params.h>
23#include <sound/soc.h>
24#include <sound/jack.h>
25
26static int snd_rpi_rpi_dac_init(struct snd_soc_pcm_runtime *rtd)
27{
28 return 0;
29}
30
31static int snd_rpi_rpi_dac_hw_params(struct snd_pcm_substream *substream,
32 struct snd_pcm_hw_params *params)
33{
34 struct snd_soc_pcm_runtime *rtd = substream->private_data;
35 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
36
37 return snd_soc_dai_set_bclk_ratio(cpu_dai, 32*2);
38}
39
40/* machine stream operations */
41static struct snd_soc_ops snd_rpi_rpi_dac_ops = {
42 .hw_params = snd_rpi_rpi_dac_hw_params,
43};
44
45static struct snd_soc_dai_link snd_rpi_rpi_dac_dai[] = {
46{
47 .name = "RPi-DAC",
48 .stream_name = "RPi-DAC HiFi",
49 .cpu_dai_name = "bcm2708-i2s.0",
50 .codec_dai_name = "pcm1794a-hifi",
51 .platform_name = "bcm2708-i2s.0",
52 .codec_name = "pcm1794a-codec",
53 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
54 SND_SOC_DAIFMT_CBS_CFS,
55 .ops = &snd_rpi_rpi_dac_ops,
56 .init = snd_rpi_rpi_dac_init,
57},
58};
59
60/* audio machine driver */
61static struct snd_soc_card snd_rpi_rpi_dac = {
62 .name = "snd_rpi_rpi_dac",
63 .owner = THIS_MODULE,
64 .dai_link = snd_rpi_rpi_dac_dai,
65 .num_links = ARRAY_SIZE(snd_rpi_rpi_dac_dai),
66};
67
68static int snd_rpi_rpi_dac_probe(struct platform_device *pdev)
69{
70 int ret = 0;
71
72 snd_rpi_rpi_dac.dev = &pdev->dev;
73
74 if (pdev->dev.of_node) {
75 struct device_node *i2s_node;
76 struct snd_soc_dai_link *dai = &snd_rpi_rpi_dac_dai[0];
77 i2s_node = of_parse_phandle(pdev->dev.of_node, "i2s-controller", 0);
78
79 if (i2s_node) {
80 dai->cpu_dai_name = NULL;
81 dai->cpu_of_node = i2s_node;
82 dai->platform_name = NULL;
83 dai->platform_of_node = i2s_node;
84 }
85 }
86
87 ret = snd_soc_register_card(&snd_rpi_rpi_dac);
49dbf1af 88 if (ret && ret != -EPROBE_DEFER)
d268c871
FM
89 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
90
91 return ret;
92}
93
94static int snd_rpi_rpi_dac_remove(struct platform_device *pdev)
95{
96 return snd_soc_unregister_card(&snd_rpi_rpi_dac);
97}
98
99static const struct of_device_id snd_rpi_rpi_dac_of_match[] = {
100 { .compatible = "rpi,rpi-dac", },
101 {},
102};
103MODULE_DEVICE_TABLE(of, snd_rpi_rpi_dac_of_match);
104
105static struct platform_driver snd_rpi_rpi_dac_driver = {
106 .driver = {
107 .name = "snd-rpi-dac",
108 .owner = THIS_MODULE,
109 .of_match_table = snd_rpi_rpi_dac_of_match,
110 },
111 .probe = snd_rpi_rpi_dac_probe,
112 .remove = snd_rpi_rpi_dac_remove,
113};
114
115module_platform_driver(snd_rpi_rpi_dac_driver);
116
117MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>");
118MODULE_DESCRIPTION("ASoC Driver for RPi-DAC");
119MODULE_LICENSE("GPL v2");