Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
dbaa7904
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dbaa7904
编写于
12月 16, 2011
作者:
A
Anthony Liguori
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hda-codec: convert to QEMU Object Model
Signed-off-by:
N
Anthony Liguori
<
aliguori@us.ibm.com
>
上级
b5ea9327
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
71 addition
and
44 deletion
+71
-44
hw/hda-audio.c
hw/hda-audio.c
+36
-22
hw/intel-hda.c
hw/intel-hda.c
+18
-13
hw/intel-hda.h
hw/intel-hda.h
+17
-9
未找到文件。
hw/hda-audio.c
浏览文件 @
dbaa7904
...
...
@@ -906,33 +906,47 @@ static int hda_audio_init_duplex(HDACodecDevice *hda)
return
hda_audio_init
(
hda
,
&
duplex
);
}
static
HDACodecDeviceInfo
hda_audio_info_output
=
{
.
qdev
.
name
=
"hda-output"
,
.
qdev
.
desc
=
"HDA Audio Codec, output-only"
,
.
qdev
.
size
=
sizeof
(
HDAAudioState
),
.
qdev
.
vmsd
=
&
vmstate_hda_audio
,
.
qdev
.
props
=
hda_audio_properties
,
.
init
=
hda_audio_init_output
,
.
exit
=
hda_audio_exit
,
.
command
=
hda_audio_command
,
.
stream
=
hda_audio_stream
,
static
void
hda_audio_output_class_init
(
ObjectClass
*
klass
,
void
*
data
)
{
HDACodecDeviceClass
*
k
=
HDA_CODEC_DEVICE_CLASS
(
klass
);
k
->
init
=
hda_audio_init_output
;
k
->
exit
=
hda_audio_exit
;
k
->
command
=
hda_audio_command
;
k
->
stream
=
hda_audio_stream
;
}
static
DeviceInfo
hda_audio_output_info
=
{
.
name
=
"hda-output"
,
.
desc
=
"HDA Audio Codec, output-only"
,
.
size
=
sizeof
(
HDAAudioState
),
.
vmsd
=
&
vmstate_hda_audio
,
.
props
=
hda_audio_properties
,
.
class_init
=
hda_audio_output_class_init
,
};
static
HDACodecDeviceInfo
hda_audio_info_duplex
=
{
.
qdev
.
name
=
"hda-duplex"
,
.
qdev
.
desc
=
"HDA Audio Codec, duplex"
,
.
qdev
.
size
=
sizeof
(
HDAAudioState
),
.
qdev
.
vmsd
=
&
vmstate_hda_audio
,
.
qdev
.
props
=
hda_audio_properties
,
.
init
=
hda_audio_init_duplex
,
.
exit
=
hda_audio_exit
,
.
command
=
hda_audio_command
,
.
stream
=
hda_audio_stream
,
static
void
hda_audio_duplex_class_init
(
ObjectClass
*
klass
,
void
*
data
)
{
HDACodecDeviceClass
*
k
=
HDA_CODEC_DEVICE_CLASS
(
klass
);
k
->
init
=
hda_audio_init_duplex
;
k
->
exit
=
hda_audio_exit
;
k
->
command
=
hda_audio_command
;
k
->
stream
=
hda_audio_stream
;
}
static
DeviceInfo
hda_audio_duplex_info
=
{
.
name
=
"hda-duplex"
,
.
desc
=
"HDA Audio Codec, duplex"
,
.
size
=
sizeof
(
HDAAudioState
),
.
vmsd
=
&
vmstate_hda_audio
,
.
props
=
hda_audio_properties
,
.
class_init
=
hda_audio_duplex_class_init
,
};
static
void
hda_audio_register
(
void
)
{
hda_codec_register
(
&
hda_audio_
info_output
);
hda_codec_register
(
&
hda_audio_
info_duplex
);
hda_codec_register
(
&
hda_audio_
output_info
);
hda_codec_register
(
&
hda_audio_
duplex_info
);
}
device_init
(
hda_audio_register
);
hw/intel-hda.c
浏览文件 @
dbaa7904
...
...
@@ -51,9 +51,8 @@ static int hda_codec_dev_init(DeviceState *qdev, DeviceInfo *base)
{
HDACodecBus
*
bus
=
DO_UPCAST
(
HDACodecBus
,
qbus
,
qdev
->
parent_bus
);
HDACodecDevice
*
dev
=
DO_UPCAST
(
HDACodecDevice
,
qdev
,
qdev
);
HDACodecDevice
Info
*
info
=
DO_UPCAST
(
HDACodecDeviceInfo
,
qdev
,
base
);
HDACodecDevice
Class
*
cdc
=
HDA_CODEC_DEVICE_GET_CLASS
(
dev
);
dev
->
info
=
info
;
if
(
dev
->
cad
==
-
1
)
{
dev
->
cad
=
bus
->
next_cad
;
}
...
...
@@ -61,25 +60,26 @@ static int hda_codec_dev_init(DeviceState *qdev, DeviceInfo *base)
return
-
1
;
}
bus
->
next_cad
=
dev
->
cad
+
1
;
return
info
->
init
(
dev
);
return
cdc
->
init
(
dev
);
}
static
int
hda_codec_dev_exit
(
DeviceState
*
qdev
)
{
HDACodecDevice
*
dev
=
DO_UPCAST
(
HDACodecDevice
,
qdev
,
qdev
);
HDACodecDeviceClass
*
cdc
=
HDA_CODEC_DEVICE_GET_CLASS
(
dev
);
if
(
dev
->
info
->
exit
)
{
dev
->
info
->
exit
(
dev
);
if
(
cdc
->
exit
)
{
cdc
->
exit
(
dev
);
}
return
0
;
}
void
hda_codec_register
(
HDACodec
DeviceInfo
*
info
)
void
hda_codec_register
(
DeviceInfo
*
info
)
{
info
->
qdev
.
init
=
hda_codec_dev_init
;
info
->
qdev
.
exit
=
hda_codec_dev_exit
;
info
->
qdev
.
bus_info
=
&
hda_codec_bus_info
;
qdev_register
(
&
info
->
qdev
);
info
->
init
=
hda_codec_dev_init
;
info
->
exit
=
hda_codec_dev_exit
;
info
->
bus_info
=
&
hda_codec_bus_info
;
qdev_register
(
info
);
}
HDACodecDevice
*
hda_codec_find
(
HDACodecBus
*
bus
,
uint32_t
cad
)
...
...
@@ -283,6 +283,7 @@ static int intel_hda_send_command(IntelHDAState *d, uint32_t verb)
{
uint32_t
cad
,
nid
,
data
;
HDACodecDevice
*
codec
;
HDACodecDeviceClass
*
cdc
;
cad
=
(
verb
>>
28
)
&
0x0f
;
if
(
verb
&
(
1
<<
27
))
{
...
...
@@ -298,7 +299,8 @@ static int intel_hda_send_command(IntelHDAState *d, uint32_t verb)
dprint
(
d
,
1
,
"%s: addressed non-existing codec
\n
"
,
__FUNCTION__
);
return
-
1
;
}
codec
->
info
->
command
(
codec
,
nid
,
data
);
cdc
=
HDA_CODEC_DEVICE_GET_CLASS
(
codec
);
cdc
->
command
(
codec
,
nid
,
data
);
return
0
;
}
...
...
@@ -491,9 +493,12 @@ static void intel_hda_notify_codecs(IntelHDAState *d, uint32_t stream, bool runn
HDACodecDevice
*
cdev
;
QTAILQ_FOREACH
(
qdev
,
&
d
->
codecs
.
qbus
.
children
,
sibling
)
{
HDACodecDeviceClass
*
cdc
;
cdev
=
DO_UPCAST
(
HDACodecDevice
,
qdev
,
qdev
);
if
(
cdev
->
info
->
stream
)
{
cdev
->
info
->
stream
(
cdev
,
stream
,
running
,
output
);
cdc
=
HDA_CODEC_DEVICE_GET_CLASS
(
cdev
);
if
(
cdc
->
stream
)
{
cdc
->
stream
(
cdev
,
stream
,
running
,
output
);
}
}
}
...
...
hw/intel-hda.h
浏览文件 @
dbaa7904
...
...
@@ -6,9 +6,16 @@
/* --------------------------------------------------------------------- */
/* hda bus */
#define TYPE_HDA_CODEC_DEVICE "hda-codec"
#define HDA_CODEC_DEVICE(obj) \
OBJECT_CHECK(HDACodecDevice, (obj), TYPE_HDA_CODEC_DEVICE)
#define HDA_CODEC_DEVICE_CLASS(klass) \
OBJECT_CLASS_CHECK(HDACodecDeviceClass, (klass), TYPE_HDA_CODEC_DEVICE)
#define HDA_CODEC_DEVICE_GET_CLASS(obj) \
OBJECT_GET_CLASS(HDACodecDeviceClass, (obj), TYPE_HDA_CODEC_DEVICE)
typedef
struct
HDACodecBus
HDACodecBus
;
typedef
struct
HDACodecDevice
HDACodecDevice
;
typedef
struct
HDACodecDeviceInfo
HDACodecDeviceInfo
;
typedef
void
(
*
hda_codec_response_func
)(
HDACodecDevice
*
dev
,
bool
solicited
,
uint32_t
response
);
...
...
@@ -23,24 +30,25 @@ struct HDACodecBus {
hda_codec_xfer_func
xfer
;
};
struct
HDACodecDevice
{
DeviceState
qdev
;
HDACodecDeviceInfo
*
info
;
uint32_t
cad
;
/* codec address */
};
typedef
struct
HDACodecDeviceClass
{
DeviceClass
parent_class
;
struct
HDACodecDeviceInfo
{
DeviceInfo
qdev
;
int
(
*
init
)(
HDACodecDevice
*
dev
);
int
(
*
exit
)(
HDACodecDevice
*
dev
);
void
(
*
command
)(
HDACodecDevice
*
dev
,
uint32_t
nid
,
uint32_t
data
);
void
(
*
stream
)(
HDACodecDevice
*
dev
,
uint32_t
stnr
,
bool
running
,
bool
output
);
}
HDACodecDeviceClass
;
struct
HDACodecDevice
{
DeviceState
qdev
;
uint32_t
cad
;
/* codec address */
};
void
hda_codec_bus_init
(
DeviceState
*
dev
,
HDACodecBus
*
bus
,
hda_codec_response_func
response
,
hda_codec_xfer_func
xfer
);
void
hda_codec_register
(
HDACodec
DeviceInfo
*
info
);
void
hda_codec_register
(
DeviceInfo
*
info
);
HDACodecDevice
*
hda_codec_find
(
HDACodecBus
*
bus
,
uint32_t
cad
);
void
hda_codec_response
(
HDACodecDevice
*
dev
,
bool
solicited
,
uint32_t
response
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录