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 /** */
15 /** USBX Component */
16 /** */
17 /** HID Remote Control Class */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22
23 /* Include necessary system files. */
24
25 #define UX_SOURCE_CODE
26
27 #include "ux_api.h"
28 #include "ux_host_class_hid.h"
29 #include "ux_host_class_hid_remote_control.h"
30 #include "ux_host_stack.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_host_class_hid_remote_control_deactivate PORTABLE C */
38 /* 6.3.0 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function performs the deactivation of a HID Remote Control */
46 /* class instance. */
47 /* */
48 /* INPUT */
49 /* */
50 /* command Pointer to command */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* Completion Status */
55 /* */
56 /* CALLS */
57 /* */
58 /* _ux_host_class_hid_periodic_report_stop Stop periodic report */
59 /* _ux_utility_memory_free Release memory block */
60 /* */
61 /* CALLED BY */
62 /* */
63 /* HID Remote Control Class */
64 /* */
65 /* RELEASE HISTORY */
66 /* */
67 /* DATE NAME DESCRIPTION */
68 /* */
69 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
70 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
71 /* resulting in version 6.1 */
72 /* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
73 /* improved unload sequence, */
74 /* resulting in version 6.3.0 */
75 /* */
76 /**************************************************************************/
_ux_host_class_hid_remote_control_deactivate(UX_HOST_CLASS_HID_CLIENT_COMMAND * command)77 UINT _ux_host_class_hid_remote_control_deactivate(UX_HOST_CLASS_HID_CLIENT_COMMAND *command)
78 {
79
80 UX_HOST_CLASS_HID *hid;
81 UX_HOST_CLASS_HID_CLIENT *hid_client;
82 UX_HOST_CLASS_HID_REMOTE_CONTROL *remote_control_instance;
83 UINT status;
84
85
86 /* Get the instance to the HID class. */
87 hid = command -> ux_host_class_hid_client_command_instance;
88
89 /* Stop the periodic report. */
90 status = _ux_host_class_hid_periodic_report_stop(hid);
91
92 /* Get the HID client pointer. */
93 hid_client = hid -> ux_host_class_hid_client;
94
95 /* Get the remote control local instance. */
96 remote_control_instance = (UX_HOST_CLASS_HID_REMOTE_CONTROL *) hid_client -> ux_host_class_hid_client_local_instance;
97
98 /* If trace is enabled, insert this event into the trace buffer. */
99 UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_HID_REMOTE_CONTROL_DEACTIVATE, hid, remote_control_instance, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
100
101 /* We may need to inform the application
102 if a function has been programmed in the system structure. */
103 if (_ux_system_host -> ux_system_host_change_function != UX_NULL)
104 {
105
106 /* Call system change function. */
107 _ux_system_host -> ux_system_host_change_function(UX_HID_CLIENT_REMOVAL, hid -> ux_host_class_hid_class, (VOID *) hid_client);
108 }
109
110 /* Unload all the memory used by the remote control client. */
111 _ux_utility_memory_free(remote_control_instance -> ux_host_class_hid_remote_control_usage_array);
112
113 /* Now free the instance memory. */
114 _ux_utility_memory_free(hid_client -> ux_host_class_hid_client_local_instance);
115
116 /* Return completion status. */
117 return(status);
118 }
119
120