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 dcecc9f6e..8eddfc2cd 100644 23--- a/drivers/Kconfig 24+++ b/drivers/Kconfig 25@@ -234,5 +234,7 @@ source "drivers/interconnect/Kconfig" 26 27 source "drivers/counter/Kconfig" 28 29+source "drivers/hdf/khdf/Kconfig" 30+ 31 source "drivers/most/Kconfig" 32 endmenu 33diff --git a/drivers/Makefile b/drivers/Makefile 34index 576228037..025b92b1f 100644 35--- a/drivers/Makefile 36+++ b/drivers/Makefile 37@@ -188,4 +188,5 @@ obj-$(CONFIG_SIOX) += siox/ 38 obj-$(CONFIG_GNSS) += gnss/ 39 obj-$(CONFIG_INTERCONNECT) += interconnect/ 40 obj-$(CONFIG_COUNTER) += counter/ 41+obj-$(CONFIG_DRIVERS_HDF) += hdf/ 42 obj-$(CONFIG_MOST) += most/ 43diff --git a/drivers/hdf/Makefile b/drivers/hdf/Makefile 44new file mode 100644 45index 000000000..5c5e1911c 46--- /dev/null 47+++ b/drivers/hdf/Makefile 48@@ -0,0 +1,2 @@ 49+export PROJECT_ROOT := ../../../../../ 50+obj-$(CONFIG_DRIVERS_HDF) += khdf/ 51-- 522.25.1 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/core \ 71+ $(HDF_ROOT_DIR)/inner_api/host/shared \ 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..79df97fab 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,81 @@ 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+ static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"}; 111+ for (int i = 0; i < 4; i++) { 112+ if (strstr(name, option[i])) 113+ return true; 114+ } 115+ return false; 116+} 117+static bool check_kbd(char *name) 118+{ 119+ static char *option[]={"Keyboard", "keyboard"}; 120+ for (int i = 0; i < 2; i++) { 121+ if (strstr(name, option[i])) 122+ return true; 123+ } 124+ return false; 125+} 126+static bool check_rocker(char *name) 127+{ 128+ static char *option[]={"Thrustmaster"}; 129+ for (int 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+ static char *option[]={"Trackball"}; 145+ for (int i = 0; i < 1; i++) { 146+ if (strstr(name, option[i])) 147+ return true; 148+ } 149+ return false; 150+} 151+static void notify_connect_event(struct hid_device *hdev) 152+{ 153+ bool check; 154+ int type = -1; 155+ HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL); 156+ if (dev == NULL) { 157+ printk("%s: malloc failed", __func__); 158+ return; 159+ } 160+ type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type; 161+ type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type; 162+ type = check_rocker(hdev->name)?HID_TYPE_ROCKER:type; 163+ type = check_encoder(hdev->name)?HID_TYPE_ENCODER:type; 164+ type = check_trackball(hdev->name)?HID_TYPE_TRACKBALL:type; 165+ if ( type < 0) { 166+ kfree(dev); 167+ dev = NULL; 168+ return; 169+ } 170+ 171+ dev->devType = type; 172+ dev->devName = hdev->name; 173+ hdev->input_dev = HidRegisterHdfInputDev(dev); 174+ if (hdev->input_dev == NULL) { 175+ printk("%s: RegisterInputDevice failed\n", __func__); 176+ } 177+ kfree(dev); 178+ dev = NULL; 179+} 180+#endif 181+ 182 int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 183 { 184 static const char *types[] = { "Device", "Pointer", "Mouse", "Device", 185@@ -2020,6 +2103,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 186 hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", 187 buf, bus, hdev->version >> 8, hdev->version & 0xff, 188 type, hdev->name, hdev->phys); 189+#if defined(CONFIG_DRIVERS_HDF_INPUT) 190+ notify_connect_event(hdev); 191+#endif 192 193 return 0; 194 } 195@@ -2035,6 +2121,10 @@ void hid_disconnect(struct hid_device *hdev) 196 if (hdev->claimed & HID_CLAIMED_HIDRAW) 197 hidraw_disconnect(hdev); 198 hdev->claimed = 0; 199+#if defined(CONFIG_DRIVERS_HDF_INPUT) 200+ if (hdev->input_dev) 201+ HidUnregisterHdfInputDev(hdev->input_dev); 202+#endif 203 } 204 EXPORT_SYMBOL_GPL(hid_disconnect); 205 206@@ -2119,6 +2209,11 @@ EXPORT_SYMBOL_GPL(hid_hw_open); 207 */ 208 void hid_hw_close(struct hid_device *hdev) 209 { 210+#if defined(CONFIG_DRIVERS_HDF_INPUT) 211+ if (hdev->input_dev) { 212+ return; 213+ } 214+#endif 215 mutex_lock(&hdev->ll_open_lock); 216 if (!--hdev->ll_open_count) 217 hdev->ll_driver->close(hdev); 218diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c 219index d1ab2dccf..5354f0153 100644 220--- a/drivers/hid/hid-input.c 221+++ b/drivers/hid/hid-input.c 222@@ -20,6 +20,10 @@ 223 #include <linux/hid.h> 224 #include <linux/hid-debug.h> 225 226+#if defined(CONFIG_DRIVERS_HDF_INPUT) 227+#include "hdf_hid_adapter.h" 228+#endif 229+ 230 #include "hid-ids.h" 231 232 #define unk KEY_UNKNOWN 233@@ -1418,7 +1422,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report) 234 return; 235 236 list_for_each_entry(hidinput, &hid->inputs, list) 237+#if defined(CONFIG_DRIVERS_HDF_INPUT) 238+ { 239+#endif 240 input_sync(hidinput->input); 241+#if defined(CONFIG_DRIVERS_HDF_INPUT) 242+ if(hid->input_dev) 243+ HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0); 244+ } 245+#endif 246 } 247 EXPORT_SYMBOL_GPL(hidinput_report_event); 248 249@@ -1869,6 +1881,41 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput, 250 report->field[i]->usage + j); 251 } 252 253+#if defined(CONFIG_DRIVERS_HDF_INPUT) 254+static void transfer_info(struct input_dev *dev) 255+{ 256+ HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL); 257+ if (info == NULL) { 258+ printk("%s: malloc failed\n",__func__); 259+ return; 260+ } 261+ info->devName = dev->name; 262+ memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT)); 263+ memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT)); 264+ memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT)); 265+ memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT)); 266+ memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT)); 267+ memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT)); 268+ memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT)); 269+ memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT)); 270+ memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT)); 271+ memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT)); 272+ for (int i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) { 273+ if (dev->absbit[i] != 0) { 274+ memcpy(info->axisInfo, dev->absinfo, sizeof(struct input_absinfo) * ABS_CNT); 275+ break; 276+ } 277+ } 278+ info->bustype = dev->id.bustype; 279+ info->vendor = dev->id.vendor; 280+ info->product = dev->id.product; 281+ info->version = dev->id.version; 282+ SendInfoToHdf(info); 283+ kfree(info); 284+ info = NULL; 285+} 286+#endif 287+ 288 /* 289 * Register the input device; print a message. 290 * Configure the input layer interface 291@@ -1954,6 +2001,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) 292 continue; 293 } 294 295+#if defined(CONFIG_DRIVERS_HDF_INPUT) 296+ transfer_info(hidinput->input); 297+#endif 298 if (input_register_device(hidinput->input)) 299 goto out_unwind; 300 hidinput->registered = true; 301diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c 302index 505c562a5..67d451beb 100644 303--- a/drivers/input/mousedev.c 304+++ b/drivers/input/mousedev.c 305@@ -869,7 +869,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev, 306 307 if (mixdev) { 308 dev_set_name(&mousedev->dev, "mice"); 309- 310+ mousedev->open = 1; 311 mousedev->open_device = mixdev_open_devices; 312 mousedev->close_device = mixdev_close_devices; 313 } else { 314diff --git a/include/linux/hid.h b/include/linux/hid.h 315index 6ed2a97eb..1d1445a23 100644 316--- a/include/linux/hid.h 317+++ b/include/linux/hid.h 318@@ -622,6 +622,7 @@ struct hid_device { /* device report descriptor */ 319 struct list_head debug_list; 320 spinlock_t debug_list_lock; 321 wait_queue_head_t debug_wait; 322+ void *input_dev; 323 }; 324 325 #define to_hid_device(pdev) \ 326