Skip to contentSkip to conversation

Make mixer emulation configurable at runtime

PATCH Superseded Bandan Das 2 participants 8 messages Sep 5, 2013 – Sep 7, 2013

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Bandan Das

author
#0 lore raw

v2 cover Make mixer emulation configurable at runtime

Currently, hda-codec mixer emulation can only be enabled by using the "--enable-mixemu" option to configure at compile time with the default value being off. These patches enable making mixer emulation selectable at runtime which is more convenient. Consequently, the last patch in this series removes the mixemu configuration option.

Example Usage:
1. -device hda-duplex,mixer=off
2. -device hda-duplex,mixer=on [Default]

v2:
* Add copyright information - Patch 1/3
* Edit description for readability - Patch 1/3
* Catch error paths in instance init functions - Patch 2/3
* Define "mixer" as a bool - Patch 2/3
* Preserve CONFIG_MIXEMU state - Patch 2/3
* Remove the --enable-mixemu configuration option - Patch 3/3

Bandan Das (3):
hda-codec: refactor common definitions into a header file
hda-codec: make mixemu selectable at runtime
audio: remove CONFIG_MIXEMU configure option and enable mixemu by
default

 configure                   |   8 -
 hw/audio/hda-codec-common.h | 456 ++++++++++++++++++++++++++++++++++++++++++++
 hw/audio/hda-codec.c        | 454 +++----------------------------------------
 3 files changed, 485 insertions(+), 433 deletions(-)
 create mode 100644 hw/audio/hda-codec-common.h
Signature · 1 line
1.8.1.4
author
#1 lore raw

PATCH v2 1/3 hda-codec: refactor common definitions into a header file

Move common defines and structs to a header file.
The next commit will include it twice, once for a device with a mixer, and once for device without a mixer.

---
 hw/audio/hda-codec-common.h | 449 ++++++++++++++++++++++++++++++++++++++++++++
 hw/audio/hda-codec.c        | 424 +----------------------------------------
 2 files changed, 450 insertions(+), 423 deletions(-)
 create mode 100644 hw/audio/hda-codec-common.h
hw/audio/hda-codec-common.h new file +449 -0
new file mode 100644
index 0000000..2f7e95f
@@ -0,0 +1,449 @@
+/*
+ * Common code to disable/enable mixer emulation at run time
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Written by Bandan Das <[email protected]>
+ * with important bits picked up from hda-codec.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * HDA codec descriptions
+ */
+
+#ifdef CONFIG_MIXEMU
+#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)
+#define QEMU_HDA_AMP_CAPS                                               \
+    (AC_AMPCAP_MUTE |                                                   \
+     (QEMU_HDA_AMP_STEPS << AC_AMPCAP_OFFSET_SHIFT)    |                \
+     (QEMU_HDA_AMP_STEPS << AC_AMPCAP_NUM_STEPS_SHIFT) |                \
+     (3                  << AC_AMPCAP_STEP_SIZE_SHIFT))
+#else
+#define QEMU_HDA_ID_OUTPUT  ((QEMU_HDA_ID_VENDOR << 16) | 0x11)
+#define QEMU_HDA_ID_DUPLEX  ((QEMU_HDA_ID_VENDOR << 16) | 0x21)
+#define QEMU_HDA_ID_MICRO   ((QEMU_HDA_ID_VENDOR << 16) | 0x31)
+#define QEMU_HDA_AMP_CAPS   QEMU_HDA_AMP_NONE
+#endif
+
+
+/* common: audio output widget */
+static const desc_param common_params_audio_dac[] = {
+    {
+        .id  = AC_PAR_AUDIO_WIDGET_CAP,
+        .val = ((AC_WID_AUD_OUT << AC_WCAP_TYPE_SHIFT) |
+                AC_WCAP_FORMAT_OVRD |
+                AC_WCAP_AMP_OVRD |
+                AC_WCAP_OUT_AMP |
+                AC_WCAP_STEREO),
+    },{
+        .id  = AC_PAR_PCM,
+        .val = QEMU_HDA_PCM_FORMATS,
+    },{
+        .id  = AC_PAR_STREAM,
+        .val = AC_SUPFMT_PCM,
+    },{
+        .id  = AC_PAR_AMP_IN_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },{
+        .id  = AC_PAR_AMP_OUT_CAP,
+        .val = QEMU_HDA_AMP_CAPS,
+    },
+};
+
+/* common: audio input widget */
+static const desc_param common_params_audio_adc[] = {
+    {
+        .id  = AC_PAR_AUDIO_WIDGET_CAP,
+        .val = ((AC_WID_AUD_IN << AC_WCAP_TYPE_SHIFT) |
+                AC_WCAP_CONN_LIST |
+                AC_WCAP_FORMAT_OVRD |
+                AC_WCAP_AMP_OVRD |
+                AC_WCAP_IN_AMP |
+                AC_WCAP_STEREO),
+    },{
+        .id  = AC_PAR_CONNLIST_LEN,
+        .val = 1,
+    },{
+        .id  = AC_PAR_PCM,
+        .val = QEMU_HDA_PCM_FORMATS,
+    },{
+        .id  = AC_PAR_STREAM,
+        .val = AC_SUPFMT_PCM,
+    },{
+        .id  = AC_PAR_AMP_IN_CAP,
+        .val = QEMU_HDA_AMP_CAPS,
+    },{
+        .id  = AC_PAR_AMP_OUT_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },
+};
+
+/* common: pin widget (line-out) */
+static const desc_param common_params_audio_lineout[] = {
+    {
+        .id  = AC_PAR_AUDIO_WIDGET_CAP,
+        .val = ((AC_WID_PIN << AC_WCAP_TYPE_SHIFT) |
+                AC_WCAP_CONN_LIST |
+                AC_WCAP_STEREO),
+    },{
+        .id  = AC_PAR_PIN_CAP,
+        .val = AC_PINCAP_OUT,
+    },{
+        .id  = AC_PAR_CONNLIST_LEN,
+        .val = 1,
+    },{
+        .id  = AC_PAR_AMP_IN_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },{
+        .id  = AC_PAR_AMP_OUT_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },
+};
+
+/* common: pin widget (line-in) */
+static const desc_param common_params_audio_linein[] = {
+    {
+        .id  = AC_PAR_AUDIO_WIDGET_CAP,
+        .val = ((AC_WID_PIN << AC_WCAP_TYPE_SHIFT) |
+                AC_WCAP_STEREO),
+    },{
+        .id  = AC_PAR_PIN_CAP,
+        .val = AC_PINCAP_IN,
+    },{
+        .id  = AC_PAR_AMP_IN_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },{
+        .id  = AC_PAR_AMP_OUT_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },
+};
+
+/* output: root node */
+static const desc_param output_params_root[] = {
+    {
+        .id  = AC_PAR_VENDOR_ID,
+        .val = QEMU_HDA_ID_OUTPUT,
+    },{
+        .id  = AC_PAR_SUBSYSTEM_ID,
+        .val = QEMU_HDA_ID_OUTPUT,
+    },{
+        .id  = AC_PAR_REV_ID,
+        .val = 0x00100101,
+    },{
+        .id  = AC_PAR_NODE_COUNT,
+        .val = 0x00010001,
+    },
+};
+
+/* output: audio function */
+static const desc_param output_params_audio_func[] = {
+    {
+        .id  = AC_PAR_FUNCTION_TYPE,
+        .val = AC_GRP_AUDIO_FUNCTION,
+    },{
+        .id  = AC_PAR_SUBSYSTEM_ID,
+        .val = QEMU_HDA_ID_OUTPUT,
+    },{
+        .id  = AC_PAR_NODE_COUNT,
+        .val = 0x00020002,
+    },{
+        .id  = AC_PAR_PCM,
+        .val = QEMU_HDA_PCM_FORMATS,
+    },{
+        .id  = AC_PAR_STREAM,
+        .val = AC_SUPFMT_PCM,
+    },{
+        .id  = AC_PAR_AMP_IN_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },{
+        .id  = AC_PAR_AMP_OUT_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },{
+        .id  = AC_PAR_GPIO_CAP,
+        .val = 0,
+    },{
+        .id  = AC_PAR_AUDIO_FG_CAP,
+        .val = 0x00000808,
+    },{
+        .id  = AC_PAR_POWER_STATE,
+        .val = 0,
+    },
+};
+
+/* output: nodes */
+static const desc_node output_nodes[] = {
+    {
+        .nid     = AC_NODE_ROOT,
+        .name    = "root",
+        .params  = output_params_root,
+        .nparams = ARRAY_SIZE(output_params_root),
+    },{
+        .nid     = 1,
+        .name    = "func",
+        .params  = output_params_audio_func,
+        .nparams = ARRAY_SIZE(output_params_audio_func),
+    },{
+        .nid     = 2,
+        .name    = "dac",
+        .params  = common_params_audio_dac,
+        .nparams = ARRAY_SIZE(common_params_audio_dac),
+        .stindex = 0,
+    },{
+        .nid     = 3,
+        .name    = "out",
+        .params  = common_params_audio_lineout,
+        .nparams = ARRAY_SIZE(common_params_audio_lineout),
+        .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) |
+                    (AC_JACK_COLOR_GREEN  << AC_DEFCFG_COLOR_SHIFT)     |
+                    0x10),
+        .pinctl  = AC_PINCTL_OUT_EN,
+        .conn    = (uint32_t[]) { 2 },
+    }
+};
+
+/* output: codec */
+static const desc_codec output = {
+    .name   = "output",
+    .iid    = QEMU_HDA_ID_OUTPUT,
+    .nodes  = output_nodes,
+    .nnodes = ARRAY_SIZE(output_nodes),
+};
+
+/* duplex: root node */
+static const desc_param duplex_params_root[] = {
+    {
+        .id  = AC_PAR_VENDOR_ID,
+        .val = QEMU_HDA_ID_DUPLEX,
+    },{
+        .id  = AC_PAR_SUBSYSTEM_ID,
+        .val = QEMU_HDA_ID_DUPLEX,
+    },{
+        .id  = AC_PAR_REV_ID,
+        .val = 0x00100101,
+    },{
+        .id  = AC_PAR_NODE_COUNT,
+        .val = 0x00010001,
+    },
+};
+
+/* duplex: audio function */
+static const desc_param duplex_params_audio_func[] = {
+    {
+        .id  = AC_PAR_FUNCTION_TYPE,
+        .val = AC_GRP_AUDIO_FUNCTION,
+    },{
+        .id  = AC_PAR_SUBSYSTEM_ID,
+        .val = QEMU_HDA_ID_DUPLEX,
+    },{
+        .id  = AC_PAR_NODE_COUNT,
+        .val = 0x00020004,
+    },{
+        .id  = AC_PAR_PCM,
+        .val = QEMU_HDA_PCM_FORMATS,
+    },{
+        .id  = AC_PAR_STREAM,
+        .val = AC_SUPFMT_PCM,
+    },{
+        .id  = AC_PAR_AMP_IN_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },{
+        .id  = AC_PAR_AMP_OUT_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },{
+        .id  = AC_PAR_GPIO_CAP,
+        .val = 0,
+    },{
+        .id  = AC_PAR_AUDIO_FG_CAP,
+        .val = 0x00000808,
+    },{
+        .id  = AC_PAR_POWER_STATE,
+        .val = 0,
+    },
+};
+
+/* duplex: nodes */
+static const desc_node duplex_nodes[] = {
+    {
+        .nid     = AC_NODE_ROOT,
+        .name    = "root",
+        .params  = duplex_params_root,
+        .nparams = ARRAY_SIZE(duplex_params_root),
+    },{
+        .nid     = 1,
+        .name    = "func",
+        .params  = duplex_params_audio_func,
+        .nparams = ARRAY_SIZE(duplex_params_audio_func),
+    },{
+        .nid     = 2,
+        .name    = "dac",
+        .params  = common_params_audio_dac,
+        .nparams = ARRAY_SIZE(common_params_audio_dac),
+        .stindex = 0,
+    },{
+        .nid     = 3,
+        .name    = "out",
+        .params  = common_params_audio_lineout,
+        .nparams = ARRAY_SIZE(common_params_audio_lineout),
+        .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) |
+                    (AC_JACK_COLOR_GREEN  << AC_DEFCFG_COLOR_SHIFT)     |
+                    0x10),
+        .pinctl  = AC_PINCTL_OUT_EN,
+        .conn    = (uint32_t[]) { 2 },
+    },{
+        .nid     = 4,
+        .name    = "adc",
+        .params  = common_params_audio_adc,
+        .nparams = ARRAY_SIZE(common_params_audio_adc),
+        .stindex = 1,
+        .conn    = (uint32_t[]) { 5 },
+    },{
+        .nid     = 5,
+        .name    = "in",
+        .params  = common_params_audio_linein,
+        .nparams = ARRAY_SIZE(common_params_audio_linein),
+        .config  = ((AC_JACK_PORT_COMPLEX << AC_DEFCFG_PORT_CONN_SHIFT) |
+                    (AC_JACK_LINE_IN      << AC_DEFCFG_DEVICE_SHIFT)    |
+                    (AC_JACK_CONN_UNKNOWN << AC_DEFCFG_CONN_TYPE_SHIFT) |
+                    (AC_JACK_COLOR_RED    << AC_DEFCFG_COLOR_SHIFT)     |
+                    0x20),
+        .pinctl  = AC_PINCTL_IN_EN,
+    }
+};
+
+/* duplex: codec */
+static const desc_codec duplex = {
+    .name   = "duplex",
+    .iid    = QEMU_HDA_ID_DUPLEX,
+    .nodes  = duplex_nodes,
+    .nnodes = ARRAY_SIZE(duplex_nodes),
+};
+
+/* micro: root node */
+static const desc_param micro_params_root[] = {
+    {
+        .id  = AC_PAR_VENDOR_ID,
+        .val = QEMU_HDA_ID_MICRO,
+    },{
+        .id  = AC_PAR_SUBSYSTEM_ID,
+        .val = QEMU_HDA_ID_MICRO,
+    },{
+        .id  = AC_PAR_REV_ID,
+        .val = 0x00100101,
+    },{
+        .id  = AC_PAR_NODE_COUNT,
+        .val = 0x00010001,
+    },
+};
+
+/* micro: audio function */
+static const desc_param micro_params_audio_func[] = {
+    {
+        .id  = AC_PAR_FUNCTION_TYPE,
+        .val = AC_GRP_AUDIO_FUNCTION,
+    },{
+        .id  = AC_PAR_SUBSYSTEM_ID,
+        .val = QEMU_HDA_ID_MICRO,
+    },{
+        .id  = AC_PAR_NODE_COUNT,
+        .val = 0x00020004,
+    },{
+        .id  = AC_PAR_PCM,
+        .val = QEMU_HDA_PCM_FORMATS,
+    },{
+        .id  = AC_PAR_STREAM,
+        .val = AC_SUPFMT_PCM,
+    },{
+        .id  = AC_PAR_AMP_IN_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },{
+        .id  = AC_PAR_AMP_OUT_CAP,
+        .val = QEMU_HDA_AMP_NONE,
+    },{
+        .id  = AC_PAR_GPIO_CAP,
+        .val = 0,
+    },{
+        .id  = AC_PAR_AUDIO_FG_CAP,
+        .val = 0x00000808,
+    },{
+        .id  = AC_PAR_POWER_STATE,
+        .val = 0,
+    },
+};
+
+/* micro: nodes */
+static const desc_node micro_nodes[] = {
+    {
+        .nid     = AC_NODE_ROOT,
+        .name    = "root",
+        .params  = micro_params_root,
+        .nparams = ARRAY_SIZE(micro_params_root),
+    },{
+        .nid     = 1,
+        .name    = "func",
+        .params  = micro_params_audio_func,
+        .nparams = ARRAY_SIZE(micro_params_audio_func),
+    },{
+        .nid     = 2,
+        .name    = "dac",
+        .params  = common_params_audio_dac,
+        .nparams = ARRAY_SIZE(common_params_audio_dac),
+        .stindex = 0,
+    },{
+        .nid     = 3,
+        .name    = "out",
+        .params  = common_params_audio_lineout,
+        .nparams = ARRAY_SIZE(common_params_audio_lineout),
+        .config  = ((AC_JACK_PORT_COMPLEX << AC_DEFCFG_PORT_CONN_SHIFT) |
+                    (AC_JACK_SPEAKER      << AC_DEFCFG_DEVICE_SHIFT)    |
+                    (AC_JACK_CONN_UNKNOWN << AC_DEFCFG_CONN_TYPE_SHIFT) |
+                    (AC_JACK_COLOR_GREEN  << AC_DEFCFG_COLOR_SHIFT)     |
+                    0x10),
+        .pinctl  = AC_PINCTL_OUT_EN,
+        .conn    = (uint32_t[]) { 2 },
+    },{
+        .nid     = 4,
+        .name    = "adc",
+        .params  = common_params_audio_adc,
+        .nparams = ARRAY_SIZE(common_params_audio_adc),
+        .stindex = 1,
+        .conn    = (uint32_t[]) { 5 },
+    },{
+        .nid     = 5,
+        .name    = "in",
+        .params  = common_params_audio_linein,
+        .nparams = ARRAY_SIZE(common_params_audio_linein),
+        .config  = ((AC_JACK_PORT_COMPLEX << AC_DEFCFG_PORT_CONN_SHIFT) |
+                    (AC_JACK_MIC_IN       << AC_DEFCFG_DEVICE_SHIFT)    |
+                    (AC_JACK_CONN_UNKNOWN << AC_DEFCFG_CONN_TYPE_SHIFT) |
+                    (AC_JACK_COLOR_RED    << AC_DEFCFG_COLOR_SHIFT)     |
+                    0x20),
+        .pinctl  = AC_PINCTL_IN_EN,
+    }
+};
+
+/* micro: codec */
+static const desc_codec micro = {
+    .name   = "micro",
+    .iid    = QEMU_HDA_ID_MICRO,
+    .nodes  = micro_nodes,
+    .nnodes = ARRAY_SIZE(micro_nodes),
+};
hw/audio/hda-codec.c +1 -423

430 lines not on this page · raw message

Signature · 1 line
1.8.1.4
author
#2 lore raw

PATCH v2 2/3 hda-codec: make mixemu selectable at runtime

In reply to Bandan Das

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.

---
 hw/audio/hda-codec-common.h | 117 +++++++++++++++++++++++---------------------
 hw/audio/hda-codec.c        |  69 ++++++++++++++++++++++++--
 2 files changed, 127 insertions(+), 59 deletions(-)
hw/audio/hda-codec-common.h +62 -55
index 2f7e95f..b4fdb51 100644
@@ -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 const desc_param glue(duplex_params_root_, PARAM)[] = {
     {
         .id  = AC_PAR_VENDOR_ID,
         .val = QEMU_HDA_ID_DUPLEX,
@@ -244,7 +244,7 @@ static const desc_param duplex_params_root[] = {
 };
 
 /* duplex: audio function */
-static const desc_param duplex_params_audio_func[] = {
+static const desc_param glue(duplex_params_audio_func_, PARAM)[] = {
     {
         .id  = AC_PAR_FUNCTION_TYPE,
         .val = AC_GRP_AUDIO_FUNCTION,
@@ -279,28 +279,28 @@ static const desc_param duplex_params_audio_func[] = {
 };
 
 /* duplex: nodes */
-static const desc_node duplex_nodes[] = {
+static const desc_node glue(duplex_nodes_, PARAM)[] = {
     {
         .nid     = AC_NODE_ROOT,
         .name    = "root",
-        .params  = duplex_params_root,
-        .nparams = ARRAY_SIZE(duplex_params_root),
+        .params  = glue(duplex_params_root_, PARAM),
+        .nparams = ARRAY_SIZE(glue(duplex_params_root_, PARAM)),
     },{
         .nid     = 1,
         .name    = "func",
-        .params  = duplex_params_audio_func,
-        .nparams = ARRAY_SIZE(duplex_params_audio_func),
+        .params  = glue(duplex_params_audio_func_, PARAM),
+        .nparams = ARRAY_SIZE(glue(duplex_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) |
@@ -311,15 +311,15 @@ static const desc_node duplex_nodes[] = {
     },{
         .nid     = 4,
         .name    = "adc",
-        .params  = common_params_audio_adc,
-        .nparams = ARRAY_SIZE(common_params_audio_adc),
+        .params  = glue(common_params_audio_adc_, PARAM),
+        .nparams = ARRAY_SIZE(glue(common_params_audio_adc_, PARAM)),
         .stindex = 1,
         .conn    = (uint32_t[]) { 5 },
     },{
         .nid     = 5,
         .name    = "in",
-        .params  = common_params_audio_linein,
-        .nparams = ARRAY_SIZE(common_params_audio_linein),
+        .params  = glue(common_params_audio_linein_, PARAM),
+        .nparams = ARRAY_SIZE(glue(common_params_audio_linein_, PARAM)),
         .config  = ((AC_JACK_PORT_COMPLEX << AC_DEFCFG_PORT_CONN_SHIFT) |
                     (AC_JACK_LINE_IN      << AC_DEFCFG_DEVICE_SHIFT)    |
                     (AC_JACK_CONN_UNKNOWN << AC_DEFCFG_CONN_TYPE_SHIFT) |
@@ -330,15 +330,15 @@ static const desc_node duplex_nodes[] = {
 };
 
 /* duplex: codec */
-static const desc_codec duplex = {
+static const desc_codec glue(duplex_, PARAM) = {
     .name   = "duplex",
     .iid    = QEMU_HDA_ID_DUPLEX,
-    .nodes  = duplex_nodes,
-    .nnodes = ARRAY_SIZE(duplex_nodes),
+    .nodes  = glue(duplex_nodes_, PARAM),
+    .nnodes = ARRAY_SIZE(glue(duplex_nodes_, PARAM)),
 };
 
 /* micro: root node */
-static const desc_param micro_params_root[] = {
+static const desc_param glue(micro_params_root_, PARAM)[] = {
     {
         .id  = AC_PAR_VENDOR_ID,
         .val = QEMU_HDA_ID_MICRO,
@@ -355,7 +355,7 @@ static const desc_param micro_params_root[] = {
 };
 
 /* micro: audio function */
-static const desc_param micro_params_audio_func[] = {
+static const desc_param glue(micro_params_audio_func_, PARAM)[] = {
     {
         .id  = AC_PAR_FUNCTION_TYPE,
         .val = AC_GRP_AUDIO_FUNCTION,
@@ -390,28 +390,28 @@ static const desc_param micro_params_audio_func[] = {
 };
 
 /* micro: nodes */
-static const desc_node micro_nodes[] = {
+static const desc_node glue(micro_nodes_, PARAM)[] = {
     {
         .nid     = AC_NODE_ROOT,
         .name    = "root",
-        .params  = micro_params_root,
-        .nparams = ARRAY_SIZE(micro_params_root),
+        .params  = glue(micro_params_root_, PARAM),
+        .nparams = ARRAY_SIZE(glue(micro_params_root_, PARAM)),
     },{
         .nid     = 1,
         .name    = "func",
-        .params  = micro_params_audio_func,
-        .nparams = ARRAY_SIZE(micro_params_audio_func),
+        .params  = glue(micro_params_audio_func_, PARAM),
+        .nparams = ARRAY_SIZE(glue(micro_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_SPEAKER      << AC_DEFCFG_DEVICE_SHIFT)    |
                     (AC_JACK_CONN_UNKNOWN << AC_DEFCFG_CONN_TYPE_SHIFT) |
@@ -422,15 +422,15 @@ static const desc_node micro_nodes[] = {
     },{
         .nid     = 4,
         .name    = "adc",
-        .params  = common_params_audio_adc,
-        .nparams = ARRAY_SIZE(common_params_audio_adc),
+        .params  = glue(common_params_audio_adc_, PARAM),
+        .nparams = ARRAY_SIZE(glue(common_params_audio_adc_, PARAM)),
         .stindex = 1,
         .conn    = (uint32_t[]) { 5 },
     },{
         .nid     = 5,
         .name    = "in",
-        .params  = common_params_audio_linein,
-        .nparams = ARRAY_SIZE(common_params_audio_linein),
+        .params  = glue(common_params_audio_linein_, PARAM),
+        .nparams = ARRAY_SIZE(glue(common_params_audio_linein_, PARAM)),
         .config  = ((AC_JACK_PORT_COMPLEX << AC_DEFCFG_PORT_CONN_SHIFT) |
                     (AC_JACK_MIC_IN       << AC_DEFCFG_DEVICE_SHIFT)    |
                     (AC_JACK_CONN_UNKNOWN << AC_DEFCFG_CONN_TYPE_SHIFT) |
@@ -441,9 +441,16 @@ static const desc_node micro_nodes[] = {
 };
 
 /* micro: codec */
-static const desc_codec micro = {
+static const desc_codec glue(micro_, PARAM) = {
     .name   = "micro",
     .iid    = QEMU_HDA_ID_MICRO,
-    .nodes  = micro_nodes,
-    .nnodes = ARRAY_SIZE(micro_nodes),
+    .nodes  = glue(micro_nodes_, PARAM),
+    .nnodes = ARRAY_SIZE(glue(micro_nodes_, PARAM)),
 };
+
+#undef PARAM
+#undef HDA_MIXER
+#undef QEMU_HDA_ID_OUTPUT
+#undef QEMU_HDA_ID_DUPLEX
+#undef QEMU_HDA_ID_MICRO
+#undef QEMU_HDA_AMP_CAPS
hw/audio/hda-codec.c +65 -4

101 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#3 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] hda-codec: make mixemu selectable at runtime

Quoted 5 lines
hw/audio/hda-codec.c +0 -0
@@ -118,7 +118,20 @@ static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as)
 #define QEMU_HDA_AMP_NONE    (0)
 #define QEMU_HDA_AMP_STEPS   0x4a

hw/audio/hda-codec.c static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as) · line 129

Quoted 10 lines
hw/audio/hda-codec.c +8 -0
 
+#ifdef CONFIG_MIXEMU
+#define   PARAM mixemu
+#define   HDA_MIXER
 #include "hda-codec-common.h"
+#else
+/* keep the compiler quiet */
+static const desc_codec output_mixemu;
+static const desc_codec duplex_mixemu;
+static const desc_codec micro_mixemu;

Needed? The *_mixemu variants are not referenced without CONFIG_MIXEMU

hw/audio/hda-codec.c static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as) · line 132

Quoted 3 lines
hw/audio/hda-codec.c +3 -0
+#endif
+
+#define   PARAM nomixemu

#undefine HDA_MIXER

hw/audio/hda-codec.c static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as) · line 134

Quoted 2 lines
hw/audio/hda-codec.c +2 -0
+#include  "hda-codec-common.h"
+

cheers,
Gerd

author
#4 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] hda-codec: make mixemu selectable at runtime

Quoted 6 lines · Gerd Hoffmann
Quoted 6 lines
hw/audio/hda-codec.c +0 -0
@@ -118,7 +118,20 @@ static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as)
 #define QEMU_HDA_AMP_NONE    (0)
 #define QEMU_HDA_AMP_STEPS   0x4a
 
Quoted 11 lines

hw/audio/hda-codec.c static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as) · line 129

Quoted 9 lines
hw/audio/hda-codec.c +8 -0
+#ifdef CONFIG_MIXEMU
+#define   PARAM mixemu
+#define   HDA_MIXER
 #include "hda-codec-common.h"
+#else
+/* keep the compiler quiet */
+static const desc_codec output_mixemu;
+static const desc_codec duplex_mixemu;
+static const desc_codec micro_mixemu;

Needed? The *_mixemu variants are not referenced without CONFIG_MIXEMU

Indeed, they are not needed anymore. Thanks for the catch. I will fix this in a follow-up post.

Quoted 6 lines

hw/audio/hda-codec.c static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as) · line 132

Quoted 3 lines
hw/audio/hda-codec.c +3 -0
+#endif
+
+#define   PARAM nomixemu

#undefine HDA_MIXER

This is not needed as I already undef this in the header file.

Quoted 5 lines

hw/audio/hda-codec.c static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as) · line 134

Quoted 2 lines
hw/audio/hda-codec.c +2 -0
+#include  "hda-codec-common.h"
+

cheers,
Gerd

author
#5 lore raw

PATCH v2 3/3 audio: remove CONFIG_MIXEMU configure option and enable mixemu by default

In reply to Bandan Das

Set mixer property to on by default. Also, always include two versions of devices (with and without mixemu) so that user can select one of them at runtime.

---
 audio/mixeng.c       |  6 ------
 configure            |  8 --------
 hw/audio/hda-codec.c | 35 -----------------------------------
 3 files changed, 49 deletions(-)
audio/mixeng.c +0 -6
index 02a9d9f..0e4976f 100644
@@ -348,7 +348,6 @@ void mixeng_clear (struct st_sample *buf, int len)
 
 void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *vol)
 {
-#ifdef CONFIG_MIXEMU
     if (vol->mute) {
         mixeng_clear (buf, len);
         return;
@@ -364,9 +363,4 @@ void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *vol)
 #endif
         buf += 1;
     }
-#else
-    (void) buf;
-    (void) len;
-    (void) vol;
-#endif
 }
configure +0 -8
index 18fa608..a908c5b 100755
@@ -215,7 +215,6 @@ linux_user="no"
 bsd_user="no"
 guest_base="yes"
 uname_release=""
-mixemu="no"
 aix="no"
 blobs="yes"
 pkgversion=""
@@ -855,8 +854,6 @@ for opt do
   ;;
   --enable-fdt) fdt="yes"
   ;;
-  --enable-mixemu) mixemu="yes"
-  ;;
   --disable-linux-aio) linux_aio="no"
   ;;
   --enable-linux-aio) linux_aio="yes"
@@ -1067,7 +1064,6 @@ echo "                           (affects only QEMU, not qemu-img)"
 echo "  --block-drv-ro-whitelist=L"
 echo "                           set block driver read-only whitelist"
 echo "                           (affects only QEMU, not qemu-img)"
-echo "  --enable-mixemu          enable mixer emulation"
 echo "  --disable-xen            disable xen backend driver support"
 echo "  --enable-xen             enable xen backend driver support"
 echo "  --disable-xen-pci-passthrough"
@@ -3554,7 +3550,6 @@ echo "mingw32 support   $mingw32"
 echo "Audio drivers     $audio_drv_list"
 echo "Block whitelist (rw) $block_drv_rw_whitelist"
 echo "Block whitelist (ro) $block_drv_ro_whitelist"
-echo "Mixer emulation   $mixemu"
 echo "VirtFS support    $virtfs"
 echo "VNC support       $vnc"
 if test "$vnc" = "yes" ; then
@@ -3735,9 +3730,6 @@ if test "$audio_win_int" = "yes" ; then
 fi
 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
-if test "$mixemu" = "yes" ; then
-  echo "CONFIG_MIXEMU=y" >> $config_host_mak
-fi
 if test "$vnc" = "yes" ; then
   echo "CONFIG_VNC=y" >> $config_host_mak
 fi
hw/audio/hda-codec.c +0 -35
index b14fae5..07a43bf 100644
@@ -118,16 +118,9 @@ 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"
-#else
-/* keep the compiler quiet */
-static const desc_codec output_mixemu;
-static const desc_codec duplex_mixemu;
-static const desc_codec micro_mixemu;
-#endif
 
 #define   PARAM nomixemu
 #include  "hda-codec-common.h"
@@ -599,11 +592,7 @@ static const VMStateDescription vmstate_hda_audio = {
 
 static Property hda_audio_properties[] = {
     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(),
 };
 
@@ -614,15 +603,7 @@ static int hda_audio_init_output(HDACodecDevice *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
-
     }
 }
 
@@ -633,15 +614,7 @@ static int hda_audio_init_duplex(HDACodecDevice *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
-
     }
 }
 
@@ -652,15 +625,7 @@ static int hda_audio_init_micro(HDACodecDevice *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
-
     }
 }
 
Signature · 1 line
1.8.1.4
#6 lore raw

Re: [Qemu-devel] [PATCH v2 3/3] audio: remove CONFIG_MIXEMU configure option and enable mixemu by default

Quoted 1 line · Bandan Das

Set mixer property to on by default.

The "by default" in the commit message is a bit misleading. There is no default any more once CONFIG_MIXEMU is gone ...

Quoted 3 lines

Also, always include two versions
of devices (with and without mixemu) so that user can select one of them at runtime.

That applies to hda audio only, and it's patch #2 actually implementing that (for the CONFIG_MIXEMU=y case).

cheers,
Gerd

author
#7 lore raw

Re: [Qemu-devel] [PATCH v2 3/3] audio: remove CONFIG_MIXEMU configure option and enable mixemu by default

Quoted 5 lines · Gerd Hoffmann
Quoted 1 line · Bandan Das

Set mixer property to on by default.

The "by default" in the commit message is a bit misleading. There is no default any more once CONFIG_MIXEMU is gone ...

I was actually referring to the mixemu property which is hda-codec specific; should have worded it better. Anyway, the commit message:
"audio: remove CONFIG_MIXEMU configure option" is descriptive enough I think.

Quoted 7 lines
Quoted 3 lines

Also, always include two versions
of devices (with and without mixemu) so that user can select one of them at runtime.

That applies to hda audio only, and it's patch #2 actually implementing that (for the CONFIG_MIXEMU=y case).

Yes, you are right. This is hda-codec specific and while patch 2 adds both versions only when CONFIG_MIXEMU is defined, this change adds both versions unconditionally. Again, probably evident enough since CONFIG_MIXEMU is being removed, so I will remove this part from the commit message.

Thanks,
Bandan

Quoted 2 lines

cheers,
Gerd