From: johann d. <jd...@us...> - 2002-02-02 19:28:38
|
Update of /cvsroot/linuxconsole/ruby/linux/drivers/input/joystick/iforce In directory usw-pr-cvs1:/tmp/cvs-serv18760 Modified Files: iforce-ff.c iforce-main.c iforce-packets.c iforce-usb.c iforce.h Log Message: Synced with latest API changes. USB fixes. Index: iforce-ff.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/joystick/iforce/iforce-ff.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- iforce-ff.c 2002/01/28 22:45:00 1.8 +++ iforce-ff.c 2002/02/02 19:28:35 1.9 @@ -1,8 +1,8 @@ /* * $Id$ * - * Copyright (c) 2000-2001 Vojtech Pavlik <vo...@uc...> - * Copyright (c) 2001 Johann Deneux <de...@if...> + * Copyright (c) 2000-2002 Vojtech Pavlik <vo...@uc...> + * Copyright (c) 2001-2002 Johann Deneux <de...@if...> * * USB/RS232 I-Force joysticks and wheels. */ @@ -101,10 +101,10 @@ } /* - * Uploads the part of an effect setting the shape of the force + * Uploads the part of an effect setting the envelope of the force */ -static int make_shape_modifier(struct iforce* iforce, +static int make_envelope_modifier(struct iforce* iforce, struct resource* mod_chunk, int no_alloc, u16 attack_duration, __s16 initial_level, u16 fade_duration, __s16 final_level) @@ -136,7 +136,7 @@ data[6] = HI(fade_duration); data[7] = HI(final_level); - iforce_send_packet(iforce, FF_CMD_SHAPE, data); + iforce_send_packet(iforce, FF_CMD_ENVELOPE, data); return 0; } @@ -145,7 +145,7 @@ * Component of spring, friction, inertia... effects */ -static int make_interactive_modifier(struct iforce* iforce, +static int make_condition_modifier(struct iforce* iforce, struct resource* mod_chunk, int no_alloc, __u16 rsat, __u16 lsat, __s16 rk, __s16 lk, u16 db, __s16 center) { @@ -179,8 +179,8 @@ data[8] = (100*rsat)>>16; data[9] = (100*lsat)>>16; - iforce_send_packet(iforce, FF_CMD_INTERACT, data); - iforce_dump_packet("interactive", FF_CMD_INTERACT, data); + iforce_send_packet(iforce, FF_CMD_CONDITION, data); + iforce_dump_packet("condition", FF_CMD_CONDITION, data); return 0; } @@ -195,25 +195,30 @@ } /* - * Analyse the changes in an effect, and tell if we need to send an interactive + * Analyse the changes in an effect, and tell if we need to send an condition * parameter packet */ -static int need_interactive_modifier(struct iforce* iforce, struct ff_effect* new) +static int need_condition_modifier(struct iforce* iforce, struct ff_effect* new) { int id = new->id; struct ff_effect* old = &iforce->core_effects[id].effect; + int ret=0; + int i; if (new->type != FF_SPRING && new->type != FF_FRICTION) { - printk(KERN_WARNING "iforce.c: bad effect type in need_interactive_modifier\n"); + printk(KERN_WARNING "iforce.c: bad effect type in need_condition_modifier\n"); return FALSE; } - return (old->u.interactive.right_saturation != new->u.interactive.right_saturation - || old->u.interactive.left_saturation != new->u.interactive.left_saturation - || old->u.interactive.right_coeff != new->u.interactive.right_coeff - || old->u.interactive.left_coeff != new->u.interactive.left_coeff - || old->u.interactive.deadband != new->u.interactive.deadband - || old->u.interactive.center != new->u.interactive.center); + for(i=0; i<2; i++) { + ret |= old->u.condition[i].right_saturation != new->u.condition[i].right_saturation + || old->u.condition[i].left_saturation != new->u.condition[i].left_saturation + || old->u.condition[i].right_coeff != new->u.condition[i].right_coeff + || old->u.condition[i].left_coeff != new->u.condition[i].left_coeff + || old->u.condition[i].deadband != new->u.condition[i].deadband + || old->u.condition[i].center != new->u.condition[i].center; + } + return ret; } /* @@ -226,7 +231,7 @@ struct ff_effect* old = &iforce->core_effects[id].effect; if (effect->type != FF_CONSTANT) { - printk(KERN_WARNING "iforce.c: bad effect type in need_shape_modifier\n"); + printk(KERN_WARNING "iforce.c: bad effect type in need_envelope_modifier\n"); return FALSE; } @@ -234,33 +239,33 @@ } /* - * Analyse the changes in an effect, and tell if we need to send a shape + * Analyse the changes in an effect, and tell if we need to send an envelope * parameter packet */ -static int need_shape_modifier(struct iforce* iforce, struct ff_effect* effect) +static int need_envelope_modifier(struct iforce* iforce, struct ff_effect* effect) { int id = effect->id; struct ff_effect* old = &iforce->core_effects[id].effect; switch (effect->type) { case FF_CONSTANT: - if (old->u.constant.shape.attack_length != effect->u.constant.shape.attack_length - || old->u.constant.shape.attack_level != effect->u.constant.shape.attack_level - || old->u.constant.shape.fade_length != effect->u.constant.shape.fade_length - || old->u.constant.shape.fade_level != effect->u.constant.shape.fade_level) + if (old->u.constant.envelope.attack_length != effect->u.constant.envelope.attack_length + || old->u.constant.envelope.attack_level != effect->u.constant.envelope.attack_level + || old->u.constant.envelope.fade_length != effect->u.constant.envelope.fade_length + || old->u.constant.envelope.fade_level != effect->u.constant.envelope.fade_level) return TRUE; break; case FF_PERIODIC: - if (old->u.periodic.shape.attack_length != effect->u.periodic.shape.attack_length - || old->u.periodic.shape.attack_level != effect->u.periodic.shape.attack_level - || old->u.periodic.shape.fade_length != effect->u.periodic.shape.fade_length - || old->u.periodic.shape.fade_level != effect->u.periodic.shape.fade_level) + if (old->u.periodic.envelope.attack_length != effect->u.periodic.envelope.attack_length + || old->u.periodic.envelope.attack_level != effect->u.periodic.envelope.attack_level + || old->u.periodic.envelope.fade_length != effect->u.periodic.envelope.fade_length + || old->u.periodic.envelope.fade_level != effect->u.periodic.envelope.fade_level) return TRUE; break; default: - printk(KERN_WARNING "iforce.c: bad effect type in need_shape_modifier\n"); + printk(KERN_WARNING "iforce.c: bad effect type in need_envelope_modifier\n"); } return FALSE; @@ -375,13 +380,13 @@ set_bit(FF_MOD1_IS_USED, core_effect->flags); } - if (!is_update || need_shape_modifier(iforce, effect)) { - param2_err = make_shape_modifier(iforce, mod2_chunk, + if (!is_update || need_envelope_modifier(iforce, effect)) { + param2_err = make_envelope_modifier(iforce, mod2_chunk, is_update, - effect->u.periodic.shape.attack_length, - effect->u.periodic.shape.attack_level, - effect->u.periodic.shape.fade_length, - effect->u.periodic.shape.fade_level); + effect->u.periodic.envelope.attack_length, + effect->u.periodic.envelope.attack_level, + effect->u.periodic.envelope.fade_length, + effect->u.periodic.envelope.fade_level); if (param2_err) return param2_err; set_bit(FF_MOD2_IS_USED, core_effect->flags); } @@ -442,13 +447,13 @@ set_bit(FF_MOD1_IS_USED, core_effect->flags); } - if (!is_update || need_shape_modifier(iforce, effect)) { - param2_err = make_shape_modifier(iforce, mod2_chunk, + if (!is_update || need_envelope_modifier(iforce, effect)) { + param2_err = make_envelope_modifier(iforce, mod2_chunk, is_update, - effect->u.constant.shape.attack_length, - effect->u.constant.shape.attack_level, - effect->u.constant.shape.fade_length, - effect->u.constant.shape.fade_level); + effect->u.constant.envelope.attack_length, + effect->u.constant.envelope.attack_level, + effect->u.constant.envelope.fade_length, + effect->u.constant.envelope.fade_level); if (param2_err) return param2_err; set_bit(FF_MOD2_IS_USED, core_effect->flags); } @@ -476,81 +481,56 @@ } /* - * Upload an interactive effect. Those are for example friction, inertia, springs... + * Upload an condition effect. Those are for example friction, inertia, springs... */ -int iforce_upload_interactive(struct iforce* iforce, struct ff_effect* effect, int is_update) +int iforce_upload_condition(struct iforce* iforce, struct ff_effect* effect, int is_update) { int core_id = effect->id; struct iforce_core_effect* core_effect = iforce->core_effects + core_id; - struct resource* mod_chunk = &(core_effect->mod1_chunk); - u8 type, axes; - u16 mod1, mod2, direction; + struct resource* mod1_chunk = &(core_effect->mod1_chunk); + struct resource* mod2_chunk = &(core_effect->mod2_chunk); + u8 type; int param_err = 1; int core_err = 0; switch (effect->type) { case FF_SPRING: type = 0x40; break; - case FF_FRICTION: type = 0x41; break; + case FF_DAMPER: type = 0x41; break; default: return -1; } - if (!is_update || need_interactive_modifier(iforce, effect)) { - param_err = make_interactive_modifier(iforce, mod_chunk, + if (!is_update || need_condition_modifier(iforce, effect)) { + param_err = make_condition_modifier(iforce, mod1_chunk, is_update, - effect->u.interactive.right_saturation, - effect->u.interactive.left_saturation, - effect->u.interactive.right_coeff, - effect->u.interactive.left_coeff, - effect->u.interactive.deadband, - effect->u.interactive.center); + effect->u.condition[0].right_saturation, + effect->u.condition[0].left_saturation, + effect->u.condition[0].right_coeff, + effect->u.condition[0].left_coeff, + effect->u.condition[0].deadband, + effect->u.condition[0].center); if (param_err) return param_err; set_bit(FF_MOD1_IS_USED, core_effect->flags); - } - - switch ((test_bit(ABS_X, &effect->u.interactive.axis) || - test_bit(ABS_WHEEL, &effect->u.interactive.axis)) | - (!!test_bit(ABS_Y, &effect->u.interactive.axis) << 1)) { - case 0: /* Only one axis, choose orientation */ - mod1 = mod_chunk->start; - mod2 = 0xffff; - direction = effect->direction; - axes = 0x20; - break; - - case 1: /* Only X axis */ - mod1 = mod_chunk->start; - mod2 = 0xffff; - direction = 0x5a00; - axes = 0x40; - break; - - case 2: /* Only Y axis */ - mod1 = 0xffff; - mod2 = mod_chunk->start; - direction = 0xb400; - axes = 0x80; - break; - - case 3: /* Both X and Y axes */ - /* TODO: same setting for both axes is not mandatory */ - mod1 = mod_chunk->start; - mod2 = mod_chunk->start; - direction = 0x6000; - axes = 0xc0; - break; + param_err = make_condition_modifier(iforce, mod2_chunk, + is_update, + effect->u.condition[1].right_saturation, + effect->u.condition[1].left_saturation, + effect->u.condition[1].right_coeff, + effect->u.condition[1].left_coeff, + effect->u.condition[1].deadband, + effect->u.condition[1].center); + if (param_err) return param_err; + set_bit(FF_MOD2_IS_USED, core_effect->flags); - default: - return -1; } if (!is_update || need_core(iforce, effect)) { core_err = make_core(iforce, effect->id, - mod1, mod2, - type, axes, + mod1_chunk->start, mod2_chunk->start, + type, 0xc0, effect->replay.length, effect->replay.delay, effect->trigger.button, effect->trigger.interval, - direction); + effect->direction); } /* If the parameter creation failed, we already returned an Index: iforce-main.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/joystick/iforce/iforce-main.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- iforce-main.c 2002/01/30 19:47:35 1.9 +++ iforce-main.c 2002/02/02 19:28:35 1.10 @@ -1,8 +1,8 @@ /* * $Id$ * - * Copyright (c) 2000-2001 Vojtech Pavlik <vo...@uc...> - * Copyright (c) 2001 Johann Deneux <de...@if...> + * Copyright (c) 2000-2002 Vojtech Pavlik <vo...@uc...> + * Copyright (c) 2001-2002 Johann Deneux <de...@if...> * * USB/RS232 I-Force joysticks and wheels. */ @@ -168,7 +168,7 @@ case FF_SPRING: case FF_FRICTION: - ret = iforce_upload_interactive(iforce, effect, is_update); + ret = iforce_upload_condition(iforce, effect, is_update); break; default: @@ -224,17 +224,20 @@ switch (iforce->bus) { #ifdef IFORCE_USB case IFORCE_USB: - if (iforce->open++) - break; - iforce->irq.dev = iforce->usbdev; - if (usb_submit_urb(&iforce->irq)) + if (!iforce->open) { + iforce->irq.dev = iforce->usbdev; + if (usb_submit_urb(&iforce->irq)) return -EIO; + } break; #endif } /* Enable force feedback */ - iforce_send_packet(iforce, FF_CMD_ENABLE, "\004"); + if (!iforce->open) + iforce_send_packet(iforce, FF_CMD_ENABLE, "\004"); + + iforce->open++; return 0; } @@ -263,11 +266,11 @@ return 0; } -static void iforce_close(struct input_dev *dev) +static void iforce_release(struct input_dev *dev) { struct iforce *iforce = dev->private; - printk(KERN_DEBUG "iforce.c: in iforce_close\n"); + printk(KERN_DEBUG "iforce.c: in iforce_release\n"); /* Disable force feedback playback */ iforce_send_packet(iforce, FF_CMD_ENABLE, "\001"); @@ -320,7 +323,7 @@ iforce->dev.private = iforce; iforce->dev.name = "Unknown I-Force device"; iforce->dev.open = iforce_open; - iforce->dev.close = iforce_close; + iforce->dev.close = iforce_release; iforce->dev.flush = iforce_flush; iforce->dev.event = iforce_input_event; iforce->dev.upload_effect = iforce_upload_effect; @@ -348,7 +351,7 @@ if (i == 20) { /* 5 seconds */ printk(KERN_ERR "iforce.c: Timeout waiting for response from device.\n"); - iforce_close(&iforce->dev); + iforce_delete(iforce); return -1; } @@ -409,8 +412,6 @@ for (i = 0; iforce->type->btn[i] >= 0; i++) { signed short t = iforce->type->btn[i]; set_bit(t, iforce->dev.keybit); - if (t != BTN_DEAD) - set_bit(FF_BTN(t), iforce->dev.ffbit); } for (i = 0; iforce->type->abs[i] >= 0; i++) { @@ -429,7 +430,7 @@ iforce->dev.absflat[t] = 128; iforce->dev.absfuzz[t] = 16; - set_bit(FF_ABS(t), iforce->dev.ffbit); + set_bit(t, iforce->dev.ffbit); break; case ABS_THROTTLE: Index: iforce-packets.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/joystick/iforce/iforce-packets.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- iforce-packets.c 2002/01/30 17:54:50 1.8 +++ iforce-packets.c 2002/02/02 19:28:35 1.9 @@ -110,6 +110,8 @@ #ifdef IFORCE_USB case IFORCE_USB: + /* FIXME: iforce->out.status should not be checked outside + * the completion handler */ if (iforce->usbdev && empty && !iforce->out.status) { iforce_usb_xmit(iforce); } Index: iforce-usb.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/joystick/iforce/iforce-usb.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- iforce-usb.c 2002/01/30 19:47:35 1.9 +++ iforce-usb.c 2002/02/02 19:28:35 1.10 @@ -118,6 +118,7 @@ iforce->cr.wIndex = 0; iforce->cr.wLength = 16; + /* FIXME: use lower-case versions instead with 2.5 */ FILL_INT_URB(&iforce->irq, dev, usb_rcvintpipe(dev, epirq->bEndpointAddress), iforce->data, 16, iforce_usb_irq, iforce, epirq->bInterval); @@ -168,6 +169,7 @@ MODULE_DEVICE_TABLE (usb, iforce_usb_ids); struct usb_driver iforce_usb_driver = { + owner: THIS_MODULE, name: "iforce", probe: iforce_usb_probe, disconnect: iforce_usb_disconnect, Index: iforce.h =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/joystick/iforce/iforce.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- iforce.h 2002/01/30 19:47:35 1.7 +++ iforce.h 2002/02/02 19:28:35 1.8 @@ -1,8 +1,8 @@ /* * $Id$ * - * Copyright (c) 2000-2001 Vojtech Pavlik <vo...@uc...> - * Copyright (c) 2001 Johann Deneux <de...@if...> + * Copyright (c) 2000-2002 Vojtech Pavlik <vo...@uc...> + * Copyright (c) 2001-2002 Johann Deneux <de...@if...> * * USB/RS232 I-Force joysticks and wheels. */ @@ -65,7 +65,7 @@ #define FF_MOD1_IS_USED 0 #define FF_MOD2_IS_USED 1 #define FF_CORE_IS_USED 2 -#define FF_CORE_IS_PLAYED 3 /* Effect is actually being played */ +#define FF_CORE_IS_PLAYED 3 /* Effect is currently being played */ #define FF_CORE_SHOULD_PLAY 4 /* User wants the effect to be played */ #define FF_CORE_UPDATE 5 /* Effect is being updated */ #define FF_MODCORE_MAX 5 @@ -91,10 +91,10 @@ }; #define FF_CMD_EFFECT 0x010e -#define FF_CMD_SHAPE 0x0208 +#define FF_CMD_ENVELOPE 0x0208 #define FF_CMD_MAGNITUDE 0x0303 #define FF_CMD_PERIOD 0x0407 -#define FF_CMD_INTERACT 0x050a +#define FF_CMD_CONDITION 0x050a #define FF_CMD_AUTOCENTER 0x4002 #define FF_CMD_PLAY 0x4103 @@ -138,7 +138,7 @@ #endif #ifdef IFORCE_USB struct usb_device *usbdev; /* USB transfer */ - struct urb irq, out, ctrl; + struct urb irq, out, ctrl; /*TODO: Use pointers and usb_alloc_urb */ struct usb_ctrlrequest cr; #endif spinlock_t xmit_lock; @@ -189,7 +189,7 @@ /* iforce-ff.c */ int iforce_upload_periodic(struct iforce*, struct ff_effect*, int is_update); int iforce_upload_constant(struct iforce*, struct ff_effect*, int is_update); -int iforce_upload_interactive(struct iforce*, struct ff_effect*, int is_update); +int iforce_upload_condition(struct iforce*, struct ff_effect*, int is_update); /* Public variables */ extern struct serio_dev iforce_serio_dev; |