diff mbox

[Qemu-devel] Re: Question about KVM and PC speaker

Message ID 6D825FA2F92349029E0C39C9BC4D72C7@FSCPC (mailing list archive)
State New, archived
Headers show

Commit Message

Sebastian Herbszt May 12, 2009, 9:06 p.m. UTC
Jan Kiszka wrote:
>> I have implemented the beep for vgabios-6b and it works on bochs but
>> fails on qemu.
>> With "-soundhw pcspk" i should hear it thru the hosts pc speaker, right?
> 
> Yep, that's how it should work. Mind to share your code and tell us
> which test case you used?

FreeDOS floppy with "debug" command and assembly code:
mov ax,0e07
xor bx,bx
int 10

With the modified vgabios (see below) it does beep on bochs on vista,
but not on qemu.

- Sebastian


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jan Kiszka May 12, 2009, 9:50 p.m. UTC | #1
Sebastian Herbszt wrote:
> Jan Kiszka wrote:
>>> I have implemented the beep for vgabios-6b and it works on bochs but
>>> fails on qemu.
>>> With "-soundhw pcspk" i should hear it thru the hosts pc speaker, right?
>>
>> Yep, that's how it should work. Mind to share your code and tell us
>> which test case you used?
> 
> FreeDOS floppy with "debug" command and assembly code:
> mov ax,0e07
> xor bx,bx
> int 10
> 
> With the modified vgabios (see below) it does beep on bochs on vista,
> but not on qemu.

Works fine for me!

Did you check twice that your modified vgabios is actually loaded by
qemu (e.g. via strace)? Moreover, does sound work at all with your qemu?
The image I tried [1] issues two beeps after loading (obviously via
direct hw access) - a good way to check general support. Note that one
reason for broken host sound with qemu can be OSS. For that reason I
always configure my qemu with --audio-drv-list=alsa.

Jan

PS: Your patch was mangled by your mail client. Fortunately, it was
small enough for manual fixing.

[1]http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/unofficial/balder/balder10.img
Sebastian Herbszt May 12, 2009, 10:21 p.m. UTC | #2
Jan Kiszka wrote:
> Sebastian Herbszt wrote:
>> With the modified vgabios (see below) it does beep on bochs on vista,
>> but not on qemu.
> 
> Works fine for me!
> 
> Did you check twice that your modified vgabios is actually loaded by
> qemu (e.g. via strace)?

Yes, it uses the right rom.

> Moreover, does sound work at all with your qemu?
> The image I tried [1] issues two beeps after loading (obviously via
> direct hw access) - a good way to check general support. Note that one
> reason for broken host sound with qemu can be OSS. For that reason I
> always configure my qemu with --audio-drv-list=alsa.

Thats a good hint :)
Seems i used to compile qemu without "--audio-drv-list". Since "dsound" and
"fmod" drivers don't compile here (i likely miss some libs in my mingw), i used "sdl".
Now i can hear those two beeps with the image you suggested. Tho those are coming
thru my sound card and not the hosts pc speaker (even with "-soundhw pcspk", but maybe
that option means something different).
With INT 10h AH=0Eh i now can hear a beep too, but it doesn't stop and qemu somewhat freezes.

> Jan
> 
> PS: Your patch was mangled by your mail client. Fortunately, it was
> small enough for manual fixing.

Unfortunatelly Windows Mail tends to do this and i failed to find an option to fix it.

- Sebastian

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Samuel Thibault May 12, 2009, 10:27 p.m. UTC | #3
Sebastian Herbszt, le Wed 13 May 2009 00:21:25 +0200, a écrit :
> Tho those are coming thru my sound card and not the hosts pc speaker
> (even with "-soundhw pcspk", but maybe that option means something
> different).

-soundhw pcspk means to emulate the PC speaker for the guest, it doesn't
have to do with how it is rendered by the host.

> >PS: Your patch was mangled by your mail client. Fortunately, it was
> >small enough for manual fixing.
> 
> Unfortunatelly Windows Mail tends to do this and i failed to find an option 
> to fix it.

Then change your mail client :)

Samuel
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
malc May 12, 2009, 10:37 p.m. UTC | #4
On Wed, 13 May 2009, Sebastian Herbszt wrote:

> Jan Kiszka wrote:
> > Sebastian Herbszt wrote:
> > > With the modified vgabios (see below) it does beep on bochs on vista,
> > > but not on qemu.
> > 
> > Works fine for me!
> > 
> > Did you check twice that your modified vgabios is actually loaded by
> > qemu (e.g. via strace)?
> 
> Yes, it uses the right rom.
> 
> > Moreover, does sound work at all with your qemu?
> > The image I tried [1] issues two beeps after loading (obviously via
> > direct hw access) - a good way to check general support. Note that one
> > reason for broken host sound with qemu can be OSS. For that reason I
> > always configure my qemu with --audio-drv-list=alsa.
> 
> Thats a good hint :)
> Seems i used to compile qemu without "--audio-drv-list". Since "dsound" and
> "fmod" drivers don't compile here (i likely miss some libs in my mingw), i
> used "sdl".

Don't do that. Here's a nice tutorial Kazu made that will probably help 
you: http://www.h7.dion.ne.jp/~qemu-win/Audio-en.html

> Now i can hear those two beeps with the image you suggested. Tho those are
> coming
> thru my sound card and not the hosts pc speaker (even with "-soundhw pcspk",
> but maybe
> that option means something different).

And it will always come through your soundcard. pcspk is not a passthrough
thing.

> With INT 10h AH=0Eh i now can hear a beep too, but it doesn't stop and qemu
> somewhat freezes.

Huh?

> > Jan
> > 
> > PS: Your patch was mangled by your mail client. Fortunately, it was
> > small enough for manual fixing.
> 
> Unfortunatelly Windows Mail tends to do this and i failed to find an option to
> fix it.
> 
> - Sebastian
> 
> 
>
Sebastian Herbszt May 14, 2009, 7:48 p.m. UTC | #5
malc wrote:
> On Wed, 13 May 2009, Sebastian Herbszt wrote:
> 
>> Jan Kiszka wrote:
>> > Moreover, does sound work at all with your qemu?
>> > The image I tried [1] issues two beeps after loading (obviously via
>> > direct hw access) - a good way to check general support. Note that one
>> > reason for broken host sound with qemu can be OSS. For that reason I
>> > always configure my qemu with --audio-drv-list=alsa.
>> 
>> Thats a good hint :)
>> Seems i used to compile qemu without "--audio-drv-list". Since "dsound" and
>> "fmod" drivers don't compile here (i likely miss some libs in my mingw), i
>> used "sdl".
> 
> Don't do that. Here's a nice tutorial Kazu made that will probably help 
> you: http://www.h7.dion.ne.jp/~qemu-win/Audio-en.html

So you're saying the use of sdl for audio is not recommended?

>> Now i can hear those two beeps with the image you suggested. Tho those are
>> coming
>> thru my sound card and not the hosts pc speaker (even with "-soundhw pcspk",
>> but maybe
>> that option means something different).
> 
> And it will always come through your soundcard. pcspk is not a passthrough
> thing.

Thanks for the clarification.

 >> With INT 10h AH=0Eh i now can hear a beep too, but it doesn't stop and qemu
>> somewhat freezes.
> 
> Huh?

With this INT 10h function qemu should beep once, but it does loop the beep infinitely.
Normally i can exit qemu by clicking on the [x] window close "icon", but while it does
endlessly beep that doesn't work (vista says process doesn't respond). Using "quit" in the
monitor window doesn't work either.

- Sebastian

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
malc May 14, 2009, 10:01 p.m. UTC | #6
On Thu, 14 May 2009, Sebastian Herbszt wrote:

> malc wrote:
> > On Wed, 13 May 2009, Sebastian Herbszt wrote:
> > 
> > > Jan Kiszka wrote:
> > > > Moreover, does sound work at all with your qemu?
> > > > The image I tried [1] issues two beeps after loading (obviously via
> > > > direct hw access) - a good way to check general support. Note that one
> > > > reason for broken host sound with qemu can be OSS. For that reason I
> > > > always configure my qemu with --audio-drv-list=alsa.
> > > 
> > > Thats a good hint :)
> > > Seems i used to compile qemu without "--audio-drv-list". Since "dsound"
> > > and
> > > "fmod" drivers don't compile here (i likely miss some libs in my mingw), i
> > > used "sdl".
> > 
> > Don't do that. Here's a nice tutorial Kazu made that will probably help you:
> > http://www.h7.dion.ne.jp/~qemu-win/Audio-en.html
> 
> So you're saying the use of sdl for audio is not recommended?

Yes.

> 
> > > Now i can hear those two beeps with the image you suggested. Tho those are
> > > coming
> > > thru my sound card and not the hosts pc speaker (even with "-soundhw
> > > pcspk",
> > > but maybe
> > > that option means something different).
> > 
> > And it will always come through your soundcard. pcspk is not a passthrough
> > thing.
> 
> Thanks for the clarification.
> 
> >> With INT 10h AH=0Eh i now can hear a beep too, but it doesn't stop and qemu
> > > somewhat freezes.
> > 
> > Huh?
> 
> With this INT 10h function qemu should beep once, but it does loop the beep
> infinitely.
> Normally i can exit qemu by clicking on the [x] window close "icon", but while
> it does
> endlessly beep that doesn't work (vista says process doesn't respond). Using
> "quit" in the
> monitor window doesn't work either.
> 

Can you post some .com file sparing me from writing the code for one
myself?
diff mbox

Patch

--- vgabios.c.orig 2009-05-12 22:24:22.000000000 +0200
+++ vgabios.c 2009-05-12 22:24:32.000000000 +0200
@@ -80,6 +80,9 @@ 
 static void memcpyb();
 static void memcpyw();
 
+static void delay_ticks();
+static void beep();
+
 static void biosfn_set_video_mode();
 static void biosfn_set_cursor_shape();
 static void biosfn_set_cursor_pos();
@@ -1965,7 +1968,7 @@ 
  switch(car)
   {
    case 7:
-    //FIXME should beep
+    beep();
     break;
 
    case 8:
@@ -3765,6 +3768,57 @@ 
 ASM_END
 }
 
+  void
+delay_ticks(ticks)
+  Bit16u ticks;
+{
+ASM_START
+  pusha
+  push ds
+  xor dx,dx
+  mov ds,dx
+  mov cx,4[bp]
+  add cx,0x46c
+  adc dx,0x46e
+  sti
+delay_ticks_wait:
+  hlt
+  mov ax,0x46c
+  mov bx,0x46e
+  cmp dx,bx
+  jb delay_ticks_out
+  cmp cx,ax
+  ja delay_ticks_wait
+delay_ticks_out:
+  pop ds
+  popa
+ASM_END
+}
+
+void beep()
+{
+ASM_START
+  pusha
+  mov al,#0xb6
+  out #0x43,al
+  mov al,#0x33
+  out #0x42,al
+  mov al,#0x5
+  out #0x42,al
+  in al,#0x61
+  push ax
+  or al,#0x03
+  out #0x61,al
+  mov cx,#0x4
+  push cx
+  call _delay_ticks
+  pop cx
+  pop ax
+  out #0x61,al
+  popa
+ASM_END
+}
+
 #ifdef DEBUG
 void unimplemented()
 {