]>
Commit | Line | Data |
---|---|---|
d61a4ce8 GH |
1 | #ifndef HW_INTEL_HDA_H |
2 | #define HW_INTEL_HDA_H | |
3 | ||
83c9f4ca | 4 | #include "hw/qdev.h" |
d61a4ce8 GH |
5 | |
6 | /* --------------------------------------------------------------------- */ | |
7 | /* hda bus */ | |
8 | ||
dbaa7904 AL |
9 | #define TYPE_HDA_CODEC_DEVICE "hda-codec" |
10 | #define HDA_CODEC_DEVICE(obj) \ | |
11 | OBJECT_CHECK(HDACodecDevice, (obj), TYPE_HDA_CODEC_DEVICE) | |
12 | #define HDA_CODEC_DEVICE_CLASS(klass) \ | |
13 | OBJECT_CLASS_CHECK(HDACodecDeviceClass, (klass), TYPE_HDA_CODEC_DEVICE) | |
14 | #define HDA_CODEC_DEVICE_GET_CLASS(obj) \ | |
15 | OBJECT_GET_CLASS(HDACodecDeviceClass, (obj), TYPE_HDA_CODEC_DEVICE) | |
16 | ||
0d936928 AL |
17 | #define TYPE_HDA_BUS "HDA" |
18 | #define HDA_BUS(obj) OBJECT_CHECK(HDACodecBus, (obj), TYPE_HDA_BUS) | |
19 | ||
d61a4ce8 GH |
20 | typedef struct HDACodecBus HDACodecBus; |
21 | typedef struct HDACodecDevice HDACodecDevice; | |
d61a4ce8 GH |
22 | |
23 | typedef void (*hda_codec_response_func)(HDACodecDevice *dev, | |
24 | bool solicited, uint32_t response); | |
25 | typedef bool (*hda_codec_xfer_func)(HDACodecDevice *dev, | |
26 | uint32_t stnr, bool output, | |
27 | uint8_t *buf, uint32_t len); | |
28 | ||
29 | struct HDACodecBus { | |
30 | BusState qbus; | |
31 | uint32_t next_cad; | |
32 | hda_codec_response_func response; | |
33 | hda_codec_xfer_func xfer; | |
34 | }; | |
35 | ||
dbaa7904 AL |
36 | typedef struct HDACodecDeviceClass |
37 | { | |
38 | DeviceClass parent_class; | |
d61a4ce8 | 39 | |
d61a4ce8 | 40 | int (*init)(HDACodecDevice *dev); |
5eaa8e1e | 41 | void (*exit)(HDACodecDevice *dev); |
d61a4ce8 | 42 | void (*command)(HDACodecDevice *dev, uint32_t nid, uint32_t data); |
ba43d289 | 43 | void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running, bool output); |
dbaa7904 AL |
44 | } HDACodecDeviceClass; |
45 | ||
46 | struct HDACodecDevice { | |
47 | DeviceState qdev; | |
48 | uint32_t cad; /* codec address */ | |
d61a4ce8 GH |
49 | }; |
50 | ||
ab809e84 | 51 | void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, size_t bus_size, |
d61a4ce8 GH |
52 | hda_codec_response_func response, |
53 | hda_codec_xfer_func xfer); | |
d61a4ce8 GH |
54 | HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad); |
55 | ||
56 | void hda_codec_response(HDACodecDevice *dev, bool solicited, uint32_t response); | |
57 | bool hda_codec_xfer(HDACodecDevice *dev, uint32_t stnr, bool output, | |
58 | uint8_t *buf, uint32_t len); | |
59 | ||
60 | /* --------------------------------------------------------------------- */ | |
61 | ||
62 | #define dprint(_dev, _level, _fmt, ...) \ | |
63 | do { \ | |
64 | if (_dev->debug >= _level) { \ | |
65 | fprintf(stderr, "%s: ", _dev->name); \ | |
66 | fprintf(stderr, _fmt, ## __VA_ARGS__); \ | |
67 | } \ | |
68 | } while (0) | |
69 | ||
70 | /* --------------------------------------------------------------------- */ | |
71 | ||
72 | #endif |