Skip to content

Commit 53ba7a4

Browse files
Griffin Kroah-Hartmandtor
authored andcommitted
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>
1 parent 4decd8f commit 53ba7a4

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/input/misc/aw86927.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct aw86927_data {
180180
struct i2c_client *client;
181181
struct regmap *regmap;
182182
struct gpio_desc *reset_gpio;
183-
bool running;
183+
u16 level;
184184
};
185185

186186
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
325325
if (!level)
326326
level = effect->u.rumble.weak_magnitude;
327327

328-
/* If already running, don't restart playback */
329-
if (haptics->running && level)
328+
/* If level does not change, don't restart playback */
329+
if (haptics->level == level)
330330
return 0;
331331

332-
haptics->running = level;
332+
haptics->level = level;
333+
333334
schedule_work(&haptics->play_work);
334335

335336
return 0;
@@ -376,8 +377,7 @@ static int aw86927_play_sine(struct aw86927_data *haptics)
376377
if (err)
377378
return err;
378379

379-
/* set gain to value lower than 0x80 to avoid distorted playback */
380-
err = regmap_write(haptics->regmap, AW86927_PLAYCFG2_REG, 0x7c);
380+
err = regmap_write(haptics->regmap, AW86927_PLAYCFG2_REG, haptics->level * 0x80 / 0xffff);
381381
if (err)
382382
return err;
383383

@@ -409,7 +409,7 @@ static void aw86927_haptics_play_work(struct work_struct *work)
409409
struct device *dev = &haptics->client->dev;
410410
int err;
411411

412-
if (haptics->running)
412+
if (haptics->level)
413413
err = aw86927_play_sine(haptics);
414414
else
415415
err = aw86927_stop(haptics);

0 commit comments

Comments
 (0)