2
0

intel-hda.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef HW_INTEL_HDA_H
  2. #define HW_INTEL_HDA_H
  3. #include "qdev.h"
  4. /* --------------------------------------------------------------------- */
  5. /* hda bus */
  6. typedef struct HDACodecBus HDACodecBus;
  7. typedef struct HDACodecDevice HDACodecDevice;
  8. typedef struct HDACodecDeviceInfo HDACodecDeviceInfo;
  9. typedef void (*hda_codec_response_func)(HDACodecDevice *dev,
  10. bool solicited, uint32_t response);
  11. typedef bool (*hda_codec_xfer_func)(HDACodecDevice *dev,
  12. uint32_t stnr, bool output,
  13. uint8_t *buf, uint32_t len);
  14. struct HDACodecBus {
  15. BusState qbus;
  16. uint32_t next_cad;
  17. hda_codec_response_func response;
  18. hda_codec_xfer_func xfer;
  19. };
  20. struct HDACodecDevice {
  21. DeviceState qdev;
  22. HDACodecDeviceInfo *info;
  23. uint32_t cad; /* codec address */
  24. };
  25. struct HDACodecDeviceInfo {
  26. DeviceInfo qdev;
  27. int (*init)(HDACodecDevice *dev);
  28. int (*exit)(HDACodecDevice *dev);
  29. void (*command)(HDACodecDevice *dev, uint32_t nid, uint32_t data);
  30. void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running, bool output);
  31. };
  32. void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus,
  33. hda_codec_response_func response,
  34. hda_codec_xfer_func xfer);
  35. void hda_codec_register(HDACodecDeviceInfo *info);
  36. HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad);
  37. void hda_codec_response(HDACodecDevice *dev, bool solicited, uint32_t response);
  38. bool hda_codec_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
  39. uint8_t *buf, uint32_t len);
  40. /* --------------------------------------------------------------------- */
  41. #define dprint(_dev, _level, _fmt, ...) \
  42. do { \
  43. if (_dev->debug >= _level) { \
  44. fprintf(stderr, "%s: ", _dev->name); \
  45. fprintf(stderr, _fmt, ## __VA_ARGS__); \
  46. } \
  47. } while (0)
  48. /* --------------------------------------------------------------------- */
  49. #endif