aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/bcm/hifiberry_dacplusdsp.c
blob: cda7ee519093095348d02d6d6438cba203727369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// SPDX-License-Identifier: GPL-2.0
/*
 * ASoC Driver for HiFiBerry DAC + DSP
 *
 * Author:	Joerg Schambacher <joscha@schambacher.com>
 *		Copyright 2018
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <sound/soc.h>

static struct snd_soc_component_driver dacplusdsp_component_driver;

static struct snd_soc_dai_driver dacplusdsp_dai = {
	.name = "dacplusdsp-hifi",
	.capture = {
		.stream_name = "DAC+DSP Capture",
		.channels_min = 2,
		.channels_max = 2,
		.rates = SNDRV_PCM_RATE_CONTINUOUS,
		.formats = SNDRV_PCM_FMTBIT_S16_LE |
			   SNDRV_PCM_FMTBIT_S24_LE |
			   SNDRV_PCM_FMTBIT_S32_LE,
	},
	.playback = {
		.stream_name = "DACP+DSP Playback",
		.channels_min = 2,
		.channels_max = 2,
		.rates = SNDRV_PCM_RATE_CONTINUOUS,
		.formats = SNDRV_PCM_FMTBIT_S16_LE |
			   SNDRV_PCM_FMTBIT_S24_LE |
			   SNDRV_PCM_FMTBIT_S32_LE,
	},
	.symmetric_rates = 1};

#ifdef CONFIG_OF
static const struct of_device_id dacplusdsp_ids[] = {
	{
		.compatible = "hifiberry,dacplusdsp",
	},
	{} };
MODULE_DEVICE_TABLE(of, dacplusdsp_ids);
#endif

static int dacplusdsp_platform_probe(struct platform_device *pdev)
{
	int ret;

	ret = snd_soc_register_component(&pdev->dev,
			&dacplusdsp_component_driver, &dacplusdsp_dai, 1);
	if (ret) {
		pr_alert("snd_soc_register_component failed\n");
		return ret;
	}

	return 0;
}

static int dacplusdsp_platform_remove(struct platform_device *pdev)
{
	snd_soc_unregister_component(&pdev->dev);
	return 0;
}

static struct platform_driver dacplusdsp_driver = {
	.driver = {
		.name = "hifiberry-dacplusdsp-codec",
		.of_match_table = of_match_ptr(dacplusdsp_ids),
		},
		.probe = dacplusdsp_platform_probe,
		.remove = dacplusdsp_platform_remove,
};

module_platform_driver(dacplusdsp_driver);

MODULE_AUTHOR("Joerg Schambacher <joerg@i2audio.com>");
MODULE_DESCRIPTION("ASoC Driver for HiFiBerry DAC+DSP");
MODULE_LICENSE("GPL v2");