summaryrefslogtreecommitdiff
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
parent49bcf3530962c40857c510af431968960ba4bdc6 (diff)
downloadrockbox-be72c4f2bf664a20f5ccc020a05a29d8ae7a16f7.tar.gz
rockbox-be72c4f2bf664a20f5ccc020a05a29d8ae7a16f7.zip
[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>
-rw-r--r--firmware/drivers/synaptics-rmi.c27
-rw-r--r--firmware/export/synaptics-rmi.h15
2 files changed, 42 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 @@
25static int rmi_cur_page; 25static int rmi_cur_page;
26static int rmi_i2c_addr; 26static int rmi_i2c_addr;
27 27
28static unsigned char dev_ctl_reg;
29
28/* NOTE: 30/* NOTE:
29 * RMI over i2c supports some special aliases on page 0x2 but this driver don't 31 * RMI over i2c supports some special aliases on page 0x2 but this driver don't
30 * use them */ 32 * use them */
@@ -33,6 +35,7 @@ int rmi_init(int i2c_dev_addr)
33{ 35{
34 rmi_i2c_addr = i2c_dev_addr; 36 rmi_i2c_addr = i2c_dev_addr;
35 rmi_cur_page = 0x4; 37 rmi_cur_page = 0x4;
38 dev_ctl_reg = rmi_read_single(RMI_DEVICE_CONTROL);
36 return 0; 39 return 0;
37} 40}
38 41
@@ -75,3 +78,27 @@ int rmi_write_single(int address, unsigned char byte)
75{ 78{
76 return rmi_write(address, 1, &byte); 79 return rmi_write(address, 1, &byte);
77} 80}
81
82/* set the device to the given sleep mode */
83void rmi_set_sleep_mode(unsigned char sleep_mode)
84{
85 /* valid value different from the actual one*/
86 if((dev_ctl_reg & RMI_SLEEP_MODE_BM) != sleep_mode)
87 {
88 dev_ctl_reg &= ~RMI_SLEEP_MODE_BM;
89 dev_ctl_reg |= sleep_mode;
90 rmi_write_single(RMI_DEVICE_CONTROL, dev_ctl_reg);
91 }
92}
93
94/* set the device's report rate to the given value */
95void rmi_set_report_rate(unsigned char report_rate)
96{
97 /* valid value different from the actual one*/
98 if((dev_ctl_reg & RMI_REPORT_RATE_BM) != report_rate)
99 {
100 dev_ctl_reg &= ~RMI_REPORT_RATE_BM;
101 dev_ctl_reg |= report_rate;
102 rmi_write_single(RMI_DEVICE_CONTROL, dev_ctl_reg);
103 }
104}
diff --git a/firmware/export/synaptics-rmi.h b/firmware/export/synaptics-rmi.h
index 38a9955dcc..564f1fd7e7 100644
--- a/firmware/export/synaptics-rmi.h
+++ b/firmware/export/synaptics-rmi.h
@@ -97,6 +97,17 @@ struct rmi_2d_absolute_data_t
97#define RMI_2D_GEST_FLICK_X_BM 0x0f 97#define RMI_2D_GEST_FLICK_X_BM 0x0f
98#define RMI_2D_GEST_FLICK_Y_BM 0xf0 98#define RMI_2D_GEST_FLICK_Y_BM 0xf0
99#define RMI_2D_GEST_FLICK_Y_BP 4 99#define RMI_2D_GEST_FLICK_Y_BP 4
100/* RMI Device Control register */
101#define RMI_REPORT_RATE_BM 0xc0
102#define RMI_SLEEP_MODE_BM 0x07
103#define RMI_REPORT_RATE_NORMAL 0x80
104#define RMI_REPORT_RATE_LOW 0x40
105#define RMI_SLEEP_MODE_FORCE_FULLY_AWAKE 0x00
106#define RMI_SLEEP_MODE_NORMAL 0x01
107#define RMI_SLEEP_MODE_LOW_POWER 0x02
108#define RMI_SLEEP_MODE_VERY_LOW_POWER 0x03
109#define RMI_SLEEP_MODE_SENSOR_SLEEP 0x04
110
100 111
101struct rmi_2d_relative_data_t 112struct rmi_2d_relative_data_t
102{ 113{
@@ -127,5 +138,9 @@ int rmi_write(int address, int byte_count, const unsigned char *buffer);
127/* Write one register 138/* Write one register
128 * WARNING: don't cross a page boundary ! */ 139 * WARNING: don't cross a page boundary ! */
129int rmi_write_single(int address, unsigned char byte); 140int rmi_write_single(int address, unsigned char byte);
141/* set the device to the given sleep mode */
142void rmi_set_sleep_mode(unsigned char sleep_mode);
143/* set the device's report rate to the given value */
144void rmi_set_report_rate(unsigned char report_rate);
130 145
131#endif 146#endif