Lines Matching refs:gc
70 struct gc { struct
84 static struct gc *gc_base[3]; argument
130 static void gc_n64_send_command(struct gc *gc, unsigned long cmd, in gc_n64_send_command() argument
133 struct parport *port = gc->pd->port; in gc_n64_send_command()
144 static void gc_n64_send_stop_bit(struct gc *gc, unsigned char target) in gc_n64_send_stop_bit() argument
146 struct parport *port = gc->pd->port; in gc_n64_send_stop_bit()
162 static void gc_n64_read_packet(struct gc *gc, unsigned char *data) in gc_n64_read_packet() argument
172 gc_n64_send_command(gc, GC_N64_REQUEST_DATA, GC_N64_OUT); in gc_n64_read_packet()
173 gc_n64_send_stop_bit(gc, GC_N64_OUT); in gc_n64_read_packet()
188 parport_write_data(gc->pd->port, GC_N64_POWER_R); in gc_n64_read_packet()
190 data[i] = parport_read_status(gc->pd->port); in gc_n64_read_packet()
191 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK); in gc_n64_read_packet()
202 static void gc_n64_process_packet(struct gc *gc) in gc_n64_process_packet() argument
209 gc_n64_read_packet(gc, data); in gc_n64_process_packet()
213 if (gc->pads[i].type != GC_N64) in gc_n64_process_packet()
216 dev = gc->pads[i].dev; in gc_n64_process_packet()
252 struct gc *gc = input_get_drvdata(dev); in gc_n64_play_effect() local
265 gc_n64_send_command(gc, GC_N64_CMD_03, target); in gc_n64_play_effect()
266 gc_n64_send_command(gc, GC_N64_CMD_80, target); in gc_n64_play_effect()
267 gc_n64_send_command(gc, GC_N64_CMD_01, target); in gc_n64_play_effect()
269 gc_n64_send_command(gc, GC_N64_CMD_80, target); in gc_n64_play_effect()
270 gc_n64_send_stop_bit(gc, target); in gc_n64_play_effect()
275 gc_n64_send_command(gc, GC_N64_CMD_03, target); in gc_n64_play_effect()
276 gc_n64_send_command(gc, GC_N64_CMD_c0, target); in gc_n64_play_effect()
277 gc_n64_send_command(gc, GC_N64_CMD_1b, target); in gc_n64_play_effect()
279 gc_n64_send_command(gc, cmd, target); in gc_n64_play_effect()
280 gc_n64_send_stop_bit(gc, target); in gc_n64_play_effect()
338 static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data) in gc_nes_read_packet() argument
342 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK | GC_NES_LATCH); in gc_nes_read_packet()
344 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK); in gc_nes_read_packet()
348 parport_write_data(gc->pd->port, GC_NES_POWER); in gc_nes_read_packet()
349 data[i] = parport_read_status(gc->pd->port) ^ 0x7f; in gc_nes_read_packet()
351 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK); in gc_nes_read_packet()
355 static void gc_nes_process_packet(struct gc *gc) in gc_nes_process_packet() argument
363 len = gc->pad_count[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : in gc_nes_process_packet()
364 (gc->pad_count[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); in gc_nes_process_packet()
366 gc_nes_read_packet(gc, len, data); in gc_nes_process_packet()
370 pad = &gc->pads[i]; in gc_nes_process_packet()
457 static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data) in gc_multi_read_packet() argument
462 parport_write_data(gc->pd->port, ~(1 << i)); in gc_multi_read_packet()
463 data[i] = parport_read_status(gc->pd->port) ^ 0x7f; in gc_multi_read_packet()
467 static void gc_multi_process_packet(struct gc *gc) in gc_multi_process_packet() argument
470 int data_len = gc->pad_count[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH; in gc_multi_process_packet()
475 gc_multi_read_packet(gc, data_len, data); in gc_multi_process_packet()
478 pad = &gc->pads[i]; in gc_multi_process_packet()
547 static void gc_psx_command(struct gc *gc, int b, unsigned char *data) in gc_psx_command() argument
549 struct parport *port = gc->pd->port; in gc_psx_command()
562 struct gc_pad *pad = &gc->pads[j]; in gc_psx_command()
568 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); in gc_psx_command()
578 static void gc_psx_read_packet(struct gc *gc, in gc_psx_read_packet() argument
587 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); in gc_psx_read_packet()
590 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER); in gc_psx_read_packet()
595 gc_psx_command(gc, 0x01, data2); /* Access pad */ in gc_psx_read_packet()
596 gc_psx_command(gc, 0x42, id); /* Get device ids */ in gc_psx_read_packet()
597 gc_psx_command(gc, 0, data2); /* Dump status */ in gc_psx_read_packet()
601 struct gc_pad *pad = &gc->pads[i]; in gc_psx_read_packet()
612 gc_psx_command(gc, 0, data2); in gc_psx_read_packet()
619 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); in gc_psx_read_packet()
707 static void gc_psx_process_packet(struct gc *gc) in gc_psx_process_packet() argument
714 gc_psx_read_packet(gc, data, id); in gc_psx_process_packet()
717 pad = &gc->pads[i]; in gc_psx_process_packet()
729 struct gc *gc = from_timer(gc, t, timer); in gc_timer() local
735 if (gc->pad_count[GC_N64]) in gc_timer()
736 gc_n64_process_packet(gc); in gc_timer()
742 if (gc->pad_count[GC_NES] || in gc_timer()
743 gc->pad_count[GC_SNES] || in gc_timer()
744 gc->pad_count[GC_SNESMOUSE]) { in gc_timer()
745 gc_nes_process_packet(gc); in gc_timer()
752 if (gc->pad_count[GC_MULTI] || gc->pad_count[GC_MULTI2]) in gc_timer()
753 gc_multi_process_packet(gc); in gc_timer()
759 if (gc->pad_count[GC_PSX] || gc->pad_count[GC_DDR]) in gc_timer()
760 gc_psx_process_packet(gc); in gc_timer()
762 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); in gc_timer()
767 struct gc *gc = input_get_drvdata(dev); in gc_open() local
770 err = mutex_lock_interruptible(&gc->mutex); in gc_open()
774 if (!gc->used++) { in gc_open()
775 parport_claim(gc->pd); in gc_open()
776 parport_write_control(gc->pd->port, 0x04); in gc_open()
777 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); in gc_open()
780 mutex_unlock(&gc->mutex); in gc_open()
786 struct gc *gc = input_get_drvdata(dev); in gc_close() local
788 mutex_lock(&gc->mutex); in gc_close()
789 if (!--gc->used) { in gc_close()
790 del_timer_sync(&gc->timer); in gc_close()
791 parport_write_control(gc->pd->port, 0x00); in gc_close()
792 parport_release(gc->pd); in gc_close()
794 mutex_unlock(&gc->mutex); in gc_close()
797 static int gc_setup_pad(struct gc *gc, int idx, int pad_type) in gc_setup_pad() argument
799 struct gc_pad *pad = &gc->pads[idx]; in gc_setup_pad()
818 "%s/input%d", gc->pd->port->name, idx); in gc_setup_pad()
827 input_set_drvdata(input_dev, gc); in gc_setup_pad()
840 gc->pad_count[pad_type]++; in gc_setup_pad()
921 struct gc *gc; in gc_attach() local
953 gc = kzalloc(sizeof(*gc), GFP_KERNEL); in gc_attach()
954 if (!gc) { in gc_attach()
959 mutex_init(&gc->mutex); in gc_attach()
960 gc->pd = pd; in gc_attach()
961 gc->parportno = pp->number; in gc_attach()
962 timer_setup(&gc->timer, gc_timer, 0); in gc_attach()
968 if (gc_setup_pad(gc, i, pads[i])) in gc_attach()
979 gc_base[port_idx] = gc; in gc_attach()
984 if (gc->pads[i].dev) in gc_attach()
985 input_unregister_device(gc->pads[i].dev); in gc_attach()
987 kfree(gc); in gc_attach()
995 struct gc *gc; in gc_detach() local
1005 gc = gc_base[i]; in gc_detach()
1009 if (gc->pads[i].dev) in gc_detach()
1010 input_unregister_device(gc->pads[i].dev); in gc_detach()
1011 parport_unregister_device(gc->pd); in gc_detach()
1012 kfree(gc); in gc_detach()