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
---
hw/audio/hda-codec-common.h | 117 +++-
hw/audio/hda-codec.c| 69 --
2 files changed, 127 insertions(+), 59 deletions(-)
diff --git a/hw/audio/hda-codec-common.h b/hw/audio/hda-codec-common.h
index 2f7e95f..b4fdb51 100644
--- a/hw/audio/hda-codec-common.h
+++ b/hw/audio/hda-codec-common.h
@@ -24,7 +24,7 @@
* HDA codec descriptions
*/
-#ifdef CONFIG_MIXEMU
+#ifdef HDA_MIXER
#define QEMU_HDA_ID_OUTPUT ((QEMU_HDA_ID_VENDOR << 16) | 0x12)
#define QEMU_HDA_ID_DUPLEX ((QEMU_HDA_ID_VENDOR << 16) | 0x22)
#define QEMU_HDA_ID_MICRO ((QEMU_HDA_ID_VENDOR << 16) | 0x32)
@@ -42,7 +42,7 @@
/* common: audio output widget */
-static const desc_param common_params_audio_dac[] = {
+static const desc_param glue(common_params_audio_dac_, PARAM)[] = {
{
.id = AC_PAR_AUDIO_WIDGET_CAP,
.val = ((AC_WID_AUD_OUT << AC_WCAP_TYPE_SHIFT) |
@@ -66,7 +66,7 @@ static const desc_param common_params_audio_dac[] = {
};
/* common: audio input widget */
-static const desc_param common_params_audio_adc[] = {
+static const desc_param glue(common_params_audio_adc_, PARAM)[] = {
{
.id = AC_PAR_AUDIO_WIDGET_CAP,
.val = ((AC_WID_AUD_IN << AC_WCAP_TYPE_SHIFT) |
@@ -94,7 +94,7 @@ static const desc_param common_params_audio_adc[] = {
};
/* common: pin widget (line-out) */
-static const desc_param common_params_audio_lineout[] = {
+static const desc_param glue(common_params_audio_lineout_, PARAM)[] = {
{
.id = AC_PAR_AUDIO_WIDGET_CAP,
.val = ((AC_WID_PIN << AC_WCAP_TYPE_SHIFT) |
@@ -116,7 +116,7 @@ static const desc_param common_params_audio_lineout[] = {
};
/* common: pin widget (line-in) */
-static const desc_param common_params_audio_linein[] = {
+static const desc_param glue(common_params_audio_linein_, PARAM)[] = {
{
.id = AC_PAR_AUDIO_WIDGET_CAP,
.val = ((AC_WID_PIN << AC_WCAP_TYPE_SHIFT) |
@@ -134,7 +134,7 @@ static const desc_param common_params_audio_linein[] = {
};
/* output: root node */
-static const desc_param output_params_root[] = {
+static const desc_param glue(output_params_root_, PARAM)[] = {
{
.id = AC_PAR_VENDOR_ID,
.val = QEMU_HDA_ID_OUTPUT,
@@ -151,7 +151,7 @@ static const desc_param output_params_root[] = {
};
/* output: audio function */
-static const desc_param output_params_audio_func[] = {
+static const desc_param glue(output_params_audio_func_, PARAM)[] = {
{
.id = AC_PAR_FUNCTION_TYPE,
.val = AC_GRP_AUDIO_FUNCTION,
@@ -186,28 +186,28 @@ static const desc_param output_params_audio_func[] = {
};
/* output: nodes */
-static const desc_node output_nodes[] = {
+static const desc_node glue(output_nodes_, PARAM)[] = {
{
.nid = AC_NODE_ROOT,
.name= "root",
-.params = output_params_root,
-.nparams = ARRAY_SIZE(output_params_root),
+.params = glue(output_params_root_, PARAM),
+.nparams = ARRAY_SIZE(glue(output_params_root_, PARAM)),
},{
.nid = 1,
.name= "func",
-.params = output_params_audio_func,
-.nparams = ARRAY_SIZE(output_params_audio_func),
+.params = glue(output_params_audio_func_, PARAM),
+.nparams = ARRAY_SIZE(glue(output_params_audio_func_, PARAM)),
},{
.nid = 2,
.name= "dac",
-.params = common_params_audio_dac,
-.nparams = ARRAY_SIZE(common_params_audio_dac),
+.params = glue(common_params_audio_dac_, PARAM),
+.nparams = ARRAY_SIZE(glue(common_params_audio_dac_, PARAM)),
.stindex = 0,
},{
.nid = 3,
.name= "out",
-.params = common_params_audio_lineout,
-.nparams = ARRAY_SIZE(common_params_audio_lineout),
+.params = glue(common_params_audio_lineout_, PARAM),
+.nparams = ARRAY_SIZE(glue(common_params_audio_lineout_, PARAM)),
.config = ((AC_JACK_PORT_COMPLEX << AC_DEFCFG_PORT_CONN_SHIFT) |
(AC_JACK_LINE_OUT << AC_DEFCFG_DEVICE_SHIFT)|
(AC_JACK_CONN_UNKNOWN << AC_DEFCFG_CONN_TYPE_SHIFT) |
@@ -219,15 +219,15 @@ static const desc_node output_nodes[] = {
};
/* output: codec */
-static const desc_codec output = {
+static const desc_codec glue(output_, PARAM) = {
.name = "output",
.iid= QEMU_HDA_ID_OUTPUT,
-.nodes = output_nodes,
-.nnodes = ARRAY_SIZE(output_nodes),
+.nodes = glue(output_nodes_, PARAM),
+.nnodes = ARRAY_SIZE(glue(output_nodes_, PARAM)),
};
/* duplex: root node */
-static const desc_param duplex_params_root[] = {
+static co