Skip to content

Commit 503106d

Browse files
committed
Merge branch 'vendor'
2 parents 5e2a3ba + 4ab12da commit 503106d

46 files changed

Lines changed: 2663 additions & 589 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

arch/arm64/boot/dts/vendor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../vendor/qcom/proprietary/devicetree-4.19
1+
../../../../../../vendor/qcom/proprietary/devicetree-4.19

arch/arm64/configs/vendor/gta4lwifi_eur_open_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,7 @@ CONFIG_INPUT_EVDEV=y
18961896
# CONFIG_INPUT_EVBUG is not set
18971897
# CONFIG_INPUT_KEYRESET is not set
18981898
# CONFIG_INPUT_KEYCOMBO is not set
1899+
CONFIG_SEC_INPUT_BOOSTER=y
18991900

19001901
#
19011902
# Input Device Drivers

drivers/input/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ config INPUT_JOYDEV
151151

152152
config INPUT_EVDEV
153153
tristate "Event interface"
154+
select SEC_INPUT_BOOSTER
154155
help
155156
Say Y here if you want your input device events be accessible
156157
under char device 13:64+ - /dev/input/eventX in a generic way.
@@ -197,6 +198,15 @@ config INPUT_KEYCOMBO
197198
---help---
198199
Say Y here if you want to take action when some keys are pressed;
199200

201+
config SEC_INPUT_BOOSTER
202+
bool "SEC INPUT BOOSTER"
203+
depends on INPUT_EVDEV
204+
default y
205+
help
206+
Say Y here if you need to enable Input Booster.
207+
208+
It's triggered in evdev module.
209+
200210
comment "Input Device Drivers"
201211

202212
source "drivers/input/keyboard/Kconfig"

drivers/input/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ obj-$(CONFIG_INPUT_LEDS) += input-leds.o
1717
obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o
1818
obj-$(CONFIG_INPUT_JOYDEV) += joydev.o
1919
obj-$(CONFIG_INPUT_EVDEV) += evdev.o
20+
obj-$(CONFIG_SEC_INPUT_BOOSTER) += input_booster.o
21+
obj-$(CONFIG_ARCH_QCOM) += input_booster_qc.o
2022
obj-$(CONFIG_INPUT_EVBUG) += evbug.o
2123

2224
obj-$(CONFIG_INPUT_KEYBOARD) += keyboard/

drivers/input/evdev.c

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,18 @@ struct evdev_client {
5353
bool revoked;
5454
unsigned long *evmasks[EV_CNT];
5555
unsigned int bufsize;
56+
#ifdef CONFIG_SEC_INPUT_BOOSTER
57+
int device_type;
58+
int touch_slot_cnt;
59+
int ev_cnt;
60+
#endif
5661
struct input_event buffer[];
5762
};
5863

64+
#ifdef CONFIG_SEC_INPUT_BOOSTER
65+
#include <linux/input/input_booster.h>
66+
#endif
67+
5968
static size_t evdev_get_mask_cnt(unsigned int type)
6069
{
6170
static const size_t counts[EV_CNT] = {
@@ -214,9 +223,281 @@ static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
214223
return 0;
215224
}
216225

226+
#ifdef CONFIG_SEC_INPUT_BOOSTER
227+
int chk_next_data(struct evdev_client *dev, int idx, int input_type)
228+
{
229+
int ret_val = 0;
230+
int next_type = -1;
231+
int next_code = -1;
232+
233+
int next_idx = (idx+1) & (dev->bufsize - 1);
234+
235+
next_type = dev->buffer[next_idx].type;
236+
next_code = dev->buffer[next_idx].code;
237+
238+
switch (input_type) {
239+
case BTN_TOUCH:
240+
if (next_type == EV_ABS && next_code == ABS_PRESSURE)
241+
ret_val = 1;
242+
break;
243+
case EV_KEY:
244+
ret_val = 1;
245+
break;
246+
default:
247+
break;
248+
}
249+
250+
return ret_val;
251+
}
252+
253+
int chk_boost_on_off(struct evdev_client *dev, int idx, int dev_type)
254+
{
255+
int ret_val = -1;
256+
257+
if (dev_type < 0)
258+
return ret_val;
259+
260+
/* In case of SPEN or HOVER, it must be empty multi event
261+
* Before starting input booster.
262+
*/
263+
if (dev_type == SPEN || dev_type == HOVER) {
264+
if (!evdev_mt_event[dev_type] && dev->buffer[idx].value)
265+
ret_val = 1;
266+
else if (evdev_mt_event[dev_type] && !dev->buffer[idx].value)
267+
ret_val = 0;
268+
} else if (dev_type == TOUCH || dev_type == MULTI_TOUCH) {
269+
if (dev->buffer[idx].value >= 0)
270+
ret_val = 1;
271+
else
272+
ret_val = 0;
273+
} else if (dev->buffer[idx].value > 0)
274+
ret_val = 1;
275+
else if (dev->buffer[idx].value <= 0)
276+
ret_val = 0;
277+
278+
return ret_val;
279+
}
280+
281+
/*
282+
* get_device_type : Define type of device for input_booster.
283+
* dev : Current device that in which input events triggered.
284+
* keyId : Each device get given unique keyid using Type, Code, Slot values
285+
* to identify which booster will be triggered.
286+
* cur_idx : Pointing current handling index from input booster.
287+
* cur_idx will be updated when cur_idx is same as head.
288+
* head : End of events set. Input booster handles from tail event to head events.
289+
* Must check if the event is the last one referring to head.
290+
*/
291+
int get_device_type(struct evdev_client *dev, unsigned int *keyId, int *cur_idx, int head)
292+
{
293+
int i;
294+
int ret_val = -1;
295+
int dev_type = NONE_TYPE_DEVICE;
296+
int uniq_slot = 0;
297+
int next_idx = 0 ;
298+
int target_idx = 0;
299+
300+
if (dev == NULL || dev->ev_cnt > MAX_EVENTS) {
301+
pr_err("evdev client is null and exceed max event number");
302+
return ret_val;
303+
}
304+
305+
/* Initializing device type before finding the proper device type. */
306+
dev->device_type = dev_type;
307+
308+
for (i = *cur_idx; i != head; i=(i+1) & (dev->bufsize - 1)) {
309+
pr_booster("%s Type : %d, Code : %d, Value : %d, Head : %d, idx : %d\n",
310+
"Input Data || ", dev->buffer[i].type,
311+
dev->buffer[i].code, dev->buffer[i].value,
312+
head, i);
313+
314+
if ( dev->buffer[i].type == EV_SYN || dev->buffer[i].code == SYN_REPORT) {
315+
break;
316+
}
317+
318+
if (dev->buffer[i].type == EV_KEY) {
319+
target_idx = i;
320+
switch (dev->buffer[i].code) {
321+
case BTN_TOUCH:
322+
if (!chk_next_data(dev, i, BTN_TOUCH))
323+
break;
324+
dev_type = SPEN;
325+
break;
326+
case BTN_TOOL_PEN:
327+
dev_type = HOVER;
328+
break;
329+
case KEY_BACK:
330+
case KEY_HOMEPAGE:
331+
dev_type = TOUCH_KEY;
332+
break;
333+
case KEY_VOLUMEUP:
334+
case KEY_VOLUMEDOWN:
335+
case KEY_POWER:
336+
dev_type = KEY;
337+
break;
338+
default:
339+
break;
340+
}
341+
342+
} else if (dev->buffer[i].type == EV_ABS) {
343+
target_idx = i;
344+
switch (dev->buffer[i].code) {
345+
case ABS_MT_TRACKING_ID:
346+
347+
if (dev->buffer[i].value >= 0) {
348+
evdev_mt_slot++;
349+
} else {
350+
evdev_mt_slot--;
351+
if (evdev_mt_slot < 0) {
352+
evdev_mt_slot = 0;
353+
break;
354+
}
355+
}
356+
357+
if (dev->buffer[i].value >= 0) {
358+
if (evdev_mt_slot == 1) {
359+
dev_type = TOUCH;
360+
uniq_slot = 1;
361+
} else if (evdev_mt_slot == 2) {
362+
dev_type = MULTI_TOUCH;
363+
uniq_slot = 2;
364+
}
365+
} else if (dev->buffer[i].value < 0) {
366+
//ret_val = 0;
367+
if (evdev_mt_slot == 0) {
368+
dev_type = TOUCH;
369+
uniq_slot = 1;
370+
} else if (evdev_mt_slot == 1) {
371+
dev_type = MULTI_TOUCH;
372+
uniq_slot = 2;
373+
}
374+
}
375+
376+
pr_booster("Touch Booster Trigger(%d), Type(%d), Code(%d), Val(%d), head(%d), Tail(%d), uniq_slot(%d), Idx(%d), Cnt(%d)",
377+
evdev_mt_slot, dev->buffer[i].type, dev->buffer[i].code, dev->buffer[i].value, head, dev->tail, uniq_slot, i, dev->ev_cnt);
378+
379+
break;
380+
}
381+
} else if (dev->buffer[i].type == EV_MSC &&
382+
dev->buffer[i].code == MSC_SCAN) {
383+
384+
if (!chk_next_data(dev, i, EV_KEY)) {
385+
break;
386+
}
387+
next_idx = (i+1) & (dev->bufsize - 1);
388+
target_idx = next_idx;
389+
switch (dev->buffer[next_idx].code) {
390+
case BTN_LEFT: /* Checking Touch Button Event */
391+
case BTN_RIGHT:
392+
case BTN_MIDDLE:
393+
dev_type = MOUSE;
394+
//Remain the last of CODE value as a uniq_slot to recognize BTN Type (LEFT, RIGHT, MIDDLE)
395+
uniq_slot = dev->buffer[next_idx].code;
396+
break;
397+
default: /* Checking Keyboard Event */
398+
dev_type = KEYBOARD;
399+
uniq_slot = dev->buffer[next_idx].code;
400+
401+
pr_booster("KBD Booster Trigger(%d), Type(%d), Code(%d), Val(%d), head(%d), Tail(%d), Idx(%d), Cnt(%d)\n",
402+
dev->buffer[next_idx].code, dev->buffer[i].type,
403+
dev->buffer[i].code, dev->buffer[i].value,
404+
head, dev->tail, i, dev->ev_cnt);
405+
break;
406+
}
407+
}
408+
409+
if (dev_type != NONE_TYPE_DEVICE ) {
410+
*keyId = create_uniq_id(dev->buffer[i].type, dev->buffer[i].code, uniq_slot);
411+
ret_val = chk_boost_on_off(dev, target_idx, dev_type);
412+
pr_booster("Dev type Find(%d), KeyID(%d), enable(%d), Target(%d)\n",
413+
dev_type, *keyId, ret_val, target_idx);
414+
break;
415+
}
416+
417+
}
418+
// if for loop reach the end, cur_idx is set as head value or pointing next one with plus one.
419+
// Especially, dev->bufsize has to be set as a 2^n.
420+
// In the code that set bufzise, we can see bufsize would be set using roundup_pow_of_two function.
421+
// return roundup_pow_of_two(n_events);
422+
// which means "A power of two is a number of the form 2n where n is an integer"
423+
424+
*cur_idx = (i == head) ? head : ((i+1) & (dev->bufsize - 1));
425+
426+
dev->device_type = dev_type;
427+
return ret_val;
428+
}
429+
430+
// ********** Detect Events ********** //
431+
void input_booster(struct evdev_client* dev, int dev_head) {
432+
int dev_type = 0;
433+
int keyId = 0;
434+
unsigned int uniqId = 0;
435+
int res_type = 0;
436+
int cnt = 0;
437+
int cur_idx = -1;
438+
int head = 0;
439+
440+
if (dev == NULL) {
441+
pr_err(ITAG"dev is Null");
442+
return;
443+
}
444+
445+
if (!ib_init_succeed || dev->ev_cnt == 0) {
446+
pr_err(ITAG"ev_cnt(%d) dt_infor hasn't mem alloc", dev->ev_cnt);
447+
return;
448+
}
449+
450+
head = dev_head;
451+
cur_idx = (head- dev->ev_cnt) & (dev->bufsize - 1);
452+
453+
while (cur_idx != head) {
454+
keyId = 0;
455+
int enable = get_device_type(dev, &keyId, &cur_idx, head);
456+
if (enable < 0 || keyId == 0) {
457+
continue;
458+
}
459+
460+
dev_type = dev->device_type;
461+
if (dev_type <= NONE_TYPE_DEVICE || dev_type >= MAX_DEVICE_TYPE_NUM) {
462+
continue;
463+
}
464+
465+
if (enable == BOOSTER_ON) {
466+
evdev_mt_event[dev_type]++;
467+
} else {
468+
evdev_mt_event[dev_type]--;
469+
}
470+
471+
if (cnt == 0 && dev->evdev->handle.dev != NULL) {
472+
while(dev->evdev->handle.dev->name[cnt] != '\0') {
473+
ib_trigger[trigger_cnt].dev_name[cnt] = dev->evdev->handle.dev->name[cnt];
474+
cnt++;
475+
}
476+
ib_trigger[trigger_cnt].dev_name[cnt] = '\0';
477+
}
478+
479+
pr_booster("Dev Name : %s(%d), Key Id(%d), IB_Cnt(%d)", ib_trigger[trigger_cnt].dev_name, dev_type, keyId, trigger_cnt);
480+
481+
ib_trigger[trigger_cnt].key_id = keyId;
482+
ib_trigger[trigger_cnt].event_type = enable;
483+
ib_trigger[trigger_cnt].dev_type = dev_type;
484+
485+
queue_work(ev_unbound_wq, &(ib_trigger[trigger_cnt++].ib_trigger_work));
486+
trigger_cnt = (trigger_cnt == MAX_IB_COUNT) ? 0 : trigger_cnt;
487+
}
488+
}
489+
#endif //--CONFIG_SEC_INPUT_BOOSTER
490+
217491
static void __pass_event(struct evdev_client *client,
218492
const struct input_event *event)
219493
{
494+
#ifdef CONFIG_SEC_INPUT_BOOSTER
495+
unsigned long flags;
496+
497+
pr_booster("Raw Input Data : %d, code : %d, Val : %d",
498+
event->type, event->code, event->value);
499+
client->ev_cnt++;
500+
#endif
220501
client->buffer[client->head++] = *event;
221502
client->head &= client->bufsize - 1;
222503

@@ -240,6 +521,13 @@ static void __pass_event(struct evdev_client *client,
240521

241522
if (event->type == EV_SYN && event->code == SYN_REPORT) {
242523
client->packet_head = client->head;
524+
#ifdef CONFIG_SEC_INPUT_BOOSTER
525+
pr_booster("IB Triggered :: HEAD(%d) TAIL(%d)", client->head, client->tail);
526+
spin_lock_irqsave(&ib_type_lock, flags);
527+
input_booster(client, client->head);
528+
client->ev_cnt = 0;
529+
spin_unlock_irqrestore(&ib_type_lock, flags);
530+
#endif
243531
kill_fasync(&client->fasync, SIGIO, POLL_IN);
244532
}
245533
}
@@ -1437,6 +1725,9 @@ static struct input_handler evdev_handler = {
14371725

14381726
static int __init evdev_init(void)
14391727
{
1728+
#ifdef CONFIG_SEC_INPUT_BOOSTER
1729+
input_booster_init();
1730+
#endif
14401731
return input_register_handler(&evdev_handler);
14411732
}
14421733

0 commit comments

Comments
 (0)