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 /** Video 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_video.h"
30 #include "ux_host_stack.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_host_class_video_entry PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function is the entry point of the Video class. It will be */
46 /* called by the USBX stack enumeration module when there is a new */
47 /* video device (speaker, microphone ...) on the bus or when the video */
48 /* device is removed. */
49 /* */
50 /* INPUT */
51 /* */
52 /* command Pointer to command */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* Completion Status */
57 /* */
58 /* CALLS */
59 /* */
60 /* _ux_host_class_video_activate Activate video class */
61 /* _ux_host_class_video_deactivate Deactivate video class */
62 /* _ux_system_error_handler Log system error */
63 /* */
64 /* CALLED BY */
65 /* */
66 /* Host Stack */
67 /* */
68 /* RELEASE HISTORY */
69 /* */
70 /* DATE NAME DESCRIPTION */
71 /* */
72 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
73 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
74 /* resulting in version 6.1 */
75 /* */
76 /**************************************************************************/
_ux_host_class_video_entry(UX_HOST_CLASS_COMMAND * command)77 UINT _ux_host_class_video_entry(UX_HOST_CLASS_COMMAND *command)
78 {
79
80 UINT status = UX_SUCCESS;
81
82
83 /* The command request will tell us we need to do here, either a enumeration
84 query, an activation or a deactivation. */
85 switch (command -> ux_host_class_command_request)
86 {
87
88
89 case UX_HOST_CLASS_COMMAND_QUERY:
90
91 /* The query command is used to let the stack enumeration process know if we want to own
92 this device or not. */
93 if ((command -> ux_host_class_command_usage == UX_HOST_CLASS_COMMAND_USAGE_CSP) &&
94 (command -> ux_host_class_command_class == UX_HOST_CLASS_VIDEO_CLASS))
95 status = UX_SUCCESS;
96 else
97 status = UX_NO_CLASS_MATCH;
98 break;
99
100 case UX_HOST_CLASS_COMMAND_ACTIVATE:
101
102 /* The activate command is used when the device inserted has found a parent and
103 is ready to complete the enumeration. */
104 status = _ux_host_class_video_activate(command);
105
106 break;
107
108
109 case UX_HOST_CLASS_COMMAND_DEACTIVATE:
110
111 /* The deactivate command is used when the device has been extracted either
112 directly or when its parents has been extracted. */
113 status = _ux_host_class_video_deactivate(command);
114
115 break;
116
117
118 default:
119
120 /* Error trap. */
121 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_FUNCTION_NOT_SUPPORTED);
122
123 /* If trace is enabled, insert this event into the trace buffer. */
124 //UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_FUNCTION_NOT_SUPPORTED, 0, 0, 0, UX_TRACE_ERRORS, 0, 0)
125
126 status = UX_FUNCTION_NOT_SUPPORTED;
127 }
128
129 return(status);
130 }
131
132