hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/input/joystick/iforce/iforce.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
34 * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
....@@ -5,29 +6,11 @@
56 * USB/RS232 I-Force joysticks and wheels.
67 */
78
8
-/*
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
- */
23
-
249 #include <linux/kernel.h>
2510 #include <linux/slab.h>
2611 #include <linux/input.h>
2712 #include <linux/module.h>
2813 #include <linux/spinlock.h>
29
-#include <linux/usb.h>
30
-#include <linux/serio.h>
3114 #include <linux/circ_buf.h>
3215 #include <linux/mutex.h>
3316
....@@ -39,10 +22,6 @@
3922
4023
4124 #define IFORCE_MAX_LENGTH 16
42
-
43
-/* iforce::bus */
44
-#define IFORCE_232 1
45
-#define IFORCE_USB 2
4625
4726 #define IFORCE_EFFECTS_MAX 32
4827
....@@ -93,27 +72,21 @@
9372 signed short *ff;
9473 };
9574
75
+struct iforce;
76
+
77
+struct iforce_xport_ops {
78
+ void (*xmit)(struct iforce *iforce);
79
+ int (*get_id)(struct iforce *iforce, u8 id,
80
+ u8 *response_data, size_t *response_len);
81
+ int (*start_io)(struct iforce *iforce);
82
+ void (*stop_io)(struct iforce *iforce);
83
+};
84
+
9685 struct iforce {
9786 struct input_dev *dev; /* Input device interface */
9887 struct iforce_device *type;
99
- int bus;
88
+ const struct iforce_xport_ops *xport_ops;
10089
101
- unsigned char data[IFORCE_MAX_LENGTH];
102
- unsigned char edata[IFORCE_MAX_LENGTH];
103
- u16 ecmd;
104
- u16 expect_packet;
105
-
106
-#ifdef CONFIG_JOYSTICK_IFORCE_232
107
- struct serio *serio; /* RS232 transfer */
108
- int idx, pkt, len, id;
109
- unsigned char csum;
110
-#endif
111
-#ifdef CONFIG_JOYSTICK_IFORCE_USB
112
- struct usb_device *usbdev; /* USB transfer */
113
- struct usb_interface *intf;
114
- struct urb *irq, *out, *ctrl;
115
- struct usb_ctrlrequest cr;
116
-#endif
11790 spinlock_t xmit_lock;
11891 /* Buffer used for asynchronous sending of bytes to the device */
11992 struct circ_buf xmit;
....@@ -139,23 +112,30 @@
139112 /* Encode a time value */
140113 #define TIME_SCALE(a) (a)
141114
115
+static inline int iforce_get_id_packet(struct iforce *iforce, u8 id,
116
+ u8 *response_data, size_t *response_len)
117
+{
118
+ return iforce->xport_ops->get_id(iforce, id,
119
+ response_data, response_len);
120
+}
121
+
122
+static inline void iforce_clear_xmit_and_wake(struct iforce *iforce)
123
+{
124
+ clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags);
125
+ wake_up_all(&iforce->wait);
126
+}
142127
143128 /* Public functions */
144
-/* iforce-serio.c */
145
-void iforce_serial_xmit(struct iforce *iforce);
146
-
147
-/* iforce-usb.c */
148
-void iforce_usb_xmit(struct iforce *iforce);
149
-
150129 /* iforce-main.c */
151
-int iforce_init_device(struct iforce *iforce);
130
+int iforce_init_device(struct device *parent, u16 bustype,
131
+ struct iforce *iforce);
152132
153133 /* iforce-packets.c */
154134 int iforce_control_playback(struct iforce*, u16 id, unsigned int);
155
-void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data);
135
+void iforce_process_packet(struct iforce *iforce,
136
+ u8 packet_id, u8 *data, size_t len);
156137 int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data);
157138 void iforce_dump_packet(struct iforce *iforce, char *msg, u16 cmd, unsigned char *data);
158
-int iforce_get_id_packet(struct iforce *iforce, char *packet);
159139
160140 /* iforce-ff.c */
161141 int iforce_upload_periodic(struct iforce *, struct ff_effect *, struct ff_effect *);