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