Lines Matching refs:gc

85 struct gc {  struct
99 static struct gc *gc_base[3]; argument
145 static void gc_n64_send_command(struct gc *gc, unsigned long cmd, in gc_n64_send_command() argument
148 struct parport *port = gc->pd->port; in gc_n64_send_command()
159 static void gc_n64_send_stop_bit(struct gc *gc, unsigned char target) in gc_n64_send_stop_bit() argument
161 struct parport *port = gc->pd->port; in gc_n64_send_stop_bit()
177 static void gc_n64_read_packet(struct gc *gc, unsigned char *data) in gc_n64_read_packet() argument
187 gc_n64_send_command(gc, GC_N64_REQUEST_DATA, GC_N64_OUT); in gc_n64_read_packet()
188 gc_n64_send_stop_bit(gc, GC_N64_OUT); in gc_n64_read_packet()
203 parport_write_data(gc->pd->port, GC_N64_POWER_R); in gc_n64_read_packet()
205 data[i] = parport_read_status(gc->pd->port); in gc_n64_read_packet()
206 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK); in gc_n64_read_packet()
217 static void gc_n64_process_packet(struct gc *gc) in gc_n64_process_packet() argument
224 gc_n64_read_packet(gc, data); in gc_n64_process_packet()
228 if (gc->pads[i].type != GC_N64) in gc_n64_process_packet()
231 dev = gc->pads[i].dev; in gc_n64_process_packet()
267 struct gc *gc = input_get_drvdata(dev); in gc_n64_play_effect() local
280 gc_n64_send_command(gc, GC_N64_CMD_03, target); in gc_n64_play_effect()
281 gc_n64_send_command(gc, GC_N64_CMD_80, target); in gc_n64_play_effect()
282 gc_n64_send_command(gc, GC_N64_CMD_01, target); in gc_n64_play_effect()
284 gc_n64_send_command(gc, GC_N64_CMD_80, target); in gc_n64_play_effect()
285 gc_n64_send_stop_bit(gc, target); in gc_n64_play_effect()
290 gc_n64_send_command(gc, GC_N64_CMD_03, target); in gc_n64_play_effect()
291 gc_n64_send_command(gc, GC_N64_CMD_c0, target); in gc_n64_play_effect()
292 gc_n64_send_command(gc, GC_N64_CMD_1b, target); in gc_n64_play_effect()
294 gc_n64_send_command(gc, cmd, target); in gc_n64_play_effect()
295 gc_n64_send_stop_bit(gc, target); in gc_n64_play_effect()
353 static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data) in gc_nes_read_packet() argument
357 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK | GC_NES_LATCH); in gc_nes_read_packet()
359 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK); in gc_nes_read_packet()
363 parport_write_data(gc->pd->port, GC_NES_POWER); in gc_nes_read_packet()
364 data[i] = parport_read_status(gc->pd->port) ^ 0x7f; in gc_nes_read_packet()
366 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK); in gc_nes_read_packet()
370 static void gc_nes_process_packet(struct gc *gc) in gc_nes_process_packet() argument
378 len = gc->pad_count[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : in gc_nes_process_packet()
379 (gc->pad_count[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); in gc_nes_process_packet()
381 gc_nes_read_packet(gc, len, data); in gc_nes_process_packet()
385 pad = &gc->pads[i]; in gc_nes_process_packet()
472 static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data) in gc_multi_read_packet() argument
477 parport_write_data(gc->pd->port, ~(1 << i)); in gc_multi_read_packet()
478 data[i] = parport_read_status(gc->pd->port) ^ 0x7f; in gc_multi_read_packet()
482 static void gc_multi_process_packet(struct gc *gc) in gc_multi_process_packet() argument
485 int data_len = gc->pad_count[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH; in gc_multi_process_packet()
490 gc_multi_read_packet(gc, data_len, data); in gc_multi_process_packet()
493 pad = &gc->pads[i]; in gc_multi_process_packet()
562 static void gc_psx_command(struct gc *gc, int b, unsigned char *data) in gc_psx_command() argument
564 struct parport *port = gc->pd->port; in gc_psx_command()
577 struct gc_pad *pad = &gc->pads[j]; in gc_psx_command()
583 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); in gc_psx_command()
593 static void gc_psx_read_packet(struct gc *gc, in gc_psx_read_packet() argument
602 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); in gc_psx_read_packet()
605 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER); in gc_psx_read_packet()
610 gc_psx_command(gc, 0x01, data2); /* Access pad */ in gc_psx_read_packet()
611 gc_psx_command(gc, 0x42, id); /* Get device ids */ in gc_psx_read_packet()
612 gc_psx_command(gc, 0, data2); /* Dump status */ in gc_psx_read_packet()
616 struct gc_pad *pad = &gc->pads[i]; in gc_psx_read_packet()
627 gc_psx_command(gc, 0, data2); in gc_psx_read_packet()
634 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); in gc_psx_read_packet()
722 static void gc_psx_process_packet(struct gc *gc) in gc_psx_process_packet() argument
729 gc_psx_read_packet(gc, data, id); in gc_psx_process_packet()
732 pad = &gc->pads[i]; in gc_psx_process_packet()
744 struct gc *gc = from_timer(gc, t, timer); in gc_timer() local
750 if (gc->pad_count[GC_N64]) in gc_timer()
751 gc_n64_process_packet(gc); in gc_timer()
757 if (gc->pad_count[GC_NES] || in gc_timer()
758 gc->pad_count[GC_SNES] || in gc_timer()
759 gc->pad_count[GC_SNESMOUSE]) { in gc_timer()
760 gc_nes_process_packet(gc); in gc_timer()
767 if (gc->pad_count[GC_MULTI] || gc->pad_count[GC_MULTI2]) in gc_timer()
768 gc_multi_process_packet(gc); in gc_timer()
774 if (gc->pad_count[GC_PSX] || gc->pad_count[GC_DDR]) in gc_timer()
775 gc_psx_process_packet(gc); in gc_timer()
777 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); in gc_timer()
782 struct gc *gc = input_get_drvdata(dev); in gc_open() local
785 err = mutex_lock_interruptible(&gc->mutex); in gc_open()
789 if (!gc->used++) { in gc_open()
790 parport_claim(gc->pd); in gc_open()
791 parport_write_control(gc->pd->port, 0x04); in gc_open()
792 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); in gc_open()
795 mutex_unlock(&gc->mutex); in gc_open()
801 struct gc *gc = input_get_drvdata(dev); in gc_close() local
803 mutex_lock(&gc->mutex); in gc_close()
804 if (!--gc->used) { in gc_close()
805 del_timer_sync(&gc->timer); in gc_close()
806 parport_write_control(gc->pd->port, 0x00); in gc_close()
807 parport_release(gc->pd); in gc_close()
809 mutex_unlock(&gc->mutex); in gc_close()
812 static int gc_setup_pad(struct gc *gc, int idx, int pad_type) in gc_setup_pad() argument
814 struct gc_pad *pad = &gc->pads[idx]; in gc_setup_pad()
833 "%s/input%d", gc->pd->port->name, idx); in gc_setup_pad()
842 input_set_drvdata(input_dev, gc); in gc_setup_pad()
855 gc->pad_count[pad_type]++; in gc_setup_pad()
935 struct gc *gc; in gc_attach() local
967 gc = kzalloc(sizeof(struct gc), GFP_KERNEL); in gc_attach()
968 if (!gc) { in gc_attach()
973 mutex_init(&gc->mutex); in gc_attach()
974 gc->pd = pd; in gc_attach()
975 gc->parportno = pp->number; in gc_attach()
976 timer_setup(&gc->timer, gc_timer, 0); in gc_attach()
982 if (gc_setup_pad(gc, i, pads[i])) in gc_attach()
993 gc_base[port_idx] = gc; in gc_attach()
998 if (gc->pads[i].dev) in gc_attach()
999 input_unregister_device(gc->pads[i].dev); in gc_attach()
1001 kfree(gc); in gc_attach()
1009 struct gc *gc; in gc_detach() local
1019 gc = gc_base[i]; in gc_detach()
1023 if (gc->pads[i].dev) in gc_detach()
1024 input_unregister_device(gc->pads[i].dev); in gc_detach()
1025 parport_unregister_device(gc->pd); in gc_detach()
1026 kfree(gc); in gc_detach()