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_deactivate PORTABLE C */ 36 /* 6.1.11 */ 37 /* AUTHOR */ 38 /* */ 39 /* Chaoqiong Xiao, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function deactivate an instance of 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_device_stack_transfer_all_request_abort */ 56 /* Abort all transfers */ 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 /* */ 68 /**************************************************************************/ _ux_device_class_video_deactivate(UX_SLAVE_CLASS_COMMAND * command)69UINT _ux_device_class_video_deactivate(UX_SLAVE_CLASS_COMMAND *command) 70 { 71 72 UX_DEVICE_CLASS_VIDEO *video; 73 UX_DEVICE_CLASS_VIDEO_STREAM *stream; 74 UX_SLAVE_ENDPOINT *endpoint; 75 UX_SLAVE_CLASS *class_inst; 76 UINT i; 77 78 79 /* Get the class container. */ 80 class_inst = command -> ux_slave_class_command_class_ptr; 81 82 /* Get the class instance in the container. */ 83 video = (UX_DEVICE_CLASS_VIDEO *) class_inst -> ux_slave_class_instance; 84 85 /* Stop pending streams. */ 86 stream = video -> ux_device_class_video_streams; 87 for (i = 0; i < video -> ux_device_class_video_streams_nb; i ++) 88 { 89 90 /* Locate the endpoint. */ 91 endpoint = stream -> ux_device_class_video_stream_endpoint; 92 93 /* Terminate the transactions pending on the endpoint. */ 94 if (endpoint) 95 _ux_device_stack_transfer_all_request_abort(endpoint, UX_TRANSFER_BUS_RESET); 96 97 /* Free the stream. */ 98 stream -> ux_device_class_video_stream_endpoint = UX_NULL; 99 stream -> ux_device_class_video_stream_interface = UX_NULL; 100 101 stream ++; 102 } 103 104 /* Free the control. */ 105 video -> ux_device_class_video_interface = UX_NULL; 106 107 /* If there is a deactivate function call it. */ 108 if (video -> ux_device_class_video_callbacks.ux_slave_class_video_instance_deactivate != UX_NULL) 109 110 /* Invoke the application. */ 111 video -> ux_device_class_video_callbacks.ux_slave_class_video_instance_deactivate(video); 112 113 /* Return completion status. */ 114 return(UX_SUCCESS); 115 } 116