summaryrefslogtreecommitdiffstats
path: root/input_hal/src/input_touch_ilitek.cpp
blob: 9d1822a7848efe676f23e5205ba993686641d8cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/*
 * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "input_touch_ilitek.h"

#include <unistd.h>
#include <stdio.h>
#include <string.h>

#include "input_hal.h"

// Touch panel device name
#define HAL_INPUT_ILITEK_TOUCH_DEVICE_NAME "ILITEK ILITEK Multi-Touch"
// Touch panel key device name
#define HAL_INPUT_ILITEK_KEY_DEVICE_NAME ""

// Touch panel horizontal resolution value
#define HAL_INPUT_TOUCH_RESOLUTION_HORIZONTAL   4816

// Touch panel vertical resolution value
#define HAL_INPUT_TOUCH_RESOLUTION_VERTICAL     2992

/*
 * Make touch panel start work
 */
static int InputTouchStart() {
  return HAL_INPUT_RET_NORMAL;
}

/*
 * Config touch panel
 */
static int InputTouchConfig(const char *path,
                            int resolution_h, int resolution_v) {
  if (NULL == path) {
    return HAL_INPUT_RET_ERROR;
  }

  if (-1 == ::access(path, F_OK)) {
    return HAL_INPUT_RET_ERROR;
  }
  return HAL_INPUT_RET_NORMAL;
}

/*
 * Get touch panel device name
 */
static int InputTouchGetDeviceName(char* name, size_t buf_length) {
  if (NULL == name) {
    return HAL_INPUT_RET_ERROR;
  }

  if (buf_length < (strlen(HAL_INPUT_ILITEK_TOUCH_DEVICE_NAME) + 1)) {
    return HAL_INPUT_RET_ERROR;
  }

  snprintf(name, buf_length, "%s", HAL_INPUT_ILITEK_TOUCH_DEVICE_NAME);
  return HAL_INPUT_RET_NORMAL;
}

/*
 * Get touch panel key device name
 */
static int InputTouchGetKeyName(char* name, size_t buf_length) {
  if (NULL == name) {
    return HAL_INPUT_RET_ERROR;
  }

  if (buf_length < (strlen(HAL_INPUT_ILITEK_KEY_DEVICE_NAME) + 1)) {
    return HAL_INPUT_RET_ERROR;
  }

  snprintf(name, buf_length, "%s", HAL_INPUT_ILITEK_KEY_DEVICE_NAME);
  return HAL_INPUT_RET_NORMAL;
}

/*
 * Get touch panel device horizontal resolution
 */
static int InputTouchGetDeviceHResolution(int *resolution) {
  if (NULL == resolution) {
    return HAL_INPUT_RET_ERROR;
  }
  *resolution = HAL_INPUT_TOUCH_RESOLUTION_HORIZONTAL;
  return HAL_INPUT_RET_NORMAL;
}

/*
 * Get touch panel device vertical resolution
 */
static int InputTouchGetDeviceVResolution(int *resolution) {
  if (NULL == resolution) {
    return HAL_INPUT_RET_ERROR;
  }
  *resolution = HAL_INPUT_TOUCH_RESOLUTION_VERTICAL;
  return HAL_INPUT_RET_NORMAL;
}

/*
 * Get whether X axis is inversion
 */
static int InputTouchGetXAxisReverse(bool* is_reverse) {
  if (NULL == is_reverse) {
    return HAL_INPUT_RET_ERROR;
  }
  *is_reverse = false;
  return HAL_INPUT_RET_NORMAL;
}

/*
 * Get whether Y axis is inversion
 */
static int InputTouchGetYAxisReverse(bool* is_reverse) {
  if (NULL == is_reverse) {
    return HAL_INPUT_RET_ERROR;
  }
  *is_reverse = false;
  return HAL_INPUT_RET_NORMAL;
}

/*
 * Execute touch panel self test
 */
static int InputTouchSelftest(int id, void *result) {
  if (NULL == result) {
    return HAL_INPUT_RET_ERROR;
  }
  return HAL_INPUT_RET_NOT_SUPPORT;
}

/*
 * Get touch panel config status
 */
static int InputTouchGetConfigStatus(int *status) {
  if (NULL == status) {
    return HAL_INPUT_RET_ERROR;
  }
  *status = HAL_INPUT_TOUCH_CONFIG_OFF;
  return HAL_INPUT_RET_NORMAL;
}

/*
 * Set whether the driver sends touch panel data or not
 */
static int InputTouchSetTouchLock(int lock) {
  if ((HAL_INPUT_TOUCH_UNREPORT == lock) ||
    (HAL_INPUT_TOUCH_REPORT == lock)) {
    return HAL_INPUT_RET_NOT_SUPPORT;
  }
  return HAL_INPUT_RET_ERROR;
}

/*
 * Suspend touch panel
 */
static int InputTouchSetTouchSuspend() {
  return HAL_INPUT_RET_NOT_SUPPORT;
}

/*
 * Set touch panel sensitivity level
 */
static int InputTouchSetSensitivityLevel(int level) {
  if ((HAL_INPUT_TOUCH_SENSITIVITY_LEVEL_LOW == level) ||
    (HAL_INPUT_TOUCH_SENSITIVITY_LEVEL_MIDDLE == level) ||
    (HAL_INPUT_TOUCH_SENSITIVITY_LEVEL_HIGH == level) ||
    (HAL_INPUT_TOUCH_SENSITIVITY_LEVEL_NONE == level) ) {
    return HAL_INPUT_RET_NOT_SUPPORT;
  }
  return HAL_INPUT_RET_ERROR;
}

/*
 * Get touch panel sensitivity level
 */
static int InputTouchGetSensitivityLevel(int *level) {
  if (NULL == level) {
    return HAL_INPUT_RET_ERROR;
  }

  return HAL_INPUT_RET_NOT_SUPPORT;
}

/*
 * Notify radio scan frequency
 */
static int InputTouchNotifyRadioScanFrequency(struct RadioInfoTouch *info) {
  if (NULL == info) {
    return HAL_INPUT_RET_ERROR;
  }
  return HAL_INPUT_RET_NOT_SUPPORT;
}

/*
 * Init touch panel operation function
 */
int InputTouchIlitekInit(struct TouchHal *touch) {
  touch->start = InputTouchStart;
  touch->config = InputTouchConfig;
  touch->get_touch_devicename = InputTouchGetDeviceName;
  touch->get_key_devicename = InputTouchGetKeyName;
  touch->get_reso_h = InputTouchGetDeviceHResolution;
  touch->get_reso_v = InputTouchGetDeviceVResolution;
  touch->get_reverse_axis_x = InputTouchGetXAxisReverse;
  touch->get_reverse_axis_y = InputTouchGetYAxisReverse;
  touch->selftest = InputTouchSelftest;
  touch->get_config_status = InputTouchGetConfigStatus;
  touch->set_touch_lock = InputTouchSetTouchLock;
  touch->set_touch_suspend = InputTouchSetTouchSuspend;
  touch->set_sensitivity_level = InputTouchSetSensitivityLevel;
  touch->get_sensitivity_level = InputTouchGetSensitivityLevel;
  touch->notify_radio_scan_frequency = InputTouchNotifyRadioScanFrequency;
  return HAL_INPUT_RET_NORMAL;
}