summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-05-23 20:10:06 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-05-23 20:10:06 +0000
commit6d991a33e31a8131cca0fd397e98efb9aba8dc27 (patch)
treed120217b04c29fd00c2f48a9bdcf30151c2f7a5d
parent737006deae421ce21af6ed252310c88d7c96bc67 (diff)
parentb08258e32fb2d4115736e1ec1f4dd7390c9a5faa (diff)
downloadgoodix_touch-android-gs-raviole-5.10-u-beta5.tar.gz
Change-Id: Id40246c9eb91bae3dc888dff0364881be1da5b1a
-rw-r--r--BUILD.bazel27
-rw-r--r--goodix_brl_hw.c93
-rw-r--r--goodix_ts_core.c117
-rw-r--r--goodix_ts_core.h32
-rw-r--r--goodix_ts_proc.c166
5 files changed, 333 insertions, 102 deletions
diff --git a/BUILD.bazel b/BUILD.bazel
new file mode 100644
index 0000000..18f7a30
--- /dev/null
+++ b/BUILD.bazel
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+load("//build/kernel/kleaf:kernel.bzl", "kernel_module")
+
+kernel_module(
+ name = "goodix",
+ srcs = glob([
+ "**/*.c",
+ "**/*.h",
+ "Kbuild",
+ ]) + [
+ "//private/google-modules/touch/common:headers",
+ "//private/google-modules/soc/gs:gs_soc_headers",
+ ],
+ outs = [
+ "goodix_brl_touch.ko",
+ ],
+ kernel_build = "//private/google-modules/soc/gs:gs_kernel_build",
+ visibility = [
+ "//private/devices/google:__subpackages__",
+ "//private/google-modules/soc/gs:__pkg__",
+ ],
+ deps = [
+ "//private/google-modules/soc/gs:gs_soc_module",
+ "//private/google-modules/touch/common:touch.common",
+ ],
+)
diff --git a/goodix_brl_hw.c b/goodix_brl_hw.c
index 1e3bc1a..baf5edf 100644
--- a/goodix_brl_hw.c
+++ b/goodix_brl_hw.c
@@ -324,6 +324,12 @@ static int brl_reset(struct goodix_ts_core *cd, int delay)
{
ts_info("chip_reset");
+ /*
+ * ESD check will fail on firmware reset. When ESD check is failed,
+ * it will reset firmware again. Skip ESD check to avoid double reset.
+ */
+ cd->ts_esd.skip_once = true;
+
gpio_direction_output(cd->board_data.reset_gpio, 0);
usleep_range(2000, 2100);
gpio_direction_output(cd->board_data.reset_gpio, 1);
@@ -344,7 +350,7 @@ static int brl_irq_enable(struct goodix_ts_core *cd, bool enable)
}
if (!enable && atomic_cmpxchg(&cd->irq_enabled, 1, 0)) {
- disable_irq_nosync(cd->irq);
+ disable_irq(cd->irq);
ts_debug("Irq disabled");
return 0;
}
@@ -352,6 +358,15 @@ static int brl_irq_enable(struct goodix_ts_core *cd, bool enable)
return 0;
}
+static int brl_disable_irq_nosync(struct goodix_ts_core *cd)
+{
+ if (atomic_cmpxchg(&cd->irq_enabled, 1, 0)) {
+ disable_irq_nosync(cd->irq);
+ ts_debug("Irq disabled");
+ }
+ return 0;
+}
+
static int brl_read(struct goodix_ts_core *cd, unsigned int addr,
unsigned char *data, unsigned int len)
{
@@ -1227,12 +1242,18 @@ static int brl_event_handler(
memset(ts_event, 0, sizeof(*ts_event));
ts_event->event_type = EVENT_INVALID;
- ts_event->clear_count = event_data->clear_count;
+ ts_event->clear_count1 = event_data->clear_count1;
+ ts_event->clear_count2 = event_data->clear_count2;
/* read status event */
- if (event_data->status_changed)
+ if (event_data->status_changed) {
hw_ops->read(cd, 0x1021C, (u8 *)&ts_event->status_data,
sizeof(ts_event->status_data));
+ if (ts_event->status_data.soft_reset_type == 0x04) {
+ ts_info("Touch - unexpected reset! Reason : WDT");
+ }
+ }
+
if (event_data->type & (GOODIX_TOUCH_EVENT >> 4))
return goodix_touch_handler(cd, ts_event,
(struct goodix_ts_touch_event_data *)event_data);
@@ -1600,6 +1621,7 @@ int brl_set_heatmap_enabled(struct goodix_ts_core *cd, bool enabled)
#define CUSTOM_MODE_MASK_PALM 0x02
#define CUSTOM_MODE_MASK_GRIP 0x04
#define CUSTOM_MODE_MASK_SCREEN_PROTECTOR 0x40
+#define CUSTOM_MODE_MASK_COORD_FILTER 0x80
int brl_set_palm_enabled(struct goodix_ts_core *cd, bool enabled)
{
struct goodix_ts_cmd cmd = { 0 };
@@ -1823,6 +1845,67 @@ exit:
return ret;
}
+#define GOODIX_CMD_SET_COORD_FILTER 0xCA
+static int brl_set_coord_filter_enabled(
+ struct goodix_ts_core *cd, bool enabled)
+{
+ struct goodix_ts_cmd cmd = { 0 };
+ int ret = 0;
+
+ cmd.cmd = GOODIX_CMD_SET_COORD_FILTER;
+ cmd.len = 5;
+ cmd.data[0] = enabled ? 0 : 1;
+
+ ret = cd->hw_ops->send_cmd(cd, &cmd);
+ if (ret != 0)
+ ts_err("failed to %s coordinate filter",
+ enabled ? "enable" : "disable");
+
+ return ret;
+}
+
+static int brl_get_coord_filter_enabled(
+ struct goodix_ts_core *cd, bool *enabled)
+{
+ int ret = 0;
+ u8 val;
+
+ ret = cd->hw_ops->read(cd, GOODIX_FEATURE_STATUS_ADDR, &val, 1);
+ if (ret != 0) {
+ ts_err("failed to get coordinate filter enabled, ret: %d", ret);
+ *enabled = false;
+ return ret;
+ }
+ *enabled = (val & CUSTOM_MODE_MASK_COORD_FILTER) == 0;
+ return ret;
+}
+
+#define GOODIX_CMD_SET_REPORT_RATE 0x9D
+#define GOODIX_REPORT_RATE_240HZ 0
+#define GOODIX_REPORT_RATE_120HZ 2
+static int brl_set_report_rate(
+ struct goodix_ts_core *cd, u32 rate)
+{
+ struct goodix_ts_cmd cmd = { 0 };
+ int ret = 0;
+
+ ts_info("set report rate %d", rate);
+ if ((rate != 120) && (rate != 240)) {
+ ts_info("Report Rate: %dHz is not support", rate);
+ return -EOPNOTSUPP;
+ }
+
+ cmd.cmd = GOODIX_CMD_SET_REPORT_RATE;
+ cmd.len = 5;
+ cmd.data[0] = rate == 240 ?
+ GOODIX_REPORT_RATE_240HZ : GOODIX_REPORT_RATE_120HZ;
+
+ ret = cd->hw_ops->send_cmd(cd, &cmd);
+ if (ret != 0)
+ ts_err("failed to set report rate");
+ return ret;
+}
+
static struct goodix_ts_hw_ops brl_hw_ops = {
.power_on = brl_power_on,
.resume = brl_resume,
@@ -1830,6 +1913,7 @@ static struct goodix_ts_hw_ops brl_hw_ops = {
.gesture = brl_gesture,
.reset = brl_reset,
.irq_enable = brl_irq_enable,
+ .disable_irq_nosync = brl_disable_irq_nosync,
.read = brl_read,
.read_fast = brl_read_fast,
.write = brl_write,
@@ -1857,6 +1941,9 @@ static struct goodix_ts_hw_ops brl_hw_ops = {
brl_get_screen_protector_mode_enabled,
.get_mutual_data = brl_get_mutual_data,
.get_self_sensing_data = brl_get_self_sensing_data,
+ .set_coord_filter_enabled = brl_set_coord_filter_enabled,
+ .get_coord_filter_enabled = brl_get_coord_filter_enabled,
+ .set_report_rate = brl_set_report_rate,
};
struct goodix_ts_hw_ops *goodix_get_hw_ops(void)
diff --git a/goodix_ts_core.c b/goodix_ts_core.c
index bf17f08..b4a8c7f 100644
--- a/goodix_ts_core.c
+++ b/goodix_ts_core.c
@@ -969,8 +969,7 @@ static int get_mutual_sensor_data(
cmd->buffer = (u8 *)cd->mutual_data;
cmd->size = tx * rx * sizeof(uint16_t);
} else {
- /* disable irq & close esd */
- cd->hw_ops->irq_enable(cd, false);
+ /* close esd */
goodix_ts_blocking_notify(NOTIFY_ESD_OFF, NULL);
ret = -EINVAL;
@@ -987,8 +986,7 @@ static int get_mutual_sensor_data(
cmd->size = tx * rx * sizeof(uint16_t);
}
- /* enable irq & esd */
- cd->hw_ops->irq_enable(cd, true);
+ /* enable esd */
goodix_ts_blocking_notify(NOTIFY_ESD_ON, NULL);
}
return ret;
@@ -1111,6 +1109,25 @@ static int get_screen_protector_mode(
return 0;
}
+static int set_coord_filter_enabled(void *private_data,
+ struct gti_coord_filter_cmd *cmd)
+{
+ struct goodix_ts_core *cd = private_data;
+ return cd->hw_ops->set_coord_filter_enabled(cd,
+ cmd->setting == GTI_COORD_FILTER_ENABLE);
+}
+
+static int get_coord_filter_enabled(void *private_data,
+ struct gti_coord_filter_cmd *cmd)
+{
+ struct goodix_ts_core *cd = private_data;
+ bool enabled = false;
+
+ cd->hw_ops->get_coord_filter_enabled(cd, &enabled);
+ cmd->setting = enabled ? GTI_COORD_FILTER_ENABLE : GTI_COORD_FILTER_DISABLE;
+ return 0;
+}
+
static int set_heatmap_enabled(
void *private_data, struct gti_heatmap_cmd *cmd)
{
@@ -1135,6 +1152,34 @@ static int gti_get_fw_version(void *private_data,
return ret;
}
+static int gti_set_irq_mode(void *private_data, struct gti_irq_cmd *cmd)
+{
+ struct goodix_ts_core *cd = private_data;
+ return cd->hw_ops->irq_enable(cd, cmd->setting == GTI_IRQ_MODE_ENABLE);
+}
+
+static int gti_get_irq_mode(void *private_data, struct gti_irq_cmd *cmd)
+{
+ struct goodix_ts_core *cd = private_data;
+
+ if (atomic_read(&cd->irq_enabled) == 1)
+ cmd->setting = GTI_IRQ_MODE_ENABLE;
+ else
+ cmd->setting = GTI_IRQ_MODE_DISABLE;
+
+ return 0;
+}
+
+static int gti_reset(void *private_data, struct gti_reset_cmd *cmd)
+{
+ struct goodix_ts_core *cd = private_data;
+
+ if (cmd->setting == GTI_RESET_MODE_HW || cmd->setting == GTI_RESET_MODE_AUTO)
+ return cd->hw_ops->reset(cd, GOODIX_NORMAL_RESET_DELAY_MS);
+ else
+ return -EOPNOTSUPP;
+}
+
static int gti_ping(void *private_data, struct gti_ping_cmd *cmd)
{
struct goodix_ts_core *cd = private_data;
@@ -1147,6 +1192,20 @@ static int gti_selftest(void *private_data, struct gti_selftest_cmd *cmd)
return driver_test_selftest(cmd->buffer);
}
+static int gti_get_context_driver(void *private_data,
+ struct gti_context_driver_cmd *cmd)
+{
+ /* There is no context from this driver. */
+ return 0;
+}
+
+static int gti_set_report_rate(void *private_data,
+ struct gti_report_rate_cmd *cmd)
+{
+ struct goodix_ts_core *cd = private_data;
+ return cd->hw_ops->set_report_rate(cd, cmd->setting);
+}
+
#endif
/* prosfs create */
@@ -1840,10 +1899,13 @@ void goodix_ts_report_status(struct goodix_ts_core *core_data,
st->grip_change, st->noise_lv_change, st->palm_change,
st->soft_reset, st->base_update, st->hop_change,
st->water_change);
- ts_info("water_status[%d] before_factorA[%d] after_factorA[%d] base_update_type[0x%x] soft_reset_type[0x%x] palm_status[%d] noise_lv[%d] grip_type[%d] event_id[%d] clear_count[%d]",
- st->water_sta, st->before_factorA, st->after_factorA,
- st->base_update_type, st->soft_reset_type, st->palm_sta,
- st->noise_lv, st->grip_type, st->event_id, ts_event->clear_count);
+ ts_info("water_status[%d] before_factorA[%d] after_factorA[%d]" \
+ " base_update_type[0x%x] soft_reset_type[0x%x] palm_status[%d]" \
+ " noise_lv[%d] grip_type[%d] event_id[%d] clear_count1[%d]" \
+ " clear_count2[%d]", st->water_sta, st->before_factorA,
+ st->after_factorA, st->base_update_type, st->soft_reset_type,
+ st->palm_sta, st->noise_lv, st->grip_type, st->event_id,
+ ts_event->clear_count1, ts_event->clear_count2);
#if IS_ENABLED(CONFIG_GOOG_TOUCH_INTERFACE)
if (st->soft_reset)
goog_notify_fw_status_changed(core_data->gti, GTI_FW_STATUS_RESET,
@@ -1861,6 +1923,12 @@ void goodix_ts_report_status(struct goodix_ts_core *core_data,
&status_data);
}
+ if (st->water_change) {
+ goog_notify_fw_status_changed(core_data->gti,
+ st->water_sta ? GTI_FW_STATUS_WATER_ENTER :
+ GTI_FW_STATUS_WATER_EXIT, &status_data);
+ }
+
if (st->noise_lv_change) {
status_data.noise_level = st->noise_lv;
goog_notify_fw_status_changed(core_data->gti, GTI_FW_STATUS_NOISE_MODE,
@@ -1886,15 +1954,12 @@ static irqreturn_t goodix_ts_threadirq_func(int irq, void *data)
struct goodix_ts_esd *ts_esd = &core_data->ts_esd;
int ret;
-#if IS_ENABLED(CONFIG_GOOG_TOUCH_INTERFACE) && IS_ENABLED(CONFIG_GTI_PM)
- ret = goog_pm_wake_lock(core_data->gti, GTI_PM_WAKELOCK_TYPE_IRQ, true);
- if(ret < 0) {
- ts_err("Error while obtaining IRQ wakelock: %d!\n", ret);
- return IRQ_HANDLED;
- }
-#endif
+ /*
+ * Since we received an interrupt from touch firmware, it means touch
+ * firmware is still alive. So skip esd check once.
+ */
+ ts_esd->skip_once = true;
- ts_esd->irq_status = true;
core_data->irq_trig_cnt++;
/* inform external module */
mutex_lock(&goodix_modules.mutex);
@@ -1905,9 +1970,6 @@ static irqreturn_t goodix_ts_threadirq_func(int irq, void *data)
ret = ext_module->funcs->irq_event(core_data, ext_module);
if (ret == EVT_CANCEL_IRQEVT) {
mutex_unlock(&goodix_modules.mutex);
-#if IS_ENABLED(CONFIG_GOOG_TOUCH_INTERFACE) && IS_ENABLED(CONFIG_GTI_PM)
- goog_pm_wake_unlock_nosync(core_data->gti, GTI_PM_WAKELOCK_TYPE_IRQ);
-#endif
return IRQ_HANDLED;
}
}
@@ -1944,10 +2006,6 @@ static irqreturn_t goodix_ts_threadirq_func(int irq, void *data)
hw_ops->after_event_handler(core_data);
}
-#if IS_ENABLED(CONFIG_GOOG_TOUCH_INTERFACE) && IS_ENABLED(CONFIG_GTI_PM)
- goog_pm_wake_unlock_nosync(core_data->gti, GTI_PM_WAKELOCK_TYPE_IRQ);
-#endif
-
return IRQ_HANDLED;
}
@@ -2308,7 +2366,7 @@ static void goodix_ts_esd_work(struct work_struct *work)
const struct goodix_ts_hw_ops *hw_ops = cd->hw_ops;
int ret = 0;
- if (ts_esd->irq_status)
+ if (ts_esd->skip_once)
goto exit;
if (!atomic_read(&ts_esd->esd_on) || atomic_read(&cd->suspended))
@@ -2339,7 +2397,7 @@ static void goodix_ts_esd_work(struct work_struct *work)
}
exit:
- ts_esd->irq_status = false;
+ ts_esd->skip_once = false;
if (atomic_read(&ts_esd->esd_on))
schedule_delayed_work(&ts_esd->esd_work, 2 * HZ);
}
@@ -2483,7 +2541,7 @@ static int goodix_ts_suspend(struct goodix_ts_core *core_data)
ts_info("Suspend start");
atomic_set(&core_data->suspended, 1);
/* disable irq */
- hw_ops->irq_enable(core_data, false);
+ hw_ops->disable_irq_nosync(core_data);
/*
* notify suspend event, inform the esd protector
@@ -2865,10 +2923,17 @@ int goodix_ts_stage2_init(struct goodix_ts_core *cd)
options->get_palm_mode = get_palm_mode;
options->set_screen_protector_mode = set_screen_protector_mode;
options->get_screen_protector_mode = get_screen_protector_mode;
+ options->set_coord_filter_enabled = set_coord_filter_enabled;
+ options->get_coord_filter_enabled = get_coord_filter_enabled;
options->set_heatmap_enabled = set_heatmap_enabled;
options->get_fw_version = gti_get_fw_version;
+ options->set_irq_mode = gti_set_irq_mode;
+ options->get_irq_mode = gti_get_irq_mode;
+ options->reset = gti_reset;
options->ping = gti_ping;
options->selftest = gti_selftest;
+ options->get_context_driver = gti_get_context_driver;
+ options->set_report_rate = gti_set_report_rate;
cd->gti = goog_touch_interface_probe(
cd, cd->bus->dev, cd->input_dev, gti_default_handler, options);
diff --git a/goodix_ts_core.h b/goodix_ts_core.h
index 1bdc826..4da22cb 100644
--- a/goodix_ts_core.h
+++ b/goodix_ts_core.h
@@ -47,11 +47,16 @@
#if IS_ENABLED(CONFIG_GOOG_TOUCH_INTERFACE)
#include <goog_touch_interface.h>
#endif
+#if IS_ENABLED(CONFIG_VH_SYSTRACE)
#include "../../../gs-google/drivers/soc/google/vh/kernel/systrace.h"
+#else
+#define ATRACE_BEGIN(f)
+#define ATRACE_END()
+#endif
#define GOODIX_CORE_DRIVER_NAME "goodix_ts"
#define GOODIX_PEN_DRIVER_NAME "goodix_ts,pen"
-#define GOODIX_DRIVER_VERSION "v1.2.2"
+#define GOODIX_DRIVER_VERSION "v1.2.4"
#define GOODIX_MAX_TOUCH 10
#define GOODIX_PEN_MAX_PRESSURE 4096
#define GOODIX_MAX_PEN_KEY 2
@@ -500,13 +505,16 @@ struct goodix_pen_data {
/*
* struct goodix_ts_event - touch event struct
+ * @clear_count1: clear count for old firmware
+ * @clear_count2: clear count for latest firmware
* @event_type: touch event type, touch data or
* request event
* @event_data: event data
*/
struct goodix_ts_event {
enum ts_event_type event_type;
- u8 clear_count;
+ u8 clear_count1;
+ u8 clear_count2;
u8 fp_flag; /* finger print DOWN flag */
u8 request_code; /* represent the request type */
u8 request_data[GOODIX_REQUEST_DATA_LEN];
@@ -525,7 +533,10 @@ struct goodix_ts_event_data {
u8 int_count;
u8 reserved3;
u8 reserved4 : 4;
- u8 clear_count : 4;
+ u8 clear_count1 : 4;
+ u8 reserved5;
+ u8 reserved6 : 4;
+ u8 clear_count2 : 4;
};
struct goodix_ts_request_event_data {
@@ -557,8 +568,10 @@ struct goodix_ts_touch_event_data {
u8 reset_int : 1;
u8 custom_coor_info_flag : 1;
u8 reserved3 : 3;
- u8 clear_count : 4;
- u16 reserved4;
+ u8 clear_count1 : 4;
+ u8 reserved4;
+ u8 reserved5 : 4;
+ u8 clear_count2 : 4;
u16 checksum;
u8 data[0];
};
@@ -634,6 +647,7 @@ struct goodix_ts_hw_ops {
int (*gesture)(struct goodix_ts_core *cd, int gesture_type);
int (*reset)(struct goodix_ts_core *cd, int delay_ms);
int (*irq_enable)(struct goodix_ts_core *cd, bool enable);
+ int (*disable_irq_nosync)(struct goodix_ts_core *cd);
int (*read)(struct goodix_ts_core *cd, unsigned int addr,
unsigned char *data, unsigned int len);
int (*read_fast)(struct goodix_ts_core *cd, unsigned int addr,
@@ -672,6 +686,11 @@ struct goodix_ts_hw_ops {
struct goodix_ts_core *cd, enum frame_data_type type);
int (*get_self_sensing_data)(
struct goodix_ts_core *cd, enum frame_data_type type);
+ int (*set_coord_filter_enabled)(
+ struct goodix_ts_core *cd, bool enabled);
+ int (*get_coord_filter_enabled)(
+ struct goodix_ts_core *cd, bool* enabled);
+ int (*set_report_rate)(struct goodix_ts_core *cd, u32 rate);
};
/*
@@ -679,9 +698,10 @@ struct goodix_ts_hw_ops {
* @esd_work: esd delayed work
* @esd_on: 1 - turn on esd protection, 0 - turn
* off esd protection
+ * @skip_once: skip once if the check is no need this time.
*/
struct goodix_ts_esd {
- bool irq_status;
+ bool skip_once;
atomic_t esd_on;
struct delayed_work esd_work;
struct notifier_block esd_notifier;
diff --git a/goodix_ts_proc.c b/goodix_ts_proc.c
index 41d1032..a8ed02f 100644
--- a/goodix_ts_proc.c
+++ b/goodix_ts_proc.c
@@ -50,6 +50,7 @@
#define CMD_GET_DUMP_LOG "get_dump_log"
#define CMD_GET_STYLUS_DATA "get_stylus_data"
#define CMD_SET_FREQ_INDEX "set_freq_index"
+#define CMD_DISABLE_FILTER "disable_filter"
char *cmd_list[] = { CMD_FW_UPDATE, CMD_AUTO_TEST, CMD_OPEN_TEST,
CMD_SELF_OPEN_TEST, CMD_NOISE_TEST, CMD_AUTO_NOISE_TEST, CMD_SHORT_TEST,
@@ -65,7 +66,7 @@ char *cmd_list[] = { CMD_FW_UPDATE, CMD_AUTO_TEST, CMD_OPEN_TEST,
CMD_SET_GRIP_MODE, CMD_SET_PALM_MODE, CMD_SET_NOISE_MODE,
CMD_SET_WATER_MODE, CMD_SET_HEATMAP, CMD_GET_SELF_COMPEN,
CMD_SET_REPORT_RATE, CMD_GET_DUMP_LOG, CMD_GET_STYLUS_DATA,
- CMD_SET_FREQ_INDEX, NULL };
+ CMD_SET_FREQ_INDEX, CMD_DISABLE_FILTER, NULL };
/* test limits keyword */
#define CSV_TP_SPECIAL_RAW_MIN "special_raw_min"
@@ -448,23 +449,23 @@ static int cal_cha_to_gnd_res(int v)
static int malloc_test_resource(void)
{
- ts_test = kzalloc(sizeof(*ts_test), GFP_KERNEL);
+ ts_test = vzalloc(sizeof(*ts_test));
if (!ts_test)
return -ENOMEM;
if (raw_data_cnt > 0) {
- ts_test->rawdata = kcalloc(raw_data_cnt,
- sizeof(struct ts_test_rawdata), GFP_KERNEL);
+ ts_test->rawdata =
+ vzalloc(raw_data_cnt * sizeof(struct ts_test_rawdata));
if (ts_test->rawdata == NULL)
return -ENOMEM;
- ts_test->deltadata = kcalloc(raw_data_cnt,
- sizeof(struct ts_test_rawdata), GFP_KERNEL);
+ ts_test->deltadata =
+ vzalloc(raw_data_cnt * sizeof(struct ts_test_rawdata));
if (ts_test->deltadata == NULL)
return -ENOMEM;
}
if (noise_data_cnt > 0) {
- ts_test->noisedata = kcalloc(noise_data_cnt,
- sizeof(struct ts_test_rawdata), GFP_KERNEL);
+ ts_test->noisedata = vzalloc(
+ noise_data_cnt * sizeof(struct ts_test_rawdata));
if (ts_test->noisedata == NULL)
return -ENOMEM;
}
@@ -475,10 +476,10 @@ static int malloc_test_resource(void)
static void release_test_resource(void)
{
if (ts_test) {
- kfree(ts_test->rawdata);
- kfree(ts_test->deltadata);
- kfree(ts_test->noisedata);
- kfree(ts_test);
+ vfree(ts_test->rawdata);
+ vfree(ts_test->deltadata);
+ vfree(ts_test->noisedata);
+ vfree(ts_test);
ts_test = NULL;
}
raw_data_cnt = 0;
@@ -1209,7 +1210,7 @@ static void seq_stop(struct seq_file *s, void *v)
{
if (s->read_pos >= index) {
// ts_info("read_pos:%d", (int)s->read_pos);
- kfree(rbuf);
+ vfree(rbuf);
rbuf = NULL;
index = 0;
release_test_resource();
@@ -2593,6 +2594,8 @@ static void goodix_get_fw_status(void)
cd->hw_ops->read(cd, 0x1021A, &val, 1);
index += sprintf(
+ &rbuf[index], "coordfilter_status[%d] ", (val >> 7) & 0x01);
+ index += sprintf(
&rbuf[index], "set_highsense_mode[%d] ", (val >> 6) & 0x01);
index +=
sprintf(&rbuf[index], "set_noise_mode[%d] ", (val >> 4) & 0x03);
@@ -3010,7 +3013,7 @@ static void goodix_get_dump_log(void)
static void goodix_get_stylus_data(void)
{
struct goodix_stylus_data stylus_data;
- u8 temp_buf[40] = {0};
+ u8 temp_buf[40] = { 0 };
u32 flag_addr = cd->ic_info.misc.touch_data_addr;
int tx = cd->ic_info.parm.drv_num;
int rx = cd->ic_info.parm.sen_num;
@@ -3071,10 +3074,11 @@ static void goodix_get_stylus_data(void)
angle_y = le16_to_cpup((__le16 *)(temp_buf + 18)) / 100;
stylus_struct_addr = cd->ic_info.misc.frame_data_addr +
- cd->ic_info.misc.frame_data_head_len +
- cd->ic_info.misc.fw_attr_len +
- cd->ic_info.misc.fw_log_len;
- ret = cd->hw_ops->read(cd, stylus_struct_addr, (u8 *)&stylus_data, sizeof(stylus_data));
+ cd->ic_info.misc.frame_data_head_len +
+ cd->ic_info.misc.fw_attr_len +
+ cd->ic_info.misc.fw_log_len;
+ ret = cd->hw_ops->read(
+ cd, stylus_struct_addr, (u8 *)&stylus_data, sizeof(stylus_data));
if (ret < 0) {
ts_err("read stylus struct data failed");
goto exit;
@@ -3160,6 +3164,17 @@ static void goodix_set_freq_index(int freq)
cd->hw_ops->send_cmd(cd, &temp_cmd);
}
+static void goodix_disable_coor_filter(int val)
+{
+ struct goodix_ts_cmd temp_cmd;
+
+ index = sprintf(rbuf, "disable coordinate filter %d\n", val);
+ temp_cmd.len = 5;
+ temp_cmd.cmd = 0xCA;
+ temp_cmd.data[0] = val ? 1 : 0;
+ cd->hw_ops->send_cmd(cd, &temp_cmd);
+}
+
static ssize_t driver_test_write(
struct file *file, const char __user *buf, size_t count, loff_t *pos)
{
@@ -3183,7 +3198,7 @@ static ssize_t driver_test_write(
return count;
}
- kfree(rbuf);
+ vfree(rbuf);
rbuf = NULL;
index = 0;
release_test_resource();
@@ -3191,13 +3206,13 @@ static ssize_t driver_test_write(
ts_info("input cmd[%s]", p);
if (!strncmp(p, CMD_FW_UPDATE, strlen(CMD_FW_UPDATE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
goodix_force_update();
goto exit;
}
if (!strncmp(p, CMD_GET_VERSION, strlen(CMD_GET_VERSION))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3212,7 +3227,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_RAWDATA, strlen(CMD_GET_RAWDATA))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3225,7 +3240,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_BASEDATA, strlen(CMD_GET_BASEDATA))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3238,7 +3253,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_DIFFDATA, strlen(CMD_GET_DIFFDATA))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3251,7 +3266,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_SELF_RAWDATA, strlen(CMD_GET_SELF_RAWDATA))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3264,7 +3279,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_SELF_DIFFDATA, strlen(CMD_GET_SELF_DIFFDATA))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3278,7 +3293,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_SELF_BASEDATA, strlen(CMD_GET_SELF_BASEDATA))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3292,7 +3307,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_DOUBLE_TAP, strlen(CMD_SET_DOUBLE_TAP))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3323,7 +3338,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_SINGLE_TAP, strlen(CMD_SET_SINGLE_TAP))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3354,7 +3369,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_LONG_PRESS, strlen(CMD_SET_LONG_PRESS))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3385,7 +3400,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_IRQ_ENABLE, strlen(CMD_SET_IRQ_ENABLE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3414,7 +3429,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_ESD_ENABLE, strlen(CMD_SET_ESD_ENABLE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3443,7 +3458,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_DEBUG_LOG, strlen(CMD_SET_DEBUG_LOG))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3474,7 +3489,7 @@ static ssize_t driver_test_write(
if (!strncmp(p, CMD_AUTO_TEST, strlen(CMD_AUTO_TEST))) {
raw_data_cnt = 16;
noise_data_cnt = 1;
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3494,7 +3509,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_CHANNEL_NUM, strlen(CMD_GET_CHANNEL_NUM))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3505,7 +3520,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_TX_FREQ, strlen(CMD_GET_TX_FREQ))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3525,7 +3540,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_SENSE_MODE, strlen(CMD_SET_SENSE_MODE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3561,7 +3576,7 @@ static ssize_t driver_test_write(
goto exit;
}
noise_data_cnt = cmd_val;
- rbuf = kzalloc(noise_data_cnt * 2000 + 5000, GFP_KERNEL);
+ rbuf = vzalloc(noise_data_cnt * 2000 + 5000);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3595,7 +3610,7 @@ static ssize_t driver_test_write(
ts_err("%s: invalid cmd param", CMD_AUTO_NOISE_TEST);
goto exit;
}
- rbuf = kzalloc(HUGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(HUGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3605,7 +3620,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_PACKAGE_ID, strlen(CMD_GET_PACKAGE_ID))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3623,7 +3638,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_MCU_ID, strlen(CMD_GET_MCU_ID))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3640,7 +3655,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_SCAN_MODE, strlen(CMD_SET_SCAN_MODE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3666,7 +3681,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_SCAN_MODE, strlen(CMD_GET_SCAN_MODE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3676,7 +3691,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_CONTINUE_MODE, strlen(CMD_SET_CONTINUE_MODE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3722,7 +3737,7 @@ static ssize_t driver_test_write(
goto exit;
}
raw_data_cnt = cmd_val;
- rbuf = kzalloc(raw_data_cnt * 5000 + 10000, GFP_KERNEL);
+ rbuf = vzalloc(raw_data_cnt * 5000 + 10000);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3739,7 +3754,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SELF_OPEN_TEST, strlen(CMD_SELF_OPEN_TEST))) {
- rbuf = kzalloc(HUGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(HUGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3755,7 +3770,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SHORT_TEST, strlen(CMD_SHORT_TEST))) {
- rbuf = kzalloc(HUGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(HUGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3771,7 +3786,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_CONFIG, strlen(CMD_GET_CONFIG))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3781,7 +3796,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_FW_STATUS, strlen(CMD_GET_FW_STATUS))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3792,7 +3807,7 @@ static ssize_t driver_test_write(
if (!strncmp(p, CMD_SET_HIGHSENSE_MODE,
strlen(CMD_SET_HIGHSENSE_MODE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3818,7 +3833,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_GRIP_DATA, strlen(CMD_SET_GRIP_DATA))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3839,7 +3854,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_GRIP_MODE, strlen(CMD_SET_GRIP_MODE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3860,7 +3875,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_PALM_MODE, strlen(CMD_SET_PALM_MODE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3881,7 +3896,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_NOISE_MODE, strlen(CMD_SET_NOISE_MODE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3902,7 +3917,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_WATER_MODE, strlen(CMD_SET_WATER_MODE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3923,7 +3938,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_ST_PARAM, strlen(CMD_SET_ST_PARAM))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3940,7 +3955,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_LP_PARAM, strlen(CMD_SET_LP_PARAM))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3957,7 +3972,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_HEATMAP, strlen(CMD_SET_HEATMAP))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3978,7 +3993,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_SELF_COMPEN, strlen(CMD_GET_SELF_COMPEN))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -3988,7 +4003,7 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_SET_REPORT_RATE, strlen(CMD_SET_REPORT_RATE))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -4009,25 +4024,25 @@ static ssize_t driver_test_write(
}
if (!strncmp(p, CMD_GET_DUMP_LOG, strlen(CMD_GET_DUMP_LOG))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
goodix_get_dump_log();
goto exit;
}
if (!strncmp(p, CMD_GET_STYLUS_DATA, strlen(CMD_GET_STYLUS_DATA))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
goodix_get_stylus_data();
goto exit;
}
if (!strncmp(p, CMD_GET_STYLUS_DATA, strlen(CMD_GET_STYLUS_DATA))) {
- rbuf = kzalloc(LARGE_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(LARGE_SIZE);
goodix_get_stylus_data();
goto exit;
}
if (!strncmp(p, CMD_SET_FREQ_INDEX, strlen(CMD_SET_FREQ_INDEX))) {
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
token = strsep(&p, ",");
if (!token || !p) {
index = sprintf(rbuf, "%s: invalid cmd param\n",
@@ -4043,7 +4058,24 @@ static ssize_t driver_test_write(
goto exit;
}
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ if (!strncmp(p, CMD_DISABLE_FILTER, strlen(CMD_DISABLE_FILTER))) {
+ rbuf = vzalloc(SHORT_SIZE);
+ token = strsep(&p, ",");
+ if (!token || !p) {
+ index = sprintf(rbuf, "%s: invalid cmd param\n",
+ CMD_DISABLE_FILTER);
+ goto exit;
+ }
+ if (kstrtos32(p, 10, &cmd_val)) {
+ index = sprintf(rbuf, "%s: invalid cmd param\n",
+ CMD_DISABLE_FILTER);
+ goto exit;
+ }
+ goodix_disable_coor_filter(cmd_val);
+ goto exit;
+ }
+
+ rbuf = vzalloc(SHORT_SIZE);
if (!rbuf) {
ts_err("failed to alloc rbuf");
goto exit;
@@ -4113,13 +4145,13 @@ int driver_test_selftest(char* buf)
release_test_resource();
index = 0;
if (rbuf != NULL) {
- kfree(rbuf);
+ vfree(rbuf);
rbuf = NULL;
}
raw_data_cnt = 16;
noise_data_cnt = 1;
- rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL);
+ rbuf = vzalloc(SHORT_SIZE);
if (rbuf == NULL) {
ts_err("failed to alloc rbuf");
ret = -ENOMEM;