1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** USBX Component */ 16 /** */ 17 /** Video Class */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 23 /* Include necessary system files. */ 24 25 #define UX_SOURCE_CODE 26 27 #include "ux_api.h" 28 #include "ux_host_class_video.h" 29 #include "ux_host_stack.h" 30 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _ux_host_class_video_transfer_request_callback PORTABLE C */ 37 /* 6.1.12 */ 38 /* AUTHOR */ 39 /* */ 40 /* Chaoqiong Xiao, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function receives a completion call back on an isoch transfer */ 45 /* request. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* transfer_request Pointer to transfer request */ 50 /* */ 51 /* OUTPUT */ 52 /* */ 53 /* None */ 54 /* */ 55 /* CALLS */ 56 /* */ 57 /* (ux_host_class_video_transfer_completion_function) */ 58 /* Transfer request completion */ 59 /* */ 60 /* CALLED BY */ 61 /* */ 62 /* Video Class */ 63 /* */ 64 /* RELEASE HISTORY */ 65 /* */ 66 /* DATE NAME DESCRIPTION */ 67 /* */ 68 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 69 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 70 /* resulting in version 6.1 */ 71 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */ 72 /* checked pending state, */ 73 /* resulting in version 6.1.12 */ 74 /* */ 75 /**************************************************************************/ _ux_host_class_video_transfer_request_callback(UX_TRANSFER * transfer_request)76VOID _ux_host_class_video_transfer_request_callback(UX_TRANSFER *transfer_request) 77 { 78 79 UX_HOST_CLASS_VIDEO *video; 80 UX_ENDPOINT *endpoint; 81 ULONG transfer_index; 82 83 84 /* Get the pointer to the video instance. */ 85 video = (UX_HOST_CLASS_VIDEO *) transfer_request -> ux_transfer_request_class_instance; 86 87 /* Do a sanity check on the transfer request, if NULL something is wrong. */ 88 if (video == UX_NULL) 89 return; 90 91 /* Check endpoint status. */ 92 endpoint = video -> ux_host_class_video_isochronous_endpoint; 93 if (endpoint -> ux_endpoint_transfer_request.ux_transfer_request_completion_code != UX_TRANSFER_STATUS_PENDING) 94 return; 95 96 /* The caller's transfer request needs to be updated. */ 97 transfer_index = video -> ux_host_class_video_transfer_request_end_index; 98 transfer_index++; 99 if (transfer_index == UX_HOST_CLASS_VIDEO_TRANSFER_REQUEST_COUNT) 100 transfer_index = 0; 101 102 /* Update the transfer index. */ 103 video -> ux_host_class_video_transfer_request_end_index = transfer_index; 104 105 /* Call the completion routine. */ 106 if (video -> ux_host_class_video_transfer_completion_function) 107 video -> ux_host_class_video_transfer_completion_function(transfer_request); 108 109 /* Return to caller. */ 110 return; 111 } 112