Lines Matching full:ff
23 static int check_effect_access(struct ff_device *ff, int effect_id, in check_effect_access() argument
26 if (effect_id < 0 || effect_id >= ff->max_effects || in check_effect_access()
27 !ff->effect_owners[effect_id]) in check_effect_access()
30 if (file && ff->effect_owners[effect_id] != file) in check_effect_access()
50 static int compat_effect(struct ff_device *ff, struct ff_effect *effect) in compat_effect() argument
56 if (!test_bit(FF_PERIODIC, ff->ffbit)) in compat_effect()
94 struct ff_device *ff = dev->ff; in input_ff_upload() local
116 if (!test_bit(effect->type, ff->ffbit)) { in input_ff_upload()
117 ret = compat_effect(ff, effect); in input_ff_upload()
122 mutex_lock(&ff->mutex); in input_ff_upload()
125 for (id = 0; id < ff->max_effects; id++) in input_ff_upload()
126 if (!ff->effect_owners[id]) in input_ff_upload()
129 if (id >= ff->max_effects) { in input_ff_upload()
140 ret = check_effect_access(ff, id, file); in input_ff_upload()
144 old = &ff->effects[id]; in input_ff_upload()
152 ret = ff->upload(dev, effect, old); in input_ff_upload()
157 ff->effects[id] = *effect; in input_ff_upload()
158 ff->effect_owners[id] = file; in input_ff_upload()
162 mutex_unlock(&ff->mutex); in input_ff_upload()
174 struct ff_device *ff = dev->ff; in erase_effect() local
177 error = check_effect_access(ff, effect_id, file); in erase_effect()
182 ff->playback(dev, effect_id, 0); in erase_effect()
183 ff->effect_owners[effect_id] = NULL; in erase_effect()
186 if (ff->erase) { in erase_effect()
187 error = ff->erase(dev, effect_id); in erase_effect()
190 ff->effect_owners[effect_id] = file; in erase_effect()
212 struct ff_device *ff = dev->ff; in input_ff_erase() local
218 mutex_lock(&ff->mutex); in input_ff_erase()
220 mutex_unlock(&ff->mutex); in input_ff_erase()
237 struct ff_device *ff = dev->ff; in input_ff_flush() local
242 mutex_lock(&ff->mutex); in input_ff_flush()
244 for (i = 0; i < ff->max_effects; i++) in input_ff_flush()
247 mutex_unlock(&ff->mutex); in input_ff_flush()
263 struct ff_device *ff = dev->ff; in input_ff_event() local
273 ff->set_gain(dev, value); in input_ff_event()
280 ff->set_autocenter(dev, value); in input_ff_event()
284 if (check_effect_access(ff, code, NULL) == 0) in input_ff_event()
285 ff->playback(dev, code, value); in input_ff_event()
301 * Once ff device is created you need to setup its upload, erase,
306 struct ff_device *ff; in input_ff_create() local
320 ff_dev_size = struct_size(ff, effect_owners, max_effects); in input_ff_create()
324 ff = kzalloc(ff_dev_size, GFP_KERNEL); in input_ff_create()
325 if (!ff) in input_ff_create()
328 ff->effects = kcalloc(max_effects, sizeof(struct ff_effect), in input_ff_create()
330 if (!ff->effects) { in input_ff_create()
331 kfree(ff); in input_ff_create()
335 ff->max_effects = max_effects; in input_ff_create()
336 mutex_init(&ff->mutex); in input_ff_create()
338 dev->ff = ff; in input_ff_create()
343 /* Copy "true" bits into ff device bitmap */ in input_ff_create()
345 __set_bit(i, ff->ffbit); in input_ff_create()
348 if (test_bit(FF_PERIODIC, ff->ffbit)) in input_ff_create()
365 struct ff_device *ff = dev->ff; in input_ff_destroy() local
368 if (ff) { in input_ff_destroy()
369 if (ff->destroy) in input_ff_destroy()
370 ff->destroy(ff); in input_ff_destroy()
371 kfree(ff->private); in input_ff_destroy()
372 kfree(ff->effects); in input_ff_destroy()
373 kfree(ff); in input_ff_destroy()
374 dev->ff = NULL; in input_ff_destroy()