summaryrefslogtreecommitdiff
path: root/drivers/video/sprdfb/sprdfb.h
blob: 52f095bdbb8ea5b6774d74018c6c6057ed49c9aa (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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/*
 * Copyright (C) 2012 Spreadtrum Communications Inc.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * 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.
 */

#ifndef _SPRDFB_H_
#define _SPRDFB_H_

#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
#include <linux/compat.h>
#include <linux/workqueue.h>
#include <linux/semaphore.h>
#include <linux/wait.h>
#ifdef CONFIG_FB_MMAP_CACHED
#include <linux/mm_types.h>
#endif

#if ((!defined(CONFIG_FB_SCX35)) && (!defined(CONFIG_FB_SCX15)))
#define FB_CHECK_ESD_IN_VFP
#endif
//#define FB_CHECK_ESD_BY_TE_SUPPORT
#define BIT_PER_PIXEL_SURPPORT

enum{
	SPRDFB_PANEL_IF_DBI = 0,
	SPRDFB_PANEL_IF_DPI,
	SPRDFB_PANEL_IF_EDPI,
	SPRDFB_PANEL_IF_LIMIT
};

enum {
	SPRDFB_UNKNOWN = 0,
	SPRDFB_DYNAMIC_PCLK = 0x1,
	SPRDFB_DYNAMIC_FPS,
	SPRDFB_DYNAMIC_MIPI_CLK,
	SPRDFB_FORCE_FPS,
	SPRDFB_FORCE_PCLK,
};

enum{
	MCU_LCD_REGISTER_TIMING = 0,
	MCU_LCD_GRAM_TIMING,
	MCU_LCD_TIMING_KIND_MAX
};

enum{
	RGB_LCD_H_TIMING = 0,
	RGB_LCD_V_TIMING,
	RGB_LCD_TIMING_KIND_MAX
};


#ifdef  CONFIG_FB_LCD_OVERLAY_SUPPORT
#define SPRD_LAYER_IMG (0x01)   /*support YUV & RGB*/
#define SPRD_LAYER_OSD (0x02) /*support RGB only*/

enum {
	SPRD_DATA_TYPE_YUV422 = 0,
	SPRD_DATA_TYPE_YUV420,
	SPRD_DATA_TYPE_YUV400,
	SPRD_DATA_TYPE_RGB888,
	SPRD_DATA_TYPE_RGB666,
	SPRD_DATA_TYPE_RGB565,
	SPRD_DATA_TYPE_RGB555,
	SPRD_DATA_TYPE_LIMIT
};

enum{
	SPRD_IMG_DATA_ENDIAN_B0B1B2B3 = 0,
	SPRD_IMG_DATA_ENDIAN_B3B2B1B0,
	SPRD_IMG_DATA_ENDIAN_B2B3B0B1,
	SPRD_IMG_DATA_ENDIAN_B1B0B3B2,
	SPRD_IMG_DATA_ENDIAN_LIMIT
};

enum{
	SPRD_OVERLAY_STATUS_OFF = 0,
	SPRD_OVERLAY_STATUS_ON,
	SPRD_OVERLAY_STATUS_STARTED,
	SPRD_OVERLAY_STATUS_MAX
};

enum{
	SPRD_OVERLAY_DISPLAY_ASYNC = 0,
	SPRD_OVERLAY_DISPLAY_SYNC,
	SPRD_OVERLAY_DISPLAY_MAX
};

typedef struct overlay_rect {
	uint16_t x;
	uint16_t y;
	uint16_t w;
	uint16_t h;
}overlay_rect;

typedef struct overlay_info{
	int layer_index;
	int data_type;
	int y_endian;
	int uv_endian;
	bool rb_switch;
	overlay_rect rect;
	unsigned char *buffer;
}overlay_info;

typedef struct overlay_display{
	int layer_index;
	overlay_rect rect;
	int display_mode;
}overlay_display;

#ifdef CONFIG_COMPAT
typedef struct overlay_info32{
	int layer_index;
	int data_type;
	int y_endian;
	int uv_endian;
	bool rb_switch;
	overlay_rect rect;
	compat_caddr_t buffer;
}overlay_info32;
#endif
#endif

enum{
	MIPI_PLL_TYPE_NONE = 0,
	MIPI_PLL_TYPE_1,
	MIPI_PLL_TYPE_2,
	MIPI_PLL_TYPE_LIMIT
};

typedef struct fb_capability {
	uint16_t need_light_sleep;	/* enable light_sleep in fb driver*/
	uint16_t mipi_pll_type;		/* 0:none	1:for pike/pikel	2:for sharkl64/sharklT8*/
}fb_capability;

struct sprdfb_device {
	struct fb_info	*fb;
	struct panel_spec	*panel;
	struct display_ctrl	*ctrl;
	void *logo_buffer_addr_v;
	void *priv1;

#ifdef CONFIG_OF
	struct device *of_dev;
#endif

	uint16_t		enable;
	uint16_t	 	dev_id; /*main_lcd, sub_lcd*/

	uint32_t	 	bpp;  /*input bit per pixel*/

	uint16_t		panel_ready; /*panel has been inited by uboot*/
	uint16_t		panel_if_type; /*panel IF*/

#ifdef CONFIG_FB_LOW_RES_SIMU
	uint32_t display_width;
	uint32_t display_height;
#endif

	union{
		uint32_t	mcu_timing[MCU_LCD_TIMING_KIND_MAX];
		uint32_t	rgb_timing[RGB_LCD_TIMING_KIND_MAX];
	}panel_timing;

	struct fb_capability capability;
	uint32_t dpi_clock;
	struct semaphore   refresh_lock;
	uint64_t frame_count;

#ifdef CONFIG_FB_ESD_SUPPORT
	struct delayed_work ESD_work;
//	struct semaphore   ESD_lock;
	uint32_t ESD_timeout_val;
	bool ESD_work_start;
	/*for debug only*/
	uint32_t check_esd_time;
	uint32_t panel_reset_time;
	uint32_t reset_dsi_time;
#ifdef FB_CHECK_ESD_BY_TE_SUPPORT
	uint32_t esd_te_waiter;
	wait_queue_head_t  esd_te_queue;
	uint32_t esd_te_done;
#endif
#endif

	uint32_t logo_buffer_size;

#ifdef CONFIG_HAS_EARLYSUSPEND
	struct early_suspend	early_suspend;
#endif
};

struct display_ctrl {
	const char	*name;

	int32_t	(*early_init)	  (struct sprdfb_device *dev);
	int32_t	(*init)		  (struct sprdfb_device *dev);
	int32_t	(*uninit)		  (struct sprdfb_device *dev);

	int32_t 	(*refresh)	  (struct sprdfb_device *dev);
	void 	(*logo_proc)	  (struct sprdfb_device *dev);

	int32_t	(*suspend)	  (struct sprdfb_device *dev);
	int32_t 	(*resume)	  (struct sprdfb_device *dev);
	int32_t (*update_clk) (struct sprdfb_device *dev);

#ifdef CONFIG_FB_ESD_SUPPORT
	int32_t	(*ESD_check)	  (struct sprdfb_device *dev);
#endif

#ifdef  CONFIG_FB_LCD_OVERLAY_SUPPORT
	int32_t 	(*enable_overlay) 	(struct sprdfb_device *dev, struct overlay_info* info, int enable);
	int32_t	(*display_overlay)	(struct sprdfb_device *dev, struct overlay_display* setting);
#endif

#ifdef CONFIG_FB_VSYNC_SUPPORT
	int32_t 	(*wait_for_vsync) 	(struct sprdfb_device *dev);
#endif

#ifdef CONFIG_FB_MMAP_CACHED
	void (*set_vma)(struct vm_area_struct *vma);
#endif
	int32_t	(*is_refresh_done)	(struct sprdfb_device *dev);

};

#ifndef ROUND
#define ROUND(a, b) (((a) + (b) / 2) / (b))
#endif

/* function declaration begin */
int sprdfb_create_sysfs(struct sprdfb_device *fb_dev);
void sprdfb_remove_sysfs(struct sprdfb_device *fb_dev);

#ifdef CONFIG_FB_DYNAMIC_FREQ_SCALING
int sprdfb_dispc_chg_clk(struct sprdfb_device *fb_dev,
				int type, u32 new_val);
#else
#define sprdfb_dispc_chg_clk(fb_dev, type, new_val) ( \
{ \
	int _ret = -ENXIO; \
	pr_err("dynamical clock feature hasn't been enabled yet\n"); \
	_ret; \
} \
)
#endif

#if !defined(CONFIG_FB_SCX15)
int sprdfb_dsi_chg_dphy_freq(struct sprdfb_device *fb_dev,
		u32 dphy_freq);
int32_t dsi_dpi_init(struct sprdfb_device *dev);
#else
#define sprdfb_dsi_chg_dphy_freq(fb_dev, dphy_freq) ( \
{ \
	int _ret = -ENXIO; \
	pr_err("this chip doesn't support for mipi dsi\n"); \
	_ret; \
} \
)

#define dsi_dpi_init(fb_dev) ( \
{ \
	int _ret = -ENXIO; \
	pr_err("this chip doesn't support for mipi dsi\n"); \
	_ret; \
} \
)
#endif

int sprdfb_chg_clk_intf(struct sprdfb_device *fb_dev,
			int type, u32 new_val);
/* Function declare begin */
#ifdef CONFIG_SC_FPGA
int sprdchip_lvds_init(void);
#endif
/* Function declare end */

#endif