summaryrefstree
path: root/kernel/include/linux/vibrator/sec_vibrator.h
blob: b9498bb03050dcee82c073206ae750044139f318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* sec_vibrator.h
 *
 * Copyright (C) 2019 Samsung Electronics
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef SEC_VIBRATOR_H
#define SEC_VIBRATOR_H

#include <linux/kthread.h>
#include <linux/leds.h>
#include <linux/cdev.h>

#define MAX_INTENSITY			10000
#define MAX_TIMEOUT			10000
#define PACKET_MAX_SIZE			1000

#define HAPTIC_ENGINE_FREQ_MIN		1200
#define HAPTIC_ENGINE_FREQ_MAX		3500

#define VIB_BUFSIZE                     30

#define HOMEKEY_DURATION		7

struct vib_packet {
	int time;
	int intensity;
	int freq;
	int overdrive;
};

enum {
	VIB_PACKET_TIME = 0,
	VIB_PACKET_INTENSITY,
	VIB_PACKET_FREQUENCY,
	VIB_PACKET_OVERDRIVE,
	VIB_PACKET_MAX,
};

enum {
	FREQ_ALERT = 0,	/* 157.5Hz */
	FREQ_ZERO,	/* 180Hz */
	FREQ_LOW,	/* 120Hz */
	FREQ_MID,	/* 150Hz */
	FREQ_HIGH,	/* 200Hz */
	FREQ_PRESS,	/* force touch press */
	FREQ_RELEASE,	/* force touch release */
	FREQ_MAX,
};

struct sec_vibrator_ops {
	int (*enable)(struct device *dev, bool en);
	int (*set_intensity)(struct device *dev, int intensity);
	int (*set_frequency)(struct device *dev, int frequency);
	int (*set_overdrive)(struct device *dev, bool en);
	int (*get_motor_type)(struct device *dev, char *buf);
	int (*get_num_waves)(struct device *dev);
	int (*set_cp_trigger_index)(struct device *dev, unsigned int index);
	int (*get_cp_trigger_index)(struct device *dev);
	int (*set_cp_trigger_queue)(struct device *dev, const char *buf);
	int (*get_cp_trigger_queue)(struct device *dev, char *buf);
	int (*set_force_touch_intensity)(struct device *dev, int intensity);
	int (*set_tuning_with_temp)(struct device *dev, int temperature);
	bool (*get_calibration)(struct device *dev);
	int (*get_step_size)(struct device *dev, int *step_size);
	int (*get_intensities)(struct device *dev, int *buf);
	int (*set_intensities)(struct device *dev, int *buf);
	int (*get_haptic_intensities)(struct device *dev, int *buf);
	int (*set_haptic_intensities)(struct device *dev, int *buf);
	int (*get_haptic_durations)(struct device *dev, int *buf);
	int (*set_haptic_durations)(struct device *dev, int *buf);
};

struct sec_vibrator_drvdata {
	struct class *to_class;
	struct device *to_dev;
	struct device *dev;
	struct hrtimer timer;
	struct kthread_worker kworker;
	struct kthread_work kwork;
	struct mutex vib_mutex;
	struct vib_packet vib_pac[PACKET_MAX_SIZE];
	const struct sec_vibrator_ops *vib_ops;

	bool f_packet_en;
	bool packet_running;
	int packet_size;
	int packet_cnt;
	unsigned int index;

	int force_touch_intensity;
	int intensity;
	int frequency;
	bool overdrive;

	int timeout;

	struct led_classdev cdev;
	int state;
	int duration;
};

extern int sec_vibrator_register(struct sec_vibrator_drvdata *ddata);
extern int sec_vibrator_unregister(struct sec_vibrator_drvdata *ddata);

#endif /* SEC_VIBRATOR_H */