cuda: convert ADB autopoll timer from ns to ms

This is in preparation for consolidating all of the ADB autopoll management
in one place.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Finn Thain <fthain@telegraphics.com.au>
Acked-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200623204936.24064-4-mark.cave-ayland@ilande.co.uk>
This commit is contained in:
Mark Cave-Ayland 2020-06-23 21:49:17 +01:00
parent 167f1667b1
commit d9b898943d

View File

@ -210,8 +210,9 @@ static void cuda_adb_poll(void *opaque)
obuf[1] = 0x40; /* polled data */ obuf[1] = 0x40; /* polled data */
cuda_send_packet_to_host(s, obuf, olen + 2); cuda_send_packet_to_host(s, obuf, olen + 2);
} }
timer_mod(s->adb_poll_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
(NANOSECONDS_PER_SECOND / (1000 / s->autopoll_rate_ms))); timer_mod(s->adb_poll_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
s->autopoll_rate_ms);
} }
/* description of commands */ /* description of commands */
@ -238,8 +239,8 @@ static bool cuda_cmd_autopoll(CUDAState *s,
s->autopoll = autopoll; s->autopoll = autopoll;
if (autopoll) { if (autopoll) {
timer_mod(s->adb_poll_timer, timer_mod(s->adb_poll_timer,
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
(NANOSECONDS_PER_SECOND / (1000 / s->autopoll_rate_ms))); s->autopoll_rate_ms);
} else { } else {
timer_del(s->adb_poll_timer); timer_del(s->adb_poll_timer);
} }
@ -264,8 +265,8 @@ static bool cuda_cmd_set_autorate(CUDAState *s,
s->autopoll_rate_ms = in_data[0]; s->autopoll_rate_ms = in_data[0];
if (s->autopoll) { if (s->autopoll) {
timer_mod(s->adb_poll_timer, timer_mod(s->adb_poll_timer,
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
(NANOSECONDS_PER_SECOND / (1000 / s->autopoll_rate_ms))); s->autopoll_rate_ms);
} }
return true; return true;
} }
@ -544,7 +545,7 @@ static void cuda_realize(DeviceState *dev, Error **errp)
s->sr_delay_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, cuda_set_sr_int, s); s->sr_delay_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, cuda_set_sr_int, s);
s->sr_delay_ns = 20 * SCALE_US; s->sr_delay_ns = 20 * SCALE_US;
s->adb_poll_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, cuda_adb_poll, s); s->adb_poll_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, cuda_adb_poll, s);
s->adb_poll_mask = 0xffff; s->adb_poll_mask = 0xffff;
s->autopoll_rate_ms = 20; s->autopoll_rate_ms = 20;
} }