diff --git a/framework/model/input/driver/hdf_hid_adapter.c b/framework/model/input/driver/hdf_hid_adapter.c index c6d0016b9978a8c9198b1a8c554272fa9e5618fb..8195529b2842dc3334c7a066e41a70c2ca39efa3 100644 --- a/framework/model/input/driver/hdf_hid_adapter.c +++ b/framework/model/input/driver/hdf_hid_adapter.c @@ -123,6 +123,7 @@ static void FreeCachedInfo(void) static int32_t SetInputDevAbsAttr(InputDevice *inputDev, const HidInfo *info) { + HDF_LOGI("%s: Cache hid device", __func__); int32_t ret; int i; for (i = 0; i < BITS_TO_LONG(ABS_CNT); i++) { @@ -298,6 +299,7 @@ static void RepateEvent(const InputDevice *device) void HidReportEvent(const void *inputDev, uint32_t type, uint32_t code, int32_t value) { + HDF_LOGI("%s: AAA start", __func__); bool loaded = InputDriverLoaded(); if (!loaded) { HDF_LOGD("%s: device not loaded", __func__); diff --git a/framework/model/input/driver/hdf_input_device_manager.c b/framework/model/input/driver/hdf_input_device_manager.c index e2c08a3414afd9bb8a96d93f8c539919c2213e73..2e5282cbaf20464709b41a003ed41f3d4646c736 100644 --- a/framework/model/input/driver/hdf_input_device_manager.c +++ b/framework/model/input/driver/hdf_input_device_manager.c @@ -45,6 +45,7 @@ static bool IsHidDevice(InputDevice *inputDev) static struct HdfDeviceObject *HidRegisterHdfDevice(InputDevice *inputDev) { + HDF_LOGI("%s: AAA start", __func__); char svcName[SERVICE_NAME_LEN] = {0}; const char *moduleName = "HDF_HID"; struct HdfDeviceObject *hdfDev = NULL; @@ -81,6 +82,7 @@ static struct HdfDeviceObject *HidRegisterHdfDevice(InputDevice *inputDev) static void HotPlugNotify(const InputDevice *inputDev, uint32_t status) { + HDF_LOGI("%s: AAA start", __func__); HotPlugEvent event = {0}; int32_t ret; @@ -107,6 +109,7 @@ static void HotPlugNotify(const InputDevice *inputDev, uint32_t status) static int32_t CreateDeviceNode(InputDevice *inputDev) { + HDF_LOGI("%s: AAA start", __func__); if (IsHidDevice(inputDev)) { HDF_LOGI("%s: prepare to register hdf device", __func__); inputDev->hdfDevObj = HidRegisterHdfDevice(inputDev); @@ -122,6 +125,7 @@ static int32_t CreateDeviceNode(InputDevice *inputDev) static void DeleteDeviceNode(InputDevice *inputDev) { + HDF_LOGI("%s: AAA start", __func__); if (IsHidDevice(inputDev)) { HDF_LOGI("remove input device: hdf_input_event%u", inputDev->devId); HdfDeviceObjectRelease(inputDev->hdfDevObj); @@ -132,6 +136,7 @@ static void DeleteDeviceNode(InputDevice *inputDev) static void AddInputDevice(InputDevice *inputDev) { + HDF_LOGI("%s: AAA start", __func__); InputDevice *tmpDev = NULL; if (g_inputManager->inputDevList == NULL) { g_inputManager->inputDevList = inputDev; @@ -153,6 +158,7 @@ static void AddInputDevice(InputDevice *inputDev) static int32_t CheckInputDevice(InputDevice *inputDev) { + HDF_LOGI("%s: AAA start", __func__); InputDevice *tmpDev = NULL; if (g_inputManager->inputDevList == NULL) { return HDF_SUCCESS; @@ -210,6 +216,7 @@ EXIT: static int32_t AllocPackageBuffer(InputDevice *inputDev) { + HDF_LOGI("%s: AAA start", __func__); uint16_t pkgNum; switch (inputDev->devType) { case INDEV_TYPE_TOUCH: @@ -256,6 +263,7 @@ static int32_t AllocPackageBuffer(InputDevice *inputDev) static int32_t AllocDeviceID(InputDevice *inputDev) { + HDF_LOGI("%s: AAA start", __func__); InputDevice *tmpDev = g_inputManager->inputDevList; uint32_t idList[MAX_INPUT_DEV_NUM + 1]; uint32_t id; @@ -313,6 +321,7 @@ static int32_t InitEventWorkQueue(InputDevice *inputDev) int32_t RegisterInputDevice(InputDevice *inputDev) { + HDF_LOGI("%s: AAA start", __func__); int32_t ret; HDF_LOGI("%s: enter", __func__); @@ -362,7 +371,7 @@ EXIT: void UnregisterInputDevice(InputDevice *inputDev) { int32_t ret; - HDF_LOGI("%s: enter", __func__); + HDF_LOGI("%s: AAA start", __func__); if (inputDev == NULL) { HDF_LOGE("%s: inputdev is null", __func__); return; @@ -405,12 +414,14 @@ EXIT: static uint32_t GetDeviceCount(void) { + HDF_LOGI("%s: AAA start", __func__); HDF_LOGI("%s: devCount = %d", __func__, g_inputManager->devCount); return g_inputManager->devCount; } static int32_t ScanAllDev(struct HdfSBuf *reply) { + HDF_LOGI("%s: AAA start", __func__); DevDesc sta; InputDevice *tmpDev = g_inputManager->inputDevList; while (tmpDev != NULL) { @@ -430,6 +441,7 @@ static int32_t ScanAllDev(struct HdfSBuf *reply) static int32_t ScanDevice(struct HdfDeviceIoClient *client, int32_t cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { + HDF_LOGI("%s: AAA start", __func__); (void)cmd; int32_t ret; if ((client == NULL) || (data == NULL) || (reply == NULL)) { @@ -445,6 +457,7 @@ static int32_t ScanDevice(struct HdfDeviceIoClient *client, int32_t cmd, static int32_t HdfInputManagerBind(struct HdfDeviceObject *device) { + HDF_LOGI("%s: AAA start", __func__); if (device == NULL) { HDF_LOGE("%s: device is null", __func__); return HDF_ERR_INVALID_PARAM; @@ -461,6 +474,7 @@ static int32_t HdfInputManagerBind(struct HdfDeviceObject *device) static InputManager *InputManagerInstance(void) { + HDF_LOGI("%s: AAA start", __func__); InputManager *manager = (InputManager *)OsalMemAlloc(sizeof(InputManager)); if (manager == NULL) { HDF_LOGE("%s: instance input manager failed", __func__); @@ -472,7 +486,7 @@ static InputManager *InputManagerInstance(void) static int32_t HdfInputManagerInit(struct HdfDeviceObject *device) { - HDF_LOGI("%s: enter", __func__); + HDF_LOGI("%s: AAA start", __func__); if (device == NULL) { HDF_LOGE("%s: device is null", __func__); return HDF_ERR_INVALID_PARAM; diff --git a/framework/model/input/driver/hdf_touch.c b/framework/model/input/driver/hdf_touch.c index dedb726dc027a9ff8980849f640367bf170b02a4..48ade902e8efff143c7e7aa4a6e9b1c96bda4db3 100644 --- a/framework/model/input/driver/hdf_touch.c +++ b/framework/model/input/driver/hdf_touch.c @@ -15,6 +15,9 @@ #include "osal_io.h" #include "event_hub.h" #include "input_i2c_ops.h" +#include +#include +#include #if defined(CONFIG_ARCH_ROCKCHIP) #include @@ -42,9 +45,12 @@ static int32_t ChipCheckResetRetry(ChipDevice *chipDev); static TouchDriver *g_touchDriverList[MAX_TOUCH_DEVICE]; static void InputFrameReport(TouchDriver *driver); static int SuspendFlag = 0; - +static uint64_t timeArray[100]; +static DEFINE_MUTEX(my_mutex); +static int32_t i = 0; static int32_t SetGpioDirAndLevel(int gpio, int dir, int level) { + HDF_LOGI("%s: AAA start", __func__); int32_t ret; if ((dir == GPIO_DIR_IN) || (dir == GPIO_DIR_OUT)) { ret = GpioSetDir(gpio, dir); @@ -186,6 +192,7 @@ static int32_t InputPinMuxCfg(uint32_t regAddr, int32_t regSize, uint32_t regVal #if defined(CONFIG_ARCH_ROCKCHIP) static int32_t SetResetStatus(TouchDriver *driver) { + HDF_LOGI("%s: AAA start", __func__); int32_t ret; uint8_t writeBuf[5]; // 5: buffer size @@ -215,6 +222,7 @@ static int32_t SetResetStatus(TouchDriver *driver) static int32_t Gt1xRequestIo(ChipDevice *chipDev) { + HDF_LOGI("%s: AAA start", __func__); int32_t ret; ret = SetGpio(chipDev->boardCfg->pins.rstGpio, 1, 0); if (ret != HDF_SUCCESS) { @@ -239,6 +247,7 @@ static int32_t Gt1xRequestIo(ChipDevice *chipDev) static int32_t HandleSeqArray(SeqArray *src, PowerEventHandler eventHandler, ChipDevice *chipDev) { + HDF_LOGI("%s: AAA start", __func__); int32_t i; SeqArray pwrTiming = {0}; int32_t ret = memcpy_s(&pwrTiming, sizeof(SeqArray), src, sizeof(SeqArray)); @@ -260,6 +269,7 @@ static int32_t HandleSeqArray(SeqArray *src, PowerEventHandler eventHandler, Chi static int32_t SetTiming(ChipDevice *chipDev, bool enable) { + HDF_LOGI("%s: AAA start", __func__); #if defined(CONFIG_ARCH_MESON) return HDF_SUCCESS; #endif @@ -304,6 +314,7 @@ static int32_t SetTiming(ChipDevice *chipDev, bool enable) static void EventHandle(TouchDriver *driver, ChipDevice *chipDev) { + HDF_LOGI("%s: AAA start", __func__); int32_t ret; if ((chipDev->ops == NULL) || (chipDev->ops->DataHandle == NULL)) { return; @@ -315,8 +326,26 @@ static void EventHandle(TouchDriver *driver, ChipDevice *chipDev) } } +static void SaveTime(uint64_t ms) +{ + // 获取锁 + mutex_lock(&my_mutex); + if (i < 100) { + timeArray[i] = ms; + i++; + } + // 释放锁 + mutex_unlock(&my_mutex); +} + static int32_t IrqHandle(uint16_t intGpioNum, void *data) { + uint64_t ns; // 纳秒 + uint64_t ms; // 毫秒 + ns = ktime_to_ns(ktime_get()); // 获取当前时间(纳秒) + ms = ns / 1000000; // 转换为毫秒 + SaveTime(ms); + TouchDriver *driver = (TouchDriver *)data; int ret = GpioDisableIrq(intGpioNum); if (ret != HDF_SUCCESS) { @@ -390,6 +419,7 @@ static int32_t SetupChipIrq(ChipDevice *chipDev) static void ChipReset(ChipDevice *chipDev) { + HDF_LOGI("%s: AAA start", __func__); if (chipDev == NULL) { HDF_LOGE("%s: invalid param", __func__); return; @@ -571,8 +601,70 @@ static int32_t ChipCheckResetRetry(ChipDevice *chipDev) } #endif +// 线程函数 +static int low_priority_thread(void *data) +{ + printk(KERN_INFO "Low priority thread started\n"); + while (!kthread_should_stop()) { + mutex_lock(&my_mutex); + for (int k = 0; k < i; k++) { + if (timeArray[0] != 0) { + HDF_LOGI("%s: irq time[%d] = %lu", __func__, k, timeArray[i]); + } + } + if ( i == 99) { + break; + } + // 释放锁 + mutex_unlock(&my_mutex); + } + + printk(KERN_INFO "Low priority thread stopped\n"); + return 0; +} + +// 设置线程优先级 +static void set_thread_priority(struct task_struct *thread, int nice_value) +{ + if (nice_value >= -20 && nice_value <= 19) { + set_user_nice(thread, nice_value); + printk(KERN_INFO "Thread priority set to nice value: %d\n", nice_value); + } else { + printk(KERN_INFO "Invalid nice value: %d\n", nice_value); + } +} + +// 模块加载函数 +static int __init low_priority_thread_init(void) +{ + struct task_struct *thread; + + // 创建内核线程 + thread = kthread_create(low_priority_thread, NULL, "low_priority_thread"); + if (IS_ERR(thread)) { + printk(KERN_INFO "Failed to create low priority thread\n"); + return PTR_ERR(thread); + } + + // 设置线程优先级(低优先级,nice value = 19) + set_thread_priority(thread, 19); + + // 启动线程 + wake_up_process(thread); + + return 0; +} + +// 模块卸载函数 +static void __exit low_priority_thread_exit(void) +{ + printk(KERN_INFO "Low priority thread module unloaded\n"); +} + + static int32_t ChipDriverInit(ChipDevice *chipDev) { + HDF_LOGI("%s: AAA start", __func__); int32_t count = 20; // 20: reset time int32_t ret; #if defined(CONFIG_ARCH_ROCKCHIP) @@ -622,12 +714,14 @@ static int32_t ChipDriverInit(ChipDevice *chipDev) #endif ret = SetupChipIrq(chipDev); + low_priority_thread_init(); CHECK_RETURN_VALUE(ret); return HDF_SUCCESS; } static InputDevice *InputDeviceInstance(ChipDevice *chipDev) { + HDF_LOGI("%s: AAA start", __func__); InputDevice *inputDev = (InputDevice *)OsalMemAlloc(sizeof(InputDevice)); if (inputDev == NULL) { HDF_LOGE("%s: instance input device failed", __func__); @@ -645,6 +739,7 @@ static InputDevice *InputDeviceInstance(ChipDevice *chipDev) static int32_t ChipMatchCheck(const ChipDevice *chipDev, const TouchDriver *driver) { + HDF_LOGI("%s: AAA start", __func__); const struct DeviceResourceNode *boardNode = driver->boardCfg->boardNode; const struct DeviceResourceNode *chipNode = chipDev->chipCfg->chipNode; @@ -668,6 +763,7 @@ static int32_t ChipMatchCheck(const ChipDevice *chipDev, const TouchDriver *driv static int32_t DeviceBindDriver(ChipDevice *chipDev) { + HDF_LOGI("%s: AAA start", __func__); TouchDriver *driver = NULL; int32_t ret = HDF_FAILURE; int32_t i; @@ -694,6 +790,7 @@ static int32_t DeviceBindDriver(ChipDevice *chipDev) int32_t RegisterTouchChipDevice(ChipDevice *chipDev) { + HDF_LOGI("%s: AAA start", __func__); int32_t ret; InputDevice *inputDev = NULL; if ((chipDev == NULL) || (chipDev->chipCfg == NULL)) { @@ -733,6 +830,7 @@ EXIT: static int32_t TouchGetDevType(TouchDriver *driver, struct HdfSBuf *reply) { + HDF_LOGI("%s: AAA start", __func__); uint32_t devType = driver->devType; HDF_LOGI("%s: enter, devType is %u", __func__, devType); bool ret = HdfSbufWriteUint32(reply, devType); @@ -745,6 +843,7 @@ static int32_t TouchGetDevType(TouchDriver *driver, struct HdfSBuf *reply) static int32_t TouchSetPowerStatus(TouchDriver *driver, struct HdfSBuf *data) { + HDF_LOGI("%s: AAA start", __func__); uint32_t pwrStatus = 0; bool ret = HdfSbufReadUint32(data, &pwrStatus); if (!ret) { @@ -758,6 +857,7 @@ static int32_t TouchSetPowerStatus(TouchDriver *driver, struct HdfSBuf *data) static int32_t TouchGetPowerStatus(TouchDriver *driver, struct HdfSBuf *reply) { + HDF_LOGI("%s: AAA start", __func__); uint32_t pwrStatus = driver->pwrStatus; bool ret = HdfSbufWriteUint32(reply, pwrStatus); if (!ret) { @@ -770,6 +870,7 @@ static int32_t TouchGetPowerStatus(TouchDriver *driver, struct HdfSBuf *reply) static int32_t TouchGetDeviceStrInfo(TouchDriver *driver, int32_t cmd, struct HdfSBuf *reply) { + HDF_LOGI("%s: AAA start", __func__); const char *info = NULL; if ((driver->device == NULL) || (driver->device->chipCfg == NULL)) { HDF_LOGE("%s: parameter invalid", __func__); @@ -802,6 +903,7 @@ static int32_t TouchGetDeviceStrInfo(TouchDriver *driver, int32_t cmd, struct Hd static int32_t TouchGetDeviceAttr(TouchDriver *driver, struct HdfSBuf *reply) { + HDF_LOGI("%s: AAA start", __func__); char *tempStr = "main_touch"; int32_t ret; if (driver->inputDev == NULL) { @@ -825,6 +927,7 @@ static int32_t TouchGetDeviceAttr(TouchDriver *driver, struct HdfSBuf *reply) static int32_t TouchGetDeviceAbility(TouchDriver *driver, struct HdfSBuf *reply) { + HDF_LOGI("%s: AAA start", __func__); if (driver->inputDev == NULL) { return HDF_FAILURE; } @@ -840,6 +943,7 @@ static int32_t TouchGetDeviceAbility(TouchDriver *driver, struct HdfSBuf *reply) static int32_t TouchSetGestureMode(TouchDriver *driver, struct HdfSBuf *data) { + HDF_LOGI("%s: AAA start", __func__); uint32_t gestureMode = 0; bool ret = HdfSbufReadUint32(data, &gestureMode); if (!ret) { @@ -853,6 +957,7 @@ static int32_t TouchSetGestureMode(TouchDriver *driver, struct HdfSBuf *data) static int32_t TouchSelfCapacitance(TouchDriver *driver, struct HdfSBuf *data, struct HdfSBuf *reply) { + HDF_LOGI("%s: AAA start", __func__); CapacitanceTestInfo capacTest = {0}; bool ret = HdfSbufReadUint32(data, &capacTest.testType); if (!ret) { @@ -876,6 +981,7 @@ static int32_t TouchSelfCapacitance(TouchDriver *driver, struct HdfSBuf *data, s static int32_t TouchRunExtraCmd(TouchDriver *driver, struct HdfSBuf *data) { + HDF_LOGI("%s: AAA start", __func__); InputExtraCmd cmd = {0}; cmd.cmdCode = HdfSbufReadString(data); if (cmd.cmdCode == NULL) { @@ -895,6 +1001,7 @@ static int32_t TouchRunExtraCmd(TouchDriver *driver, struct HdfSBuf *data) static int32_t HdfTouchDispatch(struct HdfDeviceIoClient *client, int32_t cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { + HDF_LOGI("%s: AAA start", __func__); int32_t ret; TouchDriver *touchDriver = NULL; if ((client == NULL) || (client->device == NULL) || (data == NULL) || (reply == NULL)) { @@ -949,6 +1056,7 @@ static int32_t HdfTouchDispatch(struct HdfDeviceIoClient *client, int32_t cmd, static int32_t TouchSetupBus(TouchDriver *driver, TouchBoardCfg *config) { + HDF_LOGI("%s: AAA start", __func__); uint8_t busType = config->bus.busType; uint8_t busNum = config->bus.i2c.busNum; if (busType == I2C_TYPE) { @@ -983,6 +1091,7 @@ static int32_t TouchSetupBus(TouchDriver *driver, TouchBoardCfg *config) static int32_t TouchInitData(TouchDriver *driver, TouchBoardCfg *config) { + HDF_LOGI("%s: AAA start", __func__); driver->devType = config->attr.devType; driver->devName = config->attr.devName; driver->i2cClient.i2cCfg.busNum = config->bus.i2c.busNum; @@ -1008,6 +1117,7 @@ static int32_t TouchDriverInit(TouchDriver *driver, TouchBoardCfg *config) static TouchBoardCfg *BoardConfigInstance(struct HdfDeviceObject *device) { + HDF_LOGI("%s: AAA start", __func__); TouchBoardCfg *boardCfg = (TouchBoardCfg *)OsalMemAlloc(sizeof(TouchBoardCfg)); if (boardCfg == NULL) { HDF_LOGE("%s: instance board config failed", __func__); @@ -1025,6 +1135,7 @@ static TouchBoardCfg *BoardConfigInstance(struct HdfDeviceObject *device) static TouchDriver *TouchDriverInstance(void) { + HDF_LOGI("%s: AAA start", __func__); TouchDriver *touchDrv = (TouchDriver *)OsalMemAlloc(sizeof(TouchDriver)); if (touchDrv == NULL) { HDF_LOGE("%s: instance touch driver failed", __func__); @@ -1047,6 +1158,7 @@ static void AddTouchDriver(TouchDriver *driver) static int32_t HdfTouchDriverBind(struct HdfDeviceObject *device) { + HDF_LOGI("%s: AAA start", __func__); if (device == NULL) { HDF_LOGE("%s: param is null", __func__); return HDF_ERR_INVALID_PARAM; @@ -1086,6 +1198,7 @@ static int HdfTouchDriverDozeResume(struct HdfDeviceObject *device) static int HdfTouchDriverDozeSuspend(struct HdfDeviceObject *device) { + HDF_LOGI("%s: AAA start", __func__); if (device == NULL) { HDF_LOGE("%s: param is null", __func__); return HDF_ERR_INVALID_PARAM; @@ -1121,6 +1234,7 @@ static int HdfTouchDriverDozeSuspend(struct HdfDeviceObject *device) static void HdfTouchDriverRegisterPowerListener(struct HdfDeviceObject *device) { + HDF_LOGI("%s: AAA start", __func__); int ret; static struct IPowerEventListener powerListener = {0}; HDF_LOGI("%s::enter!", __func__); @@ -1135,6 +1249,7 @@ static void HdfTouchDriverRegisterPowerListener(struct HdfDeviceObject *device) static void HdfTouchDriverUnregisterPowerListener(struct HdfDeviceObject *device) { + HDF_LOGI("%s: AAA start", __func__); static struct IPowerEventListener powerListener = {0}; HDF_LOGI("%s::enter!", __func__); powerListener.DozeResume = NULL; @@ -1191,6 +1306,7 @@ EXIT: static void HdfTouchDriverRelease(struct HdfDeviceObject *device) { + HDF_LOGI("%s: AAA start", __func__); TouchDriver *driver = NULL; InputDevice *inputDev = NULL; int32_t i;