Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
fe98c0cf
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 1 年 前同步成功
通知
158
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,发现更多精彩内容 >>
提交
fe98c0cf
编写于
9月 10, 2012
作者:
M
Mark Brown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ASoC: wm8741: Convert to direct regmap API usage
Signed-off-by:
N
Mark Brown
<
broonie@opensource.wolfsonmicro.com
>
上级
d9780550
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
24 deletion
+62
-24
sound/soc/codecs/wm8741.c
sound/soc/codecs/wm8741.c
+62
-24
未找到文件。
sound/soc/codecs/wm8741.c
浏览文件 @
fe98c0cf
...
...
@@ -18,6 +18,7 @@
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/spi/spi.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/of_device.h>
...
...
@@ -40,26 +41,43 @@ static const char *wm8741_supply_names[WM8741_NUM_SUPPLIES] = {
/* codec private data */
struct
wm8741_priv
{
enum
snd_soc_control_type
control_type
;
struct
regmap
*
regmap
;
struct
regulator_bulk_data
supplies
[
WM8741_NUM_SUPPLIES
];
unsigned
int
sysclk
;
struct
snd_pcm_hw_constraint_list
*
sysclk_constraints
;
};
static
const
u16
wm8741_reg_defaults
[
WM8741_REGISTER_COUNT
]
=
{
0x0000
,
/* R0 - DACLLSB Attenuation */
0x0000
,
/* R1 - DACLMSB Attenuation */
0x0000
,
/* R2 - DACRLSB Attenuation */
0x0000
,
/* R3 - DACRMSB Attenuation */
0x0000
,
/* R4 - Volume Control */
0x000A
,
/* R5 - Format Control */
0x0000
,
/* R6 - Filter Control */
0x0000
,
/* R7 - Mode Control 1 */
0x0002
,
/* R8 - Mode Control 2 */
0x0000
,
/* R9 - Reset */
0x0002
,
/* R32 - ADDITONAL_CONTROL_1 */
static
const
struct
reg_default
wm8741_reg_defaults
[]
=
{
{
0
,
0x0000
},
/* R0 - DACLLSB Attenuation */
{
1
,
0x0000
},
/* R1 - DACLMSB Attenuation */
{
2
,
0x0000
},
/* R2 - DACRLSB Attenuation */
{
3
,
0x0000
},
/* R3 - DACRMSB Attenuation */
{
4
,
0x0000
},
/* R4 - Volume Control */
{
5
,
0x000A
},
/* R5 - Format Control */
{
6
,
0x0000
},
/* R6 - Filter Control */
{
7
,
0x0000
},
/* R7 - Mode Control 1 */
{
8
,
0x0002
},
/* R8 - Mode Control 2 */
{
32
,
0x0002
},
/* R32 - ADDITONAL_CONTROL_1 */
};
static
bool
wm8741_readable
(
struct
device
*
dev
,
unsigned
int
reg
)
{
switch
(
reg
)
{
case
WM8741_DACLLSB_ATTENUATION
:
case
WM8741_DACLMSB_ATTENUATION
:
case
WM8741_DACRLSB_ATTENUATION
:
case
WM8741_DACRMSB_ATTENUATION
:
case
WM8741_VOLUME_CONTROL
:
case
WM8741_FORMAT_CONTROL
:
case
WM8741_FILTER_CONTROL
:
case
WM8741_MODE_CONTROL_1
:
case
WM8741_MODE_CONTROL_2
:
case
WM8741_ADDITIONAL_CONTROL_1
:
return
true
;
default:
return
false
;
}
}
static
int
wm8741_reset
(
struct
snd_soc_codec
*
codec
)
{
...
...
@@ -411,7 +429,7 @@ static int wm8741_probe(struct snd_soc_codec *codec)
goto
err_get
;
}
ret
=
snd_soc_codec_set_cache_io
(
codec
,
7
,
9
,
wm8741
->
control_type
);
ret
=
snd_soc_codec_set_cache_io
(
codec
,
7
,
9
,
SND_SOC_REGMAP
);
if
(
ret
!=
0
)
{
dev_err
(
codec
->
dev
,
"Failed to set cache I/O: %d
\n
"
,
ret
);
goto
err_enable
;
...
...
@@ -439,7 +457,6 @@ static int wm8741_probe(struct snd_soc_codec *codec)
err_enable:
regulator_bulk_disable
(
ARRAY_SIZE
(
wm8741
->
supplies
),
wm8741
->
supplies
);
err_get:
err:
return
ret
;
}
...
...
@@ -456,9 +473,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8741 = {
.
probe
=
wm8741_probe
,
.
remove
=
wm8741_remove
,
.
resume
=
wm8741_resume
,
.
reg_cache_size
=
ARRAY_SIZE
(
wm8741_reg_defaults
),
.
reg_word_size
=
sizeof
(
u16
),
.
reg_cache_default
=
wm8741_reg_defaults
,
.
controls
=
wm8741_snd_controls
,
.
num_controls
=
ARRAY_SIZE
(
wm8741_snd_controls
),
...
...
@@ -474,6 +488,18 @@ static const struct of_device_id wm8741_of_match[] = {
};
MODULE_DEVICE_TABLE
(
of
,
wm8741_of_match
);
static
const
struct
regmap_config
wm8741_regmap
=
{
.
reg_bits
=
7
,
.
val_bits
=
9
,
.
max_register
=
WM8741_MAX_REGISTER
,
.
reg_defaults
=
wm8741_reg_defaults
,
.
num_reg_defaults
=
ARRAY_SIZE
(
wm8741_reg_defaults
),
.
cache_type
=
REGCACHE_RBTREE
,
.
readable_reg
=
wm8741_readable
,
};
#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
static
int
wm8741_i2c_probe
(
struct
i2c_client
*
i2c
,
const
struct
i2c_device_id
*
id
)
...
...
@@ -492,12 +518,18 @@ static int wm8741_i2c_probe(struct i2c_client *i2c,
ret
=
devm_regulator_bulk_get
(
&
i2c
->
dev
,
ARRAY_SIZE
(
wm8741
->
supplies
),
wm8741
->
supplies
);
if
(
ret
!=
0
)
{
dev_err
(
codec
->
dev
,
"Failed to request supplies: %d
\n
"
,
ret
);
goto
err
;
dev_err
(
&
i2c
->
dev
,
"Failed to request supplies: %d
\n
"
,
ret
);
return
ret
;
}
wm8741
->
regmap
=
regmap_init_i2c
(
i2c
,
&
wm8741_regmap
);
if
(
IS_ERR
(
wm8741
->
regmap
))
{
ret
=
PTR_ERR
(
wm8741
->
regmap
);
dev_err
(
&
i2c
->
dev
,
"Failed to init regmap: %d
\n
"
,
ret
);
return
ret
;
}
i2c_set_clientdata
(
i2c
,
wm8741
);
wm8741
->
control_type
=
SND_SOC_I2C
;
ret
=
snd_soc_register_codec
(
&
i2c
->
dev
,
&
soc_codec_dev_wm8741
,
&
wm8741_dai
,
1
);
...
...
@@ -543,14 +575,20 @@ static int __devinit wm8741_spi_probe(struct spi_device *spi)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
wm8741
->
supplies
);
i
++
)
wm8741
->
supplies
[
i
].
supply
=
wm8741_supply_names
[
i
];
ret
=
devm_regulator_bulk_get
(
&
i2c
->
dev
,
ARRAY_SIZE
(
wm8741
->
supplies
),
ret
=
devm_regulator_bulk_get
(
&
spi
->
dev
,
ARRAY_SIZE
(
wm8741
->
supplies
),
wm8741
->
supplies
);
if
(
ret
!=
0
)
{
dev_err
(
&
spi
->
dev
,
"Failed to request supplies: %d
\n
"
,
ret
);
goto
err
;
return
ret
;
}
wm8741
->
regmap
=
regmap_init_spi
(
spi
,
&
wm8741_regmap
);
if
(
IS_ERR
(
wm8741
->
regmap
))
{
ret
=
PTR_ERR
(
wm8741
->
regmap
);
dev_err
(
&
spi
->
dev
,
"Failed to init regmap: %d
\n
"
,
ret
);
return
ret
;
}
wm8741
->
control_type
=
SND_SOC_SPI
;
spi_set_drvdata
(
spi
,
wm8741
);
ret
=
snd_soc_register_codec
(
&
spi
->
dev
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录