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 /**                                                                       */
16 /** USBX Component                                                        */
17 /**                                                                       */
18 /**   Audio Class                                                         */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /* Include necessary system files.  */
25 
26 #define UX_SOURCE_CODE
27 
28 #include "ux_api.h"
29 #include "ux_host_class_audio.h"
30 #include "ux_host_stack.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _ux_host_class_audio_feedback_get                   PORTABLE C      */
38 /*                                                           6.1.12       */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Chaoqiong Xiao, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function copies packed feedback data to given buffer.          */
46 /*    Note high speed data size is 4 and full speed data size is 3 bytes. */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    audio                                 Pointer to audio class        */
51 /*    feedback                              Pointer to buffer to fill     */
52 /*                                          packed feedback data          */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    Completion Status                                                   */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application                                                         */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  07-29-2022     Chaoqiong Xiao           Initial Version 6.1.12        */
70 /*                                                                        */
71 /**************************************************************************/
_ux_host_class_audio_feedback_get(UX_HOST_CLASS_AUDIO * audio,UCHAR * feedback)72 UINT  _ux_host_class_audio_feedback_get(UX_HOST_CLASS_AUDIO *audio, UCHAR *feedback)
73 {
74 #if !defined(UX_HOST_CLASS_AUDIO_FEEDBACK_SUPPORT)
75     UX_PARAMETER_NOT_USED(audio);
76     UX_PARAMETER_NOT_USED(feedback);
77     return(UX_FUNCTION_NOT_SUPPORTED);
78 #else
79 
80     /* Ensure the instance is valid.  */
81     if (_ux_host_stack_class_instance_verify(_ux_system_host_class_audio_name, (VOID *) audio) != UX_SUCCESS)
82     {
83 
84         /* Error trap. */
85         _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN);
86 
87         /* If trace is enabled, insert this event into the trace buffer.  */
88         UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, audio, 0, 0, UX_TRACE_ERRORS, 0, 0)
89 
90         return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
91     }
92 
93     feedback[0] = audio -> ux_host_class_audio_feedback_buffer[0];
94     feedback[1] = audio -> ux_host_class_audio_feedback_buffer[1];
95     feedback[2] = audio -> ux_host_class_audio_feedback_buffer[2];
96     if (_ux_host_class_audio_speed_get(audio) == UX_HIGH_SPEED_DEVICE)
97         feedback[3] = audio -> ux_host_class_audio_feedback_buffer[3];
98     return(UX_SUCCESS);
99 #endif
100 }
101