Make mixer emulation configurable at runtime
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. 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
Signature · 1 line
1.8.1.4
PATCH 1/2 hda-codec: refactor common definitions into a header file
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.
--- 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
hw/audio/hda-codec-common.h new file +427 -0
@@ -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), +};
hw/audio/hda-codec.c +1 -423
430 lines not on this page · raw message
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH 1/2] hda-codec: refactor common definitions into a header file
Quoted 3 lines · Bandan Das
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.
PATCH 2/2 hda-codec: make mixemu selectable at runtime
In reply to Bandan DasDefine 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 | 114 +++++++++++++++++++++++--------------------- hw/audio/hda-codec.c | 48 +++++++++++++++++-- 2 files changed, 105 insertions(+), 57 deletions(-)
hw/audio/hda-codec-common.h +60 -54
@@ -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
hw/audio/hda-codec.c +45 -3
73 lines not on this page · raw message
Signature · 1 line
1.8.1.4
Quoted 7 lines · Bandan Das
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.
Il 28/08/2013 11:13, Markus Armbruster ha scritto:
Quoted 6 lines
1. Why is
CONFIG_MIXEMUoff 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
Hi,
Quoted 3 lines
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.
Quoted 3 lines
Questions (not just for you, Bandan):
1. Why is
CONFIG_MIXEMUoff by default?
malc wants it this way because mixemu eats cpu time.
Quoted 5 lines
2. Why do we bother providing these devices when
CONFIG_MIXEMUoff?Why would anyone want hda audio devices without a mixer? Why wouldn't anyone who wants hda audio devices also want
CONFIG_MIXEMUenabled?
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
Quoted 21 lines · Gerd Hoffmann
Hi,
Quoted 3 lines
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.
Quoted 3 lines
Questions (not just for you, Bandan):
1. Why is
CONFIG_MIXEMUoff by default?malc wants it this way because mixemu eats cpu time.
Quoted 5 lines
2. Why do we bother providing these devices when
CONFIG_MIXEMUoff?Why would anyone want hda audio devices without a mixer? Why wouldn't anyone who wants hda audio devices also want
CONFIG_MIXEMUenabled?
Quoted 5 lines
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.
Quoted 4 lines
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?
Hi,
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
2. Why do we bother providing these devices when
CONFIG_MIXEMUoff?Why would anyone want hda audio devices without a mixer? Why wouldn't anyone who wants hda audio devices also want
CONFIG_MIXEMUenabled?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 ...
Quoted 3 lines
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.
Quoted 7 lines
Quoted 4 lines
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
Quoted 6 lines · Markus Armbruster
Quoted 4 lines · Bandan Das
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.
Quoted 6 lines
Quoted 3 lines
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...
Quoted 32 lines
Let's review where we are and where your patch takes us.
CONFIG_MIXEMUis 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_MIXEMUis 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. WhenCONFIG_MIXEMUis disabled, the hardware provides no mixer, guests fall back to a software mixer, and volume control works. Commit d61a4ce.
Quoted 8 lines
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.
Quoted 15 lines
Questions (not just for you, Bandan):
1. Why is
CONFIG_MIXEMUoff 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_MIXEMUoff?Why would anyone want hda audio devices without a mixer? Why wouldn't anyone who wants hda audio devices also want
CONFIG_MIXEMUenabled?
Quoted 6 lines
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_MIXEMUexist?
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
Quoted 6 lines
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.
Quoted 8 lines · Bandan Das
Quoted 6 lines · Markus Armbruster
Quoted 4 lines · Bandan Das
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.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
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 :)
Quoted 38 lines
Quoted 38 lines
Let's review where we are and where your patch takes us.
CONFIG_MIXEMUis 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_MIXEMUis 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. WhenCONFIG_MIXEMUis 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.
Quoted 6 lines
Quoted 2 lines
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.
Quoted 19 lines
Quoted 19 lines
Questions (not just for you, Bandan):
1. Why is
CONFIG_MIXEMUoff 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_MIXEMUoff?Why would anyone want hda audio devices without a mixer? Why wouldn't anyone who wants hda audio devices also want
CONFIG_MIXEMUenabled?The only remotely convincing reason I can think of is "we foolishly provided them, and now we have to keep them for backward compatibility".
Quoted 6 lines
Quoted 2 lines
3. Why does
CONFIG_MIXEMUexist?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.
[...]
Quoted 10 lines · Markus Armbruster
Quoted 6 lines
Quoted 2 lines
3. Why does
CONFIG_MIXEMUexist?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
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux