Emulate the speaker port's refresh clock bit. This is supposed to toggle between 0 and 1<<4 every 15 microseconds. XXX: We use gettimeofday() in the real machine instead of a monotonic clock in the virtual machine, and we are a bit sloppy about the 15 microseconds. This should be good enough for crude loops that measure approximate delays by counting how often this line toggles. Bump PKGREVISION to 1
47 lines
1.5 KiB
Text
47 lines
1.5 KiB
Text
$NetBSD: patch-ba,v 1.1 2007/12/24 10:18:22 apb Exp $
|
|
|
|
--- hw/pcspk.c.orig 2007-02-06 01:01:54.000000000 +0200
|
|
+++ hw/pcspk.c
|
|
@@ -38,7 +38,6 @@ typedef struct {
|
|
unsigned int samples;
|
|
unsigned int play_pos;
|
|
int data_on;
|
|
- int dummy_refresh_clock;
|
|
} PCSpkState;
|
|
|
|
static const char *s_spk = "pcspk";
|
|
@@ -112,15 +111,32 @@ int pcspk_audio_init(AudioState *audio)
|
|
return 0;
|
|
}
|
|
|
|
+/*
|
|
+ * Emulate the speaker port's refresh clock bit. This is supposed
|
|
+ * to toggle between 0 and 1<<4 every 15 microseconds. XXX: We use
|
|
+ * gettimeofday() in the real machine instead of a monotonic clock
|
|
+ * in the virtual machine, and we are a bit sloppy about the 15
|
|
+ * microseconds. This should be good enough for crude loops that
|
|
+ * measure approximate delays by counting how often this line toggles.
|
|
+ */
|
|
+static uint32_t pcspk_dummy_refresh_clock(void)
|
|
+{
|
|
+ struct timeval tv;
|
|
+
|
|
+ gettimeofday(&tv, NULL);
|
|
+ return ((tv.tv_sec ^ (tv.tv_usec / 15)) & 1) << 4;
|
|
+}
|
|
+
|
|
static uint32_t pcspk_ioport_read(void *opaque, uint32_t addr)
|
|
{
|
|
PCSpkState *s = opaque;
|
|
int out;
|
|
+ int dummy_refresh_clock;
|
|
|
|
- s->dummy_refresh_clock ^= (1 << 4);
|
|
out = pit_get_out(s->pit, 2, qemu_get_clock(vm_clock)) << 5;
|
|
|
|
- return pit_get_gate(s->pit, 2) | (s->data_on << 1) | s->dummy_refresh_clock | out;
|
|
+ return pit_get_gate(s->pit, 2) | (s->data_on << 1) |
|
|
+ pcspk_dummy_refresh_clock() | out;
|
|
}
|
|
|
|
static void pcspk_ioport_write(void *opaque, uint32_t addr, uint32_t val)
|