qbus: add functions to walk both devices and busses
[qemu/mdroth.git] / hw / intel-hda.h
blobba290ec85017f817b43fb4d19fc08669680741ee
1 #ifndef HW_INTEL_HDA_H
2 #define HW_INTEL_HDA_H
4 #include "qdev.h"
6 /* --------------------------------------------------------------------- */
7 /* hda bus */
9 typedef struct HDACodecBus HDACodecBus;
10 typedef struct HDACodecDevice HDACodecDevice;
11 typedef struct HDACodecDeviceInfo HDACodecDeviceInfo;
13 typedef void (*hda_codec_response_func)(HDACodecDevice *dev,
14 bool solicited, uint32_t response);
15 typedef bool (*hda_codec_xfer_func)(HDACodecDevice *dev,
16 uint32_t stnr, bool output,
17 uint8_t *buf, uint32_t len);
19 struct HDACodecBus {
20 BusState qbus;
21 uint32_t next_cad;
22 hda_codec_response_func response;
23 hda_codec_xfer_func xfer;
26 struct HDACodecDevice {
27 DeviceState qdev;
28 HDACodecDeviceInfo *info;
29 uint32_t cad; /* codec address */
32 struct HDACodecDeviceInfo {
33 DeviceInfo qdev;
34 int (*init)(HDACodecDevice *dev);
35 void (*command)(HDACodecDevice *dev, uint32_t nid, uint32_t data);
36 void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running);
39 void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus,
40 hda_codec_response_func response,
41 hda_codec_xfer_func xfer);
42 void hda_codec_register(HDACodecDeviceInfo *info);
43 HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad);
45 void hda_codec_response(HDACodecDevice *dev, bool solicited, uint32_t response);
46 bool hda_codec_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
47 uint8_t *buf, uint32_t len);
49 /* --------------------------------------------------------------------- */
51 #define dprint(_dev, _level, _fmt, ...) \
52 do { \
53 if (_dev->debug >= _level) { \
54 fprintf(stderr, "%s: ", _dev->name); \
55 fprintf(stderr, _fmt, ## __VA_ARGS__); \
56 } \
57 } while (0)
59 /* --------------------------------------------------------------------- */
61 #endif