summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-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 @@
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);
+ }
+}
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
#define RMI_2D_GEST_FLICK_X_BM 0x0f
#define RMI_2D_GEST_FLICK_Y_BM 0xf0
#define RMI_2D_GEST_FLICK_Y_BP 4
+/* RMI Device Control register */
+#define RMI_REPORT_RATE_BM 0xc0
+#define RMI_SLEEP_MODE_BM 0x07
+#define RMI_REPORT_RATE_NORMAL 0x80
+#define RMI_REPORT_RATE_LOW 0x40
+#define RMI_SLEEP_MODE_FORCE_FULLY_AWAKE 0x00
+#define RMI_SLEEP_MODE_NORMAL 0x01
+#define RMI_SLEEP_MODE_LOW_POWER 0x02
+#define RMI_SLEEP_MODE_VERY_LOW_POWER 0x03
+#define RMI_SLEEP_MODE_SENSOR_SLEEP 0x04
+
struct rmi_2d_relative_data_t
{
@@ -127,5 +138,9 @@ int rmi_write(int address, int byte_count, const unsigned char *buffer);
/* Write one register
* WARNING: don't cross a page boundary ! */
int rmi_write_single(int address, unsigned char byte);
+/* set the device to the given sleep mode */
+void rmi_set_sleep_mode(unsigned char sleep_mode);
+/* set the device's report rate to the given value */
+void rmi_set_report_rate(unsigned char report_rate);
#endif