diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index b838468a7d39d05f920373823f5d9f570474d532..c11238b683d6c238b5253c8aba09bcf4f75337d4 100644 --- a/model/input/driver/hdf_hid_adapter.c +++ b/model/input/driver/hdf_hid_adapter.c @@ -15,6 +15,7 @@ #include "hdf_hid_adapter.h" InputDevice *cachedHid[MAX_INPUT_DEV_NUM]; +HidInfo cachedInfo[MAX_INPUT_DEV_NUM]; static bool HaveHidCache(void) { @@ -42,6 +43,74 @@ static void LoadCachedHid(void) } } +static int cachedPosId(void) +{ + int32_t id = 0; + while (id < MAX_INPUT_DEV_NUM) { + if (cachedInfo[id].devName == NULL) { + return id; + } + id++; + } + return HDF_FAILURE; +} + +void GetInfoFromHid(HidInfo info) +{ + int32_t id = cachedPosId(); + if (id == HDF_FAILURE) { + HDF_LOGE("%s: cached hid info failed", __func__); + return; + } + cachedInfo[id] = info; +} + +static void SetInputDevAbility(InputDevice *inputDev) +{ + HidInfo info; + int32_t id = 0; + uint32_t len; + while (id < MAX_INPUT_DEV_NUM) { + if(cachedInfo[id].devName != NULL && !strcmp(inputDev->devName, cachedInfo[id].devName)) { + info = cachedInfo[id]; + break; + } + id++; + } + if (id == MAX_INPUT_DEV_NUM) { + HDF_LOGE("%s: match cached info failed", __func__); + return; + } + len = sizeof(unsigned long); + memcpy_s(inputDev->abilitySet.devProp, len * BITS_TO_LONG(INPUT_PROP_CNT), + info.devProp, len * BITS_TO_LONG(INPUT_PROP_CNT)); + memcpy_s(inputDev->abilitySet.eventType, len * BITS_TO_LONG(EV_CNT), + info.eventType, len * BITS_TO_LONG(EV_CNT)); + memcpy_s(inputDev->abilitySet.absCode, len * BITS_TO_LONG(ABS_CNT), + info.absCode, len * BITS_TO_LONG(ABS_CNT)); + memcpy_s(inputDev->abilitySet.relCode, len * BITS_TO_LONG(REL_CNT), + info.relCode, len * BITS_TO_LONG(REL_CNT)); + memcpy_s(inputDev->abilitySet.keyCode, len * BITS_TO_LONG(KEY_CNT), + info.keyCode, len * BITS_TO_LONG(KEY_CNT)); + memcpy_s(inputDev->abilitySet.ledCode, len * BITS_TO_LONG(LED_CNT), + info.ledCode, len * BITS_TO_LONG(LED_CNT)); + memcpy_s(inputDev->abilitySet.miscCode, len * BITS_TO_LONG(MSC_CNT), + info.miscCode, len * BITS_TO_LONG(MSC_CNT)); + memcpy_s(inputDev->abilitySet.soundCode, len * BITS_TO_LONG(SND_CNT), + info.soundCode, len * BITS_TO_LONG(SND_CNT)); + memcpy_s(inputDev->abilitySet.forceCode, len * BITS_TO_LONG(FF_CNT), + info.forceCode, len * BITS_TO_LONG(FF_CNT)); + memcpy_s(inputDev->abilitySet.switchCode, len * BITS_TO_LONG(SW_CNT), + info.switchCode, len * BITS_TO_LONG(SW_CNT)); + + inputDev->attrSet.id.busType = info.bustype; + inputDev->attrSet.id.vendor = info.vendor; + inputDev->attrSet.id.product = info.product; + inputDev->attrSet.id.version = info.version; + + cachedInfo[id].devName = NULL; +} + static InputDevice* HidConstructInputDev(HidInfo info) { InputDevice *inputDev = (InputDevice *)OsalMemAlloc(sizeof(InputDevice)); @@ -53,6 +122,8 @@ static InputDevice* HidConstructInputDev(HidInfo info) inputDev->devType = info.devType; inputDev->devName = info.devName; + SetInputDevAbility(inputDev); + return inputDev; } @@ -121,11 +192,6 @@ void HidReportEvent(const void *inputDev, uint32_t type, uint32_t code, int32_t PushOnePackage((InputDevice *)inputDev, type, code, value); } -void GetInfoFromHid(HidInfo info) -{ - (void)info; -} - static int32_t HdfHIDDriverInit(struct HdfDeviceObject *device) { (void)device; diff --git a/model/input/driver/hdf_input_device_manager.c b/model/input/driver/hdf_input_device_manager.c index 975bdf3df1633ab64fffa21b15eaa6aff0acb414..2db56fd80b31dc570d9a62bc705e0c7ee6003626 100644 --- a/model/input/driver/hdf_input_device_manager.c +++ b/model/input/driver/hdf_input_device_manager.c @@ -7,7 +7,6 @@ */ #include -#include "osal_cdev.h" #include "osal_mem.h" #include "devsvc_manager_clnt.h" #include "hdf_base.h" @@ -31,82 +30,6 @@ InputManager* GetInputManager(void) return g_inputManager; } -#ifndef __KERNEL__ -int32_t TouchIoctl(InputDevice *inputdev, int32_t cmd, unsigned long arg); -uint32_t TouchPoll(struct file *filep, InputDevice *inputDev, poll_table *wait); - -static int32_t InputDevIoctl(struct file *filep, int32_t cmd, unsigned long arg) -{ - int32_t ret; - struct drv_data *drvData = (struct drv_data *)filep->f_vnode->data; - InputDevice *inputdev = (InputDevice *)drvData->priv; - if (inputdev == NULL) { - return HDF_FAILURE; - } - - switch (inputdev->devType) { - case INDEV_TYPE_TOUCH: - ret = TouchIoctl(inputdev, cmd, arg); - break; - default: - ret = 0; - HDF_LOGE("%s: devType unknown, devType = %d", __func__, inputdev->devType); - break; - } - return ret; -} - -static int32_t InputDevOpen(struct file *filep) -{ - struct drv_data *drvData = (struct drv_data *)filep->f_vnode->data; - InputDevice *inputdev = (InputDevice *)drvData->priv; - if (inputdev == NULL) { - HDF_LOGE("%s: filep is null", __func__); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -static int32_t InputDevClose(struct file *filep) -{ - struct drv_data *drvData = (struct drv_data *)filep->f_vnode->data; - InputDevice *inputdev = (InputDevice *)drvData->priv; - if (inputdev == NULL) { - HDF_LOGE("%s: inputdev is null", __func__); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -#ifndef CONFIG_DISABLE_POLL -static int32_t InputDevPoll(struct file *filep, poll_table *wait) -{ - uint32_t pollMask = 0; - struct drv_data *drvData = (struct drv_data *)filep->f_vnode->data; - InputDevice *inputdev = (InputDevice *)drvData->priv; - switch (inputdev->devType) { - case INDEV_TYPE_TOUCH: - pollMask = TouchPoll(filep, inputdev, wait); - break; - default: - HDF_LOGE("%s: devType unknown, devType = %d", __func__, inputdev->devType); - break; - } - return pollMask; -} -#endif - -static const struct file_operations_vfs inputDevOps = { - .open = InputDevOpen, - .close = InputDevClose, - .ioctl = InputDevIoctl, -#ifndef CONFIG_DISABLE_POLL - .poll = InputDevPoll, -#endif -}; - -#endif - static bool IsHidDevice(uint32_t devType) { if ((devType > INDEV_TYPE_HID_BEGIN_POS) && (devType < INDEV_TYPE_UNKNOWN)) { @@ -174,25 +97,6 @@ static int32_t CreateDeviceNode(InputDevice *inputDev) } } -#ifndef __KERNEL__ - char *devNode = (char *)malloc(INPUT_DEV_PATH_LEN); - (void)memset_s(devNode, INPUT_DEV_PATH_LEN, 0, INPUT_DEV_PATH_LEN); - - int32_t ret = snprintf_s(devNode, INPUT_DEV_PATH_LEN, strlen("/dev/input/hdf_input_event") + 1, - "%s%u", "/dev/input/hdf_input_event", inputDev->devId); - if (ret < 0) { - HDF_LOGE("%s: snprintf_s failed", __func__); - return HDF_FAILURE; - } - inputDev->devNode = devNode; - ret = register_driver(inputDev->devNode, &inputDevOps, NODE_MODE, inputDev); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: register %s devnode failed, ret = %d", __func__, devNode, ret); - inputDev->devNode = NULL; - return ret; - } -#endif - HDF_LOGI("%s: create node succ, devId is %d ", __func__, inputDev->devId); return HDF_SUCCESS; } @@ -214,14 +118,6 @@ static void DeleteDeviceNode(InputDevice *inputDev) HdfUnregisterDevice(moduleName, svcName); } -#ifndef __KERNEL__ - int32_t ret = unregister_driver(inputDev->devNode); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: delete dev node failed, ret %d", __func__, ret); - } - free((void *)inputDev->devNode); - inputDev->devNode = NULL; -#endif HDF_LOGI("%s: delete node succ, devId is %d", __func__, inputDev->devId); } @@ -509,20 +405,11 @@ static InputManager *InputManagerInstance(void) static int32_t HdfInputManagerInit(struct HdfDeviceObject *device) { HDF_LOGI("%s: enter", __func__); - int32_t ret; if (device == NULL) { HDF_LOGE("%s: device is null", __func__); return HDF_ERR_INVALID_PARAM; } -#ifndef __KERNEL__ - ret = mkdir("/dev/input", DEFAULT_DIR_MODE); - if ((ret < 0) && (errno != EEXIST)) { - HDF_LOGE("%s: mkdir fail, ret %d, error = %d\n", __func__, ret, errno); - return HDF_FAILURE; - } -#endif - g_inputManager = InputManagerInstance(); if (g_inputManager == NULL) { return HDF_ERR_MALLOC_FAIL; diff --git a/model/input/driver/hdf_input_device_manager.h b/model/input/driver/hdf_input_device_manager.h index 4179866181c9c01b02f9d7731a5a1df20e49a821..bed6437fbb8c7cbe49afc9033c6f1919f89dced9 100644 --- a/model/input/driver/hdf_input_device_manager.h +++ b/model/input/driver/hdf_input_device_manager.h @@ -24,6 +24,20 @@ #define ONLINE 0 #define OFFLINE 1 +#ifdef DIV_ROUND_UP +#undef DIV_ROUND_UP +#endif +#define DIV_ROUND_UP(nr, d) (((nr) + (d) - 1) / (d)) + +#define BYTE_HAS_BITS 8 +#define BITS_TO_UINT64(count) DIV_ROUND_UP(count, BYTE_HAS_BITS * sizeof(unsigned long)) + +#define BITS_PER_LONG 32 +#define SET_BIT(nr) (1UL << ((nr) % BITS_PER_LONG)) + +#define FF_MAX 0x7f +#define FF_CNT (FF_MAX + 1) + #define CHECK_RETURN_VALUE(ret) do { \ if ((ret) != HDF_SUCCESS) { \ return ret; \ @@ -46,17 +60,57 @@ typedef struct { uint32_t (*getDeviceCount)(void); } IInputManagerService; +typedef struct { + unsigned long devProp[BITS_TO_UINT64(INPUT_PROP_CNT)]; + unsigned long eventType[BITS_TO_UINT64(EV_CNT)]; + unsigned long absCode[BITS_TO_UINT64(ABS_CNT)]; + unsigned long relCode[BITS_TO_UINT64(REL_CNT)]; + unsigned long keyCode[BITS_TO_UINT64(KEY_CNT)]; + unsigned long ledCode[BITS_TO_UINT64(LED_CNT)]; + unsigned long miscCode[BITS_TO_UINT64(MSC_CNT)]; + unsigned long soundCode[BITS_TO_UINT64(SND_CNT)]; + unsigned long forceCode[BITS_TO_UINT64(FF_CNT)]; + unsigned long switchCode[BITS_TO_UINT64(SW_CNT)]; + unsigned long keyType[BITS_TO_UINT64(KEY_CNT)]; + unsigned long ledType[BITS_TO_UINT64(LED_CNT)]; + unsigned long soundType[BITS_TO_UINT64(SND_CNT)]; + unsigned long switchType[BITS_TO_UINT64(SW_CNT)]; +} DevAbility; + +typedef struct { + int32_t axis; + int32_t min; + int32_t max; + int32_t fuzz; + int32_t flat; + int32_t range; +} DimensionInfo; + +typedef struct { + uint16_t busType; + uint16_t vendor; + uint16_t product; + uint16_t version; +} InputDevIdentify; + +typedef struct { + char devName[DEV_NAME_LEN]; + InputDevIdentify id; + DimensionInfo axisInfo[ABS_CNT]; +} DevAttr; + typedef struct InputDeviceInfo { struct HdfDeviceObject *hdfDevObj; uint32_t devId; uint32_t devType; - const char *devNode; const char *devName; uint16_t pkgNum; uint16_t pkgCount; bool errFrameFlag; struct HdfSBuf *pkgBuf; void *pvtData; + DevAttr attrSet; + DevAbility abilitySet; struct InputDeviceInfo *next; } InputDevice; @@ -87,6 +141,8 @@ enum InputIOsvcCmdId { GET_CHIP_INFO, GET_VENDOR_NAME, GET_CHIP_NAME, + GET_DEV_ATTR, + GET_DEV_ABILITY, SET_GESTURE_MODE, RUN_CAPAC_TEST, RUN_EXTRA_CMD, diff --git a/model/input/driver/hdf_key.c b/model/input/driver/hdf_key.c index 154df2df108b2e624083cf8766347abd4f7883bb..4188b25b37f9298cee18c1b05bcdeaaec15ff138 100644 --- a/model/input/driver/hdf_key.c +++ b/model/input/driver/hdf_key.c @@ -21,42 +21,6 @@ } \ } while (0) -static int32_t IoctlReadKeyEvent(KeyDriver *driver, unsigned long arg) -{ - KeyEventData *eventData = (KeyEventData *)(uintptr_t)arg; - - if (eventData == NULL) { - HDF_LOGE("%s: param is null", __func__); - return HDF_ERR_INVALID_PARAM; - } -#ifndef __KERNEL__ - if (LOS_ArchCopyToUser(eventData, &driver->eventData, sizeof(driver->eventData)) != 0) { - HDF_LOGE("%s:copy chipInfo failed", __func__); - return HDF_FAILURE; - } -#endif - return HDF_SUCCESS; -} - -int32_t KeyIoctl(InputDevice *inputdev, int32_t cmd, unsigned long arg) -{ - int32_t ret = HDF_FAILURE; - if (inputdev == NULL) { - return ret; - } - KeyDriver *driver = (KeyDriver *)inputdev->pvtData; - switch (cmd) { - case INPUT_IOCTL_GET_EVENT_DATA: - ret = IoctlReadKeyEvent(driver, arg); - break; - default: - ret = 0; - HDF_LOGE("%s: cmd unknown, cmd = 0x%x", __func__, cmd); - break; - } - return ret; -} - int32_t KeyIrqHandle(uint16_t intGpioNum, void *data) { uint16_t gpioValue; @@ -92,7 +56,6 @@ int32_t KeyIrqHandle(uint16_t intGpioNum, void *data) } input_sync(driver->inputdev); - driver->dataHandledFlag = true; GpioEnableIrq(intGpioNum); return HDF_SUCCESS; } @@ -186,12 +149,6 @@ static int32_t RegisterKeyDevice(KeyChipCfg *keyCfg) return HDF_ERR_MALLOC_FAIL; } -#ifdef __KERNEL__ - init_waitqueue_head(&keyDrv->pollWait); -#else - __init_waitqueue_head(&keyDrv->pollWait); -#endif - int32_t ret = KeyInit(keyDrv); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: key driver init failed, ret %d", __func__, ret); diff --git a/model/input/driver/hdf_key.h b/model/input/driver/hdf_key.h index 200eb636e3b2d868edb6121eb9dc978bc8d96050..d84230ff758d8da0e34536f30e2b7e8f7d3c11d4 100644 --- a/model/input/driver/hdf_key.h +++ b/model/input/driver/hdf_key.h @@ -9,7 +9,6 @@ #define HDF_KEY_H #include -#include "osal_cdev.h" #include "osal_time.h" #include "input_config.h" @@ -23,8 +22,6 @@ typedef struct KeyDriverInfo { uint8_t devType; KeyChipCfg *keyCfg; InputDevice *inputdev; - wait_queue_head_t pollWait; - bool dataHandledFlag; uint16_t preStatus; uint64_t timeStamp; } KeyDriver; diff --git a/model/input/driver/hdf_touch.c b/model/input/driver/hdf_touch.c index b129da732780a2e511f2fe2e89fa0df45ff7bd3c..6d32d162ec61bd840301712d719c5c47634ef4aa 100644 --- a/model/input/driver/hdf_touch.c +++ b/model/input/driver/hdf_touch.c @@ -19,114 +19,14 @@ #define MAX_TOUCH_DEVICE 5 #define REGISTER_BYTE_SIZE 4 #define TOUCH_CHIP_NAME_LEN 10 +#define AXIS_X_MAX 479 +#define AXIS_X_RANGE 480 +#define AXIS_Y_MAX 959 +#define AXIS_Y_RANGE 960 static TouchDriver *g_touchDriverList[MAX_TOUCH_DEVICE]; static void InputFrameReport(TouchDriver *driver); -#ifndef __KERNEL__ -static int32_t IoctlReadInputEvent(TouchDriver *driver, unsigned long arg) -{ - FrameData *frame = (FrameData *)(uintptr_t)arg; - if (frame == NULL) { - HDF_LOGE("%s: param is null", __func__); - return HDF_ERR_INVALID_PARAM; - } - - int32_t ret = LOS_ArchCopyToUser(frame, &driver->frameData, sizeof(driver->frameData)); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s:copy frame data failed, ret %d", __func__, ret); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -static int32_t IoctlGetDeviceType(TouchDriver *driver, unsigned long arg) -{ - int32_t ret; - uint8_t *devType = (uint8_t *)(uintptr_t)arg; - if (devType == NULL) { - HDF_LOGE("%s: param is null", __func__); - return HDF_ERR_INVALID_PARAM; - } - - ret = LOS_ArchCopyToUser(devType, &driver->devType, sizeof(driver->devType)); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s:copy devType failed, ret %d", __func__, ret); - return HDF_FAILURE; - } - - HDF_LOGI("%s: devType is %u", __func__, driver->devType); - return HDF_SUCCESS; -} - -static int32_t IoctlGetChipName(TouchDriver *driver, unsigned long arg) -{ - char *chipInfo = (char *)(uintptr_t)arg; - if (chipInfo == NULL) { - HDF_LOGE("%s: param is null", __func__); - return HDF_ERR_INVALID_PARAM; - } - - int32_t ret = LOS_ArchCopyToUser(chipInfo, driver->device->chipName, TOUCH_CHIP_NAME_LEN); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s:copy chipInfo failed, ret %d", __func__, ret); - return HDF_FAILURE; - } - - HDF_LOGI("%s: chipName is %s", __func__, driver->device->chipName); - return HDF_SUCCESS; -} - -int32_t TouchIoctl(InputDevice *inputdev, int32_t cmd, unsigned long arg) -{ - int32_t ret = HDF_FAILURE; - if (inputdev == NULL || inputdev->pvtData == NULL) { - return ret; - } - ChipDevice *device = (ChipDevice *)inputdev->pvtData; - TouchDriver *driver = device->driver; - switch (cmd) { - case INPUT_IOCTL_GET_EVENT_DATA: - ret = IoctlReadInputEvent(driver, arg); - break; - case INPUT_IOCTL_GET_DEVICE_TYPE: - ret = IoctlGetDeviceType(driver, arg); - break; - case INPUT_IOCTL_GET_CHIP_INFO: - ret = IoctlGetChipName(driver, arg); - break; - default: - ret = 0; - HDF_LOGE("%s: cmd unknown, cmd = 0x%x", __func__, cmd); - break; - } - return ret; -} - -#ifndef CONFIG_DISABLE_POLL -uint32_t TouchPoll(FAR struct file *filep, InputDevice *inputDev, poll_table *wait) -{ - uint32_t pollMask = 0; - if (filep == NULL || filep->f_vnode == NULL) { - return pollMask; - } - InputDevice *inputdev = (InputDevice *)((struct drv_data*)filep->f_vnode->data)->priv; - if (inputdev == NULL) { - HDF_LOGE("%s: inputdev is null", __func__); - return pollMask; - } - ChipDevice *device = (ChipDevice *)inputdev->pvtData; - - poll_wait(filep, &device->driver->pollWait, wait); - if (device->driver->dataHandledFlag == true) { - pollMask |= POLLIN; - } - device->driver->dataHandledFlag = false; - return pollMask; -} -#endif -#endif - static int32_t SetGpioDirAndLevel(int gpio, int dir, int level) { int32_t ret; @@ -472,6 +372,7 @@ int32_t RegisterChipDevice(ChipDevice *chipDev) goto EXIT1; } chipDev->driver->inputDev = inputDev; + chipDev->ops->SetAbility(chipDev); return HDF_SUCCESS; EXIT1: @@ -518,7 +419,7 @@ static int32_t TouchGetPowerStatus(TouchDriver *driver, struct HdfSBuf *reply) return HDF_SUCCESS; } -static int32_t TouchGetDeviceInfo(TouchDriver *driver, int32_t cmd, struct HdfSBuf *reply) +static int32_t TouchGetDeviceStrInfo(TouchDriver *driver, int32_t cmd, struct HdfSBuf *reply) { const char *info = NULL; if ((driver->device == NULL) || (driver->device->chipCfg == NULL)) { @@ -546,7 +447,46 @@ static int32_t TouchGetDeviceInfo(TouchDriver *driver, int32_t cmd, struct HdfSB HDF_LOGE("%s: HdfSbufWriteUint32 failed", __func__); return HDF_FAILURE; } - HDF_LOGD("%s: cmd is %s, the info is ", __func__, info); + HDF_LOGI("%s: cmd is %d, the info is %s", __func__, cmd, info); + return HDF_SUCCESS; +} + +static int32_t TouchGetDeviceAttr(TouchDriver *driver, struct HdfSBuf *reply) +{ + if (driver->inputDev == NULL) { + return HDF_FAILURE; + } + + HDF_LOGE("%s: enter", __func__); + char *tempStr = "main_touch"; + (void)strncpy_s(driver->inputDev->attrSet.devName, DEV_NAME_LEN, tempStr, strlen(tempStr)); + driver->inputDev->attrSet.axisInfo[ABS_MT_POSITION_X].min = 0; + driver->inputDev->attrSet.axisInfo[ABS_MT_POSITION_X].max = AXIS_X_MAX; + driver->inputDev->attrSet.axisInfo[ABS_MT_POSITION_X].range = AXIS_X_RANGE; + driver->inputDev->attrSet.axisInfo[ABS_MT_POSITION_Y].min = 0; + driver->inputDev->attrSet.axisInfo[ABS_MT_POSITION_Y].max = AXIS_Y_MAX; + driver->inputDev->attrSet.axisInfo[ABS_MT_POSITION_Y].range = AXIS_Y_RANGE; + + if (!HdfSbufWriteBuffer(reply, &driver->inputDev->attrSet, sizeof(DevAttr))) { + HDF_LOGE("%s: sbuf write dev attr failed", __func__); + } + + HDF_LOGI("%s: get dev attr succ", __func__); + return HDF_SUCCESS; +} + +static int32_t TouchGetDeviceAbility(TouchDriver *driver, struct HdfSBuf *reply) +{ + if (driver->inputDev == NULL) { + return HDF_FAILURE; + } + HDF_LOGE("%s: enter", __func__); + + if (!HdfSbufWriteBuffer(reply, &driver->inputDev->abilitySet, sizeof(DevAbility))) { + HDF_LOGE("%s: sbuf write dev ability failed", __func__); + } + + HDF_LOGI("%s: get dev ability succ", __func__); return HDF_SUCCESS; } @@ -620,6 +560,7 @@ static int32_t HdfTouchDispatch(struct HdfDeviceIoClient *client, int32_t cmd, return HDF_FAILURE; } + HDF_LOGI("%s: cmd = %d", __func__, cmd); switch (cmd) { case GET_DEV_TYPE: ret = TouchGetDevType(touchDriver, reply); @@ -633,7 +574,13 @@ static int32_t HdfTouchDispatch(struct HdfDeviceIoClient *client, int32_t cmd, case GET_CHIP_NAME: case GET_VENDOR_NAME: case GET_CHIP_INFO: - ret = TouchGetDeviceInfo(touchDriver, cmd, reply); + ret = TouchGetDeviceStrInfo(touchDriver, cmd, reply); + break; + case GET_DEV_ATTR: + ret = TouchGetDeviceAttr(touchDriver, reply); + break; + case GET_DEV_ABILITY: + ret = TouchGetDeviceAbility(touchDriver, reply); break; case SET_GESTURE_MODE: ret = TouchSetGestureMode(touchDriver, data); @@ -693,11 +640,6 @@ static int32_t TouchInitData(TouchDriver *driver, TouchBoardCfg *config) driver->i2cClient.i2cCfg.busNum = config->bus.i2c.busNum; driver->irqStopFlag = false; -#ifdef __KERNEL__ - init_waitqueue_head(&driver->pollWait); -#else - __init_waitqueue_head(&driver->pollWait); -#endif return HDF_SUCCESS; } diff --git a/model/input/driver/hdf_touch.h b/model/input/driver/hdf_touch.h index 968f8201e55a29d5093a532eefc806855b183ce6..f8ed6ce5c094d5f0bb050ea307040d785518b5bd 100644 --- a/model/input/driver/hdf_touch.h +++ b/model/input/driver/hdf_touch.h @@ -10,7 +10,6 @@ #define HDF_TOUCH_H #include -#include "osal_cdev.h" #include "osal_time.h" #include "hdf_input_device_manager.h" #include "input_config.h" @@ -71,13 +70,11 @@ typedef struct TouchPlatformDriver { const char *devName; TouchBoardCfg *boardCfg; InputI2cClient i2cClient; - wait_queue_head_t pollWait; struct OsalMutex mutex; uint32_t pwrStatus; uint32_t gestureMode; bool initedFlag; bool irqStopFlag; - bool dataHandledFlag; } TouchDriver; struct TouchChipOps; @@ -97,6 +94,7 @@ struct TouchChipOps { int32_t (*Suspend)(ChipDevice *device); int32_t (*DataHandle)(ChipDevice *device); int32_t (*UpdateFirmware)(ChipDevice *device); + void (*SetAbility)(ChipDevice *device); }; typedef struct { diff --git a/model/input/driver/touchscreen/touch_gt911.c b/model/input/driver/touchscreen/touch_gt911.c index 1bfed4376173ff32667a20a8a51ede7b952f31d2..014ad7ed88dd50bf89cad4713bdb9aeb6875dc32 100644 --- a/model/input/driver/touchscreen/touch_gt911.c +++ b/model/input/driver/touchscreen/touch_gt911.c @@ -173,6 +173,15 @@ static int32_t UpdateFirmware(ChipDevice *device) return HDF_SUCCESS; } +static void SetAbility(ChipDevice *device) +{ + device->driver->inputDev->abilitySet.devProp[0] = SET_BIT(INPUT_PROP_DIRECT); + device->driver->inputDev->abilitySet.eventType[0] = SET_BIT(EV_SYN) | + SET_BIT(EV_KEY) | SET_BIT(EV_ABS); + device->driver->inputDev->abilitySet.absCode[0] = SET_BIT(ABS_X) | SET_BIT(ABS_Y); + device->driver->inputDev->abilitySet.keyCode[3] = SET_BIT(KEY_UP) | SET_BIT(KEY_DOWN); +} + static struct TouchChipOps g_gt911ChipOps = { .Init = ChipInit, .Detect = ChipDetect, @@ -180,6 +189,7 @@ static struct TouchChipOps g_gt911ChipOps = { .Suspend = ChipSuspend, .DataHandle = ChipDataHandle, .UpdateFirmware = UpdateFirmware, + .SetAbility = SetAbility, }; static TouchChipCfg *ChipConfigInstance(struct HdfDeviceObject *device)