2010-11-01 15:05:32 +03:00
|
|
|
#ifndef HW_INTEL_HDA_H
|
|
|
|
#define HW_INTEL_HDA_H
|
|
|
|
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-core.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2010-11-01 15:05:32 +03:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* hda bus */
|
|
|
|
|
2011-12-16 23:39:51 +04:00
|
|
|
#define TYPE_HDA_CODEC_DEVICE "hda-codec"
|
2020-09-01 00:07:37 +03:00
|
|
|
OBJECT_DECLARE_TYPE(HDACodecDevice, HDACodecDeviceClass,
|
qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros
One of the goals of having less boilerplate on QOM declarations
is to avoid human error. Requiring an extra argument that is
never used is an opportunity for mistakes.
Remove the unused argument from OBJECT_DECLARE_TYPE and
OBJECT_DECLARE_SIMPLE_TYPE.
Coccinelle patch used to convert all users of the macros:
@@
declarer name OBJECT_DECLARE_TYPE;
identifier InstanceType, ClassType, lowercase, UPPERCASE;
@@
OBJECT_DECLARE_TYPE(InstanceType, ClassType,
- lowercase,
UPPERCASE);
@@
declarer name OBJECT_DECLARE_SIMPLE_TYPE;
identifier InstanceType, lowercase, UPPERCASE;
@@
OBJECT_DECLARE_SIMPLE_TYPE(InstanceType,
- lowercase,
UPPERCASE);
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Paul Durrant <paul@xen.org>
Acked-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20200916182519.415636-4-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2020-09-16 21:25:17 +03:00
|
|
|
HDA_CODEC_DEVICE)
|
2011-12-16 23:39:51 +04:00
|
|
|
|
2012-05-02 11:00:20 +04:00
|
|
|
#define TYPE_HDA_BUS "HDA"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(HDACodecBus, HDA_BUS)
|
2012-05-02 11:00:20 +04:00
|
|
|
|
2010-11-01 15:05:32 +03:00
|
|
|
|
|
|
|
typedef void (*hda_codec_response_func)(HDACodecDevice *dev,
|
|
|
|
bool solicited, uint32_t response);
|
|
|
|
typedef bool (*hda_codec_xfer_func)(HDACodecDevice *dev,
|
|
|
|
uint32_t stnr, bool output,
|
|
|
|
uint8_t *buf, uint32_t len);
|
|
|
|
|
|
|
|
struct HDACodecBus {
|
|
|
|
BusState qbus;
|
|
|
|
uint32_t next_cad;
|
|
|
|
hda_codec_response_func response;
|
|
|
|
hda_codec_xfer_func xfer;
|
|
|
|
};
|
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct HDACodecDeviceClass {
|
2011-12-16 23:39:51 +04:00
|
|
|
DeviceClass parent_class;
|
2010-11-01 15:05:32 +03:00
|
|
|
|
|
|
|
int (*init)(HDACodecDevice *dev);
|
2017-04-26 15:53:08 +03:00
|
|
|
void (*exit)(HDACodecDevice *dev);
|
2010-11-01 15:05:32 +03:00
|
|
|
void (*command)(HDACodecDevice *dev, uint32_t nid, uint32_t data);
|
2011-10-25 18:53:01 +04:00
|
|
|
void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running, bool output);
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2011-12-16 23:39:51 +04:00
|
|
|
|
|
|
|
struct HDACodecDevice {
|
|
|
|
DeviceState qdev;
|
|
|
|
uint32_t cad; /* codec address */
|
2010-11-01 15:05:32 +03:00
|
|
|
};
|
|
|
|
|
2013-08-23 22:05:16 +04:00
|
|
|
void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, size_t bus_size,
|
2010-11-01 15:05:32 +03:00
|
|
|
hda_codec_response_func response,
|
|
|
|
hda_codec_xfer_func xfer);
|
|
|
|
HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad);
|
|
|
|
|
|
|
|
void hda_codec_response(HDACodecDevice *dev, bool solicited, uint32_t response);
|
|
|
|
bool hda_codec_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
|
|
|
|
uint8_t *buf, uint32_t len);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define dprint(_dev, _level, _fmt, ...) \
|
|
|
|
do { \
|
|
|
|
if (_dev->debug >= _level) { \
|
|
|
|
fprintf(stderr, "%s: ", _dev->name); \
|
|
|
|
fprintf(stderr, _fmt, ## __VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#endif
|