summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGriffin Kroah-Hartman <griffin.kroah@fairphone.com>2026-03-04 04:37:18 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2026-04-01 19:08:32 +0300
commit53ba7a47d3783192e6846cbb42f246f0fb9f9488 (patch)
treed0265b0e954b03af7060c09465a639d465b9f1fd
parent4decd8f4ae06a6d82079186b6ad3fe51d4654a1d (diff)
downloadlinux-53ba7a47d3783192e6846cbb42f246f0fb9f9488.tar.xz
Input: aw86927 - respect vibration magnitude levels
Previously the gain value was hardcoded. Take the magnitude passed via the input API and configure the gain register accordingly. Signed-off-by: Griffin Kroah-Hartman <griffin.kroah@fairphone.com> Link: https://patch.msgid.link/20260302-aw86938-driver-v4-1-92c865df9cca@fairphone.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/misc/aw86927.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
index 8ad361239cfe..454e1af23df0 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -180,7 +180,7 @@ struct aw86927_data {
struct i2c_client *client;
struct regmap *regmap;
struct gpio_desc *reset_gpio;
- bool running;
+ u16 level;
};
static const struct regmap_config aw86927_regmap_config = {
@@ -325,11 +325,12 @@ static int aw86927_haptics_play(struct input_dev *dev, void *data, struct ff_eff
if (!level)
level = effect->u.rumble.weak_magnitude;
- /* If already running, don't restart playback */
- if (haptics->running && level)
+ /* If level does not change, don't restart playback */
+ if (haptics->level == level)
return 0;
- haptics->running = level;
+ haptics->level = level;
+
schedule_work(&haptics->play_work);
return 0;
@@ -376,8 +377,7 @@ static int aw86927_play_sine(struct aw86927_data *haptics)
if (err)
return err;
- /* set gain to value lower than 0x80 to avoid distorted playback */
- err = regmap_write(haptics->regmap, AW86927_PLAYCFG2_REG, 0x7c);
+ err = regmap_write(haptics->regmap, AW86927_PLAYCFG2_REG, haptics->level * 0x80 / 0xffff);
if (err)
return err;
@@ -409,7 +409,7 @@ static void aw86927_haptics_play_work(struct work_struct *work)
struct device *dev = &haptics->client->dev;
int err;
- if (haptics->running)
+ if (haptics->level)
err = aw86927_play_sine(haptics);
else
err = aw86927_stop(haptics);