Gerd Hoffmann | d61a4ce | 2010-11-01 13:05:32 +0100 | [diff] [blame] | 1 | #ifndef HW_INTEL_HDA_H |
| 2 | #define HW_INTEL_HDA_H |
| 3 | |
| 4 | #include "qdev.h" |
| 5 | |
| 6 | /* --------------------------------------------------------------------- */ |
| 7 | /* hda bus */ |
| 8 | |
Anthony Liguori | dbaa790 | 2011-12-16 13:39:51 -0600 | [diff] [blame] | 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) |
| 16 | |
Anthony Liguori | 0d93692 | 2012-05-02 09:00:20 +0200 | [diff] [blame] | 17 | #define TYPE_HDA_BUS "HDA" |
| 18 | #define HDA_BUS(obj) OBJECT_CHECK(HDACodecBus, (obj), TYPE_HDA_BUS) |
| 19 | |
Gerd Hoffmann | d61a4ce | 2010-11-01 13:05:32 +0100 | [diff] [blame] | 20 | typedef struct HDACodecBus HDACodecBus; |
| 21 | typedef struct HDACodecDevice HDACodecDevice; |
Gerd Hoffmann | d61a4ce | 2010-11-01 13:05:32 +0100 | [diff] [blame] | 22 | |
| 23 | typedef void (*hda_codec_response_func)(HDACodecDevice *dev, |
| 24 | bool solicited, uint32_t response); |
| 25 | typedef bool (*hda_codec_xfer_func)(HDACodecDevice *dev, |
| 26 | uint32_t stnr, bool output, |
| 27 | uint8_t *buf, uint32_t len); |
| 28 | |
| 29 | struct HDACodecBus { |
| 30 | BusState qbus; |
| 31 | uint32_t next_cad; |
| 32 | hda_codec_response_func response; |
| 33 | hda_codec_xfer_func xfer; |
| 34 | }; |
| 35 | |
Anthony Liguori | dbaa790 | 2011-12-16 13:39:51 -0600 | [diff] [blame] | 36 | typedef struct HDACodecDeviceClass |
| 37 | { |
| 38 | DeviceClass parent_class; |
Gerd Hoffmann | d61a4ce | 2010-11-01 13:05:32 +0100 | [diff] [blame] | 39 | |
Gerd Hoffmann | d61a4ce | 2010-11-01 13:05:32 +0100 | [diff] [blame] | 40 | int (*init)(HDACodecDevice *dev); |
Gerd Hoffmann | dc4b924 | 2010-11-09 11:47:44 +0100 | [diff] [blame] | 41 | int (*exit)(HDACodecDevice *dev); |
Gerd Hoffmann | d61a4ce | 2010-11-01 13:05:32 +0100 | [diff] [blame] | 42 | void (*command)(HDACodecDevice *dev, uint32_t nid, uint32_t data); |
Marc-André Lureau | ba43d28 | 2011-10-25 16:53:01 +0200 | [diff] [blame] | 43 | void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running, bool output); |
Anthony Liguori | dbaa790 | 2011-12-16 13:39:51 -0600 | [diff] [blame] | 44 | } HDACodecDeviceClass; |
| 45 | |
| 46 | struct HDACodecDevice { |
| 47 | DeviceState qdev; |
| 48 | uint32_t cad; /* codec address */ |
Gerd Hoffmann | d61a4ce | 2010-11-01 13:05:32 +0100 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, |
| 52 | hda_codec_response_func response, |
| 53 | hda_codec_xfer_func xfer); |
Gerd Hoffmann | d61a4ce | 2010-11-01 13:05:32 +0100 | [diff] [blame] | 54 | HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad); |
| 55 | |
| 56 | void hda_codec_response(HDACodecDevice *dev, bool solicited, uint32_t response); |
| 57 | bool hda_codec_xfer(HDACodecDevice *dev, uint32_t stnr, bool output, |
| 58 | uint8_t *buf, uint32_t len); |
| 59 | |
| 60 | /* --------------------------------------------------------------------- */ |
| 61 | |
| 62 | #define dprint(_dev, _level, _fmt, ...) \ |
| 63 | do { \ |
| 64 | if (_dev->debug >= _level) { \ |
| 65 | fprintf(stderr, "%s: ", _dev->name); \ |
| 66 | fprintf(stderr, _fmt, ## __VA_ARGS__); \ |
| 67 | } \ |
| 68 | } while (0) |
| 69 | |
| 70 | /* --------------------------------------------------------------------- */ |
| 71 | |
| 72 | #endif |