Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | #ifndef __MTKFB_H |
2 | #define __MTKFB_H | |
3 | ||
4 | #include "mtkfb_info.h" | |
5 | ||
6 | ||
7 | /**NOTICE: | |
8 | * Must be consistent with bionic/libc/kernel/linux/common/mtkfb.h | |
9 | */ | |
10 | #define MTK_FB_NO_ION_FD ((int)(~0U>>1)) | |
11 | #define MTK_FB_NO_USE_LAEYR_ID ((int)(~0U>>1)) | |
12 | #define FBCAPS_GENERIC_MASK (0x00000fff) | |
13 | #define FBCAPS_LCDC_MASK (0x00fff000) | |
14 | #define FBCAPS_PANEL_MASK (0xff000000) | |
15 | #define FBCAPS_MANUAL_UPDATE (0x00001000) | |
16 | #define FBCAPS_SET_BACKLIGHT (0x01000000) | |
17 | #define MTKFB_ERROR_IS_EARLY_SUSPEND (0x12000000) | |
18 | /* --------------------------------------------------------------------------- */ | |
19 | /* IOCTL commands. */ | |
20 | #define MTK_IOW(num, dtype) _IOW('O', num, dtype) | |
21 | #define MTK_IOR(num, dtype) _IOR('O', num, dtype) | |
22 | #define MTK_IOWR(num, dtype) _IOWR('O', num, dtype) | |
23 | #define MTK_IO(num) _IO('O', num) | |
24 | #define MTKFB_QUEUE_OVERLAY_CONFIG MTK_IOW(137, struct fb_overlay_config) | |
25 | /* -------------------------------------------------------------------------- */ | |
26 | #define MTKFB_SET_OVERLAY_LAYER MTK_IOW(0, struct fb_overlay_layer) | |
27 | #define MTKFB_TRIG_OVERLAY_OUT MTK_IO(1) | |
28 | #define MTKFB_SET_VIDEO_LAYERS MTK_IOW(2, struct fb_overlay_layer) | |
29 | #define MTKFB_CAPTURE_FRAMEBUFFER MTK_IOW(3, unsigned long) | |
30 | #define MTKFB_CONFIG_IMMEDIATE_UPDATE MTK_IOW(4, unsigned long) | |
31 | #define MTKFB_SET_MULTIPLE_LAYERS MTK_IOW(5, struct fb_overlay_layer) | |
32 | #define MTKFB_REGISTER_OVERLAYBUFFER MTK_IOW(6, struct fb_overlay_buffer_info) | |
33 | #define MTKFB_UNREGISTER_OVERLAYBUFFER MTK_IOW(7, unsigned int) | |
34 | #define MTKFB_SET_ORIENTATION MTK_IOW(8, unsigned long) | |
35 | #define MTKFB_FBLAYER_ENABLE MTK_IOW(9, unsigned int) | |
36 | #define MTKFB_LOCK_FRONT_BUFFER MTK_IO(10) | |
37 | #define MTKFB_UNLOCK_FRONT_BUFFER MTK_IO(11) | |
38 | #define MTKFB_POWERON MTK_IO(12) | |
39 | #define MTKFB_POWEROFF MTK_IO(13) | |
40 | ||
41 | /* Fence/Ion, OVL decoupling */ | |
42 | #define MTKFB_PREPARE_OVERLAY_BUFFER MTK_IOW(14, struct fb_overlay_buffer) | |
43 | ||
44 | /* S3D control */ | |
45 | #define MTKFB_SET_COMPOSING3D MTK_IOW(15, unsigned long) | |
46 | #define MTKFB_SET_S3D_FTM MTK_IOW(16, unsigned long) | |
47 | ||
48 | /* FM De-sense for EM and Normal mode */ | |
49 | #define MTKFB_GET_DEFAULT_UPDATESPEED MTK_IOR(17, unsigned long) | |
50 | #define MTKFB_GET_CURR_UPDATESPEED MTK_IOR(18, unsigned long) | |
51 | #define MTKFB_CHANGE_UPDATESPEED MTK_IOW(19, unsigned long) /* for EM, not called change writecycle because DPI change pll ckl */ | |
52 | #define MTKFB_GET_INTERFACE_TYPE MTK_IOR(20, unsigned long) /* /0 DBI, 1 DPI, 2 MIPI */ | |
53 | #define MTKFB_GET_POWERSTATE MTK_IOR(21, unsigned long) /* /0: power off 1: power on */ | |
54 | #define MTKFB_GET_DISPLAY_IF_INFORMATION MTK_IOR(22, mtk_dispif_info_t) | |
55 | #define MTKFB_AEE_LAYER_EXIST MTK_IOR(23, unsigned long) //called before SET_OVERLAY each time, if true, hwc will not use FB_LAYER again | |
56 | #define MTKFB_GET_OVERLAY_LAYER_INFO MTK_IOR(24, struct fb_overlay_layer_info) | |
57 | #define MTKFB_FACTORY_AUTO_TEST MTK_IOR(25, unsigned long) | |
58 | #define MTKFB_GET_FRAMEBUFFER_MVA MTK_IOR(26, unsigned int) | |
59 | #define MTKFB_SLT_AUTO_CAPTURE MTK_IOWR(27, struct fb_slt_catpure) | |
60 | ||
61 | //error handling | |
62 | #define MTKFB_META_RESTORE_SCREEN MTK_IOW(101, unsigned long) | |
63 | #define MTKFB_ERROR_INDEX_UPDATE_TIMEOUT MTK_IO(103) | |
64 | #define MTKFB_ERROR_INDEX_UPDATE_TIMEOUT_AEE MTK_IO(104) | |
65 | ||
66 | /*restore bootlogo and charater in meta mode*/ | |
67 | #define MTKFB_META_SHOW_BOOTLOGO MTK_IO(105) | |
68 | ||
69 | //Extension FB active option | |
70 | #define FB_ACTIVATE_NO_UPDATE 512 /* Skip frame update */ | |
71 | ||
72 | //---------------------------------------------------------------------- | |
73 | ||
74 | // -------------------------------------------------------------------------- | |
75 | ||
76 | /** | |
77 | * Just for mt6589 Platform | |
78 | * @{ | |
79 | */ | |
80 | #define MTKFB_GETVFRAMEPHYSICAL MTK_IOW(41, unsigned long) | |
81 | #define MTKFB_WAIT_OVERLAY_READY MTK_IO(42) | |
82 | #define MTKFB_GET_OVERLAY_LAYER_COUNT MTK_IOR(43, unsigned long) | |
83 | #define MTKFB_GET_VIDEOLAYER_SIZE MTK_IOR(44, struct fb_overlay_layer) | |
84 | #define MTKFB_CAPTURE_VIDEOBUFFER MTK_IOW(45, unsigned long) | |
85 | ||
86 | /* -------------------------------------------------------------------------- */ | |
87 | /* Video Playback Mode */ | |
88 | #define MTKFB_TV_POST_VIDEO_BUFFER MTK_IOW(46, unsigned long) | |
89 | #define MTKFB_TV_LEAVE_VIDEO_PLAYBACK_MODE MTK_IOW(47, unsigned long) | |
90 | /* For Factory Mode */ | |
91 | #define MTKFB_IS_TV_CABLE_PLUG_IN MTK_IOW(48, unsigned long) | |
92 | ||
93 | /* -------------------------------------------------------------------------- */ | |
94 | #define MTKFB_BOOTANIMATION MTK_IO(49) | |
95 | #define MTKFB_GETFPS MTK_IOW(50, unsigned long) | |
96 | #define MTKFB_VSYNC MTK_IO(51) | |
97 | ||
98 | /* ----------------------------------------------------------------------FM De-sense for EM and Normal mode */ | |
99 | #define MTKFB_FM_NOTIFY_FREQ MTK_IOW(52, unsigned long) /* for Normal mode */ | |
100 | #define MTKFB_RESET_UPDATESPEED MTK_IO(53) | |
101 | #define MTKFB_SET_UI_LAYER_ALPHA MTK_IOW(54, unsigned long) | |
102 | #define MTKFB_SET_UI_LAYER_SRCKEY MTK_IOW(55, unsigned long) | |
103 | ||
104 | #define MTKFB_GET_MAX_DISPLAY_COUNT MTK_IOR(56, unsigned int) | |
105 | #define MTKFB_SET_FB_LAYER_SECURE MTK_IOW(57, int) | |
106 | /** | |
107 | * @} | |
108 | */ | |
109 | /* ---------------------------------------------------------------------- */ | |
110 | ||
111 | /* -------------------------------------------------------------------------- */ | |
112 | ||
113 | typedef enum { | |
114 | MTK_FB_ORIENTATION_0 = 0, | |
115 | MTK_FB_ORIENTATION_90 = 1, | |
116 | MTK_FB_ORIENTATION_180 = 2, | |
117 | MTK_FB_ORIENTATION_270 = 3, | |
118 | } MTK_FB_ORIENTATION; | |
119 | ||
120 | ||
121 | typedef enum { | |
122 | MTK_FB_TV_SYSTEM_NTSC = 0, | |
123 | MTK_FB_TV_SYSTEM_PAL = 1, | |
124 | } MTK_FB_TV_SYSTEM; | |
125 | ||
126 | ||
127 | typedef enum { | |
128 | MTK_FB_TV_FMT_RGB565 = 0, | |
129 | MTK_FB_TV_FMT_YUV420_SEQ = 1, | |
130 | MTK_FB_TV_FMT_UYUV422 = 2, | |
131 | MTK_FB_TV_FMT_YUV420_BLK = 3, | |
132 | } MTK_FB_TV_SRC_FORMAT; | |
133 | ||
134 | typedef enum { | |
135 | LAYER_NORMAL_BUFFER = 0, | |
136 | LAYER_SECURE_BUFFER = 1, | |
137 | LAYER_PROTECTED_BUFFER = 2, | |
138 | LAYER_SECURE_BUFFER_WITH_ALIGN = 0x10001, /* the higher 16 bits =1 for adding 64 bytes alignment */ | |
139 | } MTK_FB_OVL_LAYER_SECURE_MODE; | |
140 | ||
141 | typedef struct _disp_dfo_item { | |
142 | char name[32]; | |
143 | int value; | |
144 | } disp_dfo_item_t; | |
145 | ||
146 | /* -------------------------------------------------------------------------- */ | |
147 | struct fb_slt_catpure { | |
148 | MTK_FB_FORMAT format; | |
149 | volatile char *outputBuffer; | |
150 | unsigned int wdma_width; | |
151 | unsigned int wdma_height; | |
152 | }; | |
153 | ||
154 | struct fb_scale { | |
155 | unsigned int xscale, yscale; | |
156 | }; | |
157 | ||
158 | struct fb_frame_offset { | |
159 | unsigned int idx; | |
160 | unsigned long offset; | |
161 | }; | |
162 | ||
163 | struct fb_update_window { | |
164 | unsigned int x, y; | |
165 | unsigned int width, height; | |
166 | }; | |
167 | ||
168 | typedef enum { | |
169 | LAYER_2D = 0, | |
170 | LAYER_3D_SBS_0 = 0x1, | |
171 | LAYER_3D_SBS_90 = 0x2, | |
172 | LAYER_3D_SBS_180 = 0x3, | |
173 | LAYER_3D_SBS_270 = 0x4, | |
174 | LAYER_3D_TAB_0 = 0x10, | |
175 | LAYER_3D_TAB_90 = 0x20, | |
176 | LAYER_3D_TAB_180 = 0x30, | |
177 | LAYER_3D_TAB_270 = 0x40, | |
178 | } MTK_FB_LAYER_TYPE; | |
179 | ||
180 | typedef enum { | |
181 | DISP_DIRECT_LINK_MODE, | |
182 | DISP_DECOUPLE_MODE | |
183 | } MTK_DISP_MODE; | |
184 | struct fb_overlay_mode { | |
185 | MTK_DISP_MODE mode; | |
186 | }; | |
187 | ||
188 | typedef enum { /* map sessions to scenairos in kernel driver */ | |
189 | DISP_SESSION_LCM = 1 << 0, /* DSI0 */ | |
190 | DISP_SESSION_MEM = 1 << 1, /* OVL0->WDMA0 */ | |
191 | DISP_SESSION_WFD = 1 << 2, /* Extention mode, Dst buf is provided by user, for Wifi Display or other purpose */ | |
192 | DISP_SESSION_MHL = 1 << 3, /* DPI */ | |
193 | DISP_SESSION_LCM1 = 1 << 4, /* DSI1 */ | |
194 | DISP_SESSION_MEM1 = 1 << 5, /* OVL1->WDMA1 */ | |
195 | /* TODO:can be extended with other Session Id */ | |
196 | SESSION_MASK = 0xff & ~(1 << 6) | |
197 | } MTK_DISP_SESSION; | |
198 | ||
199 | struct fb_overlay_session { | |
200 | unsigned int session; /* one or more @MTK_DISP_SESSION combined */ | |
201 | }; | |
202 | ||
203 | struct fb_overlay_decouple { | |
204 | MTK_DISP_MODE mode; | |
205 | unsigned int session; | |
206 | }; | |
207 | struct fb_overlay_buffer { | |
208 | /* Input */ | |
4b9e9796 | 209 | unsigned int layer_id; |
6fa3eb70 S |
210 | unsigned int layer_en; |
211 | int ion_fd; | |
212 | unsigned int cache_sync; | |
213 | /* Output */ | |
214 | unsigned int index; | |
215 | int fence_fd; | |
216 | }; | |
217 | ||
218 | struct fb_overlay_layer { | |
219 | unsigned int layer_id; | |
220 | unsigned int layer_enable; | |
221 | ||
222 | void *src_base_addr; | |
223 | void *src_phy_addr; | |
224 | unsigned int src_direct_link; | |
225 | MTK_FB_FORMAT src_fmt; | |
226 | unsigned int src_use_color_key; | |
227 | unsigned int src_color_key; | |
228 | unsigned int src_pitch; | |
229 | unsigned int src_offset_x, src_offset_y; | |
230 | unsigned int src_width, src_height; | |
231 | ||
232 | unsigned int tgt_offset_x, tgt_offset_y; | |
233 | unsigned int tgt_width, tgt_height; | |
234 | MTK_FB_ORIENTATION layer_rotation; | |
235 | MTK_FB_LAYER_TYPE layer_type; | |
236 | MTK_FB_ORIENTATION video_rotation; | |
237 | ||
238 | unsigned int isTdshp; /* set to 1, will go through tdshp first, then layer blending, then to color */ | |
239 | ||
240 | int next_buff_idx; | |
241 | int identity; | |
242 | int connected_type; | |
243 | unsigned int security; | |
244 | unsigned int alpha_enable; | |
245 | unsigned int alpha; | |
246 | int fence_fd; /* 8135 */ | |
247 | int ion_fd; /* 8135 CL 2340210 */ | |
248 | }; | |
249 | ||
250 | struct fb_overlay_config { | |
251 | int fence; | |
252 | int time; | |
253 | struct fb_overlay_layer layers[4]; | |
254 | }; | |
255 | ||
256 | struct fb_overlay_buffer_info { | |
257 | unsigned int src_vir_addr; | |
258 | unsigned int size; | |
259 | }; | |
260 | ||
261 | struct fb_overlay_layer_info { | |
262 | unsigned int layer_id; | |
263 | unsigned int layer_enabled; /* TO BE DEL */ | |
264 | unsigned int curr_en; | |
265 | unsigned int next_en; | |
266 | unsigned int hw_en; | |
267 | int curr_idx; | |
268 | int next_idx; | |
269 | int hw_idx; | |
270 | int curr_identity; | |
271 | int next_identity; | |
272 | int hw_identity; | |
273 | int curr_conn_type; | |
274 | int next_conn_type; | |
275 | int hw_conn_type; | |
276 | MTK_FB_ORIENTATION layer_rotation; | |
277 | }; | |
278 | /* -------------------------------------------------------------------------- */ | |
279 | ||
280 | struct fb_post_video_buffer { | |
281 | void *phy_addr; | |
282 | void *vir_addr; | |
283 | MTK_FB_TV_SRC_FORMAT format; | |
284 | unsigned int width, height; | |
285 | }; | |
286 | ||
287 | #ifdef __KERNEL__ | |
288 | ||
289 | #include <linux/completion.h> | |
290 | #include <linux/interrupt.h> | |
291 | #include <linux/workqueue.h> | |
292 | ||
293 | #include <linux/version.h> | |
294 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)) | |
295 | #include <linux/sw_sync.h> | |
296 | #else | |
297 | #include <../drivers/staging/android/sw_sync.h> | |
298 | #endif | |
299 | ||
300 | ||
301 | #define MTKFB_DRIVER "mtkfb" | |
302 | ||
303 | enum mtkfb_state { | |
304 | MTKFB_DISABLED = 0, | |
305 | MTKFB_SUSPENDED = 99, | |
306 | MTKFB_ACTIVE = 100 | |
307 | }; | |
308 | ||
309 | typedef enum { | |
310 | MTKFB_LAYER_ENABLE_DIRTY = (1 << 0), | |
311 | MTKFB_LAYER_FORMAT_DIRTY = (1 << 1), | |
312 | MTKFB_LAYER_SET_DIRTY = (1 << 2), | |
313 | } MTKFB_LAYER_CONFIG_DIRTY; | |
314 | ||
315 | typedef struct { | |
316 | struct work_struct work; | |
317 | struct list_head list; | |
318 | struct fb_overlay_config config; | |
319 | struct sync_fence *fences[4]; | |
320 | struct ion_handle *ion_handles[4]; | |
321 | void *dev; | |
322 | } update_ovls_work_t; | |
323 | ||
324 | struct mtkfb_device { | |
325 | int state; | |
326 | void *fb_va_base; /* MPU virtual address */ | |
327 | dma_addr_t fb_pa_base; /* Bus physical address */ | |
328 | unsigned long fb_size_in_byte; | |
329 | void *ovl_va_base; /* MPU virtual address */ | |
330 | dma_addr_t ovl_pa_base; /* Bus physical address */ | |
331 | unsigned long ovl_size_in_byte; | |
332 | ||
333 | unsigned long layer_enable; | |
334 | MTK_FB_FORMAT *layer_format; | |
335 | unsigned int layer_config_dirty; | |
336 | ||
337 | int xscale, yscale, mirror; /* transformations. | |
338 | rotate is stored in fb_info->var */ | |
339 | u32 pseudo_palette[17]; | |
340 | ||
341 | struct fb_info *fb_info; /* Linux fbdev framework data */ | |
342 | struct device *dev; | |
343 | ||
344 | /* Android native fence support */ | |
345 | struct workqueue_struct *update_ovls_wq; | |
346 | struct mutex timeline_lock; | |
347 | struct sw_sync_timeline *timeline; | |
348 | int timeline_max; | |
349 | struct list_head pending_configs; /* CL2340210 */ | |
350 | struct ion_client *ion_client; | |
351 | }; | |
352 | ||
353 | #endif /* __KERNEL__ */ | |
354 | ||
355 | extern long hdmi_handle_cmd(unsigned int cmd, unsigned long arg); | |
356 | ||
357 | ||
358 | #endif /* __MTKFB_H */ |