1 /*
2  * Copyright  2019 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef TFA2_HAPTIC_H_
9 #define TFA2_HAPTIC_H_
10 
11 #include "tfa2_dev.h"
12 
13 #define TFA2_HAPTIC_FP_INT(value, shift)  ((value) >> (shift))
14 #define TFA2_HAPTIC_FP_FRAC(value, shift) ((((value) & ((1 << (shift)) - 1)) * 1000) >> (shift))
15 
16 int tfa2_dev_start_hapticboost(struct tfa2_device *tfa);
17 int tfa2_hap_calibrate(struct tfa2_device *tfa);
18 int tfa2_hap_recalculate(struct tfa2_device *tfa, int object);
19 int tfa2_hap_load_data(struct tfa2_device *tfa);
20 int tfa2_hap_sequencer(struct tfa2_device *tfa, struct tfa2_sequence *seq);
21 int tfa2_hap_get_sequencer_duration(struct tfa2_device *tfa, struct tfa2_sequence *seq);
22 int tfa2_hap_sequencer_object(struct tfa2_device *tfa, int virtual_obj);
23 void tfa2_hap_sequencer_destroy(struct tfa2_sequence *seq);
24 int tfa2_hap_cnt_sequencer_count(nxpTfaContainer_t *cnt, int devidx);
25 int tfa2_hap_cnt_get_sequencer(nxpTfaContainer_t *cnt, int devidx, int seqidx, struct tfa2_sequence *seq);
26 int tfa2_haptic_obj0_wait_finish(struct i2c_client *client);
27 void tfa2_haptic_obj_get(struct haptic_data *data, int idx);
28 int tfa2_haptic_get_duration(struct tfa2_device *tfa, int index);
29 enum tfa_haptic_object_type tfa2_haptic_object_type(struct haptic_data *data, int index);
30 int tfa2_haptic_parse_value(struct haptic_data *data, int value);
31 int tfa2_haptic_start(struct tfa2_device *tfa, struct haptic_data *data, int index);
32 int tfa2_haptic_start_object(struct i2c_client *client, struct haptic_data *data, int index);
33 int tfa2_haptic_stop(struct tfa2_device *tfa, struct haptic_data *data, int index);
34 int tfa2_haptic_read_f0(struct i2c_client *client, int *p_value);
35 int tfa2_haptic_disable_f0_trc(struct i2c_client *client, int disable);
36 void tfa2_haptic_set_version_check(int check);
37 int tfa2_haptic_update_duration(struct haptic_data *data, int duration);
38 int tfa2_hap_patch_version(struct tfa2_device *tfa, char *string);
39 void tfa2_hap_save_haptic_cache(struct tfa2_device *tfa, struct tfa2_sequence *seq);
40 void tfa2_hap_test_restore_haptic_cache(struct tfa2_device *tfa, struct tfa2_sequence *seq);
41 
42 #endif /* TFA2_HAPTIC_H_ */
43