shpc: unparent device before free
[qemu/ar7.git] / hw / intel-hda.h
bloba1cca5b1bb24d2a6fc1d4f7e671a8114a6f9f265
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 HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad);
53 void hda_codec_response(HDACodecDevice *dev, bool solicited, uint32_t response);
54 bool hda_codec_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
55 uint8_t *buf, uint32_t len);
57 /* --------------------------------------------------------------------- */
59 #define dprint(_dev, _level, _fmt, ...) \
60 do { \
61 if (_dev->debug >= _level) { \
62 fprintf(stderr, "%s: ", _dev->name); \
63 fprintf(stderr, _fmt, ## __VA_ARGS__); \
64 } \
65 } while (0)
67 /* --------------------------------------------------------------------- */
69 #endif