2 * @copyright Copyright (c) 2018-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #include "input_util.h"
18 #include <native_service/ns_message_center_if.h>
21 #include "input_hal.h"
22 #include "input_hal_debug.h"
24 #define INPUT_UTIL_MESSAGE_SEND_RETRY 3
25 #define INPUT_UTIL_MESSAGE_SEND_WAIT 10000 /* RetryWait:10ms */
29 void InputUtilListAdd(struct InputUtilList *node_new, struct InputUtilList *node_head) {
30 node_new->prev = node_head;
31 node_new->next = node_head->next;
32 node_head->next = node_new;
33 node_new->next->prev = node_new;
39 void InputUtilListDelete(struct InputUtilList *node) {
40 node->prev->next = node->next;
41 node->next->prev = node->prev;
47 int InputUtilMCSend(HANDLE h_message, PCSTR source, UI_32 cmd, UI_32 length, PCVOID data) {
49 EFrameworkunifiedStatus e_status; /* return value */
52 e_status = McSend(h_message, source, cmd, length, data);
53 if (eFrameworkunifiedStatusOK == e_status) {
56 InputUtilSleep(INPUT_UTIL_MESSAGE_SEND_WAIT);
57 } while (i++ < INPUT_UTIL_MESSAGE_SEND_RETRY);
59 if (e_status != eFrameworkunifiedStatusOK) {
60 INPUT_ERROR_LOG("ERR: MessageSend=%d \n", e_status);
69 int InputUtilSleep(int usec) {
73 req.tv_nsec = usec * 1000;
74 nanosleep(&req, NULL);
76 return HAL_INPUT_RET_NORMAL;