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>
26 #include <hal/device/hal-display-interface.h>
27 #include <hal/hal-common-interface.h>
28 #include <libsyscommon/file.h>
32 #ifndef BACKLIGHT_PATH
33 #define BACKLIGHT_PATH "/sys/class/backlight/emulator"
36 static int display_get_max_brightness(int *val)
45 r = sys_get_int(BACKLIGHT_PATH"/max_brightness", &max);
54 static int display_get_brightness(int *brightness)
59 _E("wrong parameter");
63 r = sys_get_int(BACKLIGHT_PATH"/brightness", &v);
65 _E("fail to get brightness (errno:%d)", r);
73 static int display_set_brightness(int brightness)
77 r = display_get_max_brightness(&max);
79 _E("fail to get max brightness (errno:%d)", r);
83 if (brightness < 0 || brightness > max) {
84 _E("wrong parameter");
88 r = sys_set_int(BACKLIGHT_PATH"/brightness", brightness);
90 _E("fail to set brightness (errno:%d)", r);
97 static int display_init(void **data)
99 hal_backend_display_funcs *display_funcs;
101 display_funcs = calloc(1, sizeof(hal_backend_display_funcs));
105 display_funcs->get_max_brightness = display_get_max_brightness;
106 display_funcs->get_brightness = display_get_brightness;
107 display_funcs->set_brightness = display_set_brightness;
109 *data = (void *)display_funcs;
114 static int display_exit(void *data)
123 hal_backend EXPORT hal_backend_device_display_data = {
126 .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
127 .init = display_init,
128 .exit = display_exit,