diff options
author | lokilee73 <changjoo.lee@samsung.com> | 2019-02-26 17:59:01 +0900 |
---|---|---|
committer | Hyotaek Shim <hyotaek.shim@samsung.com> | 2019-02-27 01:12:23 +0000 |
commit | 78129922508e82a8304ef5b1add270e2ff93fb67 (patch) | |
tree | 0fac4af0ce1e644ed70e9e341c84f7361bdcc4c6 /plugins/wearable | |
parent | 3a43964853aaf1d58778195004e19d435c1fc99b (diff) | |
download | deviced-78129922508e82a8304ef5b1add270e2ff93fb67.tar.gz deviced-78129922508e82a8304ef5b1add270e2ff93fb67.tar.bz2 deviced-78129922508e82a8304ef5b1add270e2ff93fb67.zip |
Add bezel for wearable target
Change-Id: Iee31a5a0d8b37feb8cd162caadd8ee73fc931968
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
Diffstat (limited to 'plugins/wearable')
-rw-r--r-- | plugins/wearable/display/bezel.c | 130 | ||||
-rwxr-xr-x | plugins/wearable/display/core.c | 4 | ||||
-rw-r--r-- | plugins/wearable/display/key-filter.c | 48 |
3 files changed, 175 insertions, 7 deletions
diff --git a/plugins/wearable/display/bezel.c b/plugins/wearable/display/bezel.c new file mode 100644 index 00000000..d5b00053 --- /dev/null +++ b/plugins/wearable/display/bezel.c @@ -0,0 +1,130 @@ +/* + * deviced + * + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 "core/devices.h" +#include "core/common.h" +#include "core/device-notifier.h" +#include "display/util.h" +#include "display/poll.h" +#include "display-ops.h" +#include <hw/bezel.h> +#include <assert.h> +#include <vconf.h> + +#ifndef VCONFKEY_SETAPPL_WAKEUP_BY_BEZEL_ENABLE +#define VCONFKEY_SETAPPL_WAKEUP_BY_BEZEL_ENABLE "db/setting/wakeup_by_bezel_enable" +#endif + +static struct bezel_device *bezel_dev; +static int bezel_wakeup = -1; + +static void bezel_changed_cb(keynode_t *key_nodes, void *data) +{ + assert(key_nodes); + + bezel_wakeup = vconf_keynode_get_bool(key_nodes); + + _I("bezel wakeup condition is %d", bezel_wakeup); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); + + device_notify(DEVICE_NOTIFIER_BEZEL_WAKEUP, (void *)bezel_wakeup); +} + +static void bezel_init(void *data) +{ + struct hw_info *info; + int r; + + if (bezel_dev) + return; + + r = hw_get_info(BEZEL_HARDWARE_DEVICE_ID, (const struct hw_info **)&info); + if (r < 0) { + _I("bezel shared library is not supported: %d", r); + return; + } + + if (!info->open) { + _E("Fail to open bezel device : open(NULL)"); + return; + } + + r = info->open(info, NULL, (struct hw_common **)&bezel_dev); + if (r < 0) { + _E("Fail to get bezel device structure: %d", r); + return; + } + + vconf_notify_key_changed(VCONFKEY_SETAPPL_WAKEUP_BY_BEZEL_ENABLE, + bezel_changed_cb, NULL); + + if (vconf_get_bool(VCONFKEY_SETAPPL_WAKEUP_BY_BEZEL_ENABLE, &bezel_wakeup) < 0) + bezel_wakeup = 1; + + _I("bezel wakeup condition is %d", bezel_wakeup); +} + +static void bezel_exit(void *data) +{ + struct hw_info *info; + + if (!bezel_dev) + return; + + info = bezel_dev->common.info; + + assert(info); + + info->close((struct hw_common *)bezel_dev); +} + +static int bezel_start(enum device_flags flags) +{ + if (!bezel_dev) + return 0; + + return bezel_dev->set_state(BEZEL_TURNON); +} + +static int bezel_stop(enum device_flags flags) +{ + enum bezel_state state; + + if (!bezel_dev) + return 0; + + state = (bezel_wakeup ? BEZEL_TURNON : BEZEL_TURNOFF); + _I("set bezel state: %d", state); + + return bezel_dev->set_state(state); +} + +/* + * 'bezel' device_ops should be initialize before init key-filter. + */ +static const struct device_ops bezel_device_ops = { + .priority = DEVICE_PRIORITY_HIGH, + .name = "bezel", + .init = bezel_init, + .exit = bezel_exit, + .start = bezel_start, + .stop = bezel_stop, +}; + +DEVICE_OPS_REGISTER(&bezel_device_ops) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 05505ef7..11fab78c 100755 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1903,6 +1903,10 @@ static void init_lcd_operation(void) ops = find_device("touchscreen"); if (!check_default(ops)) DD_LIST_APPEND(lcdon_ops, ops); + + ops = find_device("bezel"); + if (!check_default(ops)) + DD_LIST_APPEND(lcdon_ops, ops); } static void exit_lcd_operation(void) diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index ce14ce2d..02d8a48c 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -90,8 +90,16 @@ static double combination_pressed_time; static bool touch_pressed = false; static int skip_lcd_off = false; static int skip_combination = false; +static int bezel_wakeup = true; static const struct device_ops *touchled; +static int bezel_wakeup_cb(void *data) +{ + bezel_wakeup = (int)data; + + return 0; +} + static int booting_done(void *data) { static int done = 0; @@ -199,7 +207,7 @@ static inline void broadcast_lcdoff_by_powerkey(void) NULL, NULL); } -static inline bool switch_on_lcd(void) +static inline bool switch_on_lcd(enum device_flags flags) { if (current_state_in_on()) return false; @@ -211,7 +219,7 @@ static inline bool switch_on_lcd(void) broadcast_lcdon_by_powerkey(); - lcd_on_direct(LCD_ON_BY_POWER_KEY); + lcd_on_direct(flags); return true; } @@ -305,7 +313,7 @@ static int process_menu_key(struct input_event *pinput) _D("No lcd-on capability!"); return true; } else if (pinput->value == KEY_PRESSED) { - switch_on_lcd(); + switch_on_lcd(LCD_ON_BY_POWER_KEY); } return false; @@ -394,6 +402,19 @@ static bool release_short_powerkey(void) return true; } +static int process_back_key(struct input_event *pinput) +{ + int ignore = true; + + if (pinput->value == KEY_PRESSED) { + switch_on_lcd(LCD_ON_BY_POWER_KEY); + _I("back key pressed"); + ignore = false; + } + + return ignore; +} + static int process_power_key(struct input_event *pinput) { int ignore = true; @@ -419,7 +440,7 @@ static int process_power_key(struct input_event *pinput) break; case KEY_PRESSED: if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) { - skip_lcd_off = switch_on_lcd(); + skip_lcd_off = switch_on_lcd(LCD_ON_BY_POWER_KEY); } else { _D("No lcdon capability!"); skip_lcd_off = false; @@ -536,6 +557,13 @@ static int check_key(struct input_event *pinput, int fd) ignore = process_screenlock_key(pinput); break; case KEY_BACK: + ignore = process_back_key(pinput); + stop_key_combination(NULL); + if (current_state_in_on()) { + process_hardkey_backlight(pinput); + ignore = false; + } + break; case KEY_PHONE: stop_key_combination(NULL); if (current_state_in_on()) { @@ -615,14 +643,19 @@ static int check_key_filter(void *data, int fd) break; case EV_REL: - ignore = false; + if (pm_cur_state == S_LCDOFF && bezel_wakeup) { + switch_on_lcd(LCD_ON_BY_BEZEL); + ignore = false; + } else if (pm_cur_state != S_LCDOFF) { + ignore = false; + } break; case EV_ABS: if (current_state_in_on()) ignore = false; - if (ambient_get_condition() == true) { - switch_on_lcd(); + if (ambient_get_condition() && pinput->value == KEY_PRESSED) { + switch_on_lcd(LCD_ON_BY_TOUCH); ignore = false; } @@ -672,6 +705,7 @@ static void keyfilter_init(void) touchled = find_device(TOUCHLED_NAME); register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done); + register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); } static void keyfilter_exit(void) |