summaryrefslogtreecommitdiffstats
path: root/hw/audio/hda-codec.c
diff options
context:
space:
mode:
authorBandan Das <bsd@redhat.com>2013-09-07 00:53:59 -0400
committerGerd Hoffmann <kraxel@redhat.com>2013-09-24 10:29:34 +0200
commit2690e61e8e313461428334586ed9dbf56531dae9 (patch)
tree1439e7e374cc330b97d19d02c03f9633d10ecbbc /hw/audio/hda-codec.c
parent7953793c033343dbea97836645edbe4e61754b11 (diff)
downloadhqemu-2690e61e8e313461428334586ed9dbf56531dae9.zip
hqemu-2690e61e8e313461428334586ed9dbf56531dae9.tar.gz
hda-codec: make mixemu selectable at runtime
Define PARAM so that we have two versions of the "desc_codec and family" structs. Add a property called "mixer" whose default value depends on whether CONFIG_MIXEMU is defined or not which will help us call the appropriate instance init functions. Signed-off-by: Bandan Das <bsd@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/audio/hda-codec.c')
-rw-r--r--hw/audio/hda-codec.c64
1 files changed, 60 insertions, 4 deletions
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index 65fbb2a..19a8a0e 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -118,7 +118,15 @@ static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as)
#define QEMU_HDA_AMP_NONE (0)
#define QEMU_HDA_AMP_STEPS 0x4a
+#ifdef CONFIG_MIXEMU
+#define PARAM mixemu
+#define HDA_MIXER
#include "hda-codec-common.h"
+#endif
+
+#define PARAM nomixemu
+#include "hda-codec-common.h"
+
/* -------------------------------------------------------------------------- */
static const char *fmt2name[] = {
@@ -163,6 +171,7 @@ struct HDAAudioState {
/* properties */
uint32_t debug;
+ bool mixer;
};
static void hda_audio_input_cb(void *opaque, int avail)
@@ -584,23 +593,70 @@ static const VMStateDescription vmstate_hda_audio = {
};
static Property hda_audio_properties[] = {
- DEFINE_PROP_UINT32("debug", HDAAudioState, debug, 0),
+ DEFINE_PROP_UINT32("debug", HDAAudioState, debug, 0),
+#ifdef CONFIG_MIXEMU
+ DEFINE_PROP_BOOL("mixer", HDAAudioState, mixer, true),
+#else
+ DEFINE_PROP_BOOL("mixer", HDAAudioState, mixer, false),
+#endif
DEFINE_PROP_END_OF_LIST(),
};
static int hda_audio_init_output(HDACodecDevice *hda)
{
- return hda_audio_init(hda, &output);
+ HDAAudioState *a = DO_UPCAST(HDAAudioState, hda, hda);
+
+ if (!a->mixer) {
+ return hda_audio_init(hda, &output_nomixemu);
+ } else {
+
+#ifdef CONFIG_MIXEMU
+ return hda_audio_init(hda, &output_mixemu);
+#else
+ fprintf(stderr, "ERROR: "
+ "hda-codec : Mixer emulation has not been compiled in!\n");
+ return -1;
+#endif
+
+ }
}
static int hda_audio_init_duplex(HDACodecDevice *hda)
{
- return hda_audio_init(hda, &duplex);
+ HDAAudioState *a = DO_UPCAST(HDAAudioState, hda, hda);
+
+ if (!a->mixer) {
+ return hda_audio_init(hda, &duplex_nomixemu);
+ } else {
+
+#ifdef CONFIG_MIXEMU
+ return hda_audio_init(hda, &duplex_mixemu);
+#else
+ fprintf(stderr, "ERROR: "
+ "hda-codec : Mixer emulation has not been compiled in!\n");
+ return -1;
+#endif
+
+ }
}
static int hda_audio_init_micro(HDACodecDevice *hda)
{
- return hda_audio_init(hda, &micro);
+ HDAAudioState *a = DO_UPCAST(HDAAudioState, hda, hda);
+
+ if (!a->mixer) {
+ return hda_audio_init(hda, &micro_nomixemu);
+ } else {
+
+#ifdef CONFIG_MIXEMU
+ return hda_audio_init(hda, &micro_mixemu);
+#else
+ fprintf(stderr, "ERROR: "
+ "hda-codec : Mixer emulation has not been compiled in!\n");
+ return -1;
+#endif
+
+ }
}
static void hda_audio_output_class_init(ObjectClass *klass, void *data)
OpenPOWER on IntegriCloud