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/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S 22index 8af654bd1..1e9ff41d6 100644 23--- a/arch/arm/kernel/vmlinux.lds.S 24+++ b/arch/arm/kernel/vmlinux.lds.S 25@@ -131,6 +131,14 @@ SECTIONS 26 __pv_table_end = .; 27 } 28 29+#ifdef CONFIG_DRIVERS_HDF 30+ .init.hdf_table : { 31+ _hdf_drivers_start = .; 32+ *(.hdf.driver) 33+ _hdf_drivers_end = .; 34+ } 35+#endif 36+ 37 INIT_DATA_SECTION(16) 38 39 .exit.data : { 40diff --git a/drivers/Kconfig b/drivers/Kconfig 41index dcecc9f6e..8eddfc2cd 100644 42--- a/drivers/Kconfig 43+++ b/drivers/Kconfig 44@@ -234,5 +234,7 @@ source "drivers/interconnect/Kconfig" 45 46 source "drivers/counter/Kconfig" 47 48+source "drivers/hdf/khdf/Kconfig" 49+ 50 source "drivers/most/Kconfig" 51 endmenu 52diff --git a/drivers/Makefile b/drivers/Makefile 53index 576228037..025b92b1f 100644 54--- a/drivers/Makefile 55+++ b/drivers/Makefile 56@@ -188,4 +188,5 @@ obj-$(CONFIG_SIOX) += siox/ 57 obj-$(CONFIG_GNSS) += gnss/ 58 obj-$(CONFIG_INTERCONNECT) += interconnect/ 59 obj-$(CONFIG_COUNTER) += counter/ 60+obj-$(CONFIG_DRIVERS_HDF) += hdf/ 61 obj-$(CONFIG_MOST) += most/ 62diff --git a/drivers/hdf/Makefile b/drivers/hdf/Makefile 63new file mode 100644 64index 000000000..5c5e1911c 65--- /dev/null 66+++ b/drivers/hdf/Makefile 67@@ -0,0 +1,2 @@ 68+export PROJECT_ROOT := ../../../../../ 69+obj-$(CONFIG_DRIVERS_HDF) += khdf/ 70-- 712.25.1 72diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile 73index 4acb583c9..ddcaf4cdc 100644 74--- a/drivers/hid/Makefile 75+++ b/drivers/hid/Makefile 76@@ -2,6 +2,19 @@ 77 # 78 # Makefile for the HID driver 79 # 80+HDF_ROOT_DIR = -I$(srctree)/drivers/hdf 81+ccflags-$(CONFIG_DRIVERS_HDF_INPUT) += $(HDF_ROOT_DIR)/framework/model/input/driver \ 82+ $(HDF_ROOT_DIR)/framework/include/core \ 83+ $(HDF_ROOT_DIR)/framework/core/common/include/host \ 84+ $(HDF_ROOT_DIR)/framework/include/utils \ 85+ $(HDF_ROOT_DIR)/framework/include/osal \ 86+ $(HDF_ROOT_DIR)/framework/ability/sbuf/include \ 87+ $(HDF_ROOT_DIR)/inner_api/utils \ 88+ $(HDF_ROOT_DIR)/inner_api/osal/shared \ 89+ $(HDF_ROOT_DIR)/inner_api/core \ 90+ $(HDF_ROOT_DIR)/inner_api/host/shared \ 91+ $(HDF_ROOT_DIR)/khdf/osal/include \ 92+ $(HDF_ROOT_DIR)/evdev 93 hid-y := hid-core.o hid-input.o hid-quirks.o 94 hid-$(CONFIG_DEBUG_FS) += hid-debug.o 95 96diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c 97index 5550c943f..79df97fab 100644 98--- a/drivers/hid/hid-core.c 99+++ b/drivers/hid/hid-core.c 100@@ -33,6 +33,9 @@ 101 #include <linux/hid-debug.h> 102 #include <linux/hidraw.h> 103 104+#if defined(CONFIG_DRIVERS_HDF_INPUT) 105+#include "hdf_hid_adapter.h" 106+#endif 107 #include "hid-ids.h" 108 109 /* 110@@ -1522,6 +1525,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, 111 hidinput_hid_event(hid, field, usage, value); 112 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 113 hid->hiddev_hid_event(hid, field, usage, value); 114+#if defined(CONFIG_DRIVERS_HDF_INPUT) 115+ if (hid->input_dev) { 116+ HidReportEvent(hid->input_dev, usage->type, usage->code, value); 117+ } 118+#endif 119 } 120 121 /* 122@@ -1928,6 +1936,81 @@ static const struct device_attribute dev_attr_country = { 123 .show = show_country, 124 }; 125 126+#if defined(CONFIG_DRIVERS_HDF_INPUT) 127+static bool check_mouse(char *name) 128+{ 129+ static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"}; 130+ for (int i = 0; i < 4; i++) { 131+ if (strstr(name, option[i])) 132+ return true; 133+ } 134+ return false; 135+} 136+static bool check_kbd(char *name) 137+{ 138+ static char *option[]={"Keyboard", "keyboard"}; 139+ for (int i = 0; i < 2; i++) { 140+ if (strstr(name, option[i])) 141+ return true; 142+ } 143+ return false; 144+} 145+static bool check_rocker(char *name) 146+{ 147+ static char *option[]={"Thrustmaster"}; 148+ for (int i = 0; i < 1; i++) { 149+ if (strstr(name, option[i])) 150+ return true; 151+ } 152+ return false; 153+} 154+static bool check_encoder(char *name) 155+{ 156+ if (strcmp(name, "Wired KeyBoard") == 0) { 157+ return true; 158+ } 159+ return false; 160+} 161+static bool check_trackball(char *name) 162+{ 163+ static char *option[]={"Trackball"}; 164+ for (int i = 0; i < 1; i++) { 165+ if (strstr(name, option[i])) 166+ return true; 167+ } 168+ return false; 169+} 170+static void notify_connect_event(struct hid_device *hdev) 171+{ 172+ bool check; 173+ int type = -1; 174+ HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL); 175+ if (dev == NULL) { 176+ printk("%s: malloc failed", __func__); 177+ return; 178+ } 179+ type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type; 180+ type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type; 181+ type = check_rocker(hdev->name)?HID_TYPE_ROCKER:type; 182+ type = check_encoder(hdev->name)?HID_TYPE_ENCODER:type; 183+ type = check_trackball(hdev->name)?HID_TYPE_TRACKBALL:type; 184+ if ( type < 0) { 185+ kfree(dev); 186+ dev = NULL; 187+ return; 188+ } 189+ 190+ dev->devType = type; 191+ dev->devName = hdev->name; 192+ hdev->input_dev = HidRegisterHdfInputDev(dev); 193+ if (hdev->input_dev == NULL) { 194+ printk("%s: RegisterInputDevice failed\n", __func__); 195+ } 196+ kfree(dev); 197+ dev = NULL; 198+} 199+#endif 200+ 201 int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 202 { 203 static const char *types[] = { "Device", "Pointer", "Mouse", "Device", 204@@ -2020,6 +2103,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 205 hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", 206 buf, bus, hdev->version >> 8, hdev->version & 0xff, 207 type, hdev->name, hdev->phys); 208+#if defined(CONFIG_DRIVERS_HDF_INPUT) 209+ notify_connect_event(hdev); 210+#endif 211 212 return 0; 213 } 214@@ -2035,6 +2121,10 @@ void hid_disconnect(struct hid_device *hdev) 215 if (hdev->claimed & HID_CLAIMED_HIDRAW) 216 hidraw_disconnect(hdev); 217 hdev->claimed = 0; 218+#if defined(CONFIG_DRIVERS_HDF_INPUT) 219+ if (hdev->input_dev) 220+ HidUnregisterHdfInputDev(hdev->input_dev); 221+#endif 222 } 223 EXPORT_SYMBOL_GPL(hid_disconnect); 224 225@@ -2119,6 +2209,11 @@ EXPORT_SYMBOL_GPL(hid_hw_open); 226 */ 227 void hid_hw_close(struct hid_device *hdev) 228 { 229+#if defined(CONFIG_DRIVERS_HDF_INPUT) 230+ if (hdev->input_dev) { 231+ return; 232+ } 233+#endif 234 mutex_lock(&hdev->ll_open_lock); 235 if (!--hdev->ll_open_count) 236 hdev->ll_driver->close(hdev); 237diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c 238index d1ab2dccf..5354f0153 100644 239--- a/drivers/hid/hid-input.c 240+++ b/drivers/hid/hid-input.c 241@@ -20,6 +20,10 @@ 242 #include <linux/hid.h> 243 #include <linux/hid-debug.h> 244 245+#if defined(CONFIG_DRIVERS_HDF_INPUT) 246+#include "hdf_hid_adapter.h" 247+#endif 248+ 249 #include "hid-ids.h" 250 251 #define unk KEY_UNKNOWN 252@@ -1418,7 +1422,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report) 253 return; 254 255 list_for_each_entry(hidinput, &hid->inputs, list) 256+#if defined(CONFIG_DRIVERS_HDF_INPUT) 257+ { 258+#endif 259 input_sync(hidinput->input); 260+#if defined(CONFIG_DRIVERS_HDF_INPUT) 261+ if(hid->input_dev) 262+ HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0); 263+ } 264+#endif 265 } 266 EXPORT_SYMBOL_GPL(hidinput_report_event); 267 268@@ -1869,6 +1881,41 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput, 269 report->field[i]->usage + j); 270 } 271 272+#if defined(CONFIG_DRIVERS_HDF_INPUT) 273+static void transfer_info(struct input_dev *dev) 274+{ 275+ HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL); 276+ if (info == NULL) { 277+ printk("%s: malloc failed\n",__func__); 278+ return; 279+ } 280+ info->devName = dev->name; 281+ memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT)); 282+ memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT)); 283+ memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT)); 284+ memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT)); 285+ memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT)); 286+ memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT)); 287+ memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT)); 288+ memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT)); 289+ memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT)); 290+ memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT)); 291+ for (int i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) { 292+ if (dev->absbit[i] != 0) { 293+ memcpy(info->axisInfo, dev->absinfo, sizeof(struct input_absinfo) * ABS_CNT); 294+ break; 295+ } 296+ } 297+ info->bustype = dev->id.bustype; 298+ info->vendor = dev->id.vendor; 299+ info->product = dev->id.product; 300+ info->version = dev->id.version; 301+ SendInfoToHdf(info); 302+ kfree(info); 303+ info = NULL; 304+} 305+#endif 306+ 307 /* 308 * Register the input device; print a message. 309 * Configure the input layer interface 310@@ -1954,6 +2001,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) 311 continue; 312 } 313 314+#if defined(CONFIG_DRIVERS_HDF_INPUT) 315+ transfer_info(hidinput->input); 316+#endif 317 if (input_register_device(hidinput->input)) 318 goto out_unwind; 319 hidinput->registered = true; 320diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c 321index 505c562a5..67d451beb 100644 322--- a/drivers/input/mousedev.c 323+++ b/drivers/input/mousedev.c 324@@ -869,7 +869,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev, 325 326 if (mixdev) { 327 dev_set_name(&mousedev->dev, "mice"); 328- 329+ mousedev->open = 1; 330 mousedev->open_device = mixdev_open_devices; 331 mousedev->close_device = mixdev_close_devices; 332 } else { 333diff --git a/include/linux/hid.h b/include/linux/hid.h 334index 6ed2a97eb..1d1445a23 100644 335--- a/include/linux/hid.h 336+++ b/include/linux/hid.h 337@@ -624,6 +624,7 @@ struct hid_device { /* device report descriptor */ 338 struct list_head debug_list; 339 spinlock_t debug_list_lock; 340 wait_queue_head_t debug_wait; 341+ void *input_dev; 342 struct kref ref; 343 344 unsigned int id; /* system unique id */ 345 346