summaryrefstree
path: root/kernel/drivers/video/fbdev/exynos/panel/copr.h
blob: 9f0a4da0c7b8c6a3709ef564c9280efbf8fb29e2 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) Samsung Electronics Co., Ltd.
 * Gwanghui Lee <gwanghui.lee@samsung.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef __COPR_H__
#define __COPR_H__

#include "panel.h"
#include "timenval.h"
#include <linux/ktime.h>
#include <linux/wait.h>

#define CONFIG_SUPPORT_COPR_AVG

enum {
	COPR_SET_SEQ,
	COPR_GET_SEQ,
	/* if necessary, add new seq */
	COPR_CLR_CNT_ON_SEQ,
	COPR_CLR_CNT_OFF_SEQ,
	COPR_SPI_GET_SEQ,
	COPR_DSI_GET_SEQ,
	MAX_COPR_SEQ,
};

enum {
	COPR_MAPTBL,
	/* if necessary, add new maptbl */
	MAX_COPR_MAPTBL,
};

enum COPR_STATE {
	COPR_UNINITIALIZED,
	COPR_REG_ON,
	COPR_REG_OFF,
	MAX_COPR_REG_STATE,
};

struct copr_reg {
	u8 cnt_re:1;
	u8 copr_ilc:1;
	u8 copr_en:1;
	u8 copr_gamma:1;		/* 0:GAMMA_1, 1:GAMMA_2.2 */
	u16 copr_er:10;
	u16 copr_eg:10;
	u16 copr_eb:10;
	u16 copr_erc:10;
	u16 copr_egc:10;
	u16 copr_ebc:10;
	u16 max_cnt:16;
	u8 roi_on:1;
	u16 roi_xs:12;
	u16 roi_ys:12;
	u16 roi_xe:12;
	u16 roi_ye:12;
};

struct copr_ergb {
	u16 copr_er;
	u16 copr_eg;
	u16 copr_eb;
};

struct copr_roi {
	u32 roi_xs;
	u32 roi_ys;
	u32 roi_xe;
	u32 roi_ye;
};

struct copr_properties {
	bool support;
	u32 version;
	u32 enable;
	u32 state;
	struct copr_reg reg;

	u32 copr_ready;
	u32 cur_cnt;
	u32 cur_copr;
	u32 avg_copr;
	u32 s_cur_cnt;
	u32 s_avg_copr;
	u32 comp_copr;

	struct copr_roi roi[32];
	int nr_roi;
};

struct copr_wq {
	wait_queue_head_t wait;
	atomic_t count;
	struct task_struct *thread;
};

struct copr_info {
	struct device *dev;
	struct class *class;
	struct mutex lock;
	atomic_t stop;
	struct copr_wq wq;
	struct timenval res;
	struct copr_properties props;
	struct notifier_block fb_notif;
	struct maptbl *maptbl;
	u32 nr_maptbl;
	struct seqinfo *seqtbl;
	u32 nr_seqtbl;
};

struct panel_copr_data {
	struct copr_reg reg;
	u32 version;
	struct seqinfo *seqtbl;
	u32 nr_seqtbl;
	struct maptbl *maptbl;
	u32 nr_maptbl;
};

static inline void SET_COPR_REG_GAMMA(struct copr_info *copr, bool copr_gamma)
{
	copr->props.reg.copr_gamma = copr_gamma;
}

static inline void SET_COPR_REG_E(struct copr_info *copr, int r, int g, int b)
{
	copr->props.reg.copr_er = r;
	copr->props.reg.copr_eg = g;
	copr->props.reg.copr_eb = b;
}

static inline void SET_COPR_REG_EC(struct copr_info *copr, int r, int g, int b)
{
	copr->props.reg.copr_erc = r;
	copr->props.reg.copr_egc = g;
	copr->props.reg.copr_ebc = b;
}

static inline void SET_COPR_REG_CNT_RE(struct copr_info *copr, int cnt_re)
{
	copr->props.reg.cnt_re = cnt_re;
}

static inline void SET_COPR_REG_ROI(struct copr_info *copr, struct copr_roi *roi)
{
	struct copr_properties *props = &copr->props;

	if (roi == NULL) {
		props->reg.roi_xs = 0;
		props->reg.roi_ys = 0;
		props->reg.roi_xe = 0;
		props->reg.roi_ye = 0;
		props->reg.roi_on = false;
	} else {
		props->reg.roi_xs = roi->roi_xs;
		props->reg.roi_ys = roi->roi_ys;
		props->reg.roi_xe = roi->roi_xe;
		props->reg.roi_ye = roi->roi_ye;
		props->reg.roi_on = true;
	}
}

static inline void SET_COPR_REG_RE(struct copr_info *copr, bool cnt_re)
{
	struct copr_properties *props = &copr->props;

	props->reg.cnt_re = !!cnt_re;
}

#ifdef CONFIG_EXYNOS_DECON_LCD_COPR
bool copr_is_enabled(struct copr_info *copr);
int copr_enable(struct copr_info *copr);
int copr_disable(struct copr_info *copr);
int copr_update_start(struct copr_info *copr, int count);
int copr_update_average(struct copr_info *copr);
int copr_get_value(struct copr_info *copr);
//int copr_get_average(struct copr_info *, int *, int *);
int copr_get_average_and_clear(struct copr_info *copr);
int copr_roi_get_value(struct copr_info *copr, struct copr_roi *roi, int size, u32 *out);
int copr_probe(struct panel_device *panel, struct panel_copr_data *copr_data);
int copr_res_update(struct copr_info *copr, int index, int cur_value, struct timespec cur_ts);
#else
static inline bool copr_is_enabled(struct copr_info *copr) { return 0; }
static inline int copr_enable(struct copr_info *copr) { return 0; }
static inline int copr_disable(struct copr_info *copr) { return 0; }
static inline int copr_update_start(struct copr_info *copr, int count) { return 0; }
static inline int copr_update_average(struct copr_info *copr) { return 0; }
static inline int copr_get_value(struct copr_info *copr) { return 0; }
static inline int copr_get_average_and_clear(struct copr_info *copr) { return 0; }
static inline int copr_roi_get_value(struct copr_info *copr, struct copr_roi *roi, int size, u32 *out) { return 0; }
static inline int copr_probe(struct panel_device *panel, struct panel_copr_data *copr_data) { return 0; }
static inline int copr_res_update(struct copr_info *copr, int index, int cur_value, struct timespec cur_ts) { return 0; }
#endif
#endif /* __COPR_H__ */