summaryrefstree
path: root/kernel/drivers/input/input_booster_lsi.c
blob: b0817843bb69b0b0325e7d935fe89011ec4bc355 (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
120
121
122
123
124
#include <linux/input/input_booster.h>
#include <linux/exynos-ucc.h>
#include <linux/ems_service.h>

static struct pm_qos_request cluster2_qos;
static struct pm_qos_request cluster1_qos;
static struct pm_qos_request cluster0_qos;
static struct pm_qos_request mif_qos;
static struct pm_qos_request int_qos;
static struct kpp kpp_ta;
static struct kpp kpp_fg;
static struct ucc_req ucc_req = {
	.name = "input",
};

static DEFINE_MUTEX(input_lock);
bool current_hmp_boost = INIT_ZERO;
bool current_ucc_boost = INIT_ZERO;

struct inform {
    void *qos;
    void (*set_func)(int);
    int release_value;
};
struct inform informations[MAX_RES_COUNT];

void set_ucc(int enable)
{
	mutex_lock(&input_lock);

	if (enable != current_ucc_boost) {
		pr_booster("[Input Booster2] ******      set_ucc : %d ( %s )\n", enable, __FUNCTION__);
		if (enable) {
			ucc_add_request(&ucc_req, enable);
		} else {
			ucc_remove_request(&ucc_req);
		}
		current_ucc_boost = enable;
	}

	mutex_unlock(&input_lock);
}


void set_hmp(int enable)
{
	mutex_lock(&input_lock);

	if (enable != current_hmp_boost) {
		pr_booster("[Input Booster2] ******      set_ehmp : %d ( %s )\n", enable, __FUNCTION__);
		if (enable) {
			kpp_request(STUNE_TOPAPP, &kpp_ta, enable);
			kpp_request(STUNE_FOREGROUND, &kpp_fg, enable);
		} else {
			kpp_request(STUNE_TOPAPP, &kpp_ta, 0);
			kpp_request(STUNE_FOREGROUND, &kpp_fg, 0);
		}
		current_hmp_boost = enable;
	}

	mutex_unlock(&input_lock);
}

void ib_set_booster(int *qos_values)
{
	int value = -1;
	int res_type = 0;

	for (res_type = 0; res_type < MAX_RES_COUNT; res_type++) {
		pr_info(" ib_set_booster qos_values[%d] : %d", res_type, qos_values[res_type]);
		value = qos_values[res_type];

		if (value <= 0)
			continue;

		if (informations[res_type].qos) {
			pm_qos_update_request(informations[res_type].qos, qos_values[res_type]);
		} else {
			informations[res_type].set_func(qos_values[res_type]);
		}
	}
}

void ib_release_booster(int res_id)
{
	if (informations[res_id].qos) {
		pm_qos_update_request(informations[res_id].qos, informations[res_id].release_value);
	} else {
		informations[res_id].set_func(informations[res_id].release_value);
	}

	pr_info("ib_release_booster %d value : %d", res_id, informations[res_id].release_value);
}

void input_booster_init_vendor(int *release_val)
{
	int i = 0;
	pm_qos_add_request(&cluster2_qos, PM_QOS_CLUSTER2_FREQ_MIN, PM_QOS_CLUSTER2_FREQ_MIN_DEFAULT_VALUE);
	pm_qos_add_request(&cluster1_qos, PM_QOS_CLUSTER1_FREQ_MIN, PM_QOS_CLUSTER1_FREQ_MIN_DEFAULT_VALUE);
	pm_qos_add_request(&cluster0_qos, PM_QOS_CLUSTER0_FREQ_MIN, PM_QOS_CLUSTER0_FREQ_MIN_DEFAULT_VALUE);
	pm_qos_add_request(&mif_qos, PM_QOS_BUS_THROUGHPUT, PM_QOS_BUS_THROUGHPUT_DEFAULT_VALUE);
	pm_qos_add_request(&int_qos, PM_QOS_DEVICE_THROUGHPUT, PM_QOS_DEVICE_THROUGHPUT_DEFAULT_VALUE);

	informations[i++].qos = &cluster2_qos;
	informations[i++].qos = &cluster1_qos;
	informations[i++].qos = &cluster0_qos;
	informations[i++].qos = &mif_qos;
	informations[i++].qos = &int_qos;
	informations[i++].set_func = set_hmp;
	informations[i++].set_func = set_ucc;

	for (i = 0; i < MAX_RES_COUNT; i++) {
		informations[i].release_value = release_val[i];
	}
}

void input_booster_exit_vendor(void)
{
	pm_qos_remove_request(&cluster2_qos);
	pm_qos_remove_request(&cluster1_qos);
	pm_qos_remove_request(&cluster0_qos);
	pm_qos_remove_request(&mif_qos);
	pm_qos_remove_request(&int_qos);
}