diff options
-rw-r--r-- | drivers/hid/hid-lg4ff.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index 8782fe1aaa07..530fcd19e90e 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c | |||
@@ -218,12 +218,21 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud | |||
218 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; | 218 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
219 | struct hid_report *report = list_entry(report_list->next, struct hid_report, list); | 219 | struct hid_report *report = list_entry(report_list->next, struct hid_report, list); |
220 | __s32 *value = report->field[0]->value; | 220 | __s32 *value = report->field[0]->value; |
221 | __u32 expand_a, expand_b; | ||
222 | |||
223 | if (magnitude <= 0xaaaa) { | ||
224 | expand_a = 0x0c * magnitude; | ||
225 | expand_b = 0x80 * magnitude; | ||
226 | } else { | ||
227 | expand_a = (0x0c * 0xaaaa) + 0x06 * (magnitude - 0xaaaa); | ||
228 | expand_b = (0x80 * 0xaaaa) + 0xff * (magnitude - 0xaaaa); | ||
229 | } | ||
221 | 230 | ||
222 | value[0] = 0xfe; | 231 | value[0] = 0xfe; |
223 | value[1] = 0x0d; | 232 | value[1] = 0x0d; |
224 | value[2] = magnitude >> 13; | 233 | value[2] = expand_a / 0xaaaa; |
225 | value[3] = magnitude >> 13; | 234 | value[3] = expand_a / 0xaaaa; |
226 | value[4] = magnitude >> 8; | 235 | value[4] = expand_b / 0xaaaa; |
227 | value[5] = 0x00; | 236 | value[5] = 0x00; |
228 | value[6] = 0x00; | 237 | value[6] = 0x00; |
229 | 238 | ||