• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
2index 69e7c8d4a..6bdc118dd 100644
3--- a/arch/arm64/kernel/vmlinux.lds.S
4+++ b/arch/arm64/kernel/vmlinux.lds.S
5@@ -176,6 +176,15 @@ SECTIONS
6 		INIT_RAM_FS
7 		*(.init.rodata.* .init.bss)	/* from the EFI stub */
8 	}
9+
10+#ifdef CONFIG_DRIVERS_HDF
11+	.init.hdf_table : {
12+		_hdf_drivers_start = .;
13+		*(.hdf.driver)
14+		_hdf_drivers_end = .;
15+	}
16+#endif
17+
18 	.exit.data : {
19 		ARM_EXIT_KEEP(EXIT_DATA)
20 	}
21diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
22index 23150c0f0..2780470c5 100644
23--- a/arch/arm/kernel/vmlinux.lds.S
24+++ b/arch/arm/kernel/vmlinux.lds.S
25@@ -121,6 +121,14 @@ SECTIONS
26 		__pv_table_end = .;
27 	}
28
29+#ifdef CONFIG_DRIVERS_HDF
30+	.init.hdf_table : {
31+		_hdf_drivers_start = .;
32+		*(.hdf.driver)
33+		_hdf_drivers_end = .;
34+	}
35+#endif
36+
37 	INIT_DATA_SECTION(16)
38
39 	.exit.data : {
40diff --git a/drivers/Kconfig b/drivers/Kconfig
41index ab4d43923..70fade369 100644
42--- a/drivers/Kconfig
43+++ b/drivers/Kconfig
44@@ -217,6 +217,8 @@ source "drivers/visorbus/Kconfig"
45
46 source "drivers/siox/Kconfig"
47
48+source "drivers/hdf/khdf/Kconfig"
49+
50 source "drivers/slimbus/Kconfig"
51
52 endmenu
53diff --git a/drivers/Makefile b/drivers/Makefile
54index 578f469f7..f4aae6a3a 100644
55--- a/drivers/Makefile
56+++ b/drivers/Makefile
57@@ -185,4 +185,5 @@ obj-$(CONFIG_TEE)		+= tee/
58 obj-$(CONFIG_MULTIPLEXER)	+= mux/
59 obj-$(CONFIG_UNISYS_VISORBUS)	+= visorbus/
60 obj-$(CONFIG_SIOX)		+= siox/
61+obj-$(CONFIG_DRIVERS_HDF)	+= hdf/
62 obj-$(CONFIG_GNSS)		+= gnss/
63diff --git a/drivers/hdf/Makefile b/drivers/hdf/Makefile
64new file mode 100644
65index 000000000..01ce6ab52
66--- /dev/null
67+++ b/drivers/hdf/Makefile
68@@ -0,0 +1 @@
69+obj-$(CONFIG_DRIVERS_HDF) += khdf/
70diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
71index bd7ac53b7..d7efd1e3d 100644
72--- a/drivers/hid/Makefile
73+++ b/drivers/hid/Makefile
74@@ -2,6 +2,15 @@
75 #
76 # Makefile for the HID driver
77 #
78+HDF_ROOT_DIR = -Idrivers/hdf
79+ccflags-$(CONFIG_DRIVERS_HDF_INPUT) += $(HDF_ROOT_DIR)/framework/model/input/driver \
80+             $(HDF_ROOT_DIR)/framework/include/core \
81+             $(HDF_ROOT_DIR)/framework/core/common/include/host \
82+             $(HDF_ROOT_DIR)/framework/include/utils \
83+             $(HDF_ROOT_DIR)/framework/include/osal \
84+             $(HDF_ROOT_DIR)/framework/ability/sbuf/include \
85+             $(HDF_ROOT_DIR)/khdf/osal/include \
86+             -I../../../../../third_party/FreeBSD/sys/dev/evdev
87 hid-y			:= hid-core.o hid-input.o hid-quirks.o
88 hid-$(CONFIG_DEBUG_FS)		+= hid-debug.o
89
90diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
91index bde5cef32..1cf2e9b9c 100644
92--- a/drivers/hid/hid-core.c
93+++ b/drivers/hid/hid-core.c
94@@ -36,6 +36,9 @@
95 #include <linux/hid-debug.h>
96 #include <linux/hidraw.h>
97
98+#if defined(CONFIG_DRIVERS_HDF_INPUT)
99+#include "hdf_hid_adapter.h"
100+#endif
101 #include "hid-ids.h"
102
103 /*
104@@ -1340,6 +1343,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field,
105 		hidinput_hid_event(hid, field, usage, value);
106 	if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
107 		hid->hiddev_hid_event(hid, field, usage, value);
108+#if defined(CONFIG_DRIVERS_HDF_INPUT)
109+	if (hid->input_dev) {
110+		HidReportEvent(hid->input_dev, usage->type, usage->code, value);
111+	}
112+#endif
113 }
114
115 /*
116@@ -1743,6 +1751,81 @@ static const struct device_attribute dev_attr_country = {
117 	.show = show_country,
118 };
119
120+#if defined(CONFIG_DRIVERS_HDF_INPUT)
121+static bool check_mouse(char *name)
122+{
123+	static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"};
124+	for (int i = 0; i < 4; i++) {
125+		if (strstr(name, option[i]))
126+			return true;
127+	}
128+	return false;
129+}
130+static bool check_kbd(char *name)
131+{
132+	static char *option[]={"Keyboard", "keyboard"};
133+	for (int i = 0; i < 2; i++) {
134+		if (strstr(name, option[i]))
135+			return true;
136+	}
137+	return false;
138+}
139+static bool check_rocker(char *name)
140+{
141+	static char *option[]={"Thrustmaster"};
142+	for (int i = 0; i < 1; i++) {
143+		if (strstr(name, option[i]))
144+			return true;
145+	}
146+	return false;
147+}
148+static bool check_encoder(char *name)
149+{
150+	if (strcmp(name, "Wired KeyBoard") == 0) {
151+		return true;
152+	}
153+	return false;
154+}
155+static bool check_trackball(char *name)
156+{
157+	static char *option[]={"Trackball"};
158+	for (int i = 0; i < 1; i++) {
159+		if (strstr(name, option[i]))
160+			return true;
161+	}
162+	return false;
163+}
164+static void notify_connect_event(struct hid_device *hdev)
165+{
166+	bool check;
167+	int type = -1;
168+	HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL);
169+	if (dev == NULL) {
170+		printk("%s: malloc failed", __func__);
171+		return;
172+	}
173+	type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type;
174+	type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type;
175+	type = check_rocker(hdev->name)?HID_TYPE_ROCKER:type;
176+	type = check_encoder(hdev->name)?HID_TYPE_ENCODER:type;
177+	type = check_trackball(hdev->name)?HID_TYPE_TRACKBALL:type;
178+	if ( type < 0) {
179+		kfree(dev);
180+		dev = NULL;
181+		return;
182+	}
183+
184+	dev->devType = type;
185+	dev->devName = hdev->name;
186+	hdev->input_dev = HidRegisterHdfInputDev(dev);
187+	if (hdev->input_dev == NULL) {
188+		printk("%s: RegisterInputDevice failed\n", __func__);
189+	}
190+	kfree(dev);
191+	dev = NULL;
192+}
193+#endif
194+
195 int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
196 {
197 	static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
198@@ -1832,6 +1915,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
199 	hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
200 		 buf, bus, hdev->version >> 8, hdev->version & 0xff,
201 		 type, hdev->name, hdev->phys);
202+#if defined(CONFIG_DRIVERS_HDF_INPUT)
203+	notify_connect_event(hdev);
204+#endif
205
206 	return 0;
207 }
208@@ -1847,6 +1933,10 @@ void hid_disconnect(struct hid_device *hdev)
209 	if (hdev->claimed & HID_CLAIMED_HIDRAW)
210 		hidraw_disconnect(hdev);
211 	hdev->claimed = 0;
212+#if defined(CONFIG_DRIVERS_HDF_INPUT)
213+	if (hdev->input_dev)
214+		HidUnregisterHdfInputDev(hdev->input_dev);
215+#endif
216 }
217 EXPORT_SYMBOL_GPL(hid_disconnect);
218
219@@ -1931,6 +2021,11 @@ EXPORT_SYMBOL_GPL(hid_hw_open);
220  */
221 void hid_hw_close(struct hid_device *hdev)
222 {
223+#if defined(CONFIG_DRIVERS_HDF_INPUT)
224+	if (hdev->input_dev) {
225+		return;
226+	}
227+#endif
228 	mutex_lock(&hdev->ll_open_lock);
229 	if (!--hdev->ll_open_count)
230 		hdev->ll_driver->close(hdev);
231diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
232index 11bd2ca22..a5d0d6c19 100644
233--- a/drivers/hid/hid-input.c
234+++ b/drivers/hid/hid-input.c
235@@ -32,6 +32,10 @@
236 #include <linux/hid.h>
237 #include <linux/hid-debug.h>
238
239+#if defined(CONFIG_DRIVERS_HDF_INPUT)
240+#include "hdf_hid_adapter.h"
241+#endif
242+
243 #include "hid-ids.h"
244
245 #define unk	KEY_UNKNOWN
246@@ -1365,7 +1369,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report)
247 		return;
248
249 	list_for_each_entry(hidinput, &hid->inputs, list)
250+#if defined(CONFIG_DRIVERS_HDF_INPUT)
251+	{
252+#endif
253 		input_sync(hidinput->input);
254+#if defined(CONFIG_DRIVERS_HDF_INPUT)
255+		if(hid->input_dev)
256+			HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0);
257+	}
258+#endif
259 }
260 EXPORT_SYMBOL_GPL(hidinput_report_event);
261
262@@ -1729,6 +1741,41 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput,
263 						 report->field[i]->usage + j);
264 }
265
266+#if defined(CONFIG_DRIVERS_HDF_INPUT)
267+static void transfer_info(struct input_dev *dev)
268+{
269+	HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL);
270+	if (info == NULL) {
271+		printk("%s: malloc failed\n",__func__);
272+		return;
273+	}
274+	info->devName = dev->name;
275+	memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT));
276+	memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT));
277+	memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT));
278+	memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT));
279+	memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT));
280+	memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT));
281+	memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT));
282+	memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT));
283+	memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT));
284+	memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT));
285+	for (int i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) {
286+        if (dev->absbit[i] != 0) {
287+            memcpy(info->axisInfo, dev->absinfo, sizeof(struct input_absinfo) * ABS_CNT);
288+            break;
289+        }
290+    }
291+	info->bustype = dev->id.bustype;
292+	info->vendor = dev->id.vendor;
293+	info->product = dev->id.product;
294+	info->version = dev->id.version;
295+	SendInfoToHdf(info);
296+	kfree(info);
297+	info = NULL;
298+}
299+#endif
300+
301 /*
302  * Register the input device; print a message.
303  * Configure the input layer interface
304@@ -1811,7 +1858,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
305 			hidinput_cleanup_hidinput(hid, hidinput);
306 			continue;
307 		}
308-
309+#if defined(CONFIG_DRIVERS_HDF_INPUT)
310+		transfer_info(hidinput->input);
311+#endif
312 		if (input_register_device(hidinput->input))
313 			goto out_unwind;
314 		hidinput->registered = true;
315diff --git a/include/linux/hid.h b/include/linux/hid.h
316index a46b6832b..c61a17de5 100644
317--- a/include/linux/hid.h
318+++ b/include/linux/hid.h
319@@ -621,6 +621,7 @@ struct hid_device {							/* device report descriptor */
320 	struct list_head debug_list;
321 	spinlock_t  debug_list_lock;
322 	wait_queue_head_t debug_wait;
323+	void *input_dev;
324 };
325
326 #define to_hid_device(pdev) \
327--
3282.25.1
329
330