diff options
author | Nick Dyer <nick@shmanahar.org> | 2016-07-18 17:10:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-08-23 15:32:29 -0400 |
commit | 566d533a4bd2ed9a7ce26a08df31a6e634051562 (patch) | |
tree | 3b4bd9f23d26df9b5f7a8a6ac716bdd3f1126fe2 /drivers/input | |
parent | de601f71e7d1bdfa411e61d43af7b2b6cde5d2a2 (diff) |
[media] Input: atmel_mxt_ts - add diagnostic data support for mXT1386
The mXT1386 family of chips have a different architecture which splits
the diagnostic data into 3 columns.
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 | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 7376c42d2370..584198e64661 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -137,6 +137,10 @@ struct t9_range { | |||
137 | #define MXT_DIAGNOSTIC_DELTAS 0x10 | 137 | #define MXT_DIAGNOSTIC_DELTAS 0x10 |
138 | #define MXT_DIAGNOSTIC_SIZE 128 | 138 | #define MXT_DIAGNOSTIC_SIZE 128 |
139 | 139 | ||
140 | #define MXT_FAMILY_1386 160 | ||
141 | #define MXT1386_COLUMNS 3 | ||
142 | #define MXT1386_PAGES_PER_COLUMN 8 | ||
143 | |||
140 | struct t37_debug { | 144 | struct t37_debug { |
141 | #ifdef CONFIG_TOUCHSCREEN_ATMEL_MXT_T37 | 145 | #ifdef CONFIG_TOUCHSCREEN_ATMEL_MXT_T37 |
142 | u8 mode; | 146 | u8 mode; |
@@ -2140,13 +2144,27 @@ recheck: | |||
2140 | static u16 mxt_get_debug_value(struct mxt_data *data, unsigned int x, | 2144 | static u16 mxt_get_debug_value(struct mxt_data *data, unsigned int x, |
2141 | unsigned int y) | 2145 | unsigned int y) |
2142 | { | 2146 | { |
2147 | struct mxt_info *info = &data->info; | ||
2143 | struct mxt_dbg *dbg = &data->dbg; | 2148 | struct mxt_dbg *dbg = &data->dbg; |
2144 | unsigned int ofs, page; | 2149 | unsigned int ofs, page; |
2150 | unsigned int col = 0; | ||
2151 | unsigned int col_width; | ||
2152 | |||
2153 | if (info->family_id == MXT_FAMILY_1386) { | ||
2154 | col_width = info->matrix_ysize / MXT1386_COLUMNS; | ||
2155 | col = y / col_width; | ||
2156 | y = y % col_width; | ||
2157 | } else { | ||
2158 | col_width = info->matrix_ysize; | ||
2159 | } | ||
2145 | 2160 | ||
2146 | ofs = (y + (x * data->info.matrix_ysize)) * sizeof(u16); | 2161 | ofs = (y + (x * col_width)) * sizeof(u16); |
2147 | page = ofs / MXT_DIAGNOSTIC_SIZE; | 2162 | page = ofs / MXT_DIAGNOSTIC_SIZE; |
2148 | ofs %= MXT_DIAGNOSTIC_SIZE; | 2163 | ofs %= MXT_DIAGNOSTIC_SIZE; |
2149 | 2164 | ||
2165 | if (info->family_id == MXT_FAMILY_1386) | ||
2166 | page += col * MXT1386_PAGES_PER_COLUMN; | ||
2167 | |||
2150 | return get_unaligned_le16(&dbg->t37_buf[page].data[ofs]); | 2168 | return get_unaligned_le16(&dbg->t37_buf[page].data[ofs]); |
2151 | } | 2169 | } |
2152 | 2170 | ||
@@ -2416,6 +2434,7 @@ static const struct video_device mxt_video_device = { | |||
2416 | 2434 | ||
2417 | static void mxt_debug_init(struct mxt_data *data) | 2435 | static void mxt_debug_init(struct mxt_data *data) |
2418 | { | 2436 | { |
2437 | struct mxt_info *info = &data->info; | ||
2419 | struct mxt_dbg *dbg = &data->dbg; | 2438 | struct mxt_dbg *dbg = &data->dbg; |
2420 | struct mxt_object *object; | 2439 | struct mxt_object *object; |
2421 | int error; | 2440 | int error; |
@@ -2439,8 +2458,14 @@ static void mxt_debug_init(struct mxt_data *data) | |||
2439 | 2458 | ||
2440 | /* Calculate size of data and allocate buffer */ | 2459 | /* Calculate size of data and allocate buffer */ |
2441 | dbg->t37_nodes = data->xsize * data->ysize; | 2460 | dbg->t37_nodes = data->xsize * data->ysize; |
2442 | dbg->t37_pages = DIV_ROUND_UP(data->xsize * data->info.matrix_ysize * | 2461 | |
2443 | sizeof(u16), sizeof(dbg->t37_buf->data)); | 2462 | if (info->family_id == MXT_FAMILY_1386) |
2463 | dbg->t37_pages = MXT1386_COLUMNS * MXT1386_PAGES_PER_COLUMN; | ||
2464 | else | ||
2465 | dbg->t37_pages = DIV_ROUND_UP(data->xsize * | ||
2466 | data->info.matrix_ysize * | ||
2467 | sizeof(u16), | ||
2468 | sizeof(dbg->t37_buf->data)); | ||
2444 | 2469 | ||
2445 | dbg->t37_buf = devm_kmalloc_array(&data->client->dev, dbg->t37_pages, | 2470 | dbg->t37_buf = devm_kmalloc_array(&data->client->dev, dbg->t37_pages, |
2446 | sizeof(struct t37_debug), GFP_KERNEL); | 2471 | sizeof(struct t37_debug), GFP_KERNEL); |