mirror of
https://github.com/qemu/qemu.git
synced 2024-11-26 04:13:39 +08:00
usb: pass USBEndpoint to usb_wakeup
Devices must specify which endpoint has data to transfer now. The plan is to use the usb_wakeup() not only for remove wakeup support, but for "data ready" signaling in general, so we can move away from constant polling to event driven usb device emulation. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
db4be873d3
commit
7567b51fbe
@ -267,6 +267,7 @@ typedef struct CCIDBus {
|
||||
*/
|
||||
typedef struct USBCCIDState {
|
||||
USBDevice dev;
|
||||
USBEndpoint *intr;
|
||||
CCIDBus bus;
|
||||
CCIDCardState *card;
|
||||
BulkIn bulk_in_pending[BULK_IN_PENDING_NUM]; /* circular */
|
||||
@ -839,7 +840,7 @@ static void ccid_on_slot_change(USBCCIDState *s, bool full)
|
||||
s->bmSlotICCState |= SLOT_0_CHANGED_MASK;
|
||||
}
|
||||
s->notify_slot_change = true;
|
||||
usb_wakeup(&s->dev);
|
||||
usb_wakeup(s->intr);
|
||||
}
|
||||
|
||||
static void ccid_write_data_block_error(
|
||||
@ -1190,6 +1191,7 @@ static int ccid_initfn(USBDevice *dev)
|
||||
|
||||
usb_desc_init(dev);
|
||||
qbus_create_inplace(&s->bus.qbus, &ccid_bus_info, &dev->qdev, NULL);
|
||||
s->intr = usb_ep_get(dev, USB_TOKEN_IN, CCID_INT_IN_EP);
|
||||
s->bus.qbus.allow_hotplug = 1;
|
||||
s->card = NULL;
|
||||
s->migration_state = MIGRATION_NONE;
|
||||
|
@ -44,6 +44,7 @@
|
||||
|
||||
typedef struct USBHIDState {
|
||||
USBDevice dev;
|
||||
USBEndpoint *intr;
|
||||
HIDState hid;
|
||||
} USBHIDState;
|
||||
|
||||
@ -360,7 +361,7 @@ static void usb_hid_changed(HIDState *hs)
|
||||
{
|
||||
USBHIDState *us = container_of(hs, USBHIDState, hid);
|
||||
|
||||
usb_wakeup(&us->dev);
|
||||
usb_wakeup(us->intr);
|
||||
}
|
||||
|
||||
static void usb_hid_handle_reset(USBDevice *dev)
|
||||
@ -501,6 +502,7 @@ static int usb_hid_initfn(USBDevice *dev, int kind)
|
||||
USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev);
|
||||
|
||||
usb_desc_init(dev);
|
||||
us->intr = usb_ep_get(dev, USB_TOKEN_IN, 1);
|
||||
hid_init(&us->hid, kind, usb_hid_changed);
|
||||
return 0;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ typedef struct USBHubPort {
|
||||
|
||||
typedef struct USBHubState {
|
||||
USBDevice dev;
|
||||
USBEndpoint *intr;
|
||||
USBHubPort ports[NUM_PORTS];
|
||||
} USBHubState;
|
||||
|
||||
@ -163,7 +164,7 @@ static void usb_hub_attach(USBPort *port1)
|
||||
} else {
|
||||
port->wPortStatus &= ~PORT_STAT_LOW_SPEED;
|
||||
}
|
||||
usb_wakeup(&s->dev);
|
||||
usb_wakeup(s->intr);
|
||||
}
|
||||
|
||||
static void usb_hub_detach(USBPort *port1)
|
||||
@ -171,7 +172,7 @@ static void usb_hub_detach(USBPort *port1)
|
||||
USBHubState *s = port1->opaque;
|
||||
USBHubPort *port = &s->ports[port1->index];
|
||||
|
||||
usb_wakeup(&s->dev);
|
||||
usb_wakeup(s->intr);
|
||||
|
||||
/* Let upstream know the device on this port is gone */
|
||||
s->dev.port->ops->child_detach(s->dev.port, port1->dev);
|
||||
@ -199,7 +200,7 @@ static void usb_hub_wakeup(USBPort *port1)
|
||||
|
||||
if (port->wPortStatus & PORT_STAT_SUSPEND) {
|
||||
port->wPortChange |= PORT_STAT_C_SUSPEND;
|
||||
usb_wakeup(&s->dev);
|
||||
usb_wakeup(s->intr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -481,6 +482,7 @@ static int usb_hub_initfn(USBDevice *dev)
|
||||
int i;
|
||||
|
||||
usb_desc_init(dev);
|
||||
s->intr = usb_ep_get(dev, USB_TOKEN_IN, 1);
|
||||
for (i = 0; i < NUM_PORTS; i++) {
|
||||
port = &s->ports[i];
|
||||
usb_register_port(usb_bus_from_device(dev),
|
||||
|
4
hw/usb.c
4
hw/usb.c
@ -70,8 +70,10 @@ void usb_device_reset(USBDevice *dev)
|
||||
usb_device_handle_reset(dev);
|
||||
}
|
||||
|
||||
void usb_wakeup(USBDevice *dev)
|
||||
void usb_wakeup(USBEndpoint *ep)
|
||||
{
|
||||
USBDevice *dev = ep->dev;
|
||||
|
||||
if (dev->remote_wakeup && dev->port && dev->port->ops->wakeup) {
|
||||
dev->port->ops->wakeup(dev->port);
|
||||
}
|
||||
|
2
hw/usb.h
2
hw/usb.h
@ -368,7 +368,7 @@ void usb_attach(USBPort *port);
|
||||
void usb_detach(USBPort *port);
|
||||
void usb_port_reset(USBPort *port);
|
||||
void usb_device_reset(USBDevice *dev);
|
||||
void usb_wakeup(USBDevice *dev);
|
||||
void usb_wakeup(USBEndpoint *ep);
|
||||
void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p);
|
||||
int set_usb_string(uint8_t *buf, const char *str);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user