DLKM: touch: Improve novatek 0flash driver

- Add dts configuration for change different resultion accroding
to different projects.

Change-Id: I5cb65dbeee24a450296c09a5df5145c017933fe0
Signed-off-by: wengjun1 <wengjun1@motorola.com>
Reviewed-on: https://gerrit.mot.com/1413351
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Jialei Hao <haojl2@motorola.com>
Reviewed-by: Yeqing Wang <wangyq13@motorola.com>
Reviewed-by: Hujun Liao <liaohj@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
wengjun1 2019-08-30 17:32:17 +08:00 • committed by Jun Weng
commit a372d9688e
2 changed files with 38 additions and 3 deletions

View file

@ -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) {

View file

@ -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