1 /*
2  * Copyright (c) 2021-2023 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_H
10 #define VIBRATOR_DRIVER_H
11 
12 #include "osal_mutex.h"
13 #include "hdf_device_desc.h"
14 #include "hdf_workqueue.h"
15 #include "vibrator_parser.h"
16 #include "vibrator_driver_type.h"
17 
18 struct VibratorOps {
19     int32_t (*Start)(void);
20     int32_t (*Stop)(void);
21     int32_t (*StartEffect)(uint32_t effectType);
22     int32_t (*SetParameter)(uint16_t intensity, int16_t frequency);
23 };
24 
25 typedef int32_t (*VibratorCmdHandle)(struct HdfSBuf *reqData, struct HdfSBuf *reply);
26 
27 struct VibratorCmdHandleList {
28     int32_t cmd;
29     VibratorCmdHandle func;
30 };
31 
32 struct VibratorDriverData {
33     struct IDeviceIoService ioService;
34     struct HdfDeviceObject *device;
35     HdfWorkQueue workQueue;
36     HdfWork work;
37     struct OsalMutex mutex;
38     enum VibratorConfigMode mode;
39     enum VibratorState state;
40     struct VibratorOps ops;
41     struct VibratorInfo vibratorInfo;
42 };
43 
44 void StartVibrator(void);
45 void StopVibrator(void);
46 void SetEffectVibrator(uint32_t type);
47 int32_t RegisterVibratorOps(struct VibratorOps *ops);
48 int32_t RegisterVibratorInfo(struct VibratorInfo *vibratorInfo);
49 
50 #endif /* VIBRATOR_DRIVER_H */
51