Skip to content

Commit

Permalink
Input: atmel_mxt_ts - implement debug output for messages
Browse files Browse the repository at this point in the history
Add a debug switch which causes all messages from the touch controller to
be dumped to the dmesg log with a set prefix "MXT MSG:". This is used by
Atmel user-space utilities to debug touch operation. Enabling this output
does impact touch performance.

Signed-off-by: Nick Dyer <[email protected]>
  • Loading branch information
ndyer committed Apr 26, 2016
1 parent 0c885d5 commit 3c3fcfd
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions drivers/input/touchscreen/atmel_mxt_ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ struct mxt_data {
u8 t100_aux_ampl;
u8 t100_aux_area;
u8 t100_aux_vect;
bool debug_enabled;
u8 max_reportid;
u32 config_crc;
u32 info_crc;
Expand Down Expand Up @@ -391,8 +392,8 @@ static bool mxt_object_readable(unsigned int type)

static void mxt_dump_message(struct mxt_data *data, u8 *message)
{
dev_dbg(&data->client->dev, "message: %*ph\n",
data->T5_msg_size, message);
dev_dbg(&data->client->dev, "MXT MSG: %*ph\n",
data->T5_msg_size, message);
}

static int mxt_wait_for_completion(struct mxt_data *data,
Expand Down Expand Up @@ -1145,6 +1146,7 @@ static void mxt_proc_t93_messages(struct mxt_data *data, u8 *msg)
static int mxt_proc_message(struct mxt_data *data, u8 *message)
{
u8 report_id = message[0];
bool dump = data->debug_enabled;

if (report_id == MXT_RPTID_NOMSG)
return 0;
Expand Down Expand Up @@ -1179,9 +1181,12 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message)
} else if (report_id == data->T93_reportid) {
mxt_proc_t93_messages(data, message);
} else {
mxt_dump_message(data, message);
dump = true;
}

if (dump)
mxt_dump_message(data, message);

return 1;
}

Expand Down Expand Up @@ -2989,6 +2994,36 @@ static ssize_t mxt_update_cfg_store(struct device *dev,
return ret;
}

static ssize_t mxt_debug_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mxt_data *data = dev_get_drvdata(dev);
char c;

c = data->debug_enabled ? '1' : '0';
return scnprintf(buf, PAGE_SIZE, "%c\n", c);
}

static ssize_t mxt_debug_enable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct mxt_data *data = dev_get_drvdata(dev);
u8 i;
ssize_t ret;

if (kstrtou8(buf, 0, &i) == 0 && i < 2) {
data->debug_enabled = (i == 1);

dev_dbg(dev, "%s\n", i ? "debug enabled" : "debug disabled");
ret = count;
} else {
dev_dbg(dev, "debug_enabled write error\n");
ret = -EINVAL;
}

return ret;
}

static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store);

static struct attribute *mxt_fw_attrs[] = {
Expand All @@ -3005,13 +3040,16 @@ 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_cfg, S_IWUSR, NULL, mxt_update_cfg_store);
static DEVICE_ATTR(config_crc, S_IRUGO, mxt_config_crc_show, NULL);
static DEVICE_ATTR(debug_enable, S_IWUSR | S_IRUSR, mxt_debug_enable_show,
mxt_debug_enable_store);

static struct attribute *mxt_attrs[] = {
&dev_attr_fw_version.attr,
&dev_attr_hw_version.attr,
&dev_attr_object.attr,
&dev_attr_update_cfg.attr,
&dev_attr_config_crc.attr,
&dev_attr_debug_enable.attr,
NULL
};

Expand Down

0 comments on commit 3c3fcfd

Please sign in to comment.