mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 04:12:04 -04:00
optimize aw963xx driver
1.optimization of secondary interrupt triggering logic for sar 2.modify driver aw963xx Change-Id: I81782749f4cc8c62be421316e9d367f0d9d92156 Signed-off-by: tin_bingtai.zou_tmp <tinno60@motorola.com> Reviewed-on: https://gerrit.mot.com/2585232 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: <yangyi31@motorola.com> Reviewed-by: Yuchang Guo <guoyc1@lenovo.com> Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
bf8f9b9fd0
commit
3fa32c60ae
2 changed files with 26 additions and 46 deletions
|
|
@ -312,57 +312,37 @@ static void aw963xx_irq_handle_func(uint32_t irq_status, void *data)
|
|||
int32_t ret = 0;
|
||||
uint32_t curr_status_val = 0;
|
||||
struct aw_sar *p_sar = (struct aw_sar *)data;
|
||||
|
||||
uint32_t ch_th[AW963XX_CHANNEL_NUM_MAX] = { 0 };
|
||||
AWLOGD(p_sar->dev, "IRQSRC = 0x%x", irq_status);
|
||||
|
||||
if (((irq_status >> 1) & 0x01) == 1) {
|
||||
for (i = (AW963XX_VALID_TH - 1); i >= 0; i--) {
|
||||
ret = aw_sar_i2c_read(p_sar->i2c,
|
||||
REG_STAT0 + i * (REG_STAT1 - REG_STAT0),
|
||||
&curr_status_val);
|
||||
if (ret < 0) {
|
||||
AWLOGE(p_sar->dev, "i2c IO error");
|
||||
return;
|
||||
}
|
||||
|
||||
for (j = 0; j < AW963XX_CHANNEL_NUM_MAX; j++) {
|
||||
if ((((curr_status_val >> j) & 0x01) == AW963XX_APPROACH) &&
|
||||
(p_sar->channels_arr[j].last_channel_info == AW963XX_FAR_AWAY)) {
|
||||
if (p_sar->channels_arr[j].input == NULL) {
|
||||
continue;
|
||||
}
|
||||
p_sar->channels_arr[j].last_channel_info = AW963XX_APPROACH;
|
||||
input_report_abs(p_sar->channels_arr[j].input, ABS_DISTANCE, i + 1);
|
||||
input_sync(p_sar->channels_arr[j].input);
|
||||
AWLOGD(p_sar->dev, "approach ch = %d th = %d", j, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j = 0; j < AW963XX_CHANNEL_NUM_MAX; j++) {
|
||||
if (p_sar->channels_arr[j].input == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((irq_status >> 2) & 0x01) == 1) {
|
||||
ret = aw_sar_i2c_read(p_sar->i2c, REG_STAT0, &curr_status_val);
|
||||
if (ret < 0) {
|
||||
AWLOGE(p_sar->dev, "i2c IO error");
|
||||
return;
|
||||
for (i = (AW963XX_VALID_TH - 1); i >= 0; i--) {
|
||||
ret = aw_sar_i2c_read(p_sar->i2c,
|
||||
REG_STAT0 + i * (REG_STAT1 - REG_STAT0),
|
||||
&curr_status_val);
|
||||
ch_th[j] |= ((curr_status_val >> j) & 0x01) << i;
|
||||
AWLOGE(p_sar->dev, "ch= %d, th = %d ch_th = 0x%x", j, i, ch_th[j]);
|
||||
}
|
||||
AWLOGE(p_sar->dev, "ch = %d last_th=0x%x th = 0x%x", j, p_sar->channels_arr[j].last_channel_info, ch_th[j]);
|
||||
if (p_sar->channels_arr[j].last_channel_info != ch_th[j]) {
|
||||
if ((ch_th[j] >> 3 & 0x01) == 1) { //th3
|
||||
input_report_abs(p_sar->channels_arr[j].input, ABS_DISTANCE, 4);
|
||||
} else if ((ch_th[j] >> 2 & 0x01) == 1) { //th2
|
||||
input_report_abs(p_sar->channels_arr[j].input, ABS_DISTANCE, 3);
|
||||
} else if ((ch_th[j] >> 1 & 0x01) == 1) { //th1
|
||||
input_report_abs(p_sar->channels_arr[j].input, ABS_DISTANCE, 2);
|
||||
} else if ((ch_th[j] >> 0 & 0x01) == 1) { //th0
|
||||
input_report_abs(p_sar->channels_arr[j].input, ABS_DISTANCE, 1);
|
||||
} else { //far
|
||||
input_report_abs(p_sar->channels_arr[j].input, ABS_DISTANCE, 0);
|
||||
}
|
||||
|
||||
for (j = 0; j < AW963XX_CHANNEL_NUM_MAX; j++) {
|
||||
if ((((curr_status_val >> j) & 0x01) == AW963XX_FAR_AWAY) &&
|
||||
(p_sar->channels_arr[j].last_channel_info == AW963XX_APPROACH)) {
|
||||
p_sar->channels_arr[j].last_channel_info = AW963XX_FAR_AWAY;
|
||||
if (p_sar->channels_arr[i].used == AW_FALSE) {
|
||||
continue;
|
||||
}
|
||||
input_report_abs(p_sar->channels_arr[j].input, ABS_DISTANCE, 0);
|
||||
input_sync(p_sar->channels_arr[j].input);
|
||||
AWLOGD(p_sar->dev, "far away ch = %d", j);
|
||||
}
|
||||
input_sync(p_sar->channels_arr[j].input);
|
||||
p_sar->channels_arr[j].last_channel_info = ch_th[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t aw963xx_operation_mode_get(void *data, char *buf)
|
||||
{
|
||||
ssize_t len = 0;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#define USE_SENSORS_CLASS
|
||||
#define AW963XX_CHANNEL_NUM_MAX (12)
|
||||
#define AW963XX_VALID_TH (3)
|
||||
#define AW963XX_VALID_TH (2)
|
||||
#define AW963XX_DATA_PROCESS_FACTOR (1024)
|
||||
#define AW9620X_SAR_VCC_MIN_UV (1700000)
|
||||
#define AW9620X_SAR_VCC_MAX_UV (3600000)
|
||||
|
|
|
|||
Loading…
Reference in a new issue