Lines Matching +full:port +full:- +full:phys

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 1998-2001 Vojtech Pavlik
6 * Trystan Larey-Williams
53 { ABS_X, ABS_Y, ABS_RUDDER, -1, ABS_THROTTLE };
71 } tmdc_hat_to_axis[] = {{ 0, 0}, { 1, 0}, { 0,-1}, {-1, 0}, { 0, 1}};
88 …{ 0, "Unknown %d-axis, %d-button TM device %d", 0, 0, { 0, 0 }, { 0, 0 }, tmdc_abs, tmdc_btn_joy…
95 char phys[32]; member
106 struct tmdc_port *port[2]; member
110 char phys[2][32];
161 data[k][i[k]] |= (~v & 1) << (j[k]++ - 1); /* Data bit */ in tmdc_read_packet()
163 t[k]--; in tmdc_read_packet()
172 static int tmdc_parse_packet(struct tmdc_port *port, unsigned char *data) in tmdc_parse_packet() argument
176 if (data[TMDC_BYTE_ID] != port->mode) in tmdc_parse_packet()
177 return -1; in tmdc_parse_packet()
179 for (i = 0; i < port->absc; i++) { in tmdc_parse_packet()
180 if (port->abs[i] < 0) in tmdc_parse_packet()
183 input_report_abs(port->dev, port->abs[i], data[tmdc_byte_a[i]]); in tmdc_parse_packet()
186 switch (port->mode) { in tmdc_parse_packet()
191 input_report_abs(port->dev, ABS_HAT0X, ((data[i] >> 3) & 1) - ((data[i] >> 1) & 1)); in tmdc_parse_packet()
192 input_report_abs(port->dev, ABS_HAT0Y, ((data[i] >> 2) & 1) - ( data[i] & 1)); in tmdc_parse_packet()
198 input_report_abs(port->dev, ABS_HAT0X, tmdc_hat_to_axis[(data[i] - 141) / 25].x); in tmdc_parse_packet()
199 input_report_abs(port->dev, ABS_HAT0Y, tmdc_hat_to_axis[(data[i] - 141) / 25].y); in tmdc_parse_packet()
205 for (i = 0; i < port->btnc[k]; i++) in tmdc_parse_packet()
206 input_report_key(port->dev, port->btn[i + l], in tmdc_parse_packet()
207 ((data[tmdc_byte_d[k]] >> (i + port->btno[k])) & 1)); in tmdc_parse_packet()
208 l += port->btnc[k]; in tmdc_parse_packet()
211 input_sync(port->dev); in tmdc_parse_packet()
227 tmdc->reads++; in tmdc_poll()
229 if ((r = tmdc_read_packet(tmdc->gameport, data)) != tmdc->exists) in tmdc_poll()
233 if (r & (1 << i) & tmdc->exists) { in tmdc_poll()
235 if (tmdc_parse_packet(tmdc->port[i], data[i])) in tmdc_poll()
241 tmdc->bads += bad; in tmdc_poll()
248 gameport_start_polling(tmdc->gameport); in tmdc_open()
256 gameport_stop_polling(tmdc->gameport); in tmdc_close()
262 struct tmdc_port *port; in tmdc_setup_port() local
267 tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL); in tmdc_setup_port()
269 if (!port || !input_dev) { in tmdc_setup_port()
270 err = -ENOMEM; in tmdc_setup_port()
274 port->mode = data[TMDC_BYTE_ID]; in tmdc_setup_port()
276 for (model = tmdc_models; model->id && model->id != port->mode; model++) in tmdc_setup_port()
279 port->abs = model->axes; in tmdc_setup_port()
280 port->btn = model->buttons; in tmdc_setup_port()
282 if (!model->id) { in tmdc_setup_port()
283 port->absc = data[TMDC_BYTE_DEF] >> 4; in tmdc_setup_port()
285 port->btnc[i] = i < (data[TMDC_BYTE_DEF] & 0xf) ? 8 : 0; in tmdc_setup_port()
287 port->absc = model->abs; in tmdc_setup_port()
289 port->btnc[i] = model->btnc[i]; in tmdc_setup_port()
293 port->btno[i] = model->btno[i]; in tmdc_setup_port()
295 snprintf(port->name, sizeof(port->name), model->name, in tmdc_setup_port()
296 port->absc, (data[TMDC_BYTE_DEF] & 0xf) << 3, port->mode); in tmdc_setup_port()
297 snprintf(port->phys, sizeof(port->phys), "%s/input%d", tmdc->gameport->phys, i); in tmdc_setup_port()
299 port->dev = input_dev; in tmdc_setup_port()
301 input_dev->name = port->name; in tmdc_setup_port()
302 input_dev->phys = port->phys; in tmdc_setup_port()
303 input_dev->id.bustype = BUS_GAMEPORT; in tmdc_setup_port()
304 input_dev->id.vendor = GAMEPORT_ID_VENDOR_THRUSTMASTER; in tmdc_setup_port()
305 input_dev->id.product = model->id; in tmdc_setup_port()
306 input_dev->id.version = 0x0100; in tmdc_setup_port()
307 input_dev->dev.parent = &tmdc->gameport->dev; in tmdc_setup_port()
311 input_dev->open = tmdc_open; in tmdc_setup_port()
312 input_dev->close = tmdc_close; in tmdc_setup_port()
314 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in tmdc_setup_port()
316 for (i = 0; i < port->absc && i < TMDC_ABS; i++) in tmdc_setup_port()
317 if (port->abs[i] >= 0) in tmdc_setup_port()
318 input_set_abs_params(input_dev, port->abs[i], 8, 248, 2, 4); in tmdc_setup_port()
320 for (i = 0; i < model->hats && i < TMDC_ABS_HAT; i++) in tmdc_setup_port()
321 input_set_abs_params(input_dev, tmdc_abs_hat[i], -1, 1, 0, 0); in tmdc_setup_port()
324 for (j = 0; j < port->btnc[i] && j < TMDC_BTN; j++) in tmdc_setup_port()
325 set_bit(port->btn[j + b], input_dev->keybit); in tmdc_setup_port()
326 b += port->btnc[i]; in tmdc_setup_port()
329 err = input_register_device(port->dev); in tmdc_setup_port()
336 kfree(port); in tmdc_setup_port()
353 return -ENOMEM; in tmdc_connect()
355 tmdc->gameport = gameport; in tmdc_connect()
363 if (!(tmdc->exists = tmdc_read_packet(gameport, data))) { in tmdc_connect()
364 err = -ENODEV; in tmdc_connect()
372 if (tmdc->exists & (1 << i)) { in tmdc_connect()
382 fail3: while (--i >= 0) { in tmdc_connect()
383 if (tmdc->port[i]) { in tmdc_connect()
384 input_unregister_device(tmdc->port[i]->dev); in tmdc_connect()
385 kfree(tmdc->port[i]); in tmdc_connect()
400 if (tmdc->port[i]) { in tmdc_disconnect()
401 input_unregister_device(tmdc->port[i]->dev); in tmdc_disconnect()
402 kfree(tmdc->port[i]); in tmdc_disconnect()