|
Lines 70-79
struct max77693_haptic {
Link Here
|
| 70 |
|
70 |
|
| 71 |
static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic) |
71 |
static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic) |
| 72 |
{ |
72 |
{ |
| 73 |
int delta = (haptic->pwm_dev->period + haptic->pwm_duty) / 2; |
73 |
struct pwm_args pargs; |
|
|
74 |
int delta; |
| 74 |
int error; |
75 |
int error; |
| 75 |
|
76 |
|
| 76 |
error = pwm_config(haptic->pwm_dev, delta, haptic->pwm_dev->period); |
77 |
pwm_get_args(haptic->pwm_dev, &pargs); |
|
|
78 |
delta = (pargs.period + haptic->pwm_duty) / 2; |
| 79 |
error = pwm_config(haptic->pwm_dev, delta, pargs.period); |
| 77 |
if (error) { |
80 |
if (error) { |
| 78 |
dev_err(haptic->dev, "failed to configure pwm: %d\n", error); |
81 |
dev_err(haptic->dev, "failed to configure pwm: %d\n", error); |
| 79 |
return error; |
82 |
return error; |
|
Lines 234-239
static int max77693_haptic_play_effect(struct input_dev *dev, void *data,
Link Here
|
| 234 |
struct ff_effect *effect) |
237 |
struct ff_effect *effect) |
| 235 |
{ |
238 |
{ |
| 236 |
struct max77693_haptic *haptic = input_get_drvdata(dev); |
239 |
struct max77693_haptic *haptic = input_get_drvdata(dev); |
|
|
240 |
struct pwm_args pargs; |
| 237 |
u64 period_mag_multi; |
241 |
u64 period_mag_multi; |
| 238 |
|
242 |
|
| 239 |
haptic->magnitude = effect->u.rumble.strong_magnitude; |
243 |
haptic->magnitude = effect->u.rumble.strong_magnitude; |
|
Lines 245-251
static int max77693_haptic_play_effect(struct input_dev *dev, void *data,
Link Here
|
| 245 |
* The formula to convert magnitude to pwm_duty as follows: |
249 |
* The formula to convert magnitude to pwm_duty as follows: |
| 246 |
* - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF) |
250 |
* - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF) |
| 247 |
*/ |
251 |
*/ |
| 248 |
period_mag_multi = (u64)haptic->pwm_dev->period * haptic->magnitude; |
252 |
pwm_get_args(haptic->pwm_dev, &pargs); |
|
|
253 |
period_mag_multi = (u64)pargs.period * haptic->magnitude; |
| 249 |
haptic->pwm_duty = (unsigned int)(period_mag_multi >> |
254 |
haptic->pwm_duty = (unsigned int)(period_mag_multi >> |
| 250 |
MAX_MAGNITUDE_SHIFT); |
255 |
MAX_MAGNITUDE_SHIFT); |
| 251 |
|
256 |
|
|
Lines 329-334
static int max77693_haptic_probe(struct platform_device *pdev)
Link Here
|
| 329 |
return PTR_ERR(haptic->pwm_dev); |
334 |
return PTR_ERR(haptic->pwm_dev); |
| 330 |
} |
335 |
} |
| 331 |
|
336 |
|
|
|
337 |
/* |
| 338 |
* FIXME: pwm_apply_args() should be removed when switching to the |
| 339 |
* atomic PWM API. |
| 340 |
*/ |
| 341 |
pwm_apply_args(haptic->pwm_dev); |
| 342 |
|
| 332 |
haptic->motor_reg = devm_regulator_get(&pdev->dev, "haptic"); |
343 |
haptic->motor_reg = devm_regulator_get(&pdev->dev, "haptic"); |
| 333 |
if (IS_ERR(haptic->motor_reg)) { |
344 |
if (IS_ERR(haptic->motor_reg)) { |
| 334 |
dev_err(&pdev->dev, "failed to get regulator\n"); |
345 |
dev_err(&pdev->dev, "failed to get regulator\n"); |
| 335 |
- |
|
|