Lines Matching refs:gc

89 struct gc {  struct
103 static struct gc *gc_base[3]; argument
149 static void gc_n64_send_command(struct gc *gc, unsigned long cmd, in gc_n64_send_command() argument
152 struct parport *port = gc->pd->port; in gc_n64_send_command()
163 static void gc_n64_send_stop_bit(struct gc *gc, unsigned char target) in gc_n64_send_stop_bit() argument
165 struct parport *port = gc->pd->port; in gc_n64_send_stop_bit()
181 static void gc_n64_read_packet(struct gc *gc, unsigned char *data) in gc_n64_read_packet() argument
191 gc_n64_send_command(gc, GC_N64_REQUEST_DATA, GC_N64_OUT); in gc_n64_read_packet()
192 gc_n64_send_stop_bit(gc, GC_N64_OUT); in gc_n64_read_packet()
207 parport_write_data(gc->pd->port, GC_N64_POWER_R); in gc_n64_read_packet()
209 data[i] = parport_read_status(gc->pd->port); in gc_n64_read_packet()
210 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK); in gc_n64_read_packet()
221 static void gc_n64_process_packet(struct gc *gc) in gc_n64_process_packet() argument
228 gc_n64_read_packet(gc, data); in gc_n64_process_packet()
232 if (gc->pads[i].type != GC_N64) in gc_n64_process_packet()
235 dev = gc->pads[i].dev; in gc_n64_process_packet()
271 struct gc *gc = input_get_drvdata(dev); in gc_n64_play_effect() local
284 gc_n64_send_command(gc, GC_N64_CMD_03, target); in gc_n64_play_effect()
285 gc_n64_send_command(gc, GC_N64_CMD_80, target); in gc_n64_play_effect()
286 gc_n64_send_command(gc, GC_N64_CMD_01, target); in gc_n64_play_effect()
288 gc_n64_send_command(gc, GC_N64_CMD_80, target); in gc_n64_play_effect()
289 gc_n64_send_stop_bit(gc, target); in gc_n64_play_effect()
294 gc_n64_send_command(gc, GC_N64_CMD_03, target); in gc_n64_play_effect()
295 gc_n64_send_command(gc, GC_N64_CMD_c0, target); in gc_n64_play_effect()
296 gc_n64_send_command(gc, GC_N64_CMD_1b, target); in gc_n64_play_effect()
298 gc_n64_send_command(gc, cmd, target); in gc_n64_play_effect()
299 gc_n64_send_stop_bit(gc, target); in gc_n64_play_effect()
357 static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data) in gc_nes_read_packet() argument
361 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK | GC_NES_LATCH); in gc_nes_read_packet()
363 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK); in gc_nes_read_packet()
367 parport_write_data(gc->pd->port, GC_NES_POWER); in gc_nes_read_packet()
368 data[i] = parport_read_status(gc->pd->port) ^ 0x7f; in gc_nes_read_packet()
370 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK); in gc_nes_read_packet()
374 static void gc_nes_process_packet(struct gc *gc) in gc_nes_process_packet() argument
382 len = gc->pad_count[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : in gc_nes_process_packet()
383 (gc->pad_count[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); in gc_nes_process_packet()
385 gc_nes_read_packet(gc, len, data); in gc_nes_process_packet()
389 pad = &gc->pads[i]; in gc_nes_process_packet()
476 static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data) in gc_multi_read_packet() argument
481 parport_write_data(gc->pd->port, ~(1 << i)); in gc_multi_read_packet()
482 data[i] = parport_read_status(gc->pd->port) ^ 0x7f; in gc_multi_read_packet()
486 static void gc_multi_process_packet(struct gc *gc) in gc_multi_process_packet() argument
489 int data_len = gc->pad_count[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH; in gc_multi_process_packet()
494 gc_multi_read_packet(gc, data_len, data); in gc_multi_process_packet()
497 pad = &gc->pads[i]; in gc_multi_process_packet()
566 static void gc_psx_command(struct gc *gc, int b, unsigned char *data) in gc_psx_command() argument
568 struct parport *port = gc->pd->port; in gc_psx_command()
581 struct gc_pad *pad = &gc->pads[j]; in gc_psx_command()
587 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); in gc_psx_command()
597 static void gc_psx_read_packet(struct gc *gc, in gc_psx_read_packet() argument
606 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); in gc_psx_read_packet()
609 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER); in gc_psx_read_packet()
614 gc_psx_command(gc, 0x01, data2); /* Access pad */ in gc_psx_read_packet()
615 gc_psx_command(gc, 0x42, id); /* Get device ids */ in gc_psx_read_packet()
616 gc_psx_command(gc, 0, data2); /* Dump status */ in gc_psx_read_packet()
620 struct gc_pad *pad = &gc->pads[i]; in gc_psx_read_packet()
631 gc_psx_command(gc, 0, data2); in gc_psx_read_packet()
638 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); in gc_psx_read_packet()
725 static void gc_psx_process_packet(struct gc *gc) in gc_psx_process_packet() argument
732 gc_psx_read_packet(gc, data, id); in gc_psx_process_packet()
735 pad = &gc->pads[i]; in gc_psx_process_packet()
747 struct gc *gc = (void *) private; in gc_timer() local
753 if (gc->pad_count[GC_N64]) in gc_timer()
754 gc_n64_process_packet(gc); in gc_timer()
760 if (gc->pad_count[GC_NES] || in gc_timer()
761 gc->pad_count[GC_SNES] || in gc_timer()
762 gc->pad_count[GC_SNESMOUSE]) { in gc_timer()
763 gc_nes_process_packet(gc); in gc_timer()
770 if (gc->pad_count[GC_MULTI] || gc->pad_count[GC_MULTI2]) in gc_timer()
771 gc_multi_process_packet(gc); in gc_timer()
777 if (gc->pad_count[GC_PSX] || gc->pad_count[GC_DDR]) in gc_timer()
778 gc_psx_process_packet(gc); in gc_timer()
780 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); in gc_timer()
785 struct gc *gc = input_get_drvdata(dev); in gc_open() local
788 err = mutex_lock_interruptible(&gc->mutex); in gc_open()
792 if (!gc->used++) { in gc_open()
793 parport_claim(gc->pd); in gc_open()
794 parport_write_control(gc->pd->port, 0x04); in gc_open()
795 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); in gc_open()
798 mutex_unlock(&gc->mutex); in gc_open()
804 struct gc *gc = input_get_drvdata(dev); in gc_close() local
806 mutex_lock(&gc->mutex); in gc_close()
807 if (!--gc->used) { in gc_close()
808 del_timer_sync(&gc->timer); in gc_close()
809 parport_write_control(gc->pd->port, 0x00); in gc_close()
810 parport_release(gc->pd); in gc_close()
812 mutex_unlock(&gc->mutex); in gc_close()
815 static int gc_setup_pad(struct gc *gc, int idx, int pad_type) in gc_setup_pad() argument
817 struct gc_pad *pad = &gc->pads[idx]; in gc_setup_pad()
836 "%s/input%d", gc->pd->port->name, idx); in gc_setup_pad()
845 input_set_drvdata(input_dev, gc); in gc_setup_pad()
858 gc->pad_count[pad_type]++; in gc_setup_pad()
932 struct gc *gc; in gc_attach() local
964 gc = kzalloc(sizeof(struct gc), GFP_KERNEL); in gc_attach()
965 if (!gc) { in gc_attach()
970 mutex_init(&gc->mutex); in gc_attach()
971 gc->pd = pd; in gc_attach()
972 gc->parportno = pp->number; in gc_attach()
973 setup_timer(&gc->timer, gc_timer, (long) gc); in gc_attach()
979 if (gc_setup_pad(gc, i, pads[i])) in gc_attach()
990 gc_base[port_idx] = gc; in gc_attach()
995 if (gc->pads[i].dev) in gc_attach()
996 input_unregister_device(gc->pads[i].dev); in gc_attach()
998 kfree(gc); in gc_attach()
1006 struct gc *gc; in gc_detach() local
1016 gc = gc_base[i]; in gc_detach()
1020 if (gc->pads[i].dev) in gc_detach()
1021 input_unregister_device(gc->pads[i].dev); in gc_detach()
1022 parport_unregister_device(gc->pd); in gc_detach()
1023 kfree(gc); in gc_detach()