Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / hw / audio / intel-hda.h
blob8d710eee5d66dabe7d9bb1759ba05937ba5958b7
1 #ifndef HW_INTEL_HDA_H
2 #define HW_INTEL_HDA_H
4 #include "hw/qdev-core.h"
5 #include "qom/object.h"
7 /* --------------------------------------------------------------------- */
8 /* hda bus */
10 #define TYPE_HDA_CODEC_DEVICE "hda-codec"
11 OBJECT_DECLARE_TYPE(HDACodecDevice, HDACodecDeviceClass,
12 HDA_CODEC_DEVICE)
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);
24 struct HDACodecBus {
25 BusState qbus;
26 uint32_t next_cad;
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 {
41 DeviceState qdev;
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, ...) \
57 do { \
58 if (_dev->debug >= _level) { \
59 fprintf(stderr, "%s: ", _dev->name); \
60 fprintf(stderr, _fmt, ## __VA_ARGS__); \
61 } \
62 } while (0)
64 /* --------------------------------------------------------------------- */
66 #endif