Lines Matching refs:tgfx
76 static struct tgfx { struct
94 struct tgfx *tgfx = (void *) private; in tgfx_timer() argument
99 if (tgfx->sticks & (1 << i)) { in tgfx_timer()
101 dev = tgfx->dev[i]; in tgfx_timer()
103 parport_write_data(tgfx->pd->port, ~(1 << i)); in tgfx_timer()
104 data1 = parport_read_status(tgfx->pd->port) ^ 0x7f; in tgfx_timer()
105 data2 = parport_read_control(tgfx->pd->port) ^ 0x04; /* CAVEAT parport */ in tgfx_timer()
119 mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); in tgfx_timer()
124 struct tgfx *tgfx = input_get_drvdata(dev); in tgfx_open() local
127 err = mutex_lock_interruptible(&tgfx->sem); in tgfx_open()
131 if (!tgfx->used++) { in tgfx_open()
132 parport_claim(tgfx->pd); in tgfx_open()
133 parport_write_control(tgfx->pd->port, 0x04); in tgfx_open()
134 mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); in tgfx_open()
137 mutex_unlock(&tgfx->sem); in tgfx_open()
143 struct tgfx *tgfx = input_get_drvdata(dev); in tgfx_close() local
145 mutex_lock(&tgfx->sem); in tgfx_close()
146 if (!--tgfx->used) { in tgfx_close()
147 del_timer_sync(&tgfx->timer); in tgfx_close()
148 parport_write_control(tgfx->pd->port, 0x00); in tgfx_close()
149 parport_release(tgfx->pd); in tgfx_close()
151 mutex_unlock(&tgfx->sem); in tgfx_close()
162 struct tgfx *tgfx; in tgfx_attach() local
194 tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL); in tgfx_attach()
195 if (!tgfx) { in tgfx_attach()
200 mutex_init(&tgfx->sem); in tgfx_attach()
201 tgfx->pd = pd; in tgfx_attach()
202 tgfx->parportno = pp->number; in tgfx_attach()
203 init_timer(&tgfx->timer); in tgfx_attach()
204 tgfx->timer.data = (long) tgfx; in tgfx_attach()
205 tgfx->timer.function = tgfx_timer; in tgfx_attach()
216 tgfx->dev[i] = input_dev = input_allocate_device(); in tgfx_attach()
222 tgfx->sticks |= (1 << i); in tgfx_attach()
223 snprintf(tgfx->name[i], sizeof(tgfx->name[i]), in tgfx_attach()
225 snprintf(tgfx->phys[i], sizeof(tgfx->phys[i]), in tgfx_attach()
226 "%s/input%d", tgfx->pd->port->name, i); in tgfx_attach()
228 input_dev->name = tgfx->name[i]; in tgfx_attach()
229 input_dev->phys = tgfx->phys[i]; in tgfx_attach()
235 input_set_drvdata(input_dev, tgfx); in tgfx_attach()
247 if (input_register_device(tgfx->dev[i])) in tgfx_attach()
251 if (!tgfx->sticks) { in tgfx_attach()
256 tgfx_base[port_idx] = tgfx; in tgfx_attach()
260 input_free_device(tgfx->dev[i]); in tgfx_attach()
263 if (tgfx->dev[i]) in tgfx_attach()
264 input_unregister_device(tgfx->dev[i]); in tgfx_attach()
266 kfree(tgfx); in tgfx_attach()
274 struct tgfx *tgfx; in tgfx_detach() local
284 tgfx = tgfx_base[i]; in tgfx_detach()
288 if (tgfx->dev[i]) in tgfx_detach()
289 input_unregister_device(tgfx->dev[i]); in tgfx_detach()
290 parport_unregister_device(tgfx->pd); in tgfx_detach()
291 kfree(tgfx); in tgfx_detach()