[PATCH] Fix Windows 2000 and XP HDAudio Support

Christopher Lentocha posted 1 patch 1 year ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/737e8de1-9c14-453e-35eb-bff1e6b34a4a@gmail.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
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 alcnode;
     }
     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);
+
+alcnode:
+    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
Thanks Christopher for your patch,

I'm Cc'ing Volker and Gerd who know better this hardware model.

On 7/11/23 20:27, 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,
>       },{
>           .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 alcnode;
>       }
>       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);
> +
> +alcnode:
> +    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)
Re: [PATCH] Fix Windows 2000 and XP HDAudio Support
Posted by Gerd Hoffmann 1 year ago
On Wed, Nov 08, 2023 at 11:02:06AM +0100, Philippe Mathieu-Daudé wrote:
> Thanks Christopher for your patch,
> 
> I'm Cc'ing Volker and Gerd who know better this hardware model.
> 
> On 7/11/23 20:27, Christopher Lentocha wrote:
> > 
> > Change the ID to be a Realtek ALC885 so that both

No.  Rewriting the existing codecs is clearly a non-starter.

You can add a 'hda-realtek-alc885' variant which tries to
mimic the realtek coded close enough to make old guests
without generic hda driver happy.

> > +#define QEMU_HDA_ID 0x10EC0885

Nope.  Somemething like 'REALTEK_ALC885_ID' please.

[ remaining bits of the patch snipped, needs major rework ]

take care,
  Gerd
Re: [PATCH] Fix Windows 2000 and XP HDAudio Support
Posted by Christopher Lentocha 1 year ago
So wait, you want me to add it as another device name? Because 
it is going to be the same exact way as the 1af4 device
just with a number change. Ok, work it is then ...
(Sorry about not getting back sooner also)

Christopher

On 11/8/23 6:12 AM, Gerd Hoffmann wrote:
> On Wed, Nov 08, 2023 at 11:02:06AM +0100, Philippe Mathieu-Daudé wrote:
>> Thanks Christopher for your patch,
>>
>> I'm Cc'ing Volker and Gerd who know better this hardware model.
>>
>> On 7/11/23 20:27, Christopher Lentocha wrote:
>>>
>>> Change the ID to be a Realtek ALC885 so that both
> 
> No.  Rewriting the existing codecs is clearly a non-starter.
> 
> You can add a 'hda-realtek-alc885' variant which tries to
> mimic the realtek coded close enough to make old guests
> without generic hda driver happy.
> 
>>> +#define QEMU_HDA_ID 0x10EC0885
> 
> Nope.  Somemething like 'REALTEK_ALC885_ID' please.
> 
> [ remaining bits of the patch snipped, needs major rework ]
> 
> take care,
>   Gerd
> 

Re: [PATCH] Fix Windows 2000 and XP HDAudio Support
Posted by Volker Rümelin 1 year ago
Am 12.11.23 um 01:37 schrieb Christopher Lentocha:
> So wait, you want me to add it as another device name? Because 
> it is going to be the same exact way as the 1af4 device
> just with a number change. Ok, work it is then ...
> (Sorry about not getting back sooner also)
>
> Christopher

Hi Christopher,

why do you want the device to be exactly the same as the generic hda
codec? A new device gives you the opportunity to model it closer to the
specs in the ALC885 datasheet. This could improve compatibility with the
old guest drivers.

With best regards,
Volker

> On 11/8/23 6:12 AM, Gerd Hoffmann wrote:
>> On Wed, Nov 08, 2023 at 11:02:06AM +0100, Philippe Mathieu-Daudé wrote:
>>> Thanks Christopher for your patch,
>>>
>>> I'm Cc'ing Volker and Gerd who know better this hardware model.
>>>
>>> On 7/11/23 20:27, Christopher Lentocha wrote:
>>>> Change the ID to be a Realtek ALC885 so that both
>> No.  Rewriting the existing codecs is clearly a non-starter.
>>
>> You can add a 'hda-realtek-alc885' variant which tries to
>> mimic the realtek coded close enough to make old guests
>> without generic hda driver happy.
>>
>>>> +#define QEMU_HDA_ID 0x10EC0885
>> Nope.  Somemething like 'REALTEK_ALC885_ID' please.
>>
>> [ remaining bits of the patch snipped, needs major rework ]
>>
>> take care,
>>   Gerd
>>