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