aboutsummaryrefslogtreecommitdiffstats
path: root/hw/usb.h
AgeCommit message (Collapse)AuthorFilesLines
2012-01-27usb: convert to QEMU Object ModelAnthony Liguori1-11/+39
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-19Merge remote-tracking branch 'kraxel/usb.37' into stagingAnthony Liguori1-1/+43
* kraxel/usb.37: usb-redir: Improve some debugging messages usb-redir: Try to keep our buffer size near the target size usb-redir: Pre-fill our isoc input buffer before sending pkts to the host usb-redir: Dynamically adjust iso buffering size based on ep interval usb-redir: Clear iso / irq error when stopping the stream usb: link packets to endpoints not devices usb: add max_packet_size to USBEndpoint usb/debug: add usb_ep_dump usb-desc: USBEndpoint support usb: add ifnum to USBEndpoint usb: add USBEndpoint xhci: Initial xHCI implementation usb: add audio device model usb-desc: audio endpoint support usb: track altsetting in USBDevice usb: track configuration and interface count in USBDevice. usb-host: rip out legacy procfs support
2012-01-17usb: link packets to endpoints not devicesGerd Hoffmann1-1/+3
Add USBEndpoint for the control endpoint to USBDevices. Link async packets to the USBEndpoint instead of the USBDevice. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-17usb: add max_packet_size to USBEndpointGerd Hoffmann1-0/+4
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-17usb/debug: add usb_ep_dumpGerd Hoffmann1-0/+1
Add function to dump endpoint data, for debugging purposes. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-17usb: add ifnum to USBEndpointGerd Hoffmann1-0/+3
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-17usb: add USBEndpointGerd Hoffmann1-0/+14
Start maintaining endpoint state at USBDevice level. Add USBEndpoint struct and some helper functions to deal with it. For now it contains the endpoint type only. Moved over some bits from usb-linux.c Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-13vmstate: extract declarations out of hw/hw.hPaolo Bonzini1-0/+12
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-13usb: add audio device modelH. Peter Anvin1-0/+7
This brings a usb audio device to qemu. Output only, fixed at 16bit stereo @ 480000 Hz. Based on a patch from H. Peter Anvin <hpa@linux.intel.com> Usage: add '-device usb-audio' to your qemu command line. Works sorta ok on a idle machine. Known issues: * Is *very* sensitive to latencies. * Burns quite some CPU due to usb polling. In short: It brings the qemu usb emulation to its limits. Enjoy! Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-13usb: track altsetting in USBDeviceGerd Hoffmann1-0/+8
Also handle {GET,SET}_INTERFACE in common code (usb-desc.c). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-13usb: track configuration and interface count in USBDevice.Gerd Hoffmann1-0/+3
Move fields from USBHostDevice to USBDevice. Add bits to usb-desc.c to fill them for emulated devices too. Also allow to set configuration 0 (== None) for emulated devices. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-10-13usb: fix port resetGerd Hoffmann1-0/+1
commit 891fb2cd4592b6fe76106a69e0ca40efbf82726a removed the implicit detach before (re-)attaching in usb_attach(). Some usb host controllers used that behavior though to do a port reset by a detach+attach sequence. This patch establishes old behavior by adding a new usb_reset() function for port resets and putting it into use, thereby also unifying port reset behavior of all host controllers. The patch also adds asserts to usb_attach() and usb_detach() to make sure the calls are symmetrical. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07usb-musb: Add reset functionJuha Riihimäki1-0/+1
Add a separate reset function musb_reset() to the usb-musb interface, so that users who implement a reset function can also reset usb-musb. Use this in tusb6010. Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com> [Riku Voipio: Fixes and restructuring patchset] Signed-off-by: Riku Voipio <riku.voipio@iki.fi> [Peter Maydell: More fixes and cleanups for upstream submission] Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07usb-musb: Take a DeviceState* in init functionPeter Maydell1-1/+1
Initialise usb-musb by passing it a DeviceState* and the offset of the IRQs in its gpio array, rather than a plain pointer to an irq array. This is simpler for callers and also allows us to pass in a valid parent to usb_bus_new(), so the USB bus actually appears in the qdev tree. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07usb: Remove leading underscores from __musb_irq_maxPeter Maydell1-1/+2
Identifiers with double leading underscore are reserved, so rename __musb_irq_max so we don't encroach on reserved namespace. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07usb: claim port at device initialization time.Gerd Hoffmann1-1/+4
This patch makes qemu assign a port when creating the device, not when attaching it. For most usb devices this isn't a noticable difference because they are in attached state all the time. The change affects usb-host devices which live in detached state while the real device is unplugged from the host. They have a fixed port assigned all the time now instead of getting grabbing one on attach and releasing it at detach, i.e. they stop floating around at the usb bus. The change also allows to simplify usb-hub. It doesn't need the handle_attach() callback any more to configure the downstream ports. This can be done at device initialitation time now. The changed initialization order (first grab upstream port, then register downstream ports) also fixes some icky corner cases. For example it is not possible any more to plug the hub into one of its own downstream ports. The usb host adapters must care too. USBPort->dev being non-NULL doesn't imply any more the device is in attached state. The host adapters must additionally check the USBPort->dev->attached flag. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-10usb-hid: remove usb_hid_datain_cbGerd Hoffmann1-3/+0
No users left, all migrated over to hw/hid.[ch]. Yea! Zap it! Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-04usb: use iovecs in USBPacketGerd Hoffmann1-2/+11
Zap data pointer from USBPacket, add a QEMUIOVector instead. Add a bunch of helper functions to manage USBPacket data. Switch over users to the new interface. Note that USBPacket->len was used for two purposes: First to pass in the buffer size and second to return the number of transfered bytes or the status code on async transfers. There is a new result variable for the latter. A new status code was added to catch uninitialized result. Nobody creates iovecs with more than one element (yet). Some users are (temporarely) limited to iovecs with a single element to keep the patch size as small as possible. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb: Replace device_destroy bus op with a child_detach port opHans de Goede1-1/+5
Note this fixes 2 things in one go, first of all the device_destroy bus op should be a device_detach bus op, as pending async packets from the device should be cancelled on detach not on destroy. Secondly having this as a bus op won't work with companion controllers, since then there will be 1 bus driven by the ehci controller and thus 1 set of bus ops, but the device being detached may be downstream of a handed over port. Making the detach of a downstream device a port op allows the ehci controller to forward this to the companion controller port for handed over ports. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb: Make port wakeup and complete ops take a USBPort instead of a DeviceHans de Goede1-2/+7
This makes them consistent with the attach and detach ops, and in general it makes sense to make portops take a port as argument. This also makes adding support for a companion controller easier / cleaner. [ kraxel: fix usb-musb.c build ] Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb: Add a register_companion USB bus op.Hans de Goede1-0/+5
This is a preparation patch for adding support for USB companion controllers. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-23usb: ignore USB_DT_DEBUGGerd Hoffmann1-0/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-23usb: Add a speedmask to devicesHans de Goede1-0/+3
This is used to indicate at which speed[s] the device can operate, so that this can be checked to match the ports capabilities when it gets attached to a bus. Note that currently all usb1 emulated device claim to be fullspeed, this seems to not cause any problems, but still seems wrong, because with real hardware keyboards, mice and tablets usually are lo-speed, so reporting these as fullspeed devices seems wrong. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14usb: Add defines for USB Serial Bus Release Number registerBrad Hards1-0/+6
Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14usb: cancel async packets on unplugGerd Hoffmann1-1/+7
This patch adds USBBusOps struct with (for now) only a single callback which is called when a device is about to be destroyed. The USB Host adapters are implementing this callback and use it to cancel any async requests which might be in flight before the device actually goes away. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26usb: move cancel callback to USBDeviceInfoGerd Hoffmann1-12/+5
Remove the cancel callback from the USBPacket struct, move it over to USBDeviceInfo. Zap usb_defer_packet() which is obsolete now. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26usb: keep track of packet owner.Gerd Hoffmann1-15/+3
Keep track of the device which owns the usb packet for async processing. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26usb: add usb_handle_packetGerd Hoffmann1-0/+2
Add a usb_handle_packet function, put it into use everywhere. Right now it just calls dev->info->handle_packet(), that will change in future patches though. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26usb-linux: use usb_generic_handle_packet()Hans de Goede1-0/+1
Make the linux usb host passthrough code use the usb_generic_handle_packet() function, rather then the curent DYI code. This removes 200 lines of almost identical code. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-05-26usb: Pass the packet to the device's handle_control callbackHans de Goede1-1/+1
This allows using the generic usb_generic_handle_packet function from device code which does ASYNC control requests (such as the linux host pass through code). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-05-26usb: add support for "grouped" interfaces and the Interface Association ↵Brad Hards1-0/+1
Descriptor This is used for some devices that have multiple interfaces that form a logic device. An example is Video Class, which has a Control interface and a Streaming interface. There can be additional interfaces on the same (physical) devices (e.g. a microphone), and Interface Association Descriptor handles this case. Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26usb: Add Interface Association Descriptor descriptor typeBrad Hards1-0/+1
Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-04usb: move complete callback to port opsGerd Hoffmann1-4/+3
2011-05-04usb: control buffer fixesHans de Goede1-1/+1
Windows allows control transfers to pass up to 4k of data, so raise our control buffer size to 4k. For control out transfers the usb core code copies the control request data to a buffer before calling the device's handle_control callback. Add a check for overflowing the buffer before copying the data. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-01-24usb core: add migration supportGerd Hoffmann1-5/+5
Yes, seriously. There is no migration support at all for usb devices. They loose state, especially the device address, and stop responding because of that. Oops. Luckily there is so much broken usb hardware out there that the guest usually just kicks the device hard (via port reset and reinitialization), then continues without a hitch. So we got away with that in a surprising high number of cases. The arrival of remote wakeup (which enables autosuspend support) changes that picture though. The usb devices also forget that it they are supposed to wakeup, so they don't do that. The host also doesn't notice the device stopped working in case it suspended the device and thus expects it waking up instead of polling it. Result is that your mouse is dead. Lets start fixing that. Add a vmstate struct for USBDevice. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-12usb: zap pdev from usbportGerd Hoffmann1-2/+1
It isn't needed any more. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: add port property.Gerd Hoffmann1-0/+1
This allows to explictily set the physical port where you want to plug the usb device. Example: -device usb-tablet,bus=usb.0,port=2 With explicit port addressing qemu can and will not automagically add USB Hubs. This means that: (a) You can plug two devices of your choice into the two uhci root ports. (b) If you want plug in more that two devices you have to care about adding a hub yourself. Plugging a hub works this way: -device usb-hub,bus=usb.0,port=1 Use this to add a device to the hub: -device usb-tablet,bus=usb.0,port=1.1 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: keep track of physical port address.Gerd Hoffmann1-0/+2
Add a path string to USBPort. Add usb_port_location() function to set the physical location of the usb port. Update all drivers implementing usb ports to call it. Update the monitor commands to print it. Wind it up in qdev. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: add device qualifier supportGerd Hoffmann1-0/+2
Add support for device_qualifier and other_speed_config descriptors. These are used to query the "other speed" configuration of usb 2.0 devices, i.e. in high-speed mode they return the full-speed configuration and visa versa. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: add attach callbackGerd Hoffmann1-0/+5
Add handle_attach() callback to USBDeviceInfo which is called by the generic package handler when the device is attached to the usb bus (i.e. plugged into a port). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: add speed mask to portsGerd Hoffmann1-1/+8
Add a field to usb ports indicating the speed(s) they are able to handle. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: add usb_wakeup() + wakeup callback to port opsGerd Hoffmann1-0/+2
Add wakeup callback to port ops for remote wakeup handling. Also add a usb_wakeup() function for devices which want trigger a remote wakeup. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: rework attach/detach workflowGerd Hoffmann1-1/+3
Add separate detach callback to USBPortOps, split uhci/ohci/musb/usbhub attach functions into two. Move common code to the usb_attach() function, only the hardware-specific bits remain in the attach/detach callbacks. Keep track of the port it is attached to for each usb device. [ v3: fix tyops in usb-musb.c ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: create USBPortOps, move attach there.Gerd Hoffmann1-3/+5
Create USBPortOps struct, move the attach function to that struct. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: move USB_REQ_{GET,SET}_CONFIGURATION handling to common codeGerd Hoffmann1-0/+2
This patch adds fields to the USBDevice struct for the current speed (hard-wired to full speed for now) and current device configuration. Also a init function is added which inializes these fields. This allows USB_REQ_{GET,SET}_CONFIGURATION handling to be moved to common code. For most drivers the conversion is trivial ad they support a single configuration only anyway. One exception is bluetooth where some device-specific setup code runs after get/set configuration. The other is usb-net which actually has two configurations so the the code to check for the active configuration has been adapted. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb descriptors: add settable strings.Gerd Hoffmann1-0/+9
This patch allows to set usb descriptor strings per device instance. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: data structs and helpers for usb descriptors.Gerd Hoffmann1-0/+9
This patch adds hw/usb-desc.[ch] files. They carry data structures for various usb descriptors and helper functions to generate usb packets from the structures. The intention is to have a internal representation of the device desription which is more usable than the current char array blobs, so we can have common code handle common usb device emulation using the device description. The usage of this infrastructure is optional for usb drivers as there are cases such as pass-through where it probably isn't very useful. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2010-12-11Record which USBDevice USBPort belongs too.Gleb Natapov1-1/+2
Ports on root hub will have NULL here. This is needed to reconstruct path from device to its root hub to build device path. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-03-31usb: class specific interface requestsMax Reitz1-0/+4
Mass Storage Reset and Get Max LUN are class specific requests, but they were not marked as such in hw/usb-msd.c, moved therefore ClassInterfaceRequest and ClassInterfaceOutRequest from hw/usb-net.c to hw/usb.h. Furthermore there was a problem in hw/usb-ohci.c when using DEBUG concerning systems where size_t is a 32 bit integer (printf resulted in a segmentation fault). Signed-off-by: Max Reitz <max@tyndur.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-18usb-net: use qdev for -usbdeviceGerd Hoffmann1-3/+0
Rebased to master, adapted to device renaming by armbru, no other changes. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>