1#ifndef HW_INTEL_HDA_H
2#define HW_INTEL_HDA_H
3
4#include "hw/qdev-core.h"
5#include "qom/object.h"
6
7
8
9
10#define TYPE_HDA_CODEC_DEVICE "hda-codec"
11OBJECT_DECLARE_TYPE(HDACodecDevice, HDACodecDeviceClass,
12 HDA_CODEC_DEVICE)
13
14#define TYPE_HDA_BUS "HDA"
15OBJECT_DECLARE_SIMPLE_TYPE(HDACodecBus, HDA_BUS)
16
17
18typedef void (*hda_codec_response_func)(HDACodecDevice *dev,
19 bool solicited, uint32_t response);
20typedef bool (*hda_codec_xfer_func)(HDACodecDevice *dev,
21 uint32_t stnr, bool output,
22 uint8_t *buf, uint32_t len);
23
24struct HDACodecBus {
25 BusState qbus;
26 uint32_t next_cad;
27 hda_codec_response_func response;
28 hda_codec_xfer_func xfer;
29};
30
31struct HDACodecDeviceClass {
32 DeviceClass parent_class;
33
34 int (*init)(HDACodecDevice *dev);
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);
38};
39
40struct HDACodecDevice {
41 DeviceState qdev;
42 uint32_t cad;
43};
44
45void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, size_t bus_size,
46 hda_codec_response_func response,
47 hda_codec_xfer_func xfer);
48HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad);
49
50void hda_codec_response(HDACodecDevice *dev, bool solicited, uint32_t response);
51bool hda_codec_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
52 uint8_t *buf, uint32_t len);
53
54
55
56#define dprint(_dev, _level, _fmt, ...) \
57 do { \
58 if (_dev->debug >= _level) { \
59 fprintf(stderr, "%s: ", _dev->name); \
60 fprintf(stderr, _fmt, ## __VA_ARGS__); \
61 } \
62 } while (0)
63
64
65
66#endif
67