Lines Matching full:setup

104 	/** Setup packet */
105 struct usb_setup_packet setup; member
143 /* Setup packet definition used to read raw data from USB line */
155 * @brief print the contents of a setup packet
157 * @param [in] setup The setup packet
160 static void usb_print_setup(struct usb_setup_packet *setup) in usb_print_setup() argument
163 ARG_UNUSED(setup); in usb_print_setup()
165 LOG_DBG("Setup: " in usb_print_setup()
167 setup->bmRequestType, in usb_print_setup()
168 setup->bRequest, in usb_print_setup()
169 setup->wValue, in usb_print_setup()
170 setup->wIndex, in usb_print_setup()
171 setup->wLength); in usb_print_setup()
206 * @param [in] setup The setup packet
212 static bool usb_handle_request(struct usb_setup_packet *setup, in usb_handle_request() argument
215 uint32_t type = setup->RequestType.type; in usb_handle_request()
229 if ((*handler)(setup, len, data) < 0) { in usb_handle_request()
231 usb_print_setup(setup); in usb_handle_request()
258 usb_dev.setup.wLength > usb_dev.data_buf_len) { in usb_data_to_host()
259 /* Send less data as requested during the Setup stage */ in usb_data_to_host()
263 usb_dev.setup.wLength, in usb_data_to_host()
285 struct usb_setup_packet *setup = &usb_dev.setup; in usb_handle_control_transfer() local
292 * OUT transfer, Setup packet, in usb_handle_control_transfer()
297 LOG_DBG("Read Setup Packet failed"); in usb_handle_control_transfer()
303 setup->bmRequestType = setup_raw.bmRequestType; in usb_handle_control_transfer()
304 setup->bRequest = setup_raw.bRequest; in usb_handle_control_transfer()
305 setup->wValue = sys_le16_to_cpu(setup_raw.wValue); in usb_handle_control_transfer()
306 setup->wIndex = sys_le16_to_cpu(setup_raw.wIndex); in usb_handle_control_transfer()
307 setup->wLength = sys_le16_to_cpu(setup_raw.wLength); in usb_handle_control_transfer()
319 if (usb_reqtype_is_to_device(setup)) { in usb_handle_control_transfer()
320 if (setup->wLength > CONFIG_USB_REQUEST_BUFFER_SIZE) { in usb_handle_control_transfer()
327 if (setup->wLength) { in usb_handle_control_transfer()
329 usb_dev.data_buf_len = setup->wLength; in usb_handle_control_transfer()
330 usb_dev.data_buf_residue = setup->wLength; in usb_handle_control_transfer()
336 if (!usb_handle_request(setup, in usb_handle_control_transfer()
346 setup->wLength); in usb_handle_control_transfer()
375 if (!usb_handle_request(setup, in usb_handle_control_transfer()
422 static bool usb_get_status(struct usb_setup_packet *setup, in usb_get_status() argument
451 * @param [in] setup The setup packet
457 static bool usb_get_descriptor(struct usb_setup_packet *setup, in usb_get_descriptor() argument
467 type = USB_GET_DESCRIPTOR_TYPE(setup->wValue); in usb_get_descriptor()
468 index = USB_GET_DESCRIPTOR_INDEX(setup->wValue); in usb_get_descriptor()
511 LOG_DBG("Desc %x not found!", setup->wValue); in usb_get_descriptor()
675 * @param [in] setup The setup packet
679 static bool usb_set_configuration(struct usb_setup_packet *setup) in usb_set_configuration() argument
686 LOG_DBG("Set Configuration %u request", setup->wValue); in usb_set_configuration()
688 if (setup->wValue == 0U) { in usb_set_configuration()
690 usb_dev.configuration = setup->wValue; in usb_set_configuration()
705 if (cur_config == setup->wValue) { in usb_set_configuration()
718 if ((cur_config != setup->wValue) || in usb_set_configuration()
736 usb_dev.configuration = setup->wValue; in usb_set_configuration()
742 LOG_DBG("Set Configuration %u failed", setup->wValue); in usb_set_configuration()
751 * @param [in] setup The setup packet
755 static bool usb_set_interface(struct usb_setup_packet *setup) in usb_set_interface() argument
764 LOG_DBG("Set Interface %u alternate %u", setup->wIndex, setup->wValue); in usb_set_interface()
773 if (cur_iface == setup->wIndex && in usb_set_interface()
774 cur_alt_setting == setup->wValue) { in usb_set_interface()
775 ret = usb_set_alt_setting(setup->wIndex, in usb_set_interface()
776 setup->wValue); in usb_set_interface()
784 if (cur_iface == setup->wIndex) { in usb_set_interface()
787 setup->wValue); in usb_set_interface()
805 static bool usb_get_interface(struct usb_setup_packet *setup, in usb_get_interface() argument
815 if (cur_iface == setup->wIndex) { in usb_get_interface()
818 setup->wIndex, data[0]); in usb_get_interface()
844 * @param [in] setup The setup packet
850 static bool usb_handle_std_device_req(struct usb_setup_packet *setup, in usb_handle_std_device_req() argument
855 if (usb_reqtype_is_to_host(setup)) { in usb_handle_std_device_req()
856 switch (setup->bRequest) { in usb_handle_std_device_req()
858 return usb_get_status(setup, len, data_buf); in usb_handle_std_device_req()
861 return usb_get_descriptor(setup, len, data_buf); in usb_handle_std_device_req()
873 switch (setup->bRequest) { in usb_handle_std_device_req()
875 LOG_DBG("Set Address %u request", setup->wValue); in usb_handle_std_device_req()
876 return !usb_dc_set_address(setup->wValue); in usb_handle_std_device_req()
879 return usb_set_configuration(setup); in usb_handle_std_device_req()
885 if (setup->wValue == USB_SFS_REMOTE_WAKEUP) { in usb_handle_std_device_req()
896 if (setup->wValue == USB_SFS_REMOTE_WAKEUP) { in usb_handle_std_device_req()
909 setup->bmRequestType, setup->bRequest); in usb_handle_std_device_req()
945 * @param [in] setup The setup packet
951 static bool usb_handle_std_interface_req(struct usb_setup_packet *setup, in usb_handle_std_interface_req() argument
960 (!is_interface_valid((uint8_t)setup->wIndex))) { in usb_handle_std_interface_req()
964 if (usb_reqtype_is_to_host(setup)) { in usb_handle_std_interface_req()
965 switch (setup->bRequest) { in usb_handle_std_interface_req()
974 return usb_get_interface(setup, len, data_buf); in usb_handle_std_interface_req()
980 if (setup->bRequest == USB_SREQ_SET_INTERFACE) { in usb_handle_std_interface_req()
981 return usb_set_interface(setup); in usb_handle_std_interface_req()
987 setup->bmRequestType, setup->bRequest); in usb_handle_std_interface_req()
1024 static bool usb_get_status_endpoint(struct usb_setup_packet *setup, in usb_get_status_endpoint() argument
1027 uint8_t ep = setup->wIndex; in usb_get_status_endpoint()
1054 static bool usb_halt_endpoint_req(struct usb_setup_packet *setup, bool halt) in usb_halt_endpoint_req() argument
1056 uint8_t ep = setup->wIndex; in usb_halt_endpoint_req()
1094 * @param [in] setup The setup packet
1100 static bool usb_handle_std_endpoint_req(struct usb_setup_packet *setup, in usb_handle_std_endpoint_req() argument
1104 if (usb_reqtype_is_to_host(setup)) { in usb_handle_std_endpoint_req()
1105 if (setup->bRequest == USB_SREQ_GET_STATUS) { in usb_handle_std_endpoint_req()
1106 return usb_get_status_endpoint(setup, len, data_buf); in usb_handle_std_endpoint_req()
1109 switch (setup->bRequest) { in usb_handle_std_endpoint_req()
1111 if (setup->wValue == USB_SFS_ENDPOINT_HALT) { in usb_handle_std_endpoint_req()
1112 return usb_halt_endpoint_req(setup, false); in usb_handle_std_endpoint_req()
1116 if (setup->wValue == USB_SFS_ENDPOINT_HALT) { in usb_handle_std_endpoint_req()
1117 return usb_halt_endpoint_req(setup, true); in usb_handle_std_endpoint_req()
1126 setup->bmRequestType, setup->bRequest); in usb_handle_std_endpoint_req()
1135 * @param [in] setup The setup packet
1141 static int usb_handle_standard_request(struct usb_setup_packet *setup, in usb_handle_standard_request() argument
1146 if (!usb_handle_bos(setup, len, data_buf)) { in usb_handle_standard_request()
1150 if (!usb_handle_os_desc(setup, len, data_buf)) { in usb_handle_standard_request()
1156 !usb_dev.custom_req_handler(setup, len, data_buf)) { in usb_handle_standard_request()
1160 switch (setup->RequestType.recipient) { in usb_handle_standard_request()
1162 if (usb_handle_std_device_req(setup, len, data_buf) == false) { in usb_handle_standard_request()
1167 if (usb_handle_std_interface_req(setup, len, data_buf) == false) { in usb_handle_standard_request()
1172 if (usb_handle_std_endpoint_req(setup, len, data_buf) == false) { in usb_handle_standard_request()