-
Notifications
You must be signed in to change notification settings - Fork 6
/
sample-device.c
95 lines (75 loc) · 1.92 KB
/
sample-device.c
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
91
92
93
94
95
#include <linux/module.h>
#include <linux/platform_device.h>
#include "sample-core.h"
static struct platform_device *pdev_i2s;
static struct platform_device *pdev_spdif;
static struct platform_device *pdev_i2s_spdif;
static int __init snd_sample_device_init(void)
{
int ret;
/* Add sample I2S device */
pdev_i2s = platform_device_alloc(SND_SAMPLE_DRV_NAME "-i2s", 0);
if (pdev_i2s == NULL) {
ret = -ENOMEM;
goto err_out;
}
ret = platform_device_add(pdev_i2s);
if (ret != 0) {
ret = -ENOMEM;
goto err_out_i2s;
}
dev_info(&pdev_i2s->dev, "created.\n");
/*
* Add SPDIF CODEC.
*
* NOTE: You should enable the CONFIG_SND_SOC_SPDIF to build
* SPDIF CODEC driver.
* And insmod or modprobe 'snd-soc-spdif-rx.ko' module.
*/
pdev_spdif = platform_device_alloc("spdif-dit", 0);
if (pdev_spdif == NULL) {
ret = -ENOMEM;
goto err_out_i2s;
}
ret = platform_device_add(pdev_spdif);
if (ret != 0) {
ret = -ENOMEM;
goto err_out_spdif;
}
dev_info(&pdev_spdif->dev, "created.\n");
/* Add sample ASoC card */
pdev_i2s_spdif = platform_device_alloc(
SND_SAMPLE_DRV_NAME "-i2s-spdif", 0);
if (pdev_i2s_spdif == NULL) {
ret = -ENOMEM;
goto err_out_spdif;
}
ret = platform_device_add(pdev_i2s_spdif);
if (ret != 0) {
ret = -ENOMEM;
goto err_out_i2s_spdif;
}
dev_info(&pdev_i2s_spdif->dev, "created.\n");
pr_info("loaded.\n");
return 0;
err_out_i2s_spdif:
platform_device_del(pdev_i2s_spdif);
err_out_spdif:
platform_device_del(pdev_spdif);
err_out_i2s:
platform_device_del(pdev_i2s);
err_out:
return ret;
}
static void __exit snd_sample_device_exit(void)
{
platform_device_del(pdev_i2s_spdif);
platform_device_del(pdev_spdif);
platform_device_del(pdev_i2s);
pr_info("unloaded.\n");
}
module_init(snd_sample_device_init);
module_exit(snd_sample_device_exit);
MODULE_AUTHOR("Katsuhiro Suzuki <[email protected]>");
MODULE_DESCRIPTION("Sample ALSA SoC device");
MODULE_LICENSE("GPL");