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