Lines Matching refs:gc

89 struct gc {  struct
102 static struct gc *gc_base[3]; argument
148 static void gc_n64_send_command(struct gc *gc, unsigned long cmd, in gc_n64_send_command() argument
151 struct parport *port = gc->pd->port; in gc_n64_send_command()
162 static void gc_n64_send_stop_bit(struct gc *gc, unsigned char target) in gc_n64_send_stop_bit() argument
164 struct parport *port = gc->pd->port; in gc_n64_send_stop_bit()
180 static void gc_n64_read_packet(struct gc *gc, unsigned char *data) in gc_n64_read_packet() argument
190 gc_n64_send_command(gc, GC_N64_REQUEST_DATA, GC_N64_OUT); in gc_n64_read_packet()
191 gc_n64_send_stop_bit(gc, GC_N64_OUT); in gc_n64_read_packet()
206 parport_write_data(gc->pd->port, GC_N64_POWER_R); in gc_n64_read_packet()
208 data[i] = parport_read_status(gc->pd->port); in gc_n64_read_packet()
209 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK); in gc_n64_read_packet()
220 static void gc_n64_process_packet(struct gc *gc) in gc_n64_process_packet() argument
227 gc_n64_read_packet(gc, data); in gc_n64_process_packet()
231 if (gc->pads[i].type != GC_N64) in gc_n64_process_packet()
234 dev = gc->pads[i].dev; in gc_n64_process_packet()
270 struct gc *gc = input_get_drvdata(dev); in gc_n64_play_effect() local
283 gc_n64_send_command(gc, GC_N64_CMD_03, 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_command(gc, GC_N64_CMD_01, target); in gc_n64_play_effect()
287 gc_n64_send_command(gc, GC_N64_CMD_80, target); in gc_n64_play_effect()
288 gc_n64_send_stop_bit(gc, target); in gc_n64_play_effect()
293 gc_n64_send_command(gc, GC_N64_CMD_03, target); in gc_n64_play_effect()
294 gc_n64_send_command(gc, GC_N64_CMD_c0, target); in gc_n64_play_effect()
295 gc_n64_send_command(gc, GC_N64_CMD_1b, target); in gc_n64_play_effect()
297 gc_n64_send_command(gc, cmd, target); in gc_n64_play_effect()
298 gc_n64_send_stop_bit(gc, target); in gc_n64_play_effect()
356 static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data) in gc_nes_read_packet() argument
360 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK | GC_NES_LATCH); in gc_nes_read_packet()
362 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK); in gc_nes_read_packet()
366 parport_write_data(gc->pd->port, GC_NES_POWER); in gc_nes_read_packet()
367 data[i] = parport_read_status(gc->pd->port) ^ 0x7f; in gc_nes_read_packet()
369 parport_write_data(gc->pd->port, GC_NES_POWER | GC_NES_CLOCK); in gc_nes_read_packet()
373 static void gc_nes_process_packet(struct gc *gc) in gc_nes_process_packet() argument
381 len = gc->pad_count[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : in gc_nes_process_packet()
382 (gc->pad_count[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); in gc_nes_process_packet()
384 gc_nes_read_packet(gc, len, data); in gc_nes_process_packet()
388 pad = &gc->pads[i]; in gc_nes_process_packet()
475 static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data) in gc_multi_read_packet() argument
480 parport_write_data(gc->pd->port, ~(1 << i)); in gc_multi_read_packet()
481 data[i] = parport_read_status(gc->pd->port) ^ 0x7f; in gc_multi_read_packet()
485 static void gc_multi_process_packet(struct gc *gc) in gc_multi_process_packet() argument
488 int data_len = gc->pad_count[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH; in gc_multi_process_packet()
493 gc_multi_read_packet(gc, data_len, data); in gc_multi_process_packet()
496 pad = &gc->pads[i]; in gc_multi_process_packet()
565 static void gc_psx_command(struct gc *gc, int b, unsigned char *data) in gc_psx_command() argument
567 struct parport *port = gc->pd->port; in gc_psx_command()
580 struct gc_pad *pad = &gc->pads[j]; in gc_psx_command()
586 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); in gc_psx_command()
596 static void gc_psx_read_packet(struct gc *gc, in gc_psx_read_packet() argument
605 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); in gc_psx_read_packet()
608 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER); in gc_psx_read_packet()
613 gc_psx_command(gc, 0x01, data2); /* Access pad */ in gc_psx_read_packet()
614 gc_psx_command(gc, 0x42, id); /* Get device ids */ in gc_psx_read_packet()
615 gc_psx_command(gc, 0, data2); /* Dump status */ in gc_psx_read_packet()
619 struct gc_pad *pad = &gc->pads[i]; in gc_psx_read_packet()
630 gc_psx_command(gc, 0, data2); in gc_psx_read_packet()
637 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); in gc_psx_read_packet()
724 static void gc_psx_process_packet(struct gc *gc) in gc_psx_process_packet() argument
731 gc_psx_read_packet(gc, data, id); in gc_psx_process_packet()
734 pad = &gc->pads[i]; in gc_psx_process_packet()
746 struct gc *gc = (void *) private; in gc_timer() local
752 if (gc->pad_count[GC_N64]) in gc_timer()
753 gc_n64_process_packet(gc); in gc_timer()
759 if (gc->pad_count[GC_NES] || in gc_timer()
760 gc->pad_count[GC_SNES] || in gc_timer()
761 gc->pad_count[GC_SNESMOUSE]) { in gc_timer()
762 gc_nes_process_packet(gc); in gc_timer()
769 if (gc->pad_count[GC_MULTI] || gc->pad_count[GC_MULTI2]) in gc_timer()
770 gc_multi_process_packet(gc); in gc_timer()
776 if (gc->pad_count[GC_PSX] || gc->pad_count[GC_DDR]) in gc_timer()
777 gc_psx_process_packet(gc); in gc_timer()
779 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); in gc_timer()
784 struct gc *gc = input_get_drvdata(dev); in gc_open() local
787 err = mutex_lock_interruptible(&gc->mutex); in gc_open()
791 if (!gc->used++) { in gc_open()
792 parport_claim(gc->pd); in gc_open()
793 parport_write_control(gc->pd->port, 0x04); in gc_open()
794 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); in gc_open()
797 mutex_unlock(&gc->mutex); in gc_open()
803 struct gc *gc = input_get_drvdata(dev); in gc_close() local
805 mutex_lock(&gc->mutex); in gc_close()
806 if (!--gc->used) { in gc_close()
807 del_timer_sync(&gc->timer); in gc_close()
808 parport_write_control(gc->pd->port, 0x00); in gc_close()
809 parport_release(gc->pd); in gc_close()
811 mutex_unlock(&gc->mutex); in gc_close()
814 static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) in gc_setup_pad() argument
816 struct gc_pad *pad = &gc->pads[idx]; in gc_setup_pad()
835 "%s/input%d", gc->pd->port->name, idx); in gc_setup_pad()
844 input_set_drvdata(input_dev, gc); in gc_setup_pad()
857 gc->pad_count[pad_type]++; in gc_setup_pad()
929 static struct gc __init *gc_probe(int parport, int *pads, int n_pads) in gc_probe()
931 struct gc *gc; in gc_probe() local
952 gc = kzalloc(sizeof(struct gc), GFP_KERNEL); in gc_probe()
953 if (!gc) { in gc_probe()
959 mutex_init(&gc->mutex); in gc_probe()
960 gc->pd = pd; in gc_probe()
961 setup_timer(&gc->timer, gc_timer, (long) gc); in gc_probe()
967 err = gc_setup_pad(gc, i, pads[i]); in gc_probe()
981 return gc; in gc_probe()
985 if (gc->pads[i].dev) in gc_probe()
986 input_unregister_device(gc->pads[i].dev); in gc_probe()
988 kfree(gc); in gc_probe()
997 static void gc_remove(struct gc *gc) in gc_remove() argument
1002 if (gc->pads[i].dev) in gc_remove()
1003 input_unregister_device(gc->pads[i].dev); in gc_remove()
1004 parport_unregister_device(gc->pd); in gc_remove()
1005 kfree(gc); in gc_remove()