Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20140701-1' into staging

usb bugfixes.

# gpg: Signature made Tue 01 Jul 2014 14:51:19 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-usb-20140701-1:
  ccid-card-emulated: use EventNotifier
  usb: initialize libusb_device to avoid crash
  usb: Fix usb-bt-dongle initialization.
  input: fix jumpy mouse cursor with USB mouse emulation

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell
2014-07-01 16:16:19 +01:00
4 changed files with 30 additions and 31 deletions
+2 -2
View File
@@ -124,7 +124,7 @@ static void hid_pointer_event(DeviceState *dev, QemuConsole *src,
if (evt->rel->axis == INPUT_AXIS_X) {
e->xdx += evt->rel->value;
} else if (evt->rel->axis == INPUT_AXIS_Y) {
e->ydy -= evt->rel->value;
e->ydy += evt->rel->value;
}
break;
@@ -191,7 +191,7 @@ static void hid_pointer_sync(DeviceState *dev)
if (hs->kind == HID_MOUSE) {
prev->xdx += curr->xdx;
curr->xdx = 0;
prev->ydy -= curr->ydy;
prev->ydy += curr->ydy;
curr->ydy = 0;
} else {
prev->xdx = curr->xdx;
+10 -19
View File
@@ -126,7 +126,7 @@ struct EmulatedState {
QemuMutex vreader_mutex; /* and guest_apdu_list mutex */
QemuMutex handle_apdu_mutex;
QemuCond handle_apdu_cond;
int pipe[2];
EventNotifier notifier;
int quit_apdu_thread;
QemuThread apdu_thread_id;
};
@@ -162,9 +162,7 @@ static void emulated_push_event(EmulatedState *card, EmulEvent *event)
qemu_mutex_lock(&card->event_list_mutex);
QSIMPLEQ_INSERT_TAIL(&(card->event_list), event, entry);
qemu_mutex_unlock(&card->event_list_mutex);
if (write(card->pipe[1], card, 1) != 1) {
DPRINTF(card, 1, "write to pipe failed\n");
}
event_notifier_set(&card->notifier);
}
static void emulated_push_type(EmulatedState *card, uint32_t type)
@@ -358,16 +356,12 @@ static void *event_thread(void *arg)
return NULL;
}
static void pipe_read(void *opaque)
static void card_event_handler(EventNotifier *notifier)
{
EmulatedState *card = opaque;
EmulatedState *card = container_of(notifier, EmulatedState, notifier);
EmulEvent *event, *next;
char dummy;
int len;
do {
len = read(card->pipe[0], &dummy, sizeof(dummy));
} while (len == sizeof(dummy));
event_notifier_test_and_clear(&card->notifier);
qemu_mutex_lock(&card->event_list_mutex);
QSIMPLEQ_FOREACH_SAFE(event, &card->event_list, entry, next) {
DPRINTF(card, 2, "event %s\n", emul_event_to_string(event->p.gen.type));
@@ -404,16 +398,13 @@ static void pipe_read(void *opaque)
qemu_mutex_unlock(&card->event_list_mutex);
}
static int init_pipe_signaling(EmulatedState *card)
static int init_event_notifier(EmulatedState *card)
{
if (pipe(card->pipe) < 0) {
DPRINTF(card, 2, "pipe creation failed\n");
if (event_notifier_init(&card->notifier, false) < 0) {
DPRINTF(card, 2, "event notifier creation failed\n");
return -1;
}
fcntl(card->pipe[0], F_SETFL, O_NONBLOCK);
fcntl(card->pipe[1], F_SETFL, O_NONBLOCK);
fcntl(card->pipe[0], F_SETOWN, getpid());
qemu_set_fd_handler(card->pipe[0], pipe_read, NULL, card);
event_notifier_set_handler(&card->notifier, card_event_handler);
return 0;
}
@@ -500,7 +491,7 @@ static int emulated_initfn(CCIDCardState *base)
qemu_cond_init(&card->handle_apdu_cond);
card->reader = NULL;
card->quit_apdu_thread = 0;
if (init_pipe_signaling(card) < 0) {
if (init_event_notifier(card) < 0) {
return -1;
}
+16 -8
View File
@@ -19,6 +19,7 @@
*/
#include "qemu-common.h"
#include "qemu/error-report.h"
#include "hw/usb.h"
#include "hw/usb/desc.h"
#include "sysemu/bt.h"
@@ -506,6 +507,14 @@ static int usb_bt_initfn(USBDevice *dev)
usb_desc_create_serial(dev);
usb_desc_init(dev);
s->dev.opaque = s;
if (!s->hci) {
s->hci = bt_new_hci(qemu_find_bt_vlan(0));
}
s->hci->opaque = s;
s->hci->evt_recv = usb_bt_out_hci_packet_event;
s->hci->acl_recv = usb_bt_out_hci_packet_acl;
usb_bt_handle_reset(&s->dev);
s->intr = usb_ep_get(dev, USB_TOKEN_IN, USB_EVT_EP);
return 0;
@@ -516,6 +525,7 @@ static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline)
USBDevice *dev;
struct USBBtState *s;
HCIInfo *hci;
const char *name = "usb-bt-dongle";
if (*cmdline) {
hci = hci_init(cmdline);
@@ -525,19 +535,17 @@ static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline)
if (!hci)
return NULL;
dev = usb_create_simple(bus, "usb-bt-dongle");
dev = usb_create(bus, name);
if (!dev) {
error_report("Failed to create USB device '%s'", name);
return NULL;
}
s = DO_UPCAST(struct USBBtState, dev, dev);
s->dev.opaque = s;
s->hci = hci;
s->hci->opaque = s;
s->hci->evt_recv = usb_bt_out_hci_packet_event;
s->hci->acl_recv = usb_bt_out_hci_packet_acl;
usb_bt_handle_reset(&s->dev);
if (qdev_init(&dev->qdev) < 0) {
error_report("Failed to initialize USB device '%s'", name);
return NULL;
}
return dev;
}
+2 -2
View File
@@ -1522,7 +1522,7 @@ static void usb_host_auto_check(void *unused)
{
struct USBHostDevice *s;
struct USBAutoFilter *f;
libusb_device **devs;
libusb_device **devs = NULL;
struct libusb_device_descriptor ddesc;
int unconnected = 0;
int i, n;
@@ -1623,7 +1623,7 @@ static void usb_host_auto_check(void *unused)
void usb_host_info(Monitor *mon, const QDict *qdict)
{
libusb_device **devs;
libusb_device **devs = NULL;
struct libusb_device_descriptor ddesc;
char port[16];
int i, n;