Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
e643049d
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 1 年 前同步成功
通知
153
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e643049d
编写于
9月 12, 2012
作者:
M
Mark Brown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ASoC: wm8510: Convert to direct regmap API usage
Signed-off-by:
N
Mark Brown
<
broonie@opensource.wolfsonmicro.com
>
上级
046d4f02
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
92 addition
and
25 deletion
+92
-25
sound/soc/codecs/wm8510.c
sound/soc/codecs/wm8510.c
+92
-25
未找到文件。
sound/soc/codecs/wm8510.c
浏览文件 @
e643049d
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include <linux/spi/spi.h>
#include <linux/spi/spi.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/of_device.h>
#include <linux/of_device.h>
#include <linux/regmap.h>
#include <sound/core.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/pcm_params.h>
...
@@ -33,24 +34,75 @@
...
@@ -33,24 +34,75 @@
* We can't read the WM8510 register space when we are
* We can't read the WM8510 register space when we are
* using 2 wire for device control, so we cache them instead.
* using 2 wire for device control, so we cache them instead.
*/
*/
static
const
u16
wm8510_reg
[
WM8510_CACHEREGNUM
]
=
{
static
const
struct
reg_default
wm8510_reg_defaults
[]
=
{
0x0000
,
0x0000
,
0x0000
,
0x0000
,
{
1
,
0x0000
},
0x0050
,
0x0000
,
0x0140
,
0x0000
,
{
2
,
0x0000
},
0x0000
,
0x0000
,
0x0000
,
0x00ff
,
{
3
,
0x0000
},
0x0000
,
0x0000
,
0x0100
,
0x00ff
,
{
4
,
0x0050
},
0x0000
,
0x0000
,
0x012c
,
0x002c
,
{
5
,
0x0000
},
0x002c
,
0x002c
,
0x002c
,
0x0000
,
{
6
,
0x0140
},
0x0032
,
0x0000
,
0x0000
,
0x0000
,
{
7
,
0x0000
},
0x0000
,
0x0000
,
0x0000
,
0x0000
,
{
8
,
0x0000
},
0x0038
,
0x000b
,
0x0032
,
0x0000
,
{
9
,
0x0000
},
0x0008
,
0x000c
,
0x0093
,
0x00e9
,
{
10
,
0x0000
},
0x0000
,
0x0000
,
0x0000
,
0x0000
,
{
11
,
0x00ff
},
0x0003
,
0x0010
,
0x0000
,
0x0000
,
{
12
,
0x0000
},
0x0000
,
0x0002
,
0x0001
,
0x0000
,
{
13
,
0x0000
},
0x0000
,
0x0000
,
0x0039
,
0x0000
,
{
14
,
0x0100
},
0x0001
,
{
15
,
0x00ff
},
{
16
,
0x0000
},
{
17
,
0x0000
},
{
18
,
0x012c
},
{
19
,
0x002c
},
{
20
,
0x002c
},
{
21
,
0x002c
},
{
22
,
0x002c
},
{
23
,
0x0000
},
{
24
,
0x0032
},
{
25
,
0x0000
},
{
26
,
0x0000
},
{
27
,
0x0000
},
{
28
,
0x0000
},
{
29
,
0x0000
},
{
30
,
0x0000
},
{
31
,
0x0000
},
{
32
,
0x0038
},
{
33
,
0x000b
},
{
34
,
0x0032
},
{
35
,
0x0000
},
{
36
,
0x0008
},
{
37
,
0x000c
},
{
38
,
0x0093
},
{
39
,
0x00e9
},
{
40
,
0x0000
},
{
41
,
0x0000
},
{
42
,
0x0000
},
{
43
,
0x0000
},
{
44
,
0x0003
},
{
45
,
0x0010
},
{
46
,
0x0000
},
{
47
,
0x0000
},
{
48
,
0x0000
},
{
49
,
0x0002
},
{
50
,
0x0001
},
{
51
,
0x0000
},
{
52
,
0x0000
},
{
53
,
0x0000
},
{
54
,
0x0039
},
{
55
,
0x0000
},
{
56
,
0x0001
},
};
};
static
bool
wm8510_volatile
(
struct
device
*
dev
,
unsigned
int
reg
)
{
switch
(
reg
)
{
case
WM8510_RESET
:
return
true
;
default:
return
false
;
}
}
#define WM8510_POWER1_BIASEN 0x08
#define WM8510_POWER1_BIASEN 0x08
#define WM8510_POWER1_BUFIOEN 0x10
#define WM8510_POWER1_BUFIOEN 0x10
...
@@ -58,7 +110,7 @@ static const u16 wm8510_reg[WM8510_CACHEREGNUM] = {
...
@@ -58,7 +110,7 @@ static const u16 wm8510_reg[WM8510_CACHEREGNUM] = {
/* codec private data */
/* codec private data */
struct
wm8510_priv
{
struct
wm8510_priv
{
enum
snd_soc_control_type
control_type
;
struct
regmap
*
regmap
;
};
};
static
const
char
*
wm8510_companding
[]
=
{
"Off"
,
"NC"
,
"u-law"
,
"A-law"
};
static
const
char
*
wm8510_companding
[]
=
{
"Off"
,
"NC"
,
"u-law"
,
"A-law"
};
...
@@ -454,6 +506,7 @@ static int wm8510_mute(struct snd_soc_dai *dai, int mute)
...
@@ -454,6 +506,7 @@ static int wm8510_mute(struct snd_soc_dai *dai, int mute)
static
int
wm8510_set_bias_level
(
struct
snd_soc_codec
*
codec
,
static
int
wm8510_set_bias_level
(
struct
snd_soc_codec
*
codec
,
enum
snd_soc_bias_level
level
)
enum
snd_soc_bias_level
level
)
{
{
struct
wm8510_priv
*
wm8510
=
snd_soc_codec_get_drvdata
(
codec
);
u16
power1
=
snd_soc_read
(
codec
,
WM8510_POWER1
)
&
~
0x3
;
u16
power1
=
snd_soc_read
(
codec
,
WM8510_POWER1
)
&
~
0x3
;
switch
(
level
)
{
switch
(
level
)
{
...
@@ -467,7 +520,7 @@ static int wm8510_set_bias_level(struct snd_soc_codec *codec,
...
@@ -467,7 +520,7 @@ static int wm8510_set_bias_level(struct snd_soc_codec *codec,
power1
|=
WM8510_POWER1_BIASEN
|
WM8510_POWER1_BUFIOEN
;
power1
|=
WM8510_POWER1_BIASEN
|
WM8510_POWER1_BUFIOEN
;
if
(
codec
->
dapm
.
bias_level
==
SND_SOC_BIAS_OFF
)
{
if
(
codec
->
dapm
.
bias_level
==
SND_SOC_BIAS_OFF
)
{
snd_soc_cache_sync
(
codec
);
regcache_sync
(
wm8510
->
regmap
);
/* Initial cap charge at VMID 5k */
/* Initial cap charge at VMID 5k */
snd_soc_write
(
codec
,
WM8510_POWER1
,
power1
|
0x3
);
snd_soc_write
(
codec
,
WM8510_POWER1
,
power1
|
0x3
);
...
@@ -536,10 +589,9 @@ static int wm8510_resume(struct snd_soc_codec *codec)
...
@@ -536,10 +589,9 @@ static int wm8510_resume(struct snd_soc_codec *codec)
static
int
wm8510_probe
(
struct
snd_soc_codec
*
codec
)
static
int
wm8510_probe
(
struct
snd_soc_codec
*
codec
)
{
{
struct
wm8510_priv
*
wm8510
=
snd_soc_codec_get_drvdata
(
codec
);
int
ret
;
int
ret
;
ret
=
snd_soc_codec_set_cache_io
(
codec
,
7
,
9
,
wm8510
->
control_type
);
ret
=
snd_soc_codec_set_cache_io
(
codec
,
7
,
9
,
SND_SOC_REGMAP
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
printk
(
KERN_ERR
"wm8510: failed to set cache I/O: %d
\n
"
,
ret
);
printk
(
KERN_ERR
"wm8510: failed to set cache I/O: %d
\n
"
,
ret
);
return
ret
;
return
ret
;
...
@@ -569,9 +621,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8510 = {
...
@@ -569,9 +621,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8510 = {
.
suspend
=
wm8510_suspend
,
.
suspend
=
wm8510_suspend
,
.
resume
=
wm8510_resume
,
.
resume
=
wm8510_resume
,
.
set_bias_level
=
wm8510_set_bias_level
,
.
set_bias_level
=
wm8510_set_bias_level
,
.
reg_cache_size
=
ARRAY_SIZE
(
wm8510_reg
),
.
reg_word_size
=
sizeof
(
u16
),
.
reg_cache_default
=
wm8510_reg
,
.
controls
=
wm8510_snd_controls
,
.
controls
=
wm8510_snd_controls
,
.
num_controls
=
ARRAY_SIZE
(
wm8510_snd_controls
),
.
num_controls
=
ARRAY_SIZE
(
wm8510_snd_controls
),
...
@@ -586,6 +635,18 @@ static const struct of_device_id wm8510_of_match[] = {
...
@@ -586,6 +635,18 @@ static const struct of_device_id wm8510_of_match[] = {
{
},
{
},
};
};
static
const
struct
regmap_config
wm8510_regmap
=
{
.
reg_bits
=
7
,
.
val_bits
=
9
,
.
max_register
=
WM8510_MONOMIX
,
.
reg_defaults
=
wm8510_reg_defaults
,
.
num_reg_defaults
=
ARRAY_SIZE
(
wm8510_reg_defaults
),
.
cache_type
=
REGCACHE_RBTREE
,
.
volatile_reg
=
wm8510_volatile
,
};
#if defined(CONFIG_SPI_MASTER)
#if defined(CONFIG_SPI_MASTER)
static
int
__devinit
wm8510_spi_probe
(
struct
spi_device
*
spi
)
static
int
__devinit
wm8510_spi_probe
(
struct
spi_device
*
spi
)
{
{
...
@@ -597,7 +658,10 @@ static int __devinit wm8510_spi_probe(struct spi_device *spi)
...
@@ -597,7 +658,10 @@ static int __devinit wm8510_spi_probe(struct spi_device *spi)
if
(
wm8510
==
NULL
)
if
(
wm8510
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
wm8510
->
control_type
=
SND_SOC_SPI
;
wm8510
->
regmap
=
devm_regmap_init_spi
(
spi
,
&
wm8510_regmap
);
if
(
IS_ERR
(
wm8510
->
regmap
))
return
PTR_ERR
(
wm8510
->
regmap
);
spi_set_drvdata
(
spi
,
wm8510
);
spi_set_drvdata
(
spi
,
wm8510
);
ret
=
snd_soc_register_codec
(
&
spi
->
dev
,
ret
=
snd_soc_register_codec
(
&
spi
->
dev
,
...
@@ -635,8 +699,11 @@ static __devinit int wm8510_i2c_probe(struct i2c_client *i2c,
...
@@ -635,8 +699,11 @@ static __devinit int wm8510_i2c_probe(struct i2c_client *i2c,
if
(
wm8510
==
NULL
)
if
(
wm8510
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
wm8510
->
regmap
=
devm_regmap_init_i2c
(
i2c
,
&
wm8510_regmap
);
if
(
IS_ERR
(
wm8510
->
regmap
))
return
PTR_ERR
(
wm8510
->
regmap
);
i2c_set_clientdata
(
i2c
,
wm8510
);
i2c_set_clientdata
(
i2c
,
wm8510
);
wm8510
->
control_type
=
SND_SOC_I2C
;
ret
=
snd_soc_register_codec
(
&
i2c
->
dev
,
ret
=
snd_soc_register_codec
(
&
i2c
->
dev
,
&
soc_codec_dev_wm8510
,
&
wm8510_dai
,
1
);
&
soc_codec_dev_wm8510
,
&
wm8510_dai
,
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录