@@ -189,6 +189,7 @@ enum t100_type {
/* Delay times */
#define MXT_BACKUP_TIME 50 /* msec */
+#define MXT_CAL_TIME 25 /* msec */
#define MXT_RESET_GPIO_TIME 20 /* msec */
#define MXT_RESET_INVALID_CHG 100 /* msec */
#define MXT_RESET_TIME 200 /* msec */
@@ -753,6 +754,21 @@ static int mxt_write_object(struct mxt_data *data,
return mxt_write_reg(data->client, reg + offset, val);
}
+static int mxt_recalibrate(struct mxt_data *data)
+{
+ struct device *dev = &data->client->dev;
+ int error;
+
+ dev_dbg(dev, "Recalibration ...\n");
+ error = mxt_write_object(data, MXT_GEN_COMMAND_T6,
+ MXT_COMMAND_CALIBRATE, 1);
+ if (error)
+ dev_err(dev, "Recalibration failed %d\n", error);
+ else
+ msleep(MXT_CAL_TIME);
+ return error;
+}
+
static void mxt_input_button(struct mxt_data *data, u8 *message)
{
struct input_dev *input = data->input_dev;
@@ -2663,6 +2679,19 @@ static int mxt_configure_objects(struct mxt_data *data,
return 0;
}
+static ssize_t mxt_calibrate_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct mxt_data *data = dev_get_drvdata(dev);
+ int ret;
+
+ disable_irq(data->irq);
+ ret = mxt_recalibrate(data);
+ enable_irq(data->irq);
+ return ret ?: count;
+}
+
/* Firmware Version is returned as Major.Minor.Build */
static ssize_t mxt_fw_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -2910,12 +2939,14 @@ static ssize_t mxt_update_fw_store(struct device *dev,
return count;
}
+static DEVICE_ATTR(calibrate, S_IWUSR, NULL, mxt_calibrate_store);
static DEVICE_ATTR(fw_version, S_IRUGO, mxt_fw_version_show, NULL);
static DEVICE_ATTR(hw_version, S_IRUGO, mxt_hw_version_show, NULL);
static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL);
static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store);
static struct attribute *mxt_attrs[] = {
+ &dev_attr_calibrate.attr,
&dev_attr_fw_version.attr,
&dev_attr_hw_version.attr,
&dev_attr_object.attr,
From: Jongpil Jung <jongpil19.jung@samsung.com> Make interface to calibrate touchscreen ic so that we can do calibration in user space. Change-Id: Ied8262d6451ae4478e87efc205bf07708422027f --- drivers/input/touchscreen/atmel_mxt_ts.c | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+)