From 819278a2f29240b7624768705f0c8b21442a30ff Mon Sep 17 00:00:00 2001 From: Simon1511 Date: Wed, 9 Nov 2022 20:17:11 +0100 Subject: [PATCH] sm7125: input: touchscreen: fts5cu56a: limit physical proximity sense range * On stock ROM proximity only changes if changes occur near to the sensor. However on AOSP proximity already changes if a finger is placed somewhere between the upper half and the middle of the screen, making it impossible to for example pull down the notification panel during a phone call because the screen constantly turnes off. Samsung seems to apply something remotely similar on their stock ROM by creating a whole new virtual sensor. * We now check if the area around the sensor (1400-2800 on the X axis, 0-700 on the Y axis) is touched and only then report proximity changes. * To not break proximity reporting during screen off we also check if the panel is in LPM state Change-Id: I22cb2f15cbb8a852b416642b47e1eb2799053d7e --- .../input/touchscreen/stm/fts5cu56a/fts_ts.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/stm/fts5cu56a/fts_ts.c b/drivers/input/touchscreen/stm/fts5cu56a/fts_ts.c index ce64fd045948..f700fd5f7c27 100755 --- a/drivers/input/touchscreen/stm/fts5cu56a/fts_ts.c +++ b/drivers/input/touchscreen/stm/fts5cu56a/fts_ts.c @@ -1820,10 +1820,20 @@ static u8 fts_event_handler_type_b(struct fts_ts_info *info) if (p_event_status->stype == FTS_EVENT_STATUSTYPE_VENDORINFO) { if (info->board->support_ear_detect) { if (p_event_status->status_id == 0x6A) { - p_event_status->status_data_1 = p_event_status->status_data_1 == 5 || !p_event_status->status_data_1; - info->hover_event = p_event_status->status_data_1; - input_report_abs(info->input_dev_proximity, ABS_MT_CUSTOM, p_event_status->status_data_1); - input_sync(info->input_dev_proximity); + if (info->fts_power_state == FTS_POWER_STATE_LOWPOWER || info->finger[TouchID].y < 700 && info->finger[TouchID].x > 900 + && info->finger[TouchID].x < 3000) { + // Report actual range when either the area around the sensor is touched or if panel is in LPM state + p_event_status->status_data_1 = p_event_status->status_data_1 == 5 || !p_event_status->status_data_1; + info->hover_event = p_event_status->status_data_1; + input_report_abs(info->input_dev_proximity, ABS_MT_CUSTOM, p_event_status->status_data_1); + input_sync(info->input_dev_proximity); + } else { + // Properly reset to 1cm + p_event_status->status_data_1 = 1; + info->hover_event = p_event_status->status_data_1; + input_report_abs(info->input_dev_proximity, ABS_MT_CUSTOM, p_event_status->status_data_1); + input_sync(info->input_dev_proximity); + } input_info(true, &info->client->dev, "%s: proximity: %d\n", __func__, p_event_status->status_data_1); } }