Merged
kernel common patch #224
z-jaxAdd on Jun 29, 2022
kernel common patch #224
Merged
z-jaxAdd on Jun 29, 2022
Merged fromrefs/pull/224/headintomaster
Total: 6 files changed+30-700
MREADME.md+15-10
@@ -22,17 +22,22 @@ During the build process, you can merge the driver code based on the chip platfo
22kernel/linux22kernel/linux
23├── build23├── build
24│ ├── BUILD.gn # GN file of the build framework24│ ├── BUILD.gn # GN file of the build framework
25-│ ├── kernel.mk # Kernel build file25+│ ├── kernel.mk # Kernel build file
26-│ └── ohos.build # Kernel build component file26+│ └── ohos.build # Kernel build component file
27├── patches27├── patches
28-│ ├── linux-4.19 # linux-4.19 patches28+│ ├── linux-4.19 # linux-4.19 patches
29-│ │   └── hi3516dv300_patch 29+│ │   ├── common_patch
30-│ │   ├── hi3516dv300.patch # linux-4.19 Hi3516D V300 SOC patches30+│ │   │ └── hdf.patch # linux-4.19 HDF patches
31-│ │   └── hdf.patch # linux-4.19 Hi3516D V300 HDF patches31+│ │   └── hi3516dv300_patch
32+│ │   └── hi3516dv300.patch # linux-4.19 Hi3516D V300 SOC patches
32│ └── linux-5.1033│ └── linux-5.10
33-│    └── hi3516dv300_patch 34+│    ├── common_patch
34-│    ├── hi3516dv300.patch # linux-5.10 Hi3516D V300 SOC patches35+│    │ └── hdf.patch # linux-5.10 HDF patches
35-│    └── hdf.patch # linux-5.10 Hi3516D V300 HDF patches36+│    └── hi3516dv300_patch
37+│    │ └── hi3516dv300.patch # linux-5.10 Hi3516D V300 SOC patches
38+│    └── rkrk3568_patch
39+│    ├── kernel.patch # linux-5.10 rk3568 SOC patches
40+│    └── hdf.patch # linux-5.10 rk3568 customized HDF patches
36└── config41└── config
37 ├── linux-4.1942 ├── linux-4.19
38 │   └── arch43 │   └── arch
@@ -59,7 +64,7 @@ kernel/linux
59 Apply the HDF kernel patches matching your kernel version. For details, see the method in **kernel.mk** in the **kernel/linux/build** repository.64 Apply the HDF kernel patches matching your kernel version. For details, see the method in **kernel.mk** in the **kernel/linux/build** repository.
60 65
61 ```66 ```
62- $(OHOS_BUILD_HOME)/drivers/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(HDF_PATCH_FILE)67+ $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME)
63 ```68 ```
64 69 
652. Apply the chip driver patches.702. Apply the chip driver patches.
@@ -22,17 +22,22 @@ Linux社区LTS 5.10.y分支信息请查看[kernel官网](https://git.kernel.org/
22kernel/linux22kernel/linux
23├── build23├── build
24│ ├── BUILD.gn # 编译框架GN文件24│ ├── BUILD.gn # 编译框架GN文件
25-│ ├── kernel.mk # 内核编译文件25+│ ├── kernel.mk # 内核编译文件
26-│ └── ohos.build # 内核编译组件文件26+│ └── ohos.build # 内核编译组件文件
27├── patches27├── patches
28-│ ├── linux-4.19 # linux-4.19 相关patch28+│ ├── linux-4.19 # linux-4.19 相关patch
29-│ │   └── hi3516dv300_patch 29+│ │   ├── common_patch
30-│ │   ├── hi3516dv300.patch # linux-4.19 hi3516dv300 SOC patch30+│ │   │ └── hdf.patch # linux-4.19 HDF patches
31-│ │   └── hdf.patch # linux-4.19 hi3516dv300 hdf patch31+│ │   └── hi3516dv300_patch
32+│ │   └── hi3516dv300.patch # linux-4.19 Hi3516D V300 SOC patches
32│ └── linux-5.1033│ └── linux-5.10
33-│    └── hi3516dv300_patch 34+│    ├── common_patch
34-│    ├── hi3516dv300.patch # linux-5.10 hi3516dv300 SOC patch35+│    │ └── hdf.patch # linux-5.10 HDF patches
35-│    └── hdf.patch # linux-5.10 hi3516dv300 hdf patch36+│    └── hi3516dv300_patch
37+│    │ └── hi3516dv300.patch # linux-5.10 Hi3516D V300 SOC patches
38+│    └── rkrk3568_patch
39+│    ├── kernel.patch # linux-5.10 rk3568 SOC patches
40+│    └── hdf.patch # linux-5.10 rk3568 定制 HDF patches
36└── config41└── config
37 ├── linux-4.1942 ├── linux-4.19
38 │   └── arch43 │   └── arch
@@ -59,7 +64,7 @@ kernel/linux
59 在kernel/linux/build仓中,按照kernel.mk中HDF的补丁合入方法,合入不同内核版本对应的HDF内核补丁:64 在kernel/linux/build仓中,按照kernel.mk中HDF的补丁合入方法,合入不同内核版本对应的HDF内核补丁:
60 65
61 ```66 ```
62- $(OHOS_BUILD_HOME)/drivers/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(HDF_PATCH_FILE)67+ $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME)
63 ```68 ```
64 69 
652. 合入芯片平台驱动补丁702. 合入芯片平台驱动补丁
Rlinux-4.19/hispark_taurus_patch/hdf.patch→linux-4.19/common_patch/hdf.patch+0-0
File renamed without changes.
Rlinux-5.10/hispark_phoenix_patch/hdf.patch→linux-5.10/common_patch/hdf.patch+0-0
File renamed without changes.
@@ -1,340 +0,0 @@
1-diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
2-index 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- }
21-diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
22-index 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 : {
40-diff --git a/drivers/Kconfig b/drivers/Kconfig
41-index 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
52-diff --git a/drivers/Makefile b/drivers/Makefile
53-index 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/
62-diff --git a/drivers/hdf/Makefile b/drivers/hdf/Makefile
63-new file mode 100644
64-index 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---
71-2.25.1
72-diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
73-index 4acb583c9..ddcaf4cdc 100644
74---- a/drivers/hid/Makefile
75-+++ b/drivers/hid/Makefile
76-@@ -2,6 +2,15 @@
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)/khdf/osal/include \
88-+ $(HDF_ROOT_DIR)/evdev
89- hid-y := hid-core.o hid-input.o hid-quirks.o
90- hid-$(CONFIG_DEBUG_FS) += hid-debug.o
91-
92-diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
93-index 5550c943f..79df97fab 100644
94---- a/drivers/hid/hid-core.c
95-+++ b/drivers/hid/hid-core.c
96-@@ -33,6 +33,9 @@
97- #include <linux/hid-debug.h>
98- #include <linux/hidraw.h>
99-
100-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
101-+#include "hdf_hid_adapter.h"
102-+#endif
103- #include "hid-ids.h"
104-
105- /*
106-@@ -1522,6 +1525,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field,
107- hidinput_hid_event(hid, field, usage, value);
108- if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
109- hid->hiddev_hid_event(hid, field, usage, value);
110-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
111-+ if (hid->input_dev) {
112-+ HidReportEvent(hid->input_dev, usage->type, usage->code, value);
113-+ }
114-+#endif
115- }
116-
117- /*
118-@@ -1928,6 +1936,81 @@ static const struct device_attribute dev_attr_country = {
119- .show = show_country,
120- };
121-
122-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
123-+static bool check_mouse(char *name)
124-+{
125-+ static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"};
126-+ for (int i = 0; i < 4; i++) {
127-+ if (strstr(name, option[i]))
128-+ return true;
129-+ }
130-+ return false;
131-+}
132-+static bool check_kbd(char *name)
133-+{
134-+ static char *option[]={"Keyboard", "keyboard"};
135-+ for (int i = 0; i < 2; i++) {
136-+ if (strstr(name, option[i]))
137-+ return true;
138-+ }
139-+ return false;
140-+}
141-+static bool check_rocker(char *name)
142-+{
143-+ static char *option[]={"Thrustmaster"};
144-+ for (int i = 0; i < 1; i++) {
145-+ if (strstr(name, option[i]))
146-+ return true;
147-+ }
148-+ return false;
149-+}
150-+static bool check_encoder(char *name)
151-+{
152-+ if (strcmp(name, "Wired KeyBoard") == 0) {
153-+ return true;
154-+ }
155-+ return false;
156-+}
157-+static bool check_trackball(char *name)
158-+{
159-+ static char *option[]={"Trackball"};
160-+ for (int i = 0; i < 1; i++) {
161-+ if (strstr(name, option[i]))
162-+ return true;
163-+ }
164-+ return false;
165-+}
166-+static void notify_connect_event(struct hid_device *hdev)
167-+{
168-+ bool check;
169-+ int type = -1;
170-+ HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL);
171-+ if (dev == NULL) {
172-+ printk("%s: malloc failed", __func__);
173-+ return;
174-+ }
175-+ type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type;
176-+ type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type;
177-+ type = check_rocker(hdev->name)?HID_TYPE_ROCKER:type;
178-+ type = check_encoder(hdev->name)?HID_TYPE_ENCODER:type;
179-+ type = check_trackball(hdev->name)?HID_TYPE_TRACKBALL:type;
180-+ if ( type < 0) {
181-+ kfree(dev);
182-+ dev = NULL;
183-+ return;
184-+ }
185-+
186-+ dev->devType = type;
187-+ dev->devName = hdev->name;
188-+ hdev->input_dev = HidRegisterHdfInputDev(dev);
189-+ if (hdev->input_dev == NULL) {
190-+ printk("%s: RegisterInputDevice failed\n", __func__);
191-+ }
192-+ kfree(dev);
193-+ dev = NULL;
194-+}
195-+#endif
196-+
197- int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
198- {
199- static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
200-@@ -2020,6 +2103,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
201- hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
202- buf, bus, hdev->version >> 8, hdev->version & 0xff,
203- type, hdev->name, hdev->phys);
204-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
205-+ notify_connect_event(hdev);
206-+#endif
207-
208- return 0;
209- }
210-@@ -2035,6 +2121,10 @@ void hid_disconnect(struct hid_device *hdev)
211- if (hdev->claimed & HID_CLAIMED_HIDRAW)
212- hidraw_disconnect(hdev);
213- hdev->claimed = 0;
214-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
215-+ if (hdev->input_dev)
216-+ HidUnregisterHdfInputDev(hdev->input_dev);
217-+#endif
218- }
219- EXPORT_SYMBOL_GPL(hid_disconnect);
220-
221-@@ -2119,6 +2209,11 @@ EXPORT_SYMBOL_GPL(hid_hw_open);
222- */
223- void hid_hw_close(struct hid_device *hdev)
224- {
225-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
226-+ if (hdev->input_dev) {
227-+ return;
228-+ }
229-+#endif
230- mutex_lock(&hdev->ll_open_lock);
231- if (!--hdev->ll_open_count)
232- hdev->ll_driver->close(hdev);
233-diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
234-index d1ab2dccf..5354f0153 100644
235---- a/drivers/hid/hid-input.c
236-+++ b/drivers/hid/hid-input.c
237-@@ -20,6 +20,10 @@
238- #include <linux/hid.h>
239- #include <linux/hid-debug.h>
240-
241-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
242-+#include "hdf_hid_adapter.h"
243-+#endif
244-+
245- #include "hid-ids.h"
246-
247- #define unk KEY_UNKNOWN
248-@@ -1418,7 +1422,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report)
249- return;
250-
251- list_for_each_entry(hidinput, &hid->inputs, list)
252-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
253-+ {
254-+#endif
255- input_sync(hidinput->input);
256-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
257-+ if(hid->input_dev)
258-+ HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0);
259-+ }
260-+#endif
261- }
262- EXPORT_SYMBOL_GPL(hidinput_report_event);
263-
264-@@ -1869,6 +1881,41 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput,
265- report->field[i]->usage + j);
266- }
267-
268-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
269-+static void transfer_info(struct input_dev *dev)
270-+{
271-+ HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL);
272-+ if (info == NULL) {
273-+ printk("%s: malloc failed\n",__func__);
274-+ return;
275-+ }
276-+ info->devName = dev->name;
277-+ memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT));
278-+ memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT));
279-+ memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT));
280-+ memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT));
281-+ memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT));
282-+ memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT));
283-+ memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT));
284-+ memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT));
285-+ memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT));
286-+ memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT));
287-+ for (int i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) {
288-+ if (dev->absbit[i] != 0) {
289-+ memcpy(info->axisInfo, dev->absinfo, sizeof(struct input_absinfo) * ABS_CNT);
290-+ break;
291-+ }
292-+ }
293-+ info->bustype = dev->id.bustype;
294-+ info->vendor = dev->id.vendor;
295-+ info->product = dev->id.product;
296-+ info->version = dev->id.version;
297-+ SendInfoToHdf(info);
298-+ kfree(info);
299-+ info = NULL;
300-+}
301-+#endif
302-+
303- /*
304- * Register the input device; print a message.
305- * Configure the input layer interface
306-@@ -1954,6 +2001,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
307- continue;
308- }
309-
310-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
311-+ transfer_info(hidinput->input);
312-+#endif
313- if (input_register_device(hidinput->input))
314- goto out_unwind;
315- hidinput->registered = true;
316-diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
317-index 505c562a5..67d451beb 100644
318---- a/drivers/input/mousedev.c
319-+++ b/drivers/input/mousedev.c
320-@@ -869,7 +869,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev,
321-
322- if (mixdev) {
323- dev_set_name(&mousedev->dev, "mice");
324--
325-+ mousedev->open = 1;
326- mousedev->open_device = mixdev_open_devices;
327- mousedev->close_device = mixdev_close_devices;
328- } else {
329-diff --git a/include/linux/hid.h b/include/linux/hid.h
330-index 6ed2a97eb..1d1445a23 100644
331---- a/include/linux/hid.h
332-+++ b/include/linux/hid.h
333-@@ -622,6 +622,7 @@ struct hid_device { /* device report descriptor */
334- struct list_head debug_list;
335- spinlock_t debug_list_lock;
336- wait_queue_head_t debug_wait;
337-+ void *input_dev;
338- };
339-
340- #define to_hid_device(pdev) \
@@ -1,340 +0,0 @@
1-diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
2-index 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- }
21-diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
22-index 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 : {
40-diff --git a/drivers/Kconfig b/drivers/Kconfig
41-index 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
52-diff --git a/drivers/Makefile b/drivers/Makefile
53-index 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/
62-diff --git a/drivers/hdf/Makefile b/drivers/hdf/Makefile
63-new file mode 100644
64-index 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---
71-2.25.1
72-diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
73-index 4acb583c9..ddcaf4cdc 100644
74---- a/drivers/hid/Makefile
75-+++ b/drivers/hid/Makefile
76-@@ -2,6 +2,15 @@
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)/khdf/osal/include \
88-+ $(HDF_ROOT_DIR)/evdev
89- hid-y := hid-core.o hid-input.o hid-quirks.o
90- hid-$(CONFIG_DEBUG_FS) += hid-debug.o
91-
92-diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
93-index 5550c943f..79df97fab 100644
94---- a/drivers/hid/hid-core.c
95-+++ b/drivers/hid/hid-core.c
96-@@ -33,6 +33,9 @@
97- #include <linux/hid-debug.h>
98- #include <linux/hidraw.h>
99-
100-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
101-+#include "hdf_hid_adapter.h"
102-+#endif
103- #include "hid-ids.h"
104-
105- /*
106-@@ -1522,6 +1525,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field,
107- hidinput_hid_event(hid, field, usage, value);
108- if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
109- hid->hiddev_hid_event(hid, field, usage, value);
110-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
111-+ if (hid->input_dev) {
112-+ HidReportEvent(hid->input_dev, usage->type, usage->code, value);
113-+ }
114-+#endif
115- }
116-
117- /*
118-@@ -1928,6 +1936,81 @@ static const struct device_attribute dev_attr_country = {
119- .show = show_country,
120- };
121-
122-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
123-+static bool check_mouse(char *name)
124-+{
125-+ static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"};
126-+ for (int i = 0; i < 4; i++) {
127-+ if (strstr(name, option[i]))
128-+ return true;
129-+ }
130-+ return false;
131-+}
132-+static bool check_kbd(char *name)
133-+{
134-+ static char *option[]={"Keyboard", "keyboard"};
135-+ for (int i = 0; i < 2; i++) {
136-+ if (strstr(name, option[i]))
137-+ return true;
138-+ }
139-+ return false;
140-+}
141-+static bool check_rocker(char *name)
142-+{
143-+ static char *option[]={"Thrustmaster"};
144-+ for (int i = 0; i < 1; i++) {
145-+ if (strstr(name, option[i]))
146-+ return true;
147-+ }
148-+ return false;
149-+}
150-+static bool check_encoder(char *name)
151-+{
152-+ if (strcmp(name, "Wired KeyBoard") == 0) {
153-+ return true;
154-+ }
155-+ return false;
156-+}
157-+static bool check_trackball(char *name)
158-+{
159-+ static char *option[]={"Trackball"};
160-+ for (int i = 0; i < 1; i++) {
161-+ if (strstr(name, option[i]))
162-+ return true;
163-+ }
164-+ return false;
165-+}
166-+static void notify_connect_event(struct hid_device *hdev)
167-+{
168-+ bool check;
169-+ int type = -1;
170-+ HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL);
171-+ if (dev == NULL) {
172-+ printk("%s: malloc failed", __func__);
173-+ return;
174-+ }
175-+ type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type;
176-+ type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type;
177-+ type = check_rocker(hdev->name)?HID_TYPE_ROCKER:type;
178-+ type = check_encoder(hdev->name)?HID_TYPE_ENCODER:type;
179-+ type = check_trackball(hdev->name)?HID_TYPE_TRACKBALL:type;
180-+ if ( type < 0) {
181-+ kfree(dev);
182-+ dev = NULL;
183-+ return;
184-+ }
185-+
186-+ dev->devType = type;
187-+ dev->devName = hdev->name;
188-+ hdev->input_dev = HidRegisterHdfInputDev(dev);
189-+ if (hdev->input_dev == NULL) {
190-+ printk("%s: RegisterInputDevice failed\n", __func__);
191-+ }
192-+ kfree(dev);
193-+ dev = NULL;
194-+}
195-+#endif
196-+
197- int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
198- {
199- static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
200-@@ -2020,6 +2103,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
201- hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
202- buf, bus, hdev->version >> 8, hdev->version & 0xff,
203- type, hdev->name, hdev->phys);
204-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
205-+ notify_connect_event(hdev);
206-+#endif
207-
208- return 0;
209- }
210-@@ -2035,6 +2121,10 @@ void hid_disconnect(struct hid_device *hdev)
211- if (hdev->claimed & HID_CLAIMED_HIDRAW)
212- hidraw_disconnect(hdev);
213- hdev->claimed = 0;
214-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
215-+ if (hdev->input_dev)
216-+ HidUnregisterHdfInputDev(hdev->input_dev);
217-+#endif
218- }
219- EXPORT_SYMBOL_GPL(hid_disconnect);
220-
221-@@ -2119,6 +2209,11 @@ EXPORT_SYMBOL_GPL(hid_hw_open);
222- */
223- void hid_hw_close(struct hid_device *hdev)
224- {
225-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
226-+ if (hdev->input_dev) {
227-+ return;
228-+ }
229-+#endif
230- mutex_lock(&hdev->ll_open_lock);
231- if (!--hdev->ll_open_count)
232- hdev->ll_driver->close(hdev);
233-diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
234-index d1ab2dccf..5354f0153 100644
235---- a/drivers/hid/hid-input.c
236-+++ b/drivers/hid/hid-input.c
237-@@ -20,6 +20,10 @@
238- #include <linux/hid.h>
239- #include <linux/hid-debug.h>
240-
241-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
242-+#include "hdf_hid_adapter.h"
243-+#endif
244-+
245- #include "hid-ids.h"
246-
247- #define unk KEY_UNKNOWN
248-@@ -1418,7 +1422,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report)
249- return;
250-
251- list_for_each_entry(hidinput, &hid->inputs, list)
252-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
253-+ {
254-+#endif
255- input_sync(hidinput->input);
256-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
257-+ if(hid->input_dev)
258-+ HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0);
259-+ }
260-+#endif
261- }
262- EXPORT_SYMBOL_GPL(hidinput_report_event);
263-
264-@@ -1869,6 +1881,41 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput,
265- report->field[i]->usage + j);
266- }
267-
268-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
269-+static void transfer_info(struct input_dev *dev)
270-+{
271-+ HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL);
272-+ if (info == NULL) {
273-+ printk("%s: malloc failed\n",__func__);
274-+ return;
275-+ }
276-+ info->devName = dev->name;
277-+ memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT));
278-+ memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT));
279-+ memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT));
280-+ memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT));
281-+ memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT));
282-+ memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT));
283-+ memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT));
284-+ memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT));
285-+ memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT));
286-+ memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT));
287-+ for (int i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) {
288-+ if (dev->absbit[i] != 0) {
289-+ memcpy(info->axisInfo, dev->absinfo, sizeof(struct input_absinfo) * ABS_CNT);
290-+ break;
291-+ }
292-+ }
293-+ info->bustype = dev->id.bustype;
294-+ info->vendor = dev->id.vendor;
295-+ info->product = dev->id.product;
296-+ info->version = dev->id.version;
297-+ SendInfoToHdf(info);
298-+ kfree(info);
299-+ info = NULL;
300-+}
301-+#endif
302-+
303- /*
304- * Register the input device; print a message.
305- * Configure the input layer interface
306-@@ -1954,6 +2001,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
307- continue;
308- }
309-
310-+#if defined(CONFIG_DRIVERS_HDF_INPUT)
311-+ transfer_info(hidinput->input);
312-+#endif
313- if (input_register_device(hidinput->input))
314- goto out_unwind;
315- hidinput->registered = true;
316-diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
317-index 505c562a5..67d451beb 100644
318---- a/drivers/input/mousedev.c
319-+++ b/drivers/input/mousedev.c
320-@@ -869,7 +869,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev,
321-
322- if (mixdev) {
323- dev_set_name(&mousedev->dev, "mice");
324--
325-+ mousedev->open = 1;
326- mousedev->open_device = mixdev_open_devices;
327- mousedev->close_device = mixdev_close_devices;
328- } else {
329-diff --git a/include/linux/hid.h b/include/linux/hid.h
330-index 6ed2a97eb..1d1445a23 100644
331---- a/include/linux/hid.h
332-+++ b/include/linux/hid.h
333-@@ -622,6 +622,7 @@ struct hid_device { /* device report descriptor */
334- struct list_head debug_list;
335- spinlock_t debug_list_lock;
336- wait_queue_head_t debug_wait;
337-+ void *input_dev;
338- };
339-
340- #define to_hid_device(pdev) \