From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, Miguel GAIO <mgaio35@gmail.com>
Subject: [Qemu-devel] [PULL 5/5] ohci: set effectively usb frame rate to 1kHz
Date: Mon, 1 Oct 2018 11:28:48 +0200 [thread overview]
Message-ID: <20181001092848.11082-6-kraxel@redhat.com> (raw)
In-Reply-To: <20181001092848.11082-1-kraxel@redhat.com>
From: Miguel GAIO <mgaio35@gmail.com>
USB frame rate is slightly lower than 1kHz: ie. ~950Hz.
Thus usb-audio device is not able to perform a simple audio playback
without underruns on audio backend.
eg. "-device pci-ohci,id=ohci -device usb-audio,bus=ohci.0" vs PulseAudio
backend. more than 50 underruns are observed per second.
Update ohci_sof_time computation, using QEMU_CLOCK_VIRTUAL in
ohci_usb_start(), and increment by usb_frame_time in ohci_sof()
makes USB frame rate close to 1kHz.
This way, no audio underrun are observed during audio playback.
Signed-off-by: Miguel GAIO <mgaio35@gmail.com>
Message-Id: <20180927151936.3647-1-mgaio35@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/usb/hcd-ohci.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 98da5f0f04..66656a1133 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1253,12 +1253,12 @@ static int ohci_service_ed_list(OHCIState *ohci, uint32_t head, int completion)
/* set a timer for EOF */
static void ohci_eof_timer(OHCIState *ohci)
{
- ohci->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
timer_mod(ohci->eof_timer, ohci->sof_time + usb_frame_time);
}
/* Set a timer for EOF and generate a SOF event */
static void ohci_sof(OHCIState *ohci)
{
+ ohci->sof_time += usb_frame_time;
ohci_eof_timer(ohci);
ohci_set_interrupt(ohci, OHCI_INTR_SF);
}
@@ -1362,6 +1362,7 @@ static int ohci_bus_start(OHCIState *ohci)
* can meet some race conditions
*/
+ ohci->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
ohci_eof_timer(ohci);
return 1;
@@ -1476,6 +1477,9 @@ static uint32_t ohci_get_frame_remaining(OHCIState *ohci)
* set already.
*/
tks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - ohci->sof_time;
+ if (tks < 0) {
+ tks = 0;
+ }
/* avoid muldiv if possible */
if (tks >= usb_frame_time)
--
2.9.3
next prev parent reply other threads:[~2018-10-01 9:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 9:28 [Qemu-devel] [PULL 0/5] Usb 20181001 patches Gerd Hoffmann
2018-10-01 9:28 ` [Qemu-devel] [PULL 1/5] usb-mtp: fix error conditions for write operation Gerd Hoffmann
2018-10-01 9:28 ` [Qemu-devel] [PULL 2/5] doc: replace x-root with rootdir for usb-mtp Gerd Hoffmann
2018-10-01 9:28 ` [Qemu-devel] [PULL 3/5] usb-mtp: reset ObjectInfo dataset size on cleanup Gerd Hoffmann
2018-10-01 9:28 ` [Qemu-devel] [PULL 4/5] usb-hub: clear suspend on detach Gerd Hoffmann
2018-10-01 9:28 ` Gerd Hoffmann [this message]
2018-10-01 14:44 ` [Qemu-devel] [PULL 0/5] Usb 20181001 patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181001092848.11082-6-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=mgaio35@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).