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 Audio 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_audio.h" 28 #include "ux_device_stack.h" 29 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _ux_device_class_audio_deactivate PORTABLE C */ 36 /* 6.1.12 */ 37 /* AUTHOR */ 38 /* */ 39 /* Chaoqiong Xiao, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function deactivate an instance of the audio 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 Audio Class */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 67 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 68 /* resulting in version 6.1 */ 69 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */ 70 /* fixed parameter/variable */ 71 /* names conflict C++ keyword, */ 72 /* resulting in version 6.1.12 */ 73 /* */ 74 /**************************************************************************/ _ux_device_class_audio_deactivate(UX_SLAVE_CLASS_COMMAND * command)75UINT _ux_device_class_audio_deactivate(UX_SLAVE_CLASS_COMMAND *command) 76 { 77 78 UX_DEVICE_CLASS_AUDIO *audio; 79 UX_DEVICE_CLASS_AUDIO_STREAM *stream; 80 UX_SLAVE_ENDPOINT *endpoint; 81 UX_SLAVE_CLASS *class_ptr; 82 UINT i; 83 84 85 /* Get the class container. */ 86 class_ptr = command -> ux_slave_class_command_class_ptr; 87 88 /* Get the class instance in the container. */ 89 audio = (UX_DEVICE_CLASS_AUDIO *) class_ptr -> ux_slave_class_instance; 90 91 /* Stop pending streams. */ 92 stream = audio -> ux_device_class_audio_streams; 93 for (i = 0; i < audio -> ux_device_class_audio_streams_nb; i ++) 94 { 95 96 /* Locate the endpoint. */ 97 endpoint = stream -> ux_device_class_audio_stream_endpoint; 98 99 /* Terminate the transactions pending on the endpoint. */ 100 if (endpoint) 101 _ux_device_stack_transfer_all_request_abort(endpoint, UX_TRANSFER_BUS_RESET); 102 103 /* Free the stream. */ 104 stream -> ux_device_class_audio_stream_endpoint = UX_NULL; 105 stream -> ux_device_class_audio_stream_interface = UX_NULL; 106 107 stream ++; 108 } 109 110 /* Free the control. */ 111 audio -> ux_device_class_audio_interface = UX_NULL; 112 113 /* If there is a deactivate function call it. */ 114 if (audio -> ux_device_class_audio_callbacks.ux_slave_class_audio_instance_deactivate != UX_NULL) 115 116 /* Invoke the application. */ 117 audio -> ux_device_class_audio_callbacks.ux_slave_class_audio_instance_deactivate(audio); 118 119 /* Return completion status. */ 120 return(UX_SUCCESS); 121 } 122