Blame view

drivers/input/ff-memless.c 14.2 KB
7d928a2b1   Anssi Hannula   Input: unified fo...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  /*
   *  Force feedback support for memoryless devices
   *
   *  Copyright (c) 2006 Anssi Hannula <anssi.hannula@gmail.com>
   *  Copyright (c) 2006 Dmitry Torokhov <dtor@mail.ru>
   */
  
  /*
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   */
  
  /* #define DEBUG */
da0c49011   Joe Perches   Input: use pr_fmt...
25
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7d928a2b1   Anssi Hannula   Input: unified fo...
26

5a0e3ad6a   Tejun Heo   include cleanup: ...
27
  #include <linux/slab.h>
7d928a2b1   Anssi Hannula   Input: unified fo...
28
29
30
31
  #include <linux/input.h>
  #include <linux/module.h>
  #include <linux/mutex.h>
  #include <linux/spinlock.h>
cd354f1ae   Tim Schmielau   [PATCH] remove ma...
32
  #include <linux/jiffies.h>
7d928a2b1   Anssi Hannula   Input: unified fo...
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  
  #include "fixp-arith.h"
  
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("Anssi Hannula <anssi.hannula@gmail.com>");
  MODULE_DESCRIPTION("Force feedback support for memoryless devices");
  
  /* Number of effects handled with memoryless devices */
  #define FF_MEMLESS_EFFECTS	16
  
  /* Envelope update interval in ms */
  #define FF_ENVELOPE_INTERVAL	50
  
  #define FF_EFFECT_STARTED	0
  #define FF_EFFECT_PLAYING	1
  #define FF_EFFECT_ABORTING	2
  
  struct ml_effect_state {
  	struct ff_effect *effect;
  	unsigned long flags;	/* effect state (STARTED, PLAYING, etc) */
  	int count;		/* loop count of the effect */
  	unsigned long play_at;	/* start time */
  	unsigned long stop_at;	/* stop time */
  	unsigned long adj_at;	/* last time the effect was sent */
  };
  
  struct ml_device {
  	void *private;
  	struct ml_effect_state states[FF_MEMLESS_EFFECTS];
  	int gain;
  	struct timer_list timer;
7d928a2b1   Anssi Hannula   Input: unified fo...
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
  	struct input_dev *dev;
  
  	int (*play_effect)(struct input_dev *dev, void *data,
  			   struct ff_effect *effect);
  };
  
  static const struct ff_envelope *get_envelope(const struct ff_effect *effect)
  {
  	static const struct ff_envelope empty_envelope;
  
  	switch (effect->type) {
  		case FF_PERIODIC:
  			return &effect->u.periodic.envelope;
  		case FF_CONSTANT:
  			return &effect->u.constant.envelope;
  		default:
  			return &empty_envelope;
  	}
  }
  
  /*
   * Check for the next time envelope requires an update on memoryless devices
   */
  static unsigned long calculate_next_time(struct ml_effect_state *state)
  {
  	const struct ff_envelope *envelope = get_envelope(state->effect);
  	unsigned long attack_stop, fade_start, next_fade;
  
  	if (envelope->attack_length) {
  		attack_stop = state->play_at +
  			msecs_to_jiffies(envelope->attack_length);
  		if (time_before(state->adj_at, attack_stop))
  			return state->adj_at +
  					msecs_to_jiffies(FF_ENVELOPE_INTERVAL);
  	}
  
  	if (state->effect->replay.length) {
  		if (envelope->fade_length) {
  			/* check when fading should start */
  			fade_start = state->stop_at -
  					msecs_to_jiffies(envelope->fade_length);
  
  			if (time_before(state->adj_at, fade_start))
  				return fade_start;
  
  			/* already fading, advance to next checkpoint */
  			next_fade = state->adj_at +
  					msecs_to_jiffies(FF_ENVELOPE_INTERVAL);
  			if (time_before(next_fade, state->stop_at))
  				return next_fade;
  		}
  
  		return state->stop_at;
  	}
  
  	return state->play_at;
  }
  
  static void ml_schedule_timer(struct ml_device *ml)
  {
  	struct ml_effect_state *state;
  	unsigned long now = jiffies;
  	unsigned long earliest = 0;
  	unsigned long next_at;
  	int events = 0;
  	int i;
da0c49011   Joe Perches   Input: use pr_fmt...
130
131
  	pr_debug("calculating next timer
  ");
7d928a2b1   Anssi Hannula   Input: unified fo...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
  
  	for (i = 0; i < FF_MEMLESS_EFFECTS; i++) {
  
  		state = &ml->states[i];
  
  		if (!test_bit(FF_EFFECT_STARTED, &state->flags))
  			continue;
  
  		if (test_bit(FF_EFFECT_PLAYING, &state->flags))
  			next_at = calculate_next_time(state);
  		else
  			next_at = state->play_at;
  
  		if (time_before_eq(now, next_at) &&
  		    (++events == 1 || time_before(next_at, earliest)))
  			earliest = next_at;
  	}
  
  	if (!events) {
da0c49011   Joe Perches   Input: use pr_fmt...
151
152
  		pr_debug("no actions
  ");
7d928a2b1   Anssi Hannula   Input: unified fo...
153
154
  		del_timer(&ml->timer);
  	} else {
da0c49011   Joe Perches   Input: use pr_fmt...
155
156
  		pr_debug("timer set
  ");
7d928a2b1   Anssi Hannula   Input: unified fo...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
  		mod_timer(&ml->timer, earliest);
  	}
  }
  
  /*
   * Apply an envelope to a value
   */
  static int apply_envelope(struct ml_effect_state *state, int value,
  			  struct ff_envelope *envelope)
  {
  	struct ff_effect *effect = state->effect;
  	unsigned long now = jiffies;
  	int time_from_level;
  	int time_of_envelope;
  	int envelope_level;
  	int difference;
  
  	if (envelope->attack_length &&
  	    time_before(now,
  			state->play_at + msecs_to_jiffies(envelope->attack_length))) {
da0c49011   Joe Perches   Input: use pr_fmt...
177
178
179
  		pr_debug("value = 0x%x, attack_level = 0x%x
  ",
  			 value, envelope->attack_level);
7d928a2b1   Anssi Hannula   Input: unified fo...
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
  		time_from_level = jiffies_to_msecs(now - state->play_at);
  		time_of_envelope = envelope->attack_length;
  		envelope_level = min_t(__s16, envelope->attack_level, 0x7fff);
  
  	} else if (envelope->fade_length && effect->replay.length &&
  		   time_after(now,
  			      state->stop_at - msecs_to_jiffies(envelope->fade_length)) &&
  		   time_before(now, state->stop_at)) {
  		time_from_level = jiffies_to_msecs(state->stop_at - now);
  		time_of_envelope = envelope->fade_length;
  		envelope_level = min_t(__s16, envelope->fade_level, 0x7fff);
  	} else
  		return value;
  
  	difference = abs(value) - envelope_level;
da0c49011   Joe Perches   Input: use pr_fmt...
195
196
197
198
199
200
  	pr_debug("difference = %d
  ", difference);
  	pr_debug("time_from_level = 0x%x
  ", time_from_level);
  	pr_debug("time_of_envelope = 0x%x
  ", time_of_envelope);
7d928a2b1   Anssi Hannula   Input: unified fo...
201
202
  
  	difference = difference * time_from_level / time_of_envelope;
da0c49011   Joe Perches   Input: use pr_fmt...
203
204
  	pr_debug("difference = %d
  ", difference);
7d928a2b1   Anssi Hannula   Input: unified fo...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
  
  	return value < 0 ?
  		-(difference + envelope_level) : (difference + envelope_level);
  }
  
  /*
   * Return the type the effect has to be converted into (memless devices)
   */
  static int get_compatible_type(struct ff_device *ff, int effect_type)
  {
  
  	if (test_bit(effect_type, ff->ffbit))
  		return effect_type;
  
  	if (effect_type == FF_PERIODIC && test_bit(FF_RUMBLE, ff->ffbit))
  		return FF_RUMBLE;
da0c49011   Joe Perches   Input: use pr_fmt...
221
222
  	pr_err("invalid type in get_compatible_type()
  ");
7d928a2b1   Anssi Hannula   Input: unified fo...
223
224
225
226
227
  
  	return 0;
  }
  
  /*
94ec26c85   Jari Vanhala   Input: ff-memless...
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
   * Only left/right direction should be used (under/over 0x8000) for
   * forward/reverse motor direction (to keep calculation fast & simple).
   */
  static u16 ml_calculate_direction(u16 direction, u16 force,
  				  u16 new_direction, u16 new_force)
  {
  	if (!force)
  		return new_direction;
  	if (!new_force)
  		return direction;
  	return (((u32)(direction >> 1) * force +
  		 (new_direction >> 1) * new_force) /
  		(force + new_force)) << 1;
  }
  
  /*
7d928a2b1   Anssi Hannula   Input: unified fo...
244
245
246
247
   * Combine two effects and apply gain.
   */
  static void ml_combine_effects(struct ff_effect *effect,
  			       struct ml_effect_state *state,
1b11c88d3   Dmitry Torokhov   Input: ff-memless...
248
  			       int gain)
7d928a2b1   Anssi Hannula   Input: unified fo...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
  {
  	struct ff_effect *new = state->effect;
  	unsigned int strong, weak, i;
  	int x, y;
  	fixp_t level;
  
  	switch (new->type) {
  	case FF_CONSTANT:
  		i = new->direction * 360 / 0xffff;
  		level = fixp_new16(apply_envelope(state,
  					new->u.constant.level,
  					&new->u.constant.envelope));
  		x = fixp_mult(fixp_sin(i), level) * gain / 0xffff;
  		y = fixp_mult(-fixp_cos(i), level) * gain / 0xffff;
  		/*
  		 * here we abuse ff_ramp to hold x and y of constant force
  		 * If in future any driver wants something else than x and y
  		 * in s8, this should be changed to something more generic
  		 */
  		effect->u.ramp.start_level =
923104747   Harvey Harrison   Input: use clamp_...
269
  			clamp_val(effect->u.ramp.start_level + x, -0x80, 0x7f);
7d928a2b1   Anssi Hannula   Input: unified fo...
270
  		effect->u.ramp.end_level =
923104747   Harvey Harrison   Input: use clamp_...
271
  			clamp_val(effect->u.ramp.end_level + y, -0x80, 0x7f);
7d928a2b1   Anssi Hannula   Input: unified fo...
272
273
274
  		break;
  
  	case FF_RUMBLE:
1b11c88d3   Dmitry Torokhov   Input: ff-memless...
275
276
  		strong = (u32)new->u.rumble.strong_magnitude * gain / 0xffff;
  		weak = (u32)new->u.rumble.weak_magnitude * gain / 0xffff;
94ec26c85   Jari Vanhala   Input: ff-memless...
277
278
279
280
281
282
283
284
285
286
287
288
289
  
  		if (effect->u.rumble.strong_magnitude + strong)
  			effect->direction = ml_calculate_direction(
  				effect->direction,
  				effect->u.rumble.strong_magnitude,
  				new->direction, strong);
  		else if (effect->u.rumble.weak_magnitude + weak)
  			effect->direction = ml_calculate_direction(
  				effect->direction,
  				effect->u.rumble.weak_magnitude,
  				new->direction, weak);
  		else
  			effect->direction = 0;
7d928a2b1   Anssi Hannula   Input: unified fo...
290
291
292
293
294
295
296
297
298
299
300
301
302
  		effect->u.rumble.strong_magnitude =
  			min(strong + effect->u.rumble.strong_magnitude,
  			    0xffffU);
  		effect->u.rumble.weak_magnitude =
  			min(weak + effect->u.rumble.weak_magnitude, 0xffffU);
  		break;
  
  	case FF_PERIODIC:
  		i = apply_envelope(state, abs(new->u.periodic.magnitude),
  				   &new->u.periodic.envelope);
  
  		/* here we also scale it 0x7fff => 0xffff */
  		i = i * gain / 0x7fff;
94ec26c85   Jari Vanhala   Input: ff-memless...
303
304
305
306
307
308
309
  		if (effect->u.rumble.strong_magnitude + i)
  			effect->direction = ml_calculate_direction(
  				effect->direction,
  				effect->u.rumble.strong_magnitude,
  				new->direction, i);
  		else
  			effect->direction = 0;
7d928a2b1   Anssi Hannula   Input: unified fo...
310
311
312
313
314
315
316
  		effect->u.rumble.strong_magnitude =
  			min(i + effect->u.rumble.strong_magnitude, 0xffffU);
  		effect->u.rumble.weak_magnitude =
  			min(i + effect->u.rumble.weak_magnitude, 0xffffU);
  		break;
  
  	default:
da0c49011   Joe Perches   Input: use pr_fmt...
317
318
  		pr_err("invalid type in ml_combine_effects()
  ");
7d928a2b1   Anssi Hannula   Input: unified fo...
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
  		break;
  	}
  
  }
  
  
  /*
   * Because memoryless devices have only one effect per effect type active
   * at one time we have to combine multiple effects into one
   */
  static int ml_get_combo_effect(struct ml_device *ml,
  			       unsigned long *effect_handled,
  			       struct ff_effect *combo_effect)
  {
  	struct ff_effect *effect;
  	struct ml_effect_state *state;
  	int effect_type;
  	int i;
  
  	memset(combo_effect, 0, sizeof(struct ff_effect));
  
  	for (i = 0; i < FF_MEMLESS_EFFECTS; i++) {
  		if (__test_and_set_bit(i, effect_handled))
  			continue;
  
  		state = &ml->states[i];
  		effect = state->effect;
  
  		if (!test_bit(FF_EFFECT_STARTED, &state->flags))
  			continue;
  
  		if (time_before(jiffies, state->play_at))
  			continue;
  
  		/*
  		 * here we have started effects that are either
  		 * currently playing (and may need be aborted)
  		 * or need to start playing.
  		 */
  		effect_type = get_compatible_type(ml->dev->ff, effect->type);
  		if (combo_effect->type != effect_type) {
  			if (combo_effect->type != 0) {
  				__clear_bit(i, effect_handled);
  				continue;
  			}
  			combo_effect->type = effect_type;
  		}
  
  		if (__test_and_clear_bit(FF_EFFECT_ABORTING, &state->flags)) {
  			__clear_bit(FF_EFFECT_PLAYING, &state->flags);
  			__clear_bit(FF_EFFECT_STARTED, &state->flags);
  		} else if (effect->replay.length &&
  			   time_after_eq(jiffies, state->stop_at)) {
  
  			__clear_bit(FF_EFFECT_PLAYING, &state->flags);
  
  			if (--state->count <= 0) {
  				__clear_bit(FF_EFFECT_STARTED, &state->flags);
  			} else {
  				state->play_at = jiffies +
  					msecs_to_jiffies(effect->replay.delay);
  				state->stop_at = state->play_at +
  					msecs_to_jiffies(effect->replay.length);
  			}
  		} else {
  			__set_bit(FF_EFFECT_PLAYING, &state->flags);
  			state->adj_at = jiffies;
  			ml_combine_effects(combo_effect, state, ml->gain);
  		}
  	}
  
  	return combo_effect->type != 0;
  }
  
  static void ml_play_effects(struct ml_device *ml)
  {
  	struct ff_effect effect;
  	DECLARE_BITMAP(handled_bm, FF_MEMLESS_EFFECTS);
  
  	memset(handled_bm, 0, sizeof(handled_bm));
  
  	while (ml_get_combo_effect(ml, handled_bm, &effect))
  		ml->play_effect(ml->dev, ml->private, &effect);
  
  	ml_schedule_timer(ml);
  }
  
  static void ml_effect_timer(unsigned long timer_data)
  {
  	struct input_dev *dev = (struct input_dev *)timer_data;
  	struct ml_device *ml = dev->ff->private;
bf3204cbf   Dmitry Torokhov   Input: fix lockin...
410
  	unsigned long flags;
7d928a2b1   Anssi Hannula   Input: unified fo...
411

da0c49011   Joe Perches   Input: use pr_fmt...
412
413
  	pr_debug("timer: updating effects
  ");
7d928a2b1   Anssi Hannula   Input: unified fo...
414

bf3204cbf   Dmitry Torokhov   Input: fix lockin...
415
  	spin_lock_irqsave(&dev->event_lock, flags);
7d928a2b1   Anssi Hannula   Input: unified fo...
416
  	ml_play_effects(ml);
bf3204cbf   Dmitry Torokhov   Input: fix lockin...
417
  	spin_unlock_irqrestore(&dev->event_lock, flags);
7d928a2b1   Anssi Hannula   Input: unified fo...
418
  }
bf3204cbf   Dmitry Torokhov   Input: fix lockin...
419
420
421
  /*
   * Sets requested gain for FF effects. Called with dev->event_lock held.
   */
7d928a2b1   Anssi Hannula   Input: unified fo...
422
423
424
425
  static void ml_ff_set_gain(struct input_dev *dev, u16 gain)
  {
  	struct ml_device *ml = dev->ff->private;
  	int i;
7d928a2b1   Anssi Hannula   Input: unified fo...
426
427
428
429
430
431
  	ml->gain = gain;
  
  	for (i = 0; i < FF_MEMLESS_EFFECTS; i++)
  		__clear_bit(FF_EFFECT_PLAYING, &ml->states[i].flags);
  
  	ml_play_effects(ml);
7d928a2b1   Anssi Hannula   Input: unified fo...
432
  }
bf3204cbf   Dmitry Torokhov   Input: fix lockin...
433
434
435
  /*
   * Start/stop specified FF effect. Called with dev->event_lock held.
   */
7d928a2b1   Anssi Hannula   Input: unified fo...
436
437
438
439
  static int ml_ff_playback(struct input_dev *dev, int effect_id, int value)
  {
  	struct ml_device *ml = dev->ff->private;
  	struct ml_effect_state *state = &ml->states[effect_id];
7d928a2b1   Anssi Hannula   Input: unified fo...
440
441
  
  	if (value > 0) {
da0c49011   Joe Perches   Input: use pr_fmt...
442
443
  		pr_debug("initiated play
  ");
7d928a2b1   Anssi Hannula   Input: unified fo...
444
445
446
447
448
449
450
451
  
  		__set_bit(FF_EFFECT_STARTED, &state->flags);
  		state->count = value;
  		state->play_at = jiffies +
  				 msecs_to_jiffies(state->effect->replay.delay);
  		state->stop_at = state->play_at +
  				 msecs_to_jiffies(state->effect->replay.length);
  		state->adj_at = state->play_at;
7d928a2b1   Anssi Hannula   Input: unified fo...
452
  	} else {
da0c49011   Joe Perches   Input: use pr_fmt...
453
454
  		pr_debug("initiated stop
  ");
7d928a2b1   Anssi Hannula   Input: unified fo...
455
456
457
458
459
  
  		if (test_bit(FF_EFFECT_PLAYING, &state->flags))
  			__set_bit(FF_EFFECT_ABORTING, &state->flags);
  		else
  			__clear_bit(FF_EFFECT_STARTED, &state->flags);
7d928a2b1   Anssi Hannula   Input: unified fo...
460
  	}
25ae08317   Jari Vanhala   Input: ff-memless...
461
  	ml_play_effects(ml);
7d928a2b1   Anssi Hannula   Input: unified fo...
462
463
464
465
466
467
468
469
  	return 0;
  }
  
  static int ml_ff_upload(struct input_dev *dev,
  			struct ff_effect *effect, struct ff_effect *old)
  {
  	struct ml_device *ml = dev->ff->private;
  	struct ml_effect_state *state = &ml->states[effect->id];
bf3204cbf   Dmitry Torokhov   Input: fix lockin...
470
  	spin_lock_irq(&dev->event_lock);
7d928a2b1   Anssi Hannula   Input: unified fo...
471
472
473
474
475
476
477
478
479
480
  
  	if (test_bit(FF_EFFECT_STARTED, &state->flags)) {
  		__clear_bit(FF_EFFECT_PLAYING, &state->flags);
  		state->play_at = jiffies +
  				 msecs_to_jiffies(state->effect->replay.delay);
  		state->stop_at = state->play_at +
  				 msecs_to_jiffies(state->effect->replay.length);
  		state->adj_at = state->play_at;
  		ml_schedule_timer(ml);
  	}
bf3204cbf   Dmitry Torokhov   Input: fix lockin...
481
  	spin_unlock_irq(&dev->event_lock);
7d928a2b1   Anssi Hannula   Input: unified fo...
482
483
484
485
486
487
488
489
490
491
492
493
  
  	return 0;
  }
  
  static void ml_ff_destroy(struct ff_device *ff)
  {
  	struct ml_device *ml = ff->private;
  
  	kfree(ml->private);
  }
  
  /**
e4477d2d1   Randy Dunlap   Input: add to ker...
494
   * input_ff_create_memless() - create memoryless force-feedback device
7d928a2b1   Anssi Hannula   Input: unified fo...
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
   * @dev: input device supporting force-feedback
   * @data: driver-specific data to be passed into @play_effect
   * @play_effect: driver-specific method for playing FF effect
   */
  int input_ff_create_memless(struct input_dev *dev, void *data,
  		int (*play_effect)(struct input_dev *, void *, struct ff_effect *))
  {
  	struct ml_device *ml;
  	struct ff_device *ff;
  	int error;
  	int i;
  
  	ml = kzalloc(sizeof(struct ml_device), GFP_KERNEL);
  	if (!ml)
  		return -ENOMEM;
  
  	ml->dev = dev;
  	ml->private = data;
  	ml->play_effect = play_effect;
  	ml->gain = 0xffff;
7d928a2b1   Anssi Hannula   Input: unified fo...
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
  	setup_timer(&ml->timer, ml_effect_timer, (unsigned long)dev);
  
  	set_bit(FF_GAIN, dev->ffbit);
  
  	error = input_ff_create(dev, FF_MEMLESS_EFFECTS);
  	if (error) {
  		kfree(ml);
  		return error;
  	}
  
  	ff = dev->ff;
  	ff->private = ml;
  	ff->upload = ml_ff_upload;
  	ff->playback = ml_ff_playback;
  	ff->set_gain = ml_ff_set_gain;
  	ff->destroy = ml_ff_destroy;
  
  	/* we can emulate periodic effects with RUMBLE */
  	if (test_bit(FF_RUMBLE, ff->ffbit)) {
  		set_bit(FF_PERIODIC, dev->ffbit);
  		set_bit(FF_SINE, dev->ffbit);
  		set_bit(FF_TRIANGLE, dev->ffbit);
  		set_bit(FF_SQUARE, dev->ffbit);
  	}
  
  	for (i = 0; i < FF_MEMLESS_EFFECTS; i++)
  		ml->states[i].effect = &ff->effects[i];
  
  	return 0;
  }
  EXPORT_SYMBOL_GPL(input_ff_create_memless);