[PATCH] Fix Windows 2000 and XP HDAudio Support

Christopher Lentocha posted 1 patch 1 year ago
Failed in applying to current master (apply log)
There is a newer version of this series
hw/audio/hda-codec-common.h | 66 +++++++++++++++++--------------------
hw/audio/hda-codec.c | 8 +++--
2 files changed, 36 insertions(+), 38 deletions(-)
[PATCH] Fix Windows 2000 and XP HDAudio Support
Posted by Christopher Lentocha 1 year ago

Change the ID to be a Realtek ALC885 so that both
Windows 2000 and up (including XP) and macOS
(on a later patch for HDEF ACPI Fixes) support HDA
HDA is supported for ALC885 on macOS AppleHDA.kext
and 2K people can use the following file to get
sound working (MD5sum):

959c6ad895ee22d0003fe24b6ce1b150

WDM_R269.exe

for Vista+, the following can be used for EQ or if
the native one doesn't work OOTB (MD5sum):

fb0aaffcfc620b70b7f3c3b1381d08e5

Vista_Win7_Win8_R270.exe

A Note for the Vista+ Driver: You need to go to
playback settings, under the Speaker, Advanced,
change the Hz to one that is valid, so sound
actually plays, though you may need to enable
under the Enhancements tab, check Disable All
then change the Hz, and uncheck Disable All
Under Enhancements, applying after each of
the tasks, due to a bug in the stock Realtek
Driver, also note, newer drivers don't work at
all, even on real machines, this is the latest
confirmed to work at the moment!

Signed-off-by: Christopher Lentocha <christopherericlentocha@gmail.com>
---
hw/audio/hda-codec-common.h | 66 +++++++++++++++++--------------------
hw/audio/hda-codec.c | 8 +++--
2 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/hw/audio/hda-codec-common.h b/hw/audio/hda-codec-common.h
index b4fdb51e8b..ef57a1b98d 100644
--- a/hw/audio/hda-codec-common.h
+++ b/hw/audio/hda-codec-common.h
@@ -24,19 +24,15 @@
* HDA codec descriptions
*/

+#define QEMU_HDA_ID 0x10EC0885
+
#ifdef HDA_MIXER
-#define QEMU_HDA_ID_OUTPUT ((QEMU_HDA_ID_VENDOR << 16) | 0x12)
-#define QEMU_HDA_ID_DUPLEX ((QEMU_HDA_ID_VENDOR << 16) | 0x22)
-#define QEMU_HDA_ID_MICRO ((QEMU_HDA_ID_VENDOR << 16) | 0x32)
#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

@@ -137,10 +133,10 @@ static const desc_param 
glue(common_params_audio_linein_, PARAM)[] = {
static const desc_param glue(output_params_root_, PARAM)[] = {
{
.id = AC_PAR_VENDOR_ID,
- .val = QEMU_HDA_ID_OUTPUT,
+ .val = QEMU_HDA_ID,
},{
.id = AC_PAR_SUBSYSTEM_ID,
- .val = QEMU_HDA_ID_OUTPUT,
+ .val = QEMU_HDA_ID,
},{
.id = AC_PAR_REV_ID,
.val = 0x00100101,
@@ -157,7 +153,7 @@ static const desc_param 
glue(output_params_audio_func_, PARAM)[] = {
.val = AC_GRP_AUDIO_FUNCTION,
},{
.id = AC_PAR_SUBSYSTEM_ID,
- .val = QEMU_HDA_ID_OUTPUT,
+ .val = QEMU_HDA_ID,
},{
.id = AC_PAR_NODE_COUNT,
.val = 0x00020002,
@@ -208,9 +204,9 @@ static const desc_node glue(output_nodes_, PARAM)[] = {
.name = "out",
.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) |
+ .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
+ (AC_JACK_SPEAKER << AC_DEFCFG_DEVICE_SHIFT) |
+ (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
(AC_JACK_COLOR_GREEN << AC_DEFCFG_COLOR_SHIFT) |
0x10),
.pinctl = AC_PINCTL_OUT_EN,
@@ -221,7 +217,7 @@ static const desc_node glue(output_nodes_, PARAM)[] = {
/* output: codec */
static const desc_codec glue(output_, PARAM) = {
.name = "output",
- .iid = QEMU_HDA_ID_OUTPUT,
+ .iid = QEMU_HDA_ID,
.nodes = glue(output_nodes_, PARAM),
.nnodes = ARRAY_SIZE(glue(output_nodes_, PARAM)),
};
@@ -230,10 +226,10 @@ static const desc_codec glue(output_, PARAM) = {
static const desc_param glue(duplex_params_root_, PARAM)[] = {
{
.id = AC_PAR_VENDOR_ID,
- .val = QEMU_HDA_ID_DUPLEX,
+ .val = QEMU_HDA_ID,
},{
.id = AC_PAR_SUBSYSTEM_ID,
- .val = QEMU_HDA_ID_DUPLEX,
+ .val = QEMU_HDA_ID,
},{
.id = AC_PAR_REV_ID,
.val = 0x00100101,
@@ -250,7 +246,7 @@ static const desc_param 
glue(duplex_params_audio_func_, PARAM)[] = {
.val = AC_GRP_AUDIO_FUNCTION,
},{
.id = AC_PAR_SUBSYSTEM_ID,
- .val = QEMU_HDA_ID_DUPLEX,
+ .val = QEMU_HDA_ID,
},{
.id = AC_PAR_NODE_COUNT,
.val = 0x00020004,
@@ -301,9 +297,9 @@ static const desc_node glue(duplex_nodes_, PARAM)[] = {
.name = "out",
.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) |
+ .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
+ (AC_JACK_SPEAKER << AC_DEFCFG_DEVICE_SHIFT) |
+ (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
(AC_JACK_COLOR_GREEN << AC_DEFCFG_COLOR_SHIFT) |
0x10),
.pinctl = AC_PINCTL_OUT_EN,
@@ -320,10 +316,10 @@ static const desc_node glue(duplex_nodes_, 
PARAM)[] = {
.name = "in",
.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) |
- (AC_JACK_COLOR_RED << AC_DEFCFG_COLOR_SHIFT) |
+ .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
+ (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT) |
+ (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
+ (AC_JACK_COLOR_PINK << AC_DEFCFG_COLOR_SHIFT) |
0x20),
.pinctl = AC_PINCTL_IN_EN,
}
@@ -332,7 +328,7 @@ static const desc_node glue(duplex_nodes_, PARAM)[] = {
/* duplex: codec */
static const desc_codec glue(duplex_, PARAM) = {
.name = "duplex",
- .iid = QEMU_HDA_ID_DUPLEX,
+ .iid = QEMU_HDA_ID,
.nodes = glue(duplex_nodes_, PARAM),
.nnodes = ARRAY_SIZE(glue(duplex_nodes_, PARAM)),
};
@@ -341,10 +337,10 @@ static const desc_codec glue(duplex_, PARAM) = {
static const desc_param glue(micro_params_root_, PARAM)[] = {
{
.id = AC_PAR_VENDOR_ID,
- .val = QEMU_HDA_ID_MICRO,
+ .val = QEMU_HDA_ID,
},{
.id = AC_PAR_SUBSYSTEM_ID,
- .val = QEMU_HDA_ID_MICRO,
+ .val = QEMU_HDA_ID,
},{
.id = AC_PAR_REV_ID,
.val = 0x00100101,
@@ -361,7 +357,7 @@ static const desc_param 
glue(micro_params_audio_func_, PARAM)[] = {
.val = AC_GRP_AUDIO_FUNCTION,
},{
.id = AC_PAR_SUBSYSTEM_ID,
- .val = QEMU_HDA_ID_MICRO,
+ .val = QEMU_HDA_ID,
},{
.id = AC_PAR_NODE_COUNT,
.val = 0x00020004,
@@ -412,9 +408,9 @@ static const desc_node glue(micro_nodes_, PARAM)[] = {
.name = "out",
.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) |
+ .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
(AC_JACK_SPEAKER << AC_DEFCFG_DEVICE_SHIFT) |
- (AC_JACK_CONN_UNKNOWN << AC_DEFCFG_CONN_TYPE_SHIFT) |
+ (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
(AC_JACK_COLOR_GREEN << AC_DEFCFG_COLOR_SHIFT) |
0x10),
.pinctl = AC_PINCTL_OUT_EN,
@@ -431,10 +427,10 @@ static const desc_node glue(micro_nodes_, PARAM)[] = {
.name = "in",
.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) |
+ .config = ((AC_JACK_PORT_FIXED << 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) |
+ (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
+ (AC_JACK_COLOR_PINK << AC_DEFCFG_COLOR_SHIFT) |
0x20),
.pinctl = AC_PINCTL_IN_EN,
}
@@ -443,14 +439,12 @@ static const desc_node glue(micro_nodes_, PARAM)[] = {
/* micro: codec */
static const desc_codec glue(micro_, PARAM) = {
.name = "micro",
- .iid = QEMU_HDA_ID_MICRO,
+ .iid = QEMU_HDA_ID,
.nodes = glue(micro_nodes_, PARAM),
.nnodes = ARRAY_SIZE(glue(micro_nodes_, PARAM)),
};

#undef PARAM
#undef HDA_MIXER
-#undef QEMU_HDA_ID_OUTPUT
-#undef QEMU_HDA_ID_DUPLEX
-#undef QEMU_HDA_ID_MICRO
+#undef QEMU_HDA_ID
#undef QEMU_HDA_AMP_CAPS
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index b9ad1f4c39..6999869c70 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -117,7 +117,6 @@ static void hda_codec_parse_fmt(uint32_t format, 
struct audsettings *as)

/* some defines */

-#define QEMU_HDA_ID_VENDOR 0x1af4
#define QEMU_HDA_PCM_FORMATS (AC_SUPPCM_BITS_16 | \
0x1fc /* 16 -> 96 kHz */)
#define QEMU_HDA_AMP_NONE (0)
@@ -514,7 +513,7 @@ static void hda_audio_command(HDACodecDevice *hda, 
uint32_t nid, uint32_t data)

node = hda_codec_find_node(a->desc, nid);
if (node == NULL) {
- goto fail;
+ goto liaf;
}
dprint(a, 2, "%s: nid %d (%s), verb 0x%x, payload 0x%x\n",
__func__, nid, node->name, verb, payload);
@@ -652,6 +651,11 @@ fail:
dprint(a, 1, "%s: not handled: nid %d (%s), verb 0x%x, payload 0x%x\n",
__func__, nid, node ? node->name : "?", verb, payload);
hda_codec_response(hda, true, 0);
+
+liaf:
+ dprint(a, 1, "%s: not handled: nid %d (%s), verb 0x%x, payload 0x%x\n",
+ __func__, nid, node ? node->name : "?", verb, payload);
+ hda_codec_response(hda, true, 0x0885);
}

static void hda_audio_stream(HDACodecDevice *hda, uint32_t stnr, bool 
running, bool output)
-- 
2.38.1
Re: [PATCH] Fix Windows 2000 and XP HDAudio Support
Posted by Philippe Mathieu-Daudé 1 year ago
Hi Christopher,

On 6/11/23 18:38, Christopher Lentocha wrote:
> 
> Change the ID to be a Realtek ALC885 so that both
> Windows 2000 and up (including XP) and macOS
> (on a later patch for HDEF ACPI Fixes) support HDA
> HDA is supported for ALC885 on macOS AppleHDA.kext
> and 2K people can use the following file to get
> sound working (MD5sum):
> 
> 959c6ad895ee22d0003fe24b6ce1b150
> 
> WDM_R269.exe
> 
> for Vista+, the following can be used for EQ or if
> the native one doesn't work OOTB (MD5sum):
> 
> fb0aaffcfc620b70b7f3c3b1381d08e5
> 
> Vista_Win7_Win8_R270.exe
> 
> A Note for the Vista+ Driver: You need to go to
> playback settings, under the Speaker, Advanced,
> change the Hz to one that is valid, so sound
> actually plays, though you may need to enable
> under the Enhancements tab, check Disable All
> then change the Hz, and uncheck Disable All
> Under Enhancements, applying after each of
> the tasks, due to a bug in the stock Realtek
> Driver, also note, newer drivers don't work at
> all, even on real machines, this is the latest
> confirmed to work at the moment!
> 
> Signed-off-by: Christopher Lentocha <christopherericlentocha@gmail.com>
> ---
> hw/audio/hda-codec-common.h | 66 +++++++++++++++++--------------------
> hw/audio/hda-codec.c | 8 +++--
> 2 files changed, 36 insertions(+), 38 deletions(-)
> 
> diff --git a/hw/audio/hda-codec-common.h b/hw/audio/hda-codec-common.h
> index b4fdb51e8b..ef57a1b98d 100644
> --- a/hw/audio/hda-codec-common.h
> +++ b/hw/audio/hda-codec-common.h
> @@ -24,19 +24,15 @@
> * HDA codec descriptions
> */
> 
> +#define QEMU_HDA_ID 0x10EC0885
> +
> #ifdef HDA_MIXER
> -#define QEMU_HDA_ID_OUTPUT ((QEMU_HDA_ID_VENDOR << 16) | 0x12)
> -#define QEMU_HDA_ID_DUPLEX ((QEMU_HDA_ID_VENDOR << 16) | 0x22)
> -#define QEMU_HDA_ID_MICRO ((QEMU_HDA_ID_VENDOR << 16) | 0x32)
> #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
> 
> @@ -137,10 +133,10 @@ static const desc_param 
> glue(common_params_audio_linein_, PARAM)[] = {
> static const desc_param glue(output_params_root_, PARAM)[] = {
> {
> .id = AC_PAR_VENDOR_ID,
> - .val = QEMU_HDA_ID_OUTPUT,
> + .val = QEMU_HDA_ID,

Thanks for your patch, but it seems ill-formatted and can't be
applied :/

See for help:
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#submitting-your-patches

> },{
> .id = AC_PAR_SUBSYSTEM_ID,
> - .val = QEMU_HDA_ID_OUTPUT,
> + .val = QEMU_HDA_ID,
> },{
> .id = AC_PAR_REV_ID,
> .val = 0x00100101,
> @@ -157,7 +153,7 @@ static const desc_param 
> glue(output_params_audio_func_, PARAM)[] = {
> .val = AC_GRP_AUDIO_FUNCTION,
> },{
> .id = AC_PAR_SUBSYSTEM_ID,
> - .val = QEMU_HDA_ID_OUTPUT,
> + .val = QEMU_HDA_ID,
> },{
> .id = AC_PAR_NODE_COUNT,
> .val = 0x00020002,
> @@ -208,9 +204,9 @@ static const desc_node glue(output_nodes_, PARAM)[] = {
> .name = "out",
> .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) |
> + .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
> + (AC_JACK_SPEAKER << AC_DEFCFG_DEVICE_SHIFT) |
> + (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
> (AC_JACK_COLOR_GREEN << AC_DEFCFG_COLOR_SHIFT) |
> 0x10),
> .pinctl = AC_PINCTL_OUT_EN,
> @@ -221,7 +217,7 @@ static const desc_node glue(output_nodes_, PARAM)[] = {
> /* output: codec */
> static const desc_codec glue(output_, PARAM) = {
> .name = "output",
> - .iid = QEMU_HDA_ID_OUTPUT,
> + .iid = QEMU_HDA_ID,
> .nodes = glue(output_nodes_, PARAM),
> .nnodes = ARRAY_SIZE(glue(output_nodes_, PARAM)),
> };
> @@ -230,10 +226,10 @@ static const desc_codec glue(output_, PARAM) = {
> static const desc_param glue(duplex_params_root_, PARAM)[] = {
> {
> .id = AC_PAR_VENDOR_ID,
> - .val = QEMU_HDA_ID_DUPLEX,
> + .val = QEMU_HDA_ID,
> },{
> .id = AC_PAR_SUBSYSTEM_ID,
> - .val = QEMU_HDA_ID_DUPLEX,
> + .val = QEMU_HDA_ID,
> },{
> .id = AC_PAR_REV_ID,
> .val = 0x00100101,
> @@ -250,7 +246,7 @@ static const desc_param 
> glue(duplex_params_audio_func_, PARAM)[] = {
> .val = AC_GRP_AUDIO_FUNCTION,
> },{
> .id = AC_PAR_SUBSYSTEM_ID,
> - .val = QEMU_HDA_ID_DUPLEX,
> + .val = QEMU_HDA_ID,
> },{
> .id = AC_PAR_NODE_COUNT,
> .val = 0x00020004,
> @@ -301,9 +297,9 @@ static const desc_node glue(duplex_nodes_, PARAM)[] = {
> .name = "out",
> .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) |
> + .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
> + (AC_JACK_SPEAKER << AC_DEFCFG_DEVICE_SHIFT) |
> + (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
> (AC_JACK_COLOR_GREEN << AC_DEFCFG_COLOR_SHIFT) |
> 0x10),
> .pinctl = AC_PINCTL_OUT_EN,
> @@ -320,10 +316,10 @@ static const desc_node glue(duplex_nodes_, 
> PARAM)[] = {
> .name = "in",
> .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) |
> - (AC_JACK_COLOR_RED << AC_DEFCFG_COLOR_SHIFT) |
> + .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
> + (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT) |
> + (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
> + (AC_JACK_COLOR_PINK << AC_DEFCFG_COLOR_SHIFT) |
> 0x20),
> .pinctl = AC_PINCTL_IN_EN,
> }
> @@ -332,7 +328,7 @@ static const desc_node glue(duplex_nodes_, PARAM)[] = {
> /* duplex: codec */
> static const desc_codec glue(duplex_, PARAM) = {
> .name = "duplex",
> - .iid = QEMU_HDA_ID_DUPLEX,
> + .iid = QEMU_HDA_ID,
> .nodes = glue(duplex_nodes_, PARAM),
> .nnodes = ARRAY_SIZE(glue(duplex_nodes_, PARAM)),
> };
> @@ -341,10 +337,10 @@ static const desc_codec glue(duplex_, PARAM) = {
> static const desc_param glue(micro_params_root_, PARAM)[] = {
> {
> .id = AC_PAR_VENDOR_ID,
> - .val = QEMU_HDA_ID_MICRO,
> + .val = QEMU_HDA_ID,
> },{
> .id = AC_PAR_SUBSYSTEM_ID,
> - .val = QEMU_HDA_ID_MICRO,
> + .val = QEMU_HDA_ID,
> },{
> .id = AC_PAR_REV_ID,
> .val = 0x00100101,
> @@ -361,7 +357,7 @@ static const desc_param 
> glue(micro_params_audio_func_, PARAM)[] = {
> .val = AC_GRP_AUDIO_FUNCTION,
> },{
> .id = AC_PAR_SUBSYSTEM_ID,
> - .val = QEMU_HDA_ID_MICRO,
> + .val = QEMU_HDA_ID,
> },{
> .id = AC_PAR_NODE_COUNT,
> .val = 0x00020004,
> @@ -412,9 +408,9 @@ static const desc_node glue(micro_nodes_, PARAM)[] = {
> .name = "out",
> .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) |
> + .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
> (AC_JACK_SPEAKER << AC_DEFCFG_DEVICE_SHIFT) |
> - (AC_JACK_CONN_UNKNOWN << AC_DEFCFG_CONN_TYPE_SHIFT) |
> + (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
> (AC_JACK_COLOR_GREEN << AC_DEFCFG_COLOR_SHIFT) |
> 0x10),
> .pinctl = AC_PINCTL_OUT_EN,
> @@ -431,10 +427,10 @@ static const desc_node glue(micro_nodes_, PARAM)[] 
> = {
> .name = "in",
> .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) |
> + .config = ((AC_JACK_PORT_FIXED << 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) |
> + (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
> + (AC_JACK_COLOR_PINK << AC_DEFCFG_COLOR_SHIFT) |
> 0x20),
> .pinctl = AC_PINCTL_IN_EN,
> }
> @@ -443,14 +439,12 @@ static const desc_node glue(micro_nodes_, PARAM)[] 
> = {
> /* micro: codec */
> static const desc_codec glue(micro_, PARAM) = {
> .name = "micro",
> - .iid = QEMU_HDA_ID_MICRO,
> + .iid = QEMU_HDA_ID,
> .nodes = glue(micro_nodes_, PARAM),
> .nnodes = ARRAY_SIZE(glue(micro_nodes_, PARAM)),
> };
> 
> #undef PARAM
> #undef HDA_MIXER
> -#undef QEMU_HDA_ID_OUTPUT
> -#undef QEMU_HDA_ID_DUPLEX
> -#undef QEMU_HDA_ID_MICRO
> +#undef QEMU_HDA_ID
> #undef QEMU_HDA_AMP_CAPS
> diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
> index b9ad1f4c39..6999869c70 100644
> --- a/hw/audio/hda-codec.c
> +++ b/hw/audio/hda-codec.c
> @@ -117,7 +117,6 @@ static void hda_codec_parse_fmt(uint32_t format, 
> struct audsettings *as)
> 
> /* some defines */
> 
> -#define QEMU_HDA_ID_VENDOR 0x1af4
> #define QEMU_HDA_PCM_FORMATS (AC_SUPPCM_BITS_16 | \
> 0x1fc /* 16 -> 96 kHz */)
> #define QEMU_HDA_AMP_NONE (0)
> @@ -514,7 +513,7 @@ static void hda_audio_command(HDACodecDevice *hda, 
> uint32_t nid, uint32_t data)
> 
> node = hda_codec_find_node(a->desc, nid);
> if (node == NULL) {
> - goto fail;
> + goto liaf;
> }
> dprint(a, 2, "%s: nid %d (%s), verb 0x%x, payload 0x%x\n",
> __func__, nid, node->name, verb, payload);
> @@ -652,6 +651,11 @@ fail:
> dprint(a, 1, "%s: not handled: nid %d (%s), verb 0x%x, payload 0x%x\n",
> __func__, nid, node ? node->name : "?", verb, payload);
> hda_codec_response(hda, true, 0);
> +
> +liaf:

"liaf" is not very descriptive, any better name for this label?

> + dprint(a, 1, "%s: not handled: nid %d (%s), verb 0x%x, payload 0x%x\n",
> + __func__, nid, node ? node->name : "?", verb, payload);
> + hda_codec_response(hda, true, 0x0885);
> }
> 
> static void hda_audio_stream(HDACodecDevice *hda, uint32_t stnr, bool 
> running, bool output)

Regards,

Phil.
Re: [PATCH] Fix Windows 2000 and XP HDAudio Support
Posted by Christopher Lentocha 1 year ago
I forgot to turn off HTML formatting on my mail, 
thats why, sorry.
I also changed the liaf to alcnode if its valid?
Please check your next email from me for the 
hopefully fixed patch!
Thanks,

Christopher Lentocha

On 11/7/23 5:19 AM, Philippe Mathieu-Daudé wrote:
> Hi Christopher,
> 
> On 6/11/23 18:38, Christopher Lentocha wrote:
>>
>> Change the ID to be a Realtek ALC885 so that both
>> Windows 2000 and up (including XP) and macOS
>> (on a later patch for HDEF ACPI Fixes) support HDA
>> HDA is supported for ALC885 on macOS AppleHDA.kext
>> and 2K people can use the following file to get
>> sound working (MD5sum):
>>
>> 959c6ad895ee22d0003fe24b6ce1b150
>>
>> WDM_R269.exe
>>
>> for Vista+, the following can be used for EQ or if
>> the native one doesn't work OOTB (MD5sum):
>>
>> fb0aaffcfc620b70b7f3c3b1381d08e5
>>
>> Vista_Win7_Win8_R270.exe
>>
>> A Note for the Vista+ Driver: You need to go to
>> playback settings, under the Speaker, Advanced,
>> change the Hz to one that is valid, so sound
>> actually plays, though you may need to enable
>> under the Enhancements tab, check Disable All
>> then change the Hz, and uncheck Disable All
>> Under Enhancements, applying after each of
>> the tasks, due to a bug in the stock Realtek
>> Driver, also note, newer drivers don't work at
>> all, even on real machines, this is the latest
>> confirmed to work at the moment!
>>
>> Signed-off-by: Christopher Lentocha <christopherericlentocha@gmail.com>
>> ---
>> hw/audio/hda-codec-common.h | 66 +++++++++++++++++--------------------
>> hw/audio/hda-codec.c | 8 +++--
>> 2 files changed, 36 insertions(+), 38 deletions(-)
>>
>> diff --git a/hw/audio/hda-codec-common.h b/hw/audio/hda-codec-common.h
>> index b4fdb51e8b..ef57a1b98d 100644
>> --- a/hw/audio/hda-codec-common.h
>> +++ b/hw/audio/hda-codec-common.h
>> @@ -24,19 +24,15 @@
>> * HDA codec descriptions
>> */
>>
>> +#define QEMU_HDA_ID 0x10EC0885
>> +
>> #ifdef HDA_MIXER
>> -#define QEMU_HDA_ID_OUTPUT ((QEMU_HDA_ID_VENDOR << 16) | 0x12)
>> -#define QEMU_HDA_ID_DUPLEX ((QEMU_HDA_ID_VENDOR << 16) | 0x22)
>> -#define QEMU_HDA_ID_MICRO ((QEMU_HDA_ID_VENDOR << 16) | 0x32)
>> #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
>>
>> @@ -137,10 +133,10 @@ static const desc_param glue(common_params_audio_linein_, PARAM)[] = {
>> static const desc_param glue(output_params_root_, PARAM)[] = {
>> {
>> .id = AC_PAR_VENDOR_ID,
>> - .val = QEMU_HDA_ID_OUTPUT,
>> + .val = QEMU_HDA_ID,
> 
> Thanks for your patch, but it seems ill-formatted and can't be
> applied :/
> 
> See for help:
> https://www.qemu.org/docs/master/devel/submitting-a-patch.html#submitting-your-patches
> 
>> },{
>> .id = AC_PAR_SUBSYSTEM_ID,
>> - .val = QEMU_HDA_ID_OUTPUT,
>> + .val = QEMU_HDA_ID,
>> },{
>> .id = AC_PAR_REV_ID,
>> .val = 0x00100101,
>> @@ -157,7 +153,7 @@ static const desc_param glue(output_params_audio_func_, PARAM)[] = {
>> .val = AC_GRP_AUDIO_FUNCTION,
>> },{
>> .id = AC_PAR_SUBSYSTEM_ID,
>> - .val = QEMU_HDA_ID_OUTPUT,
>> + .val = QEMU_HDA_ID,
>> },{
>> .id = AC_PAR_NODE_COUNT,
>> .val = 0x00020002,
>> @@ -208,9 +204,9 @@ static const desc_node glue(output_nodes_, PARAM)[] = {
>> .name = "out",
>> .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) |
>> + .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
>> + (AC_JACK_SPEAKER << AC_DEFCFG_DEVICE_SHIFT) |
>> + (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
>> (AC_JACK_COLOR_GREEN << AC_DEFCFG_COLOR_SHIFT) |
>> 0x10),
>> .pinctl = AC_PINCTL_OUT_EN,
>> @@ -221,7 +217,7 @@ static const desc_node glue(output_nodes_, PARAM)[] = {
>> /* output: codec */
>> static const desc_codec glue(output_, PARAM) = {
>> .name = "output",
>> - .iid = QEMU_HDA_ID_OUTPUT,
>> + .iid = QEMU_HDA_ID,
>> .nodes = glue(output_nodes_, PARAM),
>> .nnodes = ARRAY_SIZE(glue(output_nodes_, PARAM)),
>> };
>> @@ -230,10 +226,10 @@ static const desc_codec glue(output_, PARAM) = {
>> static const desc_param glue(duplex_params_root_, PARAM)[] = {
>> {
>> .id = AC_PAR_VENDOR_ID,
>> - .val = QEMU_HDA_ID_DUPLEX,
>> + .val = QEMU_HDA_ID,
>> },{
>> .id = AC_PAR_SUBSYSTEM_ID,
>> - .val = QEMU_HDA_ID_DUPLEX,
>> + .val = QEMU_HDA_ID,
>> },{
>> .id = AC_PAR_REV_ID,
>> .val = 0x00100101,
>> @@ -250,7 +246,7 @@ static const desc_param glue(duplex_params_audio_func_, PARAM)[] = {
>> .val = AC_GRP_AUDIO_FUNCTION,
>> },{
>> .id = AC_PAR_SUBSYSTEM_ID,
>> - .val = QEMU_HDA_ID_DUPLEX,
>> + .val = QEMU_HDA_ID,
>> },{
>> .id = AC_PAR_NODE_COUNT,
>> .val = 0x00020004,
>> @@ -301,9 +297,9 @@ static const desc_node glue(duplex_nodes_, PARAM)[] = {
>> .name = "out",
>> .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) |
>> + .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
>> + (AC_JACK_SPEAKER << AC_DEFCFG_DEVICE_SHIFT) |
>> + (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
>> (AC_JACK_COLOR_GREEN << AC_DEFCFG_COLOR_SHIFT) |
>> 0x10),
>> .pinctl = AC_PINCTL_OUT_EN,
>> @@ -320,10 +316,10 @@ static const desc_node glue(duplex_nodes_, PARAM)[] = {
>> .name = "in",
>> .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) |
>> - (AC_JACK_COLOR_RED << AC_DEFCFG_COLOR_SHIFT) |
>> + .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
>> + (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT) |
>> + (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
>> + (AC_JACK_COLOR_PINK << AC_DEFCFG_COLOR_SHIFT) |
>> 0x20),
>> .pinctl = AC_PINCTL_IN_EN,
>> }
>> @@ -332,7 +328,7 @@ static const desc_node glue(duplex_nodes_, PARAM)[] = {
>> /* duplex: codec */
>> static const desc_codec glue(duplex_, PARAM) = {
>> .name = "duplex",
>> - .iid = QEMU_HDA_ID_DUPLEX,
>> + .iid = QEMU_HDA_ID,
>> .nodes = glue(duplex_nodes_, PARAM),
>> .nnodes = ARRAY_SIZE(glue(duplex_nodes_, PARAM)),
>> };
>> @@ -341,10 +337,10 @@ static const desc_codec glue(duplex_, PARAM) = {
>> static const desc_param glue(micro_params_root_, PARAM)[] = {
>> {
>> .id = AC_PAR_VENDOR_ID,
>> - .val = QEMU_HDA_ID_MICRO,
>> + .val = QEMU_HDA_ID,
>> },{
>> .id = AC_PAR_SUBSYSTEM_ID,
>> - .val = QEMU_HDA_ID_MICRO,
>> + .val = QEMU_HDA_ID,
>> },{
>> .id = AC_PAR_REV_ID,
>> .val = 0x00100101,
>> @@ -361,7 +357,7 @@ static const desc_param glue(micro_params_audio_func_, PARAM)[] = {
>> .val = AC_GRP_AUDIO_FUNCTION,
>> },{
>> .id = AC_PAR_SUBSYSTEM_ID,
>> - .val = QEMU_HDA_ID_MICRO,
>> + .val = QEMU_HDA_ID,
>> },{
>> .id = AC_PAR_NODE_COUNT,
>> .val = 0x00020004,
>> @@ -412,9 +408,9 @@ static const desc_node glue(micro_nodes_, PARAM)[] = {
>> .name = "out",
>> .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) |
>> + .config = ((AC_JACK_PORT_FIXED << AC_DEFCFG_PORT_CONN_SHIFT) |
>> (AC_JACK_SPEAKER << AC_DEFCFG_DEVICE_SHIFT) |
>> - (AC_JACK_CONN_UNKNOWN << AC_DEFCFG_CONN_TYPE_SHIFT) |
>> + (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
>> (AC_JACK_COLOR_GREEN << AC_DEFCFG_COLOR_SHIFT) |
>> 0x10),
>> .pinctl = AC_PINCTL_OUT_EN,
>> @@ -431,10 +427,10 @@ static const desc_node glue(micro_nodes_, PARAM)[] = {
>> .name = "in",
>> .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) |
>> + .config = ((AC_JACK_PORT_FIXED << 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) |
>> + (AC_JACK_CONN_1_8 << AC_DEFCFG_CONN_TYPE_SHIFT) |
>> + (AC_JACK_COLOR_PINK << AC_DEFCFG_COLOR_SHIFT) |
>> 0x20),
>> .pinctl = AC_PINCTL_IN_EN,
>> }
>> @@ -443,14 +439,12 @@ static const desc_node glue(micro_nodes_, PARAM)[] = {
>> /* micro: codec */
>> static const desc_codec glue(micro_, PARAM) = {
>> .name = "micro",
>> - .iid = QEMU_HDA_ID_MICRO,
>> + .iid = QEMU_HDA_ID,
>> .nodes = glue(micro_nodes_, PARAM),
>> .nnodes = ARRAY_SIZE(glue(micro_nodes_, PARAM)),
>> };
>>
>> #undef PARAM
>> #undef HDA_MIXER
>> -#undef QEMU_HDA_ID_OUTPUT
>> -#undef QEMU_HDA_ID_DUPLEX
>> -#undef QEMU_HDA_ID_MICRO
>> +#undef QEMU_HDA_ID
>> #undef QEMU_HDA_AMP_CAPS
>> diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
>> index b9ad1f4c39..6999869c70 100644
>> --- a/hw/audio/hda-codec.c
>> +++ b/hw/audio/hda-codec.c
>> @@ -117,7 +117,6 @@ static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as)
>>
>> /* some defines */
>>
>> -#define QEMU_HDA_ID_VENDOR 0x1af4
>> #define QEMU_HDA_PCM_FORMATS (AC_SUPPCM_BITS_16 | \
>> 0x1fc /* 16 -> 96 kHz */)
>> #define QEMU_HDA_AMP_NONE (0)
>> @@ -514,7 +513,7 @@ static void hda_audio_command(HDACodecDevice *hda, uint32_t nid, uint32_t data)
>>
>> node = hda_codec_find_node(a->desc, nid);
>> if (node == NULL) {
>> - goto fail;
>> + goto liaf;
>> }
>> dprint(a, 2, "%s: nid %d (%s), verb 0x%x, payload 0x%x\n",
>> __func__, nid, node->name, verb, payload);
>> @@ -652,6 +651,11 @@ fail:
>> dprint(a, 1, "%s: not handled: nid %d (%s), verb 0x%x, payload 0x%x\n",
>> __func__, nid, node ? node->name : "?", verb, payload);
>> hda_codec_response(hda, true, 0);
>> +
>> +liaf:
> 
> "liaf" is not very descriptive, any better name for this label?
> 
>> + dprint(a, 1, "%s: not handled: nid %d (%s), verb 0x%x, payload 0x%x\n",
>> + __func__, nid, node ? node->name : "?", verb, payload);
>> + hda_codec_response(hda, true, 0x0885);
>> }
>>
>> static void hda_audio_stream(HDACodecDevice *hda, uint32_t stnr, bool running, bool output)
> 
> Regards,
> 
> Phil.