diff options
-rw-r--r-- | firmware/drivers/synaptics-rmi.c | 27 | ||||
-rw-r--r-- | firmware/export/synaptics-rmi.h | 15 |
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 @@ | |||
25 | static int rmi_cur_page; | 25 | static int rmi_cur_page; |
26 | static int rmi_i2c_addr; | 26 | static int rmi_i2c_addr; |
27 | 27 | ||
28 | static 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 */ | ||
83 | void 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 */ | ||
95 | void 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 | ||
101 | struct rmi_2d_relative_data_t | 112 | struct 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 ! */ |
129 | int rmi_write_single(int address, unsigned char byte); | 140 | int rmi_write_single(int address, unsigned char byte); |
141 | /* set the device to the given sleep mode */ | ||
142 | void rmi_set_sleep_mode(unsigned char sleep_mode); | ||
143 | /* set the device's report rate to the given value */ | ||
144 | void rmi_set_report_rate(unsigned char report_rate); | ||
130 | 145 | ||
131 | #endif | 146 | #endif |