2 * ASoC Driver for HifiBerry AMP
4 * Author: Sebastian Eickhoff <basti.eickhoff@googlemail.com>
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.
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.
17 #include <linux/module.h>
18 #include <linux/platform_device.h>
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>
26 static int snd_rpi_hifiberry_amp_init(struct snd_soc_pcm_runtime
*rtd
)
28 // ToDo: init of the dsp-registers.
32 static int snd_rpi_hifiberry_amp_hw_params( struct snd_pcm_substream
*substream
,
33 struct snd_pcm_hw_params
*params
)
35 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
36 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
38 return snd_soc_dai_set_bclk_ratio(cpu_dai
, 64);
41 static struct snd_soc_ops snd_rpi_hifiberry_amp_ops
= {
42 .hw_params
= snd_rpi_hifiberry_amp_hw_params
,
45 static struct snd_soc_dai_link snd_rpi_hifiberry_amp_dai
[] = {
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
,
62 static struct snd_soc_card snd_rpi_hifiberry_amp
= {
63 .name
= "snd_rpi_hifiberry_amp",
64 .driver_name
= "HifiberryAmp",
66 .dai_link
= snd_rpi_hifiberry_amp_dai
,
67 .num_links
= ARRAY_SIZE(snd_rpi_hifiberry_amp_dai
),
70 static const struct of_device_id snd_rpi_hifiberry_amp_of_match
[] = {
71 { .compatible
= "hifiberry,hifiberry-amp", },
74 MODULE_DEVICE_TABLE(of
, snd_rpi_hifiberry_amp_of_match
);
77 static int snd_rpi_hifiberry_amp_probe(struct platform_device
*pdev
)
81 snd_rpi_hifiberry_amp
.dev
= &pdev
->dev
;
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
,
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
;
97 ret
= snd_soc_register_card(&snd_rpi_hifiberry_amp
);
100 dev_err(&pdev
->dev
, "snd_soc_register_card() failed: %d\n", ret
);
107 static int snd_rpi_hifiberry_amp_remove(struct platform_device
*pdev
)
109 return snd_soc_unregister_card(&snd_rpi_hifiberry_amp
);
113 static struct platform_driver snd_rpi_hifiberry_amp_driver
= {
115 .name
= "snd-hifiberry-amp",
116 .owner
= THIS_MODULE
,
117 .of_match_table
= snd_rpi_hifiberry_amp_of_match
,
119 .probe
= snd_rpi_hifiberry_amp_probe
,
120 .remove
= snd_rpi_hifiberry_amp_remove
,
124 module_platform_driver(snd_rpi_hifiberry_amp_driver
);
127 MODULE_AUTHOR("Sebastian Eickhoff <basti.eickhoff@googlemail.com>");
128 MODULE_DESCRIPTION("ASoC driver for HiFiBerry-AMP");
129 MODULE_LICENSE("GPL v2");