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,15 @@ 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)/khdf/osal/include \ 69+ $(HDF_ROOT_DIR)/evdev 70 hid-y := hid-core.o hid-input.o hid-quirks.o 71 hid-$(CONFIG_DEBUG_FS) += hid-debug.o 72 73diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c 74index 5550c943f..79df97fab 100644 75--- a/drivers/hid/hid-core.c 76+++ b/drivers/hid/hid-core.c 77@@ -33,6 +33,9 @@ 78 #include <linux/hid-debug.h> 79 #include <linux/hidraw.h> 80 81+#if defined(CONFIG_DRIVERS_HDF_INPUT) 82+#include "hdf_hid_adapter.h" 83+#endif 84 #include "hid-ids.h" 85 86 /* 87@@ -1522,6 +1525,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, 88 hidinput_hid_event(hid, field, usage, value); 89 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 90 hid->hiddev_hid_event(hid, field, usage, value); 91+#if defined(CONFIG_DRIVERS_HDF_INPUT) 92+ if (hid->input_dev) { 93+ HidReportEvent(hid->input_dev, usage->type, usage->code, value); 94+ } 95+#endif 96 } 97 98 /* 99@@ -1928,6 +1936,81 @@ static const struct device_attribute dev_attr_country = { 100 .show = show_country, 101 }; 102 103+#if defined(CONFIG_DRIVERS_HDF_INPUT) 104+static bool check_mouse(char *name) 105+{ 106+ static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"}; 107+ for (int i = 0; i < 4; i++) { 108+ if (strstr(name, option[i])) 109+ return true; 110+ } 111+ return false; 112+} 113+static bool check_kbd(char *name) 114+{ 115+ static char *option[]={"Keyboard", "keyboard"}; 116+ for (int i = 0; i < 2; i++) { 117+ if (strstr(name, option[i])) 118+ return true; 119+ } 120+ return false; 121+} 122+static bool check_rocker(char *name) 123+{ 124+ static char *option[]={"Thrustmaster"}; 125+ for (int i = 0; i < 1; i++) { 126+ if (strstr(name, option[i])) 127+ return true; 128+ } 129+ return false; 130+} 131+static bool check_encoder(char *name) 132+{ 133+ if (strcmp(name, "Wired KeyBoard") == 0) { 134+ return true; 135+ } 136+ return false; 137+} 138+static bool check_trackball(char *name) 139+{ 140+ static char *option[]={"Trackball"}; 141+ for (int i = 0; i < 1; i++) { 142+ if (strstr(name, option[i])) 143+ return true; 144+ } 145+ return false; 146+} 147+static void notify_connect_event(struct hid_device *hdev) 148+{ 149+ bool check; 150+ int type = -1; 151+ HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL); 152+ if (dev == NULL) { 153+ printk("%s: malloc failed", __func__); 154+ return; 155+ } 156+ type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type; 157+ type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type; 158+ type = check_rocker(hdev->name)?HID_TYPE_ROCKER:type; 159+ type = check_encoder(hdev->name)?HID_TYPE_ENCODER:type; 160+ type = check_trackball(hdev->name)?HID_TYPE_TRACKBALL:type; 161+ if ( type < 0) { 162+ kfree(dev); 163+ dev = NULL; 164+ return; 165+ } 166+ 167+ dev->devType = type; 168+ dev->devName = hdev->name; 169+ hdev->input_dev = HidRegisterHdfInputDev(dev); 170+ if (hdev->input_dev == NULL) { 171+ printk("%s: RegisterInputDevice failed\n", __func__); 172+ } 173+ kfree(dev); 174+ dev = NULL; 175+} 176+#endif 177+ 178 int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 179 { 180 static const char *types[] = { "Device", "Pointer", "Mouse", "Device", 181@@ -2020,6 +2103,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 182 hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", 183 buf, bus, hdev->version >> 8, hdev->version & 0xff, 184 type, hdev->name, hdev->phys); 185+#if defined(CONFIG_DRIVERS_HDF_INPUT) 186+ notify_connect_event(hdev); 187+#endif 188 189 return 0; 190 } 191@@ -2035,6 +2121,10 @@ void hid_disconnect(struct hid_device *hdev) 192 if (hdev->claimed & HID_CLAIMED_HIDRAW) 193 hidraw_disconnect(hdev); 194 hdev->claimed = 0; 195+#if defined(CONFIG_DRIVERS_HDF_INPUT) 196+ if (hdev->input_dev) 197+ HidUnregisterHdfInputDev(hdev->input_dev); 198+#endif 199 } 200 EXPORT_SYMBOL_GPL(hid_disconnect); 201 202@@ -2119,6 +2209,11 @@ EXPORT_SYMBOL_GPL(hid_hw_open); 203 */ 204 void hid_hw_close(struct hid_device *hdev) 205 { 206+#if defined(CONFIG_DRIVERS_HDF_INPUT) 207+ if (hdev->input_dev) { 208+ return; 209+ } 210+#endif 211 mutex_lock(&hdev->ll_open_lock); 212 if (!--hdev->ll_open_count) 213 hdev->ll_driver->close(hdev); 214diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c 215index d1ab2dccf..5354f0153 100644 216--- a/drivers/hid/hid-input.c 217+++ b/drivers/hid/hid-input.c 218@@ -20,6 +20,10 @@ 219 #include <linux/hid.h> 220 #include <linux/hid-debug.h> 221 222+#if defined(CONFIG_DRIVERS_HDF_INPUT) 223+#include "hdf_hid_adapter.h" 224+#endif 225+ 226 #include "hid-ids.h" 227 228 #define unk KEY_UNKNOWN 229@@ -1418,7 +1422,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report) 230 return; 231 232 list_for_each_entry(hidinput, &hid->inputs, list) 233+#if defined(CONFIG_DRIVERS_HDF_INPUT) 234+ { 235+#endif 236 input_sync(hidinput->input); 237+#if defined(CONFIG_DRIVERS_HDF_INPUT) 238+ if(hid->input_dev) 239+ HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0); 240+ } 241+#endif 242 } 243 EXPORT_SYMBOL_GPL(hidinput_report_event); 244 245@@ -1869,6 +1881,41 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput, 246 report->field[i]->usage + j); 247 } 248 249+#if defined(CONFIG_DRIVERS_HDF_INPUT) 250+static void transfer_info(struct input_dev *dev) 251+{ 252+ HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL); 253+ if (info == NULL) { 254+ printk("%s: malloc failed\n",__func__); 255+ return; 256+ } 257+ info->devName = dev->name; 258+ memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT)); 259+ memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT)); 260+ memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT)); 261+ memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT)); 262+ memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT)); 263+ memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT)); 264+ memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT)); 265+ memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT)); 266+ memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT)); 267+ memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT)); 268+ for (int i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) { 269+ if (dev->absbit[i] != 0) { 270+ memcpy(info->axisInfo, dev->absinfo, sizeof(struct input_absinfo) * ABS_CNT); 271+ break; 272+ } 273+ } 274+ info->bustype = dev->id.bustype; 275+ info->vendor = dev->id.vendor; 276+ info->product = dev->id.product; 277+ info->version = dev->id.version; 278+ SendInfoToHdf(info); 279+ kfree(info); 280+ info = NULL; 281+} 282+#endif 283+ 284 /* 285 * Register the input device; print a message. 286 * Configure the input layer interface 287@@ -1954,6 +2001,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) 288 continue; 289 } 290 291+#if defined(CONFIG_DRIVERS_HDF_INPUT) 292+ transfer_info(hidinput->input); 293+#endif 294 if (input_register_device(hidinput->input)) 295 goto out_unwind; 296 hidinput->registered = true; 297diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c 298index 505c562a5..67d451beb 100644 299--- a/drivers/input/mousedev.c 300+++ b/drivers/input/mousedev.c 301@@ -869,7 +869,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev, 302 303 if (mixdev) { 304 dev_set_name(&mousedev->dev, "mice"); 305- 306+ mousedev->open = 1; 307 mousedev->open_device = mixdev_open_devices; 308 mousedev->close_device = mixdev_close_devices; 309 } else { 310diff --git a/include/linux/hid.h b/include/linux/hid.h 311index 6ed2a97eb..1d1445a23 100644 312--- a/include/linux/hid.h 313+++ b/include/linux/hid.h 314@@ -622,6 +622,7 @@ struct hid_device { /* device report descriptor */ 315 struct list_head debug_list; 316 spinlock_t debug_list_lock; 317 wait_queue_head_t debug_wait; 318+ void *input_dev; 319 }; 320 321 #define to_hid_device(pdev) \ 322