4 #include "hw/qdev-core.h"
5 #include "qom/object.h"
7 /* --------------------------------------------------------------------- */
10 #define TYPE_HDA_CODEC_DEVICE "hda-codec"
11 OBJECT_DECLARE_TYPE(HDACodecDevice
, HDACodecDeviceClass
,
14 #define TYPE_HDA_BUS "HDA"
15 OBJECT_DECLARE_SIMPLE_TYPE(HDACodecBus
, HDA_BUS
)
18 typedef void (*hda_codec_response_func
)(HDACodecDevice
*dev
,
19 bool solicited
, uint32_t response
);
20 typedef bool (*hda_codec_xfer_func
)(HDACodecDevice
*dev
,
21 uint32_t stnr
, bool output
,
22 uint8_t *buf
, uint32_t len
);
27 hda_codec_response_func response
;
28 hda_codec_xfer_func xfer
;
31 struct HDACodecDeviceClass
{
32 DeviceClass parent_class
;
34 void (*init
)(HDACodecDevice
*dev
, Error
**errp
);
35 void (*exit
)(HDACodecDevice
*dev
);
36 void (*command
)(HDACodecDevice
*dev
, uint32_t nid
, uint32_t data
);
37 void (*stream
)(HDACodecDevice
*dev
, uint32_t stnr
, bool running
, bool output
);
40 struct HDACodecDevice
{
42 uint32_t cad
; /* codec address */
45 void hda_codec_bus_init(DeviceState
*dev
, HDACodecBus
*bus
, size_t bus_size
,
46 hda_codec_response_func response
,
47 hda_codec_xfer_func xfer
);
48 HDACodecDevice
*hda_codec_find(HDACodecBus
*bus
, uint32_t cad
);
50 void hda_codec_response(HDACodecDevice
*dev
, bool solicited
, uint32_t response
);
51 bool hda_codec_xfer(HDACodecDevice
*dev
, uint32_t stnr
, bool output
,
52 uint8_t *buf
, uint32_t len
);
54 /* --------------------------------------------------------------------- */
56 #define dprint(_dev, _level, _fmt, ...) \
58 if (_dev->debug >= _level) { \
59 fprintf(stderr, "%s: ", _dev->name); \
60 fprintf(stderr, _fmt, ## __VA_ARGS__); \
64 /* --------------------------------------------------------------------- */