]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - sound/soc/bcm/hifiberry_amp.c
sound: Suppress error message about deferrals
[mirror_ubuntu-zesty-kernel.git] / sound / soc / bcm / hifiberry_amp.c
CommitLineData
5377f81c
DM
1/*
2 * ASoC Driver for HifiBerry AMP
3 *
4 * Author: Sebastian Eickhoff <basti.eickhoff@googlemail.com>
5 * Copyright 2014
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_hifiberry_amp_init(struct snd_soc_pcm_runtime *rtd)
27{
28 // ToDo: init of the dsp-registers.
29 return 0;
30}
31
32static int snd_rpi_hifiberry_amp_hw_params( struct snd_pcm_substream *substream,
33 struct snd_pcm_hw_params *params )
34{
35 struct snd_soc_pcm_runtime *rtd = substream->private_data;
36 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
37
38 return snd_soc_dai_set_bclk_ratio(cpu_dai, 64);
39}
40
41static struct snd_soc_ops snd_rpi_hifiberry_amp_ops = {
42 .hw_params = snd_rpi_hifiberry_amp_hw_params,
43};
44
45static struct snd_soc_dai_link snd_rpi_hifiberry_amp_dai[] = {
46 {
47 .name = "HifiBerry AMP",
48 .stream_name = "HifiBerry AMP HiFi",
49 .cpu_dai_name = "bcm2708-i2s.0",
50 .codec_dai_name = "tas5713-hifi",
51 .platform_name = "bcm2708-i2s.0",
52 .codec_name = "tas5713.1-001b",
53 .dai_fmt = SND_SOC_DAIFMT_I2S |
54 SND_SOC_DAIFMT_NB_NF |
55 SND_SOC_DAIFMT_CBS_CFS,
56 .ops = &snd_rpi_hifiberry_amp_ops,
57 .init = snd_rpi_hifiberry_amp_init,
58 },
59};
60
61
62static struct snd_soc_card snd_rpi_hifiberry_amp = {
63 .name = "snd_rpi_hifiberry_amp",
64 .driver_name = "HifiberryAmp",
65 .owner = THIS_MODULE,
66 .dai_link = snd_rpi_hifiberry_amp_dai,
67 .num_links = ARRAY_SIZE(snd_rpi_hifiberry_amp_dai),
68};
69
70static const struct of_device_id snd_rpi_hifiberry_amp_of_match[] = {
71 { .compatible = "hifiberry,hifiberry-amp", },
72 {},
73};
74MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_amp_of_match);
75
76
77static int snd_rpi_hifiberry_amp_probe(struct platform_device *pdev)
78{
79 int ret = 0;
80
81 snd_rpi_hifiberry_amp.dev = &pdev->dev;
82
83 if (pdev->dev.of_node) {
84 struct device_node *i2s_node;
85 struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_amp_dai[0];
86 i2s_node = of_parse_phandle(pdev->dev.of_node,
87 "i2s-controller", 0);
88
89 if (i2s_node) {
90 dai->cpu_dai_name = NULL;
91 dai->cpu_of_node = i2s_node;
92 dai->platform_name = NULL;
93 dai->platform_of_node = i2s_node;
94 }
95 }
96
97 ret = snd_soc_register_card(&snd_rpi_hifiberry_amp);
98
49dbf1af 99 if (ret && ret != -EPROBE_DEFER)
5377f81c 100 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
5377f81c
DM
101
102 return ret;
103}
104
105
106static int snd_rpi_hifiberry_amp_remove(struct platform_device *pdev)
107{
108 return snd_soc_unregister_card(&snd_rpi_hifiberry_amp);
109}
110
111
112static struct platform_driver snd_rpi_hifiberry_amp_driver = {
113 .driver = {
114 .name = "snd-hifiberry-amp",
115 .owner = THIS_MODULE,
116 .of_match_table = snd_rpi_hifiberry_amp_of_match,
117 },
118 .probe = snd_rpi_hifiberry_amp_probe,
119 .remove = snd_rpi_hifiberry_amp_remove,
120};
121
122
123module_platform_driver(snd_rpi_hifiberry_amp_driver);
124
125
126MODULE_AUTHOR("Sebastian Eickhoff <basti.eickhoff@googlemail.com>");
127MODULE_DESCRIPTION("ASoC driver for HiFiBerry-AMP");
128MODULE_LICENSE("GPL v2");