All of lore.kernel.org
 help / color / mirror / Atom feed
From: jooaun <jasaw81@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, raphaelpereira@gmail.com,
	jooaun <jasaw81@gmail.com>
Subject: [PATCH 4/8] qt2160: add configurable power mode
Date: Tue,  9 Nov 2010 13:15:07 +1100	[thread overview]
Message-ID: <1289268911-32322-4-git-send-email-jasaw81@gmail.com> (raw)
In-Reply-To: <1289268911-32322-1-git-send-email-jasaw81@gmail.com>

Add configurable low power mode to reduce power consumption. We trade off responsiveness for lower power consumption. Each +1 increment in value causes the chip to sleep 16ms longer before detecting a touch.
Signed-off-by: Joo Aun Saw <jasaw81@gmail.com>
---
 drivers/input/keyboard/qt2160.c |   13 +++++++++++++
 include/linux/input/qt2160.h    |    3 +++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/input/keyboard/qt2160.c b/drivers/input/keyboard/qt2160.c
index 6439e40..0d662e2 100755
--- a/drivers/input/keyboard/qt2160.c
+++ b/drivers/input/keyboard/qt2160.c
@@ -299,6 +299,15 @@ static int __devinit qt2160_configure_device(struct i2c_client *client,
 	/* perform dummy write to reset I2C state */
 	i2c_smbus_write_byte(client, QT2160_CMD_CHIPID);
 
+	/* setup LP mode */
+	if (pdata->low_power_mode) {
+		error = i2c_smbus_write_byte_data(client, QT2160_CMD_LP_MODE,
+						  pdata->low_power_mode);
+		if (error) {
+			dev_err(&client->dev, "could not write power config\n");
+			goto config_fault;
+		}
+	}
 	/* setup slider control and slider options */
 	if (pdata->slider_length) {
 		error |= i2c_smbus_write_byte_data(
@@ -547,9 +556,13 @@ static int qt2160_suspend(struct i2c_client *client, pm_message_t message)
 
 static int qt2160_resume(struct i2c_client *client)
 {
+	struct qt2160_data *qt2160 = i2c_get_clientdata(client);
+	struct qt2160_info *hw_info = qt2160->hw_info;
 	int error;
 	u8 lp_mode_val = QT2160_LP_MODE_DEFAULT_VALUE;
 
+	if (hw_info->low_power_mode)
+		lp_mode_val = hw_info->low_power_mode;
 	error = i2c_smbus_write_byte_data(client, QT2160_CMD_LP_MODE,
 					  lp_mode_val);
 	if (error)
diff --git a/include/linux/input/qt2160.h b/include/linux/input/qt2160.h
index 748c86e..8a1913f 100755
--- a/include/linux/input/qt2160.h
+++ b/include/linux/input/qt2160.h
@@ -16,6 +16,8 @@
  *  same aks group; keys in the same aks group will only report 1 active key at
  *  any time; value 0 disables aks group; valid aks groups are 1, 2, 3
  * @key_burst_length: key sensitivity; 0 use default
+ * @low_power_mode: value 0 use default; each +1 increment causes the chip to
+ *  sleep 16ms longer before detecting a touch (slower response); max 255
  */
 struct qt2160_info {
 	unsigned char slider_length;
@@ -23,6 +25,7 @@ struct qt2160_info {
 	unsigned short keycodes[QT2160_MAXKEYS];
 	unsigned char key_aks[QT2160_MAXKEYS];
 	unsigned char key_burst_length[QT2160_MAXKEYS];
+	unsigned char low_power_mode;
 };
 
 #endif /* __QT2160_H__ */
-- 
1.7.0.4


  parent reply	other threads:[~2010-11-09  2:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-09  2:15 [PATCH 1/8] qt2160: add slider support jooaun
2010-11-09  2:15 ` [PATCH 2/8] qt2160: configurable key sensitivity jooaun
2010-11-09  2:43   ` jooaun
2010-11-09  2:15 ` [PATCH 3/8] qt2160: add PM support jooaun
2010-11-09  2:15 ` jooaun [this message]
2010-11-09  2:15 ` [PATCH 5/8] qt2160: fix starting of device calibration jooaun
2010-11-09  2:15 ` [PATCH 6/8] qt2160: only read device when Change pin is active jooaun
2010-11-09  2:45   ` jooaun
2010-11-09  2:15 ` [PATCH 7/8] qt2160: optional interrupt flag jooaun
2010-11-09  2:46   ` jooaun
2010-11-09  2:15 ` [PATCH 8/8] qt2160: add hardware reset jooaun
2010-11-09  2:47   ` jooaun

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=1289268911-32322-4-git-send-email-jasaw81@gmail.com \
    --to=jasaw81@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=raphaelpereira@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.