summaryrefslogtreecommitdiff
path: root/hw/pcspk.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2012-02-01 20:31:43 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2012-02-17 09:58:22 -0600
commit4aa5d2853a69d95f5e05bd02200dfc6f47cab9de (patch)
tree16251b86d628106b5933949ae7ceb932f3b67569 /hw/pcspk.c
parent302fe51b5900c5ca5be921269b61f4862e0634ce (diff)
downloadqemu-4aa5d2853a69d95f5e05bd02200dfc6f47cab9de.tar.gz
i8254: Factor out pit_get_channel_info
Instead of providing 4 individual query functions for mode, gate, output and initial counter state, introduce a service that queries all information at once. This comes with tiny additional costs for pcspk_callback but with a much cleaner interface. Also, it will simplify the implementation of the KVM in-kernel PIT model. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/pcspk.c')
-rw-r--r--hw/pcspk.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/hw/pcspk.c b/hw/pcspk.c
index 49dd9691cf..e4303247d4 100644
--- a/hw/pcspk.c
+++ b/hw/pcspk.c
@@ -75,12 +75,16 @@ static inline void generate_samples(PCSpkState *s)
static void pcspk_callback(void *opaque, int free)
{
PCSpkState *s = opaque;
+ PITChannelInfo ch;
unsigned int n;
- if (pit_get_mode(s->pit, 2) != 3)
+ pit_get_channel_info(s->pit, 2, &ch);
+
+ if (ch.mode != 3) {
return;
+ }
- n = pit_get_initial_count(s->pit, 2);
+ n = ch.initial_count;
/* avoid frequencies that are not reproducible with sample rate */
if (n < PCSPK_MIN_COUNT)
n = 0;
@@ -121,12 +125,14 @@ static uint64_t pcspk_io_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PCSpkState *s = opaque;
- int out;
+ PITChannelInfo ch;
+
+ pit_get_channel_info(s->pit, 2, &ch);
s->dummy_refresh_clock ^= (1 << 4);
- out = pit_get_out(s->pit, 2, qemu_get_clock_ns(vm_clock)) << 5;
- return pit_get_gate(s->pit, 2) | (s->data_on << 1) | s->dummy_refresh_clock | out;
+ return ch.gate | (s->data_on << 1) | s->dummy_refresh_clock |
+ (ch.out << 5);
}
static void pcspk_io_write(void *opaque, target_phys_addr_t addr, uint64_t val,