qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime
@ 2013-08-27 19:17 Bandan Das
  2013-08-27 19:17 ` [Qemu-devel] [PATCH 1/2] hda-codec: refactor common definitions into a header file Bandan Das
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Bandan Das @ 2013-08-27 19:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Markus Armbruster

Currently, hda-codec mixer emulation can only be enabled by using the
"--enable-mixemu" option to configure at compile time. These patches add 
the option to make it configurable at runtime as well. 

An example usage could be a qemu cmdline  : 
"-device hda-duplex,mixer=(on/off)" although this 
is not part of this change.

Bandan Das (2):
  hda-codec: refactor common definitions into a header file
  hda-codec: make mixemu selectable at runtime

 hw/audio/hda-codec-common.h | 433 ++++++++++++++++++++++++++++++++++++++++
 hw/audio/hda-codec.c        | 472 +++++---------------------------------------
 2 files changed, 479 insertions(+), 426 deletions(-)
 create mode 100644 hw/audio/hda-codec-common.h

-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 1/2] hda-codec: refactor common definitions into a header file
  2013-08-27 19:17 [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime Bandan Das
@ 2013-08-27 19:17 ` Bandan Das
  2013-08-28  8:02   ` Markus Armbruster
  2013-08-27 19:17 ` [Qemu-devel] [PATCH 2/2] hda-codec: make mixemu selectable at runtime Bandan Das
  2013-08-28  9:13 ` [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable " Markus Armbruster
  2 siblings, 1 reply; 12+ messages in thread
From: Bandan Das @ 2013-08-27 19:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Markus Armbruster

Move common defines and structs to a header file.
We will then include these twice in hda-codec.c - 
a version with mixer enabled and another with not enabled.

Signed-off-by: Bandan Das <bsd@redhat.com>
---
 hw/audio/hda-codec-common.h | 427 ++++++++++++++++++++++++++++++++++++++++++++
 hw/audio/hda-codec.c        | 424 +------------------------------------------
 2 files changed, 428 insertions(+), 423 deletions(-)
 create mode 100644 hw/audio/hda-codec-common.h

diff --git a/hw/audio/hda-codec-common.h b/hw/audio/hda-codec-common.h
new file mode 100644
index 0000000..8433e40
--- /dev/null
+++ b/hw/audio/hda-codec-common.h
@@ -0,0 +1,427 @@
+/*
+ * 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),
+};
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index 9550c97..65fbb2a 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -118,429 +118,7 @@ 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 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),
-};
-
+#include "hda-codec-common.h"
 /* -------------------------------------------------------------------------- */
 
 static const char *fmt2name[] = {
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 2/2] hda-codec: make mixemu selectable at runtime
  2013-08-27 19:17 [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime Bandan Das
  2013-08-27 19:17 ` [Qemu-devel] [PATCH 1/2] hda-codec: refactor common definitions into a header file Bandan Das
@ 2013-08-27 19:17 ` Bandan Das
  2013-08-28  9:13 ` [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable " Markus Armbruster
  2 siblings, 0 replies; 12+ messages in thread
From: Bandan Das @ 2013-08-27 19:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Markus Armbruster

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>
---
 hw/audio/hda-codec-common.h | 114 +++++++++++++++++++++++---------------------
 hw/audio/hda-codec.c        |  48 +++++++++++++++++--
 2 files changed, 105 insertions(+), 57 deletions(-)

diff --git a/hw/audio/hda-codec-common.h b/hw/audio/hda-codec-common.h
index 8433e40..01319af 100644
--- a/hw/audio/hda-codec-common.h
+++ b/hw/audio/hda-codec-common.h
@@ -20,7 +20,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) |
@@ -44,7 +44,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) |
@@ -72,7 +72,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) |
@@ -94,7 +94,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) |
@@ -112,7 +112,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,
@@ -129,7 +129,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,
@@ -164,28 +164,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) |
@@ -197,15 +197,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,
@@ -222,7 +222,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,
@@ -257,28 +257,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) |
@@ -289,15 +289,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) |
@@ -308,15 +308,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,
@@ -333,7 +333,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,
@@ -368,28 +368,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) |
@@ -400,15 +400,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) |
@@ -419,9 +419,15 @@ 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 QEMU_HDA_ID_OUTPUT
+#undef QEMU_HDA_ID_DUPLEX
+#undef QEMU_HDA_ID_MICRO
+#undef QEMU_HDA_AMP_CAPS
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index 65fbb2a..30aa709 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -163,6 +163,7 @@ struct HDAAudioState {
 
     /* properties */
     uint32_t debug;
+    uint32_t mixer;
 };
 
 static void hda_audio_input_cb(void *opaque, int avail)
@@ -585,22 +586,63 @@ static const VMStateDescription vmstate_hda_audio = {
 
 static Property hda_audio_properties[] = {
     DEFINE_PROP_UINT32("debug", HDAAudioState, debug, 0),
+#ifdef CONFIG_MIXEMU
+    DEFINE_PROP_UINT32("mixer", HDAAudioState, mixer, 1),
+#else
+    DEFINE_PROP_UINT32("mixer", HDAAudioState, mixer, 0),
+#endif
     DEFINE_PROP_END_OF_LIST(),
 };
 
+#ifdef CONFIG_MIXEMU
+#define PARAM mixemu
+#include "hda-codec-common.h"
+#undef CONFIG_MIXEMU
+#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"
+
 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 {
+        return hda_audio_init(hda, &output_mixemu);
+    }
 }
 
 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 {
+        return hda_audio_init(hda, &duplex_mixemu);
+    }
 }
 
 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 {
+        return hda_audio_init(hda, &micro_mixemu);
+    }
 }
 
 static void hda_audio_output_class_init(ObjectClass *klass, void *data)
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] hda-codec: refactor common definitions into a header file
  2013-08-27 19:17 ` [Qemu-devel] [PATCH 1/2] hda-codec: refactor common definitions into a header file Bandan Das
@ 2013-08-28  8:02   ` Markus Armbruster
  0 siblings, 0 replies; 12+ messages in thread
From: Markus Armbruster @ 2013-08-28  8:02 UTC (permalink / raw)
  To: Bandan Das; +Cc: qemu-devel, Gerd Hoffmann

Bandan Das <bsd@redhat.com> writes:

> Move common defines and structs to a header file.
> We will then include these twice in hda-codec.c - 
> a version with mixer enabled and another with not enabled.

Suggest:

    The next commit will include it twice, once for a device with a
    mixer, and once for device without a mixer.

Actual patch is pure code motion.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime
  2013-08-27 19:17 [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime Bandan Das
  2013-08-27 19:17 ` [Qemu-devel] [PATCH 1/2] hda-codec: refactor common definitions into a header file Bandan Das
  2013-08-27 19:17 ` [Qemu-devel] [PATCH 2/2] hda-codec: make mixemu selectable at runtime Bandan Das
@ 2013-08-28  9:13 ` Markus Armbruster
  2013-08-28 11:07   ` Paolo Bonzini
                     ` (2 more replies)
  2 siblings, 3 replies; 12+ messages in thread
From: Markus Armbruster @ 2013-08-28  9:13 UTC (permalink / raw)
  To: Bandan Das; +Cc: qemu-devel, Gerd Hoffmann

Bandan Das <bsd@redhat.com> writes:

> Currently, hda-codec mixer emulation can only be enabled by using the
> "--enable-mixemu" option to configure at compile time. These patches add 
> the option to make it configurable at runtime as well. 
>
> An example usage could be a qemu cmdline  : 
> "-device hda-duplex,mixer=(on/off)" although this 
> is not part of this change.

Really?  I see a new property "mixer" in PATCH 2/2.  It's UINT32 rather
than BOOL, though.

Let's review where we are and where your patch takes us.

CONFIG_MIXEMU is set by configure --enable-mixemu (default off).  It
does two things:

* It makes mixeng_volume() actually do something.  Users:

  audio_pcm_sw_read():

    if (!(hw->ctl_caps & VOICE_VOLUME_CAP)) {
        mixeng_volume (sw->buf, ret, &sw->vol);
    }

  audio_pcm_sw_write():

        if (!(sw->hw->ctl_caps & VOICE_VOLUME_CAP)) {
            mixeng_volume (sw->buf, swlim, &sw->vol);
        }

  Only pulse and the spice audio backends set VOICE_VOLUME_CAP.

  Impact on users isn't obvious to me.

* Devices hda-{output,duplex,micro} have a mixer if and only if
  CONFIG_MIXEMU is enabled.

  Reason: their mixer cannot work without CONFIG_MIXEMU.  Advertizing a
  broken hardware mixer to guests breaks volume control.  Not nice.  So,
  advertize it only when it works.  When CONFIG_MIXEMU is disabled, the
  hardware provides no mixer, guests fall back to a software mixer, and
  volume control works.  Commit d61a4ce.

  So, -device hda-duplex gives you *different* devices depending on
  whether you enabled mixer emulation.  Enabling/disabling QEMU's mixer
  emulation changes guest ABI.  This was a bad idea.  We should have
  created either two sets of devices, one with and one without a mixer,
  or a device property to control mixer presence.

  Your patch implements the latter.  And boy is it ugly :)

Questions (not just for you, Bandan):

1. Why is CONFIG_MIXEMU off by default?

   We generally default optional code to "on", to avoid bit-rot.  We
   make exceptions only when the optional code is truly unwanted by a
   clear majority of our users.  Why would anyone want hda audio devices
   without a mixer?

2. Why do we bother providing these devices when CONFIG_MIXEMU off?

   Why would anyone want hda audio devices without a mixer?  Why
   wouldn't anyone who wants hda audio devices also want CONFIG_MIXEMU
   enabled?

   The only remotely convincing reason I can think of is "we foolishly
   provided them, and now we have to keep them for backward
   compatibility".

3. Why does CONFIG_MIXEMU exist?

   Closest thing to a discussion I could find in the list archives:

   http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg02313.html
   http://lists.gnu.org/archive/html/qemu-devel/2012-04/msg02285.html

   I don't exactly find the argument for CONFIG_MIXEMU convincing.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime
  2013-08-28  9:13 ` [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable " Markus Armbruster
@ 2013-08-28 11:07   ` Paolo Bonzini
  2013-08-28 11:33   ` Gerd Hoffmann
  2013-08-28 15:52   ` Bandan Das
  2 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2013-08-28 11:07 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Bandan Das, qemu-devel, Gerd Hoffmann

Il 28/08/2013 11:13, Markus Armbruster ha scritto:
> 1. Why is CONFIG_MIXEMU off by default?
> 
>    We generally default optional code to "on", to avoid bit-rot.  We
>    make exceptions only when the optional code is truly unwanted by a
>    clear majority of our users.  Why would anyone want hda audio devices
>    without a mixer?

malc said mixer emulation was slower and didn't want it enabled by default.

Paolo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime
  2013-08-28  9:13 ` [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable " Markus Armbruster
  2013-08-28 11:07   ` Paolo Bonzini
@ 2013-08-28 11:33   ` Gerd Hoffmann
  2013-08-28 11:45     ` Markus Armbruster
  2013-08-28 15:52   ` Bandan Das
  2 siblings, 1 reply; 12+ messages in thread
From: Gerd Hoffmann @ 2013-08-28 11:33 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Bandan Das, qemu-devel

  Hi,

>   Only pulse and the spice audio backends set VOICE_VOLUME_CAP.
> 
>   Impact on users isn't obvious to me.

It offloads volume control to the audio backend, i.e. it will be done by
pulseaudio/spice-client instead of mixemu.

> Questions (not just for you, Bandan):
> 
> 1. Why is CONFIG_MIXEMU off by default?

malc wants it this way because mixemu eats cpu time.

> 2. Why do we bother providing these devices when CONFIG_MIXEMU off?
> 
>    Why would anyone want hda audio devices without a mixer?  Why
>    wouldn't anyone who wants hda audio devices also want CONFIG_MIXEMU
>    enabled?

It'll actually work just fine with HDA.  The guest figures there is no
volume control and will fallback to do volume control in software then.
Net effect is that the audio sample processing to change volume is done
by the guest instead of mixemu, so you don't actually save cpu time by
turning off mixemu ...

I think AC97 has broken volume control with CONFIG_MIXEMU=n, because the
guest tries to use the non-functional volume controls.

So, yes, for serious sound support you want CONFIG_MIXEMU=y.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime
  2013-08-28 11:33   ` Gerd Hoffmann
@ 2013-08-28 11:45     ` Markus Armbruster
  2013-08-28 11:52       ` Gerd Hoffmann
  0 siblings, 1 reply; 12+ messages in thread
From: Markus Armbruster @ 2013-08-28 11:45 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Bandan Das, qemu-devel

Gerd Hoffmann <kraxel@redhat.com> writes:

>   Hi,
>
>>   Only pulse and the spice audio backends set VOICE_VOLUME_CAP.
>> 
>>   Impact on users isn't obvious to me.
>
> It offloads volume control to the audio backend, i.e. it will be done by
> pulseaudio/spice-client instead of mixemu.
>
>> Questions (not just for you, Bandan):
>> 
>> 1. Why is CONFIG_MIXEMU off by default?
>
> malc wants it this way because mixemu eats cpu time.
>
>> 2. Why do we bother providing these devices when CONFIG_MIXEMU off?
>> 
>>    Why would anyone want hda audio devices without a mixer?  Why
>>    wouldn't anyone who wants hda audio devices also want CONFIG_MIXEMU
>>    enabled?
>
> It'll actually work just fine with HDA.  The guest figures there is no
> volume control and will fallback to do volume control in software then.
> Net effect is that the audio sample processing to change volume is done
> by the guest instead of mixemu, so you don't actually save cpu time by
> turning off mixemu ...

I don't doubt it works, I doubt anybody would want the software mixing
done in the guest instead of mixemu so badly that he wants to use a
special device that makes that possible.

> I think AC97 has broken volume control with CONFIG_MIXEMU=n, because the
> guest tries to use the non-functional volume controls.
>
> So, yes, for serious sound support you want CONFIG_MIXEMU=y.

Which brings me back to question 1: why is non-serious sound support the
default?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime
  2013-08-28 11:45     ` Markus Armbruster
@ 2013-08-28 11:52       ` Gerd Hoffmann
  0 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2013-08-28 11:52 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Bandan Das, qemu-devel

  Hi,

> >> 2. Why do we bother providing these devices when CONFIG_MIXEMU off?
> >> 
> >>    Why would anyone want hda audio devices without a mixer?  Why
> >>    wouldn't anyone who wants hda audio devices also want CONFIG_MIXEMU
> >>    enabled?
> >
> > It'll actually work just fine with HDA.  The guest figures there is no
> > volume control and will fallback to do volume control in software then.
> > Net effect is that the audio sample processing to change volume is done
> > by the guest instead of mixemu, so you don't actually save cpu time by
> > turning off mixemu ...
> 
> I don't doubt it works, I doubt anybody would want the software mixing
> done in the guest instead of mixemu so badly that he wants to use a
> special device that makes that possible.

Backward compatibility is the only reason.

> > I think AC97 has broken volume control with CONFIG_MIXEMU=n, because the
> > guest tries to use the non-functional volume controls.
> >
> > So, yes, for serious sound support you want CONFIG_MIXEMU=y.
> 
> Which brings me back to question 1: why is non-serious sound support the
> default?

Last attempt to flip the default was vetoed by malc.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime
  2013-08-28  9:13 ` [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable " Markus Armbruster
  2013-08-28 11:07   ` Paolo Bonzini
  2013-08-28 11:33   ` Gerd Hoffmann
@ 2013-08-28 15:52   ` Bandan Das
  2013-08-28 16:37     ` Markus Armbruster
  2 siblings, 1 reply; 12+ messages in thread
From: Bandan Das @ 2013-08-28 15:52 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, Gerd Hoffmann

Markus Armbruster <armbru@redhat.com> writes:

> Bandan Das <bsd@redhat.com> writes:
>
>> Currently, hda-codec mixer emulation can only be enabled by using the
>> "--enable-mixemu" option to configure at compile time. These patches add 
>> the option to make it configurable at runtime as well. 
>>
>> An example usage could be a qemu cmdline  : 
>> "-device hda-duplex,mixer=(on/off)" although this 
>> is not part of this change.
>
> Really?  I see a new property "mixer" in PATCH 2/2.  It's UINT32 rather
> than BOOL, though.

Well, what else can I say, Bad example... 

> Let's review where we are and where your patch takes us.
>
> CONFIG_MIXEMU is set by configure --enable-mixemu (default off).  It
> does two things:
>
> * It makes mixeng_volume() actually do something.  Users:
>
>   audio_pcm_sw_read():
>
>     if (!(hw->ctl_caps & VOICE_VOLUME_CAP)) {
>         mixeng_volume (sw->buf, ret, &sw->vol);
>     }
>
>   audio_pcm_sw_write():
>
>         if (!(sw->hw->ctl_caps & VOICE_VOLUME_CAP)) {
>             mixeng_volume (sw->buf, swlim, &sw->vol);
>         }
>
>   Only pulse and the spice audio backends set VOICE_VOLUME_CAP.
>
>   Impact on users isn't obvious to me.
>
> * Devices hda-{output,duplex,micro} have a mixer if and only if
>   CONFIG_MIXEMU is enabled.
>
>   Reason: their mixer cannot work without CONFIG_MIXEMU.  Advertizing a
>   broken hardware mixer to guests breaks volume control.  Not nice.  So,
>   advertize it only when it works.  When CONFIG_MIXEMU is disabled, the
>   hardware provides no mixer, guests fall back to a software mixer, and
>   volume control works.  Commit d61a4ce.
>
>   So, -device hda-duplex gives you *different* devices depending on
>   whether you enabled mixer emulation.  Enabling/disabling QEMU's mixer
>   emulation changes guest ABI.  This was a bad idea.  We should have
>   created either two sets of devices, one with and one without a mixer,
>   or a device property to control mixer presence.
>
>   Your patch implements the latter.  And boy is it ugly :)
>

I prefer having a device property rather than two different devices
which is probably overkill IMO. This is the most straight-forward way
I could do it.

> Questions (not just for you, Bandan):
>
> 1. Why is CONFIG_MIXEMU off by default?
>
>    We generally default optional code to "on", to avoid bit-rot.  We
>    make exceptions only when the optional code is truly unwanted by a
>    clear majority of our users.  Why would anyone want hda audio devices
>    without a mixer?
>
> 2. Why do we bother providing these devices when CONFIG_MIXEMU off?
>
>    Why would anyone want hda audio devices without a mixer?  Why
>    wouldn't anyone who wants hda audio devices also want CONFIG_MIXEMU
>    enabled?
>
>    The only remotely convincing reason I can think of is "we foolishly
>    provided them, and now we have to keep them for backward
>    compatibility".
>
> 3. Why does CONFIG_MIXEMU exist?
>
I can post a patch for it (again) on top of these changes and 
see where it goes. If the default value of the "mixer" property stays
off, malc's concerns mentioned elsewhere in this thread will be taken 
care of too (I think).

Bandan
>    Closest thing to a discussion I could find in the list archives:
>
>    http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg02313.html
>    http://lists.gnu.org/archive/html/qemu-devel/2012-04/msg02285.html
>
>    I don't exactly find the argument for CONFIG_MIXEMU convincing.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime
  2013-08-28 15:52   ` Bandan Das
@ 2013-08-28 16:37     ` Markus Armbruster
  2013-08-28 17:35       ` Jan Kiszka
  0 siblings, 1 reply; 12+ messages in thread
From: Markus Armbruster @ 2013-08-28 16:37 UTC (permalink / raw)
  To: Bandan Das; +Cc: qemu-devel, Gerd Hoffmann

Bandan Das <bsd@redhat.com> writes:

> Markus Armbruster <armbru@redhat.com> writes:
>
>> Bandan Das <bsd@redhat.com> writes:
>>
>>> Currently, hda-codec mixer emulation can only be enabled by using the
>>> "--enable-mixemu" option to configure at compile time. These patches add 
>>> the option to make it configurable at runtime as well. 
>>>
>>> An example usage could be a qemu cmdline  : 
>>> "-device hda-duplex,mixer=(on/off)" although this 
>>> is not part of this change.
>>
>> Really?  I see a new property "mixer" in PATCH 2/2.  It's UINT32 rather
>> than BOOL, though.
>
> Well, what else can I say, Bad example... 

Commit messages are easy enough to fix :)

>> Let's review where we are and where your patch takes us.
>>
>> CONFIG_MIXEMU is set by configure --enable-mixemu (default off).  It
>> does two things:
>>
>> * It makes mixeng_volume() actually do something.  Users:
>>
>>   audio_pcm_sw_read():
>>
>>     if (!(hw->ctl_caps & VOICE_VOLUME_CAP)) {
>>         mixeng_volume (sw->buf, ret, &sw->vol);
>>     }
>>
>>   audio_pcm_sw_write():
>>
>>         if (!(sw->hw->ctl_caps & VOICE_VOLUME_CAP)) {
>>             mixeng_volume (sw->buf, swlim, &sw->vol);
>>         }
>>
>>   Only pulse and the spice audio backends set VOICE_VOLUME_CAP.
>>
>>   Impact on users isn't obvious to me.
>>
>> * Devices hda-{output,duplex,micro} have a mixer if and only if
>>   CONFIG_MIXEMU is enabled.
>>
>>   Reason: their mixer cannot work without CONFIG_MIXEMU.  Advertizing a
>>   broken hardware mixer to guests breaks volume control.  Not nice.  So,
>>   advertize it only when it works.  When CONFIG_MIXEMU is disabled, the
>>   hardware provides no mixer, guests fall back to a software mixer, and
>>   volume control works.  Commit d61a4ce.
>>
>>   So, -device hda-duplex gives you *different* devices depending on
>>   whether you enabled mixer emulation.  Enabling/disabling QEMU's mixer
>>   emulation changes guest ABI.  This was a bad idea.  We should have
>>   created either two sets of devices, one with and one without a mixer,
>>   or a device property to control mixer presence.
>>
>>   Your patch implements the latter.  And boy is it ugly :)
>>
>
> I prefer having a device property rather than two different devices
> which is probably overkill IMO. This is the most straight-forward way
> I could do it.

Two devices would probably be similarly ugly.

I'm fine with either way.  The property way now has the distinct
advantage of working code.

>> Questions (not just for you, Bandan):
>>
>> 1. Why is CONFIG_MIXEMU off by default?
>>
>>    We generally default optional code to "on", to avoid bit-rot.  We
>>    make exceptions only when the optional code is truly unwanted by a
>>    clear majority of our users.  Why would anyone want hda audio devices
>>    without a mixer?
>>
>> 2. Why do we bother providing these devices when CONFIG_MIXEMU off?
>>
>>    Why would anyone want hda audio devices without a mixer?  Why
>>    wouldn't anyone who wants hda audio devices also want CONFIG_MIXEMU
>>    enabled?
>>
>>    The only remotely convincing reason I can think of is "we foolishly
>>    provided them, and now we have to keep them for backward
>>    compatibility".
>>
>> 3. Why does CONFIG_MIXEMU exist?
>>
> I can post a patch for it (again) on top of these changes and 
> see where it goes. If the default value of the "mixer" property stays
> off, malc's concerns mentioned elsewhere in this thread will be taken 
> care of too (I think).

I think we should default to working, fully-featured devices, because
that's what most users want.  The few users prepared to sacrifice the
hardware mixer in the hope of saving a few cycles can try mixer=off.

[...]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime
  2013-08-28 16:37     ` Markus Armbruster
@ 2013-08-28 17:35       ` Jan Kiszka
  0 siblings, 0 replies; 12+ messages in thread
From: Jan Kiszka @ 2013-08-28 17:35 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Bandan Das, qemu-devel, Gerd Hoffmann

On 2013-08-28 18:37, Markus Armbruster wrote:
>>> 3. Why does CONFIG_MIXEMU exist?
>>>
>> I can post a patch for it (again) on top of these changes and 
>> see where it goes. If the default value of the "mixer" property stays
>> off, malc's concerns mentioned elsewhere in this thread will be taken 
>> care of too (I think).
> 
> I think we should default to working, fully-featured devices, because
> that's what most users want.  The few users prepared to sacrifice the
> hardware mixer in the hope of saving a few cycles can try mixer=off.

Ack. Please finally make the mixer default=on. I'm running with this
switch for 5 years now in my local config as its required for proper
audio device emulation with Musicpal e.g. I think CPUs became faster
since then, likely over-compensating the additional cycles.

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-08-28 17:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-27 19:17 [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable at runtime Bandan Das
2013-08-27 19:17 ` [Qemu-devel] [PATCH 1/2] hda-codec: refactor common definitions into a header file Bandan Das
2013-08-28  8:02   ` Markus Armbruster
2013-08-27 19:17 ` [Qemu-devel] [PATCH 2/2] hda-codec: make mixemu selectable at runtime Bandan Das
2013-08-28  9:13 ` [Qemu-devel] [PATCH 0/2] Make mixer emulation configurable " Markus Armbruster
2013-08-28 11:07   ` Paolo Bonzini
2013-08-28 11:33   ` Gerd Hoffmann
2013-08-28 11:45     ` Markus Armbruster
2013-08-28 11:52       ` Gerd Hoffmann
2013-08-28 15:52   ` Bandan Das
2013-08-28 16:37     ` Markus Armbruster
2013-08-28 17:35       ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).