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