summaryrefslogtreecommitdiff
path: root/plugins/wearable/display/key-filter.c
blob: 891dadb8de8e339374676f5d7d65fae1a8600e11 (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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
/*
 * deviced
 *
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
 *
 * 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 <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <vconf.h>
#include <sys/types.h>
#include <libsyscommon/dbus-system.h>
#include <linux/input.h>

#include "ambient-mode.h"
#include "util.h"
#include "core.h"
#include "poll.h"
#include "device-node.h"
#include "display-actor.h"
#include "display-ops.h"
#include "core/common.h"
#include "core/devices.h"
#include "core/device-notifier.h"
#include "shared/common.h"
#include "power/power-handler.h"
#include "led/touch-key.h"
#include "apps/apps.h"

#ifndef KEY_SCREENLOCK
#define KEY_SCREENLOCK		0x98
#endif
#ifndef SW_GLOVE
#define SW_GLOVE		0x16
#endif

#define PREDEF_LEAVESLEEP	"leavesleep"
#define POWEROFF_ACT			"poweroff"
#define USEC_PER_SEC			1000000
#define USEC_PER_MSEC			1000
#define CSC_CONFIG_MODE_RUNNING	1

#define CAPTURE_COMBINATION_INTERVAL		0.5	/* 0.5 second */
#define TORCH_COMBINATION_INTERVAL			0.1 /* 0.1 second */
#define DEFAULT_COMBINATION_INTERVAL		0.1 /* 0.1 second */

#define LONGKEY_PRESSED_TIME	4	/* 4 second */

#define KEY_MAX_DELAY_TIME		700	/* ms */

#define SIGNAL_CHANGE_HARDKEY		"ChangeHardkey"
#define SIGNAL_LCDON_BY_POWERKEY	"LCDOnByPowerkey"
#define SIGNAL_LCDOFF_BY_POWERKEY	"LCDOffByPowerkey"

#define NORMAL_POWER			0
#define KEY_TEST_MODE_POWER		2

#define GLOVE_MODE	1

enum key_combination_flags {
	KEY_COMBINATION_STOP		= 0,
	KEY_COMBINATION_POWERKEY	= BIT(0),
	KEY_COMBINATION_MENUKEY		= BIT(1),
	KEY_COMBINATION_VOLUMEUP	= BIT(2),
	KEY_COMBINATION_VOLUMEDOWN	= BIT(3),
};

enum combination_process {
	COMBINATION_STOP	= KEY_COMBINATION_STOP,
	COMBINATION_SCREENCAPTURE	= KEY_COMBINATION_POWERKEY | KEY_COMBINATION_MENUKEY,
	COMBINATION_TORCH	= KEY_COMBINATION_POWERKEY | KEY_COMBINATION_VOLUMEUP,
	COMBINATION_QUICKTALK	= KEY_COMBINATION_POWERKEY | KEY_COMBINATION_VOLUMEDOWN,
};

static struct timeval pressed_time;
static guint longkey_timeout_id = 0;
static guint longkey_restore_id = 0;
static guint displayon_by_powerkey_timeout_id = 0;
static int cancel_lcdoff;
static int key_combination = KEY_COMBINATION_STOP;
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 booting_check = true;

static inline int current_state_in_on(void)
{
	return (pm_cur_state == S_LCDDIM || pm_cur_state == S_NORMAL);
}

static inline void restore_custom_brightness(void)
{
	if (pm_cur_state == S_LCDDIM &&
	    backlight_ops.get_custom_status())
		backlight_ops.custom_update();
}

static void longkey_pressed(void)
{
	unsigned int caps;

	_I("Power key long pressed!");
	cancel_lcdoff = 1;

	caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);

	if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
		/* change state - LCD on */
		if (disp_plgn.pm_change_internal)
			disp_plgn.pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL);
		(*pm_callback)(INPUT_POLL_EVENT, NULL);
	}

	if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) {
		_D("No poweroff capability!");
		return;
	}
	pm_status_flag &= ~PWROFF_FLAG;
}

static gboolean longkey_restore_cb(void *data)
{
	device_notify(DEVICE_NOTIFIER_LONGKEY_RESTORE, (void *)NULL);
	longkey_restore_id = 0;

	return G_SOURCE_REMOVE;
}

static gboolean longkey_pressed_cb(void *data)
{
	longkey_pressed();
	longkey_timeout_id = 0;

	return G_SOURCE_REMOVE;
}

static unsigned long timediff_usec(struct timeval t1, struct timeval t2)
{
	unsigned long udiff;

	udiff = (t2.tv_sec - t1.tv_sec) * USEC_PER_SEC;
	udiff += (t2.tv_usec - t1.tv_usec);

	return udiff;
}

static inline void check_key_pair(int code, int new, int *old)
{
	if (new == *old)
		_E("key pair is not matched! (%d, %d)", code, new);
	else
		*old = new;
}

static inline void broadcast_lcdon_by_powerkey(void)
{
	dbus_handle_emit_dbus_signal(NULL,
					DEVICED_PATH_DISPLAY,
					DEVICED_INTERFACE_DISPLAY,
					SIGNAL_LCDON_BY_POWERKEY,
					NULL);
}

static inline void broadcast_lcdoff_by_powerkey(void)
{
	dbus_handle_emit_dbus_signal(NULL,
					DEVICED_PATH_DISPLAY,
					DEVICED_INTERFACE_DISPLAY,
					SIGNAL_LCDOFF_BY_POWERKEY,
					NULL);
}

static inline bool switch_on_lcd(enum device_flags flags)
{
	if (current_state_in_on())
		return false;

	if (backlight_ops.get_lcd_power() == DPMS_ON) {
		if (ambient_get_state() == false)
			return false;
	}

	if (flags & LCD_ON_BY_POWER_KEY)
		broadcast_lcdon_by_powerkey();
	else if (flags & LCD_ON_BY_TOUCH)
		_I("Display on by Touch_wakeup event");

	lcd_on_direct(flags);

	return true;
}

static inline void switch_off_lcd(void)
{
	if (!current_state_in_on())
		return;

	if (backlight_ops.get_lcd_power() == DPMS_OFF)
		return;

	broadcast_lcdoff_by_powerkey();

	lcd_off_procedure(LCD_OFF_BY_POWER_KEY);
}

static void check_key_combination(struct input_event *pinput)
{
	double press_time, diff_time;
	press_time = (pinput->time).tv_sec + USEC_TO_SEC((pinput->time).tv_usec);
	diff_time = press_time - combination_pressed_time;

	switch (key_combination) {
	case COMBINATION_SCREENCAPTURE:
		if (diff_time <= CAPTURE_COMBINATION_INTERVAL) {
			_I("Combination key : SCREENCAPTURE mode");
			skip_combination = true;
		}
		break;
	case COMBINATION_TORCH:
		if (diff_time <= TORCH_COMBINATION_INTERVAL) {
			/* When torch combination, display control should be not change. */
			if (displayon_by_powerkey_timeout_id) {
				g_source_remove(displayon_by_powerkey_timeout_id);
				displayon_by_powerkey_timeout_id = 0;
			}
			_I("Combination key : TORCH mode");
			skip_combination = true;
		} else
			key_combination = COMBINATION_STOP;
		break;
	case COMBINATION_QUICKTALK:
		if (diff_time <= DEFAULT_COMBINATION_INTERVAL) {
			_I("Combination key : QUICK-TALK mode");
			skip_combination = true;
			if (longkey_timeout_id) {
				g_source_remove(longkey_timeout_id);
				longkey_timeout_id = 0;
			}
		}
		break;
	default:
		combination_pressed_time = press_time;
		return;
	}

}

static void start_key_combination(struct input_event *pinput)
{
	switch (pinput->code) {
	case KEY_POWER:
		key_combination |= KEY_COMBINATION_POWERKEY;
		break;
	case KEY_MENU:
		key_combination |= KEY_COMBINATION_MENUKEY;
		break;
	case KEY_VOLUMEUP:
		key_combination |= KEY_COMBINATION_VOLUMEUP;
		break;
	case KEY_VOLUMEDOWN:
		key_combination |= KEY_COMBINATION_VOLUMEDOWN;
		break;
	default:
		return;
	}

	check_key_combination(pinput);
}

static void stop_key_combination(struct input_event *pinput)
{
	if (pinput == NULL) {
		key_combination = KEY_COMBINATION_STOP;
		return;
	}

	switch (pinput->code) {
	case KEY_POWER:
		key_combination &= ~KEY_COMBINATION_POWERKEY;
		break;
	case KEY_MENU:
		key_combination &= ~KEY_COMBINATION_MENUKEY;
		break;
	case KEY_VOLUMEUP:
		key_combination &= ~KEY_COMBINATION_VOLUMEUP;
		break;
	case KEY_VOLUMEDOWN:
		key_combination &= ~KEY_COMBINATION_VOLUMEDOWN;
		break;
	default:
		_E("This code(%d) is not combination type.", pinput->code);
		break;
	}
}

static void process_combination_key(struct input_event *pinput)
{
	if (pinput->value == KEY_PRESSED)
		start_key_combination(pinput);
	else if (pinput->value == KEY_RELEASED)
		stop_key_combination(pinput);
}

static int process_menu_key(struct input_event *pinput)
{
	int caps;

	caps = display_get_caps(DISPLAY_ACTOR_MENU_KEY);

	if (!display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
		if (current_state_in_on())
			return false;
		_D("No lcd-on capability!");
		return true;
	} else if (pinput->value == KEY_PRESSED)
		switch_on_lcd(LCD_ON_BY_POWER_KEY);

	return false;
}

static int decide_lcdoff(void)
{
	/* It's not needed if it's already LCD off state */
	if (!current_state_in_on() &&
	    backlight_ops.get_lcd_power() != DPMS_ON)
		return false;

	/*
	 * This flag is set at the moment
	 * that LCD is turned on by power key
	 * LCD has not to turned off in the situation.
	 */
	if (skip_lcd_off)
		return false;

	/* LCD is not turned off when powerkey is pressed,not released */
	if (key_combination == KEY_COMBINATION_POWERKEY)
		return false;

	/* LCD-off is blocked at the moment poweroff popup shows */
	if (cancel_lcdoff)
		return false;

	/* LCD-off is blocked when powerkey and volmedown key are pressed */
	if (skip_combination)
		return false;

	/* At booting time, display must do not turn off */
	if (booting_check)
		return false;

	return true;
}

static int lcdoff_powerkey(void)
{
	int ignore = true;

	if (decide_lcdoff() == true) {
		check_processes(S_NORMAL);
		check_processes(S_LCDDIM);

		if (!check_holdkey_block(S_NORMAL) &&
		    !check_holdkey_block(S_LCDDIM)) {
			if (display_info.update_auto_brightness)
				display_info.update_auto_brightness(false);
			switch_off_lcd();
			delete_condition(S_NORMAL);
			delete_condition(S_LCDDIM);
			update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY);
			if (disp_plgn.pm_change_internal)
				disp_plgn.pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF);
		}
	} else {
		ignore = false;
		skip_combination = false;
	}
	cancel_lcdoff = 0;

	return ignore;
}

static int process_back_key(struct input_event *pinput)
{
	int ignore = true;

	if (pinput->value == KEY_PRESSED) {
		switch_on_lcd(LCD_ON_BY_BACK_KEY);
		_I("back key pressed");
		ignore = false;
	}

	return ignore;
}

static int process_power_key(struct input_event *pinput)
{
	int ignore = true;
	static int value = KEY_RELEASED;
	unsigned int caps;

	caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);

	switch (pinput->value) {
	case KEY_RELEASED:
		check_key_pair(pinput->code, pinput->value, &value);

		if (!display_conf.powerkey_doublepress) {
			if (display_has_caps(caps, DISPLAY_CAPA_LCDOFF))
				lcdoff_powerkey();
			else
				_D("No lcdoff capability!");
		} else if (skip_lcd_off)
			ignore = false;

		if (!display_has_caps(caps, DISPLAY_CAPA_LCDON))
			ignore = true;

		if (longkey_timeout_id > 0) {
			g_source_remove(longkey_timeout_id);
			longkey_timeout_id = 0;
		}

		if (longkey_restore_id > 0) {
			g_source_remove(longkey_restore_id);
			longkey_restore_id = 0;
		}

		break;
	case KEY_PRESSED:
		if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
			skip_lcd_off = switch_on_lcd(LCD_ON_BY_POWER_KEY);
		} else {
			_D("No lcdon capability!");
			skip_lcd_off = false;
		}
		check_key_pair(pinput->code, pinput->value, &value);
		_I("power key pressed");
		pressed_time.tv_sec = (pinput->time).tv_sec;
		pressed_time.tv_usec = (pinput->time).tv_usec;
		if (key_combination == KEY_COMBINATION_POWERKEY) {
			/* add long key timer */
			longkey_timeout_id = g_timeout_add(
				    display_conf.longpress_interval,
				    longkey_pressed_cb, NULL);
			/* add long key restore timer */
			longkey_restore_id = g_timeout_add(
				    LONGKEY_PRESSED_TIME,
				    longkey_restore_cb, NULL);
		}
		cancel_lcdoff = 0;

		break;
	case KEY_BEING_PRESSED:
		if (timediff_usec(pressed_time, pinput->time) >
		    (display_conf.longpress_interval * USEC_PER_MSEC))
			longkey_pressed();
		break;
	}
	return ignore;
}

static int process_screenlock_key(struct input_event *pinput)
{
	if (pinput->value != KEY_RELEASED) {
		stop_key_combination(NULL);
		return true;
	}

	if (!current_state_in_on())
		return false;

	check_processes(S_NORMAL);
	check_processes(S_LCDDIM);

	if (!check_holdkey_block(S_NORMAL) && !check_holdkey_block(S_LCDDIM)) {
		delete_condition(S_NORMAL);
		delete_condition(S_LCDDIM);
		update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY);

		/* LCD off forcly */
		if (disp_plgn.pm_change_internal)
			disp_plgn.pm_change_internal(-1, LCD_OFF);
	}

	return true;
}

static void process_hardkey_backlight(struct input_event *pinput)
{
	int opt;

	_E("pinput->value : %d", pinput->value);
	if (pinput->value == KEY_PRESSED) {
		if (touchled && touchled->execute) {
			opt = TOUCHLED_PRESS;
			touchled->execute(&opt);
		}
	} else if (pinput->value == KEY_RELEASED) {
		/* if lockscreen is idle lock */
		if (__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) {
			_D("Lock state, key backlight is off when phone is unlocked!");
			return;
		}

		if (touchled && touchled->execute) {
			opt = TOUCHLED_RELEASE;
			touchled->execute(&opt);
		}
	}
}

static void update_vital_state(struct input_event *pinput)
{
	int type;

	/* Change vital state to  VITAL_EXIT only if vital mode is active */
	if (!vital_mode())
		return;

	/* Touch or Menu Key Release Event */
	if (pinput->type == EV_ABS || (pinput->type == EV_KEY &&
	    pinput->value == KEY_RELEASED && pinput->code == KEY_MENU)) {
		/* Enable all services upon receiving user input, else maintain same state */
		type = VITAL_EXIT;
		device_notify(DEVICE_NOTIFIER_VITAL_STATE, &type);
	}
}

static int check_key(struct input_event *pinput, int fd)
{
	int ignore = true;

	process_combination_key(pinput);
	switch (pinput->code) {
	case KEY_MENU:
		ignore = process_menu_key(pinput);
		break;
	case KEY_POWER:
		ignore = process_power_key(pinput);
		if (current_state_in_on())
			ignore = false;
		break;
	case KEY_SCREENLOCK:
		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()) {
			process_hardkey_backlight(pinput);
			ignore = false;
		}
		break;
	case KEY_VOLUMEUP:
	case KEY_VOLUMEDOWN:
		if (current_state_in_on())
			ignore = false;
		break;
	case KEY_CAMERA:
	case KEY_EXIT:
	case KEY_CONFIG:
	case KEY_MEDIA:
	case KEY_MUTE:
	case KEY_PLAYPAUSE:
	case KEY_PLAYCD:
	case KEY_PAUSECD:
	case KEY_STOPCD:
	case KEY_NEXTSONG:
	case KEY_PREVIOUSSONG:
	case KEY_REWIND:
	case KEY_FASTFORWARD:
		stop_key_combination(NULL);
		if (current_state_in_on())
			ignore = false;
		break;
	case 0x1DB:
	case 0x1DC:
	case 0x1DD:
	case 0x1DE:
		stop_key_combination(NULL);
		break;
	default:
		stop_key_combination(NULL);
		ignore = false;
	}
#ifdef ENABLE_PM_LOG
	if (pinput->value == KEY_PRESSED)
		pm_history_save(PM_LOG_KEY_PRESS, pinput->code);
	else if (pinput->value == KEY_RELEASED)
		pm_history_save(PM_LOG_KEY_RELEASE, pinput->code);
#endif
	return ignore;
}

static int check_key_filter(void *data, int fd)
{
	struct input_event *pinput = data;
	int ignore = true;
	static int old_fd, code, value;

	assert(pinput);

	switch (pinput->type) {
	case EV_KEY:
		if (pinput->code == BTN_TOUCH &&
			pinput->value == KEY_RELEASED)
			touch_pressed = false;
		/*
		 * Normally, touch press/release events don't occur
		 * in lcd off state. But touch release events can occur
		 * in the state abnormally. Then touch events are ignored
		 * when lcd is off state.
		 */
		if (pinput->code == BTN_TOUCH && !current_state_in_on())
			break;
		if (pinput->code == code && pinput->value == value) {
			_E("Same key(%d, %d) is polled [%d,%d]",
				code, value, old_fd, fd);
		}
		old_fd = fd;
		code = pinput->code;
		value = pinput->value;

		update_vital_state(pinput);
		ignore = check_key(pinput, fd);
		restore_custom_brightness();

		break;
	case EV_REL:
		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:
		update_vital_state(pinput);
		if (pinput->value == KEY_PRESSED) {
			switch_on_lcd(LCD_ON_BY_TOUCH);
			ignore = false;
		}

		if (current_state_in_on())
			ignore = false;

		restore_custom_brightness();

		if (pinput->value == KEY_PRESSED)
			touch_pressed = true;
		else if (pinput->value == KEY_RELEASED)
			touch_pressed = false;
		break;
	case EV_SW:
		break;
	}

	if (ignore)
		return 1;

	return 0;
}

static int booting_done_cb(void *data)
{
	booting_check = 0;

	return 0;
}

static int bezel_wakeup_cb(void *data)
{
	bezel_wakeup = (int)((intptr_t)data);

	return 0;
}

/*
 * Default capability
 * powerkey := LCDON | LCDOFF | POWEROFF
 * homekey  := LCDON
 */
static struct display_actor_ops display_powerkey_actor = {
	.id	= DISPLAY_ACTOR_POWER_KEY,
	.caps	= DISPLAY_CAPA_LCDON |
		  DISPLAY_CAPA_LCDOFF |
		  DISPLAY_CAPA_POWEROFF,
};

static struct display_actor_ops display_menukey_actor = {
	.id	= DISPLAY_ACTOR_MENU_KEY,
	.caps	= DISPLAY_CAPA_LCDON,
};

static void keyfilter_init(void)
{
	display_add_actor(&display_powerkey_actor);
	display_add_actor(&display_menukey_actor);

	touchled = find_device(TOUCHLED_NAME);

	register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done_cb);
	register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb);
}

static void key_backlight_enable(bool enable)
{
	int opt;

	if (!touchled || !touchled->execute)
		return;

	if (enable)
		opt = TOUCHLED_DIRECT_ON;
	else
		opt = TOUCHLED_DIRECT_OFF;

	touchled->execute(&opt);
}

static const struct display_keyfilter_ops normal_keyfilter_ops = {
	.init			= keyfilter_init,
	.check			= check_key_filter,
	.set_powerkey_ignore	= NULL,
	.powerkey_lcdoff	= NULL,
	.backlight_enable	= key_backlight_enable,
};

const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops;