From a372d9688e06fb60dd977a5eff63d197afb0f353 Mon Sep 17 00:00:00 2001 From: wengjun1 Date: Fri, 30 Aug 2019 17:32:17 +0800 Subject: [PATCH] DLKM: touch: Improve novatek 0flash driver - Add dts configuration for change different resultion accroding to different projects. Change-Id: I5cb65dbeee24a450296c09a5df5145c017933fe0 Signed-off-by: wengjun1 Reviewed-on: https://gerrit.mot.com/1413351 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Jialei Hao Reviewed-by: Yeqing Wang Reviewed-by: Hujun Liao Submit-Approved: Jira Key --- .../touchscreen/nova_0flash_mmi/nt36xxx.c | 40 +++++++++++++++++-- .../touchscreen/nova_0flash_mmi/nt36xxx.h | 1 + 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c index c4f715263199..4deac63fc507 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c +++ b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c @@ -991,6 +991,36 @@ return: n.a. *******************************************************/ #ifdef CONFIG_OF +static int nvt_get_dt_def_coords(struct device *dev, char *name) +{ + u32 coords[TOUCH_COORDS_ARR_SIZE]; + struct property *prop; + struct device_node *np = dev->of_node; + int coords_size, rc; + + prop = of_find_property(np, name, NULL); + if (!prop) + return -EINVAL; + if (!prop->value) + return -ENODATA; + + coords_size = prop->length / sizeof(u32); + if (coords_size != TOUCH_COORDS_ARR_SIZE) { + dev_err(dev, "invalid %s\n", name); + return -EINVAL; + } + + rc = of_property_read_u32_array(np, name, coords, coords_size); + if (rc && (rc != -EINVAL)) { + NVT_LOG("Unable to read novatek,def-max-resolution\n"); + return rc; + } + + ts->abs_x_max = coords[0]; + ts->abs_y_max = coords[1]; + return rc; +} + static int32_t nvt_parse_dt(struct device *dev) { struct device_node *np = dev->of_node; @@ -1011,6 +1041,13 @@ static int32_t nvt_parse_dt(struct device *dev) NVT_LOG("SWRST_N8_ADDR=0x%06X\n", SWRST_N8_ADDR); } + ret = nvt_get_dt_def_coords(dev, "novatek,def-max-resolution"); + if (ret) { + ts->abs_x_max = TOUCH_DEFAULT_MAX_WIDTH; + ts->abs_y_max = TOUCH_DEFAULT_MAX_HEIGHT; + } + NVT_LOG("novatek,def-max-resolution=%d,%d\n", ts->abs_x_max, ts->abs_y_max); + ret = of_property_read_u32(np, "novatek,spi-rd-fast-addr", &SPI_RD_FAST_ADDR); if (ret) { NVT_LOG("not support novatek,spi-rd-fast-addr\n"); @@ -1550,9 +1587,6 @@ static int32_t nvt_ts_probe(struct spi_device *client) goto err_chipvertrim_failed; } - ts->abs_x_max = TOUCH_DEFAULT_MAX_WIDTH; - ts->abs_y_max = TOUCH_DEFAULT_MAX_HEIGHT; - //---allocate input device--- ts->input_dev = input_allocate_device(); if (ts->input_dev == NULL) { diff --git a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h index 3b1142a12a15..7a4867f17d85 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h +++ b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h @@ -67,6 +67,7 @@ //---Touch info.--- +#define TOUCH_COORDS_ARR_SIZE 2 #define TOUCH_DEFAULT_MAX_WIDTH 720 #define TOUCH_DEFAULT_MAX_HEIGHT 1560 #define TOUCH_MAX_FINGER_NUM 10