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_ioctl PORTABLE C */
36 /* 6.2.1 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function performs certain functions on the audio instance */
44 /* */
45 /* INPUT */
46 /* */
47 /* audio Address of audio class */
48 /* instance */
49 /* ioctl_function IOCTL function code */
50 /* parameter Parameter for function */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* Status */
55 /* */
56 /* CALLS */
57 /* */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* Application */
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 /* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
71 /* resulting in version 6.2.1 */
72 /* */
73 /**************************************************************************/
_ux_device_class_audio_ioctl(UX_DEVICE_CLASS_AUDIO * audio,ULONG ioctl_function,VOID * parameter)74 UINT _ux_device_class_audio_ioctl(UX_DEVICE_CLASS_AUDIO *audio, ULONG ioctl_function,
75 VOID *parameter)
76 {
77
78 UINT status;
79 VOID **pptr_parameter;
80
81
82 /* Let's be optimist ! */
83 status = UX_SUCCESS;
84
85 /* The command request will tell us what we need to do here. */
86 switch (ioctl_function)
87 {
88
89 case UX_DEVICE_CLASS_AUDIO_IOCTL_GET_ARG:
90
91 /* Properly cast the parameter pointer. */
92 pptr_parameter = (VOID **) parameter;
93
94 /* Save argument. */
95 *pptr_parameter = audio -> ux_device_class_audio_callbacks.ux_device_class_audio_arg;
96
97 break;
98
99 default:
100
101 /* Function not supported. Return an error. */
102 status = UX_FUNCTION_NOT_SUPPORTED;
103 }
104
105 /* Return status to caller. */
106 return(status);
107
108 }
109
110 /**************************************************************************/
111 /* */
112 /* FUNCTION RELEASE */
113 /* */
114 /* _uxe_device_class_audio_ioctl PORTABLE C */
115 /* 6.2.1 */
116 /* AUTHOR */
117 /* */
118 /* Chaoqiong Xiao, Microsoft Corporation */
119 /* */
120 /* DESCRIPTION */
121 /* */
122 /* This function checks errors in ioctl function call. */
123 /* */
124 /* INPUT */
125 /* */
126 /* audio Address of audio class */
127 /* instance */
128 /* ioctl_function IOCTL function code */
129 /* parameter Parameter for function */
130 /* */
131 /* OUTPUT */
132 /* */
133 /* Status */
134 /* */
135 /* CALLS */
136 /* */
137 /* _ux_device_class_audio_ioctl Perform IOCTL function */
138 /* */
139 /* CALLED BY */
140 /* */
141 /* Application */
142 /* */
143 /* RELEASE HISTORY */
144 /* */
145 /* DATE NAME DESCRIPTION */
146 /* */
147 /* 03-08-2023 Chaoqiong Xiao Initial Version 6.2.1 */
148 /* */
149 /**************************************************************************/
_uxe_device_class_audio_ioctl(UX_DEVICE_CLASS_AUDIO * audio,ULONG ioctl_function,VOID * parameter)150 UINT _uxe_device_class_audio_ioctl(UX_DEVICE_CLASS_AUDIO *audio, ULONG ioctl_function,
151 VOID *parameter)
152 {
153
154 /* Sanity check. */
155 if (audio == UX_NULL)
156 return(UX_INVALID_PARAMETER);
157
158 /* Dispatch IOCTL commands. */
159 return(_ux_device_class_audio_ioctl(audio, ioctl_function, parameter));
160 }
161