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 /** USBX Component */ 15 /** */ 16 /** Device Video Class */ 17 /** */ 18 /**************************************************************************/ 19 /**************************************************************************/ 20 21 #define UX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "ux_api.h" 27 #include "ux_device_class_video.h" 28 #include "ux_device_stack.h" 29 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _ux_device_class_video_uninitialize PORTABLE C */ 36 /* 6.3.0 */ 37 /* AUTHOR */ 38 /* */ 39 /* Chaoqiong Xiao, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function uninitialize the Video class. */ 44 /* */ 45 /* INPUT */ 46 /* */ 47 /* command Pointer to a class command */ 48 /* */ 49 /* OUTPUT */ 50 /* */ 51 /* Completion Status */ 52 /* */ 53 /* CALLS */ 54 /* */ 55 /* _ux_utility_thread_delete Delete thread used */ 56 /* _ux_utility_memory_free Free used local memory */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* Device Video Class */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */ 67 /* 10-31-2023 Chaoqiong Xiao Modified comment(s), */ 68 /* added a new mode to manage */ 69 /* endpoint buffer in classes */ 70 /* with zero copy enabled, */ 71 /* resulting in version 6.3.0 */ 72 /* */ 73 /**************************************************************************/ _ux_device_class_video_uninitialize(UX_SLAVE_CLASS_COMMAND * command)74UINT _ux_device_class_video_uninitialize(UX_SLAVE_CLASS_COMMAND *command) 75 { 76 77 UX_DEVICE_CLASS_VIDEO *video; 78 UX_DEVICE_CLASS_VIDEO_STREAM *stream; 79 UX_SLAVE_CLASS *class_inst; 80 ULONG i; 81 82 83 /* Get the class container. */ 84 class_inst = command -> ux_slave_class_command_class_ptr; 85 86 /* Get the class instance in the container. */ 87 video = (UX_DEVICE_CLASS_VIDEO *) class_inst -> ux_slave_class_instance; 88 89 /* Sanity check. */ 90 if (video != UX_NULL) 91 { 92 93 /* Free the stream resources. */ 94 stream = (UX_DEVICE_CLASS_VIDEO_STREAM *)((UCHAR *)video + sizeof(UX_DEVICE_CLASS_VIDEO)); 95 for (i = 0; i < video -> ux_device_class_video_streams_nb; i ++) 96 { 97 #if !defined(UX_DEVICE_STANDALONE) 98 _ux_utility_thread_delete(&stream -> ux_device_class_video_stream_thread); 99 _ux_utility_memory_free(stream -> ux_device_class_video_stream_thread_stack); 100 #endif 101 _ux_utility_memory_free(stream -> ux_device_class_video_stream_buffer); 102 103 /* Next stream instance. */ 104 stream ++; 105 } 106 107 /* Free the video instance with controls and streams. */ 108 _ux_utility_memory_free(video); 109 } 110 111 /* Return completion status. */ 112 return(UX_SUCCESS); 113 } 114