Lines Matching refs:adi

109 struct adi {  struct
130 struct adi adi[2]; argument
141 struct adi *adi = port->adi; in adi_read_packet() local
148 adi[i].ret = -1; in adi_read_packet()
164 if ((w & 0x30) < 0x30 && adi[i].ret < ADI_MAX_LENGTH && t[i] > 0) { in adi_read_packet()
165 adi[i].data[++adi[i].ret] = w; in adi_read_packet()
185 struct adi *adi = port->adi; in adi_move_bits() local
187 adi[0].idx = adi[1].idx = 0; in adi_move_bits()
189 if (adi[0].ret <= 0 || adi[1].ret <= 0) return; in adi_move_bits()
190 if (adi[0].data[0] & 0x20 || ~adi[1].data[0] & 0x20) return; in adi_move_bits()
192 for (i = 1; i <= adi[1].ret; i++) in adi_move_bits()
193 adi[0].data[((length - 1) >> 1) + i + 1] = adi[1].data[i]; in adi_move_bits()
195 adi[0].ret += adi[1].ret; in adi_move_bits()
196 adi[1].ret = -1; in adi_move_bits()
203 static inline int adi_get_bits(struct adi *adi, int count) in adi_get_bits() argument
207 if ((adi->idx += count) > adi->ret) return 0; in adi_get_bits()
209 bits |= ((adi->data[adi->idx - i] >> 5) & 1) << i; in adi_get_bits()
217 static int adi_decode(struct adi *adi) in adi_decode() argument
219 struct input_dev *dev = adi->dev; in adi_decode()
220 char *abs = adi->abs; in adi_decode()
221 short *key = adi->key; in adi_decode()
224 if (adi->ret < adi->length || adi->id != (adi_get_bits(adi, 4) | (adi_get_bits(adi, 4) << 4))) in adi_decode()
227 for (i = 0; i < adi->axes10; i++) in adi_decode()
228 input_report_abs(dev, *abs++, adi_get_bits(adi, 10)); in adi_decode()
230 for (i = 0; i < adi->axes8; i++) in adi_decode()
231 input_report_abs(dev, *abs++, adi_get_bits(adi, 8)); in adi_decode()
233 for (i = 0; i < adi->buttons && i < 63; i++) { in adi_decode()
234 if (i == adi->pad) { in adi_decode()
235 t = adi_get_bits(adi, 4); in adi_decode()
239 input_report_key(dev, *key++, adi_get_bits(adi, 1)); in adi_decode()
242 for (i = 0; i < adi->hats; i++) { in adi_decode()
243 if ((t = adi_get_bits(adi, 4)) > 8) t = 0; in adi_decode()
248 for (i = 63; i < adi->buttons; i++) in adi_decode()
249 input_report_key(dev, *key++, adi_get_bits(adi, 1)); in adi_decode()
266 adi_move_bits(port, port->adi[0].length); in adi_read()
269 if (port->adi[i].length) in adi_read()
270 result |= adi_decode(port->adi + i); in adi_read()
331 static void adi_id_decode(struct adi *adi, struct adi_port *port) in adi_id_decode() argument
335 if (adi->ret < ADI_MIN_ID_LENGTH) /* Minimum ID packet length */ in adi_id_decode()
338 if (adi->ret < (t = adi_get_bits(adi, 10))) { in adi_id_decode()
339 printk(KERN_WARNING "adi: Short ID packet: reported: %d != read: %d\n", t, adi->ret); in adi_id_decode()
343 adi->id = adi_get_bits(adi, 4) | (adi_get_bits(adi, 4) << 4); in adi_id_decode()
345 if ((t = adi_get_bits(adi, 4)) & ADI_FLAG_HAT) adi->hats++; in adi_id_decode()
347 adi->length = adi_get_bits(adi, 10); in adi_id_decode()
349 if (adi->length >= ADI_MAX_LENGTH || adi->length < ADI_MIN_LENGTH) { in adi_id_decode()
350 printk(KERN_WARNING "adi: Bad data packet length (%d).\n", adi->length); in adi_id_decode()
351 adi->length = 0; in adi_id_decode()
355 adi->axes8 = adi_get_bits(adi, 4); in adi_id_decode()
356 adi->buttons = adi_get_bits(adi, 6); in adi_id_decode()
358 if (adi_get_bits(adi, 6) != 8 && adi->hats) { in adi_id_decode()
360 adi->length = 0; in adi_id_decode()
364 adi->buttons += adi_get_bits(adi, 6); in adi_id_decode()
365 adi->hats += adi_get_bits(adi, 4); in adi_id_decode()
367 i = adi_get_bits(adi, 4); in adi_id_decode()
370 adi->axes10 = adi->axes8 - i; in adi_id_decode()
371 adi->axes8 = i; in adi_id_decode()
374 t = adi_get_bits(adi, 4); in adi_id_decode()
377 adi->cname[i] = adi_get_bits(adi, 8); in adi_id_decode()
378 adi->cname[i] = 0; in adi_id_decode()
380 t = 8 + adi->buttons + adi->axes10 * 10 + adi->axes8 * 8 + adi->hats * 4; in adi_id_decode()
381 if (adi->length != t && adi->length != t + (t & 1)) { in adi_id_decode()
382 printk(KERN_WARNING "adi: Expected length %d != data length %d\n", t, adi->length); in adi_id_decode()
383 adi->length = 0; in adi_id_decode()
387 switch (adi->id) { in adi_id_decode()
389 adi->pad = 4; in adi_id_decode()
390 adi->buttons -= 4; in adi_id_decode()
393 adi->pad = 0; in adi_id_decode()
394 adi->buttons -= 4; in adi_id_decode()
397 adi->pad = -1; in adi_id_decode()
402 static int adi_init_input(struct adi *adi, struct adi_port *port, int half) in adi_init_input() argument
408 adi->dev = input_dev = input_allocate_device(); in adi_init_input()
412 t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX; in adi_init_input()
414 snprintf(buf, ADI_MAX_PHYS_LENGTH, adi_names[t], adi->id); in adi_init_input()
415 snprintf(adi->name, ADI_MAX_NAME_LENGTH, "Logitech %s [%s]", buf, adi->cname); in adi_init_input()
416 snprintf(adi->phys, ADI_MAX_PHYS_LENGTH, "%s/input%d", port->gameport->phys, half); in adi_init_input()
418 adi->abs = adi_abs[t]; in adi_init_input()
419 adi->key = adi_key[t]; in adi_init_input()
421 input_dev->name = adi->name; in adi_init_input()
422 input_dev->phys = adi->phys; in adi_init_input()
425 input_dev->id.product = adi->id; in adi_init_input()
436 for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) in adi_init_input()
437 set_bit(adi->abs[i], input_dev->absbit); in adi_init_input()
439 for (i = 0; i < adi->buttons; i++) in adi_init_input()
440 set_bit(adi->key[i], input_dev->keybit); in adi_init_input()
445 static void adi_init_center(struct adi *adi) in adi_init_center() argument
449 if (!adi->length) in adi_init_center()
452 for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) { in adi_init_center()
454 t = adi->abs[i]; in adi_init_center()
455 x = input_abs_get_val(adi->dev, t); in adi_init_center()
457 if (t == ABS_THROTTLE || t == ABS_RUDDER || adi->id == ADI_ID_WGPE) in adi_init_center()
458 x = i < adi->axes10 ? 512 : 128; in adi_init_center()
460 if (i < adi->axes10) in adi_init_center()
461 input_set_abs_params(adi->dev, t, 64, x * 2 - 64, 2, 16); in adi_init_center()
462 else if (i < adi->axes10 + adi->axes8) in adi_init_center()
463 input_set_abs_params(adi->dev, t, 48, x * 2 - 48, 1, 16); in adi_init_center()
465 input_set_abs_params(adi->dev, t, -1, 1, 0, 0); in adi_init_center()
494 if (port->adi[0].ret >= ADI_MIN_LEN_LENGTH) in adi_connect()
495 adi_move_bits(port, adi_get_bits(port->adi, 10)); in adi_connect()
498 adi_id_decode(port->adi + i, port); in adi_connect()
500 if (!port->adi[i].length) in adi_connect()
503 err = adi_init_input(port->adi + i, port, i); in adi_connect()
508 if (!port->adi[0].length && !port->adi[1].length) { in adi_connect()
523 if (port->adi[i].length > 0) { in adi_connect()
524 adi_init_center(port->adi + i); in adi_connect()
525 err = input_register_device(port->adi[i].dev); in adi_connect()
533 if (port->adi[i].length > 0) { in adi_connect()
534 input_unregister_device(port->adi[i].dev); in adi_connect()
535 port->adi[i].dev = NULL; in adi_connect()
539 if (port->adi[i].dev) in adi_connect()
540 input_free_device(port->adi[i].dev); in adi_connect()
553 if (port->adi[i].length > 0) in adi_disconnect()
554 input_unregister_device(port->adi[i].dev); in adi_disconnect()