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 /** USBX Component */ 16 /** */ 17 /** Device Audio Class */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 #define UX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "ux_api.h" 28 #include "ux_device_class_audio.h" 29 #include "ux_device_stack.h" 30 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _ux_device_class_audio_deactivate PORTABLE C */ 37 /* 6.1.12 */ 38 /* AUTHOR */ 39 /* */ 40 /* Chaoqiong Xiao, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function deactivate an instance of the audio class. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* command Pointer to a class command */ 49 /* */ 50 /* OUTPUT */ 51 /* */ 52 /* Completion Status */ 53 /* */ 54 /* CALLS */ 55 /* */ 56 /* _ux_device_stack_transfer_all_request_abort */ 57 /* Abort all transfers */ 58 /* */ 59 /* CALLED BY */ 60 /* */ 61 /* Device Audio Class */ 62 /* */ 63 /* RELEASE HISTORY */ 64 /* */ 65 /* DATE NAME DESCRIPTION */ 66 /* */ 67 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 68 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 69 /* resulting in version 6.1 */ 70 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */ 71 /* fixed parameter/variable */ 72 /* names conflict C++ keyword, */ 73 /* resulting in version 6.1.12 */ 74 /* */ 75 /**************************************************************************/ _ux_device_class_audio_deactivate(UX_SLAVE_CLASS_COMMAND * command)76UINT _ux_device_class_audio_deactivate(UX_SLAVE_CLASS_COMMAND *command) 77 { 78 79 UX_DEVICE_CLASS_AUDIO *audio; 80 UX_DEVICE_CLASS_AUDIO_STREAM *stream; 81 UX_SLAVE_ENDPOINT *endpoint; 82 UX_SLAVE_CLASS *class_ptr; 83 UINT i; 84 85 86 /* Get the class container. */ 87 class_ptr = command -> ux_slave_class_command_class_ptr; 88 89 /* Get the class instance in the container. */ 90 audio = (UX_DEVICE_CLASS_AUDIO *) class_ptr -> ux_slave_class_instance; 91 92 /* Stop pending streams. */ 93 stream = audio -> ux_device_class_audio_streams; 94 for (i = 0; i < audio -> ux_device_class_audio_streams_nb; i ++) 95 { 96 97 /* Locate the endpoint. */ 98 endpoint = stream -> ux_device_class_audio_stream_endpoint; 99 100 /* Terminate the transactions pending on the endpoint. */ 101 if (endpoint) 102 _ux_device_stack_transfer_all_request_abort(endpoint, UX_TRANSFER_BUS_RESET); 103 104 /* Free the stream. */ 105 stream -> ux_device_class_audio_stream_endpoint = UX_NULL; 106 stream -> ux_device_class_audio_stream_interface = UX_NULL; 107 108 stream ++; 109 } 110 111 /* Free the control. */ 112 audio -> ux_device_class_audio_interface = UX_NULL; 113 114 /* If there is a deactivate function call it. */ 115 if (audio -> ux_device_class_audio_callbacks.ux_slave_class_audio_instance_deactivate != UX_NULL) 116 117 /* Invoke the application. */ 118 audio -> ux_device_class_audio_callbacks.ux_slave_class_audio_instance_deactivate(audio); 119 120 /* Return completion status. */ 121 return(UX_SUCCESS); 122 } 123