Lines Matching refs:tgfx

76 static struct tgfx {  struct
93 struct tgfx *tgfx = (void *) private; in tgfx_timer() argument
98 if (tgfx->sticks & (1 << i)) { in tgfx_timer()
100 dev = tgfx->dev[i]; in tgfx_timer()
102 parport_write_data(tgfx->pd->port, ~(1 << i)); in tgfx_timer()
103 data1 = parport_read_status(tgfx->pd->port) ^ 0x7f; in tgfx_timer()
104 data2 = parport_read_control(tgfx->pd->port) ^ 0x04; /* CAVEAT parport */ in tgfx_timer()
118 mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); in tgfx_timer()
123 struct tgfx *tgfx = input_get_drvdata(dev); in tgfx_open() local
126 err = mutex_lock_interruptible(&tgfx->sem); in tgfx_open()
130 if (!tgfx->used++) { in tgfx_open()
131 parport_claim(tgfx->pd); in tgfx_open()
132 parport_write_control(tgfx->pd->port, 0x04); in tgfx_open()
133 mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); in tgfx_open()
136 mutex_unlock(&tgfx->sem); in tgfx_open()
142 struct tgfx *tgfx = input_get_drvdata(dev); in tgfx_close() local
144 mutex_lock(&tgfx->sem); in tgfx_close()
145 if (!--tgfx->used) { in tgfx_close()
146 del_timer_sync(&tgfx->timer); in tgfx_close()
147 parport_write_control(tgfx->pd->port, 0x00); in tgfx_close()
148 parport_release(tgfx->pd); in tgfx_close()
150 mutex_unlock(&tgfx->sem); in tgfx_close()
159 static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) in tgfx_probe()
161 struct tgfx *tgfx; in tgfx_probe() local
182 tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL); in tgfx_probe()
183 if (!tgfx) { in tgfx_probe()
189 mutex_init(&tgfx->sem); in tgfx_probe()
190 tgfx->pd = pd; in tgfx_probe()
191 init_timer(&tgfx->timer); in tgfx_probe()
192 tgfx->timer.data = (long) tgfx; in tgfx_probe()
193 tgfx->timer.function = tgfx_timer; in tgfx_probe()
205 tgfx->dev[i] = input_dev = input_allocate_device(); in tgfx_probe()
212 tgfx->sticks |= (1 << i); in tgfx_probe()
213 snprintf(tgfx->name[i], sizeof(tgfx->name[i]), in tgfx_probe()
215 snprintf(tgfx->phys[i], sizeof(tgfx->phys[i]), in tgfx_probe()
216 "%s/input%d", tgfx->pd->port->name, i); in tgfx_probe()
218 input_dev->name = tgfx->name[i]; in tgfx_probe()
219 input_dev->phys = tgfx->phys[i]; in tgfx_probe()
225 input_set_drvdata(input_dev, tgfx); in tgfx_probe()
237 err = input_register_device(tgfx->dev[i]); in tgfx_probe()
242 if (!tgfx->sticks) { in tgfx_probe()
249 return tgfx; in tgfx_probe()
252 input_free_device(tgfx->dev[i]); in tgfx_probe()
255 if (tgfx->dev[i]) in tgfx_probe()
256 input_unregister_device(tgfx->dev[i]); in tgfx_probe()
258 kfree(tgfx); in tgfx_probe()
267 static void tgfx_remove(struct tgfx *tgfx) in tgfx_remove() argument
272 if (tgfx->dev[i]) in tgfx_remove()
273 input_unregister_device(tgfx->dev[i]); in tgfx_remove()
274 parport_unregister_device(tgfx->pd); in tgfx_remove()
275 kfree(tgfx); in tgfx_remove()