1 /* 2 * Copyright (c) 2022 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 DRV2605L_DRIVER_H 10 #define DRV2605L_DRIVER_H 11 12 #include "hdf_device_desc.h" 13 14 #define I2C_READ_MSG_NUM 2 15 #define I2C_READ_MSG_ADDR_IDX 0 16 #define I2C_READ_MSG_VALUE_IDX 1 17 18 #define DRV2605L_ADDR_WIDTH_1_BYTE 1 // 8 bit 19 #define DRV2605L_ADDR_WIDTH_2_BYTE 2 // 16 bit 20 21 #define I2C_WRITE_MSG_NUM 1 22 #define I2C_REG_BUF_LEN 4 23 #define I2C_BYTE_MASK 0xFF 24 #define I2C_BYTE_OFFSET 8 25 26 #define DRV2605_REG_MODE 0x01 // Mode register 27 #define DRV2605_MODE_REALTIME 0x05 // Real-time playback (RTP) mode 28 #define DRV2605_MODE_STANDBY 0x45 // Software standby mode 29 30 #define DRV2605_REG_CONTROL3 0x1D // Control3 Register 31 #define DRV2605_MODE_OPEN_LOOP 0xA9 // Open Loop 32 33 #define DRV2605_REG_FEEDBACK 0x1A // Feedback control register 34 #define DRV2605_MODE_LRA 0xB6 // LRA Mode 35 36 #define DRV2605_REG_RTPIN 0x02 // Real-time playback input register 37 #define DRV2605_REG_LRARESON 0x20 // LRA open loop period 38 39 #define INTENSITY_MAPPING_VALUE(value) {0XA8 + ((value) * (0XFF - 0XA8)) / 100} 40 41 #define FREQUENCY_MAPPING_VALUE(value) {1000000 / (98 * (value))} 42 43 enum Drv2605lConfigValueIndex { 44 DRV2605L_ADDR_INDEX, 45 DRV2605L_VALUE_INDEX, 46 DRV2605L_VALUE_BUTT, 47 }; 48 49 struct Drv2605lDriverData { 50 struct IDeviceIoService ioService; 51 struct HdfDeviceObject *device; 52 const struct DeviceResourceNode *root; 53 struct VibratorCfgData *drv2605lCfgData; 54 }; 55 56 #endif /* DRV2605L_DRIVER_H */