笔记目录
- GPIO按键适配
- PS:每次修改适配都要再客制化一下,来更新修改。!!!
- 一、GPIO按键适配(Rk)
- linux键值
- 二、GPIO适配:RK平台(android11)
- 调试:1、adb命令打开GPIO口,设置为输出口,并设置输出电平
- 2、adb命令打开GPIO口,设置为输入口,并读取输入电平
- 三、GPIO适配:海思平台(560)
- 四、adc按键适配(RK)
- 五、adc按键适配(海思)
- 1、寻找空闲的adc通道
- 2、adb下寻找阈值电压
- 3、更改适配文件
- 4、替换.xml
- 六、framework自定义按键适配(编整包)
- 七、mipi屏适配
- 1、适配路径
- 2、示例参考
- 3、(屏没亮时)硬件情况解决方法
- 八、海思烧录内核
- 九、麦克风适配
- 十、wifi适配
- 十一、rk平台适配蓝牙遥控器
- 十二、rk平台适配i2c传感器
- 十三、重力传感器X轴反向
- 十四、拔掉摄像头程序崩溃
GPIO按键适配
PS:每次修改适配都要再客制化一下,来更新修改。!!!
一、GPIO按键适配(Rk)
1、寻找input子系统对应键值(系统层)
cat frameworks/base/core/java/android/view/KeyEvent.java
2、3568编译时设备树路径(每次调试都要删掉再加新的)
//每次更改文件都要再客制化一下,来更新修改
#主
kernel/arch/arm64/boot/dts/rockchip/lango_common_overlay.dtsi
#从
kernel/arch/arm64/boot/dts/rockchip/lg-panel_default.dtsi
3、编译内核命令rk系列
//3568、3399、3566,生成/kernel/boot.img
./Customer/compile.h ke;./Customer/compile.h bo
//3288
- 1.kernel编译./Customer/compile.sh;./mkimage.shkernel目录生成kernel.img和resource.img- 单独烧录kernel调试:第一步: 执行编译内核命令 ./Customer/compile.sh ke。**第二步: 执行打包boot命令./mkimage.sh,生成文件为代码根目录下 rockdev\Image-rk3288\boot.img,kernel.img,resource.img。文件不到2MB。**第三步: 把boot.img和kernel.img和resource.img一起烧录进主板,下次就可以单独烧kernel.img resource.img文件了,Loader可以不要。- 另外,如要修改主板根目录下的文件, 如init.rc等文件,可在源代码out\target\product\rk3288\root\下修改,然后用./mkimage.sh打包生成代码根目录下rockdev\Image-rk3288\boot.img,单独烧录即可。
4、示例
/** 例如:1.需要把i2c2关闭 2.配置某个GPIO. 参考以下代码:* 注意:比如想要修改gpio-ctrl这个节点的数据,* 但是在上层dts文件中该节点的定义为gpio-ctrl{...};* 直接使用&gpio-ctrl来覆盖原先的内容是不行的,会出现编译报错* 因为&符号的作用是引用节点的标签来覆盖原有节点的数据** 正确的修改方法:在gpio-ctrl节点的定义处添加标签gpio_ctrl,改为:gpio_ctrl:gpio-ctrl{...};标签添加完毕后,* 就可以在其他文件中,通过&gpio_ctrl对标签引用来覆盖原先节点数据** &i2c2{* status="disabled";* };** &gpio_ctrl{* gpio1_out = <&gpio3 RK_PC1 GPIO_ACTIVE_HIGH>;* gpio2_out = <&gpio3 RK_PC2 GPIO_ACTIVE_HIGH>;* };* The nickname can't start with number.*// {};
&wiegand_snd {status = "disabled";
};&uart2 {status = "disabled";
};&gpio_keys {compatible = "gpio-keys";autorepeat;pinctrl-names = "default";pinctrl-0 = <&pwrbtn>;volume-up {debounce-interval = <100>;gpios = <&gpio0 RK_PD0 GPIO_ACTIVE_LOW>;label = "GPIO Key volume up";linux,code = <KEY_VOLUMEUP>;};volume-down {debounce-interval = <100>;gpios = <&gpio0 RK_PD1 GPIO_ACTIVE_LOW>;label = "GPIO Key volume down";linux,code = <KEY_VOLUMEDOWN>;};brightness-up {debounce-interval = <100>;gpios = <&gpio4 RK_PC2 GPIO_ACTIVE_LOW>;label = "GPIO Key brightness up";linux,code = <KEY_BRIGHTNESSUP>;};brightness-down {debounce-interval = <100>;gpios = <&gpio4 RK_PC3 GPIO_ACTIVE_LOW>;label = "GPIO Key brightness down";linux,code = <KEY_BRIGHTNESSDOWN>;};
};
注意音量减开机前某个阶段按下音量减系统会进入安全模式,注意gpios的默认电平状态。
(23条消息) Android安全模式_android 安全模式_星眸之心的博客-CSDN博客
linux键值
#define KEY_RESERVED 0
#define KEY_ESC 1
#define KEY_1 2
#define KEY_2 3
#define KEY_3 4
#define KEY_4 5
#define KEY_5 6
#define KEY_6 7
#define KEY_7 8
#define KEY_8 9
#define KEY_9 10
#define KEY_0 11
#define KEY_MINUS 12
#define KEY_EQUAL 13
#define KEY_BACKSPACE 14
#define KEY_TAB 15
#define KEY_Q 16
#define KEY_W 17
#define KEY_E 18
#define KEY_R 19
#define KEY_T 20
#define KEY_Y 21
#define KEY_U 22
#define KEY_I 23
#define KEY_O 24
#define KEY_P 25
#define KEY_LEFTBRACE 26
#define KEY_RIGHTBRACE 27
#define KEY_ENTER 28
#define KEY_LEFTCTRL 29
#define KEY_A 30
#define KEY_S 31
#define KEY_D 32
#define KEY_F 33
#define KEY_G 34
#define KEY_H 35
#define KEY_J 36
#define KEY_K 37
#define KEY_L 38
#define KEY_SEMICOLON 39
#define KEY_APOSTROPHE 40
#define KEY_GRAVE 41
#define KEY_LEFTSHIFT 42
#define KEY_BACKSLASH 43
#define KEY_Z 44
#define KEY_X 45
#define KEY_C 46
#define KEY_V 47
#define KEY_B 48
#define KEY_N 49
#define KEY_M 50
#define KEY_COMMA 51
#define KEY_DOT 52
#define KEY_SLASH 53
#define KEY_RIGHTSHIFT 54
#define KEY_KPASTERISK 55
#define KEY_LEFTALT 56
#define KEY_SPACE 57
#define KEY_CAPSLOCK 58
#define KEY_F1 59
#define KEY_F2 60
#define KEY_F3 61
#define KEY_F4 62
#define KEY_F5 63
#define KEY_F6 64
#define KEY_F7 65
#define KEY_F8 66
#define KEY_F9 67
#define KEY_F10 68
#define KEY_NUMLOCK 69
#define KEY_SCROLLLOCK 70
#define KEY_KP7 71
#define KEY_KP8 72
#define KEY_KP9 73
#define KEY_KPMINUS 74
#define KEY_KP4 75
#define KEY_KP5 76
#define KEY_KP6 77
#define KEY_KPPLUS 78
#define KEY_KP1 79
#define KEY_KP2 80d
#define KEY_KP3 81
#define KEY_KP0 82
#define KEY_KPDOT 83#define KEY_ZENKAKUHANKAKU 85
#define KEY_102ND 86
#define KEY_F11 87
#define KEY_F12 88
#define KEY_RO 89
#define KEY_KATAKANA 90
#define KEY_HIRAGANA 91
#define KEY_HENKAN 92
#define KEY_KATAKANAHIRAGANA 93
#define KEY_MUHENKAN 94
#define KEY_KPJPCOMMA 95
#define KEY_KPENTER 96
#define KEY_RIGHTCTRL 97
#define KEY_KPSLASH 98
#define KEY_SYSRQ 99
#define KEY_RIGHTALT 100
#define KEY_LINEFEED 101
#define KEY_HOME 102
#define KEY_UP 103
#define KEY_PAGEUP 104
#define KEY_LEFT 105
#define KEY_RIGHT 106
#define KEY_END 107
#define KEY_DOWN 108
#define KEY_PAGEDOWN 109
#define KEY_INSERT 110
#define KEY_DELETE 111
#define KEY_MACRO 112
#define KEY_MUTE 113
#define KEY_VOLUMEDOWN 114
#define KEY_VOLUMEUP 115
#define KEY_POWER 116 /* SC System Power Down */
#define KEY_KPEQUAL 117
#define KEY_KPPLUSMINUS 118
#define KEY_PAUSE 119
#define KEY_SCALE 120 /* AL Compiz Scale (Expose) */#define KEY_KPCOMMA 121
#define KEY_HANGEUL 122
#define KEY_HANGUEL KEY_HANGEUL
#define KEY_HANJA 123
#define KEY_YEN 124
#define KEY_LEFTMETA 125
#define KEY_RIGHTMETA 126
#define KEY_COMPOSE 127#define KEY_STOP 128 /* AC Stop */
#define KEY_AGAIN 129
#define KEY_PROPS 130 /* AC Properties */
#define KEY_UNDO 131 /* AC Undo */
#define KEY_FRONT 132
#define KEY_COPY 133 /* AC Copy */
#define KEY_OPEN 134 /* AC Open */
#define KEY_PASTE 135 /* AC Paste */
#define KEY_FIND 136 /* AC Search */
#define KEY_CUT 137 /* AC Cut */
#define KEY_HELP 138 /* AL Integrated Help Center */
#define KEY_MENU 139 /* Menu (show menu) */
#define KEY_CALC 140 /* AL Calculator */
#define KEY_SETUP 141
#define KEY_SLEEP 142 /* SC System Sleep */
#define KEY_WAKEUP 143 /* System Wake Up */
#define KEY_FILE 144 /* AL Local Machine Browser */
#define KEY_SENDFILE 145
#define KEY_DELETEFILE 146
#define KEY_XFER 147
#define KEY_PROG1 148
#define KEY_PROG2 149
#define KEY_WWW 150 /* AL Internet Browser */
#define KEY_MSDOS 151
#define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */
#define KEY_SCREENLOCK KEY_COFFEE
#define KEY_DIRECTION 153
#define KEY_CYCLEWINDOWS 154
#define KEY_MAIL 155
#define KEY_BOOKMARKS 156 /* AC Bookmarks */
#define KEY_COMPUTER 157
#define KEY_BACK 158 /* AC Back */
#define KEY_FORWARD 159 /* AC Forward */
#define KEY_CLOSECD 160
#define KEY_EJECTCD 161
#define KEY_EJECTCLOSECD 162
#define KEY_NEXTSONG 163
#define KEY_PLAYPAUSE 164
#define KEY_PREVIOUSSONG 165
#define KEY_STOPCD 166
#define KEY_RECORD 167
#define KEY_REWIND 168
#define KEY_PHONE 169 /* Media Select Telephone */
#define KEY_ISO 170
#define KEY_CONFIG 171 /* AL Consumer Control Configuration */
#define KEY_HOMEPAGE 172 /* AC Home */
#define KEY_REFRESH 173 /* AC Refresh */
#define KEY_EXIT 174 /* AC Exit */
#define KEY_MOVE 175
#define KEY_EDIT 176
#define KEY_SCROLLUP 177
#define KEY_SCROLLDOWN 178
#define KEY_KPLEFTPAREN 179
#define KEY_KPRIGHTPAREN 180
#define KEY_NEW 181 /* AC New */
#define KEY_REDO 182 /* AC Redo/Repeat */#define KEY_F13 183
#define KEY_F14 184
#define KEY_F15 185
#define KEY_F16 186
#define KEY_F17 187
#define KEY_F18 188
#define KEY_F19 189
#define KEY_F20 190
#define KEY_F21 191
#define KEY_F22 192
#define KEY_F23 193
#define KEY_F24 194#define KEY_PLAYCD 200
#define KEY_PAUSECD 201
#define KEY_PROG3 202
#define KEY_PROG4 203
#define KEY_DASHBOARD 204 /* AL Dashboard */
#define KEY_SUSPEND 205
#define KEY_CLOSE 206 /* AC Close */
#define KEY_PLAY 207
#define KEY_FASTFORWARD 208
#define KEY_BASSBOOST 209
#define KEY_PRINT 210 /* AC Print */
#define KEY_HP 211
#define KEY_CAMERA 212
#define KEY_SOUND 213
#define KEY_QUESTION 214
#define KEY_EMAIL 215
#define KEY_CHAT 216
#define KEY_SEARCH 217
#define KEY_CONNECT 218
#define KEY_FINANCE 219 /* AL Checkbook/Finance */
#define KEY_SPORT 220
#define KEY_SHOP 221
#define KEY_ALTERASE 222
#define KEY_CANCEL 223 /* AC Cancel */
#define KEY_BRIGHTNESSDOWN 224
#define KEY_BRIGHTNESSUP 225
#define KEY_MEDIA 226#define KEY_SWITCHVIDEOMODE 227 /* Cycle between available videooutputs (Monitor/LCD/TV-out/etc) */
#define KEY_KBDILLUMTOGGLE 228
#define KEY_KBDILLUMDOWN 229
#define KEY_KBDILLUMUP 230#define KEY_SEND 231 /* AC Send */
#define KEY_REPLY 232 /* AC Reply */
#define KEY_FORWARDMAIL 233 /* AC Forward Msg */
#define KEY_SAVE 234 /* AC Save */
#define KEY_DOCUMENTS 235#define KEY_BATTERY 236#define KEY_BLUETOOTH 237
#define KEY_WLAN 238
#define KEY_UWB 239#define KEY_UNKNOWN 240#define KEY_VIDEO_NEXT 241 /* drive next video source */
#define KEY_VIDEO_PREV 242 /* drive previous video source */
#define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */
#define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */
#define KEY_DISPLAY_OFF 245 /* display device to off state */#define KEY_WIMAX 246
#define KEY_RFKILL 247 /* Key that controls all radios *//* adc 按键的键值最多只能到255,如果要限制键值的话要去fastboot里面改Thresholdx,x对应adcx通道*/
/* Code 255 is reserved for special needs of AT keyboard driver */#define BTN_MISC 0x100
#define BTN_0 0x100
#define BTN_1 0x101
#define BTN_2 0x102
#define BTN_3 0x103
#define BTN_4 0x104
#define BTN_5 0x105
#define BTN_6 0x106
#define BTN_7 0x107
#define BTN_8 0x108
#define BTN_9 0x109#define BTN_MOUSE 0x110
#define BTN_LEFT 0x110
#define BTN_RIGHT 0x111
#define BTN_MIDDLE 0x112
#define BTN_SIDE 0x113
#define BTN_EXTRA 0x114
#define BTN_FORWARD 0x115
#define BTN_BACK 0x116
#define BTN_TASK 0x117#define BTN_JOYSTICK 0x120
#define BTN_TRIGGER 0x120
#define BTN_THUMB 0x121
#define BTN_THUMB2 0x122
#define BTN_TOP 0x123
#define BTN_TOP2 0x124
#define BTN_PINKIE 0x125
#define BTN_BASE 0x126
#define BTN_BASE2 0x127
#define BTN_BASE3 0x128
#define BTN_BASE4 0x129
#define BTN_BASE5 0x12a
#define BTN_BASE6 0x12b
#define BTN_DEAD 0x12f#define BTN_GAMEPAD 0x130
#define BTN_A 0x130
#define BTN_B 0x131
#define BTN_C 0x132
#define BTN_X 0x133
#define BTN_Y 0x134
#define BTN_Z 0x135
#define BTN_TL 0x136
#define BTN_TR 0x137
#define BTN_TL2 0x138
#define BTN_TR2 0x139
#define BTN_SELECT 0x13a
#define BTN_START 0x13b
#define BTN_MODE 0x13c
#define BTN_THUMBL 0x13d
#define BTN_THUMBR 0x13e#define BTN_DIGI 0x140
#define BTN_TOOL_PEN 0x140
#define BTN_TOOL_RUBBER 0x141
#define BTN_TOOL_BRUSH 0x142
#define BTN_TOOL_PENCIL 0x143
#define BTN_TOOL_AIRBRUSH 0x144
#define BTN_TOOL_FINGER 0x145
#define BTN_TOOL_MOUSE 0x146
#define BTN_TOOL_LENS 0x147
#define BTN_TOUCH 0x14a
#define BTN_STYLUS 0x14b
#define BTN_STYLUS2 0x14c
#define BTN_TOOL_DOUBLETAP 0x14d
#define BTN_TOOL_TRIPLETAP 0x14e
#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */#define BTN_WHEEL 0x150
#define BTN_GEAR_DOWN 0x150
#define BTN_GEAR_UP 0x151#define KEY_OK 0x160
#define KEY_SELECT 0x161
#define KEY_GOTO 0x162
#define KEY_CLEAR 0x163
#define KEY_POWER2 0x164
#define KEY_OPTION 0x165
#define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */
#define KEY_TIME 0x167
#define KEY_VENDOR 0x168
#define KEY_ARCHIVE 0x169
#define KEY_PROGRAM 0x16a /* Media Select Program Guide */
#define KEY_CHANNEL 0x16b
#define KEY_FAVORITES 0x16c
#define KEY_EPG 0x16d
#define KEY_PVR 0x16e /* Media Select Home */
#define KEY_MHP 0x16f
#define KEY_LANGUAGE 0x170
#define KEY_TITLE 0x171
#define KEY_SUBTITLE 0x172
#define KEY_ANGLE 0x173
#define KEY_ZOOM 0x174
#define KEY_MODE 0x175
#define KEY_KEYBOARD 0x176
#define KEY_SCREEN 0x177
#define KEY_PC 0x178 /* Media Select Computer */
#define KEY_TV 0x179 /* Media Select TV */
#define KEY_TV2 0x17a /* Media Select Cable */
#define KEY_VCR 0x17b /* Media Select VCR */
#define KEY_VCR2 0x17c /* VCR Plus */
#define KEY_SAT 0x17d /* Media Select Satellite */
#define KEY_SAT2 0x17e
#define KEY_CD 0x17f /* Media Select CD */
#define KEY_TAPE 0x180 /* Media Select Tape */
#define KEY_RADIO 0x181
#define KEY_TUNER 0x182 /* Media Select Tuner */
#define KEY_PLAYER 0x183
#define KEY_TEXT 0x184
#define KEY_DVD 0x185 /* Media Select DVD */
#define KEY_AUX 0x186
#define KEY_MP3 0x187
#define KEY_AUDIO 0x188
#define KEY_VIDEO 0x189
#define KEY_DIRECTORY 0x18a
#define KEY_LIST 0x18b
#define KEY_MEMO 0x18c /* Media Select Messages */
#define KEY_CALENDAR 0x18d
#define KEY_RED 0x18e
#define KEY_GREEN 0x18f
#define KEY_YELLOW 0x190
#define KEY_BLUE 0x191
#define KEY_CHANNELUP 0x192 /* Channel Increment */
#define KEY_CHANNELDOWN 0x193 /* Channel Decrement */
#define KEY_FIRST 0x194
#define KEY_LAST 0x195 /* Recall Last */
#define KEY_AB 0x196
#define KEY_NEXT 0x197
#define KEY_RESTART 0x198
#define KEY_SLOW 0x199
#define KEY_SHUFFLE 0x19a
#define KEY_BREAK 0x19b
#define KEY_PREVIOUS 0x19c
#define KEY_DIGITS 0x19d
#define KEY_TEEN 0x19e
#define KEY_TWEN 0x19f
#define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */
#define KEY_GAMES 0x1a1 /* Media Select Games */
#define KEY_ZOOMIN 0x1a2 /* AC Zoom In */
#define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */
#define KEY_ZOOMRESET 0x1a4 /* AC Zoom */
#define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */
#define KEY_EDITOR 0x1a6 /* AL Text Editor */
#define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */
#define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */
#define KEY_PRESENTATION 0x1a9 /* AL Presentation App */
#define KEY_DATABASE 0x1aa /* AL Database App */
#define KEY_NEWS 0x1ab /* AL Newsreader */
#define KEY_VOICEMAIL 0x1ac /* AL Voicemail */
#define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */
#define KEY_MESSENGER 0x1ae /* AL Instant Messaging */
#define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */
#define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */
#define KEY_LOGOFF 0x1b1 /* AL Logoff */#define KEY_DOLLAR 0x1b2
#define KEY_EURO 0x1b3#define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */
#define KEY_FRAMEFORWARD 0x1b5
#define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */
#define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */#define KEY_DEL_EOL 0x1c0
#define KEY_DEL_EOS 0x1c1
#define KEY_INS_LINE 0x1c2
#define KEY_DEL_LINE 0x1c3#define KEY_FN 0x1d0
#define KEY_FN_ESC 0x1d1
#define KEY_FN_F1 0x1d2
#define KEY_FN_F2 0x1d3
#define KEY_FN_F3 0x1d4
#define KEY_FN_F4 0x1d5
#define KEY_FN_F5 0x1d6
#define KEY_FN_F6 0x1d7
#define KEY_FN_F7 0x1d8
#define KEY_FN_F8 0x1d9
#define KEY_FN_F9 0x1da
#define KEY_FN_F10 0x1db
#define KEY_FN_F11 0x1dc
#define KEY_FN_F12 0x1dd
#define KEY_FN_1 0x1de
#define KEY_FN_2 0x1df
#define KEY_FN_D 0x1e0
#define KEY_FN_E 0x1e1
#define KEY_FN_F 0x1e2
#define KEY_FN_S 0x1e3
#define KEY_FN_B 0x1e4#define KEY_BRL_DOT1 0x1f1
#define KEY_BRL_DOT2 0x1f2
#define KEY_BRL_DOT3 0x1f3
#define KEY_BRL_DOT4 0x1f4
#define KEY_BRL_DOT5 0x1f5
#define KEY_BRL_DOT6 0x1f6
#define KEY_BRL_DOT7 0x1f7
#define KEY_BRL_DOT8 0x1f8
#define KEY_BRL_DOT9 0x1f9
#define KEY_BRL_DOT10 0x1fa#define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */
#define KEY_NUMERIC_1 0x201 /* and other keypads */
#define KEY_NUMERIC_2 0x202
#define KEY_NUMERIC_3 0x203
#define KEY_NUMERIC_4 0x204
#define KEY_NUMERIC_5 0x205
#define KEY_NUMERIC_6 0x206
#define KEY_NUMERIC_7 0x207
#define KEY_NUMERIC_8 0x208
#define KEY_NUMERIC_9 0x209
#define KEY_NUMERIC_STAR 0x20a
#define KEY_NUMERIC_POUND 0x20b#define KEY_CAMERA_FOCUS 0x210
#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */
二、GPIO适配:RK平台(android11)
记得先要确认硬件状态
//例如复用韦根以及串口作为GPIO
&wiegand_snd {status = "disabled";
};&uart3 {status = "disabled";
};&gpio_ctrl{gpio1_out = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;gpio2_out = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;gpio3_out = <&gpio4 RK_PC2 GPIO_ACTIVE_LOW>;gpio4_out = <&gpio4 RK_PC3 GPIO_ACTIVE_LOW>;};
查看当前GPIO复用情况:
cat /sys/kernel/debug/pinctrl/pinctrl-rockchip-pinctrl/pinmux-pins
调试:1、adb命令打开GPIO口,设置为输出口,并设置输出电平
//进入adb命令环境
adb shell
//root权限
su
//打开指定GPIO
echo 236 > /sys/class/gpio/export
//修改为输出
echo out > /sys/class/gpio/gpio236/direction
//写入输出值 0 或者1
echo 1 > /sys/class/gpio/gpio236/value
echo 0 > /sys/class/gpio/gpio236/value
2、adb命令打开GPIO口,设置为输入口,并读取输入电平
//进入adb命令环境
adb shell
//root权限
su
//打开指定GPIO
echo 236 > /sys/class/gpio/export
//修改为输入
echo in > /sys/class/gpio/gpio236/direction
//读取输入值
cat /sys/class/gpio/gpio236/value
PS:RK的设备树是可供uboot和kernel同时使用的,如果使用特殊的GPIO口使用直接指定GPIO口的方式来配置可能会没有用。例如debug口的TX和RX。
当3399使用以下写法的时候是控不动的:
&i2c4 {status = "disabled";
};&uart2 {status = "disabled";
};&gpio_ctrl{gpio1_out = <&gpio1 RK_PB3 GPIO_ACTIVE_LOW>;gpio2_out = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>;gpio3_out = <&gpio1 RK_PC3 GPIO_ACTIVE_LOW>;//debug_txgpio4_out = <&gpio1 RK_PC4 GPIO_ACTIVE_LOW>;//debug_rx
};
因为在uboot阶段的时候,我们需要它进行打印而要输出打印就必须将debug的两个口切换成串口模式。而当进入kernel模式的时候,我们这里把他(uart2)disabled了。因此uart2无法从串口模式切换成GPIO口模式,gpio4_out = <&gpio1 RK_PC4 GPIO_ACTIVE_LOW> 这种写法放到代码里只是申请一个GPIO口。而debug_tx并没有从串口状态回到GPIO口状态,因此申请是无效的。因此还是保留之前的串口状态,如下:
uart2c {uart2c_xfer: uart2c-xfer {rockchip,pins =<4 RK_PC3 1 &pcfg_pull_up>,<4 RK_PC4 1 &pcfg_pull_up>;};};
很直观的现象,就是export出来怎么都拉不低。因此解决方法就是:1、关闭在uboot状态下的串口打印状态(fiq_debugger),2、重新指定GPIO状态
&i2c4 {status = "disabled";
};&uart2 {status = "disabled";
};
// fiq_debugger功能会影响debug口的供电,如果不关没有办法让debug口作为gpio口
&fiq_debugger {status = "disabled";
};&gpio_ctrl{gpio1_out = <&gpio1 RK_PB3 GPIO_ACTIVE_LOW>;gpio2_out = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>;pinctrl-0 = <&power_vbus1 &power_vbus2 &uart_gpio1 &uart_gpio2>;
};&pinctrl {debug_to_gpio {uart_gpio1: uart_gpio1 {rockchip,pins =<4 RK_PC3 RK_FUNC_GPIO &pcfg_pull_none>;};uart_gpio2: uart_gpio2 {rockchip,pins =<4 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none>;};};
};
三、GPIO适配:海思平台(560)
PS:前提是key_pars.cpp里面可以解析gpio,811就不支持解析gpio。
1、key_pad.xml路径:/atv/etc/key_pad.xml(直接在这里改然后重启调试即可,可以再复制到源码的key_pad.xml)
2、getevent 捕获input子系统信息,busybox vi /atv/etc/key_pad.xml。
3、例子
<key_pad KeyThreshold="0x00" KeyCode="0x0000" /><key_pad KeyThreshold="0x00" KeyCode="0x0000" /></channel3><gpio><enable value="1" /><KeyLevelNum value="2" /><key_pad GroupNum="0" PinNum="1" KeyCode="0x69" /> <!-- KEY_LEFT --><key_pad GroupNum="0" PinNum="0" KeyCode="0x6A" /> <!-- KEY_RIGHT --></gpio></key_pad_xml>
四、adc按键适配(RK)
[(23条消息) rk3588-adc按键实现分析_press-threshold-microvolt_mapleasx的博客-CSDN博客](https://blog.csdn.net/weixin_40224996/article/details/127380322?ops_request_misc=%7B%22request%5Fid%22%3A%22167773690416800184139338%22%2C%22scm%22%3A%2220140713.130102334.pc%5Fall.%22%7D&request_id=167773690416800184139338&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v1~rank_v31_ecpm-3-127380322-null-null.142v73control_1,201v4add_ask,239v2insert_chatgpt&utm_term=rk3568 adc按键配置&spm=1018.2226.3001.4187)
android7:
&rk_key {compatible = "rockchip,key";status = "okay";io-channels = <&saradc 0>;back-key {linux,code = <158>;//ADC 0 key for backlabel = "back";rockchip,adc_value = <1>;};
}android11:adc_keys2: adc-keys2 {status = "okay";compatible = "adc-keys";io-channels = <&saradc 1>;io-channel-names = "buttons";//满压为1.8Vkeyup-threshold-microvolt = <1800000>;poll-interval = <100>;f1-key {linux,code = <KEY_F1>;label = "f1";//11下RK仅支持按下判断按下电压来判断采样值,否则驱动会报错press-threshold-microvolt = <10000>;};};
//比如看adc0
cat /sys/bus/platform/drivers/meson-saradc/ff809000.saradc/iio:device0/in_voltage0_raw
//下面是3288.L的
cat /sys/bus/platform/drivers/rockchip-saradc/ff100000.saradc/iio:device0/in_voltage0_raw
1)默认情况下adc值
Lrk3288:/sys/bus/platform/drivers/rockchip-saradc/ff100000.saradc/iio:device0 # cat in_voltage0_raw
cat in_voltage0_raw
1023
2)拿镊子接地的adc值
Lrk3288:/sys/bus/platform/drivers/rockchip-saradc/ff100000.saradc/iio:device0 # cat in_voltage0_raw
cat in_voltage0_raw
1
所以说明有效的adc值是1023-1,rockchip,adc_value 应该写<1>;
五、adc按键适配(海思)
1、寻找空闲的adc通道
2、adb下寻找阈值电压
adc的键值最多只能到255,想要限制键值范围要到fastboot改threshold。811的0值是不会上报的。
//捕获adc1的电压,默认高电平0xfc,当
Hi3751V350:/ # sample_lsadc 1
........
Channel 1 Value 0x000000cc//电平可能变化选择离默认值比较近的,这里选d0
Channel 1 Value 0x000000d0
........
3、更改适配文件
(例子中Customer\toolchains\keypad\keypad_351A_kangrong.xml)
4、替换.xml
//不知道替换后文件叫什么名字可以找客制化文件
adb push aaa.xml atv/etc/key_pad.xml
六、framework自定义按键适配(编整包)
1、先在头文件中找对应码值是否存在,不存在则自行添加
kernel\include\dt-bindings\input\rk-input.h
2、调试命令
//可以查看当前遥控器所使用的.kl
dumpsys input
//发送键值命令(键值为系统的键值)
input keyevent 302
3、修改framework/native/include/input/InputEventLabels.h文件
4、修改framework/native/include/android/keycodes.h文件
5、修改framework/base/core/java/android/view/KeyEvent.java文件
同时还需要加上LAST_KEYCODE 的值。
6、修改资源文件/framework/base/core/res/res/values/attrs.xml
7、修改framework/base/services/core/java/com/android/server/policy/PhoneWindowManager.java文件
8、 修改kl文件(板子下手动替换)
base/data/keyboards/Generic.kl
9、更新framework/base下的.txt文件
Kl文件,即keylayout文件,一般来说每个按键输入设备(比如遥控器,键盘,按键板)都对应一个kl文件,kl文件由EventHub加载,完成linux上报键值到android应用键值的映射。Kl文件在系统一般位于/system/usr/keylayout或者/vendor/usr/keylayout等目录。源码下各个平台的位置不一样,以海思811为例,在device/hisilicon/bigfish/prebuilts/目录下。
如何确定输入设备对应的kl文件呢?一般来说,EventHub会根据输入设备的name或者VID和PID等信息来找对应的kl文件,这些信息可以通过getevent -v或者cat /proc/bus/input/devices命令来获取
XMR3568A:/ # getevent -v
add device 1: /dev/input/event1bus: 0003vendor 046dproduct c077version 0111name: "Logitech USB Optical Mouse"location: "usb-fd8c0000.usb-1/input0"id: ""version: 1.0.1
可以通过命令dumpsys input 获得对应的kl(keylayout)文件。android kl(key layout)文件是一个映射文件,是标准linux与anroid的键值映射文件,一般kl文件会根据Vendor以及product来命名.kl文件,如果.kl文件与KeycodeLabels.h中的按键不匹配则会默认使用Generic.kl。
//.kl命名格式:Vendor_Vendor号_Product_Product号.kl2: fe6e0030.pwmClasses: 0x00000021Path: /dev/input/event4Enabled: trueDescriptor: 6e6866b287cdd04b028ef220947dd504c325d316Location: gpio-keys/remotectlControllerNumber: 0UniqueId:Identifier: bus=0x0019, vendor=0x524b, product=0x0006, version=0x0100KeyLayoutFile: /system/usr/keylayout/Generic.klKeyCharacterMapFile: /system/usr/keychars/Generic.kcmConfigurationFile:HaveKeyboardLayoutOverlay: falseVideoDevice: <none>
9、修改libc/kernel/uapi/linux/input-event-codes.h文件
10、(middleware)修改middleware/userkeyprocess/UserKeyProcesslmpl的键值。
可以不用push framework.jar包,直接把安卓的键值当做case值。
七、mipi屏适配
1、适配路径
Customer\toolchains\panel\lg-double-lcd-lvds1024X600-mipi800X1280_YF101B03.dtsi
2、示例参考
//背光调试
&backlight2 {default-brightness-level = <200>;pwm-freq = <100000>;pwm-polarity = <0>;pwm-brightMin = <80>;pwm-brightMax = <255>;
};&route_dsi0 {status = "okay";connect = <&vopb_out_dsi0>;
};
//rk3288 有两路通道vopb(4K) vopl(2K) ,这里异显设vopb通道是edp,vopl通道mipi
&dsi0_in_vopl {status = "disabled";
};&dsi0_in_vopb {status = "okay";
};&dsi0 {status = "okay";//dsi时钟=像素时钟*颜色位数(RGB888则为24)/4rockchip,lane-rate = <520>;panel: panel {dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_EOT_PACKET | MIPI_DSI_MODE_LPM)>;dsi,format = <MIPI_DSI_FMT_RGB888>;bus-format = <MEDIA_BUS_FMT_RBG888_1X24>;dsi,lanes = <4>;//dsi,channel = <1>;reset-delay-ms = <30>;init-delay-ms = <100>;enable-delay-ms = <100>;prepare-delay-ms = <100>;unprepare-delay-ms = <100>; status = "okay";//指令表,位数号(39则位数>2,15则位数=2,05则位数=1) 延时 位数 指令1 指令2 指令3...panel-init-sequence = [39 00 04 FF 98 81 0315 00 02 01 0015 00 02 02 0015 00 02 03 7315 00 02 04 0015 00 02 05 0015 00 02 06 0815 00 02 07 0015 00 02 08 0015 00 02 09 0015 00 02 0A 0115 00 02 0B 0115 00 02 0C 0015 00 02 0D 0115 00 02 0E 0115 00 02 0F 0015 00 02 10 0015 00 02 11 0015 00 02 12 0015 00 02 13 0015 00 02 14 0015 00 02 15 0015 00 02 16 0015 00 02 17 0015 00 02 18 0015 00 02 19 0015 00 02 1A 0015 00 02 1B 0015 00 02 1C 0015 00 02 1D 0015 00 02 1E 4015 00 02 1F C015 00 02 20 0615 00 02 21 0115 00 02 22 0615 00 02 23 0115 00 02 24 8815 00 02 25 8815 00 02 26 0015 00 02 27 0015 00 02 28 3B15 00 02 29 0315 00 02 2A 0015 00 02 2B 0015 00 02 2C 0015 00 02 2D 0015 00 02 2E 0015 00 02 2F 0015 00 02 30 0015 00 02 31 0015 00 02 32 0015 00 02 33 0015 00 02 34 00 15 00 02 35 0015 00 02 36 0015 00 02 37 0015 00 02 38 0015 00 02 39 0015 00 02 3A 0015 00 02 3B 0015 00 02 3C 0015 00 02 3D 0015 00 02 3E 0015 00 02 3F 0015 00 02 40 0015 00 02 41 0015 00 02 42 0015 00 02 43 0015 00 02 44 00/*GIP_2*/15 00 02 50 0115 00 02 51 2315 00 02 52 4515 00 02 53 6715 00 02 54 8915 00 02 55 AB15 00 02 56 0115 00 02 57 2315 00 02 58 4515 00 02 59 6715 00 02 5A 8915 00 02 5B AB15 00 02 5C CD15 00 02 5D EF/*GIP_3 */15 00 02 5E 0015 00 02 5F 0115 00 02 60 0115 00 02 61 0615 00 02 62 0615 00 02 63 0715 00 02 64 0715 00 02 65 0015 00 02 66 0015 00 02 67 0215 00 02 68 0215 00 02 69 0515 00 02 6A 0515 00 02 6B 0215 00 02 6C 0D15 00 02 6D 0D15 00 02 6E 0C15 00 02 6F 0C15 00 02 70 0F15 00 02 71 0F15 00 02 72 0E15 00 02 73 0E15 00 02 74 0215 00 02 75 0115 00 02 76 0115 00 02 77 0615 00 02 78 0615 00 02 79 0715 00 02 7A 0715 00 02 7B 0015 00 02 7C 0015 00 02 7D 0215 00 02 7E 0215 00 02 7F 0515 00 02 80 0515 00 02 81 0215 00 02 82 0D15 00 02 83 0D15 00 02 84 0C15 00 02 85 0C15 00 02 86 0F15 00 02 87 0F15 00 02 88 0E15 00 02 89 0E15 00 02 8A 02/*Page 4 command;*/39 00 04 FF 98 81 0415 00 02 3B C015 00 02 6C 1515 00 02 6E 2A15 00 02 6F 3315 00 02 8D 1B15 00 02 87 BA15 00 02 3A 2415 00 02 26 7615 00 02 B2 D1/* Page 1 command */39 00 04 FF 98 81 0115 00 02 22 0A15 00 02 31 0015 00 02 40 5315 00 02 43 6615 00 02 53 4C15 00 02 50 8715 00 02 51 8215 00 02 60 1515 00 02 61 0115 00 02 62 0C15 00 02 63 00/* Gamma P*/ 15 00 02 A0 0015 00 02 A1 1315 00 02 A2 2315 00 02 A3 1415 00 02 A4 1615 00 02 A5 2915 00 02 A6 1E15 00 02 A7 1D15 00 02 A8 8615 00 02 A9 1E15 00 02 AA 2915 00 02 AB 7415 00 02 AC 1915 00 02 AD 1715 00 02 AE 4B15 00 02 AF 2015 00 02 B0 2615 00 02 B1 4C15 00 02 B2 5D15 00 02 B3 3F/* Gamma N*/ 15 00 02 C0 0015 00 02 C1 1315 00 02 C2 2315 00 02 C3 1415 00 02 C4 1615 00 02 C5 2915 00 02 C6 1E15 00 02 C7 1D15 00 02 C8 8615 00 02 C9 1E15 00 02 CA 2915 00 02 CB 7415 00 02 CC 1915 00 02 CD 1715 00 02 CE 4B15 00 02 CF 2015 00 02 D0 2615 00 02 D1 4C15 00 02 D2 5D15 00 02 D3 3F/* Page 0 command*/39 00 04 FF 98 81 0015 00 02 35 0005 78 01 1105 14 01 29];panel-exit-sequence = [05 16 01 2805 78 01 10];disp_timings: display-timings {native-mode = <&panel_timing>;panel_timing: timing0 {//像素时钟=htotal*vtotal*fps(帧率),rk同步时长用lenclock-frequency = <68430000>;hactive = <800>;vactive = <1280>;hback-porch = <10>;hfront-porch = <50>;hsync-len = <20>;vback-porch = <8>;vfront-porch = <4>;vsync-len = <4>;hsync-active = <0>;vsync-active = <0>;de-active = <0>;pixelclk-active = <0>;};};};
};
3、(屏没亮时)硬件情况解决方法
1、再查软件屏幕没问题则换一块mipi屏百分百可以亮的屏幕看是否可以点亮。点亮则查线序。
2、再查板子的引脚电压mipi_reset、mipi_vcc、mipi_1V8是否可以供得起屏幕亮起。一般MIPIOUT附近都有测试点可供测量。
3、查屏幕,拿到屏幕规格书对线序,板子接上屏幕。万用表调至电阻档关键测数据脚以及mipi_reset、mipi_vcc、mipi_1V8。
4、最后再不济才用示波器来量时序。
八、海思烧录内核
1、串口下,导出panel.img
dd写分区
导出panel.img:
dd of=/data/panel.img if=/dev/block/platform/soc/f9830000.emmc/by-name/panelparam
写入panel.img:
dd if=/data/panel.img of=/dev/block/platform/soc/f9830000.emmc/by-name/panelparam写入boot内核 :
dd if=/data/boot.img of=/dev/block/platform/soc/f9830000.emmc/by-name/boot && dd if=/data/dtbo.img of=/dev/block/platform/soc/f9830000.emmc/by-name/dtbo写入fastboot:
dd if=/data/slaveboot.bin of=/dev/block/platform/soc/f9830000.emmc/by-name/slaveboot && dd if=/data/fastboot.bin of=/dev/block/platform/soc/f9830000.emmc/by-name/fastbootl写入logo
dd if=/data/logo.img of=/dev/block/platform/soc/f9830000.emmc/by-name/logo
导出panel.img:
dd of=/storage/sda1/panel.img if=/dev/block/platform/soc/f9830000.emmc/by-name/panelparam
写入panel.img:
dd if=/storage/sda1/panel.img of=/dev/block/platform/soc/f9830000.emmc/by-name/panelparam
2、打开hitool导入刚刚导出的panel.img修改再导入到板子中。
九、麦克风适配
1、源码路径:rockchip/audio/tinyalsa_hal/audio_hw.c
//已经连接上后会有声卡节点提示
#if FORCE_MIC_TO_USB_MIC//pgz 20171207, force mic to usb micif( (in->device | AUDIO_DEVICE_BIT_IN) == AUDIO_DEVICE_IN_BUILTIN_MIC){ALOGE("pgz start_input_stream() force mic to usb mic");in->device = AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET & (~AUDIO_DEVICE_BIT_IN);}
#endifin_dump(in, 0);route_pcm_open(getRouteFromDevice(in->device | AUDIO_DEVICE_BIT_IN));if( (in->device | AUDIO_DEVICE_BIT_IN) == AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET){in->pcm = pcm_open(PCM_CARD_USB, PCM_DEVICE, PCM_IN, in->config);}else{in->pcm = pcm_open(PCM_CARD, PCM_DEVICE, PCM_IN, in->config);}
十、wifi适配
1、资料路径
Z:\rk3566\RKDocs\android\wifi
2、.ko模块路径
//编译内核只需替换对应.ko即可
console:/vendor/lib/modules # ls
8188eu.ko 8723ds.ko 8822bs.ko modules.alias modules.softdep
8189fs.ko 8812cu.ko bcmdhd.ko modules.dep
8723cs.ko 8821cs.ko mali_kbase.ko modules.load
//查询是否加载模块命令
lsmod
//插入.ko模块命令insmod 8723ds.ko
十一、rk平台适配蓝牙遥控器
目的:修改中心键键值ENTER为DPAD_CENTER
先找到对应中心键的位置码值
XMR3399C:/ # getevent -lrt
add device 1: /dev/input/event4name: "小米蓝牙语音遥控器"
add device 2: /dev/input/event1name: "Logitech USB Optical Mouse"
add device 3: /dev/input/event2name: "gpio-keys"
add device 4: /dev/input/event0name: "adc_keys"
add device 5: /dev/input/event3name: "ff420030.pwm"
[ 293.174312] /dev/input/event4: EV_MSC MSC_SCAN 00070028
[ 293.174312] /dev/input/event4: EV_KEY KEY_ENTER DOWN
[ 293.174312] /dev/input/event4: EV_SYN SYN_REPORT 00000000
通过getevent命令可找到对应的SCAN码:00070028。首先可知0007时keyboard类型,rk参考/kernel/include/linux/hid.h
海思:hisilicon/bigfish/sdk/source/kernel/linux-4.9.y/include/linux/hid.h
/** HID usage tables*/#define HID_USAGE_PAGE 0xffff0000#define HID_UP_UNDEFINED 0x00000000
#define HID_UP_GENDESK 0x00010000
#define HID_UP_SIMULATION 0x00020000
#define HID_UP_GENDEVCTRLS 0x00060000
#define HID_UP_KEYBOARD 0x00070000
#define HID_UP_LED 0x00080000
#define HID_UP_BUTTON 0x00090000
其次0028其实为码值数组下标,具体数组位置如下。
/kernel/drivers/hid/hid-input.c
static const unsigned char hid_keyboard[256] = {
0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26,
27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106,
105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71,
72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190,
191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113,
115,114,unk,unk,unk,121,unk, 89, 93,124, 92, 94, 95,unk,unk,unk,
122,123, 90, 91, 85,unk,unk,unk,unk,unk,unk,unk,111,unk,unk,unk,
unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
unk,unk,unk,unk,unk,unk,179,180,unk,unk,unk,unk,unk,unk,unk,unk,
unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
unk,unk,unk,unk,unk,unk,unk,unk,111,unk,unk,unk,unk,unk,unk,unk,
29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,
150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk
};
28意为第2行(0,1,2)第8列(0,1,2)的码值。即按下遥控中间键产生的码值为28对应linux码值为ENTER。所以我们要想改变为DPAD_CENTER,其实将28修改为353即可。为了不改动公版原来的码值,这里应修改对应的.kl文件来达到效果。
如果只改.kl只需要上传修改的对应键值就可以了,其它的找不到会默认到Generic.kl下寻找。
十二、rk平台适配i2c传感器
1、查看传感器是否有对应驱动
2、如果有则寻找驱动compatible名字以及对应i2c地址
3、查看板卡对应的端子是哪路i2c
4、编写对应驱动
&i2c3 {status = "okay";sensor@76 {compatible ="meas,ms5637";reg = <0x76>;type = <8>;//压力传感器irq_enable = <0>;poll_delay_ms = <100>;};sensor@19 {compatible ="gs_sc7a20";reg = <0x19>;type = <2>;//加速度传感器irq_enable = <0>;poll_delay_ms = <100>;};sensor@48 {compatible = "ls_stk3x1x";reg = <0x48>;type = <5>;irq_enable = <0>;//光照传感器poll_delay_ms = <100>;layout = <1>;};
};
5、调试命令
i2cdetect -y 3
结果:出现16进制数字说明识别到设备但未匹配到驱动,出现到UU说明已经出现驱动有可能匹配成功。若未成功还要再看一下驱动代码。
十三、重力传感器X轴反向
kernel/rockchip/sensor/st/MmaSensor.cpp
void MmaSensor::processEvent(int code, int value)
{#ifndef GSENSOR_MXC6655XA_SUPPORTswitch (code) {case EVENT_TYPE_ACCEL_X:
+ #if MMASENSOR_NEGATIVE_X
+ value = -value;
+ #endifmPendingEvent.acceleration.x = (value - accel_offset[0]) * ACCELERATION_RATIO_ANDROID_TO_HW;break;case EVENT_TYPE_ACCEL_Y:mPendingEvent.acceleration.y = (value - accel_offset[1]) * ACCELERATION_RATIO_ANDROID_TO_HW;break;case EVENT_TYPE_ACCEL_Z:mPendingEvent.acceleration.z = (value - accel_offset[2]) * ACCELERATION_RATIO_ANDROID_TO_HW;break;}#elsestatic float fAccRawData[3] = {0.0};float dataOut[3] = {0.0};int returnFlag = 0;switch (code) {case EVENT_TYPE_ACCEL_X:#if MMASENSOR_NEGATIVE_Xvalue = -value;#endifmPendingEvent.acceleration.x = (value - accel_offset[0]) * ACCELERATION_RATIO_ANDROID_TO_HW;fAccRawData[0]=mPendingEvent.acceleration.x / 9.80665;break;case EVENT_TYPE_ACCEL_Y:...}
十四、拔掉摄像头程序崩溃
kernel/drivers/media/common/videobuf2/videobuf2-core.c
static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
{/** All operations on vb_done_list are performed under done_lock* spinlock protection. However, buffers may be removed from* it and returned to userspace only while holding both driver's* lock and the done_lock spinlock. Thus we can be sure that as* long as we hold the driver's lock, the list will remain not* empty if list_empty() check succeeds.*/for (;;) {int ret;if (q->waiting_in_dqbuf) {dprintk(1, "another dup()ped fd is waiting for a buffer\n");return -EBUSY;}if (!q->streaming) {dprintk(1, "streaming off, will not wait for buffers\n");return -EINVAL;}if (q->error) {dprintk(1, "Queue in error state, will not wait for buffers\n");return -EIO;}if (q->last_buffer_dequeued) {dprintk(3, "last buffer dequeued already, will not wait for buffers\n");return -EPIPE;}if (!list_empty(&q->done_list)) {/** Found a buffer that we were waiting for.*/break;}if (nonblocking) {dprintk(3, "nonblocking and no buffers to dequeue, will not wait\n");return -EAGAIN;}q->waiting_in_dqbuf = 1;/** We are streaming and blocking, wait for another buffer to* become ready or for streamoff. Driver's lock is released to* allow streamoff or qbuf to be called while waiting.*/call_void_qop(q, wait_prepare, q);/** All locks have been released, it is safe to sleep now.*/dprintk(3, "will sleep waiting for buffers\n");
+ ret = wait_event_interruptible_timeout(q->done_wq,
+ !list_empty(&q->done_list) || !q->streaming ||
+ q->error, msecs_to_jiffies(5000));
+ if (!ret) {
+ printk("dqbuf timeout \n");
+ return -ETIME;
+ }/** We need to reevaluate both conditions again after reacquiring* the locks or return an error if one occurred.*/call_void_qop(q, wait_finish, q);q->waiting_in_dqbuf = 0;
+ if (ret < 0) {dprintk(1, "sleep was interrupted\n");return ret;}}return 0;
}