Commit 7a3ed686 authored by Sangwon Jee's avatar Sangwon Jee Committed by Dmitry Torokhov

Input: melfas_mip4 - add resolution reporting

Add support for retrieving device resolution (pixels per mm) from firmware
and using it when setting up input device.
Signed-off-by: default avatarSangwon Jee <jeesw@melfas.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 564a68de
......@@ -33,7 +33,7 @@
/*****************************************************************
* Protocol
* Version : MIP 4.0 Rev 4.4
* Version : MIP 4.0 Rev 4.6
*****************************************************************/
/* Address */
......@@ -52,6 +52,11 @@
#define MIP4_R1_INFO_NODE_NUM_X 0x14
#define MIP4_R1_INFO_NODE_NUM_Y 0x15
#define MIP4_R1_INFO_KEY_NUM 0x16
#define MIP4_R1_INFO_PRESSURE_NUM 0x17
#define MIP4_R1_INFO_LENGTH_X 0x18
#define MIP4_R1_INFO_LENGTH_Y 0x1A
#define MIP4_R1_INFO_PPM_X 0x1C
#define MIP4_R1_INFO_PPM_Y 0x1D
#define MIP4_R1_INFO_VERSION_BOOT 0x20
#define MIP4_R1_INFO_VERSION_CORE 0x22
#define MIP4_R1_INFO_VERSION_APP 0x24
......@@ -158,6 +163,8 @@ struct mip4_ts {
u8 node_x;
u8 node_y;
u8 node_key;
unsigned int ppm_x;
unsigned int ppm_y;
struct mip4_fw_version fw_version;
......@@ -242,7 +249,7 @@ static int mip4_query_device(struct mip4_ts *ts)
{
int error;
u8 cmd[2];
u8 buf[8];
u8 buf[14];
/* Product name */
cmd[0] = MIP4_R0_INFO;
......@@ -269,7 +276,7 @@ static int mip4_query_device(struct mip4_ts *ts)
/* Resolution */
cmd[0] = MIP4_R0_INFO;
cmd[1] = MIP4_R1_INFO_RESOLUTION_X;
error = mip4_i2c_xfer(ts, cmd, sizeof(cmd), buf, 7);
error = mip4_i2c_xfer(ts, cmd, sizeof(cmd), buf, 14);
if (error) {
dev_warn(&ts->client->dev,
"Failed to retrieve touchscreen parameters: %d\n",
......@@ -287,6 +294,11 @@ static int mip4_query_device(struct mip4_ts *ts)
"node_x: %d, node_y: %d, node_key: %d\n",
ts->node_x, ts->node_y, ts->node_key);
ts->ppm_x = buf[12];
ts->ppm_y = buf[13];
dev_dbg(&ts->client->dev, "ppm_x: %d, ppm_y: %d\n",
ts->ppm_x, ts->ppm_y);
/* Key ts */
if (ts->node_key > 0)
ts->key_num = ts->node_key;
......@@ -1095,6 +1107,10 @@ static int mip4_flash_fw(struct mip4_ts *ts,
input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0);
input_set_abs_params(ts->input, ABS_X, 0, ts->max_x, 0, 0);
input_set_abs_params(ts->input, ABS_Y, 0, ts->max_y, 0, 0);
input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x);
input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y);
input_abs_set_res(ts->input, ABS_X, ts->ppm_x);
input_abs_set_res(ts->input, ABS_Y, ts->ppm_y);
return error ? error : 0;
}
......@@ -1377,6 +1393,8 @@ static int mip4_probe(struct i2c_client *client, const struct i2c_device_id *id)
MIP4_TOUCH_MAJOR_MIN, MIP4_TOUCH_MAJOR_MAX, 0, 0);
input_set_abs_params(input, ABS_MT_TOUCH_MINOR,
MIP4_TOUCH_MINOR_MIN, MIP4_TOUCH_MINOR_MAX, 0, 0);
input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x);
input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y);
error = input_mt_init_slots(input, MIP4_MAX_FINGERS, INPUT_MT_DIRECT);
if (error)
......@@ -1494,6 +1512,6 @@ static struct i2c_driver mip4_driver = {
module_i2c_driver(mip4_driver);
MODULE_DESCRIPTION("MELFAS MIP4 Touchscreen");
MODULE_VERSION("2016.01.13");
MODULE_VERSION("2016.03.03");
MODULE_AUTHOR("Sangwon Jee <jeesw@melfas.com>");
MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment