Lines Matching full:setup

36 static bool reqtype_is_to_host(const struct usb_setup_packet *const setup)  in reqtype_is_to_host()  argument
38 return setup->wLength && USB_REQTYPE_GET_DIR(setup->bmRequestType); in reqtype_is_to_host()
41 static bool reqtype_is_to_device(const struct usb_setup_packet *const setup) in reqtype_is_to_device() argument
43 return !reqtype_is_to_host(setup); in reqtype_is_to_device()
59 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in post_status_stage() local
62 if (setup->bRequest == USB_SREQ_SET_ADDRESS) { in post_status_stage()
63 ret = udc_set_address(uds_ctx->dev, setup->wValue); in post_status_stage()
65 LOG_ERR("Failed to set device address 0x%x", setup->wValue); in post_status_stage()
69 if (setup->bRequest == USB_SREQ_SET_FEATURE && in post_status_stage()
70 setup->wValue == USB_SFS_TEST_MODE) { in post_status_stage()
71 uint8_t mode = SF_TEST_MODE_SELECTOR(setup->wIndex); in post_status_stage()
86 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_set_address() local
90 if (setup->wValue > 127 || setup->wIndex || setup->wLength) { in sreq_set_address()
95 if (setup->RequestType.recipient != USB_REQTYPE_RECIPIENT_DEVICE) { in sreq_set_address()
108 ret = udc_set_address(uds_ctx->dev, setup->wValue); in sreq_set_address()
110 LOG_ERR("Failed to set device address 0x%x", setup->wValue); in sreq_set_address()
117 if (usbd_state_is_address(uds_ctx) && setup->wValue == 0) { in sreq_set_address()
129 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_set_configuration() local
133 LOG_INF("Set Configuration Request value %u", setup->wValue); in sreq_set_configuration()
136 if (setup->wValue > UINT8_MAX || setup->wLength) { in sreq_set_configuration()
141 if (setup->RequestType.recipient != USB_REQTYPE_RECIPIENT_DEVICE) { in sreq_set_configuration()
151 if (setup->wValue && !usbd_config_exist(uds_ctx, speed, setup->wValue)) { in sreq_set_configuration()
156 if (setup->wValue == usbd_get_config_value(uds_ctx)) { in sreq_set_configuration()
157 LOG_DBG("Already in the configuration %u", setup->wValue); in sreq_set_configuration()
161 ret = usbd_config_set(uds_ctx, setup->wValue); in sreq_set_configuration()
164 setup->wValue, ret); in sreq_set_configuration()
168 if (setup->wValue == 0) { in sreq_set_configuration()
176 usbd_msg_pub_simple(uds_ctx, USBD_MSG_CONFIGURATION, setup->wValue); in sreq_set_configuration()
184 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_set_interface() local
187 if (setup->RequestType.recipient != USB_REQTYPE_RECIPIENT_INTERFACE) { in sreq_set_interface()
193 if (setup->wLength) { in sreq_set_interface()
198 if (setup->wValue > UINT8_MAX || setup->wIndex > UINT8_MAX) { in sreq_set_interface()
208 ret = usbd_interface_set(uds_ctx, setup->wIndex, setup->wValue); in sreq_set_interface()
230 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_clear_feature() local
231 uint8_t ep = setup->wIndex; in sreq_clear_feature()
235 if (setup->wLength) { in sreq_clear_feature()
246 if (usbd_state_is_address(uds_ctx) && setup->wIndex) { in sreq_clear_feature()
251 switch (setup->RequestType.recipient) { in sreq_clear_feature()
253 if (setup->wIndex != 0) { in sreq_clear_feature()
258 if (setup->wValue == USB_SFS_REMOTE_WAKEUP) { in sreq_clear_feature()
264 if (setup->wValue == USB_SFS_ENDPOINT_HALT) { in sreq_clear_feature()
285 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in set_feature_test_mode() local
286 uint8_t mode = SF_TEST_MODE_SELECTOR(setup->wIndex); in set_feature_test_mode()
288 if (setup->RequestType.recipient != USB_REQTYPE_RECIPIENT_DEVICE || in set_feature_test_mode()
289 SF_TEST_LOWER_BYTE(setup->wIndex) != 0) { in set_feature_test_mode()
306 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_set_feature() local
307 uint8_t ep = setup->wIndex; in sreq_set_feature()
311 if (setup->wLength) { in sreq_set_feature()
316 if (unlikely(setup->wValue == USB_SFS_TEST_MODE)) { in sreq_set_feature()
329 if (usbd_state_is_address(uds_ctx) && setup->wIndex) { in sreq_set_feature()
334 switch (setup->RequestType.recipient) { in sreq_set_feature()
336 if (setup->wIndex != 0) { in sreq_set_feature()
341 if (setup->wValue == USB_SFS_REMOTE_WAKEUP) { in sreq_set_feature()
347 if (setup->wValue == USB_SFS_ENDPOINT_HALT) { in sreq_set_feature()
369 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in std_request_to_device() local
372 switch (setup->bRequest) { in std_request_to_device()
400 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_get_status() local
401 uint8_t ep = setup->wIndex; in sreq_get_status()
404 if (setup->wLength != sizeof(response)) { in sreq_get_status()
415 if (usbd_state_is_address(uds_ctx) && setup->wIndex) { in sreq_get_status()
420 switch (setup->RequestType.recipient) { in sreq_get_status()
422 if (setup->wIndex != 0) { in sreq_get_status()
442 if (net_buf_tailroom(buf) < setup->wLength) { in sreq_get_status()
462 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_get_desc_cfg() local
523 if (buf->len > setup->wLength) { in sreq_get_desc_cfg()
524 net_buf_remove_mem(buf, buf->len - setup->wLength); in sreq_get_desc_cfg()
612 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_get_desc_dev() local
616 len = MIN(setup->wLength, net_buf_tailroom(buf)); in sreq_get_desc_dev()
638 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_get_desc_str() local
657 len = MIN(setup->wLength, net_buf_tailroom(buf)); in sreq_get_desc_str()
661 string_ascii7_to_utf16le(d_nd, buf, setup->wLength); in sreq_get_desc_str()
670 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_get_dev_qualifier() local
698 len = MIN(setup->wLength, net_buf_tailroom(buf)); in sreq_get_dev_qualifier()
725 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_get_desc_bos() local
749 len = MIN(net_buf_tailroom(buf), MIN(setup->wLength, bos.wTotalLength)); in sreq_get_desc_bos()
752 setup->wLength, bos.bLength, bos.wTotalLength, net_buf_tailroom(buf)); in sreq_get_desc_bos()
780 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_get_descriptor() local
781 uint8_t desc_type = USB_GET_DESCRIPTOR_TYPE(setup->wValue); in sreq_get_descriptor()
782 uint8_t desc_idx = USB_GET_DESCRIPTOR_INDEX(setup->wValue); in sreq_get_descriptor()
787 if (setup->RequestType.recipient != USB_REQTYPE_RECIPIENT_DEVICE) { in sreq_get_descriptor()
824 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_get_configuration() local
833 if (setup->wLength != sizeof(cfg)) { in sreq_get_configuration()
838 if (net_buf_tailroom(buf) < setup->wLength) { in sreq_get_configuration()
851 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in sreq_get_interface() local
856 if (setup->RequestType.recipient != USB_REQTYPE_RECIPIENT_INTERFACE) { in sreq_get_interface()
870 if (setup->wIndex > UINT8_MAX || in sreq_get_interface()
871 setup->wIndex > cfg_desc->bNumInterfaces) { in sreq_get_interface()
876 if (usbd_get_alt_value(uds_ctx, setup->wIndex, &cur_alt)) { in sreq_get_interface()
882 setup->wIndex, cur_alt); in sreq_get_interface()
884 if (setup->wLength != sizeof(cur_alt)) { in sreq_get_interface()
889 if (net_buf_tailroom(buf) < setup->wLength) { in sreq_get_interface()
902 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in std_request_to_host() local
905 switch (setup->bRequest) { in std_request_to_host()
930 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in vendor_device_request() local
933 vreq_nd = usbd_device_get_vreq(uds_ctx, setup->bRequest); in vendor_device_request()
939 if (reqtype_is_to_device(setup) && vreq_nd->to_dev != NULL) { in vendor_device_request()
940 LOG_DBG("Vendor request 0x%02x to device", setup->bRequest); in vendor_device_request()
941 errno = vreq_nd->to_dev(uds_ctx, setup, buf); in vendor_device_request()
945 if (reqtype_is_to_host(setup) && vreq_nd->to_host != NULL) { in vendor_device_request()
946 LOG_DBG("Vendor request 0x%02x to host", setup->bRequest); in vendor_device_request()
947 errno = vreq_nd->to_host(uds_ctx, setup, buf); in vendor_device_request()
958 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in nonstd_request() local
962 switch (setup->RequestType.recipient) { in nonstd_request()
964 c_nd = usbd_class_get_by_ep(uds_ctx, setup->wIndex); in nonstd_request()
967 c_nd = usbd_class_get_by_iface(uds_ctx, setup->wIndex); in nonstd_request()
970 c_nd = usbd_class_get_by_req(uds_ctx, setup->bRequest); in nonstd_request()
977 if (reqtype_is_to_device(setup)) { in nonstd_request()
978 ret = usbd_class_control_to_dev(c_nd->c_data, setup, dbuf); in nonstd_request()
980 ret = usbd_class_control_to_host(c_nd->c_data, setup, dbuf); in nonstd_request()
992 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in handle_setup_request() local
997 switch (setup->RequestType.type) { in handle_setup_request()
999 if (reqtype_is_to_device(setup)) { in handle_setup_request()
1016 LOG_HEXDUMP_INF(setup, sizeof(*setup), "setup:"); in handle_setup_request()
1032 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in ctrl_xfer_get_setup() local
1040 memcpy(setup, buf->data, sizeof(struct usb_setup_packet)); in ctrl_xfer_get_setup()
1042 setup->wValue = sys_le16_to_cpu(setup->wValue); in ctrl_xfer_get_setup()
1043 setup->wIndex = sys_le16_to_cpu(setup->wIndex); in ctrl_xfer_get_setup()
1044 setup->wLength = sys_le16_to_cpu(setup->wLength); in ctrl_xfer_get_setup()
1056 if (reqtype_is_to_device(setup)) { in ctrl_xfer_get_setup()
1057 if (setup->wLength) { in ctrl_xfer_get_setup()
1069 if (!setup->wLength) { in ctrl_xfer_get_setup()
1106 struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); in usbd_handle_ctrl_xfer() local
1116 if (err && err != -ENOMEM && !bi->setup) { in usbd_handle_ctrl_xfer()
1130 buf, bi->ep, buf->len, bi->setup, bi->data, bi->status); in usbd_handle_ctrl_xfer()
1132 if (bi->setup && bi->ep == USB_CONTROL_EP_OUT) { in usbd_handle_ctrl_xfer()
1136 LOG_ERR("Malformed setup packet"); in usbd_handle_ctrl_xfer()
1141 /* Remove setup packet buffer from the chain */ in usbd_handle_ctrl_xfer()
1168 if (reqtype_is_to_device(setup) && setup->wLength) { in usbd_handle_ctrl_xfer()
1220 if (reqtype_is_to_host(setup)) { in usbd_handle_ctrl_xfer()
1222 } else if (setup->wLength) { in usbd_handle_ctrl_xfer()