diff --git a/kernel.mk b/kernel.mk index d1845a5eb1f679477e9cb6e047da342352509e35..d794033e1748b564d886c7b74444c33709f4f296 100644 --- a/kernel.mk +++ b/kernel.mk @@ -63,6 +63,7 @@ ifneq ($(findstring $(PRODUCT_NAME), hi3516dv300 Hi3516DV300),) HI3516DV300_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/linux-4.19/hi3516dv300_small_patch HI3516DV300_PATCH_FILE := $(HI3516DV300_PATCH_DIR)/hi3516dv300_small.patch HDF_PATCH_FILE := $(HI3516DV300_PATCH_DIR)/hdf.patch +HDF_INPUT_PATCH_FILE := $(HI3516DV300_PATCH_DIR)/hdf_input.patch KERNEL_IMAGE_FILE := $(KERNEL_SRC_TMP_PATH)/arch/arm/boot/uImage ifeq ($(PRODUCT_NAME), hi3516dv300) DEFCONFIG_FILE := hi3516dv300_small_defconfig @@ -74,7 +75,7 @@ export HDF_PROJECT_ROOT=$(OHOS_BUILD_HOME)/ $(KERNEL_IMAGE_FILE): $(hide) echo "build kernel..." $(hide) rm -rf $(KERNEL_SRC_TMP_PATH);mkdir -p $(KERNEL_SRC_TMP_PATH);cp -arfL $(KERNEL_SRC_PATH)/* $(KERNEL_SRC_TMP_PATH)/ - $(hide) cd $(KERNEL_SRC_TMP_PATH) && patch -p1 < $(HDF_PATCH_FILE) && patch -p1 < $(HI3516DV300_PATCH_FILE) + $(hide) cd $(KERNEL_SRC_TMP_PATH) && patch -p1 < $(HDF_PATCH_FILE) && patch -p1 < $(HI3516DV300_PATCH_FILE) && patch -p1 < $(HDF_INPUT_PATCH_FILE) $(hide) cp -rf $(KERNEL_CONFIG_PATH)/. $(KERNEL_SRC_TMP_PATH)/ $(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) distclean $(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(DEFCONFIG_FILE) diff --git a/linux-4.19/hi3516dv300_small_patch/hdf_input.patch b/linux-4.19/hi3516dv300_small_patch/hdf_input.patch new file mode 100644 index 0000000000000000000000000000000000000000..51b26586c82f315a90abeb8bbcff30bafe1e225c --- /dev/null +++ b/linux-4.19/hi3516dv300_small_patch/hdf_input.patch @@ -0,0 +1,200 @@ +diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile +index bd7ac53b7..d7efd1e3d 100644 +--- a/drivers/hid/Makefile ++++ b/drivers/hid/Makefile +@@ -2,6 +2,15 @@ + # + # Makefile for the HID driver + # ++HDF_ROOT_DIR = -Idrivers/hdf ++ccflags-$(CONFIG_DRIVERS_HDF_INPUT) += $(HDF_ROOT_DIR)/framework/model/input/driver \ ++ $(HDF_ROOT_DIR)/framework/include/core \ ++ $(HDF_ROOT_DIR)/framework/core/common/include/host \ ++ $(HDF_ROOT_DIR)/framework/include/utils \ ++ $(HDF_ROOT_DIR)/framework/include/osal \ ++ $(HDF_ROOT_DIR)/framework/ability/sbuf/include \ ++ $(HDF_ROOT_DIR)/khdf/osal/include \ ++ -I../../../../../third_party/FreeBSD/sys/dev/evdev + hid-y := hid-core.o hid-input.o hid-quirks.o + hid-$(CONFIG_DEBUG_FS) += hid-debug.o + +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c +index 05122167d..94cfdfbbf 100644 +--- a/drivers/hid/hid-core.c ++++ b/drivers/hid/hid-core.c +@@ -36,6 +36,9 @@ + #include + #include + ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++#include "hdf_hid_adapter.h" ++#endif + #include "hid-ids.h" + + /* +@@ -1340,6 +1343,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, + hidinput_hid_event(hid, field, usage, value); + if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) + hid->hiddev_hid_event(hid, field, usage, value); ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ if (hid->input_dev) { ++ HidReportEvent(hid->input_dev, usage->type, usage->code, value); ++ } ++#endif + } + + /* +@@ -1743,6 +1751,53 @@ static const struct device_attribute dev_attr_country = { + .show = show_country, + }; + ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++static bool check_mouse(char *name) ++{ ++ static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"}; ++ for (int i = 0; i < 4; i++) { ++ if (strstr(name, option[i])) ++ return true; ++ } ++ return false; ++} ++static bool check_kbd(char *name) ++{ ++ static char *option[]={"Keyboard", "keyboard"}; ++ for (int i = 0; i < 2; i++) { ++ if (strstr(name, option[i])) ++ return true; ++ } ++ return false; ++} ++static void notify_connect_event(struct hid_device *hdev) ++{ ++ bool check; ++ int type = -1; ++ HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL); ++ if (dev == NULL) { ++ printk("%s: malloc failed", __func__); ++ return; ++ } ++ type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type; ++ type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type; ++ if ( type < 0) { ++ kfree(dev); ++ dev = NULL; ++ return; ++ } ++ ++ dev->devType = type; ++ dev->devName = hdev->name; ++ hdev->input_dev = HidRegisterHdfInputDev(dev); ++ if (hdev->input_dev == NULL) { ++ printk("%s: RegisterInputDevice failed\n", __func__); ++ } ++ kfree(dev); ++ dev = NULL; ++} ++#endif ++ + int hid_connect(struct hid_device *hdev, unsigned int connect_mask) + { + static const char *types[] = { "Device", "Pointer", "Mouse", "Device", +@@ -1833,6 +1888,10 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) + buf, bus, hdev->version >> 8, hdev->version & 0xff, + type, hdev->name, hdev->phys); + ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ notify_connect_event(hdev); ++#endif ++ + return 0; + } + EXPORT_SYMBOL_GPL(hid_connect); +@@ -1847,6 +1906,10 @@ void hid_disconnect(struct hid_device *hdev) + if (hdev->claimed & HID_CLAIMED_HIDRAW) + hidraw_disconnect(hdev); + hdev->claimed = 0; ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ if (hdev->input_dev) ++ HidUnregisterHdfInputDev(hdev->input_dev); ++#endif + } + EXPORT_SYMBOL_GPL(hid_disconnect); + +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c +index 11bd2ca22..6f7805698 100644 +--- a/drivers/hid/hid-input.c ++++ b/drivers/hid/hid-input.c +@@ -32,6 +32,10 @@ + #include + #include + ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++#include "hdf_hid_adapter.h" ++#endif ++ + #include "hid-ids.h" + + #define unk KEY_UNKNOWN +@@ -1365,7 +1369,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report) + return; + + list_for_each_entry(hidinput, &hid->inputs, list) ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ { ++#endif + input_sync(hidinput->input); ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ if(hid->input_dev) ++ HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0); ++ } ++#endif + } + EXPORT_SYMBOL_GPL(hidinput_report_event); + +@@ -1729,6 +1741,35 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput, + report->field[i]->usage + j); + } + ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++static void transfer_info(struct input_dev *dev) ++{ ++ HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL); ++ if (info == NULL) { ++ printk("%s: malloc failed\n",__func__); ++ return; ++ } ++ info->devName = dev->name; ++ memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT)); ++ memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT)); ++ memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT)); ++ memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT)); ++ memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT)); ++ memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT)); ++ memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT)); ++ memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT)); ++ memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT)); ++ memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT)); ++ info->bustype = dev->id.bustype; ++ info->vendor = dev->id.vendor; ++ info->product = dev->id.product; ++ info->version = dev->id.version; ++ SendInfoToHdf(info); ++ kfree(info); ++ info = NULL; ++} ++#endif ++ + /* + * Register the input device; print a message. + * Configure the input layer interface +@@ -1811,7 +1852,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) + hidinput_cleanup_hidinput(hid, hidinput); + continue; + } +- ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ transfer_info(hidinput->input); ++#endif + if (input_register_device(hidinput->input)) + goto out_unwind; + hidinput->registered = true; diff --git a/linux-4.19/hi3516dv300_small_patch/hi3516dv300_small.patch b/linux-4.19/hi3516dv300_small_patch/hi3516dv300_small.patch index 1a912b65f332b7a1f0fb4cd1e6a0ac119467e958..6d4a647616bcac331d3e1050a980660d9203574e 100644 --- a/linux-4.19/hi3516dv300_small_patch/hi3516dv300_small.patch +++ b/linux-4.19/hi3516dv300_small_patch/hi3516dv300_small.patch @@ -364589,204 +364589,4 @@ index 67048f922ff2..e950f32243b6 100755 ipv6_route_test|ipv6_rt) ipv6_route_test;; ipv4_route_test|ipv4_rt) ipv4_route_test;; ipv6_addr_metric) ipv6_addr_metric_test;; -diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile -index bd7ac53b7..d7efd1e3d 100644 ---- a/drivers/hid/Makefile -+++ b/drivers/hid/Makefile -@@ -2,6 +2,15 @@ - # - # Makefile for the HID driver - # -+HDF_ROOT_DIR = -Idrivers/hdf -+ccflags-$(CONFIG_DRIVERS_HDF_INPUT) += $(HDF_ROOT_DIR)/framework/model/input/driver \ -+ $(HDF_ROOT_DIR)/framework/include/core \ -+ $(HDF_ROOT_DIR)/framework/core/common/include/host \ -+ $(HDF_ROOT_DIR)/framework/include/utils \ -+ $(HDF_ROOT_DIR)/framework/include/osal \ -+ $(HDF_ROOT_DIR)/framework/ability/sbuf/include \ -+ $(HDF_ROOT_DIR)/khdf/osal/include \ -+ -I../../../../../third_party/FreeBSD/sys/dev/evdev - hid-y := hid-core.o hid-input.o hid-quirks.o - hid-$(CONFIG_DEBUG_FS) += hid-debug.o - -diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c -index 05122167d..94cfdfbbf 100644 ---- a/drivers/hid/hid-core.c -+++ b/drivers/hid/hid-core.c -@@ -36,6 +36,9 @@ - #include - #include - -+#if defined(CONFIG_DRIVERS_HDF_INPUT) -+#include "hdf_hid_adapter.h" -+#endif - #include "hid-ids.h" - - /* -@@ -1340,6 +1343,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, - hidinput_hid_event(hid, field, usage, value); - if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) - hid->hiddev_hid_event(hid, field, usage, value); -+#if defined(CONFIG_DRIVERS_HDF_INPUT) -+ if (hid->input_dev) { -+ HidReportEvent(hid->input_dev, usage->type, usage->code, value); -+ } -+#endif - } - - /* -@@ -1743,6 +1751,53 @@ static const struct device_attribute dev_attr_country = { - .show = show_country, - }; - -+#if defined(CONFIG_DRIVERS_HDF_INPUT) -+static bool check_mouse(char *name) -+{ -+ static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"}; -+ for (int i = 0; i < 4; i++) { -+ if (strstr(name, option[i])) -+ return true; -+ } -+ return false; -+} -+static bool check_kbd(char *name) -+{ -+ static char *option[]={"Keyboard", "keyboard"}; -+ for (int i = 0; i < 2; i++) { -+ if (strstr(name, option[i])) -+ return true; -+ } -+ return false; -+} -+static void notify_connect_event(struct hid_device *hdev) -+{ -+ bool check; -+ int type = -1; -+ HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL); -+ if (dev == NULL) { -+ printk("%s: malloc failed", __func__); -+ return; -+ } -+ type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type; -+ type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type; -+ if ( type < 0) { -+ kfree(dev); -+ dev = NULL; -+ return; -+ } -+ -+ dev->devType = type; -+ dev->devName = hdev->name; -+ hdev->input_dev = HidRegisterHdfInputDev(dev); -+ if (hdev->input_dev == NULL) { -+ printk("%s: RegisterInputDevice failed\n", __func__); -+ } -+ kfree(dev); -+ dev = NULL; -+} -+#endif -+ - int hid_connect(struct hid_device *hdev, unsigned int connect_mask) - { - static const char *types[] = { "Device", "Pointer", "Mouse", "Device", -@@ -1833,6 +1888,10 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) - buf, bus, hdev->version >> 8, hdev->version & 0xff, - type, hdev->name, hdev->phys); - -+#if defined(CONFIG_DRIVERS_HDF_INPUT) -+ notify_connect_event(hdev); -+#endif -+ - return 0; - } - EXPORT_SYMBOL_GPL(hid_connect); -@@ -1847,6 +1906,10 @@ void hid_disconnect(struct hid_device *hdev) - if (hdev->claimed & HID_CLAIMED_HIDRAW) - hidraw_disconnect(hdev); - hdev->claimed = 0; -+#if defined(CONFIG_DRIVERS_HDF_INPUT) -+ if (hdev->input_dev) -+ HidUnregisterHdfInputDev(hdev->input_dev); -+#endif - } - EXPORT_SYMBOL_GPL(hid_disconnect); - -diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c -index 11bd2ca22..6f7805698 100644 ---- a/drivers/hid/hid-input.c -+++ b/drivers/hid/hid-input.c -@@ -32,6 +32,10 @@ - #include - #include - -+#if defined(CONFIG_DRIVERS_HDF_INPUT) -+#include "hdf_hid_adapter.h" -+#endif -+ - #include "hid-ids.h" - - #define unk KEY_UNKNOWN -@@ -1365,7 +1369,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report) - return; - - list_for_each_entry(hidinput, &hid->inputs, list) -+#if defined(CONFIG_DRIVERS_HDF_INPUT) -+ { -+#endif - input_sync(hidinput->input); -+#if defined(CONFIG_DRIVERS_HDF_INPUT) -+ if(hid->input_dev) -+ HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0); -+ } -+#endif - } - EXPORT_SYMBOL_GPL(hidinput_report_event); - -@@ -1729,6 +1741,35 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput, - report->field[i]->usage + j); - } - -+#if defined(CONFIG_DRIVERS_HDF_INPUT) -+static void transfer_info(struct input_dev *dev) -+{ -+ HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL); -+ if (info == NULL) { -+ printk("%s: malloc failed\n",__func__); -+ return; -+ } -+ info->devName = dev->name; -+ memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT)); -+ memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT)); -+ memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT)); -+ memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT)); -+ memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT)); -+ memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT)); -+ memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT)); -+ memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT)); -+ memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT)); -+ memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT)); -+ info->bustype = dev->id.bustype; -+ info->vendor = dev->id.vendor; -+ info->product = dev->id.product; -+ info->version = dev->id.version; -+ SendInfoToHdf(info); -+ kfree(info); -+ info = NULL; -+} -+#endif -+ - /* - * Register the input device; print a message. - * Configure the input layer interface -@@ -1811,7 +1852,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) - hidinput_cleanup_hidinput(hid, hidinput); - continue; - } -- -+#if defined(CONFIG_DRIVERS_HDF_INPUT) -+ transfer_info(hidinput->input); -+#endif - if (input_register_device(hidinput->input)) - goto out_unwind; - hidinput->registered = true;