Lines Matching refs:gc
73 struct gc { struct
87 static struct gc *gc_base[3]; argument
133 static void gc_n64_send_command(struct gc *gc, unsigned long cmd, in gc_n64_send_command() argument
136 struct parport *port = gc->pd->port; in gc_n64_send_command()
147 static void gc_n64_send_stop_bit(struct gc *gc, unsigned char target) in gc_n64_send_stop_bit() argument
149 struct parport *port = gc->pd->port; in gc_n64_send_stop_bit()
165 static void gc_n64_read_packet(struct gc *gc, unsigned char *data) in gc_n64_read_packet() argument
175 gc_n64_send_command(gc, GC_N64_REQUEST_DATA, GC_N64_OUT); in gc_n64_read_packet()
176 gc_n64_send_stop_bit(gc, GC_N64_OUT); in gc_n64_read_packet()
191 parport_write_data(gc->pd->port, GC_N64_POWER_R); in gc_n64_read_packet()
193 data[i] = parport_read_status(gc->pd->port); in gc_n64_read_packet()
194 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK); in gc_n64_read_packet()
205 static void gc_n64_process_packet(struct gc *gc) in gc_n64_process_packet() argument
212 gc_n64_read_packet(gc, data); in gc_n64_process_packet()
216 if (gc->pads[i].type != GC_N64) in gc_n64_process_packet()
219 dev = gc->pads[i].dev; in gc_n64_process_packet()
255 struct gc *gc = input_get_drvdata(dev); in gc_n64_play_effect() local
268 gc_n64_send_command(gc, GC_N64_CMD_03, 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_command(gc, GC_N64_CMD_01, target); in gc_n64_play_effect()
272 gc_n64_send_command(gc, GC_N64_CMD_80, target); in gc_n64_play_effect()
273 gc_n64_send_stop_bit(gc, target); in gc_n64_play_effect()
278 gc_n64_send_command(gc, GC_N64_CMD_03, target); in gc_n64_play_effect()
279 gc_n64_send_command(gc, GC_N64_CMD_c0, target); in gc_n64_play_effect()
280 gc_n64_send_command(gc, GC_N64_CMD_1b, target); in gc_n64_play_effect()
282 gc_n64_send_command(gc, cmd, target); in gc_n64_play_effect()
283 gc_n64_send_stop_bit(gc, target); in gc_n64_play_effect()
341 static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data) in gc_nes_read_packet() argument
345 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK | GC_NES_LATCH); in gc_nes_read_packet()
347 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK); in gc_nes_read_packet()
351 parport_write_data(gc->pd->port, GC_NES_POWER); in gc_nes_read_packet()
352 data[i] = parport_read_status(gc->pd->port) ^ 0x7f; in gc_nes_read_packet()
354 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK); in gc_nes_read_packet()
358 static void gc_nes_process_packet(struct gc *gc) in gc_nes_process_packet() argument
366 len = gc->pad_count[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : in gc_nes_process_packet()
367 (gc->pad_count[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); in gc_nes_process_packet()
369 gc_nes_read_packet(gc, len, data); in gc_nes_process_packet()
373 pad = &gc->pads[i]; in gc_nes_process_packet()
460 static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data) in gc_multi_read_packet() argument
465 parport_write_data(gc->pd->port, ~(1 << i)); in gc_multi_read_packet()
466 data[i] = parport_read_status(gc->pd->port) ^ 0x7f; in gc_multi_read_packet()
470 static void gc_multi_process_packet(struct gc *gc) in gc_multi_process_packet() argument
473 int data_len = gc->pad_count[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH; in gc_multi_process_packet()
478 gc_multi_read_packet(gc, data_len, data); in gc_multi_process_packet()
481 pad = &gc->pads[i]; in gc_multi_process_packet()
550 static void gc_psx_command(struct gc *gc, int b, unsigned char *data) in gc_psx_command() argument
552 struct parport *port = gc->pd->port; in gc_psx_command()
565 struct gc_pad *pad = &gc->pads[j]; in gc_psx_command()
571 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); in gc_psx_command()
581 static void gc_psx_read_packet(struct gc *gc, in gc_psx_read_packet() argument
590 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); in gc_psx_read_packet()
593 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER); in gc_psx_read_packet()
598 gc_psx_command(gc, 0x01, data2); /* Access pad */ in gc_psx_read_packet()
599 gc_psx_command(gc, 0x42, id); /* Get device ids */ in gc_psx_read_packet()
600 gc_psx_command(gc, 0, data2); /* Dump status */ in gc_psx_read_packet()
604 struct gc_pad *pad = &gc->pads[i]; in gc_psx_read_packet()
615 gc_psx_command(gc, 0, data2); in gc_psx_read_packet()
622 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); in gc_psx_read_packet()
710 static void gc_psx_process_packet(struct gc *gc) in gc_psx_process_packet() argument
717 gc_psx_read_packet(gc, data, id); in gc_psx_process_packet()
720 pad = &gc->pads[i]; in gc_psx_process_packet()
732 struct gc *gc = from_timer(gc, t, timer); in gc_timer() local
738 if (gc->pad_count[GC_N64]) in gc_timer()
739 gc_n64_process_packet(gc); in gc_timer()
745 if (gc->pad_count[GC_NES] || in gc_timer()
746 gc->pad_count[GC_SNES] || in gc_timer()
747 gc->pad_count[GC_SNESMOUSE]) { in gc_timer()
748 gc_nes_process_packet(gc); in gc_timer()
755 if (gc->pad_count[GC_MULTI] || gc->pad_count[GC_MULTI2]) in gc_timer()
756 gc_multi_process_packet(gc); in gc_timer()
762 if (gc->pad_count[GC_PSX] || gc->pad_count[GC_DDR]) in gc_timer()
763 gc_psx_process_packet(gc); in gc_timer()
765 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); in gc_timer()
770 struct gc *gc = input_get_drvdata(dev); in gc_open() local
773 err = mutex_lock_interruptible(&gc->mutex); in gc_open()
777 if (!gc->used++) { in gc_open()
778 parport_claim(gc->pd); in gc_open()
779 parport_write_control(gc->pd->port, 0x04); in gc_open()
780 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); in gc_open()
783 mutex_unlock(&gc->mutex); in gc_open()
789 struct gc *gc = input_get_drvdata(dev); in gc_close() local
791 mutex_lock(&gc->mutex); in gc_close()
792 if (!--gc->used) { in gc_close()
793 del_timer_sync(&gc->timer); in gc_close()
794 parport_write_control(gc->pd->port, 0x00); in gc_close()
795 parport_release(gc->pd); in gc_close()
797 mutex_unlock(&gc->mutex); in gc_close()
800 static int gc_setup_pad(struct gc *gc, int idx, int pad_type) in gc_setup_pad() argument
802 struct gc_pad *pad = &gc->pads[idx]; in gc_setup_pad()
821 "%s/input%d", gc->pd->port->name, idx); in gc_setup_pad()
830 input_set_drvdata(input_dev, gc); in gc_setup_pad()
843 gc->pad_count[pad_type]++; in gc_setup_pad()
924 struct gc *gc; in gc_attach() local
956 gc = kzalloc(sizeof(struct gc), GFP_KERNEL); in gc_attach()
957 if (!gc) { in gc_attach()
962 mutex_init(&gc->mutex); in gc_attach()
963 gc->pd = pd; in gc_attach()
964 gc->parportno = pp->number; in gc_attach()
965 timer_setup(&gc->timer, gc_timer, 0); in gc_attach()
971 if (gc_setup_pad(gc, i, pads[i])) in gc_attach()
982 gc_base[port_idx] = gc; in gc_attach()
987 if (gc->pads[i].dev) in gc_attach()
988 input_unregister_device(gc->pads[i].dev); in gc_attach()
990 kfree(gc); in gc_attach()
998 struct gc *gc; in gc_detach() local
1008 gc = gc_base[i]; in gc_detach()
1012 if (gc->pads[i].dev) in gc_detach()
1013 input_unregister_device(gc->pads[i].dev); in gc_detach()
1014 parport_unregister_device(gc->pd); in gc_detach()
1015 kfree(gc); in gc_detach()