• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/Makefile b/Makefile
2index e5cb4a4f2..210b200c8 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -494,7 +494,7 @@ LINUXINCLUDE    := \
6 		$(USERINCLUDE)
7
8 KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
9-KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
10+KBUILD_CFLAGS   := -Wall -Wundef -Wno-trigraphs \
11 		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
12 		   -Werror=implicit-function-declaration -Werror=implicit-int \
13 		   -Werror=return-type -Wno-format-security \
14@@ -946,7 +946,7 @@ KBUILD_CFLAGS   += $(call cc-option,-fconserve-stack)
15 KBUILD_CFLAGS   += -Werror=date-time
16
17 # enforce correct pointer usage
18-KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
19+KBUILD_CFLAGS   += $(call cc-option,-Wno=incompatible-pointer-types)
20
21 # Require designated initializers for all marked structures
22 KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
23diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
24index 30c102978942..1d8b8de34f1c 100644
25--- a/arch/arm64/kernel/vmlinux.lds.S
26+++ b/arch/arm64/kernel/vmlinux.lds.S
27@@ -201,6 +201,15 @@ SECTIONS
28 		INIT_RAM_FS
29 		*(.init.rodata.* .init.bss)	/* from the EFI stub */
30 	}
31+
32+#ifdef CONFIG_DRIVERS_HDF
33+	.init.hdf_table : {
34+		_hdf_drivers_start = .;
35+		*(.hdf.driver)
36+		_hdf_drivers_end = .;
37+	}
38+#endif
39+
40 	.exit.data : {
41 		EXIT_DATA
42 	}
43diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
44index 485b7dbd4..ff0326c8c 100644
45--- a/arch/arm64/Makefile
46+++ b/arch/arm64/Makefile
47@@ -44,8 +44,7 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y)
48 $(warning Detected assembler with broken .inst; disassembly will be unreliable)
49 endif
50
51-KBUILD_CFLAGS	+= -mgeneral-regs-only	\
52-		   $(compat_vdso) $(cc_has_k_constraint)
53+KBUILD_CFLAGS	+= $(compat_vdso) $(cc_has_k_constraint)
54 KBUILD_CFLAGS	+= $(call cc-disable-warning, psabi)
55 KBUILD_AFLAGS	+= $(compat_vdso)
56
57diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
58index 8af654bd1..1e9ff41d6 100644
59--- a/arch/arm/kernel/vmlinux.lds.S
60+++ b/arch/arm/kernel/vmlinux.lds.S
61@@ -131,6 +131,14 @@ SECTIONS
62 		__pv_table_end = .;
63 	}
64
65+#ifdef CONFIG_DRIVERS_HDF
66+	.init.hdf_table : {
67+		_hdf_drivers_start = .;
68+		*(.hdf.driver)
69+		_hdf_drivers_end = .;
70+	}
71+#endif
72+
73 	INIT_DATA_SECTION(16)
74
75 	.exit.data : {
76diff --git a/drivers/Kconfig b/drivers/Kconfig
77index 826b2b19d0b8..9a887e91b375 100644
78--- a/drivers/Kconfig
79+++ b/drivers/Kconfig
80@@ -236,6 +236,8 @@ source "drivers/interconnect/Kconfig"
81
82 source "drivers/counter/Kconfig"
83
84+source "drivers/hdf/khdf/Kconfig"
85+
86 source "drivers/most/Kconfig"
87
88 source "drivers/accesstokenid/Kconfig"
89diff --git a/drivers/Makefile b/drivers/Makefile
90index ecc494918773..79507aef0c21 100644
91--- a/drivers/Makefile
92+++ b/drivers/Makefile
93@@ -191,5 +191,6 @@ obj-$(CONFIG_SIOX)		+= siox/
94 obj-$(CONFIG_GNSS)		+= gnss/
95 obj-$(CONFIG_INTERCONNECT)	+= interconnect/
96 obj-$(CONFIG_COUNTER)		+= counter/
97+obj-$(CONFIG_DRIVERS_HDF)	+= hdf/
98 obj-$(CONFIG_MOST)		+= most/
99 obj-$(CONFIG_ACCESS_TOKENID)	+= accesstokenid/
100diff --git a/drivers/hdf/Makefile b/drivers/hdf/Makefile
101new file mode 100644
102index 000000000000..5c5e1911c4f7
103--- /dev/null
104+++ b/drivers/hdf/Makefile
105@@ -0,0 +1,2 @@
106+export PROJECT_ROOT := ../../../../../
107+obj-$(CONFIG_DRIVERS_HDF) += khdf/
108diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
109index 4acb583c92a6..ddcaf4cdcb9c 100644
110--- a/drivers/hid/Makefile
111+++ b/drivers/hid/Makefile
112@@ -2,6 +2,15 @@
113 #
114 # Makefile for the HID driver
115 #
116+HDF_ROOT_DIR = -I$(srctree)/drivers/hdf
117+ccflags-$(CONFIG_DRIVERS_HDF_INPUT) += $(HDF_ROOT_DIR)/framework/model/input/driver \
118+             $(HDF_ROOT_DIR)/framework/include/core \
119+             $(HDF_ROOT_DIR)/framework/core/common/include/host \
120+             $(HDF_ROOT_DIR)/framework/include/utils \
121+             $(HDF_ROOT_DIR)/framework/include/osal \
122+             $(HDF_ROOT_DIR)/framework/ability/sbuf/include \
123+             $(HDF_ROOT_DIR)/khdf/osal/include \
124+             $(HDF_ROOT_DIR)/evdev
125 hid-y			:= hid-core.o hid-input.o hid-quirks.o
126 hid-$(CONFIG_DEBUG_FS)		+= hid-debug.o
127
128diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
129index 5550c943f985..f0503e2327a3 100644
130--- a/drivers/hid/hid-core.c
131+++ b/drivers/hid/hid-core.c
132@@ -33,6 +33,9 @@
133 #include <linux/hid-debug.h>
134 #include <linux/hidraw.h>
135
136+#if defined(CONFIG_DRIVERS_HDF_INPUT)
137+#include "hdf_hid_adapter.h"
138+#endif
139 #include "hid-ids.h"
140
141 /*
142@@ -1522,6 +1525,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field,
143 		hidinput_hid_event(hid, field, usage, value);
144 	if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
145 		hid->hiddev_hid_event(hid, field, usage, value);
146+#if defined(CONFIG_DRIVERS_HDF_INPUT)
147+	if (hid->input_dev) {
148+		HidReportEvent(hid->input_dev, usage->type, usage->code, value);
149+	}
150+#endif
151 }
152
153 /*
154@@ -1928,6 +1936,85 @@ static const struct device_attribute dev_attr_country = {
155 	.show = show_country,
156 };
157
158+#if defined(CONFIG_DRIVERS_HDF_INPUT)
159+static bool check_mouse(char *name)
160+{
161+	int i;
162+	static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"};
163+	for (i = 0; i < 4; i++) {
164+		if (strstr(name, option[i]))
165+			return true;
166+	}
167+	return false;
168+}
169+static bool check_kbd(char *name)
170+{
171+	int i;
172+	static char *option[]={"Keyboard", "keyboard"};
173+	for (i = 0; i < 2; i++) {
174+		if (strstr(name, option[i]))
175+			return true;
176+	}
177+	return false;
178+}
179+static bool check_rocker(char *name)
180+{
181+	int i;
182+	static char *option[]={"Thrustmaster"};
183+	for (i = 0; i < 1; i++) {
184+		if (strstr(name, option[i]))
185+			return true;
186+	}
187+	return false;
188+}
189+static bool check_encoder(char *name)
190+{
191+	if (strcmp(name, "Wired KeyBoard") == 0) {
192+		return true;
193+	}
194+	return false;
195+}
196+static bool check_trackball(char *name)
197+{
198+	int i;
199+	static char *option[]={"Trackball"};
200+	for (i = 0; i < 1; i++) {
201+		if (strstr(name, option[i]))
202+			return true;
203+	}
204+	return false;
205+}
206+static void notify_connect_event(struct hid_device *hdev)
207+{
208+	bool check;
209+	int type = -1;
210+	HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL);
211+	if (dev == NULL) {
212+		printk("%s: malloc failed", __func__);
213+		return;
214+	}
215+	type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type;
216+	type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type;
217+	type = check_rocker(hdev->name)?HID_TYPE_ROCKER:type;
218+	type = check_encoder(hdev->name)?HID_TYPE_ENCODER:type;
219+	type = check_trackball(hdev->name)?HID_TYPE_TRACKBALL:type;
220+	if ( type < 0) {
221+		kfree(dev);
222+		dev = NULL;
223+		return;
224+	}
225+
226+	dev->devType = type;
227+	dev->devName = hdev->name;
228+	hdev->input_dev = HidRegisterHdfInputDev(dev);
229+	if (hdev->input_dev == NULL) {
230+		printk("%s: RegisterInputDevice failed\n", __func__);
231+	}
232+	kfree(dev);
233+	dev = NULL;
234+}
235+#endif
236+
237 int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
238 {
239 	static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
240@@ -2020,6 +2107,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
241 	hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
242 		 buf, bus, hdev->version >> 8, hdev->version & 0xff,
243 		 type, hdev->name, hdev->phys);
244+#if defined(CONFIG_DRIVERS_HDF_INPUT)
245+	notify_connect_event(hdev);
246+#endif
247
248 	return 0;
249 }
250@@ -2035,6 +2125,10 @@ void hid_disconnect(struct hid_device *hdev)
251 	if (hdev->claimed & HID_CLAIMED_HIDRAW)
252 		hidraw_disconnect(hdev);
253 	hdev->claimed = 0;
254+#if defined(CONFIG_DRIVERS_HDF_INPUT)
255+	if (hdev->input_dev)
256+		HidUnregisterHdfInputDev(hdev->input_dev);
257+#endif
258 }
259 EXPORT_SYMBOL_GPL(hid_disconnect);
260
261@@ -2119,6 +2213,11 @@ EXPORT_SYMBOL_GPL(hid_hw_open);
262  */
263 void hid_hw_close(struct hid_device *hdev)
264 {
265+#if defined(CONFIG_DRIVERS_HDF_INPUT)
266+	if (hdev->input_dev) {
267+		return;
268+	}
269+#endif
270 	mutex_lock(&hdev->ll_open_lock);
271 	if (!--hdev->ll_open_count)
272 		hdev->ll_driver->close(hdev);
273diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
274index 580d378342c4..fb945f4ce1ff 100644
275--- a/drivers/hid/hid-input.c
276+++ b/drivers/hid/hid-input.c
277@@ -20,6 +20,10 @@
278 #include <linux/hid.h>
279 #include <linux/hid-debug.h>
280
281+#if defined(CONFIG_DRIVERS_HDF_INPUT)
282+#include "hdf_hid_adapter.h"
283+#endif
284+
285 #include "hid-ids.h"
286
287 #define unk	KEY_UNKNOWN
288@@ -1416,7 +1420,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report)
289 		return;
290
291 	list_for_each_entry(hidinput, &hid->inputs, list)
292+#if defined(CONFIG_DRIVERS_HDF_INPUT)
293+	{
294+#endif
295 		input_sync(hidinput->input);
296+#if defined(CONFIG_DRIVERS_HDF_INPUT)
297+		if(hid->input_dev)
298+			HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0);
299+	}
300+#endif
301 }
302 EXPORT_SYMBOL_GPL(hidinput_report_event);
303
304@@ -1867,6 +1879,42 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput,
305 						 report->field[i]->usage + j);
306 }
307
308+#if defined(CONFIG_DRIVERS_HDF_INPUT)
309+static void transfer_info(struct input_dev *dev)
310+{
311+	int i;
312+	HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL);
313+	if (info == NULL) {
314+		printk("%s: malloc failed\n",__func__);
315+		return;
316+	}
317+	info->devName = dev->name;
318+	memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT));
319+	memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT));
320+	memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT));
321+	memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT));
322+	memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT));
323+	memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT));
324+	memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT));
325+	memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT));
326+	memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT));
327+	memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT));
328+	for (i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) {
329+		if (dev->absbit[i] != 0) {
330+			memcpy(info->axisInfo, dev->absinfo, sizeof(struct input_absinfo) * ABS_CNT);
331+			break;
332+		}
333+	}
334+	info->bustype = dev->id.bustype;
335+	info->vendor = dev->id.vendor;
336+	info->product = dev->id.product;
337+	info->version = dev->id.version;
338+	SendInfoToHdf(info);
339+	kfree(info);
340+	info = NULL;
341+}
342+#endif
343+
344 /*
345  * Register the input device; print a message.
346  * Configure the input layer interface
347@@ -1952,6 +2000,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
348 			continue;
349 		}
350
351+#if defined(CONFIG_DRIVERS_HDF_INPUT)
352+		transfer_info(hidinput->input);
353+#endif
354 		if (input_register_device(hidinput->input))
355 			goto out_unwind;
356 		hidinput->registered = true;
357diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
358index a48e5f2d859d..90d25f2248b1 100644
359--- a/drivers/input/misc/Makefile
360+++ b/drivers/input/misc/Makefile
361@@ -85,3 +85,17 @@ obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND)	+= xen-kbdfront.o
362 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
363 obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR)	+= ideapad_slidebar.o
364
365+ccflags-y +=-Idrivers/hdf/framework/model/input/driver \
366+             -Idrivers/hdf/framework/model/input/driver/input_bus_ops \
367+             -Idrivers/hdf/framework/include/core \
368+             -Idrivers/hdf/framework/core/common/include/host \
369+             -Idrivers/hdf/framework/include/utils \
370+             -Idrivers/hdf/framework/include/osal \
371+             -Idrivers/hdf/framework/include/platform \
372+             -Idrivers/hdf/framework/include/config \
373+             -Idrivers/hdf/framework/core/host/include \
374+             -Idrivers/hdf/framework/core/shared/include \
375+             -Idrivers/hdf/framework/utils/include \
376+             -Idrivers/hdf/khdf/osal/include
377+ccflags-y +=-Ibounds_checking_function/include \
378+             -Idrivers/hdf/evdev
379diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
380index 505c562a5daa..67d451beba08 100644
381--- a/drivers/input/mousedev.c
382+++ b/drivers/input/mousedev.c
383@@ -869,7 +869,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev,
384
385 	if (mixdev) {
386 		dev_set_name(&mousedev->dev, "mice");
387-
388+		mousedev->open = 1;
389 		mousedev->open_device = mixdev_open_devices;
390 		mousedev->close_device = mixdev_close_devices;
391 	} else {
392diff --git a/include/linux/hid.h b/include/linux/hid.h
393index 6ed2a97eb55f..1d1445a23967 100644
394--- a/include/linux/hid.h
395+++ b/include/linux/hid.h
396@@ -622,6 +622,7 @@ struct hid_device {							/* device report descriptor */
397 	struct list_head debug_list;
398 	spinlock_t  debug_list_lock;
399 	wait_queue_head_t debug_wait;
400+	void *input_dev;
401 };
402
403 #define to_hid_device(pdev) \
404