Skip to content

Commit 31b102a

Browse files
pwnrazronettboots
authored andcommitted
goodix_driver_gt9886: implement single tap sensor
Pretty much the same as udfps/dt2w stuff Just use one of the FOD gestures as it detects specifically single taps. Also modify some logic so the appropriate mode gets set in cases like udfps and dt2w is disabled but st2w is enabled Signed-off-by: onettboots <blackcocopet@gmail.com>
1 parent fcc15dd commit 31b102a

3 files changed

Lines changed: 50 additions & 9 deletions

File tree

drivers/input/touchscreen/goodix_driver_gt9886/goodix_ts_core.c

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ static ssize_t udfps_enabled_store(struct device *dev,
846846

847847
core_data->udfps_enabled = buf[0] != '0';
848848

849-
core_data->gesture_enabled = core_data->double_tap_enabled | core_data->udfps_enabled;
849+
core_data->gesture_enabled = core_data->double_tap_enabled | core_data->udfps_enabled | core_data->single_tap_enabled;
850850

851851
goodix_check_gesture_stat(true);
852852

@@ -877,7 +877,7 @@ static ssize_t double_tap_enabled_store(struct device *dev,
877877

878878
core_data->double_tap_enabled = buf[0] != '0';
879879

880-
core_data->gesture_enabled = core_data->double_tap_enabled | core_data->udfps_enabled;
880+
core_data->gesture_enabled = core_data->double_tap_enabled | core_data->udfps_enabled | core_data->single_tap_enabled;
881881

882882
goodix_check_gesture_stat(true);
883883

@@ -892,6 +892,37 @@ static ssize_t double_tap_enabled_show(struct device *dev,
892892
return scnprintf(buf, PAGE_SIZE, "%i\n", core_data->double_tap_enabled);
893893
}
894894

895+
static ssize_t single_tap_pressed_show(struct device *dev,
896+
struct device_attribute *attr, char *buf)
897+
{
898+
struct goodix_ts_core *core_data = dev_get_drvdata(dev);
899+
900+
return scnprintf(buf, PAGE_SIZE, "%i\n", core_data->single_tap_pressed);
901+
}
902+
903+
static ssize_t single_tap_enabled_store(struct device *dev,
904+
struct device_attribute *attr, const char *buf,
905+
size_t count)
906+
{
907+
struct goodix_ts_core *core_data = dev_get_drvdata(dev);
908+
909+
core_data->single_tap_enabled = buf[0] != '0';
910+
911+
core_data->gesture_enabled = core_data->double_tap_enabled | core_data->udfps_enabled | core_data->single_tap_enabled;
912+
913+
goodix_check_gesture_stat(true);
914+
915+
return count;
916+
}
917+
918+
static ssize_t single_tap_enabled_show(struct device *dev,
919+
struct device_attribute *attr, char *buf)
920+
{
921+
struct goodix_ts_core *core_data = dev_get_drvdata(dev);
922+
923+
return scnprintf(buf, PAGE_SIZE, "%i\n", core_data->single_tap_enabled);
924+
}
925+
895926
static DEVICE_ATTR(extmod_info, 0444, goodix_ts_extmod_show, NULL);
896927
static DEVICE_ATTR(driver_info, 0444, goodix_ts_driver_info_show, NULL);
897928
static DEVICE_ATTR(chip_info, 0444, goodix_ts_chip_info_show, NULL);
@@ -905,6 +936,8 @@ static DEVICE_ATTR(udfps_pressed, 0660, udfps_pressed_show, NULL);
905936
static DEVICE_ATTR(udfps_enabled, 0664, udfps_enabled_show, udfps_enabled_store);
906937
static DEVICE_ATTR(double_tap_pressed, 0660, double_tap_pressed_show, NULL);
907938
static DEVICE_ATTR(double_tap_enabled, 0664, double_tap_enabled_show, double_tap_enabled_store);
939+
static DEVICE_ATTR(single_tap_pressed, 0660, single_tap_pressed_show, NULL);
940+
static DEVICE_ATTR(single_tap_enabled, 0664, single_tap_enabled_show, single_tap_enabled_store);
908941
#ifdef CONFIG_TOUCHSCREEN_GOODIX_GTX8_GAMEMODE
909942
static DEVICE_ATTR(game_mode, 0664,
910943
goodix_ts_game_mode_show, goodix_ts_game_mode_store);
@@ -923,6 +956,8 @@ static struct attribute *sysfs_attrs[] = {
923956
&dev_attr_udfps_enabled.attr,
924957
&dev_attr_double_tap_pressed.attr,
925958
&dev_attr_double_tap_enabled.attr,
959+
&dev_attr_single_tap_pressed.attr,
960+
&dev_attr_single_tap_enabled.attr,
926961
#ifdef CONFIG_TOUCHSCREEN_GOODIX_GTX8_GAMEMODE
927962
&dev_attr_game_mode.attr,
928963
#endif
@@ -1769,11 +1804,11 @@ int goodix_ts_suspend(struct goodix_ts_core *core_data)
17691804

17701805
r = ext_module->funcs->before_suspend(core_data, ext_module);
17711806
if (r == EVT_CANCEL_SUSPEND) {
1772-
if (core_data->double_tap_enabled && core_data->udfps_enabled) {
1807+
if (core_data->double_tap_enabled && (core_data->udfps_enabled || core_data->single_tap_enabled)) {
17731808
atomic_set(&core_data->suspend_stat, TP_GESTURE_DBCLK_FOD);
17741809
} else if (core_data->double_tap_enabled) {
17751810
atomic_set(&core_data->suspend_stat, TP_GESTURE_DBCLK);
1776-
} else if (core_data->udfps_enabled) {
1811+
} else if (core_data->udfps_enabled || core_data->single_tap_enabled) {
17771812
atomic_set(&core_data->suspend_stat, TP_GESTURE_FOD);
17781813
}
17791814
ts_info("suspend_stat[%d]", atomic_read(&core_data->suspend_stat));
@@ -1989,7 +2024,7 @@ int goodix_ts_msm_drm_notifier_callback(struct notifier_block *self,
19892024
//if (!atomic_read(&core_data->suspend_stat))
19902025
core_data->udfps_pressed = 0;
19912026
core_data->double_tap_pressed = 0;
1992-
ts_info("core_data->suspend_stat = %d\n", atomic_read(&core_data->suspend_stat));
2027+
core_data->single_tap_pressed = 0;
19932028
ts_info("touchpanel resume");
19942029
queue_work(core_data->event_wq, &core_data->resume_work);
19952030
return 0;

drivers/input/touchscreen/goodix_driver_gt9886/goodix_ts_core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ struct goodix_ts_core {
501501
u8 udfps_enabled;
502502
u8 double_tap_pressed;
503503
u8 double_tap_enabled;
504+
u8 single_tap_pressed;
505+
u8 single_tap_enabled;
504506
int result_type;
505507
#ifdef CONFIG_TOUCHSCREEN_GOODIX_GTX8_GAMEMODE
506508
int touch_mode[Touch_Mode_NUM][VALUE_TYPE_SIZE];
@@ -1284,6 +1286,8 @@ struct goodix_ts_core {
12841286
u8 udfps_enabled;
12851287
u8 double_tap_pressed;
12861288
u8 double_tap_enabled;
1289+
u8 single_tap_pressed;
1290+
u8 single_tap_enabled;
12871291
int result_type;
12881292
struct class *gtp_tp_class;
12891293
struct device *gtp_touch_dev;

drivers/input/touchscreen/goodix_driver_gt9886/goodix_ts_gesture.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static int gsx_gesture_ist(struct goodix_ts_core *core_data,
390390
ts_debug("udfps_enabled= %d aod_status=%d", core_data->udfps_enabled, core_data->aod_status);
391391
ts_debug("sleep_finger: %d", !core_data->sleep_finger);*/
392392

393-
if ((core_data->udfps_enabled || core_data->aod_status) && FP_Event_Gesture) {
393+
if ((core_data->udfps_enabled || core_data->single_tap_enabled || core_data->aod_status) && FP_Event_Gesture) {
394394
switch (temp_data[2]) {
395395
case 0x46:
396396
core_data->udfps_pressed = 1;
@@ -410,6 +410,8 @@ static int gsx_gesture_ist(struct goodix_ts_core *core_data,
410410
case 0x4c:
411411
/*wait for report key event*/
412412
FP_Event_Gesture = 0;
413+
core_data->single_tap_pressed = 1;
414+
sysfs_notify(&core_data->pdev->dev.kobj, NULL, "single_tap_pressed");
413415
input_report_key(core_data->input_dev, KEY_GOTO, 1);
414416
input_sync(core_data->input_dev);
415417
input_report_key(core_data->input_dev, KEY_GOTO, 0);
@@ -484,7 +486,7 @@ static int goodix_set_suspend_func(struct goodix_ts_core *core_data)
484486

485487
if (core_data->double_tap_enabled)
486488
mode |= 0x01;
487-
if (core_data->udfps_enabled)
489+
if (core_data->udfps_enabled || core_data->single_tap_enabled)
488490
mode |= 0x02;
489491

490492
switch (mode) {
@@ -563,11 +565,11 @@ static int goodix_wakeup_and_set_suspend_func(struct goodix_ts_core *core_data)
563565
}
564566
} while (r < 0 && ++retry < 3);
565567

566-
if (core_data->double_tap_enabled && core_data->udfps_enabled) {
568+
if (core_data->double_tap_enabled && (core_data->udfps_enabled || core_data->single_tap_enabled)) {
567569
atomic_set(&core_data->suspend_stat, TP_GESTURE_DBCLK_FOD);
568570
} else if (core_data->double_tap_enabled) {
569571
atomic_set(&core_data->suspend_stat, TP_GESTURE_DBCLK);
570-
} else if (core_data->udfps_enabled) {
572+
} else if (core_data->udfps_enabled || core_data->single_tap_enabled) {
571573
atomic_set(&core_data->suspend_stat, TP_GESTURE_FOD);
572574
} else {
573575
atomic_set(&core_data->suspend_stat, TP_SLEEP);

0 commit comments

Comments
 (0)