• 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,19 @@
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)/inner_api/utils \
86+             $(HDF_ROOT_DIR)/inner_api/osal/shared \
87+             $(HDF_ROOT_DIR)/inner_api/host/shared \
88+             $(HDF_ROOT_DIR)/inner_api/core \
89+             $(HDF_ROOT_DIR)/khdf/osal/include \
90+             -I../../../../../third_party/FreeBSD/sys/dev/evdev
91 hid-y			:= hid-core.o hid-input.o hid-quirks.o
92 hid-$(CONFIG_DEBUG_FS)		+= hid-debug.o
93
94diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
95index bde5cef32..1cf2e9b9c 100644
96--- a/drivers/hid/hid-core.c
97+++ b/drivers/hid/hid-core.c
98@@ -36,6 +36,9 @@
99 #include <linux/hid-debug.h>
100 #include <linux/hidraw.h>
101
102+#if defined(CONFIG_DRIVERS_HDF_INPUT)
103+#include "hdf_hid_adapter.h"
104+#endif
105 #include "hid-ids.h"
106
107 /*
108@@ -1340,6 +1343,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field,
109 		hidinput_hid_event(hid, field, usage, value);
110 	if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
111 		hid->hiddev_hid_event(hid, field, usage, value);
112+#if defined(CONFIG_DRIVERS_HDF_INPUT)
113+	if (hid->input_dev) {
114+		HidReportEvent(hid->input_dev, usage->type, usage->code, value);
115+	}
116+#endif
117 }
118
119 /*
120@@ -1743,6 +1751,81 @@ static const struct device_attribute dev_attr_country = {
121 	.show = show_country,
122 };
123
124+#if defined(CONFIG_DRIVERS_HDF_INPUT)
125+static bool check_mouse(char *name)
126+{
127+	static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"};
128+	for (int i = 0; i < 4; i++) {
129+		if (strstr(name, option[i]))
130+			return true;
131+	}
132+	return false;
133+}
134+static bool check_kbd(char *name)
135+{
136+	static char *option[]={"Keyboard", "keyboard"};
137+	for (int i = 0; i < 2; i++) {
138+		if (strstr(name, option[i]))
139+			return true;
140+	}
141+	return false;
142+}
143+static bool check_rocker(char *name)
144+{
145+	static char *option[]={"Thrustmaster"};
146+	for (int i = 0; i < 1; i++) {
147+		if (strstr(name, option[i]))
148+			return true;
149+	}
150+	return false;
151+}
152+static bool check_encoder(char *name)
153+{
154+	if (strcmp(name, "Wired KeyBoard") == 0) {
155+		return true;
156+	}
157+	return false;
158+}
159+static bool check_trackball(char *name)
160+{
161+	static char *option[]={"Trackball"};
162+	for (int i = 0; i < 1; i++) {
163+		if (strstr(name, option[i]))
164+			return true;
165+	}
166+	return false;
167+}
168+static void notify_connect_event(struct hid_device *hdev)
169+{
170+	bool check;
171+	int type = -1;
172+	HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL);
173+	if (dev == NULL) {
174+		printk("%s: malloc failed", __func__);
175+		return;
176+	}
177+	type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type;
178+	type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type;
179+	type = check_rocker(hdev->name)?HID_TYPE_ROCKER:type;
180+	type = check_encoder(hdev->name)?HID_TYPE_ENCODER:type;
181+	type = check_trackball(hdev->name)?HID_TYPE_TRACKBALL:type;
182+	if ( type < 0) {
183+		kfree(dev);
184+		dev = NULL;
185+		return;
186+	}
187+
188+	dev->devType = type;
189+	dev->devName = hdev->name;
190+	hdev->input_dev = HidRegisterHdfInputDev(dev);
191+	if (hdev->input_dev == NULL) {
192+		printk("%s: RegisterInputDevice failed\n", __func__);
193+	}
194+	kfree(dev);
195+	dev = NULL;
196+}
197+#endif
198+
199 int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
200 {
201 	static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
202@@ -1832,6 +1915,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
203 	hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
204 		 buf, bus, hdev->version >> 8, hdev->version & 0xff,
205 		 type, hdev->name, hdev->phys);
206+#if defined(CONFIG_DRIVERS_HDF_INPUT)
207+	notify_connect_event(hdev);
208+#endif
209
210 	return 0;
211 }
212@@ -1847,6 +1933,10 @@ void hid_disconnect(struct hid_device *hdev)
213 	if (hdev->claimed & HID_CLAIMED_HIDRAW)
214 		hidraw_disconnect(hdev);
215 	hdev->claimed = 0;
216+#if defined(CONFIG_DRIVERS_HDF_INPUT)
217+	if (hdev->input_dev)
218+		HidUnregisterHdfInputDev(hdev->input_dev);
219+#endif
220 }
221 EXPORT_SYMBOL_GPL(hid_disconnect);
222
223@@ -1931,6 +2021,11 @@ EXPORT_SYMBOL_GPL(hid_hw_open);
224  */
225 void hid_hw_close(struct hid_device *hdev)
226 {
227+#if defined(CONFIG_DRIVERS_HDF_INPUT)
228+	if (hdev->input_dev) {
229+		return;
230+	}
231+#endif
232 	mutex_lock(&hdev->ll_open_lock);
233 	if (!--hdev->ll_open_count)
234 		hdev->ll_driver->close(hdev);
235diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
236index 11bd2ca22..a5d0d6c19 100644
237--- a/drivers/hid/hid-input.c
238+++ b/drivers/hid/hid-input.c
239@@ -32,6 +32,10 @@
240 #include <linux/hid.h>
241 #include <linux/hid-debug.h>
242
243+#if defined(CONFIG_DRIVERS_HDF_INPUT)
244+#include "hdf_hid_adapter.h"
245+#endif
246+
247 #include "hid-ids.h"
248
249 #define unk	KEY_UNKNOWN
250@@ -1365,7 +1369,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report)
251 		return;
252
253 	list_for_each_entry(hidinput, &hid->inputs, list)
254+#if defined(CONFIG_DRIVERS_HDF_INPUT)
255+	{
256+#endif
257 		input_sync(hidinput->input);
258+#if defined(CONFIG_DRIVERS_HDF_INPUT)
259+		if(hid->input_dev)
260+			HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0);
261+	}
262+#endif
263 }
264 EXPORT_SYMBOL_GPL(hidinput_report_event);
265
266@@ -1729,6 +1741,41 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput,
267 						 report->field[i]->usage + j);
268 }
269
270+#if defined(CONFIG_DRIVERS_HDF_INPUT)
271+static void transfer_info(struct input_dev *dev)
272+{
273+	HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL);
274+	if (info == NULL) {
275+		printk("%s: malloc failed\n",__func__);
276+		return;
277+	}
278+	info->devName = dev->name;
279+	memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT));
280+	memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT));
281+	memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT));
282+	memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT));
283+	memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT));
284+	memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT));
285+	memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT));
286+	memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT));
287+	memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT));
288+	memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT));
289+	for (int i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) {
290+        if (dev->absbit[i] != 0) {
291+            memcpy(info->axisInfo, dev->absinfo, sizeof(struct input_absinfo) * ABS_CNT);
292+            break;
293+        }
294+    }
295+	info->bustype = dev->id.bustype;
296+	info->vendor = dev->id.vendor;
297+	info->product = dev->id.product;
298+	info->version = dev->id.version;
299+	SendInfoToHdf(info);
300+	kfree(info);
301+	info = NULL;
302+}
303+#endif
304+
305 /*
306  * Register the input device; print a message.
307  * Configure the input layer interface
308@@ -1811,7 +1858,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
309 			hidinput_cleanup_hidinput(hid, hidinput);
310 			continue;
311 		}
312-
313+#if defined(CONFIG_DRIVERS_HDF_INPUT)
314+		transfer_info(hidinput->input);
315+#endif
316 		if (input_register_device(hidinput->input))
317 			goto out_unwind;
318 		hidinput->registered = true;
319diff --git a/include/linux/hid.h b/include/linux/hid.h
320index a46b6832b..c61a17de5 100644
321--- a/include/linux/hid.h
322+++ b/include/linux/hid.h
323@@ -621,6 +621,7 @@ struct hid_device {							/* device report descriptor */
324 	struct list_head debug_list;
325 	spinlock_t  debug_list_lock;
326 	wait_queue_head_t debug_wait;
327+	void *input_dev;
328 };
329
330 #define to_hid_device(pdev) \
331--
3322.25.1
333
334