the patch about win7 guest unable to disable the sound completely

Submitted by liequan.che@i-soft.com.cn on Jan. 29, 2013, 7:22 a.m.

Details

Message ID 20130129072254.DE2E7F7506@ent3in1-5-196.sinanet.com
State New
Headers show

Commit Message

liequan.che@i-soft.com.cn Jan. 29, 2013, 7:22 a.m.
Hi all:
I slove the problem that qemu doesn't support to disable the sound completely when someone choose ich6 sound card.
I test it in centos 6.3,guest win7,ich6 sound card.it works fine. 

my patch:
     

Patch hide | download patch | download mbox

--- qemu-kvm-0.12.1.2/hw/hda-audio.c    2013-01-29 10:07:34.750968170 +0800
+++ qemu-kvm-0.12.1.2.new/hw/hda-audio.c    2013-01-29 10:07:05.696283899 +0800
@@ -647,10 +647,59 @@ 
         hda_codec_response(hda, true, node->pinctl);
         break;
     case AC_VERB_SET_PIN_WIDGET_CONTROL:
-        if (node->pinctl != payload) {
+        if (node->pinctl != payload)
+        {
+            if (node->pinctl == 0x40 && payload == 0)
+            {
+                st = a->st + node->stindex;
+                if (st->node == NULL)
+                {
+                    goto fail;
+                }
+                dprint(a, 1, "amp (%s): %s%s%s%s index %d  gain %3d %s\n",
+                   st->node->name,
+                   (payload & AC_AMP_SET_OUTPUT) ? "o" : "-",
+                   (payload & AC_AMP_SET_INPUT)  ? "i" : "-",
+                   (payload & AC_AMP_SET_LEFT)   ? "l" : "-",
+                   (payload & AC_AMP_SET_RIGHT)  ? "r" : "-",
+                   (payload & AC_AMP_SET_INDEX) >> AC_AMP_SET_INDEX_SHIFT,
+                   (payload & AC_AMP_GAIN),
+                   (payload & AC_AMP_MUTE) ? "muted" : "");
+                st->gain_left = payload & AC_AMP_GAIN;
+                st->mute_left = payload & AC_AMP_MUTE;
+                st->gain_right = payload & AC_AMP_GAIN;
+                st->mute_right = payload & AC_AMP_MUTE;
+                hda_audio_setup(st);            
+                hda_audio_set_amp(st);
+                hda_audio_set_running(st, false);
+            }  
             dprint(a, 1, "unhandled pin control bit\n");
         }
-        hda_codec_response(hda, true, 0);
+        else
+        {
+            st = a->st + node->stindex;
+            if (st->node == NULL)
+            {
+                goto fail;
+            }
+            dprint(a, 1, "amp (%s): %s%s%s%s index %d  gain %3d %s\n",
+                   st->node->name,
+                   (payload & AC_AMP_SET_OUTPUT) ? "o" : "-",
+                   (payload & AC_AMP_SET_INPUT)  ? "i" : "-",
+                   (payload & AC_AMP_SET_LEFT)   ? "l" : "-",
+                   (payload & AC_AMP_SET_RIGHT)  ? "r" : "-",
+                   (payload & AC_AMP_SET_INDEX) >> AC_AMP_SET_INDEX_SHIFT,
+                   (payload & AC_AMP_GAIN),
+                   (payload & AC_AMP_MUTE) ? "muted" : "");
+            st->gain_left = payload & AC_AMP_GAIN;
+            st->mute_left = payload & AC_AMP_MUTE;
+            st->gain_right = payload & AC_AMP_GAIN;
+            st->mute_right = payload & AC_AMP_MUTE;
+            hda_audio_setup(st);            
+            hda_audio_set_amp(st);
+            hda_audio_set_running(st, true);
+        }
+        hda_codec_response(hda, true, 0);
         break;
 
     /* audio in/out widget */