Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
a065050a
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
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看板
提交
a065050a
编写于
8月 22, 2013
作者:
M
Mark Brown
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'asoc/topic/lm4857' into asoc-next
上级
54c1e27d
9b270968
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
76 deletion
+31
-76
sound/soc/codecs/lm4857.c
sound/soc/codecs/lm4857.c
+31
-76
未找到文件。
sound/soc/codecs/lm4857.c
浏览文件 @
a065050a
...
...
@@ -16,6 +16,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h>
...
...
@@ -23,12 +24,15 @@
#include <sound/tlv.h>
struct
lm4857
{
struct
i2c_client
*
i2c
;
struct
regmap
*
regmap
;
uint8_t
mode
;
};
static
const
uint8_t
lm4857_default_regs
[]
=
{
0x00
,
0x00
,
0x00
,
0x00
,
static
const
struct
reg_default
lm4857_default_regs
[]
=
{
{
0x0
,
0x00
},
{
0x1
,
0x00
},
{
0x2
,
0x00
},
{
0x3
,
0x00
},
};
/* The register offsets in the cache array */
...
...
@@ -42,39 +46,6 @@ static const uint8_t lm4857_default_regs[] = {
#define LM4857_WAKEUP 5
#define LM4857_EPGAIN 4
static
int
lm4857_write
(
struct
snd_soc_codec
*
codec
,
unsigned
int
reg
,
unsigned
int
value
)
{
uint8_t
data
;
int
ret
;
ret
=
snd_soc_cache_write
(
codec
,
reg
,
value
);
if
(
ret
<
0
)
return
ret
;
data
=
(
reg
<<
6
)
|
value
;
ret
=
i2c_master_send
(
codec
->
control_data
,
&
data
,
1
);
if
(
ret
!=
1
)
{
dev_err
(
codec
->
dev
,
"Failed to write register: %d
\n
"
,
ret
);
return
ret
;
}
return
0
;
}
static
unsigned
int
lm4857_read
(
struct
snd_soc_codec
*
codec
,
unsigned
int
reg
)
{
unsigned
int
val
;
int
ret
;
ret
=
snd_soc_cache_read
(
codec
,
reg
,
&
val
);
if
(
ret
)
return
-
1
;
return
val
;
}
static
int
lm4857_get_mode
(
struct
snd_kcontrol
*
kcontrol
,
struct
snd_ctl_elem_value
*
ucontrol
)
{
...
...
@@ -96,7 +67,7 @@ static int lm4857_set_mode(struct snd_kcontrol *kcontrol,
lm4857
->
mode
=
value
;
if
(
codec
->
dapm
.
bias_level
==
SND_SOC_BIAS_ON
)
snd_soc_update_bits
(
codec
,
LM4857_CTRL
,
0x0F
,
value
+
6
);
regmap_update_bits
(
lm4857
->
regmap
,
LM4857_CTRL
,
0x0F
,
value
+
6
);
return
1
;
}
...
...
@@ -108,10 +79,11 @@ static int lm4857_set_bias_level(struct snd_soc_codec *codec,
switch
(
level
)
{
case
SND_SOC_BIAS_ON
:
snd_soc_update_bits
(
codec
,
LM4857_CTRL
,
0x0F
,
lm4857
->
mode
+
6
);
regmap_update_bits
(
lm4857
->
regmap
,
LM4857_CTRL
,
0x0F
,
lm4857
->
mode
+
6
);
break
;
case
SND_SOC_BIAS_STANDBY
:
snd_soc_update_bits
(
codec
,
LM4857_CTRL
,
0x0F
,
0
);
regmap_update_bits
(
lm4857
->
regmap
,
LM4857_CTRL
,
0x0F
,
0
);
break
;
default:
break
;
...
...
@@ -171,49 +143,32 @@ static const struct snd_soc_dapm_route lm4857_routes[] = {
{
"EP"
,
NULL
,
"IN"
},
};
static
int
lm4857_probe
(
struct
snd_soc_codec
*
codec
)
{
struct
lm4857
*
lm4857
=
snd_soc_codec_get_drvdata
(
codec
);
struct
snd_soc_dapm_context
*
dapm
=
&
codec
->
dapm
;
int
ret
;
codec
->
control_data
=
lm4857
->
i2c
;
ret
=
snd_soc_add_codec_controls
(
codec
,
lm4857_controls
,
ARRAY_SIZE
(
lm4857_controls
));
if
(
ret
)
return
ret
;
ret
=
snd_soc_dapm_new_controls
(
dapm
,
lm4857_dapm_widgets
,
ARRAY_SIZE
(
lm4857_dapm_widgets
));
if
(
ret
)
return
ret
;
static
struct
snd_soc_codec_driver
soc_codec_dev_lm4857
=
{
.
set_bias_level
=
lm4857_set_bias_level
,
ret
=
snd_soc_dapm_add_routes
(
dapm
,
lm4857_routes
,
ARRAY_SIZE
(
lm4857_routes
));
if
(
ret
)
return
ret
;
.
controls
=
lm4857_controls
,
.
num_controls
=
ARRAY_SIZE
(
lm4857_controls
),
.
dapm_widgets
=
lm4857_dapm_widgets
,
.
num_dapm_widgets
=
ARRAY_SIZE
(
lm4857_dapm_widgets
),
.
dapm_routes
=
lm4857_routes
,
.
num_dapm_routes
=
ARRAY_SIZE
(
lm4857_routes
),
};
snd_soc_dapm_new_widgets
(
dapm
);
static
const
struct
regmap_config
lm4857_regmap_config
=
{
.
val_bits
=
6
,
.
reg_bits
=
2
,
return
0
;
}
.
max_register
=
LM4857_CTRL
,
static
struct
snd_soc_codec_driver
soc_codec_dev_lm4857
=
{
.
write
=
lm4857_write
,
.
read
=
lm4857_read
,
.
probe
=
lm4857_probe
,
.
reg_cache_size
=
ARRAY_SIZE
(
lm4857_default_regs
),
.
reg_word_size
=
sizeof
(
uint8_t
),
.
reg_cache_default
=
lm4857_default_regs
,
.
set_bias_level
=
lm4857_set_bias_level
,
.
cache_type
=
REGCACHE_FLAT
,
.
reg_defaults
=
lm4857_default_regs
,
.
num_reg_defaults
=
ARRAY_SIZE
(
lm4857_default_regs
),
};
static
int
lm4857_i2c_probe
(
struct
i2c_client
*
i2c
,
const
struct
i2c_device_id
*
id
)
{
struct
lm4857
*
lm4857
;
int
ret
;
lm4857
=
devm_kzalloc
(
&
i2c
->
dev
,
sizeof
(
*
lm4857
),
GFP_KERNEL
);
if
(
!
lm4857
)
...
...
@@ -221,11 +176,11 @@ static int lm4857_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata
(
i2c
,
lm4857
);
lm4857
->
i2c
=
i2c
;
ret
=
snd_soc_register_codec
(
&
i2c
->
dev
,
&
soc_codec_dev_lm4857
,
NULL
,
0
);
lm4857
->
regmap
=
devm_regmap_init_i2c
(
i2c
,
&
lm4857_regmap_config
)
;
if
(
IS_ERR
(
lm4857
->
regmap
))
return
PTR_ERR
(
lm4857
->
regmap
);
return
ret
;
return
snd_soc_register_codec
(
&
i2c
->
dev
,
&
soc_codec_dev_lm4857
,
NULL
,
0
)
;
}
static
int
lm4857_i2c_remove
(
struct
i2c_client
*
i2c
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录