mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 13:49:24 -04:00
haptics: awinic: add haptic context while flat-up
-1, add haptic context whild flat-up reduce the gain of vibration -2, disable this feature when the bootmode is factory Change-Id: I75a871cf94af54f375a42be54ddcd1d380972797 Signed-off-by: yangjq <yangjq@lenovo.com> Reviewed-on: https://gerrit.mot.com/1374681 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Jianqi Yang <yangj@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
ab148d38d5
commit
0199f360d0
2 changed files with 57 additions and 10 deletions
|
|
@ -1332,7 +1332,7 @@ static int aw8695_haptic_cont(struct aw8695 *aw8695)
|
|||
aw8695_i2c_write(aw8695, AW8695_REG_BEMF_VTHL_L, 0xf8);
|
||||
aw8695_i2c_write_bits(aw8695, AW8695_REG_BEMF_NUM,
|
||||
AW8695_BIT_BEMF_NUM_BRK_MASK, aw8695->cont_num_brk);
|
||||
aw8695_i2c_write(aw8695, AW8695_REG_TIME_NZC, 0x23); /* 35*171us=5.985ms */
|
||||
aw8695_i2c_write(aw8695, AW8695_REG_TIME_NZC, 0x23); /* 35*171us=5.985ms */
|
||||
|
||||
/* f0 driver level */
|
||||
aw8695_i2c_write(aw8695, AW8695_REG_DRV_LVL, aw8695->cont_drv_lvl);
|
||||
|
|
@ -1800,7 +1800,6 @@ static void aw8695_rtp_play(struct aw8695 *aw8695, int value)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void aw8695_haptic_context(struct aw8695 *aw8695, enum aw8695_haptic_mode cmd)
|
||||
{
|
||||
int t_top = 0;
|
||||
|
|
@ -1819,14 +1818,13 @@ static void aw8695_haptic_context(struct aw8695 *aw8695, enum aw8695_haptic_mode
|
|||
aw8695->gain = 0x20;
|
||||
break;
|
||||
case HAPTIC_LONG:
|
||||
aw8695->gain = 0x06;
|
||||
aw8695->gain = aw8695->long_gain_reduced;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void aw8695_vibrate(struct aw8695 *aw8695, int value)
|
||||
{
|
||||
|
|
@ -1841,11 +1839,20 @@ static void aw8695_vibrate(struct aw8695 *aw8695, int value)
|
|||
|
||||
if (seq >= AW8695_SEQ_NO_RTP_BASE) {
|
||||
aw8695->haptic_mode = HAPTIC_RTP;
|
||||
aw8695->gain = 0x20;
|
||||
} else if (value < 100 || seq > 2) {
|
||||
aw8695->haptic_mode = HAPTIC_SHORT;
|
||||
aw8695->gain = 0x20;
|
||||
} else {
|
||||
aw8695->haptic_mode = HAPTIC_LONG;
|
||||
aw8695->gain = aw8695->long_gain_normal;
|
||||
}
|
||||
if(!aw8695->factory_mode)
|
||||
aw8695_haptic_context(aw8695,aw8695->haptic_mode);
|
||||
if (aw8695->debugfs_debug)
|
||||
aw8695_haptic_set_gain(aw8695, aw8695->gain_debug);
|
||||
else
|
||||
aw8695_haptic_set_gain(aw8695, aw8695->gain);
|
||||
|
||||
switch (aw8695->haptic_mode) {
|
||||
|
||||
|
|
@ -2194,7 +2201,7 @@ static ssize_t aw8695_gain_show(struct device *dev,
|
|||
struct led_classdev *cdev = dev_get_drvdata(dev);
|
||||
struct aw8695 *aw8695 = container_of(cdev, struct aw8695, cdev);
|
||||
#endif
|
||||
return snprintf(buf, PAGE_SIZE, "0x%02x\n", aw8695->gain);
|
||||
return snprintf(buf, PAGE_SIZE, "0x%02x\n", aw8695->gain_debug);
|
||||
}
|
||||
|
||||
static ssize_t aw8695_gain_store(struct device *dev,
|
||||
|
|
@ -2217,8 +2224,12 @@ static ssize_t aw8695_gain_store(struct device *dev,
|
|||
pr_debug("%s: value=%d\n", __FUNCTION__, val);
|
||||
|
||||
mutex_lock(&aw8695->lock);
|
||||
aw8695->gain = val;
|
||||
aw8695_haptic_set_gain(aw8695, aw8695->gain);
|
||||
if (val > 0)
|
||||
aw8695->debugfs_debug = true;
|
||||
else
|
||||
aw8695->debugfs_debug = false;
|
||||
aw8695->gain_debug = val;
|
||||
aw8695_haptic_set_gain(aw8695, aw8695->gain_debug);
|
||||
mutex_unlock(&aw8695->lock);
|
||||
return count;
|
||||
}
|
||||
|
|
@ -3340,6 +3351,8 @@ static irqreturn_t aw8695_irq(int irq, void *data)
|
|||
static int aw8695_parse_dt(struct device *dev, struct aw8695 *aw8695,
|
||||
struct device_node *np)
|
||||
{
|
||||
int rc;
|
||||
|
||||
aw8695->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0);
|
||||
if (aw8695->reset_gpio < 0) {
|
||||
dev_err(dev, "%s: no reset gpio provided, will not HW reset device\n", __func__);
|
||||
|
|
@ -3354,6 +3367,26 @@ static int aw8695_parse_dt(struct device *dev, struct aw8695 *aw8695,
|
|||
dev_info(dev, "%s: irq gpio provided ok.\n", __func__);
|
||||
}
|
||||
|
||||
aw8695->haptic_context_gpio = of_get_named_gpio(np, "haptic-context-gpio", 0);
|
||||
if (aw8695->haptic_context_gpio < 0) {
|
||||
dev_err(dev, "%s: no haptic context gpio provided.\n", __func__);
|
||||
} else {
|
||||
dev_info(dev, "%s: haptic context gpio provided ok.\n", __func__);
|
||||
}
|
||||
|
||||
rc = of_property_read_s32(np, "long-gain-normal", &aw8695->long_gain_normal);
|
||||
if (rc) {
|
||||
aw8695->long_gain_normal = 0x0e;
|
||||
dev_err(dev, "%s: no normal gain value for long vibrating provided.\n", __func__);
|
||||
}
|
||||
dev_info(dev, "%s: normal gain value for long vibrating is 0x%02x.\n", __func__, aw8695->long_gain_normal);
|
||||
|
||||
rc = of_property_read_s32(np, "long-gain-reduced", &aw8695->long_gain_reduced);
|
||||
if (rc) {
|
||||
aw8695->long_gain_reduced = 0x06;
|
||||
dev_err(dev, "%s: no reduced gain value for long vibrating provided.\n", __func__);
|
||||
}
|
||||
dev_info(dev, "%s: reduced gain value for long vibrating is 0x%02x.\n", __func__, aw8695->long_gain_reduced);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -3396,9 +3429,9 @@ static int aw8695_read_chipid(struct aw8695 *aw8695)
|
|||
case AW8695_CHIPID:
|
||||
pr_info("%s aw8695 detected\n", __func__);
|
||||
aw8695->chipid = AW8695_CHIPID;
|
||||
/*
|
||||
/*
|
||||
*aw8695->flags |= AW8695_FLAG_SKIP_INTERRUPTS;
|
||||
*/
|
||||
*/
|
||||
aw8695_haptic_softreset(aw8695);
|
||||
return 0;
|
||||
default:
|
||||
|
|
@ -3504,6 +3537,15 @@ static struct attribute_group aw8695_attribute_group = {
|
|||
.attrs = aw8695_attributes
|
||||
};
|
||||
|
||||
static bool mmi_factory_check(void)
|
||||
{
|
||||
struct device_node *np = of_find_node_by_path("/chosen");
|
||||
bool factory = false;
|
||||
if (np)
|
||||
factory = of_property_read_bool(np, "mmi,factory-cable");
|
||||
of_node_put(np);
|
||||
return factory;
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
*
|
||||
|
|
@ -3601,6 +3643,7 @@ static int aw8695_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *
|
|||
|
||||
g_aw8695 = aw8695;
|
||||
|
||||
aw8695->factory_mode = mmi_factory_check();
|
||||
aw8695_vibrator_init(aw8695);
|
||||
|
||||
aw8695_haptic_init(aw8695);
|
||||
|
|
|
|||
|
|
@ -311,8 +311,12 @@ struct aw8695 {
|
|||
int reset_gpio;
|
||||
int irq_gpio;
|
||||
int haptic_context_gpio;
|
||||
int long_gain_normal;
|
||||
int long_gain_reduced;
|
||||
|
||||
enum aw8695_haptic_mode haptic_mode;
|
||||
bool factory_mode;
|
||||
bool debugfs_debug;
|
||||
atomic_t reduce_pwr;
|
||||
unsigned char hwen_flag;
|
||||
unsigned char flags;
|
||||
|
|
@ -330,7 +334,7 @@ struct aw8695 {
|
|||
int index;
|
||||
int vmax;
|
||||
int gain;
|
||||
|
||||
int gain_debug;
|
||||
unsigned char seq[AW8695_SEQUENCER_SIZE];
|
||||
unsigned char loop[AW8695_SEQUENCER_SIZE];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue