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_feedback_set PORTABLE C */ 37 /* 6.1.10 */ 38 /* AUTHOR */ 39 /* */ 40 /* Chaoqiong Xiao, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function set encoded feedback of the Audio Stream. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* stream Address of audio stream */ 49 /* instance */ 50 /* encoded_feedback Feedback data (3 or 4 bytes) */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* None */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* */ 59 /* CALLED BY */ 60 /* */ 61 /* Application */ 62 /* */ 63 /* RELEASE HISTORY */ 64 /* */ 65 /* DATE NAME DESCRIPTION */ 66 /* */ 67 /* 01-31-2022 Chaoqiong Xiao Initial Version 6.1.10 */ 68 /* */ 69 /**************************************************************************/ _ux_device_class_audio_feedback_set(UX_DEVICE_CLASS_AUDIO_STREAM * stream,UCHAR * encoded_feedback)70UINT _ux_device_class_audio_feedback_set(UX_DEVICE_CLASS_AUDIO_STREAM *stream, 71 UCHAR *encoded_feedback) 72 { 73 #if !defined(UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT) 74 UX_PARAMETER_NOT_USED(stream); 75 UX_PARAMETER_NOT_USED(encoded_feedback); 76 return(UX_FUNCTION_NOT_SUPPORTED); 77 #else 78 79 UX_SLAVE_DEVICE *device; 80 UX_SLAVE_ENDPOINT *endpoint; 81 UX_SLAVE_TRANSFER *transfer; 82 UCHAR *buffer; 83 84 85 /* Get the pointer to the device. */ 86 device = &_ux_system_slave -> ux_system_slave_device; 87 88 /* As long as the device is in the CONFIGURED state. */ 89 if (device -> ux_slave_device_state != UX_DEVICE_CONFIGURED) 90 { 91 92 /* Cannot proceed with command, the interface is down. */ 93 return(UX_CONFIGURATION_HANDLE_UNKNOWN); 94 } 95 96 /* Check if endpoint is available. */ 97 endpoint = stream -> ux_device_class_audio_stream_feedback; 98 if (endpoint == UX_NULL) 99 return(UX_ERROR); 100 101 /* Check if endpoint direction is OK. */ 102 if ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_IN) 103 return(UX_ERROR); 104 105 /* Transfer buffer. */ 106 transfer = &endpoint -> ux_slave_endpoint_transfer_request; 107 buffer = transfer -> ux_slave_transfer_request_data_pointer; 108 109 /* Save data. */ 110 *buffer++ = *encoded_feedback ++; 111 *buffer++ = *encoded_feedback ++; 112 *buffer++ = *encoded_feedback ++; 113 if (_ux_system_slave -> ux_system_slave_speed == UX_HIGH_SPEED_DEVICE) 114 *buffer = *encoded_feedback; 115 return(UX_SUCCESS); 116 #endif 117 } 118 119 /**************************************************************************/ 120 /* */ 121 /* FUNCTION RELEASE */ 122 /* */ 123 /* _uxe_device_class_audio_feedback_set PORTABLE C */ 124 /* 6.2.1 */ 125 /* AUTHOR */ 126 /* */ 127 /* Chaoqiong Xiao, Microsoft Corporation */ 128 /* */ 129 /* DESCRIPTION */ 130 /* */ 131 /* This function checks errors in encoded feedback setting function */ 132 /* call. */ 133 /* */ 134 /* INPUT */ 135 /* */ 136 /* stream Address of audio stream */ 137 /* instance */ 138 /* encoded_feedback Feedback data (3 or 4 bytes) */ 139 /* */ 140 /* OUTPUT */ 141 /* */ 142 /* None */ 143 /* */ 144 /* CALLS */ 145 /* */ 146 /* _ux_device_class_audio_feedback_set Set encoded feedback */ 147 /* */ 148 /* CALLED BY */ 149 /* */ 150 /* Application */ 151 /* */ 152 /* RELEASE HISTORY */ 153 /* */ 154 /* DATE NAME DESCRIPTION */ 155 /* */ 156 /* 03-08-2023 Chaoqiong Xiao Initial Version 6.2.1 */ 157 /* */ 158 /**************************************************************************/ _uxe_device_class_audio_feedback_set(UX_DEVICE_CLASS_AUDIO_STREAM * stream,UCHAR * encoded_feedback)159UINT _uxe_device_class_audio_feedback_set(UX_DEVICE_CLASS_AUDIO_STREAM *stream, 160 UCHAR *encoded_feedback) 161 { 162 163 /* Sanity check on input parameters. */ 164 if (stream == UX_NULL || encoded_feedback == UX_NULL) 165 return(UX_INVALID_PARAMETER); 166 167 /* Get feedback. */ 168 return(_ux_device_class_audio_feedback_set(stream, encoded_feedback)); 169 } 170