Changeset 2b0db98 in mainline for uspace/lib/usb
- Timestamp:
- 2011-01-07T14:02:56Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6986418
- Parents:
- d99120f (diff), 0f191a2 (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. - Location:
- uspace/lib/usb
- Files:
-
- 5 edited
-
include/usb/hcdhubd.h (modified) (1 diff)
-
include/usb/usbdrv.h (modified) (1 diff)
-
src/hcdhubd.c (modified) (3 diffs)
-
src/recognise.c (modified) (3 diffs)
-
src/usbdrv.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/hcdhubd.h
rd99120f r2b0db98 207 207 int usb_hc_add_child_device(device_t *, const char *, const char *, bool); 208 208 209 210 /** 211 * @} 212 */ 213 209 214 #endif -
uspace/lib/usb/include/usb/usbdrv.h
rd99120f r2b0db98 41 41 #include <usb/descriptor.h> 42 42 43 int usb_drv_hc_connect(device_t *, unsigned int); 43 int usb_drv_find_hc(device_t *, devman_handle_t *); 44 int usb_drv_hc_connect(device_t *, devman_handle_t, unsigned int); 45 int usb_drv_hc_connect_auto(device_t *, unsigned int); 44 46 45 47 int usb_drv_reserve_default_address(int); -
uspace/lib/usb/src/hcdhubd.c
rd99120f r2b0db98 36 36 #include <usb/devreq.h> 37 37 #include <usbhc_iface.h> 38 #include <usb_iface.h> 38 39 #include <usb/descriptor.h> 39 40 #include <driver.h> … … 45 46 #include "hcdhubd_private.h" 46 47 48 49 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle) 50 { 51 assert(dev); 52 assert(dev->parent != NULL); 53 54 device_t *parent = dev->parent; 55 56 if (parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) { 57 usb_iface_t *usb_iface 58 = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE]; 59 assert(usb_iface != NULL); 60 if (usb_iface->get_hc_handle) { 61 int rc = usb_iface->get_hc_handle(parent, handle); 62 return rc; 63 } 64 } 65 66 return ENOTSUP; 67 } 68 69 static usb_iface_t usb_iface = { 70 .get_hc_handle = usb_iface_get_hc_handle 71 }; 72 73 static device_ops_t child_ops = { 74 .interfaces[USB_DEV_IFACE] = &usb_iface 75 }; 76 47 77 /** Callback when new device is detected and must be handled by this driver. 48 78 * … … 129 159 } 130 160 child->name = child_info->name; 161 child->parent = child_info->parent; 162 child->ops = &child_ops; 131 163 132 164 match_id = create_match_id(); -
uspace/lib/usb/src/recognise.c
rd99120f r2b0db98 33 33 * @brief Functions for recognising kind of attached devices. 34 34 */ 35 #include <usb_iface.h> 35 36 #include <usb/usbdrv.h> 36 37 #include <usb/classes/classes.h> … … 38 39 #include <errno.h> 39 40 41 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle) 42 { 43 assert(dev); 44 assert(dev->parent != NULL); 45 46 device_t *parent = dev->parent; 47 48 if (parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) { 49 usb_iface_t *usb_iface 50 = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE]; 51 assert(usb_iface != NULL); 52 if (usb_iface->get_hc_handle) { 53 int rc = usb_iface->get_hc_handle(parent, handle); 54 return rc; 55 } 56 } 57 58 return ENOTSUP; 59 } 60 61 static usb_iface_t usb_iface = { 62 .get_hc_handle = usb_iface_get_hc_handle 63 }; 64 65 static device_ops_t child_ops = { 66 .interfaces[USB_DEV_IFACE] = &usb_iface 67 }; 40 68 41 69 #define BCD_INT(a) (((unsigned int)(a)) / 256) … … 285 313 goto failure; 286 314 } 315 child->parent = parent; 287 316 child->name = child_name; 317 child->ops = &child_ops; 288 318 289 319 rc = usb_drv_create_device_match_ids(hc, &child->match_ids, address); -
uspace/lib/usb/src/usbdrv.c
rd99120f r2b0db98 35 35 #include <usb/usbdrv.h> 36 36 #include <usbhc_iface.h> 37 #include <usb_iface.h> 37 38 #include <errno.h> 38 39 #include <str_error.h> … … 54 55 } transfer_info_t; 55 56 57 /** Find handle of host controller the device is physically attached to. 58 * 59 * @param[in] dev Device looking for its host controller. 60 * @param[out] handle Host controller devman handle. 61 * @return Error code. 62 */ 63 int usb_drv_find_hc(device_t *dev, devman_handle_t *handle) 64 { 65 if (dev == NULL) { 66 return EBADMEM; 67 } 68 if (handle == NULL) { 69 return EBADMEM; 70 } 71 72 int parent_phone = devman_parent_device_connect(dev->handle, 73 IPC_FLAG_BLOCKING); 74 if (parent_phone < 0) { 75 return parent_phone; 76 } 77 78 devman_handle_t h; 79 int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE), 80 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h); 81 82 ipc_hangup(parent_phone); 83 84 if (rc != EOK) { 85 return rc; 86 } 87 88 *handle = h; 89 90 return EOK; 91 } 92 93 /** Connect to host controller the device is physically attached to. 94 * 95 * @param dev Device asking for connection. 96 * @param hc_handle Devman handle of the host controller. 97 * @param flags Connection flags (blocking connection). 98 * @return Phone to the HC or error code. 99 */ 100 int usb_drv_hc_connect(device_t *dev, devman_handle_t hc_handle, 101 unsigned int flags) 102 { 103 return devman_device_connect(hc_handle, flags); 104 } 105 56 106 /** Connect to host controller the device is physically attached to. 57 107 * … … 60 110 * @return Phone to corresponding HC or error code. 61 111 */ 62 int usb_drv_hc_connect(device_t *dev, unsigned int flags) 63 { 112 int usb_drv_hc_connect_auto(device_t *dev, unsigned int flags) 113 { 114 int rc; 115 devman_handle_t hc_handle; 116 64 117 /* 65 118 * Call parent hub to obtain device handle of respective HC. 66 119 */ 67 68 /* 69 * FIXME: currently we connect always to virtual host controller. 70 */ 71 int rc; 72 devman_handle_t handle; 73 74 rc = devman_device_get_handle("/virt/usbhc", &handle, flags); 120 rc = usb_drv_find_hc(dev, &hc_handle); 75 121 if (rc != EOK) { 76 122 return rc; 77 123 } 78 124 79 int phone = devman_device_connect(handle, flags); 80 81 return phone; 125 return usb_drv_hc_connect(dev, hc_handle, flags); 82 126 } 83 127
Note:
See TracChangeset
for help on using the changeset viewer.
