tzh
2024-08-20 ca8393c352368485bcb8b277004fdb0c6cb572c6
feat(ir): add allwinner ir func and hal
9 files modified
43 files added
3196 ■■■■■ changed files
android/device/softwinner/ceres-common/BoardConfigCommon.mk 1 ●●●● patch | view | raw | blame | history
android/device/softwinner/ceres-common/ceres-common.mk 2 ●●●●● patch | view | raw | blame | history
android/frameworks/base/api/current.txt 1 ●●●● patch | view | raw | blame | history
android/frameworks/base/api/test-current.txt 2 ●●● patch | view | raw | blame | history
android/frameworks/base/core/java/android/view/KeyEvent.java 4 ●●● patch | view | raw | blame | history
android/frameworks/base/core/res/res/values/attrs.xml 1 ●●●● patch | view | raw | blame | history
android/frameworks/native/include/android/keycodes.h 1 ●●●● patch | view | raw | blame | history
android/frameworks/native/include/input/InputEventLabels.h 1 ●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/HomletBoardConfig.mk 9 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/Android.mk 18 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/IRConfig.mk 6 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/core/Android.bp 46 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/core/MultiirService.cpp 69 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/core/MultiirService.h 31 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/core/multi_ir.rc 6 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/core/multiir.cpp 752 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/core/multiir.h 54 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/core/uevent_utils.cpp 155 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/core/virtual_input.cpp 460 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/core/virtual_input.h 52 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/jni/Android.mk 34 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/jni/com_softwinner_multiir.cpp 173 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/Vendor_000d_Product_3838.kl 11 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_2992.kl 36 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_4040.kl 25 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_4cb3.kl 53 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_7f80.kl 37 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_9f00.kl 48 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_ba04.kl 1 ●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_bc00.kl 34 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_dd22.kl 47 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_fb04.kl 48 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_fc00.kl 12 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_fe01.kl 33 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_fe01_petrel.kl 33 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_ff00.kl 35 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_rc5_ir_04.kl 7 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/sunxi-ir-recovery.kl 19 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/sunxi-ir-uinput.kl 244 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/sunxi-ir.kl 244 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/virtual-remote.kl 26 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/libmultiir/Android.bp 25 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/libmultiir/IMultiirService.cpp 164 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/libmultiir/IMultiirService.h 33 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/multiir.mk 51 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/sepolicy/file_contexts 1 ●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/sepolicy/multi_ir.te 24 ●●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/sepolicy/private/service_contexts 1 ●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/sepolicy/service.te 1 ●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/hardware/input/multi_ir/sepolicy/system_server.te 1 ●●●● patch | view | raw | blame | history
android/vendor/aw/homlet/homlet.mk 1 ●●●● patch | view | raw | blame | history
longan/device/config/chips/a133/configs/c3/board.dts 23 ●●●● patch | view | raw | blame | history
android/device/softwinner/ceres-common/BoardConfigCommon.mk
old mode 100644new mode 100755
....@@ -1,4 +1,5 @@
11 include device/softwinner/common/BoardConfigCommon.mk
2
+include vendor/aw/homlet/HomletBoardConfig.mk
23
34 TARGET_PLATFORM := tablet
45 TARGET_BOARD_PLATFORM := ceres
android/device/softwinner/ceres-common/ceres-common.mk
old mode 100644new mode 100755
....@@ -1,6 +1,8 @@
11 # inherit common.mk
22 $(call inherit-product-if-exists, device/softwinner/common/common.mk)
33
4
+$(call inherit-product-if-exists, vendor/aw/homlet/homlet.mk)
5
+
46 PRODUCT_CPU_TYPE ?= A100
57
68 DEVICE_PACKAGE_OVERLAYS := \
android/frameworks/base/api/current.txt
....@@ -49070,6 +49070,7 @@
4907049070 field public static final int KEYCODE_ALT_RIGHT = 58; // 0x3a
4907149071 field public static final int KEYCODE_APOSTROPHE = 75; // 0x4b
4907249072 field public static final int KEYCODE_APP_SWITCH = 187; // 0xbb
49073
+ field public static final int KEYCODE_APP_VIDEO = 289; // 0x121
4907349074 field public static final int KEYCODE_ASSIST = 219; // 0xdb
4907449075 field public static final int KEYCODE_AT = 77; // 0x4d
4907549076 field public static final int KEYCODE_AVR_INPUT = 182; // 0xb6
android/frameworks/base/api/test-current.txt
old mode 100644new mode 100755
....@@ -3231,7 +3231,7 @@
32313231 public class KeyEvent extends android.view.InputEvent implements android.os.Parcelable {
32323232 method public static String actionToString(int);
32333233 method public final void setDisplayId(int);
3234
- field public static final int LAST_KEYCODE = 288; // 0x120
3234
+ field public static final int LAST_KEYCODE = 289; // 0x121
32353235 }
32363236
32373237 public final class KeyboardShortcutGroup implements android.os.Parcelable {
android/frameworks/base/core/java/android/view/KeyEvent.java
old mode 100644new mode 100755
....@@ -825,6 +825,8 @@
825825 */
826826 public static final int KEYCODE_PROFILE_SWITCH = 288;
827827
828
+ public static final int KEYCODE_APP_VIDEO = 289;
829
+
828830 /* add for other platform, Reserved for them */
829831 /**
830832 * @hide
....@@ -897,7 +899,7 @@
897899 * @hide
898900 */
899901 @TestApi
900
- public static final int LAST_KEYCODE = KEYCODE_PROFILE_SWITCH;
902
+ public static final int LAST_KEYCODE = KEYCODE_APP_VIDEO;
901903
902904 private static boolean isHomlet;
903905
android/frameworks/base/core/res/res/values/attrs.xml
old mode 100644new mode 100755
....@@ -1924,6 +1924,7 @@
19241924 <enum name="KEYCODE_THUMBS_UP" value="286" />
19251925 <enum name="KEYCODE_THUMBS_DOWN" value="287" />
19261926 <enum name="KEYCODE_PROFILE_SWITCH" value="288" />
1927
+ <enum name="KEYCODE_APP_VIDEO" value="289" />
19271928 <enum name="KEYCODE_TV_SYSTEM" value="10000" />
19281929 <enum name="KEYCODE_GOTO" value="10001" />
19291930 <enum name="KEYCODE_SUBTITLE" value="10002" />
android/frameworks/native/include/android/keycodes.h
old mode 100644new mode 100755
....@@ -777,6 +777,7 @@
777777 /** Used to switch current account that is consuming content.
778778 * May be consumed by system to switch current viewer profile. */
779779 AKEYCODE_PROFILE_SWITCH = 288,
780
+ AKEYCODE_APP_VIDEO = 289,
780781 /* add some new keys for TVD */
781782 AKEYCODE_TV_SYSTEM = 10000,
782783 AKEYCODE_GOTO = 10001,
android/frameworks/native/include/input/InputEventLabels.h
old mode 100644new mode 100755
....@@ -328,6 +328,7 @@
328328 DEFINE_KEYCODE(THUMBS_UP),
329329 DEFINE_KEYCODE(THUMBS_DOWN),
330330 DEFINE_KEYCODE(PROFILE_SWITCH),
331
+ DEFINE_KEYCODE(APP_VIDEO),
331332 DEFINE_KEYCODE(TV_SYSTEM),
332333 DEFINE_KEYCODE(GOTO),
333334 DEFINE_KEYCODE(SUBTITLE),
android/vendor/aw/homlet/HomletBoardConfig.mk
....@@ -0,0 +1,9 @@
1
+include vendor/aw/homlet/hardware/input/multi_ir/IRConfig.mk
2
+
3
+# homlet common sepolicy
4
+#BOARD_SEPOLICY_DIRS += \
5
+# vendor/aw/homlet/sepolicy
6
+
7
+# homlet private sepolicy
8
+#BOARD_PLAT_PRIVATE_SEPOLICY_DIR += \
9
+# vendor/aw/homlet/sepolicy/private
android/vendor/aw/homlet/hardware/input/multi_ir/Android.mk
....@@ -0,0 +1,18 @@
1
+# Copyright (C) 2010 The Android Open Source Project
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+LOCAL_PATH := $(call my-dir)
16
+
17
+include $(call all-makefiles-under,$(LOCAL_PATH))
18
+
android/vendor/aw/homlet/hardware/input/multi_ir/IRConfig.mk
....@@ -0,0 +1,6 @@
1
+
2
+BOARD_SEPOLICY_DIRS += \
3
+ vendor/aw/homlet/hardware/input/multi_ir/sepolicy
4
+
5
+BOARD_PLAT_PRIVATE_SEPOLICY_DIR += \
6
+ vendor/aw/homlet/hardware/input/multi_ir/sepolicy/private
android/vendor/aw/homlet/hardware/input/multi_ir/core/Android.bp
....@@ -0,0 +1,46 @@
1
+cc_binary {
2
+ name: "multi_ir",
3
+ recovery_available: true,
4
+ srcs: [
5
+ "multiir.cpp",
6
+ "virtual_input.cpp",
7
+ "uevent_utils.cpp",
8
+ "MultiirService.cpp",
9
+ ],
10
+
11
+ init_rc: ["multi_ir.rc"],
12
+
13
+ shared_libs: [
14
+ "libcutils",
15
+ // "libc",
16
+ "liblog",
17
+ "libutils",
18
+ "libbinder",
19
+ "libandroid_runtime",
20
+ "libmultiirservice",
21
+ ],
22
+
23
+ include_dirs: [
24
+ "system/core/libutils/include",
25
+ ],
26
+
27
+ cflags: [
28
+ "-DLOG_TAG=\"multiir\"",
29
+ "-DCEC_ONE_TOUCH_PLAY",
30
+ "-llog",
31
+ ],
32
+
33
+ target: {
34
+ recovery: {
35
+ exclude_shared_libs: [
36
+ "libbinder",
37
+ "libandroid_runtime",
38
+ "libmultiirservice",
39
+ ],
40
+
41
+ exclude_srcs: ["MultiirService.cpp"],
42
+ cflags: ["-DBUILD_TARGET_RECOVERY"],
43
+ },
44
+
45
+ }
46
+}
android/vendor/aw/homlet/hardware/input/multi_ir/core/MultiirService.cpp
....@@ -0,0 +1,69 @@
1
+#ifndef BUILD_TARGET_RECOVERY
2
+#undef NDEBUG
3
+
4
+#include "MultiirService.h"
5
+#include "virtual_input.h"
6
+#include "multiir.h"
7
+#include <binder/IServiceManager.h>
8
+#include <utils/misc.h>
9
+#include <utils/Log.h>
10
+
11
+
12
+#define DEBUG true
13
+
14
+namespace android {
15
+
16
+void MultiirService::instantiate() {
17
+ defaultServiceManager()->addService(
18
+ String16("softwinner.multi_ir"), new MultiirService());
19
+}
20
+
21
+MultiirService::MultiirService() {
22
+ ALOGD("MultiirService create");
23
+}
24
+
25
+MultiirService::~MultiirService() {
26
+ ALOGD("MultiirService destoryed");
27
+}
28
+
29
+int MultiirService::enterMouseMode(void) {
30
+ if (DEBUG) ALOGD("MultiirService enterMouseMode");
31
+ int ret = create_virtual_mouse_dev("VirtualMouse");
32
+ return ret;
33
+}
34
+
35
+int MultiirService::exitMouseMode(void) {
36
+ if (DEBUG) ALOGD("MultiirService exitMouseMode");
37
+ int ret = destory_virtual_mouse_dev();
38
+ return ret;
39
+}
40
+
41
+int MultiirService::getDefaultPointerSpeed(void) {
42
+ return get_default_pointerspeed();
43
+}
44
+
45
+int MultiirService::getDefaultStepDistance(void) {
46
+ return get_default_stepdistance();
47
+}
48
+
49
+int MultiirService::setPointerSpeed(int mx) {
50
+ set_pointerspeed(mx);
51
+ return 1;
52
+}
53
+
54
+int MultiirService::setStepDistance(int px) {
55
+ set_stepdistance(px);
56
+ return 1;
57
+}
58
+
59
+int MultiirService::reset(void) {
60
+ reset();
61
+ return 1;
62
+}
63
+
64
+int MultiirService::reportMouseKeyEvent(int scan_code, int key_state) {
65
+ return report_mouse_keyevent(scan_code, key_state);
66
+}
67
+}
68
+
69
+#endif
android/vendor/aw/homlet/hardware/input/multi_ir/core/MultiirService.h
....@@ -0,0 +1,31 @@
1
+#ifndef ANDROID_MULTIIRSERVICE_H
2
+#define ANDROID_MULTIIRSERVICE_H
3
+#ifndef BUILD_TARGET_RECOVERY
4
+
5
+#include <utils/Log.h>
6
+#include <utils/Errors.h>
7
+#include "IMultiirService.h"
8
+
9
+namespace android {
10
+
11
+class MultiirService : public BnMultiirService {
12
+public:
13
+ static void instantiate();
14
+ virtual int enterMouseMode(void);
15
+ virtual int exitMouseMode(void);
16
+ virtual int getDefaultPointerSpeed(void);
17
+ virtual int getDefaultStepDistance(void);
18
+ virtual int setPointerSpeed(int ms);
19
+ virtual int setStepDistance(int px);
20
+ virtual int reset(void);
21
+ virtual int reportMouseKeyEvent(int scan_code, int key_state);
22
+
23
+private:
24
+ MultiirService();
25
+ virtual ~MultiirService();
26
+};
27
+
28
+};
29
+#endif
30
+
31
+#endif
android/vendor/aw/homlet/hardware/input/multi_ir/core/multi_ir.rc
....@@ -0,0 +1,6 @@
1
+service multi_ir /system/bin/multi_ir
2
+ class main
3
+ user root
4
+ group system input uhid
5
+ seclabel u:r:multi_ir:s0
6
+
android/vendor/aw/homlet/hardware/input/multi_ir/core/multiir.cpp
....@@ -0,0 +1,752 @@
1
+/*
2
+ * multi ir daemon for android -
3
+ * Copyright (C) 2015-2018 AllwinnerTech
4
+ *
5
+ * This program is free software; you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation; either version 2 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program; if not, write to the Free Software
17
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ *
19
+ */
20
+
21
+#include <unistd.h>
22
+#include <stdio.h>
23
+#include <stdlib.h>
24
+#include <string.h>
25
+#include <stdint.h>
26
+#include <ctype.h>
27
+#include <dirent.h>
28
+#include <fcntl.h>
29
+#include <sys/ioctl.h>
30
+#include <sys/inotify.h>
31
+#include <sys/types.h>
32
+#include <utils/Log.h>
33
+#include <sys/poll.h>
34
+#include <linux/input.h>
35
+#include <sys/time.h>
36
+#include <signal.h>
37
+#include <errno.h>
38
+#include <pthread.h>
39
+#include <thread>
40
+
41
+#include "cutils/properties.h"
42
+#ifndef BUILD_TARGET_RECOVERY
43
+#include <binder/IPCThreadState.h>
44
+#include <binder/ProcessState.h>
45
+#include <binder/IServiceManager.h>
46
+#include "MultiirService.h"
47
+#endif
48
+#include "virtual_input.h"
49
+#include "multiir.h"
50
+
51
+
52
+#ifdef HDMI_CEC_STANDBY_SUPPORT
53
+extern int uevent_init(int *ufds);
54
+extern int uevent_process_event(void);
55
+#endif
56
+
57
+#define multi_debug(fmt, arg...) \
58
+do { \
59
+ if (mult_flags & PRINT_DEBUG) \
60
+ fprintf(stdout, "[D] " fmt"\n", ##arg); \
61
+} while(0)
62
+
63
+enum {
64
+ PRINT_ERROR = 1U << 0,
65
+ PRINT_WARN = 1U << 1,
66
+ PRINT_DEBUG = 1U << 2,
67
+};
68
+
69
+static int mult_flags = 0x0;
70
+
71
+extern int g_mousefd;
72
+int event_mode = 0;
73
+
74
+pthread_mutex_t mutex;
75
+struct itimerval timer_value;
76
+//#define DEBUG
77
+
78
+extern int nfds;
79
+#define MOUSE_CODE (0xE8)
80
+#define DPAD_UP 19
81
+#define DPAD_DOWN 20
82
+#define DPAD_LEFT 21
83
+#define DPAD_RIGHT 22
84
+#define DPAD_CENTER 23
85
+
86
+#define KEY_LAYOUT_PATH "/system/usr/keylayout"
87
+#define DEFAULT_KEYLAYOUT_FILE "sunxi-ir.kl"
88
+#define IR_KEYPRESS_TIMEOUT (500000)
89
+#define IR_REPEAT_PERIOD (80)
90
+#define DEFAULT_POINTER_SPEED IR_REPEAT_PERIOD
91
+#define POINTER_SPEED_MAX (100)
92
+#define POINTER_SPEED_MIN (10)
93
+#define DEFAULT_STEP_DISTANCE 20
94
+
95
+static int pointer_speed = DEFAULT_POINTER_SPEED;
96
+static int mDistance = DEFAULT_STEP_DISTANCE;
97
+
98
+int get_default_pointerspeed(void)
99
+{
100
+ return POINTER_SPEED_MAX - DEFAULT_POINTER_SPEED;
101
+}
102
+
103
+int get_default_stepdistance(void)
104
+{
105
+ return DEFAULT_STEP_DISTANCE;
106
+}
107
+
108
+void set_pointerspeed(int ms)
109
+{
110
+ // real speed = POINTER_SPEED_MAX - ms
111
+ // userspace set speed, value more smaller speed more faster
112
+ if (ms < POINTER_SPEED_MIN)
113
+ pointer_speed = POINTER_SPEED_MAX;
114
+ else if (ms > POINTER_SPEED_MAX)
115
+ pointer_speed = POINTER_SPEED_MIN;
116
+ else
117
+ pointer_speed = POINTER_SPEED_MAX - ms + POINTER_SPEED_MIN;
118
+}
119
+
120
+void set_stepdistance(int px)
121
+{
122
+ if (px < 5)
123
+ mDistance = 5;
124
+ else if (px > 50)
125
+ mDistance = 50;
126
+ else
127
+ mDistance = px;
128
+}
129
+
130
+void reset(void)
131
+{
132
+ set_pointerspeed(DEFAULT_POINTER_SPEED);
133
+ set_stepdistance(DEFAULT_STEP_DISTANCE);
134
+}
135
+
136
+/*
137
+ * A valid customer ir key layout file *MUST* namd by 'customer_ir_xxxx.kl',
138
+ * which 'xxxx' is the identity(ir address code, in hex),
139
+ * eg. customer_ir_9f00.kl
140
+*/
141
+#define FILENAME_PREFIX "customer_ir_"
142
+#define FILENAME_PREFIX_RC5 "customer_rc5_ir_"
143
+#define FILENAME_EXTENSION ".kl"
144
+
145
+#define IR_PROTOCOL_USED "/proc/sunxi_ir_protocol"
146
+#define NEC (0)
147
+#define RC5 (1)
148
+static unsigned int ir_protocol_used ;
149
+
150
+
151
+struct keymap_t {
152
+ int keycode;
153
+ char name[MAX_NAME_LEN];
154
+};
155
+
156
+struct key_dev_t {
157
+ int uinputfd;
158
+ struct input_event *event;
159
+ int last_code;
160
+ int last_value;
161
+ int keypressed;
162
+};
163
+
164
+struct keymap_t default_keys[KEYCODE_CNT];
165
+struct keymap_t customer_keys[KEYCODE_CNT];
166
+struct mapping_table_t mapping_table[KEY_MAPING_MAX];
167
+struct key_dev_t sunxi_ir_dev;
168
+
169
+int mapping_table_cnt = 0;
170
+
171
+void keymap_init(struct keymap_t *map)
172
+{
173
+ int i;
174
+ for (i=0; i<KEYCODE_CNT; i++, map++) {
175
+ map->keycode = RESERVE_CODE;
176
+ strcpy(map->name, RESERVE_NAME);
177
+ }
178
+}
179
+
180
+#ifdef DEBUG
181
+void dump_keymap(struct keymap_t *map)
182
+{
183
+ int i;
184
+
185
+ for (i=0; i<KEYCODE_CNT; i++, map++) {
186
+ if (!strlen(map->name)) continue;
187
+ printf("key\t%d\t%s\n", map->keycode, map->name);
188
+ }
189
+}
190
+
191
+void dump_mapping_table(struct mapping_table_t *table, struct keymap_t *def)
192
+{
193
+ int i;
194
+
195
+ printf("+ identity: 0x%04x\n", table->identity);
196
+ for (i=0; i<KEYCODE_CNT; i++) {
197
+ printf("\t[%3d] --> { %3d, %-20s }\n", i, table->value[i],
198
+ (def + table->value[i])->name);
199
+ }
200
+}
201
+#endif
202
+
203
+static int isDPADKey(int scan) {
204
+ int DPADKeyCode[4] = {DPAD_UP, DPAD_DOWN, DPAD_LEFT, DPAD_RIGHT};
205
+ int i;
206
+ for (i = 0; i < 4; i++) {
207
+ if (DPADKeyCode[i] == scan) return 1;
208
+ }
209
+ return 0;
210
+}
211
+
212
+/**
213
+ * @brief: create a keymap form keylayout file(*.kl)
214
+ * @param: path - path to the target file
215
+ * @param: map - store the result
216
+ * @return:
217
+ */
218
+int create_keymap_from_file(const char *path, struct keymap_t *map)
219
+{
220
+ int ret = 0;
221
+ FILE *kl_fd = NULL;
222
+ char buf[1024], lable[32], name[MAX_NAME_LEN];
223
+ int keycode;
224
+ char *p;
225
+ struct keymap_t *des;
226
+
227
+ kl_fd = fopen(path, "r");
228
+ if (!kl_fd) {
229
+ ALOGE("open '%s' fail, %s\n", path, strerror(errno));
230
+ return -1;
231
+ }
232
+
233
+ while (fgets(buf, 1024, kl_fd)) {
234
+ p = buf;
235
+ while (*p==' ') p++;
236
+ if (*p=='#') continue;
237
+
238
+ if (sscanf(buf, "%31s %d %31s", lable, &keycode, name)!=3) continue;
239
+ if (strcmp(lable, "key")!=0 || keycode < KEYCODE_MIN || keycode > KEYCODE_MAX) continue;
240
+
241
+ des = (struct keymap_t *)(map + keycode);
242
+ des->keycode = keycode;
243
+ strcpy(des->name, name);
244
+ }
245
+
246
+ if (!feof(kl_fd)) {
247
+ ALOGE("reading '%s' error, %s\n", path, strerror(errno));
248
+ ret = -1;
249
+ }
250
+
251
+ fclose(kl_fd);
252
+ return ret;
253
+}
254
+
255
+/**
256
+ * @brief: make a mapping from src to des, the result is store at @table,
257
+ * the mapping will set to ir driver through ioctl syscall.
258
+ * @param: src
259
+ * @param: des
260
+ * @param: table
261
+ */
262
+void generate_mapping_table(struct keymap_t* src, struct keymap_t *des, struct mapping_table_t *table)
263
+{
264
+ int i, j;
265
+ struct keymap_t *p;
266
+
267
+ memset(table, 0, sizeof(struct mapping_table_t));
268
+ for (i=0; i<KEYCODE_CNT; i++, src++) {
269
+ if (src->keycode==RESERVE_CODE) continue;
270
+
271
+ p = des;
272
+ for (j=0; j<KEYCODE_CNT; j++, p++) {
273
+ if (p->keycode!=-1 && strcmp(src->name, p->name)==0) {
274
+ table->value[p->keycode] = src->keycode;
275
+
276
+ if (table->powerkey==0 && strcmp(src->name, "POWER")==0) {
277
+ table->powerkey = p->keycode;
278
+ }
279
+
280
+ p->keycode = -1;
281
+ }
282
+ }
283
+ }
284
+}
285
+
286
+/**
287
+ * @brief: filter out the valid kaylaout file.
288
+ * @param: name
289
+ * @return: -1 means something error, else the identity.
290
+ */
291
+int kl_filename_verify(const char *name)
292
+{
293
+ char *p;
294
+ int i, identity;
295
+ /* filename prefix filter */
296
+ if(ir_protocol_used == RC5){
297
+ if (strncmp(name, FILENAME_PREFIX_RC5, strlen(FILENAME_PREFIX_RC5)))
298
+ return -1;
299
+ }
300
+ else if(ir_protocol_used == NEC){
301
+ if (strncmp(name, FILENAME_PREFIX, strlen(FILENAME_PREFIX)))
302
+ return -1;
303
+ }
304
+ /* filename extensiion filter */
305
+ if(ir_protocol_used == RC5){
306
+ p = (char *)name + strlen(FILENAME_PREFIX_RC5) + 2;
307
+ if (strcmp(p, FILENAME_EXTENSION))
308
+ return -1;
309
+ }
310
+ else if(ir_protocol_used == NEC){
311
+ p = (char *)name + strlen(FILENAME_PREFIX) + 4;
312
+ if (strcmp(p, FILENAME_EXTENSION))
313
+ return -1;
314
+ }
315
+
316
+ /* identity filter, 4 hexadecimal number */
317
+ if(ir_protocol_used == RC5){
318
+ p = (char *)name + strlen(FILENAME_PREFIX_RC5);
319
+ for (i=0; i<2; i++) {
320
+ if (isxdigit(*(p+i))==0)
321
+ return -1;
322
+ }
323
+ }
324
+ else if(ir_protocol_used == NEC){
325
+ p = (char *)name + strlen(FILENAME_PREFIX);
326
+ for (i=0; i<4; i++) {
327
+ if (isxdigit(*(p+i))==0)
328
+ return -1;
329
+ }
330
+ }
331
+ identity = strtol(p, &p, 16);
332
+
333
+ return identity;
334
+}
335
+
336
+int init_sunxi_ir_map(void)
337
+{
338
+ int mapping_table_cnt = 0;
339
+ char kl_path[512] = {0};
340
+ DIR *dir;
341
+ struct dirent *dirent;
342
+ int identity;
343
+
344
+ /* create default key map */
345
+ keymap_init(default_keys);
346
+ sprintf(kl_path, "%s/%s", KEY_LAYOUT_PATH, DEFAULT_KEYLAYOUT_FILE);
347
+ create_keymap_from_file(kl_path, default_keys);
348
+
349
+#ifdef DEBUG
350
+ dump_keymap(default_keys);
351
+#endif
352
+
353
+ dir = opendir(KEY_LAYOUT_PATH);
354
+ if (!dir) {
355
+ ALOGE("Open directory '%s' error, %s\n",
356
+ KEY_LAYOUT_PATH, strerror(errno));
357
+ exit(-1);
358
+ }
359
+
360
+ while ((dirent = readdir(dir))!= NULL) {
361
+ identity = kl_filename_verify(dirent->d_name);
362
+ if ((identity != -1) && (mapping_table_cnt < KEY_MAPING_MAX)) {
363
+#ifdef DEBUG
364
+ ALOGI("config filename %s\n", dirent->d_name);
365
+#endif
366
+ sprintf(kl_path, "%s/%s", KEY_LAYOUT_PATH, dirent->d_name);
367
+ memset(customer_keys, 0, sizeof(struct keymap_t)*(KEYCODE_CNT));
368
+ create_keymap_from_file(kl_path, customer_keys);
369
+ generate_mapping_table(default_keys, customer_keys, &(mapping_table[mapping_table_cnt]));
370
+ mapping_table[mapping_table_cnt].identity = identity;
371
+ #ifdef DEBUG
372
+ dump_mapping_table(&(mapping_table[mapping_table_cnt]), default_keys);
373
+ #endif
374
+ mapping_table_cnt++;
375
+ }
376
+ }
377
+ closedir(dir);
378
+ return mapping_table_cnt;
379
+}
380
+
381
+int detect_key_event(struct input_event *event, int ir_map_cnt)
382
+{
383
+ int i;
384
+ int scan_code = 0;
385
+ int scan_addr = 0;
386
+
387
+ if(ir_protocol_used == RC5){
388
+ scan_code = event->value & 0x7f;
389
+ scan_addr = (event->value >> 8) & 0x1f;
390
+ }
391
+ else if(ir_protocol_used == NEC){
392
+ scan_code = event->value & 0xff;
393
+ scan_addr = (event->value >> 8) & 0xffff;
394
+ }
395
+ for(i = 0; i < ir_map_cnt; i++)
396
+ {
397
+ if(mapping_table[i].identity == scan_addr)
398
+ {
399
+ return mapping_table[i].value[scan_code];
400
+ }
401
+ }
402
+ return -1;
403
+}
404
+
405
+int convertCenterEvent(int scancode, int sync)
406
+{
407
+ struct input_event temp_event;
408
+ if (scancode != DPAD_CENTER)
409
+ return 0;
410
+ temp_event.code = BTN_LEFT;
411
+ temp_event.type = EV_KEY;
412
+ temp_event.value = 0;
413
+ report_key_event(g_mousefd, &temp_event, sync);
414
+ return 0;
415
+}
416
+
417
+int ir_key_up(struct key_dev_t *ir_dev, int code, int sync)
418
+{
419
+ struct input_event temp_event;
420
+
421
+ if(!(ir_dev->keypressed))
422
+ {
423
+ return 0;
424
+ }
425
+ temp_event.type = EV_KEY;
426
+ if (event_mode && (code == DPAD_CENTER))
427
+ return convertCenterEvent(code, sync);
428
+ temp_event.code = code;
429
+ temp_event.value = 0;
430
+ report_key_event(ir_dev->uinputfd, &temp_event, sync);
431
+ multi_debug("up %04x %04x %08x\n", temp_event.type, temp_event.code, temp_event.value);
432
+ ir_dev->keypressed = 0;
433
+ return 0;
434
+}
435
+
436
+int convertEvent(struct key_dev_t *ir_dev, int scancode)
437
+{
438
+ struct input_event temp_event;
439
+ temp_event.type = EV_REL;
440
+ switch (scancode) {
441
+ case DPAD_UP:
442
+ temp_event.code = REL_Y;
443
+ temp_event.value = -mDistance;
444
+ break;
445
+ case DPAD_DOWN:
446
+ temp_event.code = REL_Y;
447
+ temp_event.value = mDistance;
448
+ break;
449
+ case DPAD_LEFT:
450
+ temp_event.code = REL_X;
451
+ temp_event.value = -mDistance;
452
+ break;
453
+ case DPAD_RIGHT:
454
+ temp_event.code = REL_X;
455
+ temp_event.value = mDistance;
456
+ break;
457
+ case DPAD_CENTER:
458
+ temp_event.type = EV_KEY;
459
+ temp_event.code = BTN_LEFT;
460
+ temp_event.value = 1;
461
+ break;
462
+ default:
463
+ return 0;
464
+ }
465
+ ir_dev->keypressed = 1;
466
+ ir_dev->last_code = temp_event.code;
467
+ ir_dev->last_value = temp_event.value;
468
+ report_key_event(g_mousefd, &temp_event, 1);
469
+ return 0;
470
+}
471
+
472
+int ir_key_down(struct key_dev_t *ir_dev, int scancode)
473
+{
474
+ struct input_event temp_event;
475
+
476
+ if (ir_dev->keypressed)
477
+ ir_key_up(ir_dev, scancode, 1);
478
+
479
+ if (event_mode && (isDPADKey(scancode) || scancode == DPAD_CENTER)) {
480
+ return convertEvent(ir_dev, scancode);
481
+ }
482
+
483
+ temp_event.type = EV_KEY;
484
+ temp_event.code = scancode;
485
+ temp_event.value = 1;
486
+ ir_dev->keypressed = 1;
487
+ ir_dev->last_code = scancode;
488
+ report_key_event(ir_dev->uinputfd, &temp_event, 1);
489
+ multi_debug("down %04x %04x %08x\n", temp_event.type, temp_event.code, temp_event.value);
490
+ return 0;
491
+}
492
+
493
+int sunxi_timer_init(struct itimerval *value, int repeat_num)
494
+{
495
+ if(repeat_num == 0)
496
+ {
497
+ value->it_value.tv_sec = 0;
498
+ value->it_value.tv_usec = IR_KEYPRESS_TIMEOUT; //200ms¶¨Ê±
499
+ value->it_interval.tv_sec = 0;
500
+ value->it_interval.tv_usec = IR_KEYPRESS_TIMEOUT; //200ms¶¨Ê±
501
+ }else if(repeat_num > 0) { // Support to decrease the period of repeating time
502
+ value->it_value.tv_sec = 0;
503
+ value->it_value.tv_usec = pointer_speed * 1000;
504
+ value->it_interval.tv_sec = 0;
505
+ value->it_interval.tv_usec = pointer_speed * 1000;
506
+ }
507
+ setitimer(ITIMER_REAL, value, NULL);
508
+ return 0;
509
+}
510
+
511
+void ir_key_repeat(int signum)
512
+{
513
+ struct input_event temp_event;
514
+
515
+ if (signum!=SIGALRM)
516
+ return;
517
+
518
+ pthread_mutex_lock(&mutex);
519
+ if(sunxi_ir_dev.keypressed)
520
+ {
521
+ temp_event.type = EV_REL;
522
+ temp_event.code = sunxi_ir_dev.last_code;
523
+ temp_event.value = sunxi_ir_dev.last_value;
524
+ report_key_event(g_mousefd, &temp_event, 1);
525
+ sunxi_timer_init(&timer_value, 1);
526
+ }
527
+ pthread_mutex_unlock(&mutex);
528
+ return;
529
+}
530
+
531
+int sunxi_mod_timer(struct itimerval *value)
532
+{
533
+ setitimer(ITIMER_REAL, value, NULL);
534
+ return 0;
535
+}
536
+
537
+int sunxi_del_timer(struct itimerval *value)
538
+{
539
+ value->it_value.tv_sec = 0;
540
+ value->it_value.tv_usec = 0;
541
+ value->it_interval.tv_sec = 0;
542
+ value->it_interval.tv_usec = 0;
543
+ setitimer(ITIMER_REAL, value, NULL);
544
+ return 0;
545
+}
546
+
547
+#ifdef CEC_ONE_TOUCH_PLAY
548
+#define ONE_TOUCH_PLAY_CODE (0xDF)
549
+void trigger_one_touch_play(void)
550
+{
551
+ property_set("hdmi_cts.one_touch_play", "1");
552
+}
553
+#endif
554
+
555
+
556
+
557
+void setMouseMode(int mode) {
558
+ event_mode = mode;
559
+}
560
+
561
+int detect_key_input(struct key_dev_t *ir_dev)
562
+{
563
+ int scan_code;
564
+ int key_state;
565
+
566
+ scan_code = detect_key_event(ir_dev->event, mapping_table_cnt);
567
+
568
+ if(scan_code <= 0)
569
+ {
570
+ return 0;
571
+ }
572
+
573
+ key_state = (ir_dev->event->value >> 24) & 0x1;
574
+
575
+#ifdef CEC_ONE_TOUCH_PLAY
576
+ if (key_state && scan_code == ONE_TOUCH_PLAY_CODE) {
577
+ trigger_one_touch_play();
578
+ ALOGD("trigger one touch play.");
579
+ }
580
+#endif
581
+
582
+ if(key_state)
583
+ {
584
+ ir_key_down(ir_dev, scan_code);
585
+ if(event_mode && isDPADKey(scan_code))
586
+ {
587
+ sunxi_timer_init(&timer_value, 0);
588
+ }
589
+ }
590
+ else
591
+ {
592
+ if(event_mode)
593
+ {
594
+ sunxi_del_timer(&timer_value);
595
+ }
596
+ ir_key_up(ir_dev, scan_code, 1);
597
+ }
598
+ return 0;
599
+}
600
+
601
+static int _report_mouse_keyevent(struct key_dev_t *ir_dev, int scan_code, int key_state)
602
+{
603
+ if (scan_code <= 0) {
604
+ return 0;
605
+ }
606
+
607
+ if (key_state) {
608
+ ir_key_down(ir_dev, scan_code);
609
+ if (event_mode && isDPADKey(scan_code)) {
610
+ sunxi_timer_init(&timer_value, 0);
611
+ }
612
+ } else {
613
+ if (event_mode) {
614
+ sunxi_del_timer(&timer_value);
615
+ }
616
+ ir_key_up(ir_dev, scan_code, 1);
617
+ }
618
+ return 0;
619
+}
620
+
621
+int report_mouse_keyevent(int scan_code, int key_state)
622
+{
623
+ return _report_mouse_keyevent(&sunxi_ir_dev, scan_code, key_state);
624
+}
625
+
626
+static int ir_protocol(unsigned int *ir_protocol_used )
627
+{
628
+ int res = 0,fd = 0;
629
+ fd = open(IR_PROTOCOL_USED,O_RDONLY|O_NONBLOCK);
630
+ res = read(fd,ir_protocol_used,sizeof(unsigned int));
631
+ printf("IR_PROTOCOL_USED = %d\n",*ir_protocol_used);
632
+ if(res < 0)
633
+ {
634
+ ALOGE("can not read IR_PROTOCOL_USED\n");
635
+ return 1;
636
+ }
637
+ if((*ir_protocol_used!= NEC)&&(*ir_protocol_used!= RC5))
638
+ {
639
+ ALOGE("WRONG : sunxi only support rc5 or nec protocol now\n\n");
640
+ return 1;
641
+ }
642
+ close(fd);
643
+ return 0;
644
+}
645
+#ifndef BUILD_TARGET_RECOVERY
646
+std::thread mServiceThread;
647
+void startService(void)
648
+{
649
+ android::sp<android::ProcessState> proc(android::ProcessState::self());
650
+ android::sp<android::IServiceManager> sm = android::defaultServiceManager();
651
+ android::MultiirService::instantiate();
652
+ android::ProcessState::self()->startThreadPool();
653
+ android::IPCThreadState::self()->joinThreadPool();
654
+}
655
+#endif
656
+
657
+int main(void)
658
+{
659
+ int err;
660
+ //int scan_code = 0;
661
+ //const char *devname = NULL;
662
+ const char *inotify_path = "/dev/input";
663
+ char uinput_devname[32] = "sunxi-ir-uinput";
664
+ char devpath[PATH_MAX];
665
+ struct pollfd ufds[POLL_FD_NUM];
666
+ char device_name[16] = {0};
667
+ struct inputdev_info * sourcedev = NULL;
668
+ struct input_event ir_event;
669
+ int uinputfd = -1;
670
+ //To determine which protocol of IR will be used
671
+ if(ir_protocol(&ir_protocol_used))
672
+ {
673
+ ALOGE("WRONG:faied to get ir_protocol_used \
674
+ default to use NEC protocol\n");
675
+ ir_protocol_used = NEC;
676
+ }
677
+ //ÐéÄâÉ豸½¨Á¢
678
+ uinputfd = setup_virtual_input_dev(uinput_devname);
679
+ ALOGD("uinputfd=%d\n", uinputfd);
680
+ if(uinputfd <= 0)
681
+ {
682
+ return 0;
683
+ }
684
+
685
+ sunxi_ir_dev.uinputfd = uinputfd;
686
+ sunxi_ir_dev.event = &ir_event;
687
+
688
+ mapping_table_cnt = init_sunxi_ir_map();
689
+ if(mapping_table_cnt <= 0)
690
+ {
691
+ ALOGE("cant find any ir map");
692
+ return 0;
693
+ }
694
+
695
+ pthread_mutex_init(&mutex, NULL);
696
+ signal(SIGALRM, ir_key_repeat);
697
+
698
+ memset(ufds, 0, sizeof(ufds));
699
+ memset(&sourcedev, 0, sizeof(sourcedev));
700
+
701
+ /* inotify when '/dev/inpu't dir change */
702
+ nfds = 1;
703
+ ufds[0].fd = inotify_init();
704
+ ufds[0].events = POLLIN;
705
+ err = inotify_add_watch(ufds[0].fd, inotify_path, IN_DELETE | IN_CREATE);
706
+ if (err < 0) {
707
+ ALOGE("could not add watch for '%s', %s",
708
+ inotify_path, strerror(errno));
709
+ return -1;
710
+ }
711
+
712
+#ifdef HDMI_CEC_STANDBY_SUPPORT
713
+ if (uevent_init(&ufds[CEC_FD_INDEX].fd)==0) {
714
+ nfds++;
715
+ ufds[CEC_FD_INDEX].events = POLLIN;
716
+ ALOGD("uevent listen start");
717
+ }
718
+#endif
719
+
720
+ strcpy(device_name, "sunxi-ir");
721
+
722
+ /* try to find the target input device */
723
+ err = try_to_find_device(device_name, devpath);
724
+ if (err==0 && strlen(devpath)) {
725
+ ALOGD("find target device, path=%s", devpath);
726
+ sourcedev = open_device(devpath, ufds);
727
+ }
728
+
729
+#ifndef BUILD_TARGET_RECOVERY
730
+ mServiceThread = std::thread(startService);
731
+#endif
732
+
733
+ while(1) {
734
+ poll(ufds, nfds, -1);
735
+ if (ufds[0].revents & POLLIN) {
736
+ notify_process(sourcedev, uinput_devname, inotify_path, ufds[0].fd, ufds);
737
+ }
738
+ if (ufds[INPUT_FD_INDEX].revents & POLLIN) {
739
+
740
+ if(!input_event_process(ufds[INPUT_FD_INDEX].fd, &ir_event))
741
+ {
742
+ detect_key_input(&sunxi_ir_dev);
743
+ }
744
+ }
745
+ #ifdef HDMI_CEC_STANDBY_SUPPORT
746
+ if (ufds[CEC_FD_INDEX].revents & POLLIN) {
747
+ uevent_process_event();
748
+ }
749
+ #endif
750
+ }
751
+ return 0;
752
+}
android/vendor/aw/homlet/hardware/input/multi_ir/core/multiir.h
....@@ -0,0 +1,54 @@
1
+
2
+#ifndef __MULTI_IR_H__
3
+#define __MULTI_IR_H__
4
+
5
+#include <linux/ioctl.h>
6
+
7
+/* ioctl cmd define */
8
+#define MULTI_IR_IOC_MAGIC 'M'
9
+/* return the max mapping table count support, if error, return -1 */
10
+#define MULTI_IR_IOC_REQ_MAP _IOR(MULTI_IR_IOC_MAGIC, 1, int *)
11
+#define MULTI_IR_IOC_SET_MAP _IOW(MULTI_IR_IOC_MAGIC, 2, void *)
12
+#define MULTI_IR_IOC_CLR_MAP _IOW(MULTI_IR_IOC_MAGIC, 3, int)
13
+
14
+#define MAX_NAME_LEN (32)
15
+#define KEYCODE_MIN (0)
16
+#define KEYCODE_MAX (300)
17
+#define KEYCODE_CNT (KEYCODE_MAX-KEYCODE_MIN+1)
18
+#define KEY_MAPING_MAX (18)
19
+
20
+#define RESERVE_CODE 0
21
+#define RESERVE_NAME "!RESERVE"
22
+
23
+
24
+/*
25
+ A mapping table is mapping from customer ir key layout file(*.kl)
26
+ to default layout file.
27
+
28
+ For example:
29
+ in coustomer kl file --> key 28 POWER
30
+ in default kl file --> key 57 POWER
31
+
32
+ then, the mapping will be like that: mapping_table.value[57] = 28
33
+*/
34
+struct mapping_table_t {
35
+ int identity; /* means ir address */
36
+ int powerkey; /* powerky to wakeup system */
37
+ int value[KEYCODE_CNT]; /* convert from coustomer keycode to
38
+ default keycode */
39
+};
40
+
41
+void setMouseMode(int mode);
42
+int report_mouse_keyevent(int scan_code, int key_state);
43
+#define HDMI_CEC_STANDBY_SUPPORT
44
+
45
+#ifdef HDMI_CEC_STANDBY_SUPPORT
46
+#define POLL_FD_NUM (3)
47
+#define CEC_FD_INDEX (1)
48
+#define INPUT_FD_INDEX (2)
49
+#else
50
+#define POLL_FD_NUM (2)
51
+#define INPUT_FD_INDEX (1)
52
+#endif
53
+
54
+#endif /* __MULTI_IR_H__ */
android/vendor/aw/homlet/hardware/input/multi_ir/core/uevent_utils.cpp
....@@ -0,0 +1,155 @@
1
+
2
+#include <stdio.h>
3
+#include <string.h>
4
+#include <unistd.h>
5
+#include <poll.h>
6
+#include <pthread.h>
7
+
8
+#include <sys/time.h>
9
+#include <sys/socket.h>
10
+#include <sys/un.h>
11
+#include <sys/queue.h>
12
+#include <linux/netlink.h>
13
+#include <utils/Log.h>
14
+
15
+static const char * device_match_array[] = {
16
+ "change@/devices/platform/soc/hdmi",
17
+ "change@/devices/soc.0/1ee0000.hdmi",
18
+};
19
+
20
+static int fd = -1;
21
+
22
+/* Returns !0 on failure, 0 on success */
23
+int uevent_init(int *ufds)
24
+{
25
+ struct sockaddr_nl addr;
26
+ int sz = 64*1024;
27
+ int s;
28
+
29
+ memset(&addr, 0, sizeof(addr));
30
+ addr.nl_family = AF_NETLINK;
31
+ addr.nl_pid = getpid();
32
+ addr.nl_groups = 0xffffffff;
33
+
34
+ s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
35
+ if(s < 0)
36
+ return 0;
37
+
38
+ setsockopt(s, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz));
39
+
40
+ if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
41
+ close(s);
42
+ return 0;
43
+ }
44
+
45
+ fd = s;
46
+ *ufds = fd;
47
+ return (fd > 0) ? 0 : -1;
48
+}
49
+
50
+int uevent_next_event(char* buffer, int buffer_length)
51
+{
52
+ while (1) {
53
+ struct pollfd fds;
54
+ int nr;
55
+
56
+ fds.fd = fd;
57
+ fds.events = POLLIN;
58
+ fds.revents = 0;
59
+ nr = poll(&fds, 1, -1);
60
+
61
+ if(nr > 0 && (fds.revents & POLLIN)) {
62
+ int count = recv(fd, buffer, buffer_length, 0);
63
+ if (count > 0) {
64
+ return count;
65
+ }
66
+ }
67
+ }
68
+ return 0;
69
+}
70
+
71
+/* return interval in sec */
72
+long get_interval(void)
73
+{
74
+ static struct timeval previous;
75
+ struct timeval current, interval;
76
+
77
+ gettimeofday(&current, NULL);
78
+ timersub(&current, &previous, &interval);
79
+ previous = current;
80
+
81
+ return interval.tv_sec;
82
+}
83
+
84
+extern void report_standby_request(void);
85
+char msg[1024] = {0};
86
+int uevent_process_event(void)
87
+{
88
+ int i;
89
+ int count = 0;
90
+ char *substr = NULL;
91
+ int cec_opcode = 0;
92
+
93
+ count = recv(fd, msg, 1024, 0);
94
+ if (count<=0) return 0;
95
+
96
+ msg[count] = 0;
97
+ for (substr=msg; substr<msg+count; substr+=(strlen(substr)+1)) {
98
+ if (!strcmp(substr, device_match_array[0])
99
+ || !strcmp(substr, device_match_array[1])) {
100
+ i = 0;
101
+ while (i++<4 && substr<(msg+count))
102
+ substr += (strlen(substr)+1);
103
+
104
+ sscanf(substr, "CEC_MSG=%x", &cec_opcode);
105
+ ALOGV("recv: %s, opcode [%02x]\n", substr, cec_opcode);
106
+
107
+ if (cec_opcode == 0x36) {
108
+ long interval = get_interval();
109
+ if (interval > 5 || interval < 0) {
110
+ report_standby_request();
111
+ ALOGD("standby request from HDMI-CEC\n");
112
+ }
113
+ ALOGD("receive CEC standy request, interval = %ld sec", interval);
114
+ }
115
+ break;
116
+ }
117
+ }
118
+
119
+ return 0;
120
+}
121
+
122
+#if 0
123
+int main(int argc, char **argv)
124
+{
125
+ char msg[1024] = {0};
126
+ char *substr = NULL;
127
+ int count, i;
128
+ int cec_opcode = 0;
129
+
130
+ if (uevent_init()!=0) {
131
+ fprintf(stderr, "uevent init error\n");
132
+ return -1;
133
+ }
134
+
135
+ while (1) {
136
+ count = uevent_next_event(msg, sizeof(msg));
137
+ if (count > 0) {
138
+ msg[count] = 0;
139
+ for (substr=msg; substr<msg+count; substr+=(strlen(substr)+1)) {
140
+ if (strcmp(substr, DEVICE_MATCH_STR)==0) {
141
+ i = 0;
142
+ while (i++<4 && substr<(msg+count))
143
+ substr += (strlen(substr)+1);
144
+
145
+ sscanf(substr, "CEC_MSG=%x", &cec_opcode);
146
+ fprintf(stdout, "recv: %s, opcode [%02x]\n", substr, cec_opcode);
147
+ break;
148
+ }
149
+ }
150
+ }
151
+ }
152
+
153
+ return 0;
154
+}
155
+#endif
android/vendor/aw/homlet/hardware/input/multi_ir/core/virtual_input.cpp
....@@ -0,0 +1,460 @@
1
+/*
2
+ * multi ir daemon for android -
3
+ * Copyright (C) 2015-2018 AllwinnerTech
4
+ *
5
+ * This program is free software; you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation; either version 2 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program; if not, write to the Free Software
17
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ *
19
+ */
20
+#include <unistd.h>
21
+#include <stdio.h>
22
+#include <stdlib.h>
23
+#include <string.h>
24
+#include <stdint.h>
25
+#include <dirent.h>
26
+#include <fcntl.h>
27
+#include <sys/ioctl.h>
28
+#include <sys/inotify.h>
29
+#include <sys/poll.h>
30
+#include <utils/Log.h>
31
+#include <linux/input.h>
32
+#include <linux/uinput.h>
33
+#include <sys/types.h>
34
+#include <errno.h>
35
+
36
+#include "multiir.h"
37
+#include "virtual_input.h"
38
+
39
+#define uinput_debug(fmt, arg...) \
40
+do { \
41
+ if (print_flags & PRINT_DEBUG) \
42
+ fprintf(stdout, "[D] " fmt"\n", ##arg); \
43
+} while(0)
44
+
45
+#define uinput_warning(fmt, arg...) \
46
+do { \
47
+ if (print_flags & PRINT_WARN) \
48
+ fprintf(stdout, "[W] " fmt"\n", ##arg); \
49
+} while(0)
50
+
51
+#define uinput_error(fmt, arg...) \
52
+do { \
53
+ if (print_flags & PRINT_ERROR) \
54
+ fprintf(stderr, "[E] " fmt"\n", ##arg); \
55
+} while(0)
56
+
57
+enum {
58
+ PRINT_ERROR = 1U << 0,
59
+ PRINT_WARN = 1U << 1,
60
+ PRINT_DEBUG = 1U << 2,
61
+};
62
+
63
+#define UINPUT_NAME "/dev/uinput"
64
+static int g_uinputfd = -1;
65
+int g_mousefd = -1;
66
+static int print_flags = 0;
67
+
68
+static struct uinput_user_dev virtual_inputdev;
69
+static struct uinput_user_dev virtual_mousedev;
70
+
71
+
72
+int nfds = 0;
73
+
74
+static int is_devname_match(const char *devpath, const char *tname)
75
+{
76
+ int fd;
77
+ char name[80];
78
+
79
+ if (!devpath || !tname)
80
+ return 0;
81
+
82
+ fd = open(devpath, O_RDWR);
83
+ if (fd<0) {
84
+ uinput_error("could not open '%s', %s",
85
+ devpath, strerror(errno));
86
+ return 0;
87
+ }
88
+ name[sizeof(name)-1] = '\0';
89
+ if(ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
90
+ uinput_error("could not get device name for '%s', %s",
91
+ devpath, strerror(errno));
92
+ name[0] = '\0';
93
+ goto notmatch;
94
+ }
95
+ if (!strcmp(name, tname)) {
96
+ uinput_debug("find match device '%s'", devpath);
97
+ close(fd);
98
+ return 1;
99
+ }
100
+
101
+notmatch:
102
+ close(fd);
103
+ uinput_debug("device not match or ioctl error, %s(%s)", devpath, name);
104
+ return 0;
105
+}
106
+
107
+int try_to_find_device(const char *devname, char *path)
108
+{
109
+ const char *dirname = "/dev/input";
110
+ char devpath[PATH_MAX];
111
+ char *p;
112
+ DIR *dir;
113
+ struct dirent *de;
114
+
115
+ if (!devname || !path)
116
+ return -1;
117
+
118
+ path[0] = '\0';
119
+ dir = opendir(dirname);
120
+ if(dir == NULL)
121
+ return -1;
122
+ strcpy(devpath, dirname);
123
+ p = devpath + strlen(devpath);
124
+ *p++ = '/';
125
+ while((de = readdir(dir))) {
126
+ if(de->d_name[0] == '.' &&
127
+ (de->d_name[1] == '\0' ||
128
+ (de->d_name[1] == '.' && de->d_name[2] == '\0')))
129
+ continue;
130
+
131
+ strcpy(p, de->d_name);
132
+ if (is_devname_match(devpath, devname)) {
133
+ strcpy(path, devpath);
134
+ break;
135
+ }
136
+ }
137
+ closedir(dir);
138
+ return 0;
139
+}
140
+
141
+struct inputdev_info *open_device(const char *devpath, struct pollfd *ufds)
142
+{
143
+ struct inputdev_info *info;
144
+
145
+ if (!devpath)
146
+ goto errout;
147
+
148
+ info = (inputdev_info *)calloc(sizeof(*info), sizeof(char));
149
+ if (!info) {
150
+ uinput_error("could not malloc, %s", strerror(errno));
151
+ goto errout;
152
+ }
153
+
154
+ info->fd = open(devpath, O_RDWR);
155
+ if (info->fd < 0) {
156
+ uinput_error("could not open device '%s', %s",
157
+ devpath, strerror(errno));
158
+ free(info);
159
+ goto errout;
160
+ }
161
+
162
+ strcpy(info->devpath, devpath);
163
+ if (ioctl(info->fd, EVIOCGVERSION, &info->version)) {
164
+ uinput_warning("could not get driver version for '%s', %s",
165
+ devpath, strerror(errno));
166
+ }
167
+ if (ioctl(info->fd, EVIOCGID, &info->id)) {
168
+ uinput_warning("could not get driver id for '%s', %s",
169
+ devpath, strerror(errno));
170
+ }
171
+
172
+ if (ioctl(info->fd, EVIOCGNAME(sizeof(info->name)-1), info->name) < 1) {
173
+ uinput_warning("could not get device name for %s, %s",
174
+ devpath, strerror(errno));
175
+ }
176
+ if (ioctl(info->fd, EVIOCGPHYS(sizeof(info->location)-1), info->location) < 1) {
177
+ uinput_warning("could not get location for %s, %s",
178
+ devpath, strerror(errno));
179
+ }
180
+ if (ioctl(info->fd, EVIOCGUNIQ(sizeof(info->idstr) - 1), info->idstr) < 1) {
181
+ uinput_warning("could not get idstring for %s, %s",
182
+ devpath, strerror(errno));
183
+ }
184
+
185
+ if (print_flags & PRINT_DEBUG) {
186
+ fprintf(stdout, " devpath: %s\n", info->devpath);
187
+ fprintf(stdout, " bus: %04x\n"
188
+ " vendor %04x\n"
189
+ " product %04x\n"
190
+ " version %04x\n",
191
+ info->id.bustype, info->id.vendor,
192
+ info->id.product, info->id.version);
193
+ fprintf(stdout, " name: \"%s\"\n", info->name);
194
+ fprintf(stdout, " location: \"%s\"\n"
195
+ " id: \"%s\"\n", info->location, info->idstr);
196
+ fprintf(stdout, " version: %d.%d.%d\n",
197
+ info->version >> 16,
198
+ (info->version >> 8) & 0xff,
199
+ info->version & 0xff);
200
+ }
201
+
202
+ ufds[INPUT_FD_INDEX].fd = info->fd;
203
+ ufds[INPUT_FD_INDEX].events = POLLIN;
204
+ nfds++;
205
+ uinput_debug("add device '%s' to poll", devpath);
206
+ return info;
207
+errout:
208
+ uinput_error("could open device '%s'!", devpath);
209
+ return NULL;
210
+}
211
+
212
+static void close_device(struct inputdev_info * sourcedev, const char *devpath, struct pollfd *ufds)
213
+{
214
+ if (!sourcedev)
215
+ return;
216
+
217
+ if (!strcmp(sourcedev->devpath, devpath)) {
218
+ close(sourcedev->fd);
219
+ free(sourcedev);
220
+ sourcedev = NULL;
221
+
222
+ nfds--;
223
+ ufds[nfds].fd = -1;
224
+ ufds[nfds].events = 0;
225
+ uinput_debug("close device '%s'", devpath);
226
+ } else {
227
+ uinput_debug("device '%s' not open, ignore", devpath);
228
+ }
229
+}
230
+
231
+int notify_process(struct inputdev_info * sourcedev, char *device_name, const char *dirname, int nfd, struct pollfd *ufds)
232
+{
233
+ int res;
234
+ char devpath[PATH_MAX];
235
+ char *p;
236
+ char event_buf[512];
237
+ int event_size;
238
+ int event_pos = 0;
239
+ struct inotify_event *event;
240
+
241
+ res = read(nfd, event_buf, sizeof(event_buf));
242
+ if (res < (int)sizeof(*event)) {
243
+ if (errno == EINTR)
244
+ return 0;
245
+ uinput_error("could not get event, %s", strerror(errno));
246
+ return 1;
247
+ }
248
+ uinput_debug("got %d bytes of event information", res);
249
+
250
+ strcpy(devpath, dirname);
251
+ p = devpath + strlen(devpath);
252
+ *p++ = '/';
253
+
254
+ while(res >= (int)sizeof(*event)) {
255
+ event = (struct inotify_event *)(event_buf + event_pos);
256
+ uinput_debug("%d: %08x \"%s\"",
257
+ event->wd, event->mask, event->len ? event->name : "");
258
+
259
+ if (event->len) {
260
+ strcpy(p, event->name);
261
+ if (event->mask & IN_CREATE) {
262
+ if (!sourcedev && is_devname_match(devpath, device_name)) {
263
+ uinput_debug("find target device, path=%s", devpath);
264
+ sourcedev = open_device(devpath, ufds);
265
+ }
266
+ } else {
267
+ close_device(sourcedev, devpath, ufds);
268
+ }
269
+ }
270
+
271
+ event_size = sizeof(*event) + event->len;
272
+ res -= event_size;
273
+ event_pos += event_size;
274
+ }
275
+
276
+ return 0;
277
+}
278
+
279
+int input_event_process(int nfd, struct input_event *event)
280
+{
281
+ int res;
282
+
283
+ res = read(nfd, event, sizeof(struct input_event));
284
+ if (res < (int)sizeof(struct input_event)) {
285
+ uinput_error("could not get event");
286
+ return -1;
287
+ }
288
+
289
+// ALOGD("%04x %04x %08x", event->type, event->code, event->value);
290
+ return 0;
291
+}
292
+
293
+int create_virtual_mouse_dev(char *mouse_dev) {
294
+ int uinputfd = -1;
295
+
296
+ if (g_mousefd >= 0) {
297
+ ALOGD("multiir had enter mouse mode");
298
+ return 0;
299
+ }
300
+
301
+ ALOGD("multi_ir open uinput dev");
302
+
303
+ uinputfd = open(UINPUT_NAME, O_WRONLY | O_NDELAY);
304
+ if (uinputfd <= 0) {
305
+ ALOGE("could not open '%s', %s\n", UINPUT_NAME, strerror(errno));
306
+ return uinputfd;
307
+ }
308
+
309
+ memset(&virtual_mousedev, 0, sizeof(virtual_mousedev));
310
+ strncpy(virtual_mousedev.name, mouse_dev, UINPUT_MAX_NAME_SIZE);
311
+ virtual_mousedev.id.version = 0x0111;
312
+ virtual_mousedev.id.bustype = BUS_USB;
313
+ virtual_mousedev.id.vendor = 0x093a;
314
+ virtual_mousedev.id.product = 0x2521;
315
+
316
+ /* setup mouse coordinate event */
317
+ if (ioctl(uinputfd, UI_SET_EVBIT, EV_REL) < 0) ALOGE("set evbit rel fail : %s", strerror(errno));
318
+ if (ioctl(uinputfd, UI_SET_EVBIT, EV_KEY) < 0) ALOGE("set evbit key fail : %s", strerror(errno));
319
+ if (ioctl(uinputfd, UI_SET_RELBIT, REL_X) < 0) ALOGE("set relbit x fail : %s", strerror(errno));
320
+ if (ioctl(uinputfd, UI_SET_RELBIT, REL_Y) < 0) ALOGE("set relbit y fail : %s", strerror(errno));
321
+
322
+ /* setup mouse button event */
323
+ if (ioctl(uinputfd, UI_SET_KEYBIT, BTN_MOUSE) < 0) ALOGE("set keybit mouse fail : %s", strerror(errno));
324
+
325
+ /* create input device into input subsystem */
326
+ write(uinputfd, &virtual_mousedev, sizeof(virtual_mousedev));
327
+ if (ioctl(uinputfd, UI_DEV_CREATE)) {
328
+ ALOGE("could not create uinput device, %s\n", strerror(errno));
329
+ close(uinputfd);
330
+ uinputfd = -1;
331
+ return uinputfd;
332
+ }
333
+
334
+ g_mousefd = uinputfd;
335
+ setMouseMode(1);
336
+ return 0;
337
+}
338
+
339
+int destory_virtual_mouse_dev(void) {
340
+ if (g_mousefd == -1) {
341
+ ALOGD("multiir had exit mouse mode");
342
+ return 0;
343
+ }
344
+
345
+ if (ioctl(g_mousefd, UI_DEV_DESTROY)) {
346
+ ALOGD("could not destory virtual mouse: %s", strerror(errno));
347
+ close(g_mousefd);
348
+ g_mousefd = -1;
349
+ return -1;
350
+ }
351
+ close(g_mousefd);
352
+ g_mousefd = -1;
353
+ setMouseMode(0);
354
+ return 0;
355
+}
356
+
357
+int setup_virtual_input_dev(char *inputdev_name)
358
+{
359
+ int i;
360
+ int uinputfd = -1;
361
+
362
+ ALOGD("multi_ir open uinput dev");
363
+
364
+ uinputfd = open(UINPUT_NAME, O_WRONLY | O_NDELAY);
365
+ if (uinputfd <= 0) {
366
+ ALOGE("could not open '%s', %s\n", UINPUT_NAME, strerror(errno));
367
+ return uinputfd;
368
+ }
369
+
370
+ memset(&virtual_inputdev, 0, sizeof(virtual_inputdev));
371
+ strncpy(virtual_inputdev.name, inputdev_name, UINPUT_MAX_NAME_SIZE);
372
+ virtual_inputdev.id.version = 4;
373
+ virtual_inputdev.id.bustype = BUS_HOST;
374
+ ioctl(uinputfd, UI_SET_EVBIT, EV_KEY);
375
+ ioctl(uinputfd, UI_SET_EVBIT, EV_MSC);
376
+ ioctl(uinputfd, UI_SET_EVBIT, EV_REP);
377
+
378
+ /* register a cursor device */
379
+ ioctl(uinputfd, UI_SET_KEYBIT, BTN_MOUSE);
380
+ ioctl(uinputfd, UI_SET_RELBIT, REL_X);
381
+ ioctl(uinputfd, UI_SET_RELBIT, REL_Y);
382
+ ioctl(uinputfd, UI_SET_EVBIT, EV_REL);
383
+#if 0
384
+ /* setup mouse coordinate event */
385
+ ioctl(uinputfd, UI_SET_EVBIT, EV_REL);
386
+ ioctl(uinputfd, UI_SET_RELBIT, REL_X);
387
+ ioctl(uinputfd, UI_SET_RELBIT, REL_Y);
388
+
389
+ /* setup mouse button event */
390
+ ioctl(uinputfd, UI_SET_KEYBIT, BTN_MOUSE);
391
+ ioctl(uinputfd, UI_SET_KEYBIT, BTN_TOUCH);
392
+ ioctl(uinputfd, UI_SET_KEYBIT, BTN_LEFT);
393
+ ioctl(uinputfd, UI_SET_KEYBIT, BTN_RIGHT);
394
+ ioctl(uinputfd, UI_SET_KEYBIT, BTN_MIDDLE);
395
+#endif
396
+
397
+ for (i = KEYCODE_MIN; i < KEYCODE_CNT; i++)
398
+ ioctl(uinputfd, UI_SET_KEYBIT, i);
399
+
400
+ /* create input device into input subsystem */
401
+ write(uinputfd, &virtual_inputdev, sizeof(virtual_inputdev));
402
+ if (ioctl(uinputfd, UI_DEV_CREATE)) {
403
+ ALOGE("could not create uinput device, %s\n", strerror(errno));
404
+ close(uinputfd);
405
+ uinputfd = -1;
406
+ return uinputfd;
407
+ }
408
+
409
+ g_uinputfd = uinputfd;
410
+ return uinputfd;
411
+}
412
+
413
+void report_key_event(int uinputfd, struct input_event *event, int sync)
414
+{
415
+ struct input_event temp_event;
416
+
417
+ write(uinputfd, event, sizeof(struct input_event));
418
+
419
+ if (sync) {
420
+ memset(&temp_event, 0, sizeof(struct input_event));
421
+ temp_event.type = EV_SYN;
422
+ temp_event.code = SYN_REPORT;
423
+ temp_event.value = 0;
424
+ write(uinputfd, &temp_event, sizeof(struct input_event));
425
+ }
426
+}
427
+
428
+#define POWER_KEY (0x74)
429
+void report_standby_request(void)
430
+{
431
+ int uinputfd = g_uinputfd;
432
+ struct input_event event;
433
+
434
+ if (uinputfd<0)
435
+ return;
436
+
437
+ memset(&event, 0, sizeof(event));
438
+ gettimeofday(&event.time, NULL);
439
+ event.type = EV_KEY;
440
+ event.code = POWER_KEY;
441
+ event.value = 1;
442
+ write(uinputfd, &event, sizeof(event));
443
+
444
+ event.type = EV_SYN;
445
+ event.code = SYN_REPORT;
446
+ event.value = 0;
447
+ write(uinputfd, &event, sizeof(event));
448
+
449
+ memset(&event, 0, sizeof(event));
450
+ gettimeofday(&event.time, NULL);
451
+ event.type = EV_KEY;
452
+ event.code = POWER_KEY;
453
+ event.value = 0;
454
+ write(uinputfd, &event, sizeof(event));
455
+
456
+ event.type = EV_SYN;
457
+ event.code = SYN_REPORT;
458
+ event.value = 0;
459
+ write(uinputfd, &event, sizeof(event));
460
+}
android/vendor/aw/homlet/hardware/input/multi_ir/core/virtual_input.h
....@@ -0,0 +1,52 @@
1
+/*
2
+ * multi ir daemon for android -
3
+ * Copyright (C) 2015-2018 AllwinnerTech
4
+ *
5
+ * This program is free software; you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation; either version 2 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program; if not, write to the Free Software
17
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ *
19
+ */
20
+
21
+#ifndef __virtual_input_h
22
+#define __virtual_input_h
23
+
24
+#include <linux/input.h>
25
+
26
+struct inputdev_info {
27
+ char devpath[PATH_MAX];
28
+ char name[80];
29
+ char location[80];
30
+ char idstr[80];
31
+
32
+ struct input_id id;
33
+ int version;
34
+
35
+ int fd;
36
+ int idx;
37
+};
38
+
39
+int setup_virtual_input_dev(char *inputdev_name);
40
+int destory_virtual_mouse_dev(void);
41
+int create_virtual_mouse_dev(char *mouse_dev);
42
+int try_to_find_device(const char *devname, char *path);
43
+struct inputdev_info *open_device(const char *devpath, struct pollfd *ufds);
44
+int notify_process(struct inputdev_info * sourcedev, char *device_name, const char *dirname, int nfd, struct pollfd *ufds);
45
+int input_event_process(int nfd, struct input_event *event);
46
+void report_key_event(int uinputfd, struct input_event *event, int sync);
47
+int get_default_pointerspeed(void);
48
+int get_default_stepdistance(void);
49
+void set_pointerspeed(int ms);
50
+void set_stepdistance(int px);
51
+void reset(void);
52
+#endif
android/vendor/aw/homlet/hardware/input/multi_ir/jni/Android.mk
....@@ -0,0 +1,34 @@
1
+LOCAL_PATH:= $(call my-dir)
2
+include $(CLEAR_VARS)
3
+
4
+LOCAL_SRC_FILES:= \
5
+ com_softwinner_multiir.cpp
6
+
7
+LOCAL_SHARED_LIBRARIES := \
8
+ libandroid_runtime \
9
+ libnativehelper \
10
+ libutils \
11
+ libbinder \
12
+ libui \
13
+ libcutils \
14
+ libmultiirservice
15
+
16
+LOCAL_STATIC_LIBRARIES :=
17
+
18
+LOCAL_C_INCLUDES += \
19
+ frameworks/base/core/jni \
20
+ $(LOCAL_PATH)/../libmultiir \
21
+ libnativehelper/include/nativehelper
22
+
23
+LOCAL_CFLAGS += -Wno-unused-parameter
24
+
25
+LOCAL_MODULE_TAGS := optional
26
+
27
+LOCAL_LDLIBS := -llog
28
+
29
+LOCAL_MODULE:= libmultiir_jni
30
+
31
+LOCAL_PRELINK_MODULE:= false
32
+
33
+include $(BUILD_SHARED_LIBRARY)
34
+
android/vendor/aw/homlet/hardware/input/multi_ir/jni/com_softwinner_multiir.cpp
....@@ -0,0 +1,173 @@
1
+/*
2
+**
3
+** Copyright 2006, The Android Open Source Project
4
+**
5
+** Licensed under the Apache License, Version 2.0 (the "License");
6
+** you may not use this file except in compliance with the License.
7
+** You may obtain a copy of the License at
8
+**
9
+** http://www.apache.org/licenses/LICENSE-2.0
10
+**
11
+** Unless required by applicable law or agreed to in writing, software
12
+** distributed under the License is distributed on an "AS IS" BASIS,
13
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+** See the License for the specific language governing permissions and
15
+** limitations under the License.
16
+*/
17
+
18
+#define LOG_TAG "JNIMultiir"
19
+#define LOG_NDEBUG 0
20
+
21
+#include "JNIHelp.h"
22
+#include "jni.h"
23
+#include "android_runtime/AndroidRuntime.h"
24
+#include "utils/Errors.h"
25
+#include "utils/String8.h"
26
+#include "android_util_Binder.h"
27
+#include <stdio.h>
28
+#include <assert.h>
29
+#include <binder/IServiceManager.h>
30
+#include <binder/IPCThreadState.h>
31
+#include "IMultiirService.h"
32
+
33
+using namespace android;
34
+
35
+static sp<IMultiirService> multiirService;
36
+
37
+static int init_native(JNIEnv *env) {
38
+ int time = 100;
39
+ ALOGD("init");
40
+ sp<IServiceManager> sm = defaultServiceManager();
41
+ sp<IBinder> binder;
42
+ do {
43
+ binder = sm->getService(String16("softwinner.multi_ir"));
44
+ if(binder != 0){
45
+ multiirService = interface_cast<IMultiirService>(binder);
46
+ return 0;
47
+ }
48
+ ALOGW("softwinner multiir service not published, waiting...");
49
+ usleep(500000);
50
+ } while(time--);
51
+
52
+ return -1;
53
+}
54
+
55
+static void throw_NullPointerException(JNIEnv *env, const char* msg) {
56
+ jclass clazz;
57
+ clazz = env->FindClass("java/lang/NullPointerException");
58
+ env->ThrowNew(clazz, msg);
59
+}
60
+
61
+static int enterMouseMode(JNIEnv *env, jobject clazz) {
62
+ if(multiirService == NULL){
63
+ ALOGW("softwinner multiir service is not fount");
64
+ return -1;
65
+ }
66
+ int ret = multiirService->enterMouseMode();
67
+ return ret;
68
+}
69
+
70
+static int exitMouseMode(JNIEnv *env, jobject clazz) {
71
+ if(multiirService == NULL){
72
+ ALOGW("softwinner multiir service is not fount");
73
+ return -1;
74
+ }
75
+ int ret = multiirService->exitMouseMode();
76
+ return ret;
77
+}
78
+
79
+static int getDefaultPointerSpeed(JNIEnv *env, jobject clazz) {
80
+ if(multiirService == NULL){
81
+ ALOGW("softwinner multiir service is not fount");
82
+ return -1;
83
+ }
84
+ int ret = multiirService->getDefaultPointerSpeed();
85
+ return ret;
86
+}
87
+
88
+static int getDefaultStepDistance(JNIEnv *env, jobject clazz) {
89
+ if(multiirService == NULL){
90
+ ALOGW("softwinner multiir service is not fount");
91
+ return -1;
92
+ }
93
+ int ret = multiirService->getDefaultStepDistance();
94
+ return ret;
95
+}
96
+
97
+static int reset(JNIEnv *env, jobject clazz) {
98
+ if(multiirService == NULL){
99
+ ALOGW("softwinner multiir service is not fount");
100
+ return -1;
101
+ }
102
+ int ret = multiirService->reset();
103
+ return ret;
104
+}
105
+
106
+static int setPointerSpeed(JNIEnv *env, jobject clazz, jint ms) {
107
+ if(multiirService == NULL){
108
+ ALOGW("softwinner multiir service is not fount");
109
+ return -1;
110
+ }
111
+ int ret = multiirService->setPointerSpeed(ms);
112
+ return ret;
113
+}
114
+
115
+static int setStepDistance(JNIEnv *env, jobject clazz, jint px) {
116
+ if(multiirService == NULL){
117
+ ALOGW("softwinner multiir service is not fount");
118
+ return -1;
119
+ }
120
+ int ret = multiirService->setStepDistance(px);
121
+ return ret;
122
+}
123
+
124
+static int reportMouseKeyEvent(JNIEnv *env, jobject clazz, jint scanCode, jint keyState) {
125
+ if(multiirService == NULL){
126
+ ALOGW("softwinner multiir service is not fount");
127
+ return -1;
128
+ }
129
+ int ret = multiirService->reportMouseKeyEvent(scanCode, keyState);
130
+ return ret;
131
+}
132
+
133
+static JNINativeMethod method_table[] = {
134
+ { "_nativeInit", "()I", (void*)init_native},
135
+ { "_enterMouseMode", "()I", (void*)enterMouseMode },
136
+ { "_exitMouseMode", "()I", (void*)exitMouseMode },
137
+ { "_getDefaultPointerSpeed", "()I", (void*)getDefaultPointerSpeed },
138
+ { "_getDefaultStepDistance", "()I", (void*)getDefaultStepDistance },
139
+ { "_reset", "()I", (void*)reset },
140
+ { "_setPointerSpeed", "(I)I", (void*)setPointerSpeed },
141
+ { "_setStepDistance", "(I)I", (void*)setStepDistance },
142
+ { "_reportMouseKeyEvent", "(II)I", (void*)reportMouseKeyEvent },
143
+};
144
+
145
+static int register_android_os_Multiir(JNIEnv *env){
146
+ return AndroidRuntime::registerNativeMethods(
147
+ env, "com/softwinner/Multiir",method_table, NELEM(method_table));
148
+}
149
+
150
+jint JNI_OnLoad(JavaVM* vm, void* reserved){
151
+ JNIEnv* env = NULL;
152
+ jint result = -1;
153
+
154
+ ALOGD("Multiir JNI_OnLoad()");
155
+
156
+ if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
157
+ ALOGE("ERROR: GetEnv failed\n");
158
+ goto bail;
159
+ }
160
+ assert(env != NULL);
161
+
162
+ if (register_android_os_Multiir(env) < 0) {
163
+ ALOGE("ERROR: Multiir native registration failed\n");
164
+ goto bail;
165
+ }
166
+
167
+ /* success -- return valid version number */
168
+ result = JNI_VERSION_1_4;
169
+
170
+bail:
171
+ return result;
172
+}
173
+
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/Vendor_000d_Product_3838.kl
....@@ -0,0 +1,11 @@
1
+key 1 BACK
2
+key 127 MENU
3
+key 353 DPAD_CENTER
4
+key 108 DPAD_DOWN
5
+key 103 DPAD_UP
6
+key 240 HOME
7
+key 105 DPAD_LEFT
8
+key 106 DPAD_RIGHT
9
+key 233 VOLUME_UP
10
+key 234 VOLUME_DOWN
11
+key 116 POWER
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_2992.kl
....@@ -0,0 +1,36 @@
1
+key 39 BACK
2
+key 27 MENU
3
+key 54 SEARCH
4
+key 55 DPAD_CENTER
5
+key 40 DPAD_DOWN
6
+key 42 DPAD_UP
7
+key 43 HOME
8
+key 26 DPAD_LEFT
9
+key 41 DPAD_RIGHT
10
+key 24 VOLUME_UP
11
+key 23 VOLUME_DOWN
12
+key 242 POWER
13
+key 49 0
14
+key 22 1
15
+key 52 2
16
+key 36 3
17
+key 21 4
18
+key 51 5
19
+key 35 6
20
+key 20 7
21
+key 50 8
22
+key 34 9
23
+key 45 MEDIA_PLAY_PAUSE
24
+key 57 MEDIA_STOP
25
+key 28 MEDIA_PREVIOUS
26
+key 44 MEDIA_NEXT
27
+key 56 MEDIA_REWIND
28
+key 61 MEDIA_FAST_FORWARD
29
+key 63 VOLUME_MUTE
30
+key 59 TV_SYSTEM
31
+key 47 SETTINGS
32
+key 16 PROG_RED
33
+key 30 PROG_BLUE
34
+key 46 PROG_GREEN
35
+key 58 PROG_YELLOW
36
+key 32 MOUSE
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_4040.kl
....@@ -0,0 +1,25 @@
1
+key 66 BACK
2
+key 69 MENU
3
+key 13 DPAD_CENTER
4
+key 14 DPAD_DOWN
5
+key 11 DPAD_UP
6
+key 26 HOME
7
+key 16 DPAD_LEFT
8
+key 17 DPAD_RIGHT
9
+key 24 VOLUME_UP
10
+key 23 VOLUME_DOWN
11
+key 77 POWER
12
+key 0 0
13
+key 1 1
14
+key 2 2
15
+key 3 3
16
+key 4 4
17
+key 5 5
18
+key 6 6
19
+key 7 7
20
+key 8 8
21
+key 9 9
22
+key 67 VOLUME_MUTE
23
+key 71 MOUSE
24
+key 12 DEL
25
+key 83 APP_VIDEO
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_4cb3.kl
....@@ -0,0 +1,53 @@
1
+key 197 BACK
2
+#key 93 MENU
3
+#key 13 SEARCH
4
+key 206 DPAD_CENTER
5
+key 210 DPAD_DOWN
6
+key 202 DPAD_UP
7
+key 136 HOME
8
+key 153 DPAD_LEFT
9
+key 193 DPAD_RIGHT
10
+key 128 VOLUME_UP
11
+key 129 VOLUME_DOWN
12
+key 220 POWER
13
+key 135 0
14
+key 146 1
15
+key 147 2
16
+key 204 3
17
+key 142 4
18
+key 143 5
19
+key 200 6
20
+key 138 7
21
+key 139 8
22
+key 196 9
23
+
24
+key 149 MEDIA_PLAY_PAUSE
25
+#key 19 MEDIA_STOP
26
+key 221 MEDIA_PREVIOUS
27
+key 140 MEDIA_NEXT
28
+key 157 MEDIA_REWIND
29
+key 158 MEDIA_FAST_FORWARD
30
+key 156 VOLUME_MUTE
31
+#key 4 TV_SYSTEM
32
+#key 70 SUBTITLE
33
+key 152 AUDIO
34
+key 141 SETTINGS
35
+key 205 PROG_RED
36
+key 195 PROG_BLUE
37
+key 145 PROG_GREEN
38
+key 131 PROG_YELLOW
39
+#key 5 HELP
40
+key 155 FAVOURITE
41
+key 214 LOOP
42
+key 130 EXPAND
43
+#key 12 ZOOM_IN
44
+#key 88 ZOOM_OUT
45
+#key 27 MOUSE
46
+#key 84 MOVIE
47
+#key 91 APPS
48
+#key 23 BROWSER
49
+#key 16 INFO
50
+key 133 CHANNEL_UP
51
+key 134 CHANNEL_DOWN
52
+key 208 POUND
53
+key 218 STAR
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_7f80.kl
....@@ -0,0 +1,37 @@
1
+key 27 BACK WAKE_DROPPED
2
+key 73 MENU WAKE_DROPPED
3
+key 13 DPAD_CENTER WAKE_DROPPED
4
+key 40 DPAD_DOWN WAKE_DROPPED
5
+key 38 DPAD_UP WAKE_DROPPED
6
+key 83 HOME WAKE
7
+key 37 DPAD_LEFT WAKE_DROPPED
8
+key 39 DPAD_RIGHT WAKE_DROPPED
9
+key 78 VOLUME_UP WAKE
10
+key 86 VOLUME_DOWN WAKE
11
+key 81 POWER WAKE
12
+key 48 0 WAKE
13
+key 49 1 WAKE
14
+key 50 2 WAKE
15
+key 51 3 WAKE
16
+key 52 4 WAKE
17
+key 53 5 WAKE
18
+key 54 6 WAKE
19
+key 55 7 WAKE
20
+key 56 8 WAKE
21
+key 57 9 WAKE
22
+key 77 VOLUME_MUTE WAKE
23
+key 09 PROG_RED WAKE
24
+key 17 PROG_GREEN WAKE
25
+key 84 PROG_YELLOW WAKE
26
+key 79 PROG_BLUE WAKE
27
+key 187 MEDIA_NEXT WAKE
28
+key 189 MEDIA_PREVIOUS WAKE
29
+#key 83 MEDIA_PLAY_PAUSE
30
+key 68 DEL WAKE
31
+key 82 MOUSE WAKE
32
+key 88 PERIOD WAKE
33
+key 28 ENTER WAKE
34
+#key 205 TV WAKE
35
+#key 145 MOVIE WAKE
36
+#key 131 APPS WAKE
37
+#key 195 FAVOURITE WAKE
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_9f00.kl
....@@ -0,0 +1,48 @@
1
+key 79 BACK
2
+key 22 MENU
3
+key 13 SEARCH
4
+key 2 DPAD_CENTER
5
+key 10 DPAD_DOWN
6
+key 67 DPAD_UP
7
+key 71 HOME
8
+key 6 DPAD_LEFT
9
+key 14 DPAD_RIGHT
10
+key 0 VOLUME_UP
11
+key 93 VOLUME_DOWN
12
+key 87 POWER
13
+key 90 0
14
+key 26 1
15
+key 1 2
16
+key 69 3
17
+key 89 4
18
+key 77 5
19
+key 64 6
20
+key 82 7
21
+key 83 8
22
+key 65 9
23
+key 80 MEDIA_PLAY_PAUSE
24
+key 19 MEDIA_STOP
25
+key 15 MEDIA_PREVIOUS
26
+key 11 MEDIA_NEXT
27
+key 7 MEDIA_REWIND
28
+key 3 MEDIA_FAST_FORWARD
29
+key 92 VOLUME_MUTE
30
+key 4 TV_SYSTEM
31
+key 70 SUBTITLE
32
+key 68 AUDIO
33
+key 9 SETTINGS
34
+key 85 PROG_RED
35
+key 72 PROG_BLUE
36
+key 78 PROG_GREEN
37
+key 73 PROG_YELLOW
38
+key 5 HELP
39
+key 21 FAVOURITE
40
+key 8 LOOP
41
+key 20 EXPAND
42
+key 12 ZOOM_IN
43
+key 88 ZOOM_OUT
44
+key 17 MOUSE
45
+key 84 MOVIE
46
+key 91 APPS
47
+key 23 BROWSER
48
+key 16 INFO
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_ba04.kl
....@@ -0,0 +1 @@
1
+key 06 F10 WAKE_DROPPED
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_bc00.kl
....@@ -0,0 +1,34 @@
1
+key 72 BACK
2
+key 20 MENU
3
+key 21 DPAD_CENTER
4
+key 23 DPAD_DOWN
5
+key 22 DPAD_UP
6
+key 148 HOME
7
+key 25 DPAD_LEFT
8
+key 24 DPAD_RIGHT
9
+key 68 VOLUME_UP
10
+key 67 VOLUME_DOWN
11
+key 13 POWER
12
+key 0 0
13
+key 1 1
14
+key 2 2
15
+key 3 3
16
+key 4 4
17
+key 5 5
18
+key 6 6
19
+key 7 7
20
+key 8 8
21
+key 9 9
22
+key 78 MEDIA_PLAY_PAUSE
23
+key 90 MEDIA_STOP
24
+key 14 VOLUME_MUTE
25
+key 27 TV_SYSTEM
26
+key 152 SETTINGS
27
+key 98 PROG_RED
28
+key 101 PROG_BLUE
29
+key 99 PROG_GREEN
30
+key 100 PROG_YELLOW
31
+key 15 MENU
32
+key 77 HISENSE_FAC_NEC_DMP
33
+
34
+
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_dd22.kl
....@@ -0,0 +1,47 @@
1
+key 130 HOME
2
+key 149 BACK
3
+key 135 0
4
+key 146 1
5
+key 147 2
6
+key 204 3
7
+key 142 4
8
+key 143 5
9
+key 200 6
10
+key 138 7
11
+key 139 8
12
+key 196 9
13
+key 202 DPAD_UP
14
+key 210 DPAD_DOWN
15
+key 153 DPAD_LEFT
16
+key 193 DPAD_RIGHT
17
+key 206 DPAD_CENTER
18
+key 128 VOLUME_UP
19
+key 129 VOLUME_DOWN
20
+key 220 POWER
21
+key 197 MENU
22
+key 217 MEDIA_PLAY_PAUSE
23
+key 132 MEDIA_FAST_FORWARD
24
+key 137 MEDIA_REWIND
25
+#key 89 MEDIA_REWIND
26
+key 156 MUTE
27
+key 221 PAGE_UP
28
+key 140 PAGE_DOWN
29
+key 150 MEDIA_STOP
30
+key 125 FORWARD
31
+key 164 VOLUME_MUTE
32
+key 133 CHANNEL_UP
33
+key 134 CHANNEL_DOWN
34
+key 141 SETTINGS
35
+#set181 =app_firstpage
36
+key 136 AVR_POWER
37
+#set182 =Fast switching
38
+key 214 AVR_INPUT
39
+key 205 PROG_RED
40
+key 145 PROG_GREEN
41
+key 131 PROG_YELLOW
42
+key 195 PROG_BLUE
43
+#set209 =Switch the channel
44
+key 152 MUSIC
45
+key 218 POUND
46
+key 208 STAR
47
+
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_fb04.kl
....@@ -0,0 +1,48 @@
1
+key 10 BACK
2
+key 93 MENU
3
+#key 13 SEARCH
4
+key 92 DPAD_CENTER
5
+key 29 DPAD_DOWN
6
+key 68 DPAD_UP
7
+key 31 HOME
8
+key 28 DPAD_LEFT
9
+key 72 DPAD_RIGHT
10
+key 69 VOLUME_UP
11
+key 25 VOLUME_DOWN
12
+key 26 POWER
13
+key 71 0
14
+key 19 1
15
+key 16 2
16
+key 17 3
17
+key 15 4
18
+key 12 5
19
+key 13 6
20
+key 11 7
21
+key 8 8
22
+key 9 9
23
+key 80 MEDIA_PLAY_PAUSE
24
+#key 19 MEDIA_STOP
25
+#key 11 MEDIA_PREVIOUS
26
+#key 15 MEDIA_NEXT
27
+key 7 MEDIA_REWIND
28
+key 3 MEDIA_FAST_FORWARD
29
+key 35 VOLUME_MUTE
30
+key 4 TV_SYSTEM
31
+key 70 SUBTITLE
32
+#key 68 AUDIO
33
+key 83 SETTINGS
34
+key 85 PROG_RED
35
+#key 72 PROG_BLUE
36
+key 78 PROG_GREEN
37
+key 73 PROG_YELLOW
38
+key 5 HELP
39
+key 21 FAVOURITE
40
+#key 8 LOOP
41
+key 20 EXPAND
42
+#key 12 ZOOM_IN
43
+key 88 ZOOM_OUT
44
+key 27 MOUSE
45
+key 84 MOVIE
46
+key 91 APPS
47
+key 23 BROWSER
48
+#key 16 INFO
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_fc00.kl
....@@ -0,0 +1,12 @@
1
+key 93 F1
2
+key 66 F2
3
+key 86 F3
4
+key 72 F4
5
+key 83 F5
6
+key 29 BACK
7
+key 79 F7
8
+key 71 HISENSE_FAC_NEC_OK
9
+key 10 HISENSE_FAC_NEC_MAC
10
+key 78 HISENSE_FAC_NEC_IP
11
+key 0 HISENSE_FAC_NEC_M
12
+key 21 HISENSE_FAC_NEC_AGING
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_fe01.kl
....@@ -0,0 +1,33 @@
1
+key 25 BACK
2
+key 76 MENU
3
+key 19 DPAD_CENTER
4
+key 26 DPAD_DOWN
5
+key 22 DPAD_UP
6
+key 17 HOME
7
+key 81 DPAD_LEFT
8
+key 80 DPAD_RIGHT
9
+key 24 VOLUME_UP
10
+key 16 VOLUME_DOWN
11
+key 15 APPS
12
+key 67 SETTINGS
13
+key 64 POWER
14
+key 1 0
15
+key 78 1
16
+key 13 2
17
+key 12 3
18
+key 74 4
19
+key 9 5
20
+key 8 6
21
+key 70 7
22
+key 5 8
23
+key 4 9
24
+key 65 VOLUME_MUTE
25
+key 0 MOUSE
26
+key 213 CALCULATOR
27
+key 75 MEDIA_PREVIOUS
28
+key 79 MEDIA_NEXT
29
+key 66 DEL
30
+key 02 CALENDAR
31
+key 33 ZOOM_IN
32
+key 34 ZOOM_OUT
33
+key 35 INFO
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_fe01_petrel.kl
....@@ -0,0 +1,33 @@
1
+key 25 BACK
2
+key 0 MENU
3
+key 19 DPAD_CENTER
4
+key 26 DPAD_DOWN
5
+key 22 DPAD_UP
6
+key 17 HOME
7
+key 81 DPAD_LEFT
8
+key 80 DPAD_RIGHT
9
+key 24 VOLUME_UP
10
+key 16 VOLUME_DOWN
11
+key 15 APPS
12
+key 67 CONTACTS
13
+key 64 POWER
14
+key 1 0
15
+key 78 1
16
+key 13 2
17
+key 12 3
18
+key 74 4
19
+key 9 5
20
+key 8 6
21
+key 70 7
22
+key 5 8
23
+key 4 9
24
+key 65 VOLUME_MUTE
25
+key 76 MOUSE
26
+key 213 CALCULATOR
27
+key 75 MEDIA_PREVIOUS
28
+key 79 MEDIA_NEXT
29
+key 66 DEL
30
+key 02 CALENDAR
31
+key 33 ZOOM_IN
32
+key 34 ZOOM_OUT
33
+key 35 INFO
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_ir_ff00.kl
....@@ -0,0 +1,35 @@
1
+key 64 BACK
2
+key 4 MENU
3
+key 85 DPAD_CENTER
4
+key 22 DPAD_DOWN
5
+key 70 DPAD_UP
6
+key 78 HOME
7
+key 71 DPAD_LEFT
8
+key 21 DPAD_RIGHT
9
+key 20 VOLUME_UP
10
+key 16 VOLUME_DOWN
11
+key 24 POWER
12
+key 29 0
13
+key 15 1
14
+key 17 2
15
+key 18 3
16
+key 76 4
17
+key 88 5
18
+key 27 6
19
+key 23 7
20
+key 77 8
21
+key 10 9
22
+key 91 VOLUME_MUTE
23
+key 90 PROG_RED
24
+key 2 PROG_BLUE
25
+key 13 PROG_GREEN
26
+key 6 PROG_YELLOW
27
+key 80 MEDIA_NEXT
28
+key 82 MEDIA_PREVIOUS
29
+key 79 SETTINGS
30
+key 30 DEL
31
+key 28 ENTER
32
+key 205 TV
33
+key 145 MOVIE
34
+key 131 APPS
35
+key 195 FAVOURITE
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/customer_rc5_ir_04.kl
....@@ -0,0 +1,7 @@
1
+key 20 DPAD_DOWN
2
+key 14 DPAD_UP
3
+key 16 DPAD_LEFT
4
+key 18 DPAD_RIGHT
5
+key 1 POWER
6
+key 17 STAR
7
+key 14 BACK
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/sunxi-ir-recovery.kl
....@@ -0,0 +1,19 @@
1
+key 102 HOME
2
+key 158 BACK
3
+key 11 0
4
+key 2 1
5
+key 3 2
6
+key 4 3
7
+key 5 4
8
+key 6 5
9
+key 7 6
10
+key 8 7
11
+key 9 8
12
+key 10 9
13
+key 103 DPAD_UP
14
+key 108 DPAD_DOWN
15
+key 105 DPAD_LEFT
16
+key 106 DPAD_RIGHT
17
+key 28 DPAD_CENTER
18
+key 114 VOLUME_DOWN
19
+key 115 VOLUME_UP
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/sunxi-ir-uinput.kl
....@@ -0,0 +1,244 @@
1
+key 1 SOFT_LEFT
2
+key 2 SOFT_RIGHT
3
+key 3 HOME
4
+key 4 BACK
5
+key 5 CALL
6
+key 6 ENDCALL
7
+key 7 0
8
+key 8 1
9
+key 9 2
10
+key 10 3
11
+key 11 4
12
+key 12 5
13
+key 13 6
14
+key 14 7
15
+key 15 8
16
+key 16 9
17
+key 17 STAR
18
+key 18 POUND
19
+key 19 DPAD_UP
20
+key 20 DPAD_DOWN
21
+key 21 DPAD_LEFT
22
+key 22 DPAD_RIGHT
23
+key 23 DPAD_CENTER
24
+key 24 VOLUME_UP
25
+key 25 VOLUME_DOWN
26
+key 26 SCROLL_LOCK
27
+key 27 CAMERA
28
+key 28 CLEAR
29
+key 29 A
30
+key 30 B
31
+key 31 C
32
+key 32 D
33
+key 33 E
34
+key 34 F
35
+key 35 G
36
+key 36 H
37
+key 37 I
38
+key 38 J
39
+key 39 K
40
+key 40 L
41
+key 41 M
42
+key 42 N
43
+key 43 O
44
+key 44 P
45
+key 45 Q
46
+key 46 R
47
+key 47 S
48
+key 48 T
49
+key 49 U
50
+key 50 V
51
+key 51 W
52
+key 52 X
53
+key 53 Y
54
+key 54 Z
55
+key 55 COMMA
56
+key 56 PERIOD
57
+key 57 ALT_LEFT
58
+key 58 ALT_RIGHT
59
+key 59 SHIFT_LEFT
60
+key 60 SHIFT_RIGHT
61
+key 61 TAB
62
+key 62 SPACE
63
+key 63 SYM
64
+key 64 EXPLORER
65
+key 65 ENVELOPE
66
+key 66 ENTER
67
+key 67 DEL
68
+key 68 GRAVE
69
+key 69 MINUS
70
+key 70 EQUALS
71
+key 71 LEFT_BRACKET
72
+key 72 RIGHT_BRACKET
73
+key 73 BACKSLASH
74
+key 74 SEMICOLON
75
+key 75 APOSTROPHE
76
+key 76 SLASH
77
+key 77 AT
78
+key 78 NUM
79
+key 79 HEADSETHOOK
80
+key 80 FOCUS
81
+key 81 PLUS
82
+key 82 MENU
83
+key 83 NOTIFICATION
84
+key 84 SEARCH
85
+key 85 MEDIA_PLAY_PAUSE
86
+key 86 MEDIA_STOP
87
+key 87 MEDIA_NEXT
88
+key 88 MEDIA_PREVIOUS
89
+key 89 MEDIA_REWIND
90
+key 90 MEDIA_FAST_FORWARD
91
+key 91 MUTE
92
+key 92 PAGE_UP
93
+key 93 PAGE_DOWN
94
+key 94 PICTSYMBOLS
95
+key 95 SWITCH_CHARSET
96
+# ir keyboard dont need gamepad key, fix kodi can not use ir keyboard
97
+#key 96 BUTTON_A
98
+#key 97 BUTTON_B
99
+#key 98 BUTTON_C
100
+#key 99 BUTTON_X
101
+#key 100 BUTTON_Y
102
+#key 101 BUTTON_Z
103
+#key 102 BUTTON_L1
104
+#key 103 BUTTON_R1
105
+#key 104 BUTTON_L2
106
+#key 105 BUTTON_R2
107
+#key 106 BUTTON_THUMBL
108
+#key 107 BUTTON_THUMBR
109
+#key 108 BUTTON_START
110
+#key 109 BUTTON_SELECT
111
+#key 110 BUTTON_MODE
112
+key 111 ESCAPE
113
+key 112 FORWARD_DEL
114
+key 113 CTRL_LEFT
115
+key 114 CTRL_RIGHT
116
+key 115 CAPS_LOCK
117
+key 116 POWER
118
+key 117 META_LEFT
119
+key 118 META_RIGHT
120
+key 119 FUNCTION
121
+key 120 SYSRQ
122
+key 121 BREAK
123
+key 122 MOVE_HOME
124
+key 123 MOVE_END
125
+key 124 INSERT
126
+key 125 FORWARD
127
+key 126 MEDIA_PLAY
128
+key 127 MEDIA_PAUSE
129
+key 128 MEDIA_CLOSE
130
+key 129 MEDIA_EJECT
131
+key 130 MEDIA_RECORD
132
+key 131 F1
133
+key 132 F2
134
+key 133 F3
135
+key 134 F4
136
+key 135 F5
137
+key 136 F6
138
+key 137 F7
139
+key 138 F8
140
+key 139 F9
141
+key 140 F10
142
+key 141 F11
143
+key 142 F12
144
+key 143 NUM_LOCK
145
+key 144 NUMPAD_0
146
+key 145 NUMPAD_1
147
+key 146 NUMPAD_2
148
+key 147 NUMPAD_3
149
+key 148 NUMPAD_4
150
+key 149 NUMPAD_5
151
+key 150 NUMPAD_6
152
+key 151 NUMPAD_7
153
+key 152 NUMPAD_8
154
+key 153 NUMPAD_9
155
+key 154 NUMPAD_DIVIDE
156
+key 155 NUMPAD_MULTIPLY
157
+key 156 NUMPAD_SUBTRACT
158
+key 157 NUMPAD_ADD
159
+key 158 NUMPAD_DOT
160
+key 159 NUMPAD_COMMA
161
+key 160 NUMPAD_ENTER
162
+key 161 NUMPAD_EQUALS
163
+key 162 NUMPAD_LEFT_PAREN
164
+key 163 NUMPAD_RIGHT_PAREN
165
+key 164 VOLUME_MUTE
166
+key 165 INFO
167
+key 166 CHANNEL_UP
168
+key 167 CHANNEL_DOWN
169
+key 168 ZOOM_IN
170
+key 169 ZOOM_OUT
171
+key 170 TV
172
+key 171 WINDOW
173
+key 172 GUIDE
174
+key 173 DVR
175
+key 174 BOOKMARK
176
+key 175 CAPTIONS
177
+key 176 SETTINGS
178
+key 177 TV_POWER
179
+key 178 TV_INPUT
180
+key 179 STB_INPUT
181
+key 180 STB_POWER
182
+key 181 AVR_POWER
183
+key 182 AVR_INPUT
184
+key 183 PROG_RED
185
+key 184 PROG_GREEN
186
+key 185 PROG_YELLOW
187
+key 186 PROG_BLUE
188
+key 187 APP_SWITCH
189
+key 188 BUTTON_1
190
+key 189 BUTTON_2
191
+key 190 BUTTON_3
192
+key 191 BUTTON_4
193
+key 192 BUTTON_5
194
+key 193 BUTTON_6
195
+key 194 BUTTON_7
196
+key 195 BUTTON_8
197
+key 196 BUTTON_9
198
+key 197 BUTTON_10
199
+key 198 BUTTON_11
200
+key 199 BUTTON_12
201
+key 200 BUTTON_13
202
+key 201 BUTTON_14
203
+key 202 BUTTON_15
204
+key 203 BUTTON_16
205
+key 204 LANGUAGE_SWITCH
206
+key 205 MANNER_MODE
207
+key 206 3D_MODE
208
+key 207 CONTACTS
209
+key 208 CALENDAR
210
+key 209 MUSIC
211
+key 210 CALCULATOR
212
+key 211 ZENKAKU_HANKAKU
213
+key 212 EISU
214
+key 213 MUHENKAN
215
+key 214 HENKAN
216
+key 215 KATAKANA_HIRAGANA
217
+key 216 YEN
218
+key 217 RO
219
+key 218 KANA
220
+key 219 ASSIST
221
+key 220 BRIGHTNESS_DOWN
222
+key 221 BRIGHTNESS_UP
223
+key 222 MEDIA_AUDIO_TRACK
224
+key 223 TV_SYSTEM
225
+key 224 GOTO
226
+key 225 SUBTITLE
227
+key 226 AUDIO
228
+key 227 ZOOM
229
+key 228 HELP
230
+key 229 FAVOURITE
231
+key 230 LOOP
232
+key 231 EXPAND
233
+key 232 MOUSE
234
+key 233 MOVIE
235
+key 234 APPS
236
+key 235 BROWSER
237
+key 236 SCREENSHOT
238
+#key 237 HISENSE_FAC_NEC_DMP
239
+#key 238 HISENSE_FAC_NEC_OK
240
+#key 239 HISENSE_FAC_NEC_MAC
241
+#key 240 HISENSE_FAC_NEC_IP
242
+#key 241 HISENSE_FAC_NEC_M
243
+#key 242 HISENSE_FAC_NEC_AGING
244
+key 289 APP_VIDEO
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/sunxi-ir.kl
....@@ -0,0 +1,244 @@
1
+key 1 SOFT_LEFT
2
+key 2 SOFT_RIGHT
3
+key 3 HOME
4
+key 4 BACK
5
+key 5 CALL
6
+key 6 ENDCALL
7
+key 7 0
8
+key 8 1
9
+key 9 2
10
+key 10 3
11
+key 11 4
12
+key 12 5
13
+key 13 6
14
+key 14 7
15
+key 15 8
16
+key 16 9
17
+key 17 STAR
18
+key 18 POUND
19
+key 19 DPAD_UP
20
+key 20 DPAD_DOWN
21
+key 21 DPAD_LEFT
22
+key 22 DPAD_RIGHT
23
+key 23 DPAD_CENTER
24
+key 24 VOLUME_UP
25
+key 25 VOLUME_DOWN
26
+key 26 SCROLL_LOCK
27
+key 27 CAMERA
28
+key 28 CLEAR
29
+key 29 A
30
+key 30 B
31
+key 31 C
32
+key 32 D
33
+key 33 E
34
+key 34 F
35
+key 35 G
36
+key 36 H
37
+key 37 I
38
+key 38 J
39
+key 39 K
40
+key 40 L
41
+key 41 M
42
+key 42 N
43
+key 43 O
44
+key 44 P
45
+key 45 Q
46
+key 46 R
47
+key 47 S
48
+key 48 T
49
+key 49 U
50
+key 50 V
51
+key 51 W
52
+key 52 X
53
+key 53 Y
54
+key 54 Z
55
+key 55 COMMA
56
+key 56 PERIOD
57
+key 57 ALT_LEFT
58
+key 58 ALT_RIGHT
59
+key 59 SHIFT_LEFT
60
+key 60 SHIFT_RIGHT
61
+key 61 TAB
62
+key 62 SPACE
63
+key 63 SYM
64
+key 64 EXPLORER
65
+key 65 ENVELOPE
66
+key 66 ENTER
67
+key 67 DEL
68
+key 68 GRAVE
69
+key 69 MINUS
70
+key 70 EQUALS
71
+key 71 LEFT_BRACKET
72
+key 72 RIGHT_BRACKET
73
+key 73 BACKSLASH
74
+key 74 SEMICOLON
75
+key 75 APOSTROPHE
76
+key 76 SLASH
77
+key 77 AT
78
+key 78 NUM
79
+key 79 HEADSETHOOK
80
+key 80 FOCUS
81
+key 81 PLUS
82
+key 82 MENU
83
+key 83 NOTIFICATION
84
+key 84 SEARCH
85
+key 85 MEDIA_PLAY_PAUSE
86
+key 86 MEDIA_STOP
87
+key 87 MEDIA_NEXT
88
+key 88 MEDIA_PREVIOUS
89
+key 89 MEDIA_REWIND
90
+key 90 MEDIA_FAST_FORWARD
91
+key 91 MUTE
92
+key 92 PAGE_UP
93
+key 93 PAGE_DOWN
94
+key 94 PICTSYMBOLS
95
+key 95 SWITCH_CHARSET
96
+# ir keyboard dont need gamepad key, fix kodi can not use ir keyboard
97
+#key 96 BUTTON_A
98
+#key 97 BUTTON_B
99
+#key 98 BUTTON_C
100
+#key 99 BUTTON_X
101
+#key 100 BUTTON_Y
102
+#key 101 BUTTON_Z
103
+#key 102 BUTTON_L1
104
+#key 103 BUTTON_R1
105
+#key 104 BUTTON_L2
106
+#key 105 BUTTON_R2
107
+#key 106 BUTTON_THUMBL
108
+#key 107 BUTTON_THUMBR
109
+#key 108 BUTTON_START
110
+#key 109 BUTTON_SELECT
111
+#key 110 BUTTON_MODE
112
+key 111 ESCAPE
113
+key 112 FORWARD_DEL
114
+key 113 CTRL_LEFT
115
+key 114 CTRL_RIGHT
116
+key 115 CAPS_LOCK
117
+key 116 POWER
118
+key 117 META_LEFT
119
+key 118 META_RIGHT
120
+key 119 FUNCTION
121
+key 120 SYSRQ
122
+key 121 BREAK
123
+key 122 MOVE_HOME
124
+key 123 MOVE_END
125
+key 124 INSERT
126
+key 125 FORWARD
127
+key 126 MEDIA_PLAY
128
+key 127 MEDIA_PAUSE
129
+key 128 MEDIA_CLOSE
130
+key 129 MEDIA_EJECT
131
+key 130 MEDIA_RECORD
132
+key 131 F1
133
+key 132 F2
134
+key 133 F3
135
+key 134 F4
136
+key 135 F5
137
+key 136 F6
138
+key 137 F7
139
+key 138 F8
140
+key 139 F9
141
+key 140 F10
142
+key 141 F11
143
+key 142 F12
144
+key 143 NUM_LOCK
145
+key 144 NUMPAD_0
146
+key 145 NUMPAD_1
147
+key 146 NUMPAD_2
148
+key 147 NUMPAD_3
149
+key 148 NUMPAD_4
150
+key 149 NUMPAD_5
151
+key 150 NUMPAD_6
152
+key 151 NUMPAD_7
153
+key 152 NUMPAD_8
154
+key 153 NUMPAD_9
155
+key 154 NUMPAD_DIVIDE
156
+key 155 NUMPAD_MULTIPLY
157
+key 156 NUMPAD_SUBTRACT
158
+key 157 NUMPAD_ADD
159
+key 158 NUMPAD_DOT
160
+key 159 NUMPAD_COMMA
161
+key 160 NUMPAD_ENTER
162
+key 161 NUMPAD_EQUALS
163
+key 162 NUMPAD_LEFT_PAREN
164
+key 163 NUMPAD_RIGHT_PAREN
165
+key 164 VOLUME_MUTE
166
+key 165 INFO
167
+key 166 CHANNEL_UP
168
+key 167 CHANNEL_DOWN
169
+key 168 ZOOM_IN
170
+key 169 ZOOM_OUT
171
+key 170 TV
172
+key 171 WINDOW
173
+key 172 GUIDE
174
+key 173 DVR
175
+key 174 BOOKMARK
176
+key 175 CAPTIONS
177
+key 176 SETTINGS
178
+key 177 TV_POWER
179
+key 178 TV_INPUT
180
+key 179 STB_INPUT
181
+key 180 STB_POWER
182
+key 181 AVR_POWER
183
+key 182 AVR_INPUT
184
+key 183 PROG_RED
185
+key 184 PROG_GREEN
186
+key 185 PROG_YELLOW
187
+key 186 PROG_BLUE
188
+key 187 APP_SWITCH
189
+key 188 BUTTON_1
190
+key 189 BUTTON_2
191
+key 190 BUTTON_3
192
+key 191 BUTTON_4
193
+key 192 BUTTON_5
194
+key 193 BUTTON_6
195
+key 194 BUTTON_7
196
+key 195 BUTTON_8
197
+key 196 BUTTON_9
198
+key 197 BUTTON_10
199
+key 198 BUTTON_11
200
+key 199 BUTTON_12
201
+key 200 BUTTON_13
202
+key 201 BUTTON_14
203
+key 202 BUTTON_15
204
+key 203 BUTTON_16
205
+key 204 LANGUAGE_SWITCH
206
+key 205 MANNER_MODE
207
+key 206 3D_MODE
208
+key 207 CONTACTS
209
+key 208 CALENDAR
210
+key 209 MUSIC
211
+key 210 CALCULATOR
212
+key 211 ZENKAKU_HANKAKU
213
+key 212 EISU
214
+key 213 MUHENKAN
215
+key 214 HENKAN
216
+key 215 KATAKANA_HIRAGANA
217
+key 216 YEN
218
+key 217 RO
219
+key 218 KANA
220
+key 219 ASSIST
221
+key 220 BRIGHTNESS_DOWN
222
+key 221 BRIGHTNESS_UP
223
+key 222 MEDIA_AUDIO_TRACK
224
+key 223 TV_SYSTEM
225
+key 224 GOTO
226
+key 225 SUBTITLE
227
+key 226 AUDIO
228
+key 227 ZOOM
229
+key 228 HELP
230
+key 229 FAVOURITE
231
+key 230 LOOP
232
+key 231 EXPAND
233
+key 232 MOUSE
234
+key 233 MOVIE
235
+key 234 APPS
236
+key 235 BROWSER
237
+key 236 SCREENSHOT
238
+#key 237 HISENSE_FAC_NEC_DMP
239
+#key 238 HISENSE_FAC_NEC_OK
240
+#key 239 HISENSE_FAC_NEC_MAC
241
+#key 240 HISENSE_FAC_NEC_IP
242
+#key 241 HISENSE_FAC_NEC_M
243
+#key 242 HISENSE_FAC_NEC_AGING
244
+key 289 APP_VIDEO
android/vendor/aw/homlet/hardware/input/multi_ir/keylayout/virtual-remote.kl
....@@ -0,0 +1,26 @@
1
+# Copyright (C) 2013 The Android Open Source Project
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+# http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+
16
+key 217 SEARCH
17
+
18
+key 158 BACK
19
+key 172 HOME
20
+key 164 MEDIA_PLAY_PAUSE
21
+
22
+key 103 DPAD_UP
23
+key 108 DPAD_DOWN
24
+key 105 DPAD_LEFT
25
+key 106 DPAD_RIGHT
26
+key 353 DPAD_CENTER
android/vendor/aw/homlet/hardware/input/multi_ir/libmultiir/Android.bp
....@@ -0,0 +1,25 @@
1
+cc_library_shared {
2
+ name: "libmultiirservice",
3
+
4
+ srcs: ["IMultiirService.cpp"],
5
+
6
+ shared_libs: [
7
+ "libcutils",
8
+ "libutils",
9
+ "libbinder",
10
+ "liblog",
11
+ "libandroid_runtime",
12
+ ],
13
+
14
+ export_include_dirs: [
15
+ ".",
16
+ ],
17
+
18
+ host_ldlibs: ["-llog"],
19
+
20
+}
21
+
22
+cc_library_headers {
23
+ name: "libmultiirservice_headers",
24
+ export_include_dirs: ["."],
25
+}
android/vendor/aw/homlet/hardware/input/multi_ir/libmultiir/IMultiirService.cpp
....@@ -0,0 +1,164 @@
1
+#undef NDEBUG
2
+#define LOG_TAG "MultiirService"
3
+
4
+#include <utils/Log.h>
5
+#include <memory.h>
6
+#include <stdint.h>
7
+#include <sys/types.h>
8
+
9
+#include <binder/Parcel.h>
10
+#include <binder/IMemory.h>
11
+#include "IMultiirService.h"
12
+
13
+#define DEBUG true
14
+
15
+namespace android {
16
+
17
+enum {
18
+ ENTERMOUSEMODE = IBinder::FIRST_CALL_TRANSACTION,
19
+ EXITMOUSEMODE = ENTERMOUSEMODE + 1,
20
+ GETDEFAULTPOINTERSPEED = EXITMOUSEMODE + 1,
21
+ GETDEFAULTSTEPDISTANCE = GETDEFAULTPOINTERSPEED + 1,
22
+ SETPOINTERSPEED = GETDEFAULTSTEPDISTANCE + 1,
23
+ SETSTEPDISTANCE = SETPOINTERSPEED + 1,
24
+ RESET = SETSTEPDISTANCE + 1,
25
+ REPORTMOUSEKEYEVENT = RESET + 1,
26
+};
27
+
28
+class BpMultiirService : public BpInterface<IMultiirService> {
29
+
30
+public:
31
+ BpMultiirService(const sp<IBinder>& impl)
32
+ : BpInterface<IMultiirService>(impl){
33
+ }
34
+
35
+ int enterMouseMode(void) {
36
+ if (DEBUG) {
37
+ ALOGD("IMultiirService enter virtual mouse mode");
38
+ }
39
+ Parcel data, reply;
40
+ data.writeInterfaceToken(IMultiirService::getInterfaceDescriptor());
41
+ remote()->transact(ENTERMOUSEMODE, data, &reply);
42
+ return reply.readInt32();
43
+ }
44
+
45
+ int exitMouseMode(void) {
46
+ if (DEBUG) {
47
+ ALOGD("IMultiirService exit virtual mouse mode");
48
+ }
49
+ Parcel data, reply;
50
+ data.writeInterfaceToken(IMultiirService::getInterfaceDescriptor());
51
+ remote()->transact(EXITMOUSEMODE, data, &reply);
52
+ return reply.readInt32();
53
+ }
54
+
55
+ int getDefaultPointerSpeed(void) {
56
+ Parcel data, reply;
57
+ data.writeInterfaceToken(IMultiirService::getInterfaceDescriptor());
58
+ remote()->transact(GETDEFAULTPOINTERSPEED, data, &reply);
59
+ return reply.readInt32();
60
+ }
61
+
62
+ int getDefaultStepDistance(void) {
63
+ Parcel data, reply;
64
+ data.writeInterfaceToken(IMultiirService::getInterfaceDescriptor());
65
+ remote()->transact(GETDEFAULTSTEPDISTANCE, data, &reply);
66
+ return reply.readInt32();
67
+ }
68
+
69
+ int reset(void) {
70
+ Parcel data, reply;
71
+ data.writeInterfaceToken(IMultiirService::getInterfaceDescriptor());
72
+ remote()->transact(RESET, data, &reply);
73
+ return reply.readInt32();
74
+ }
75
+
76
+ int setPointerSpeed(int ms) {
77
+ Parcel data, reply;
78
+ data.writeInterfaceToken(IMultiirService::getInterfaceDescriptor());
79
+ data.writeInt32(ms);
80
+ remote()->transact(SETPOINTERSPEED, data, &reply);
81
+ return reply.readInt32();
82
+ }
83
+
84
+ int setStepDistance(int px) {
85
+ Parcel data, reply;
86
+ data.writeInterfaceToken(IMultiirService::getInterfaceDescriptor());
87
+ data.writeInt32(px);
88
+ remote()->transact(SETSTEPDISTANCE, data, &reply);
89
+ return reply.readInt32();
90
+ }
91
+ int reportMouseKeyEvent(int scan_code, int key_state) {
92
+ Parcel data, reply;
93
+ data.writeInterfaceToken(IMultiirService::getInterfaceDescriptor());
94
+ data.writeInt32(scan_code);
95
+ data.writeInt32(key_state);
96
+ remote()->transact(REPORTMOUSEKEYEVENT, data, &reply);
97
+ return reply.readInt32();
98
+ }
99
+};
100
+
101
+IMPLEMENT_META_INTERFACE(MultiirService, "com.softwinner.IMultiirService");
102
+
103
+status_t BnMultiirService::onTransact(
104
+ uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
105
+ switch (code) {
106
+ case ENTERMOUSEMODE :
107
+ {
108
+ CHECK_INTERFACE(IMultiitService, data, reply);
109
+ reply->writeInt32(enterMouseMode());
110
+ return NO_ERROR;
111
+ }
112
+ case EXITMOUSEMODE :
113
+ {
114
+ CHECK_INTERFACE(IMultiitService, data, reply);
115
+ reply->writeInt32(exitMouseMode());
116
+ return NO_ERROR;
117
+ }
118
+ case GETDEFAULTPOINTERSPEED :
119
+ {
120
+ CHECK_INTERFACE(IMultiitService, data, reply);
121
+ reply->writeInt32(getDefaultPointerSpeed());
122
+ return NO_ERROR;
123
+ }
124
+ case GETDEFAULTSTEPDISTANCE :
125
+ {
126
+ CHECK_INTERFACE(IMultiitService, data, reply);
127
+ reply->writeInt32(getDefaultStepDistance());
128
+ return NO_ERROR;
129
+ }
130
+ case SETPOINTERSPEED :
131
+ {
132
+ CHECK_INTERFACE(IMultiitService, data, reply);
133
+ int speed = data.readInt32();
134
+ reply->writeInt32(setPointerSpeed(speed));
135
+ return NO_ERROR;
136
+ }
137
+ case SETSTEPDISTANCE :
138
+ {
139
+ CHECK_INTERFACE(IMultiitService, data, reply);
140
+ int distance = data.readInt32();
141
+ reply->writeInt32(setStepDistance(distance));
142
+ return NO_ERROR;
143
+ }
144
+ case RESET :
145
+ {
146
+ CHECK_INTERFACE(IMultiitService, data, reply);
147
+ reply->writeInt32(reset());
148
+ return NO_ERROR;
149
+ }
150
+ case REPORTMOUSEKEYEVENT :
151
+ {
152
+ CHECK_INTERFACE(IMultiitService, data, reply);
153
+ int scan_code = data.readInt32();
154
+ int key_state = data.readInt32();
155
+ reply->writeInt32(reportMouseKeyEvent(scan_code, key_state));
156
+ return NO_ERROR;
157
+ }
158
+ default:
159
+ return BBinder::onTransact(code, data, reply, flags);
160
+ }
161
+}
162
+
163
+};
164
+
android/vendor/aw/homlet/hardware/input/multi_ir/libmultiir/IMultiirService.h
....@@ -0,0 +1,33 @@
1
+#ifndef ANDROID_IMULTIIRSERVICE_H
2
+#define ANDROID_IMULTIIRSERVICE_H
3
+
4
+#include <utils/Errors.h>
5
+#include <utils/RefBase.h>
6
+#include <binder/IInterface.h>
7
+#include <binder/Parcel.h>
8
+#include <utils/Log.h>
9
+
10
+namespace android {
11
+class IMultiirService : public IInterface {
12
+
13
+public:
14
+ DECLARE_META_INTERFACE(MultiirService);
15
+ virtual int enterMouseMode(void) = 0;
16
+ virtual int exitMouseMode(void) = 0;
17
+ virtual int getDefaultPointerSpeed(void) = 0;
18
+ virtual int getDefaultStepDistance(void) = 0;
19
+ virtual int setPointerSpeed(int ms) = 0;
20
+ virtual int setStepDistance(int px) = 0;
21
+ virtual int reset(void) = 0;
22
+ virtual int reportMouseKeyEvent(int scan_code, int key_state) = 0;
23
+};
24
+
25
+class BnMultiirService : public BnInterface<IMultiirService> {
26
+
27
+public:
28
+ virtual status_t onTransact(uint32_t code, const Parcel& data,
29
+ Parcel* reply, uint32_t flags = 0);
30
+};
31
+};
32
+
33
+#endif
android/vendor/aw/homlet/hardware/input/multi_ir/multiir.mk
....@@ -0,0 +1,51 @@
1
+# utils, add multi_ir to recovery
2
+PRODUCT_PACKAGES += \
3
+ multi_ir \
4
+ multi_ir.recovery \
5
+ libmultiir_jni \
6
+ libmultiirservice \
7
+
8
+BASE_KL_COPY_LIST := virtual-remote.kl \
9
+ sunxi-ir-uinput.kl \
10
+ customer_rc5_ir_04.kl \
11
+
12
+BASE_KL_COPY_LIST += customer_ir_9f00.kl \
13
+ customer_ir_dd22.kl \
14
+ customer_ir_fb04.kl \
15
+ customer_ir_ff00.kl \
16
+ customer_ir_4cb3.kl \
17
+ customer_ir_bc00.kl \
18
+ customer_ir_fc00.kl \
19
+ customer_ir_2992.kl \
20
+ customer_ir_4040.kl \
21
+ customer_ir_ba04.kl \
22
+ customer_ir_7f80.kl
23
+
24
+SYSTEM_KL_COPY_LIST := $(BASE_KL_COPY_LIST) \
25
+ Vendor_000d_Product_3838.kl \
26
+ sunxi-ir.kl \
27
+
28
+RECOVERY_KL_COPY_LIST := $(BASE_KL_COPY_LIST) \
29
+ customer_ir_fe01.kl
30
+
31
+SUNXI_VENDOR_KL_DIR := vendor/aw/homlet/hardware/input/multi_ir/keylayout
32
+SYSTEM_KL_DIR := system/usr/keylayout
33
+RECOVERY_KL_DIR := /root/system/usr/keylayout
34
+
35
+PRODUCT_COPY_FILES += $(foreach f,$(SYSTEM_KL_COPY_LIST),$(SUNXI_VENDOR_KL_DIR)/$(f):$(SYSTEM_KL_DIR)/$(f))
36
+
37
+# H6 use different ir keyboard
38
+ifeq ($(TARGET_BOARD_PLATFORM),petrel)
39
+PRODUCT_COPY_FILES += \
40
+ $(SUNXI_VENDOR_KL_DIR)/customer_ir_fe01_petrel.kl:$(SYSTEM_KL_DIR)/customer_ir_fe01.kl
41
+
42
+else
43
+PRODUCT_COPY_FILES += \
44
+ $(SUNXI_VENDOR_KL_DIR)/customer_ir_fe01.kl:$(SYSTEM_KL_DIR)/customer_ir_fe01.kl
45
+
46
+endif
47
+
48
+# recovery support multi_ir
49
+PRODUCT_COPY_FILES += $(foreach f,$(RECOVERY_KL_COPY_LIST),$(SUNXI_VENDOR_KL_DIR)/$(f):$(RECOVERY_KL_DIR)/$(f))
50
+PRODUCT_COPY_FILES += \
51
+ $(SUNXI_VENDOR_KL_DIR)/sunxi-ir-recovery.kl:$(RECOVERY_KL_DIR)/sunxi-ir.kl
android/vendor/aw/homlet/hardware/input/multi_ir/sepolicy/file_contexts
....@@ -0,0 +1 @@
1
+/system/bin/multi_ir u:object_r:multi_ir_exec:s0
android/vendor/aw/homlet/hardware/input/multi_ir/sepolicy/multi_ir.te
....@@ -0,0 +1,24 @@
1
+type multi_ir, domain;
2
+type multi_ir_exec, exec_type, file_type, system_file_type;
3
+init_daemon_domain(multi_ir)
4
+typeattribute multi_ir coredomain;
5
+type proc_ir, fs_type, proc_type;
6
+
7
+binder_use(multi_ir)
8
+binder_service(multi_ir)
9
+allow multi_ir servicemanager:binder { call transfer };
10
+allow multi_ir softwinner_service:service_manager { add find };
11
+allow multi_ir proc_ir:file rw_file_perms;
12
+#allow multi_ir sysfs:file write;
13
+allow multi_ir sysfs_devices_system_cpu:file write;
14
+allow multi_ir rootfs:dir {open read};
15
+allow multi_ir rootfs:file {open read execute getattr };
16
+allow multi_ir rootfs:file {entrypoint};
17
+#allow multi_ir self:capability {dac_override net_admin};
18
+allow multi_ir self:netlink_kobject_uevent_socket {create setopt bind read};
19
+allow multi_ir uhid_device:chr_file {write open read ioctl};
20
+allow multi_ir input_device:dir {write open read search getattr};
21
+allow multi_ir input_device:chr_file {write open read ioctl};
22
+allow multi_ir property_socket:sock_file {write};
23
+allow multi_ir init:unix_stream_socket connectto;
24
+allow multi_ir self:capability { net_admin };
android/vendor/aw/homlet/hardware/input/multi_ir/sepolicy/private/service_contexts
....@@ -0,0 +1 @@
1
+softwinner\.multiir u:object_r:multiir_service:s0
android/vendor/aw/homlet/hardware/input/multi_ir/sepolicy/service.te
....@@ -0,0 +1 @@
1
+type multiir_service, system_api_service, system_server_service, service_manager_type;
android/vendor/aw/homlet/hardware/input/multi_ir/sepolicy/system_server.te
....@@ -0,0 +1 @@
1
+allow system_server multiir_service:service_manager { add find };
android/vendor/aw/homlet/homlet.mk
....@@ -0,0 +1 @@
1
+$(call inherit-product-if-exists, vendor/aw/homlet/hardware/input/multi_ir/multiir.mk)
longan/device/config/chips/a133/configs/c3/board.dts
....@@ -370,10 +370,10 @@
370370 pinctrl-1 = <&twi3_pins_b>;
371371 status = "okay";
372372 // RTC
373
- pcf8563@51 {
374
- compatible = "haoyu,hym8563";
375
- reg = <0x51>;
376
- status = "okay";
373
+ pcf8563@51 {
374
+ compatible = "haoyu,hym8563";
375
+ reg = <0x51>;
376
+ status = "okay";
377377 };
378378 };
379379
....@@ -1339,7 +1339,7 @@
13391339
13401340 sysled {
13411341 label = "sysled";
1342
- gpios = <&r_pio PL 11 1 0 1 1>;
1342
+ gpios = <&r_pio PL 10 1 0 1 1>;
13431343 linux,default_trigger = "heartbeat";
13441344 };
13451345
....@@ -1355,6 +1355,19 @@
13551355 cpu-supply = <&reg_dcdc2>;
13561356 };
13571357
1358
+&s_cir0 {
1359
+ status = "okay";
1360
+
1361
+ s_cir0_used = <1>;
1362
+ ir_power_key_code0 = <0x4d>;
1363
+ ir_addr_code0 = <0x4040>;
1364
+ ir_power_key_code1 = <0x51>;
1365
+ ir_addr_code1 = <0x7f80>;
1366
+ ir_power_key_code2 = <0x1c>;
1367
+ ir_addr_code2 = <0xdf00>;
1368
+ wakeup-source;
1369
+};
1370
+
13581371 //#include "lcd-lvds-21-1920-1080.dtsi"
13591372 #include "lcd-lvds-7-1024-600.dtsi"
13601373 //#include "lcd-mipi-10-800-1280.dtsi"