4 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include <linux/limits.h>
27 #include <hal/device/hal-touchscreen-interface.h>
28 #include <hal/hal-common-interface.h>
31 #define TOUCHSCREEN_CON_FILE "/sys/devices/platform/rpi_ft5406/enable"
33 #define TURNON_TOUCHSCREEN 1
34 #define TURNOFF_TOUCHSCREEN 0
36 static int touchscreen_get_state(enum touchscreen_state *state)
44 ret = sys_get_int(TOUCHSCREEN_CON_FILE, &val);
46 _E("Failed to get touchscreen state (%d)", ret);
51 case TURNOFF_TOUCHSCREEN:
52 *state = TOUCHSCREEN_OFF;
54 case TURNON_TOUCHSCREEN:
55 *state = TOUCHSCREEN_ON;
58 _E("Failed to get touchscreen state (%d)", val);
65 static int touchscreen_set_state(enum touchscreen_state state)
72 val = TURNOFF_TOUCHSCREEN;
75 val = TURNON_TOUCHSCREEN;
78 _E("Invalid input (%d)", state);
82 ret = sys_set_int(TOUCHSCREEN_CON_FILE, val);
84 _E("Failed to change touchscreen state (%d)", ret);
89 static int touchscreen_init(void **data)
91 hal_backend_touchscreen_funcs *touchscreen_funcs;
93 touchscreen_funcs = calloc(1, sizeof(hal_backend_touchscreen_funcs));
94 if (!touchscreen_funcs)
97 touchscreen_funcs->get_state = touchscreen_get_state;
98 touchscreen_funcs->set_state = touchscreen_set_state;
100 *data = (void *)touchscreen_funcs;
105 static int touchscreen_exit(void *data)
114 hal_backend EXPORT hal_backend_device_touchscreen_data = {
115 .name = "touchscreen",
117 .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
118 .init = touchscreen_init,
119 .exit = touchscreen_exit,