From: Chris Leech <christopher.leech@linux.intel.com> To: linux-input@vger.kernel.org Cc: Joonyoung Shim <jy0922.shim@samsung.com> Subject: [PATCH 3/5] qt602240_ts: Trust factory configuration of touchscreen. Date: Tue, 16 Nov 2010 12:42:00 -0800 [thread overview] Message-ID: <20101116204200.28796.23013.stgit@localhost6.localdomain6> (raw) In-Reply-To: <20101116203914.28796.23141.stgit@localhost6.localdomain6> The maXTouch 224 touchscreen controller has non-volatile storage for system configuration and calibration settings. Make it a platform option to trust those values, instead of reconfiguring everything. The configuration settings currently being applied are determined from the firmware version, but are not appropriate for all systems. This should be a compatible change with existing users of this driver. Signed-off-by: Chris Leech <christopher.leech@linux.intel.com> --- drivers/input/touchscreen/qt602240_ts.c | 121 +++++++++++++++++++++++-------- include/linux/i2c/qt602240_ts.h | 8 ++ 2 files changed, 98 insertions(+), 31 deletions(-) diff --git a/drivers/input/touchscreen/qt602240_ts.c b/drivers/input/touchscreen/qt602240_ts.c index 95496ec..11055ec 100644 --- a/drivers/input/touchscreen/qt602240_ts.c +++ b/drivers/input/touchscreen/qt602240_ts.c @@ -353,7 +353,7 @@ struct qt602240_finger { struct qt602240_data { struct i2c_client *client; struct input_dev *input_dev; - const struct qt602240_platform_data *pdata; + struct qt602240_platform_data *pdata; struct qt602240_object *object_table; struct qt602240_info info; struct qt602240_finger finger[QT602240_MAX_FINGER]; @@ -754,7 +754,7 @@ static int qt602240_check_reg_init(struct qt602240_data *data) static int qt602240_check_matrix_size(struct qt602240_data *data) { - const struct qt602240_platform_data *pdata = data->pdata; + struct qt602240_platform_data *pdata = data->pdata; struct device *dev = &data->client->dev; int mode = -1; int error; @@ -844,7 +844,7 @@ static int qt602240_make_highchg(struct qt602240_data *data) static void qt602240_handle_pdata(struct qt602240_data *data) { - const struct qt602240_platform_data *pdata = data->pdata; + struct qt602240_platform_data *pdata = data->pdata; u8 voltage; /* Set touchscreen lines */ @@ -890,6 +890,48 @@ static void qt602240_handle_pdata(struct qt602240_data *data) } } +static void qt602240_read_config(struct qt602240_data *data) +{ + struct qt602240_platform_data *pdata = data->pdata; + u8 val; + u8 high, low; + + /* touchscreen lines */ + qt602240_read_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_XSIZE, + &val); + pdata->x_line = val; + qt602240_read_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_YSIZE, + &val); + pdata->x_line = val; + + /* touchscreen orient */ + qt602240_read_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_ORIENT, + &val); + pdata->orient = val; + + /* touchscreen burst length */ + qt602240_read_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_BLEN, + &val); + pdata->blen = val; + + /* touchscreen threshold */ + qt602240_read_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_TCHTHR, + &val); + pdata->threshold = val; + + /* touchscreen resolution */ + qt602240_read_object(data, QT602240_TOUCH_MULTI, + QT602240_TOUCH_XRANGE_LSB, &low); + qt602240_read_object(data, QT602240_TOUCH_MULTI, + QT602240_TOUCH_XRANGE_MSB, &high); + pdata->x_size = (high << 8) | (low + 1); + qt602240_read_object(data, QT602240_TOUCH_MULTI, + QT602240_TOUCH_YRANGE_LSB, &low); + qt602240_read_object(data, QT602240_TOUCH_MULTI, + QT602240_TOUCH_YRANGE_MSB, &high); + pdata->y_size = (high << 8) | (low + 1); +} + static int qt602240_get_info(struct qt602240_data *data) { struct i2c_client *client = data->client; @@ -981,23 +1023,28 @@ static int qt602240_initialize(struct qt602240_data *data) if (error) return error; - /* Check register init values */ - error = qt602240_check_reg_init(data); - if (error) - return error; + if (data->pdata->trust_nvm) { + /* read configuration from device */ + qt602240_read_config(data); + } else { + /* Check register init values */ + error = qt602240_check_reg_init(data); + if (error) + return error; - /* Check X/Y matrix size */ - error = qt602240_check_matrix_size(data); - if (error) - return error; + /* Check X/Y matrix size */ + error = qt602240_check_matrix_size(data); + if (error) + return error; - qt602240_handle_pdata(data); + qt602240_handle_pdata(data); - /* Backup to memory */ - qt602240_write_object(data, QT602240_GEN_COMMAND, - QT602240_COMMAND_BACKUPNV, - QT602240_BACKUP_VALUE); - msleep(QT602240_BACKUP_TIME); + /* Backup to memory */ + qt602240_write_object(data, QT602240_GEN_COMMAND, + QT602240_COMMAND_BACKUPNV, + QT602240_BACKUP_VALUE); + msleep(QT602240_BACKUP_TIME); + } /* Soft reset */ qt602240_write_object(data, QT602240_GEN_COMMAND, @@ -1227,6 +1274,8 @@ static int __devinit qt602240_probe(struct i2c_client *client, struct qt602240_data *data; struct input_dev *input_dev; int error; + u16 x_size; + u16 y_size; if (!client->dev.platform_data) return -EINVAL; @@ -1249,20 +1298,6 @@ static int __devinit qt602240_probe(struct i2c_client *client, __set_bit(EV_KEY, input_dev->evbit); __set_bit(BTN_TOUCH, input_dev->keybit); - /* For single touch */ - input_set_abs_params(input_dev, ABS_X, - 0, QT602240_MAX_XC, 0, 0); - input_set_abs_params(input_dev, ABS_Y, - 0, QT602240_MAX_YC, 0, 0); - - /* For multi touch */ - input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, - 0, QT602240_MAX_AREA, 0, 0); - input_set_abs_params(input_dev, ABS_MT_POSITION_X, - 0, QT602240_MAX_XC, 0, 0); - input_set_abs_params(input_dev, ABS_MT_POSITION_Y, - 0, QT602240_MAX_YC, 0, 0); - input_set_drvdata(input_dev, data); data->client = client; @@ -1276,6 +1311,30 @@ static int __devinit qt602240_probe(struct i2c_client *client, if (error) goto err_free_object; + /* + * Bit 0 of TOUCH_ORIENT is the X/Y swap configuration. + * If the axises are swapped the reporting will change, and in order to + * get the scaling correct we need to swap the maximum range values + * reported to the input layer. + */ + if (data->pdata->orient & 1) { + x_size = data->pdata->y_size; + y_size = data->pdata->x_size; + } else { + x_size = data->pdata->x_size; + y_size = data->pdata->y_size; + } + + /* For single touch */ + input_set_abs_params(input_dev, ABS_X, 0, x_size, 0, 0); + input_set_abs_params(input_dev, ABS_Y, 0, y_size, 0, 0); + + /* For multi touch */ + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, + QT602240_MAX_AREA, 0, 0); + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, x_size, 0, 0); + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, y_size, 0, 0); + error = qt602240_make_highchg(data); if (error) goto err_free_object; diff --git a/include/linux/i2c/qt602240_ts.h b/include/linux/i2c/qt602240_ts.h index c5033e1..d2aa1b6 100644 --- a/include/linux/i2c/qt602240_ts.h +++ b/include/linux/i2c/qt602240_ts.h @@ -33,6 +33,14 @@ struct qt602240_platform_data { unsigned int threshold; unsigned int voltage; unsigned char orient; + /* + * trust_nvm: 1 to trust HW config, 0 for software reconfiguration + * If trust_nvm is set, all of the above values will be read from the + * device (presumably loaded from non-volatile memory at reset), + * instead of the other way around (configuring the device based on + * platform_data). + */ + unsigned char trust_nvm; }; #endif /* __LINUX_QT602240_TS_H */
next prev parent reply other threads:[~2010-11-16 20:42 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-11-16 20:41 [PATCH 0/4] qt602240_ts changes for Intel mid platform Chris Leech 2010-11-16 20:41 ` [PATCH 1/5] qt602240_ts: fix wrong sizeof in object table allocation Chris Leech 2010-11-18 11:16 ` Joonyoung Shim 2010-11-18 11:30 ` Joonyoung Shim 2010-11-16 20:41 ` [PATCH 2/5] qt602240_ts: move clearing of pending interrupt closer to request_threaded_irq Chris Leech 2010-11-18 12:53 ` Joonyoung Shim 2010-11-18 19:29 ` Chris Leech 2010-11-18 22:54 ` Dmitry Torokhov 2010-11-16 20:42 ` Chris Leech [this message] 2010-11-18 13:09 ` [PATCH 3/5] qt602240_ts: Trust factory configuration of touchscreen Joonyoung Shim 2010-11-18 19:41 ` Chris Leech 2010-11-16 20:42 ` [PATCH 4/5] qt602240_ts: add optional hooks for board specific reset logic Chris Leech 2010-11-18 11:32 ` Joonyoung Shim 2010-11-18 19:46 ` Chris Leech 2010-11-16 20:42 ` [PATCH 5/5] qt602240_ts: add mXT224 identifier to id_table, to match Intel mid firmware identifier Chris Leech 2010-11-18 11:34 ` Joonyoung Shim
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20101116204200.28796.23013.stgit@localhost6.localdomain6 \ --to=christopher.leech@linux.intel.com \ --cc=jy0922.shim@samsung.com \ --cc=linux-input@vger.kernel.org \ --subject='Re: [PATCH 3/5] qt602240_ts: Trust factory configuration of touchscreen.' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.