| 104 | } |
| 105 | |
| 106 | static void enable_interface(struct usbdev_ctrl *this, int iface_num) |
| 107 | { |
| 108 | struct usbdev_configuration *config = this->current_config; |
| 109 | struct usbdev_interface *iface = &config->interfaces[iface_num]; |
| 110 | |
| 111 | /* first: shut down all endpoints except EP0 */ |
| 112 | cease_operation(this); |
| 113 | |
| 114 | /* now enable all configured endpoints */ |
| 115 | int epcount = iface->descriptor.bNumEndpoints; |
| 116 | int i; |
| 117 | for (i = 0; i < epcount; i++) { |
| 118 | int ep = iface->eps[i].bEndpointAddress; |
| 119 | int mps = iface->eps[i].wMaxPacketSize; |
| 120 | int in_dir = 0; |
| 121 | if (ep & 0x80) { |
| 122 | in_dir = 1; |
| 123 | ep &= 0x7f; |
| 124 | } |
| 125 | int ep_type = iface->eps[i].bmAttributes & 0x3; |
| 126 | this->start_ep(this, ep, in_dir, ep_type, mps); |
| 127 | } |
| 128 | |
| 129 | this->current_iface = iface; |
| 130 | |
| 131 | // gadget specific configuration |
| 132 | if (iface->init) |
| 133 | iface->init(this); |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * handle default control transfers on EP 0 |
no test coverage detected