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,19 @@ 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)/inner_api/utils \ 124+ $(HDF_ROOT_DIR)/inner_api/osal/shared \ 125+ $(HDF_ROOT_DIR)/inner_api/host/shared \ 126+ $(HDF_ROOT_DIR)/inner_api/core \ 127+ $(HDF_ROOT_DIR)/khdf/osal/include \ 128+ $(HDF_ROOT_DIR)/evdev 129 hid-y := hid-core.o hid-input.o hid-quirks.o 130 hid-$(CONFIG_DEBUG_FS) += hid-debug.o 131 132diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c 133index 5550c943f985..f0503e2327a3 100644 134--- a/drivers/hid/hid-core.c 135+++ b/drivers/hid/hid-core.c 136@@ -33,6 +33,9 @@ 137 #include <linux/hid-debug.h> 138 #include <linux/hidraw.h> 139 140+#if defined(CONFIG_DRIVERS_HDF_INPUT) 141+#include "hdf_hid_adapter.h" 142+#endif 143 #include "hid-ids.h" 144 145 /* 146@@ -1522,6 +1525,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, 147 hidinput_hid_event(hid, field, usage, value); 148 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 149 hid->hiddev_hid_event(hid, field, usage, value); 150+#if defined(CONFIG_DRIVERS_HDF_INPUT) 151+ if (hid->input_dev) { 152+ HidReportEvent(hid->input_dev, usage->type, usage->code, value); 153+ } 154+#endif 155 } 156 157 /* 158@@ -1928,6 +1936,85 @@ static const struct device_attribute dev_attr_country = { 159 .show = show_country, 160 }; 161 162+#if defined(CONFIG_DRIVERS_HDF_INPUT) 163+static bool check_mouse(char *name) 164+{ 165+ int i; 166+ static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"}; 167+ for (i = 0; i < 4; i++) { 168+ if (strstr(name, option[i])) 169+ return true; 170+ } 171+ return false; 172+} 173+static bool check_kbd(char *name) 174+{ 175+ int i; 176+ static char *option[]={"Keyboard", "keyboard"}; 177+ for (i = 0; i < 2; i++) { 178+ if (strstr(name, option[i])) 179+ return true; 180+ } 181+ return false; 182+} 183+static bool check_rocker(char *name) 184+{ 185+ int i; 186+ static char *option[]={"Thrustmaster"}; 187+ for (i = 0; i < 1; i++) { 188+ if (strstr(name, option[i])) 189+ return true; 190+ } 191+ return false; 192+} 193+static bool check_encoder(char *name) 194+{ 195+ if (strcmp(name, "Wired KeyBoard") == 0) { 196+ return true; 197+ } 198+ return false; 199+} 200+static bool check_trackball(char *name) 201+{ 202+ int i; 203+ static char *option[]={"Trackball"}; 204+ for (i = 0; i < 1; i++) { 205+ if (strstr(name, option[i])) 206+ return true; 207+ } 208+ return false; 209+} 210+static void notify_connect_event(struct hid_device *hdev) 211+{ 212+ bool check; 213+ int type = -1; 214+ HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL); 215+ if (dev == NULL) { 216+ printk("%s: malloc failed", __func__); 217+ return; 218+ } 219+ type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type; 220+ type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type; 221+ type = check_rocker(hdev->name)?HID_TYPE_ROCKER:type; 222+ type = check_encoder(hdev->name)?HID_TYPE_ENCODER:type; 223+ type = check_trackball(hdev->name)?HID_TYPE_TRACKBALL:type; 224+ if ( type < 0) { 225+ kfree(dev); 226+ dev = NULL; 227+ return; 228+ } 229+ 230+ dev->devType = type; 231+ dev->devName = hdev->name; 232+ hdev->input_dev = HidRegisterHdfInputDev(dev); 233+ if (hdev->input_dev == NULL) { 234+ printk("%s: RegisterInputDevice failed\n", __func__); 235+ } 236+ kfree(dev); 237+ dev = NULL; 238+} 239+#endif 240+ 241 int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 242 { 243 static const char *types[] = { "Device", "Pointer", "Mouse", "Device", 244@@ -2020,6 +2107,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 245 hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", 246 buf, bus, hdev->version >> 8, hdev->version & 0xff, 247 type, hdev->name, hdev->phys); 248+#if defined(CONFIG_DRIVERS_HDF_INPUT) 249+ notify_connect_event(hdev); 250+#endif 251 252 return 0; 253 } 254@@ -2035,6 +2125,10 @@ void hid_disconnect(struct hid_device *hdev) 255 if (hdev->claimed & HID_CLAIMED_HIDRAW) 256 hidraw_disconnect(hdev); 257 hdev->claimed = 0; 258+#if defined(CONFIG_DRIVERS_HDF_INPUT) 259+ if (hdev->input_dev) 260+ HidUnregisterHdfInputDev(hdev->input_dev); 261+#endif 262 } 263 EXPORT_SYMBOL_GPL(hid_disconnect); 264 265@@ -2119,6 +2213,11 @@ EXPORT_SYMBOL_GPL(hid_hw_open); 266 */ 267 void hid_hw_close(struct hid_device *hdev) 268 { 269+#if defined(CONFIG_DRIVERS_HDF_INPUT) 270+ if (hdev->input_dev) { 271+ return; 272+ } 273+#endif 274 mutex_lock(&hdev->ll_open_lock); 275 if (!--hdev->ll_open_count) 276 hdev->ll_driver->close(hdev); 277diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c 278index 580d378342c4..fb945f4ce1ff 100644 279--- a/drivers/hid/hid-input.c 280+++ b/drivers/hid/hid-input.c 281@@ -20,6 +20,10 @@ 282 #include <linux/hid.h> 283 #include <linux/hid-debug.h> 284 285+#if defined(CONFIG_DRIVERS_HDF_INPUT) 286+#include "hdf_hid_adapter.h" 287+#endif 288+ 289 #include "hid-ids.h" 290 291 #define unk KEY_UNKNOWN 292@@ -1416,7 +1420,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report) 293 return; 294 295 list_for_each_entry(hidinput, &hid->inputs, list) 296+#if defined(CONFIG_DRIVERS_HDF_INPUT) 297+ { 298+#endif 299 input_sync(hidinput->input); 300+#if defined(CONFIG_DRIVERS_HDF_INPUT) 301+ if(hid->input_dev) 302+ HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0); 303+ } 304+#endif 305 } 306 EXPORT_SYMBOL_GPL(hidinput_report_event); 307 308@@ -1867,6 +1879,42 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput, 309 report->field[i]->usage + j); 310 } 311 312+#if defined(CONFIG_DRIVERS_HDF_INPUT) 313+static void transfer_info(struct input_dev *dev) 314+{ 315+ int i; 316+ HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL); 317+ if (info == NULL) { 318+ printk("%s: malloc failed\n",__func__); 319+ return; 320+ } 321+ info->devName = dev->name; 322+ memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT)); 323+ memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT)); 324+ memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT)); 325+ memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT)); 326+ memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT)); 327+ memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT)); 328+ memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT)); 329+ memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT)); 330+ memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT)); 331+ memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT)); 332+ for (i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) { 333+ if (dev->absbit[i] != 0) { 334+ memcpy(info->axisInfo, dev->absinfo, sizeof(struct input_absinfo) * ABS_CNT); 335+ break; 336+ } 337+ } 338+ info->bustype = dev->id.bustype; 339+ info->vendor = dev->id.vendor; 340+ info->product = dev->id.product; 341+ info->version = dev->id.version; 342+ SendInfoToHdf(info); 343+ kfree(info); 344+ info = NULL; 345+} 346+#endif 347+ 348 /* 349 * Register the input device; print a message. 350 * Configure the input layer interface 351@@ -1952,6 +2000,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) 352 continue; 353 } 354 355+#if defined(CONFIG_DRIVERS_HDF_INPUT) 356+ transfer_info(hidinput->input); 357+#endif 358 if (input_register_device(hidinput->input)) 359 goto out_unwind; 360 hidinput->registered = true; 361diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile 362index a48e5f2d859d..90d25f2248b1 100644 363--- a/drivers/input/misc/Makefile 364+++ b/drivers/input/misc/Makefile 365@@ -85,3 +85,17 @@ obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o 366 obj-$(CONFIG_INPUT_YEALINK) += yealink.o 367 obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR) += ideapad_slidebar.o 368 369+ccflags-y +=-Idrivers/hdf/framework/model/input/driver \ 370+ -Idrivers/hdf/framework/model/input/driver/input_bus_ops \ 371+ -Idrivers/hdf/framework/include/core \ 372+ -Idrivers/hdf/framework/core/common/include/host \ 373+ -Idrivers/hdf/framework/include/utils \ 374+ -Idrivers/hdf/framework/include/osal \ 375+ -Idrivers/hdf/framework/include/platform \ 376+ -Idrivers/hdf/framework/include/config \ 377+ -Idrivers/hdf/framework/core/host/include \ 378+ -Idrivers/hdf/framework/core/shared/include \ 379+ -Idrivers/hdf/framework/utils/include \ 380+ -Idrivers/hdf/khdf/osal/include 381+ccflags-y +=-Ibounds_checking_function/include \ 382+ -Idrivers/hdf/evdev 383diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c 384index 505c562a5daa..67d451beba08 100644 385--- a/drivers/input/mousedev.c 386+++ b/drivers/input/mousedev.c 387@@ -869,7 +869,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev, 388 389 if (mixdev) { 390 dev_set_name(&mousedev->dev, "mice"); 391- 392+ mousedev->open = 1; 393 mousedev->open_device = mixdev_open_devices; 394 mousedev->close_device = mixdev_close_devices; 395 } else { 396diff --git a/include/linux/hid.h b/include/linux/hid.h 397index 6ed2a97eb55f..1d1445a23967 100644 398--- a/include/linux/hid.h 399+++ b/include/linux/hid.h 400@@ -622,6 +622,7 @@ struct hid_device { /* device report descriptor */ 401 struct list_head debug_list; 402 spinlock_t debug_list_lock; 403 wait_queue_head_t debug_wait; 404+ void *input_dev; 405 }; 406 407 #define to_hid_device(pdev) \ 408