Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
0eee62e0
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
161
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看板
提交
0eee62e0
编写于
2月 23, 2015
作者:
T
Takashi Iwai
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'topic/pcm-internal' into for-next
上级
8d085d3c
b2022138
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
51 deletion
+41
-51
sound/core/pcm.c
sound/core/pcm.c
+41
-51
未找到文件。
sound/core/pcm.c
浏览文件 @
0eee62e0
...
...
@@ -49,8 +49,6 @@ static struct snd_pcm *snd_pcm_get(struct snd_card *card, int device)
struct
snd_pcm
*
pcm
;
list_for_each_entry
(
pcm
,
&
snd_pcm_devices
,
list
)
{
if
(
pcm
->
internal
)
continue
;
if
(
pcm
->
card
==
card
&&
pcm
->
device
==
device
)
return
pcm
;
}
...
...
@@ -62,8 +60,6 @@ static int snd_pcm_next(struct snd_card *card, int device)
struct
snd_pcm
*
pcm
;
list_for_each_entry
(
pcm
,
&
snd_pcm_devices
,
list
)
{
if
(
pcm
->
internal
)
continue
;
if
(
pcm
->
card
==
card
&&
pcm
->
device
>
device
)
return
pcm
->
device
;
else
if
(
pcm
->
card
->
number
>
card
->
number
)
...
...
@@ -76,6 +72,9 @@ static int snd_pcm_add(struct snd_pcm *newpcm)
{
struct
snd_pcm
*
pcm
;
if
(
newpcm
->
internal
)
return
0
;
list_for_each_entry
(
pcm
,
&
snd_pcm_devices
,
list
)
{
if
(
pcm
->
card
==
newpcm
->
card
&&
pcm
->
device
==
newpcm
->
device
)
return
-
EBUSY
;
...
...
@@ -782,6 +781,9 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device,
pcm
->
card
=
card
;
pcm
->
device
=
device
;
pcm
->
internal
=
internal
;
mutex_init
(
&
pcm
->
open_mutex
);
init_waitqueue_head
(
&
pcm
->
open_wait
);
INIT_LIST_HEAD
(
&
pcm
->
list
);
if
(
id
)
strlcpy
(
pcm
->
id
,
id
,
sizeof
(
pcm
->
id
));
if
((
err
=
snd_pcm_new_stream
(
pcm
,
SNDRV_PCM_STREAM_PLAYBACK
,
playback_count
))
<
0
)
{
...
...
@@ -792,8 +794,6 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device,
snd_pcm_free
(
pcm
);
return
err
;
}
mutex_init
(
&
pcm
->
open_mutex
);
init_waitqueue_head
(
&
pcm
->
open_wait
);
if
((
err
=
snd_device_new
(
card
,
SNDRV_DEV_PCM
,
pcm
,
&
ops
))
<
0
)
{
snd_pcm_free
(
pcm
);
return
err
;
...
...
@@ -888,8 +888,9 @@ static int snd_pcm_free(struct snd_pcm *pcm)
if
(
!
pcm
)
return
0
;
list_for_each_entry
(
notify
,
&
snd_pcm_notify_list
,
list
)
{
notify
->
n_unregister
(
pcm
);
if
(
!
pcm
->
internal
)
{
list_for_each_entry
(
notify
,
&
snd_pcm_notify_list
,
list
)
notify
->
n_unregister
(
pcm
);
}
if
(
pcm
->
private_free
)
pcm
->
private_free
(
pcm
);
...
...
@@ -919,6 +920,9 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
if
(
snd_BUG_ON
(
!
pcm
||
!
rsubstream
))
return
-
ENXIO
;
if
(
snd_BUG_ON
(
stream
!=
SNDRV_PCM_STREAM_PLAYBACK
&&
stream
!=
SNDRV_PCM_STREAM_CAPTURE
))
return
-
EINVAL
;
*
rsubstream
=
NULL
;
pstr
=
&
pcm
->
streams
[
stream
];
if
(
pstr
->
substream
==
NULL
||
pstr
->
substream_count
==
0
)
...
...
@@ -927,25 +931,14 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
card
=
pcm
->
card
;
prefer_subdevice
=
snd_ctl_get_preferred_subdevice
(
card
,
SND_CTL_SUBDEV_PCM
);
switch
(
stream
)
{
case
SNDRV_PCM_STREAM_PLAYBACK
:
if
(
pcm
->
info_flags
&
SNDRV_PCM_INFO_HALF_DUPLEX
)
{
for
(
substream
=
pcm
->
streams
[
SNDRV_PCM_STREAM_CAPTURE
].
substream
;
substream
;
substream
=
substream
->
next
)
{
if
(
SUBSTREAM_BUSY
(
substream
))
return
-
EAGAIN
;
}
}
break
;
case
SNDRV_PCM_STREAM_CAPTURE
:
if
(
pcm
->
info_flags
&
SNDRV_PCM_INFO_HALF_DUPLEX
)
{
for
(
substream
=
pcm
->
streams
[
SNDRV_PCM_STREAM_PLAYBACK
].
substream
;
substream
;
substream
=
substream
->
next
)
{
if
(
SUBSTREAM_BUSY
(
substream
))
return
-
EAGAIN
;
}
if
(
pcm
->
info_flags
&
SNDRV_PCM_INFO_HALF_DUPLEX
)
{
int
opposite
=
!
stream
;
for
(
substream
=
pcm
->
streams
[
opposite
].
substream
;
substream
;
substream
=
substream
->
next
)
{
if
(
SUBSTREAM_BUSY
(
substream
))
return
-
EAGAIN
;
}
break
;
default:
return
-
EINVAL
;
}
if
(
file
->
f_flags
&
O_APPEND
)
{
...
...
@@ -968,15 +961,12 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
return
0
;
}
if
(
prefer_subdevice
>=
0
)
{
for
(
substream
=
pstr
->
substream
;
substream
;
substream
=
substream
->
next
)
if
(
!
SUBSTREAM_BUSY
(
substream
)
&&
substream
->
number
==
prefer_subdevice
)
goto
__ok
;
}
for
(
substream
=
pstr
->
substream
;
substream
;
substream
=
substream
->
next
)
if
(
!
SUBSTREAM_BUSY
(
substream
))
for
(
substream
=
pstr
->
substream
;
substream
;
substream
=
substream
->
next
)
{
if
(
!
SUBSTREAM_BUSY
(
substream
)
&&
(
prefer_subdevice
==
-
1
||
substream
->
number
==
prefer_subdevice
))
break
;
__ok:
}
if
(
substream
==
NULL
)
return
-
EAGAIN
;
...
...
@@ -1086,15 +1076,16 @@ static int snd_pcm_dev_register(struct snd_device *device)
if
(
snd_BUG_ON
(
!
device
||
!
device
->
device_data
))
return
-
ENXIO
;
pcm
=
device
->
device_data
;
if
(
pcm
->
internal
)
return
0
;
mutex_lock
(
&
register_mutex
);
err
=
snd_pcm_add
(
pcm
);
if
(
err
)
{
mutex_unlock
(
&
register_mutex
);
return
err
;
}
if
(
err
)
goto
unlock
;
for
(
cidx
=
0
;
cidx
<
2
;
cidx
++
)
{
int
devtype
=
-
1
;
if
(
pcm
->
streams
[
cidx
].
substream
==
NULL
||
pcm
->
internal
)
if
(
pcm
->
streams
[
cidx
].
substream
==
NULL
)
continue
;
switch
(
cidx
)
{
case
SNDRV_PCM_STREAM_PLAYBACK
:
...
...
@@ -1109,9 +1100,8 @@ static int snd_pcm_dev_register(struct snd_device *device)
&
snd_pcm_f_ops
[
cidx
],
pcm
,
&
pcm
->
streams
[
cidx
].
dev
);
if
(
err
<
0
)
{
list_del
(
&
pcm
->
list
);
mutex_unlock
(
&
register_mutex
);
return
err
;
list_del_init
(
&
pcm
->
list
);
goto
unlock
;
}
for
(
substream
=
pcm
->
streams
[
cidx
].
substream
;
substream
;
substream
=
substream
->
next
)
...
...
@@ -1121,8 +1111,9 @@ static int snd_pcm_dev_register(struct snd_device *device)
list_for_each_entry
(
notify
,
&
snd_pcm_notify_list
,
list
)
notify
->
n_register
(
pcm
);
unlock:
mutex_unlock
(
&
register_mutex
);
return
0
;
return
err
;
}
static
int
snd_pcm_dev_disconnect
(
struct
snd_device
*
device
)
...
...
@@ -1133,13 +1124,10 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
int
cidx
;
mutex_lock
(
&
register_mutex
);
if
(
list_empty
(
&
pcm
->
list
))
goto
unlock
;
mutex_lock
(
&
pcm
->
open_mutex
);
wake_up
(
&
pcm
->
open_wait
);
list_del_init
(
&
pcm
->
list
);
for
(
cidx
=
0
;
cidx
<
2
;
cidx
++
)
for
(
cidx
=
0
;
cidx
<
2
;
cidx
++
)
{
for
(
substream
=
pcm
->
streams
[
cidx
].
substream
;
substream
;
substream
=
substream
->
next
)
{
snd_pcm_stream_lock_irq
(
substream
);
if
(
substream
->
runtime
)
{
...
...
@@ -1149,18 +1137,20 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
}
snd_pcm_stream_unlock_irq
(
substream
);
}
list_for_each_entry
(
notify
,
&
snd_pcm_notify_list
,
list
)
{
notify
->
n_disconnect
(
pcm
);
}
if
(
!
pcm
->
internal
)
{
list_for_each_entry
(
notify
,
&
snd_pcm_notify_list
,
list
)
notify
->
n_disconnect
(
pcm
);
}
for
(
cidx
=
0
;
cidx
<
2
;
cidx
++
)
{
snd_unregister_device
(
&
pcm
->
streams
[
cidx
].
dev
);
if
(
!
pcm
->
internal
)
snd_unregister_device
(
&
pcm
->
streams
[
cidx
].
dev
);
if
(
pcm
->
streams
[
cidx
].
chmap_kctl
)
{
snd_ctl_remove
(
pcm
->
card
,
pcm
->
streams
[
cidx
].
chmap_kctl
);
pcm
->
streams
[
cidx
].
chmap_kctl
=
NULL
;
}
}
mutex_unlock
(
&
pcm
->
open_mutex
);
unlock:
mutex_unlock
(
&
register_mutex
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录