Ignore:
Timestamp:
2010-12-15T13:25:20Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1840e0d
Parents:
d5e7668
Message:

usbvirt: add callback when device changes state

The virtual root hub uses this to suspend power source to all
ports when entering `configured' state.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbvirt/include/usbvirt/device.h

    rd5e7668 r266d0871  
    5252} usbvirt_request_recipient_t;
    5353
     54/** Possible states of virtual USB device.
     55 * Notice that these are not 1:1 mappings to those in USB specification.
     56 */
     57typedef enum {
     58        USBVIRT_STATE_DEFAULT,
     59        USBVIRT_STATE_ADDRESS,
     60        USBVIRT_STATE_CONFIGURED
     61} usbvirt_device_state_t;
     62
    5463typedef struct usbvirt_device usbvirt_device_t;
    5564struct usbvirt_control_transfer;
     
    96105        usb_direction_t (*decide_control_transfer_direction)(
    97106            usb_endpoint_t endpoint, void *buffer, size_t size);
     107
     108        /** Callback when device changes its state.
     109         *
     110         * It is correct that this function is called when both states
     111         * are equal (e.g. this function is called during SET_CONFIGURATION
     112         * request done on already configured device).
     113         *
     114         * @warning The value of <code>dev->state</code> before calling
     115         * this function is not specified (i.e. can be @p old_state or
     116         * @p new_state).
     117         */
     118        void (*on_state_change)(usbvirt_device_t *dev,
     119            usbvirt_device_state_t old_state, usbvirt_device_state_t new_state);
    98120} usbvirt_device_ops_t;
    99121
     
    130152        uint8_t current_configuration;
    131153} usbvirt_descriptors_t;
    132 
    133 /** Possible states of virtual USB device.
    134  * Notice that these are not 1:1 mappings to those in USB specification.
    135  */
    136 typedef enum {
    137         USBVIRT_STATE_DEFAULT,
    138         USBVIRT_STATE_ADDRESS,
    139         USBVIRT_STATE_CONFIGURED
    140 } usbvirt_device_state_t;
    141154
    142155/** Information about on-going control transfer.
Note: See TracChangeset for help on using the changeset viewer.