diff options
-rw-r--r-- | include/sound/simple_card.h | 38 | ||||
-rw-r--r-- | sound/soc/Kconfig | 3 | ||||
-rw-r--r-- | sound/soc/Makefile | 1 | ||||
-rw-r--r-- | sound/soc/generic/Kconfig | 4 | ||||
-rw-r--r-- | sound/soc/generic/Makefile | 3 | ||||
-rw-r--r-- | sound/soc/generic/simple-card.c | 114 |
6 files changed, 163 insertions, 0 deletions
diff --git a/include/sound/simple_card.h b/include/sound/simple_card.h new file mode 100644 index 000000000000..4b62b8dc6a4f --- /dev/null +++ b/include/sound/simple_card.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * ASoC simple sound card support | ||
3 | * | ||
4 | * Copyright (C) 2012 Renesas Solutions Corp. | ||
5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef __SIMPLE_CARD_H | ||
13 | #define __SIMPLE_CARD_H | ||
14 | |||
15 | #include <sound/soc.h> | ||
16 | |||
17 | struct asoc_simple_dai_init_info { | ||
18 | unsigned int fmt; | ||
19 | unsigned int cpu_daifmt; | ||
20 | unsigned int codec_daifmt; | ||
21 | unsigned int sysclk; | ||
22 | }; | ||
23 | |||
24 | struct asoc_simple_card_info { | ||
25 | const char *name; | ||
26 | const char *card; | ||
27 | const char *cpu_dai; | ||
28 | const char *codec; | ||
29 | const char *platform; | ||
30 | const char *codec_dai; | ||
31 | struct asoc_simple_dai_init_info *init; /* for snd_link.init */ | ||
32 | |||
33 | /* used in simple-card.c */ | ||
34 | struct snd_soc_dai_link snd_link; | ||
35 | struct snd_soc_card snd_card; | ||
36 | }; | ||
37 | |||
38 | #endif /* __SIMPLE_CARD_H */ | ||
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 0f85f6d526e0..a7df779894d5 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig | |||
@@ -51,5 +51,8 @@ source "sound/soc/txx9/Kconfig" | |||
51 | # Supported codecs | 51 | # Supported codecs |
52 | source "sound/soc/codecs/Kconfig" | 52 | source "sound/soc/codecs/Kconfig" |
53 | 53 | ||
54 | # generic frame-work | ||
55 | source "sound/soc/generic/Kconfig" | ||
56 | |||
54 | endif # SND_SOC | 57 | endif # SND_SOC |
55 | 58 | ||
diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 363dfd6cffe7..57d3463ce9d6 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile | |||
@@ -6,6 +6,7 @@ obj-$(CONFIG_SND_SOC_DMAENGINE_PCM) += snd-soc-dmaengine-pcm.o | |||
6 | 6 | ||
7 | obj-$(CONFIG_SND_SOC) += snd-soc-core.o | 7 | obj-$(CONFIG_SND_SOC) += snd-soc-core.o |
8 | obj-$(CONFIG_SND_SOC) += codecs/ | 8 | obj-$(CONFIG_SND_SOC) += codecs/ |
9 | obj-$(CONFIG_SND_SOC) += generic/ | ||
9 | obj-$(CONFIG_SND_SOC) += atmel/ | 10 | obj-$(CONFIG_SND_SOC) += atmel/ |
10 | obj-$(CONFIG_SND_SOC) += au1x/ | 11 | obj-$(CONFIG_SND_SOC) += au1x/ |
11 | obj-$(CONFIG_SND_SOC) += blackfin/ | 12 | obj-$(CONFIG_SND_SOC) += blackfin/ |
diff --git a/sound/soc/generic/Kconfig b/sound/soc/generic/Kconfig new file mode 100644 index 000000000000..610f61251640 --- /dev/null +++ b/sound/soc/generic/Kconfig | |||
@@ -0,0 +1,4 @@ | |||
1 | config SND_SIMPLE_CARD | ||
2 | tristate "ASoC Simple sound card support" | ||
3 | help | ||
4 | This option enables generic simple sound card support | ||
diff --git a/sound/soc/generic/Makefile b/sound/soc/generic/Makefile new file mode 100644 index 000000000000..9c3b246792bf --- /dev/null +++ b/sound/soc/generic/Makefile | |||
@@ -0,0 +1,3 @@ | |||
1 | snd-soc-simple-card-objs := simple-card.o | ||
2 | |||
3 | obj-$(CONFIG_SND_SIMPLE_CARD) += snd-soc-simple-card.o | ||
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c new file mode 100644 index 000000000000..b4b4cab30232 --- /dev/null +++ b/sound/soc/generic/simple-card.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * ASoC simple sound card support | ||
3 | * | ||
4 | * Copyright (C) 2012 Renesas Solutions Corp. | ||
5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/platform_device.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <sound/simple_card.h> | ||
15 | |||
16 | #define asoc_simple_get_card_info(p) \ | ||
17 | container_of(p->dai_link, struct asoc_simple_card_info, snd_link) | ||
18 | |||
19 | static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) | ||
20 | { | ||
21 | struct asoc_simple_card_info *cinfo = asoc_simple_get_card_info(rtd); | ||
22 | struct asoc_simple_dai_init_info *iinfo = cinfo->init; | ||
23 | struct snd_soc_dai *codec = rtd->codec_dai; | ||
24 | struct snd_soc_dai *cpu = rtd->cpu_dai; | ||
25 | unsigned int cpu_daifmt = iinfo->fmt | iinfo->cpu_daifmt; | ||
26 | unsigned int codec_daifmt = iinfo->fmt | iinfo->codec_daifmt; | ||
27 | int ret; | ||
28 | |||
29 | if (codec_daifmt) { | ||
30 | ret = snd_soc_dai_set_fmt(codec, codec_daifmt); | ||
31 | if (ret < 0) | ||
32 | return ret; | ||
33 | } | ||
34 | |||
35 | if (iinfo->sysclk) { | ||
36 | ret = snd_soc_dai_set_sysclk(codec, 0, iinfo->sysclk, 0); | ||
37 | if (ret < 0) | ||
38 | return ret; | ||
39 | } | ||
40 | |||
41 | if (cpu_daifmt) { | ||
42 | ret = snd_soc_dai_set_fmt(cpu, cpu_daifmt); | ||
43 | if (ret < 0) | ||
44 | return ret; | ||
45 | } | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static int asoc_simple_card_probe(struct platform_device *pdev) | ||
51 | { | ||
52 | struct asoc_simple_card_info *cinfo = pdev->dev.platform_data; | ||
53 | |||
54 | if (!cinfo) { | ||
55 | dev_err(&pdev->dev, "no info for asoc-simple-card\n"); | ||
56 | return -EINVAL; | ||
57 | } | ||
58 | |||
59 | if (!cinfo->name || | ||
60 | !cinfo->card || | ||
61 | !cinfo->cpu_dai || | ||
62 | !cinfo->codec || | ||
63 | !cinfo->platform || | ||
64 | !cinfo->codec_dai) { | ||
65 | dev_err(&pdev->dev, "insufficient asoc_simple_card_info settings\n"); | ||
66 | return -EINVAL; | ||
67 | } | ||
68 | |||
69 | /* | ||
70 | * init snd_soc_dai_link | ||
71 | */ | ||
72 | cinfo->snd_link.name = cinfo->name; | ||
73 | cinfo->snd_link.stream_name = cinfo->name; | ||
74 | cinfo->snd_link.cpu_dai_name = cinfo->cpu_dai; | ||
75 | cinfo->snd_link.platform_name = cinfo->platform; | ||
76 | cinfo->snd_link.codec_name = cinfo->codec; | ||
77 | cinfo->snd_link.codec_dai_name = cinfo->codec_dai; | ||
78 | |||
79 | /* enable snd_link.init if cinfo has settings */ | ||
80 | if (cinfo->init) | ||
81 | cinfo->snd_link.init = asoc_simple_card_dai_init; | ||
82 | |||
83 | /* | ||
84 | * init snd_soc_card | ||
85 | */ | ||
86 | cinfo->snd_card.name = cinfo->card; | ||
87 | cinfo->snd_card.owner = THIS_MODULE; | ||
88 | cinfo->snd_card.dai_link = &cinfo->snd_link; | ||
89 | cinfo->snd_card.num_links = 1; | ||
90 | cinfo->snd_card.dev = &pdev->dev; | ||
91 | |||
92 | return snd_soc_register_card(&cinfo->snd_card); | ||
93 | } | ||
94 | |||
95 | static int asoc_simple_card_remove(struct platform_device *pdev) | ||
96 | { | ||
97 | struct asoc_simple_card_info *cinfo = pdev->dev.platform_data; | ||
98 | |||
99 | return snd_soc_unregister_card(&cinfo->snd_card); | ||
100 | } | ||
101 | |||
102 | static struct platform_driver asoc_simple_card = { | ||
103 | .driver = { | ||
104 | .name = "asoc-simple-card", | ||
105 | }, | ||
106 | .probe = asoc_simple_card_probe, | ||
107 | .remove = asoc_simple_card_remove, | ||
108 | }; | ||
109 | |||
110 | module_platform_driver(asoc_simple_card); | ||
111 | |||
112 | MODULE_LICENSE("GPL"); | ||
113 | MODULE_DESCRIPTION("ASoC Simple Sound Card"); | ||
114 | MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); | ||