diff options
author | Nick Dyer <nick@shmanahar.org> | 2016-07-18 17:10:33 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-08-23 15:31:39 -0400 |
commit | 2786489f324e8384a814793d88c3a76d1973f422 (patch) | |
tree | 14969e38fe9c74ff51e5bdf07ebb6628ac258d3c /drivers/input | |
parent | ecfdd7e2660e5208072d3afaed8c3e05a643b64f (diff) |
[media] Input: atmel_mxt_ts - read touchscreen size
The touchscreen may have a margin where not all the matrix is used. Read
the parameters from T9 and T100 and take account of the difference.
Note: this does not read the XORIGIN/YORIGIN fields so it assumes that
the touchscreen starts at (0,0)
Signed-off-by: Nick Dyer <nick@shmanahar.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index a9f987b59f9a..29be261a4750 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -103,6 +103,8 @@ struct t7_config { | |||
103 | 103 | ||
104 | /* MXT_TOUCH_MULTI_T9 field */ | 104 | /* MXT_TOUCH_MULTI_T9 field */ |
105 | #define MXT_T9_CTRL 0 | 105 | #define MXT_T9_CTRL 0 |
106 | #define MXT_T9_XSIZE 3 | ||
107 | #define MXT_T9_YSIZE 4 | ||
106 | #define MXT_T9_ORIENT 9 | 108 | #define MXT_T9_ORIENT 9 |
107 | #define MXT_T9_RANGE 18 | 109 | #define MXT_T9_RANGE 18 |
108 | 110 | ||
@@ -150,7 +152,9 @@ struct t37_debug { | |||
150 | #define MXT_T100_CTRL 0 | 152 | #define MXT_T100_CTRL 0 |
151 | #define MXT_T100_CFG1 1 | 153 | #define MXT_T100_CFG1 1 |
152 | #define MXT_T100_TCHAUX 3 | 154 | #define MXT_T100_TCHAUX 3 |
155 | #define MXT_T100_XSIZE 9 | ||
153 | #define MXT_T100_XRANGE 13 | 156 | #define MXT_T100_XRANGE 13 |
157 | #define MXT_T100_YSIZE 20 | ||
154 | #define MXT_T100_YRANGE 24 | 158 | #define MXT_T100_YRANGE 24 |
155 | 159 | ||
156 | #define MXT_T100_CFG_SWITCHXY BIT(5) | 160 | #define MXT_T100_CFG_SWITCHXY BIT(5) |
@@ -259,6 +263,8 @@ struct mxt_data { | |||
259 | unsigned int max_x; | 263 | unsigned int max_x; |
260 | unsigned int max_y; | 264 | unsigned int max_y; |
261 | bool xy_switch; | 265 | bool xy_switch; |
266 | u8 xsize; | ||
267 | u8 ysize; | ||
262 | bool in_bootloader; | 268 | bool in_bootloader; |
263 | u16 mem_size; | 269 | u16 mem_size; |
264 | u8 t100_aux_ampl; | 270 | u8 t100_aux_ampl; |
@@ -1714,6 +1720,18 @@ static int mxt_read_t9_resolution(struct mxt_data *data) | |||
1714 | return -EINVAL; | 1720 | return -EINVAL; |
1715 | 1721 | ||
1716 | error = __mxt_read_reg(client, | 1722 | error = __mxt_read_reg(client, |
1723 | object->start_address + MXT_T9_XSIZE, | ||
1724 | sizeof(data->xsize), &data->xsize); | ||
1725 | if (error) | ||
1726 | return error; | ||
1727 | |||
1728 | error = __mxt_read_reg(client, | ||
1729 | object->start_address + MXT_T9_YSIZE, | ||
1730 | sizeof(data->ysize), &data->ysize); | ||
1731 | if (error) | ||
1732 | return error; | ||
1733 | |||
1734 | error = __mxt_read_reg(client, | ||
1717 | object->start_address + MXT_T9_RANGE, | 1735 | object->start_address + MXT_T9_RANGE, |
1718 | sizeof(range), &range); | 1736 | sizeof(range), &range); |
1719 | if (error) | 1737 | if (error) |
@@ -1763,6 +1781,18 @@ static int mxt_read_t100_config(struct mxt_data *data) | |||
1763 | 1781 | ||
1764 | data->max_y = get_unaligned_le16(&range_y); | 1782 | data->max_y = get_unaligned_le16(&range_y); |
1765 | 1783 | ||
1784 | error = __mxt_read_reg(client, | ||
1785 | object->start_address + MXT_T100_XSIZE, | ||
1786 | sizeof(data->xsize), &data->xsize); | ||
1787 | if (error) | ||
1788 | return error; | ||
1789 | |||
1790 | error = __mxt_read_reg(client, | ||
1791 | object->start_address + MXT_T100_YSIZE, | ||
1792 | sizeof(data->ysize), &data->ysize); | ||
1793 | if (error) | ||
1794 | return error; | ||
1795 | |||
1766 | /* read orientation config */ | 1796 | /* read orientation config */ |
1767 | error = __mxt_read_reg(client, | 1797 | error = __mxt_read_reg(client, |
1768 | object->start_address + MXT_T100_CFG1, | 1798 | object->start_address + MXT_T100_CFG1, |
@@ -2121,7 +2151,7 @@ static int mxt_convert_debug_pages(struct mxt_data *data, u16 *outbuf) | |||
2121 | outbuf[i] = mxt_get_debug_value(data, x, y); | 2151 | outbuf[i] = mxt_get_debug_value(data, x, y); |
2122 | 2152 | ||
2123 | /* Next value */ | 2153 | /* Next value */ |
2124 | if (++x >= data->info.matrix_xsize) { | 2154 | if (++x >= data->xsize) { |
2125 | x = 0; | 2155 | x = 0; |
2126 | y++; | 2156 | y++; |
2127 | } | 2157 | } |
@@ -2276,8 +2306,8 @@ static int mxt_set_input(struct mxt_data *data, unsigned int i) | |||
2276 | if (i > 0) | 2306 | if (i > 0) |
2277 | return -EINVAL; | 2307 | return -EINVAL; |
2278 | 2308 | ||
2279 | f->width = data->info.matrix_xsize; | 2309 | f->width = data->xsize; |
2280 | f->height = data->info.matrix_ysize; | 2310 | f->height = data->ysize; |
2281 | f->pixelformat = V4L2_TCH_FMT_DELTA_TD16; | 2311 | f->pixelformat = V4L2_TCH_FMT_DELTA_TD16; |
2282 | f->field = V4L2_FIELD_NONE; | 2312 | f->field = V4L2_FIELD_NONE; |
2283 | f->colorspace = V4L2_COLORSPACE_RAW; | 2313 | f->colorspace = V4L2_COLORSPACE_RAW; |
@@ -2392,9 +2422,9 @@ static void mxt_debug_init(struct mxt_data *data) | |||
2392 | dbg->t37_address = object->start_address; | 2422 | dbg->t37_address = object->start_address; |
2393 | 2423 | ||
2394 | /* Calculate size of data and allocate buffer */ | 2424 | /* Calculate size of data and allocate buffer */ |
2395 | dbg->t37_nodes = data->info.matrix_xsize * data->info.matrix_ysize; | 2425 | dbg->t37_nodes = data->xsize * data->ysize; |
2396 | dbg->t37_pages = DIV_ROUND_UP(dbg->t37_nodes * sizeof(u16), | 2426 | dbg->t37_pages = DIV_ROUND_UP(data->xsize * data->info.matrix_ysize * |
2397 | sizeof(dbg->t37_buf->data)); | 2427 | sizeof(u16), sizeof(dbg->t37_buf->data)); |
2398 | 2428 | ||
2399 | dbg->t37_buf = devm_kmalloc_array(&data->client->dev, dbg->t37_pages, | 2429 | dbg->t37_buf = devm_kmalloc_array(&data->client->dev, dbg->t37_pages, |
2400 | sizeof(struct t37_debug), GFP_KERNEL); | 2430 | sizeof(struct t37_debug), GFP_KERNEL); |