1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** USBX Component */ 17 /** */ 18 /** Video Class */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 24 /* Include necessary system files. */ 25 26 #define UX_SOURCE_CODE 27 28 #include "ux_api.h" 29 #include "ux_host_class_video.h" 30 #include "ux_host_stack.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _ux_host_class_video_transfer_request PORTABLE C */ 38 /* 6.1.12 */ 39 /* AUTHOR */ 40 /* */ 41 /* Chaoqiong Xiao, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function submits an isochronous video transfer request or */ 46 /* isochronous video transfer request list to the USBX stack. */ 47 /* */ 48 /* Note if the transfer request is not linked (next pointer is NULL), */ 49 /* a single request is submitted. If the transfer request links into a */ 50 /* list, the whole list is submitted. */ 51 /* */ 52 /* INPUT */ 53 /* */ 54 /* video Pointer to video class */ 55 /* video_transfer_request Pointer to transfer request */ 56 /* */ 57 /* OUTPUT */ 58 /* */ 59 /* Completion Status */ 60 /* */ 61 /* CALLS */ 62 /* */ 63 /* _ux_host_stack_transfer_request Process transfer request */ 64 /* */ 65 /* CALLED BY */ 66 /* */ 67 /* Video Class */ 68 /* */ 69 /* RELEASE HISTORY */ 70 /* */ 71 /* DATE NAME DESCRIPTION */ 72 /* */ 73 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 74 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 75 /* resulting in version 6.1 */ 76 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */ 77 /* set pending on endpoint, */ 78 /* resulting in version 6.1.12 */ 79 /* */ 80 /**************************************************************************/ _ux_host_class_video_transfer_request(UX_HOST_CLASS_VIDEO * video,UX_HOST_CLASS_VIDEO_TRANSFER_REQUEST * video_transfer_request)81UINT _ux_host_class_video_transfer_request(UX_HOST_CLASS_VIDEO *video, 82 UX_HOST_CLASS_VIDEO_TRANSFER_REQUEST *video_transfer_request) 83 { 84 85 UINT status; 86 UX_ENDPOINT *endpoint; 87 UX_TRANSFER *transfer_list; 88 UX_TRANSFER *transfer_request; 89 UX_TRANSFER *previous_transfer; 90 91 /* Get transfer request list head. */ 92 transfer_list = &video_transfer_request -> ux_host_class_video_transfer_request; 93 94 /* Get endpoint. */ 95 endpoint = video -> ux_host_class_video_isochronous_endpoint; 96 97 /* Process the transfer request list (if multiple found). */ 98 previous_transfer = UX_NULL; 99 while(video_transfer_request) 100 { 101 102 /* The transfer request is embedded in the application transfer request. */ 103 transfer_request = &video_transfer_request -> ux_host_class_video_transfer_request; 104 105 /* Select the direction. We do this by taking the endpoint direction. */ 106 transfer_request -> ux_transfer_request_type = video -> ux_host_class_video_isochronous_endpoint -> 107 ux_endpoint_descriptor.bEndpointAddress & UX_REQUEST_DIRECTION; 108 109 /* Fill the transfer request with all the required fields. */ 110 transfer_request -> ux_transfer_request_endpoint = endpoint; 111 transfer_request -> ux_transfer_request_data_pointer = video_transfer_request -> ux_host_class_video_transfer_request_data_pointer; 112 transfer_request -> ux_transfer_request_requested_length = video_transfer_request -> ux_host_class_video_transfer_request_requested_length; 113 transfer_request -> ux_transfer_request_completion_function = _ux_host_class_video_transfer_request_completed; 114 transfer_request -> ux_transfer_request_class_instance = video; 115 116 /* We memorize the application transfer request in the local transfer request. */ 117 transfer_request -> ux_transfer_request_user_specific = (VOID *) video_transfer_request; 118 119 /* Confirm transfer is not linking to others */ 120 transfer_request -> ux_transfer_request_next_transfer_request = UX_NULL; 121 122 /* Add it to transfer list tail. */ 123 if (previous_transfer != UX_NULL) 124 previous_transfer -> ux_transfer_request_next_transfer_request = transfer_request; 125 126 /* Save as previous transfer. */ 127 previous_transfer = transfer_request; 128 129 /* Check next transfer request. */ 130 video_transfer_request = video_transfer_request -> ux_host_class_video_transfer_request_next_video_transfer_request; 131 } 132 133 /* Set endpoint status to pending, for callback and abort to check. */ 134 endpoint -> ux_endpoint_transfer_request.ux_transfer_request_completion_code = UX_TRANSFER_STATUS_PENDING; 135 136 /* Transfer the transfer request (list). */ 137 status = _ux_host_stack_transfer_request(transfer_list); 138 139 /* Return completion status. */ 140 return(status); 141 } 142