Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Linux-御风守护者
linux
提交
20406f9b
L
linux
项目概览
Linux-御风守护者
/
linux
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
20406f9b
编写于
5月 20, 2010
作者:
T
Takashi Iwai
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'topic/jack' into for-linus
上级
5e8aa852
ebb812cb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
73 addition
and
6 deletion
+73
-6
include/sound/jack.h
include/sound/jack.h
+8
-0
sound/core/jack.c
sound/core/jack.c
+65
-6
未找到文件。
include/sound/jack.h
浏览文件 @
20406f9b
...
@@ -42,6 +42,11 @@ enum snd_jack_types {
...
@@ -42,6 +42,11 @@ enum snd_jack_types {
SND_JACK_MECHANICAL
=
0x0008
,
/* If detected separately */
SND_JACK_MECHANICAL
=
0x0008
,
/* If detected separately */
SND_JACK_VIDEOOUT
=
0x0010
,
SND_JACK_VIDEOOUT
=
0x0010
,
SND_JACK_AVOUT
=
SND_JACK_LINEOUT
|
SND_JACK_VIDEOOUT
,
SND_JACK_AVOUT
=
SND_JACK_LINEOUT
|
SND_JACK_VIDEOOUT
,
/* Kept separate from switches to facilitate implementation */
SND_JACK_BTN_0
=
0x4000
,
SND_JACK_BTN_1
=
0x2000
,
SND_JACK_BTN_2
=
0x1000
,
};
};
struct
snd_jack
{
struct
snd_jack
{
...
@@ -50,6 +55,7 @@ struct snd_jack {
...
@@ -50,6 +55,7 @@ struct snd_jack {
int
type
;
int
type
;
const
char
*
id
;
const
char
*
id
;
char
name
[
100
];
char
name
[
100
];
unsigned
int
key
[
3
];
/* Keep in sync with definitions above */
void
*
private_data
;
void
*
private_data
;
void
(
*
private_free
)(
struct
snd_jack
*
);
void
(
*
private_free
)(
struct
snd_jack
*
);
};
};
...
@@ -59,6 +65,8 @@ struct snd_jack {
...
@@ -59,6 +65,8 @@ struct snd_jack {
int
snd_jack_new
(
struct
snd_card
*
card
,
const
char
*
id
,
int
type
,
int
snd_jack_new
(
struct
snd_card
*
card
,
const
char
*
id
,
int
type
,
struct
snd_jack
**
jack
);
struct
snd_jack
**
jack
);
void
snd_jack_set_parent
(
struct
snd_jack
*
jack
,
struct
device
*
parent
);
void
snd_jack_set_parent
(
struct
snd_jack
*
jack
,
struct
device
*
parent
);
int
snd_jack_set_key
(
struct
snd_jack
*
jack
,
enum
snd_jack_types
type
,
int
keytype
);
void
snd_jack_report
(
struct
snd_jack
*
jack
,
int
status
);
void
snd_jack_report
(
struct
snd_jack
*
jack
,
int
status
);
...
...
sound/core/jack.c
浏览文件 @
20406f9b
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include <sound/jack.h>
#include <sound/jack.h>
#include <sound/core.h>
#include <sound/core.h>
static
int
jack_types
[]
=
{
static
int
jack_
switch_
types
[]
=
{
SW_HEADPHONE_INSERT
,
SW_HEADPHONE_INSERT
,
SW_MICROPHONE_INSERT
,
SW_MICROPHONE_INSERT
,
SW_LINEOUT_INSERT
,
SW_LINEOUT_INSERT
,
...
@@ -56,7 +56,7 @@ static int snd_jack_dev_register(struct snd_device *device)
...
@@ -56,7 +56,7 @@ static int snd_jack_dev_register(struct snd_device *device)
{
{
struct
snd_jack
*
jack
=
device
->
device_data
;
struct
snd_jack
*
jack
=
device
->
device_data
;
struct
snd_card
*
card
=
device
->
card
;
struct
snd_card
*
card
=
device
->
card
;
int
err
;
int
err
,
i
;
snprintf
(
jack
->
name
,
sizeof
(
jack
->
name
),
"%s %s"
,
snprintf
(
jack
->
name
,
sizeof
(
jack
->
name
),
"%s %s"
,
card
->
shortname
,
jack
->
id
);
card
->
shortname
,
jack
->
id
);
...
@@ -66,6 +66,19 @@ static int snd_jack_dev_register(struct snd_device *device)
...
@@ -66,6 +66,19 @@ static int snd_jack_dev_register(struct snd_device *device)
if
(
!
jack
->
input_dev
->
dev
.
parent
)
if
(
!
jack
->
input_dev
->
dev
.
parent
)
jack
->
input_dev
->
dev
.
parent
=
snd_card_get_device_link
(
card
);
jack
->
input_dev
->
dev
.
parent
=
snd_card_get_device_link
(
card
);
/* Add capabilities for any keys that are enabled */
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
jack
->
key
);
i
++
)
{
int
testbit
=
SND_JACK_BTN_0
>>
i
;
if
(
!
(
jack
->
type
&
testbit
))
continue
;
if
(
!
jack
->
key
[
i
])
jack
->
key
[
i
]
=
BTN_0
+
i
;
input_set_capability
(
jack
->
input_dev
,
EV_KEY
,
jack
->
key
[
i
]);
}
err
=
input_register_device
(
jack
->
input_dev
);
err
=
input_register_device
(
jack
->
input_dev
);
if
(
err
==
0
)
if
(
err
==
0
)
jack
->
registered
=
1
;
jack
->
registered
=
1
;
...
@@ -113,10 +126,10 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
...
@@ -113,10 +126,10 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
jack
->
type
=
type
;
jack
->
type
=
type
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
jack_types
);
i
++
)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
jack_
switch_
types
);
i
++
)
if
(
type
&
(
1
<<
i
))
if
(
type
&
(
1
<<
i
))
input_set_capability
(
jack
->
input_dev
,
EV_SW
,
input_set_capability
(
jack
->
input_dev
,
EV_SW
,
jack_types
[
i
]);
jack_
switch_
types
[
i
]);
err
=
snd_device_new
(
card
,
SNDRV_DEV_JACK
,
jack
,
&
ops
);
err
=
snd_device_new
(
card
,
SNDRV_DEV_JACK
,
jack
,
&
ops
);
if
(
err
<
0
)
if
(
err
<
0
)
...
@@ -151,6 +164,43 @@ void snd_jack_set_parent(struct snd_jack *jack, struct device *parent)
...
@@ -151,6 +164,43 @@ void snd_jack_set_parent(struct snd_jack *jack, struct device *parent)
}
}
EXPORT_SYMBOL
(
snd_jack_set_parent
);
EXPORT_SYMBOL
(
snd_jack_set_parent
);
/**
* snd_jack_set_key - Set a key mapping on a jack
*
* @jack: The jack to configure
* @type: Jack report type for this key
* @keytype: Input layer key type to be reported
*
* Map a SND_JACK_BTN_ button type to an input layer key, allowing
* reporting of keys on accessories via the jack abstraction. If no
* mapping is provided but keys are enabled in the jack type then
* BTN_n numeric buttons will be reported.
*
* Note that this is intended to be use by simple devices with small
* numbers of keys that can be reported. It is also possible to
* access the input device directly - devices with complex input
* capabilities on accessories should consider doing this rather than
* using this abstraction.
*
* This function may only be called prior to registration of the jack.
*/
int
snd_jack_set_key
(
struct
snd_jack
*
jack
,
enum
snd_jack_types
type
,
int
keytype
)
{
int
key
=
fls
(
SND_JACK_BTN_0
)
-
fls
(
type
);
WARN_ON
(
jack
->
registered
);
if
(
!
keytype
||
key
>=
ARRAY_SIZE
(
jack
->
key
))
return
-
EINVAL
;
jack
->
type
|=
type
;
jack
->
key
[
key
]
=
keytype
;
return
0
;
}
EXPORT_SYMBOL
(
snd_jack_set_key
);
/**
/**
* snd_jack_report - Report the current status of a jack
* snd_jack_report - Report the current status of a jack
*
*
...
@@ -164,10 +214,19 @@ void snd_jack_report(struct snd_jack *jack, int status)
...
@@ -164,10 +214,19 @@ void snd_jack_report(struct snd_jack *jack, int status)
if
(
!
jack
)
if
(
!
jack
)
return
;
return
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
jack_types
);
i
++
)
{
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
jack
->
key
);
i
++
)
{
int
testbit
=
SND_JACK_BTN_0
>>
i
;
if
(
jack
->
type
&
testbit
)
input_report_key
(
jack
->
input_dev
,
jack
->
key
[
i
],
status
&
testbit
);
}
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
jack_switch_types
);
i
++
)
{
int
testbit
=
1
<<
i
;
int
testbit
=
1
<<
i
;
if
(
jack
->
type
&
testbit
)
if
(
jack
->
type
&
testbit
)
input_report_switch
(
jack
->
input_dev
,
jack_types
[
i
],
input_report_switch
(
jack
->
input_dev
,
jack_switch_types
[
i
],
status
&
testbit
);
status
&
testbit
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录