Lines Matching full:setup

105 	/** Setup packet */
106 struct usb_setup_packet setup; member
144 /* Setup packet definition used to read raw data from USB line */
156 * @brief print the contents of a setup packet
158 * @param [in] setup The setup packet
161 static void usb_print_setup(struct usb_setup_packet *setup) in usb_print_setup() argument
164 ARG_UNUSED(setup); in usb_print_setup()
166 LOG_DBG("Setup: " in usb_print_setup()
168 setup->bmRequestType, in usb_print_setup()
169 setup->bRequest, in usb_print_setup()
170 setup->wValue, in usb_print_setup()
171 setup->wIndex, in usb_print_setup()
172 setup->wLength); in usb_print_setup()
207 * @param [in] setup The setup packet
213 static bool usb_handle_request(struct usb_setup_packet *setup, in usb_handle_request() argument
216 uint32_t type = setup->RequestType.type; in usb_handle_request()
230 if ((*handler)(setup, len, data) < 0) { in usb_handle_request()
232 usb_print_setup(setup); in usb_handle_request()
259 usb_dev.setup.wLength > usb_dev.data_buf_len) { in usb_data_to_host()
260 /* Send less data as requested during the Setup stage */ in usb_data_to_host()
264 usb_dev.setup.wLength, in usb_data_to_host()
286 struct usb_setup_packet *setup = &usb_dev.setup; in usb_handle_control_transfer() local
293 * OUT transfer, Setup packet, in usb_handle_control_transfer()
298 LOG_DBG("Read Setup Packet failed"); in usb_handle_control_transfer()
304 setup->bmRequestType = setup_raw.bmRequestType; in usb_handle_control_transfer()
305 setup->bRequest = setup_raw.bRequest; in usb_handle_control_transfer()
306 setup->wValue = sys_le16_to_cpu(setup_raw.wValue); in usb_handle_control_transfer()
307 setup->wIndex = sys_le16_to_cpu(setup_raw.wIndex); in usb_handle_control_transfer()
308 setup->wLength = sys_le16_to_cpu(setup_raw.wLength); in usb_handle_control_transfer()
320 if (usb_reqtype_is_to_device(setup)) { in usb_handle_control_transfer()
321 if (setup->wLength > CONFIG_USB_REQUEST_BUFFER_SIZE) { in usb_handle_control_transfer()
328 if (setup->wLength) { in usb_handle_control_transfer()
330 usb_dev.data_buf_len = setup->wLength; in usb_handle_control_transfer()
331 usb_dev.data_buf_residue = setup->wLength; in usb_handle_control_transfer()
337 if (!usb_handle_request(setup, in usb_handle_control_transfer()
347 setup->wLength); in usb_handle_control_transfer()
376 if (!usb_handle_request(setup, in usb_handle_control_transfer()
423 static bool usb_get_status(struct usb_setup_packet *setup, in usb_get_status() argument
452 * @param [in] setup The setup packet
458 static bool usb_get_descriptor(struct usb_setup_packet *setup, in usb_get_descriptor() argument
468 type = USB_GET_DESCRIPTOR_TYPE(setup->wValue); in usb_get_descriptor()
469 index = USB_GET_DESCRIPTOR_INDEX(setup->wValue); in usb_get_descriptor()
512 LOG_DBG("Desc %x not found!", setup->wValue); in usb_get_descriptor()
676 * @param [in] setup The setup packet
680 static bool usb_set_configuration(struct usb_setup_packet *setup) in usb_set_configuration() argument
687 LOG_DBG("Set Configuration %u request", setup->wValue); in usb_set_configuration()
689 if (setup->wValue == 0U) { in usb_set_configuration()
691 usb_dev.configuration = setup->wValue; in usb_set_configuration()
706 if (cur_config == setup->wValue) { in usb_set_configuration()
719 if ((cur_config != setup->wValue) || in usb_set_configuration()
737 usb_dev.configuration = setup->wValue; in usb_set_configuration()
743 LOG_DBG("Set Configuration %u failed", setup->wValue); in usb_set_configuration()
752 * @param [in] setup The setup packet
756 static bool usb_set_interface(struct usb_setup_packet *setup) in usb_set_interface() argument
765 LOG_DBG("Set Interface %u alternate %u", setup->wIndex, setup->wValue); in usb_set_interface()
774 if (cur_iface == setup->wIndex && in usb_set_interface()
775 cur_alt_setting == setup->wValue) { in usb_set_interface()
776 ret = usb_set_alt_setting(setup->wIndex, in usb_set_interface()
777 setup->wValue); in usb_set_interface()
785 if (cur_iface == setup->wIndex) { in usb_set_interface()
788 setup->wValue); in usb_set_interface()
806 static bool usb_get_interface(struct usb_setup_packet *setup, in usb_get_interface() argument
816 if (cur_iface == setup->wIndex) { in usb_get_interface()
819 setup->wIndex, data[0]); in usb_get_interface()
845 * @param [in] setup The setup packet
851 static bool usb_handle_std_device_req(struct usb_setup_packet *setup, in usb_handle_std_device_req() argument
856 if (usb_reqtype_is_to_host(setup)) { in usb_handle_std_device_req()
857 switch (setup->bRequest) { in usb_handle_std_device_req()
859 return usb_get_status(setup, len, data_buf); in usb_handle_std_device_req()
862 return usb_get_descriptor(setup, len, data_buf); in usb_handle_std_device_req()
874 switch (setup->bRequest) { in usb_handle_std_device_req()
876 LOG_DBG("Set Address %u request", setup->wValue); in usb_handle_std_device_req()
877 return !usb_dc_set_address(setup->wValue); in usb_handle_std_device_req()
880 return usb_set_configuration(setup); in usb_handle_std_device_req()
886 if (setup->wValue == USB_SFS_REMOTE_WAKEUP) { in usb_handle_std_device_req()
897 if (setup->wValue == USB_SFS_REMOTE_WAKEUP) { in usb_handle_std_device_req()
910 setup->bmRequestType, setup->bRequest); in usb_handle_std_device_req()
946 * @param [in] setup The setup packet
952 static bool usb_handle_std_interface_req(struct usb_setup_packet *setup, in usb_handle_std_interface_req() argument
961 (!is_interface_valid((uint8_t)setup->wIndex))) { in usb_handle_std_interface_req()
965 if (usb_reqtype_is_to_host(setup)) { in usb_handle_std_interface_req()
966 switch (setup->bRequest) { in usb_handle_std_interface_req()
975 return usb_get_interface(setup, len, data_buf); in usb_handle_std_interface_req()
981 if (setup->bRequest == USB_SREQ_SET_INTERFACE) { in usb_handle_std_interface_req()
982 return usb_set_interface(setup); in usb_handle_std_interface_req()
988 setup->bmRequestType, setup->bRequest); in usb_handle_std_interface_req()
1025 static bool usb_get_status_endpoint(struct usb_setup_packet *setup, in usb_get_status_endpoint() argument
1028 uint8_t ep = setup->wIndex; in usb_get_status_endpoint()
1055 static bool usb_halt_endpoint_req(struct usb_setup_packet *setup, bool halt) in usb_halt_endpoint_req() argument
1057 uint8_t ep = setup->wIndex; in usb_halt_endpoint_req()
1095 * @param [in] setup The setup packet
1101 static bool usb_handle_std_endpoint_req(struct usb_setup_packet *setup, in usb_handle_std_endpoint_req() argument
1105 if (usb_reqtype_is_to_host(setup)) { in usb_handle_std_endpoint_req()
1106 if (setup->bRequest == USB_SREQ_GET_STATUS) { in usb_handle_std_endpoint_req()
1107 return usb_get_status_endpoint(setup, len, data_buf); in usb_handle_std_endpoint_req()
1110 switch (setup->bRequest) { in usb_handle_std_endpoint_req()
1112 if (setup->wValue == USB_SFS_ENDPOINT_HALT) { in usb_handle_std_endpoint_req()
1113 return usb_halt_endpoint_req(setup, false); in usb_handle_std_endpoint_req()
1117 if (setup->wValue == USB_SFS_ENDPOINT_HALT) { in usb_handle_std_endpoint_req()
1118 return usb_halt_endpoint_req(setup, true); in usb_handle_std_endpoint_req()
1127 setup->bmRequestType, setup->bRequest); in usb_handle_std_endpoint_req()
1136 * @param [in] setup The setup packet
1142 static int usb_handle_standard_request(struct usb_setup_packet *setup, in usb_handle_standard_request() argument
1147 if (!usb_handle_bos(setup, len, data_buf)) { in usb_handle_standard_request()
1151 if (!usb_handle_os_desc(setup, len, data_buf)) { in usb_handle_standard_request()
1157 !usb_dev.custom_req_handler(setup, len, data_buf)) { in usb_handle_standard_request()
1161 switch (setup->RequestType.recipient) { in usb_handle_standard_request()
1163 if (usb_handle_std_device_req(setup, len, data_buf) == false) { in usb_handle_standard_request()
1168 if (usb_handle_std_interface_req(setup, len, data_buf) == false) { in usb_handle_standard_request()
1173 if (usb_handle_std_endpoint_req(setup, len, data_buf) == false) { in usb_handle_standard_request()