Merge commit 'd34e8f6e9d3a396c3327aa9807c83f9e1f4a7bd7' into upstream-merge
[qemu-kvm.git] / hw / intel-hda.h
blobf52358709b7a02e8783855ff686bc67d9a36e233
1 #ifndef HW_INTEL_HDA_H
2 #define HW_INTEL_HDA_H
4 #include "qdev.h"
6 /* --------------------------------------------------------------------- */
7 /* hda bus */
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)
17 typedef struct HDACodecBus HDACodecBus;
18 typedef struct HDACodecDevice HDACodecDevice;
20 typedef void (*hda_codec_response_func)(HDACodecDevice *dev,
21 bool solicited, uint32_t response);
22 typedef bool (*hda_codec_xfer_func)(HDACodecDevice *dev,
23 uint32_t stnr, bool output,
24 uint8_t *buf, uint32_t len);
26 struct HDACodecBus {
27 BusState qbus;
28 uint32_t next_cad;
29 hda_codec_response_func response;
30 hda_codec_xfer_func xfer;
33 typedef struct HDACodecDeviceClass
35 DeviceClass parent_class;
37 int (*init)(HDACodecDevice *dev);
38 int (*exit)(HDACodecDevice *dev);
39 void (*command)(HDACodecDevice *dev, uint32_t nid, uint32_t data);
40 void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running, bool output);
41 } HDACodecDeviceClass;
43 struct HDACodecDevice {
44 DeviceState qdev;
45 uint32_t cad; /* codec address */
48 void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus,
49 hda_codec_response_func response,
50 hda_codec_xfer_func xfer);
51 void hda_codec_register(DeviceInfo *info);
52 HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad);
54 void hda_codec_response(HDACodecDevice *dev, bool solicited, uint32_t response);
55 bool hda_codec_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
56 uint8_t *buf, uint32_t len);
58 /* --------------------------------------------------------------------- */
60 #define dprint(_dev, _level, _fmt, ...) \
61 do { \
62 if (_dev->debug >= _level) { \
63 fprintf(stderr, "%s: ", _dev->name); \
64 fprintf(stderr, _fmt, ## __VA_ARGS__); \
65 } \
66 } while (0)
68 /* --------------------------------------------------------------------- */
70 #endif