26 #include <linux/hid.h>
27 #include <linux/input.h>
28 #include <linux/module.h>
29 #include <linux/slab.h>
34 #ifdef CONFIG_HOLTEK_FF
83 #define HOLTEKFF_MSG_LENGTH 7
85 static const u8 start_effect_1[] = { 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 };
86 static const u8 stop_all4[] = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
87 static const u8 stop_all6[] = { 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
89 struct holtekff_device {
93 static void holtekff_send(
struct holtekff_device *holtekff,
95 const u8 data[HOLTEKFF_MSG_LENGTH])
99 for (i = 0; i < HOLTEKFF_MSG_LENGTH; i++) {
100 holtekff->field->value[
i] =
data[
i];
108 static int holtekff_play(
struct input_dev *
dev,
void *
data,
111 struct hid_device *hid = input_get_drvdata(dev);
112 struct holtekff_device *holtekff =
data;
115 u8 buf[HOLTEKFF_MSG_LENGTH] =
116 { 0x01, 0x01, 0xff, 0xff, 0x10, 0xe0, 0x00 };
118 left = effect->
u.
rumble.strong_magnitude;
119 right = effect->
u.
rumble.weak_magnitude;
120 dbg_hid(
"called with 0x%04x 0x%04x\n", left, right);
122 if (!left && !right) {
123 holtekff_send(holtekff, hid, stop_all6);
133 buf[6] =
min(0xf, (left >> 12) + (right >> 12));
135 holtekff_send(holtekff, hid, buf);
136 holtekff_send(holtekff, hid, start_effect_1);
141 static int holtekff_init(
struct hid_device *hid)
143 struct holtekff_device *holtekff;
149 struct input_dev *dev = hidinput->
input;
152 if (list_empty(report_list)) {
153 hid_err(hid,
"no output report found\n");
159 if (report->
maxfield < 1 || report->
field[0]->report_count != 7) {
160 hid_err(hid,
"unexpected output report layout\n");
164 holtekff = kzalloc(
sizeof(*holtekff),
GFP_KERNEL);
170 holtekff->field = report->
field[0];
173 holtekff_send(holtekff, hid, stop_all4);
174 holtekff_send(holtekff, hid, stop_all6);
187 static inline int holtekff_init(
struct hid_device *hid)
197 ret = hid_parse(hdev);
199 hid_err(hdev,
"parse failed\n");
205 hid_err(hdev,
"hw start failed\n");
224 .id_table = holtek_devices,
225 .probe = holtek_probe,
228 static int __init holtek_init(
void)
233 static void __exit holtek_exit(
void)