mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 21:59:12 -04:00
sx933x: only sense enabled channels
When a channel for the capsensor is turned on, enable sensing only on that specific channel. Same for disable. Previously, all channels were enabled when a single channel was set to enable, and all channels were turned off after every channel was disabled. Enabling only the channels we need will reduce scan time and increase performance. Change-Id: I77e11b1a66b3cbcfbfdbb9752faecb53dd6a3ea7 Signed-off-by: Ryan Lattrel <ryanl@motorola.com> Reviewed-on: https://gerrit.mot.com/1269356 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Guoyue Liu <liugy11@motorola.com> Reviewed-by: Kenneth Kessler <kennykessler@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
73d2dc3bab
commit
9966367f76
2 changed files with 10 additions and 18 deletions
|
|
@ -734,7 +734,6 @@ static void sx933x_exit_platform_hw(struct i2c_client *client)
|
|||
static int capsensor_set_enable(struct sensors_classdev *sensors_cdev,
|
||||
unsigned int enable)
|
||||
{
|
||||
bool disableFlag = true;
|
||||
int i = 0;
|
||||
u32 temp = 0x0;
|
||||
|
||||
|
|
@ -743,7 +742,7 @@ static int capsensor_set_enable(struct sensors_classdev *sensors_cdev,
|
|||
if (enable == 1) {
|
||||
LOG_DBG("enable cap sensor : %s\n", sensors_cdev->name);
|
||||
sx933x_i2c_read_16bit(global_sx933x, SX933X_GNRLCTRL2_REG, &temp);
|
||||
temp = temp | 0x0000001F;
|
||||
temp = temp | (1 << psmtcButtons[i].offset);
|
||||
LOG_INFO("set reg 0x%x val 0x%x\n", SX933X_GNRLCTRL2_REG, temp);
|
||||
sx933x_i2c_write_16bit(global_sx933x, SX933X_GNRLCTRL2_REG, temp);
|
||||
psmtcButtons[i].enabled = true;
|
||||
|
|
@ -753,6 +752,9 @@ static int capsensor_set_enable(struct sensors_classdev *sensors_cdev,
|
|||
manual_offset_calibration(global_sx933x);
|
||||
} else if (enable == 0) {
|
||||
LOG_DBG("disable cap sensor : %s\n", sensors_cdev->name);
|
||||
sx933x_i2c_read_16bit(global_sx933x, SX933X_GNRLCTRL2_REG, &temp);
|
||||
temp = temp & ~(1 << psmtcButtons[i].offset);
|
||||
sx933x_i2c_write_16bit(global_sx933x, SX933X_GNRLCTRL2_REG, temp);
|
||||
psmtcButtons[i].enabled = false;
|
||||
input_report_abs(psmtcButtons[i].input_dev, ABS_DISTANCE, -1);
|
||||
input_sync(psmtcButtons[i].input_dev);
|
||||
|
|
@ -761,22 +763,6 @@ static int capsensor_set_enable(struct sensors_classdev *sensors_cdev,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if all chs disabled, then disable all
|
||||
for (i = 0; i < ARRAY_SIZE(psmtcButtons); i++) {
|
||||
if (psmtcButtons[i].enabled) {
|
||||
disableFlag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (disableFlag) {
|
||||
LOG_DBG("disable all chs\n");
|
||||
sx933x_i2c_read_16bit(global_sx933x, SX933X_GNRLCTRL2_REG, &temp);
|
||||
LOG_INFO("read reg 0x%x val 0x%x\n", SX933X_GNRLCTRL2_REG, temp);
|
||||
temp = temp & 0xFFFFFFE0;
|
||||
LOG_INFO("set reg 0x%x val 0x%x\n", SX933X_GNRLCTRL2_REG, temp);
|
||||
sx933x_i2c_write_16bit(global_sx933x, SX933X_GNRLCTRL2_REG, temp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ struct _buttonInfo
|
|||
bool enabled;
|
||||
//may different project use different buttons
|
||||
bool used;
|
||||
int offset;
|
||||
};
|
||||
|
||||
struct totalButtonInformation
|
||||
|
|
@ -651,6 +652,7 @@ static struct _buttonInfo psmtcButtons[] =
|
|||
.name = "Moto CapSense Ch0",
|
||||
.enabled = false,
|
||||
.used = false,
|
||||
.offset = 0,
|
||||
},
|
||||
{
|
||||
.ProxMask = SX933X_STAT0_PROXSTAT_PH1_FLAG,
|
||||
|
|
@ -658,6 +660,7 @@ static struct _buttonInfo psmtcButtons[] =
|
|||
.name = "Moto CapSense Ch1",
|
||||
.enabled = false,
|
||||
.used = false,
|
||||
.offset = 1,
|
||||
},
|
||||
{
|
||||
.ProxMask = SX933X_STAT0_PROXSTAT_PH2_FLAG,
|
||||
|
|
@ -665,6 +668,7 @@ static struct _buttonInfo psmtcButtons[] =
|
|||
.name = "Moto CapSense Ch2",
|
||||
.enabled = false,
|
||||
.used = false,
|
||||
.offset = 2,
|
||||
},
|
||||
{
|
||||
.ProxMask = SX933X_STAT0_PROXSTAT_PH3_FLAG,
|
||||
|
|
@ -672,6 +676,7 @@ static struct _buttonInfo psmtcButtons[] =
|
|||
.name = "Moto CapSense Ch3",
|
||||
.enabled = false,
|
||||
.used = false,
|
||||
.offset = 3,
|
||||
},
|
||||
{
|
||||
.ProxMask = SX933X_STAT0_PROXSTAT_PH4_FLAG,
|
||||
|
|
@ -679,6 +684,7 @@ static struct _buttonInfo psmtcButtons[] =
|
|||
.name = "Moto CapSense Ch4",
|
||||
.enabled = false,
|
||||
.used = false,
|
||||
.offset = 4,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue