summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorJean-Louis Biasini <jlbiasini@gmail.com>2013-07-29 14:01:37 +0300
committerAmaury Pouly <amaury.pouly@gmail.com>2013-07-29 14:28:24 +0200
commitbe72c4f2bf664a20f5ccc020a05a29d8ae7a16f7 (patch)
treefc1a839d7e8e33ca2cf40eb2e6a86c09772c78a9 /firmware/drivers
parent49bcf3530962c40857c510af431968960ba4bdc6 (diff)
[RMI Driver] Implement power saving support
Implement standard values and functions to operate on power control register. This allow to modify both reporting rate and sleep mode in order to save power. Change-Id: I2bdffd4160e10eec488eb5e19de8a2a258ddbb04 Reviewed-on: http://gerrit.rockbox.org/529 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/synaptics-rmi.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/firmware/drivers/synaptics-rmi.c b/firmware/drivers/synaptics-rmi.c
index c979927fee..1b7cf2f8ef 100644
--- a/firmware/drivers/synaptics-rmi.c
+++ b/firmware/drivers/synaptics-rmi.c
@@ -25,6 +25,8 @@
static int rmi_cur_page;
static int rmi_i2c_addr;
+static unsigned char dev_ctl_reg;
+
/* NOTE:
* RMI over i2c supports some special aliases on page 0x2 but this driver don't
* use them */
@@ -33,6 +35,7 @@ int rmi_init(int i2c_dev_addr)
{
rmi_i2c_addr = i2c_dev_addr;
rmi_cur_page = 0x4;
+ dev_ctl_reg = rmi_read_single(RMI_DEVICE_CONTROL);
return 0;
}
@@ -75,3 +78,27 @@ int rmi_write_single(int address, unsigned char byte)
{
return rmi_write(address, 1, &byte);
}
+
+/* set the device to the given sleep mode */
+void rmi_set_sleep_mode(unsigned char sleep_mode)
+{
+ /* valid value different from the actual one*/
+ if((dev_ctl_reg & RMI_SLEEP_MODE_BM) != sleep_mode)
+ {
+ dev_ctl_reg &= ~RMI_SLEEP_MODE_BM;
+ dev_ctl_reg |= sleep_mode;
+ rmi_write_single(RMI_DEVICE_CONTROL, dev_ctl_reg);
+ }
+}
+
+/* set the device's report rate to the given value */
+void rmi_set_report_rate(unsigned char report_rate)
+{
+ /* valid value different from the actual one*/
+ if((dev_ctl_reg & RMI_REPORT_RATE_BM) != report_rate)
+ {
+ dev_ctl_reg &= ~RMI_REPORT_RATE_BM;
+ dev_ctl_reg |= report_rate;
+ rmi_write_single(RMI_DEVICE_CONTROL, dev_ctl_reg);
+ }
+}