Changeset df6ded8 in mainline for uspace/lib/usbdev/include/usb
- Timestamp:
- 2018-02-28T16:37:50Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1b20da0
- Parents:
- f5e5f73 (diff), b2dca8de (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Jakub Jermar <jakub@…> (2018-02-28 16:06:42)
- git-committer:
- Jakub Jermar <jakub@…> (2018-02-28 16:37:50)
- Location:
- uspace/lib/usbdev/include/usb/dev
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/include/usb/dev/device.h
rf5e5f73 rdf6ded8 42 42 #include <usb/dev/alternate_ifaces.h> 43 43 #include <usb/dev/pipes.h> 44 #include <usbhc_iface.h> 44 45 45 46 #include <assert.h> … … 58 59 59 60 /* DDF parts */ 60 errno_t usb_device_create_ddf(ddf_dev_t *, const usb_endpoint_description_t **, const char **); 61 errno_t usb_device_create_ddf(ddf_dev_t *, 62 const usb_endpoint_description_t **, const char **); 61 63 void usb_device_destroy_ddf(ddf_dev_t *); 62 64 … … 67 69 } 68 70 69 usb_device_t * usb_device_create(devman_handle_t);71 usb_device_t *usb_device_create(devman_handle_t); 70 72 void usb_device_destroy(usb_device_t *); 71 73 72 const char * usb_device_get_name(usb_device_t *);74 const char *usb_device_get_name(usb_device_t *); 73 75 ddf_fun_t *usb_device_ddf_fun_create(usb_device_t *, fun_type_t, const char *); 74 76 75 async_exch_t * usb_device_bus_exchange_begin(usb_device_t *);77 async_exch_t *usb_device_bus_exchange_begin(usb_device_t *); 76 78 void usb_device_bus_exchange_end(async_exch_t *); 77 79 … … 86 88 usb_endpoint_mapping_t * usb_device_get_mapped_ep_desc(usb_device_t *, 87 89 const usb_endpoint_description_t *); 88 usb_endpoint_mapping_t * usb_device_get_mapped_ep(usb_device_t *, 89 usb_endpoint_t); 90 int usb_device_unmap_ep(usb_endpoint_mapping_t *); 90 91 91 int usb_device_get_iface_number(usb_device_t *); 92 devman_handle_t usb_device_get_devman_handle(usb_device_t *); 92 usb_address_t usb_device_get_address(const usb_device_t *); 93 usb_speed_t usb_device_get_depth(const usb_device_t *); 94 usb_speed_t usb_device_get_speed(const usb_device_t *); 95 int usb_device_get_iface_number(const usb_device_t *); 96 devman_handle_t usb_device_get_devman_handle(const usb_device_t *); 93 97 94 const usb_device_descriptors_t * usb_device_descriptors(usb_device_t *);98 const usb_device_descriptors_t *usb_device_descriptors(usb_device_t *); 95 99 96 const usb_alternate_interfaces_t * usb_device_get_alternative_ifaces(100 const usb_alternate_interfaces_t *usb_device_get_alternative_ifaces( 97 101 usb_device_t *); 98 102 99 void * usb_device_data_alloc(usb_device_t *, size_t);100 void * usb_device_data_get(usb_device_t *);103 void *usb_device_data_alloc(usb_device_t *, size_t); 104 void *usb_device_data_get(usb_device_t *); 101 105 102 106 #endif -
uspace/lib/usbdev/include/usb/dev/driver.h
rf5e5f73 rdf6ded8 45 45 errno_t (*device_add)(usb_device_t *); 46 46 /** Callback when a device is about to be removed from the system. */ 47 errno_t (*device_rem )(usb_device_t *);47 errno_t (*device_remove)(usb_device_t *); 48 48 /** Callback when a device was removed from the system. */ 49 49 errno_t (*device_gone)(usb_device_t *); 50 /** Callback asking the driver to online a specific function. */ 51 errno_t (*function_online)(ddf_fun_t *); 52 /** Callback asking the driver to offline a specific function. */ 53 errno_t (*function_offline)(ddf_fun_t *); 50 54 } usb_driver_ops_t; 51 55 -
uspace/lib/usbdev/include/usb/dev/pipes.h
rf5e5f73 rdf6ded8 1 1 /* 2 2 * Copyright (c) 2011 Vojtech Horky 3 * Copyright (c) 2018 Ondrej Hlavaty 3 4 * All rights reserved. 4 5 * … … 44 45 45 46 #define CTRL_PIPE_MIN_PACKET_SIZE 8 47 46 48 /** Abstraction of a logical connection to USB device endpoint. 47 * It encapsulates endpoint attributes (transfer type etc.).49 * It contains some vital information about the pipe. 48 50 * This endpoint must be bound with existing usb_device_connection_t 49 51 * (i.e. the wire to send data over). 50 52 */ 51 53 typedef struct { 52 /** Endpoint number. */ 53 usb_endpoint_t endpoint_no; 54 55 /** Endpoint transfer type. */ 56 usb_transfer_type_t transfer_type; 57 58 /** Endpoint direction. */ 59 usb_direction_t direction; 60 61 /** Maximum packet size for the endpoint. */ 62 size_t max_packet_size; 63 64 /** Number of packets per frame/uframe. 65 * Only valid for HS INT and ISO transfers. All others should set to 1*/ 66 unsigned packets; 54 /** Pipe description received from HC */ 55 usb_pipe_desc_t desc; 67 56 68 57 /** Whether to automatically reset halt on the endpoint. … … 70 59 */ 71 60 bool auto_reset_halt; 72 73 61 /** The connection used for sending the data. */ 74 62 usb_dev_session_t *bus_session; … … 103 91 /** Found descriptor fitting the description. */ 104 92 const usb_standard_endpoint_descriptor_t *descriptor; 93 /** Relevant superspeed companion descriptor. */ 94 const usb_superspeed_endpoint_companion_descriptor_t 95 *companion_descriptor; 105 96 /** Interface descriptor the endpoint belongs to. */ 106 97 const usb_standard_interface_descriptor_t *interface; … … 109 100 } usb_endpoint_mapping_t; 110 101 111 errno_t usb_pipe_initialize(usb_pipe_t *, usb_endpoint_t, usb_transfer_type_t, 112 size_t, usb_direction_t, unsigned, usb_dev_session_t *); 102 errno_t usb_pipe_initialize(usb_pipe_t *, usb_dev_session_t *); 113 103 errno_t usb_pipe_initialize_default_control(usb_pipe_t *, usb_dev_session_t *); 114 104 115 errno_t usb_pipe_probe_default_control(usb_pipe_t *);116 105 errno_t usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *, 117 106 size_t, const uint8_t *, size_t, usb_dev_session_t *); 118 107 119 errno_t usb_pipe_register(usb_pipe_t *, unsigned); 108 errno_t usb_pipe_register(usb_pipe_t *, 109 const usb_standard_endpoint_descriptor_t *, 110 const usb_superspeed_endpoint_companion_descriptor_t *); 120 111 errno_t usb_pipe_unregister(usb_pipe_t *); 121 112 122 113 errno_t usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *); 123 114 errno_t usb_pipe_write(usb_pipe_t *, const void *, size_t); 115 116 errno_t usb_pipe_read_dma(usb_pipe_t *, void *, void *, size_t, size_t *); 117 errno_t usb_pipe_write_dma(usb_pipe_t *, void *, void *, size_t); 124 118 125 119 errno_t usb_pipe_control_read(usb_pipe_t *, const void *, size_t, … … 128 122 const void *, size_t); 129 123 124 void *usb_pipe_alloc_buffer(usb_pipe_t *, size_t); 125 void usb_pipe_free_buffer(usb_pipe_t *, void *); 130 126 #endif 131 127 /** -
uspace/lib/usbdev/include/usb/dev/poll.h
rf5e5f73 rdf6ded8 1 1 /* 2 2 * Copyright (c) 2011 Vojtech Horky 3 * Copyright (c) 2017 Petr Manek 3 4 * All rights reserved. 4 5 * … … 43 44 #include <stddef.h> 44 45 #include <stdint.h> 46 #include <fibril_synch.h> 45 47 46 /** Parameters and callbacks for automated polling. */ 47 typedef struct { 48 /** Level of debugging messages from auto polling. 49 * 0 - nothing 50 * 1 - inform about errors and polling start/end 51 * 2 - also dump every retrieved buffer 48 49 /** USB automated polling. */ 50 typedef struct usb_polling { 51 /** Mandatory parameters - user is expected to configure these. */ 52 53 /** USB device to poll. */ 54 usb_device_t *device; 55 56 /** Device enpoint mapping to use for polling. */ 57 usb_endpoint_mapping_t *ep_mapping; 58 59 /** Size of the recieved data. */ 60 size_t request_size; 61 62 /** 63 * Data buffer of at least `request_size`. User is responsible for its 64 * allocation. 52 65 */ 53 int debug; 54 /** Maximum number of consecutive errors before polling termination. */ 55 size_t max_failures; 56 /** Delay between poll requests in milliseconds. 57 * Set to negative value to use value from endpoint descriptor. 58 */ 59 int delay; 60 /** Whether to automatically try to clear the HALT feature after 61 * the endpoint stalls. 62 */ 63 bool auto_clear_halt; 66 uint8_t *buffer; 67 64 68 /** Callback when data arrives. 65 69 * … … 72 76 bool (*on_data)(usb_device_t *dev, uint8_t *data, size_t data_size, 73 77 void *arg); 78 79 80 /** 81 * Optional parameters - user can customize them, but they are 82 * defaulted to some reasonable values. 83 */ 84 85 /** Level of debugging messages from auto polling. 86 * 0 - nothing (default) 87 * 1 - inform about errors and polling start/end 88 * 2 - also dump every retrieved buffer 89 */ 90 int debug; 91 92 /** 93 * Maximum number of consecutive errors before polling termination 94 * (default 3). 95 */ 96 size_t max_failures; 97 98 /** Delay between poll requests in milliseconds. 99 * By default, value from endpoint descriptor used. 100 */ 101 int delay; 102 103 /** Whether to automatically try to clear the HALT feature after 104 * the endpoint stalls (true by default). 105 */ 106 bool auto_clear_halt; 107 108 /** Argument to pass to callbacks (default NULL). */ 109 void *arg; 110 74 111 /** Callback when polling is terminated. 75 112 * … … 80 117 void (*on_polling_end)(usb_device_t *dev, bool due_to_errors, 81 118 void *arg); 119 82 120 /** Callback when error occurs. 83 121 * … … 88 126 */ 89 127 bool (*on_error)(usb_device_t *dev, errno_t err_code, void *arg); 90 /** Argument to pass to callbacks. */91 void *arg;92 } usb_device_auto_polling_t;93 128 94 typedef bool (*usb_polling_callback_t)(usb_device_t *, uint8_t *, size_t, void *);95 typedef void (*usb_polling_terminted_callback_t)(usb_device_t *, bool, void *);96 129 97 extern errno_t usb_device_auto_polling(usb_device_t *, usb_endpoint_t, 98 const usb_device_auto_polling_t *, size_t); 130 /** 131 * Internal parameters - user is not expected to set them. Messing with 132 * them can result in unexpected behavior if you do not know what you 133 * are doing. 134 */ 99 135 100 extern errno_t usb_device_auto_poll(usb_device_t *, usb_endpoint_t, 101 usb_polling_callback_t, size_t, int, usb_polling_terminted_callback_t, void *);136 /** Fibril used for polling. */ 137 fid_t fibril; 102 138 103 extern errno_t usb_device_auto_polling_desc(usb_device_t *, 104 const usb_endpoint_description_t *, const usb_device_auto_polling_t *, 105 size_t); 139 /** True if polling is currently in operation. */ 140 volatile bool running; 106 141 107 extern errno_t usb_device_auto_poll_desc(usb_device_t *, 108 const usb_endpoint_description_t *, usb_polling_callback_t, size_t, int, 109 usb_polling_terminted_callback_t, void *); 142 /** True if polling should terminate as soon as possible. */ 143 volatile bool joining; 144 145 /** Synchronization primitives for joining polling end. */ 146 fibril_mutex_t guard; 147 fibril_condvar_t cv; 148 } usb_polling_t; 149 150 errno_t usb_polling_init(usb_polling_t *); 151 void usb_polling_fini(usb_polling_t *); 152 153 errno_t usb_polling_start(usb_polling_t *); 154 errno_t usb_polling_join(usb_polling_t *); 110 155 111 156 #endif -
uspace/lib/usbdev/include/usb/dev/request.h
rf5e5f73 rdf6ded8 85 85 char **); 86 86 87 errno_t usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t);88 87 errno_t usb_pipe_clear_halt(usb_pipe_t *, usb_pipe_t *); 89 88 errno_t usb_request_get_endpoint_status(usb_pipe_t *, usb_pipe_t *, uint16_t *);
Note:
See TracChangeset
for help on using the changeset viewer.
