1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef VIBRATOR_DRIVER_TYPE_H 10 #define VIBRATOR_DRIVER_TYPE_H 11 12 #include "hdf_log.h" 13 14 #define CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(ptr, ret) do { \ 15 if ((ptr) == NULL) { \ 16 HDF_LOGE("%s:line %d pointer is null and return errno", __func__, __LINE__); \ 17 return (ret); \ 18 } \ 19 } while (0) 20 21 #define CHECK_VIBRATOR_PARSER_RESULT_RETURN_VALUE(ret, str) do { \ 22 if (ret != HDF_SUCCESS) { \ 23 HDF_LOGE("%s:line %d %s fail, ret = %d!", __func__, __LINE__, str, ret); \ 24 return HDF_FAILURE; \ 25 } \ 26 } while (0) 27 28 #define CHECK_VIBRATOR_NULL_PTR_RETURN(ptr) do { \ 29 if ((ptr) == NULL) { \ 30 HDF_LOGE("%s:line %d pointer is null and return", __func__, __LINE__); \ 31 return; \ 32 } \ 33 } while (0) 34 35 enum VibratorBusType { 36 VIBRATOR_BUS_I2C = 0, 37 VIBRATOR_BUS_GPIO = 1, 38 }; 39 40 enum VibratorState { 41 VIBRATOR_STATE_IDLE = 0, 42 VIBRATOR_STATE_START_TIMER = 1, 43 VIBRATOR_STATE_STOP = 2, 44 VIBRATOR_STATE_SET_EFFECT = 3, 45 }; 46 47 enum VibratorConfigMode { 48 VIBRATOR_MODE_ONCE = 0, // The mode of a one-shot vibration effect. 49 VIBRATOR_MODE_PRESET = 1, // The mode of a preset vibration effect. 50 VIBRATOR_MODE_BUTT = 0XFF, 51 }; 52 53 enum VibratorDrvIoCmd { 54 VIBRATOR_DRV_IO_START_ONCE = 0, 55 VIBRATOR_DRV_IO_START_PRESET = 1, 56 VIBRATOR_DRV_IO_STOP = 2, 57 VIBRATOR_DRV_IO_END, 58 }; 59 60 #endif /* VIBRATOR_DRIVER_TYPE_H */ 61