rk3568 power key
一,概略图
关键字
rk3568、powerkey、电源、按键
概略图
设备树文件
rk3568-toybrick-x10.dtsi // out目录生成
rk3568-toybrick-x10-linux.dts
- power键对应的设备树文件并不是 input_device.hcs
linux 设备树查看:/proc/device-tree
设备树节点
dev/input/event1:rk805 pwrkey 设备节点
[ 0.966480] input: rk805 pwrkey as /devices/platform/fdd40000.i2c/i2c-0/0-0020/rk805-pwrkey/input/input1 // sys/class/input/input1
[ 0.966816] [I/HDF_LOG_TAG] HidRegisterHdfInputDev: enter devName=hid-powerkey, devType=1
HidRegisterHdfDevice: svcName is hdf_input_event2, devName = hid-powerkey // /sys/class/hdf/hdf_input_event2
powerkey按键有两个设备节点:
- sys/class/input/input1
- sys/class/hdf/hdf_input_event2
cat /proc/interrupts 查看硬件中断
rk3568 power键中断是rk817
rk3568内核配置文件
kernel/linux/config/linux-5.10/arch/arm64/configs/rk3568_standard_defconfig
# CONFIG_INPUT_PWM_BEEPER is not set
# CONFIG_INPUT_PWM_VIBRA is not set
CONFIG_INPUT_RK805_PWRKEY=y
# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
# CONFIG_INPUT_ADXL34X is not set
对应的驱动文件:kernel/linux/linux-5.10/drivers/input/misc/rk805-pwrkey.c 还有其他关联驱动如kernel/linux/linux-5.10/drivers/mfd/rk808.c
底层设备按键事件先传递给Linux、hid驱动,再将此事件上报
注册驱动
有patch :out/kernel/src_tmp/linux-5.10/drivers/input/misc/rk805-pwrkey.c (input_register_device注册Linux驱动, HidRegisterHdfPowerKeyDev 注册hid驱动》
out/kernel/src_tmp/linux-5.10/drivers/hdf/framework/model/input/driver/hdf_hid_adapter.c : HidRegisterHdfInputDev
中断处理
rk805-pwrkey.c 收到中断后调用驱动中的input_report_key、HidReportEvent 函数上报事件
mmi-service中会监控eventX设备节点,获取处理事件信息,并将按键事件传递给订阅此事件的服务;
当前未用到的流程:
HidReportEvent调用drivers/hdf_core/framework/model/input/driver/event_hub.c :PushOnePackage 然后调用 HdfAddWork将工作添加到工作队列中(在(input_manager.c中有定义和初始化,为event_hub.c中定义的EventQueueWorkEntry函数,主线中在源码中定义,4.1r代码在patch中添加), EventQueueWorkEntry函数中调用HdfDeviceSendEvent接口后,用户可感知此事件
用户态处理或业务
多模在mmi-service中监控/dev/input/event1
foundation/multimodalinput/input/service/module_loader/src/mmi_service.cpp : InitLibinputService
bool MMIService::InitLibinputService()
{
if (!(libinputAdapter_.Init([] (void *event, int64_t frameTime) { // 初始化libinputAdapter,并传入接收event的回调函数(input_event_handler.cpp: OnEvent);libinputAdapter中会扫描打开eventX,获取fd
::OHOS::DelayedSingleton<InputEventHandler>::GetInstance()->OnEvent(event, frameTime);
}
))) {
MMI_HILOGE("Libinput init, bind failed");
return false;
}
auto inputFds = libinputAdapter_.GetInputFds(); // 获取被监控设备节点eventX文件的描述符fd
for (auto fd : inputFds) {
auto ret = AddEpoll(EPOLL_EVENT_INPUT, fd); // 添加epoll,监控设备节点
if (ret < 0) {
MMI_HILOGE("AddEpoll error ret:%{public}d", ret);
EpollClose();
return false;
}
MMI_HILOGD("AddEpoll, epollfd:%{public}d, fd:%{public}d", mmiFd_, fd);
}
return true;
}
检测到按键事件后到foundation/multimodalinput/input/service/event_handler/src/input_event_handler.cpp: OnEvent
然后foundation/multimodalinput/input/service/event_handler/src/event_normalize_handler.cpp 规范化处理
... ...
- 休眠控制:base/powermgr/power_manager/services/native/src/suspend/suspend_controller.cpp中通过多模的inputmanager订阅接收按键事件 然后调用熄屏函数BeginPowerkeyScreenOff
- 唤醒控制:base/powermgr/power_manager/services/native/src/wakeup/wakeup_controller.cpp中接收按键事件然后判断是否中断休眠
- 长按关机:rk中没这个代码,大体逻辑是订阅电源键长按事件,收到事件收调用关机流程,如下图:
更多推荐
所有评论(0)