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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
/*++
* linux/sound/soc/codecs/wmt_hwdac.c
* WonderMedia I2S audio driver for ALSA
*
* Copyright c 2010 WonderMedia Technologies, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* WonderMedia Technologies, Inc.
* 4F, 533, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C
--*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/initval.h>
/*
* Debug
*/
#define AUDIO_NAME "HW_DAC"
//#define WMT_HWDAC_DEBUG 1
//#define WMT_HWDAC_DEBUG_DETAIL 1
#ifdef WMT_HWDAC_DEBUG
#define DPRINTK(format, arg...) \
printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
#else
#define DPRINTK(format, arg...) do {} while (0)
#endif
#ifdef WMT_HWDAC_DEBUG_DETAIL
#define DBG_DETAIL(format, arg...) \
printk(KERN_INFO AUDIO_NAME ": [%s]" format "\n" , __FUNCTION__, ## arg)
#else
#define DBG_DETAIL(format, arg...) do {} while (0)
#endif
#define err(format, arg...) \
printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
#define info(format, arg...) \
printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
#define warn(format, arg...) \
printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)
extern int wmt_getsyspara(char *varname, unsigned char *varval, int *varlen);
static int hwdac_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{
DBG_DETAIL();
return 0;
}
#define HWDAC_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | \
SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | \
SNDRV_PCM_RATE_96000)
#define HWDAC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_FLOAT)
static struct snd_soc_dai_ops hwdac_dai_ops = {
.hw_params = hwdac_pcm_hw_params,
};
struct snd_soc_dai_driver hwdac_dai = {
.name = "HWDAC",
.playback = {
.stream_name = "Playback",
.channels_min = 1,
.channels_max = 2,
.rates = HWDAC_RATES,
.formats = HWDAC_FORMATS,
},
.capture = {
.stream_name = "Capture",
.channels_min = 1,
.channels_max = 2,
.rates = HWDAC_RATES,
.formats = HWDAC_FORMATS,
},
.ops = &hwdac_dai_ops,
};
static int hwdac_probe(struct snd_soc_codec *codec)
{
DBG_DETAIL();
return 0;
}
/* remove everything here */
static int hwdac_remove(struct snd_soc_codec *codec)
{
DBG_DETAIL();
return 0;
}
struct snd_soc_codec_driver soc_codec_dev_hwdac = {
.probe = hwdac_probe,
.remove = hwdac_remove,
};
static int __devinit hwdac_platform_probe(struct platform_device *pdev)
{
int ret = 0;
DBG_DETAIL();
ret = snd_soc_register_codec(&pdev->dev,
&soc_codec_dev_hwdac, &hwdac_dai, 1);
if (ret)
info("snd_soc_register_codec fail");
return ret;
}
static int __devexit hwdac_platform_remove(struct platform_device *pdev)
{
DBG_DETAIL();
snd_soc_unregister_codec(&pdev->dev);
return 0;
}
static struct platform_driver wmt_hwdac_driver = {
.driver = {
.name = "wmt-i2s-hwdac",
.owner = THIS_MODULE,
},
.probe = hwdac_platform_probe,
.remove = __devexit_p(hwdac_platform_remove),
};
static int __init wmt_hwdac_platform_init(void)
{
char buf[80];
int varlen = 80;
char codec_name[5];
int ret = 0;
DBG_DETAIL();
/*ret = wmt_getsyspara("wmt.audio.i2s", buf, &varlen);
if (ret == 0) {
sscanf(buf, "%5s", codec_name);
if (strcmp(codec_name, "hwdac")) {
info("hwdac string not found");
return -EINVAL;
}
}*/
return platform_driver_register(&wmt_hwdac_driver);
}
module_init(wmt_hwdac_platform_init);
static void __exit wmt_hwdac_platform_exit(void)
{
DBG_DETAIL();
platform_driver_unregister(&wmt_hwdac_driver);
}
module_exit(wmt_hwdac_platform_exit);
MODULE_DESCRIPTION("WMT [ALSA SoC] driver");
MODULE_AUTHOR("WonderMedia Technologies, Inc.");
MODULE_LICENSE("GPL");
|