mfd: wm8350-i2c: Make sure the i2c regmap functions are compiled
[linux/fpc-iii.git] / include / video / mmp_disp.h
blobb9dd1fbb00827d29aff8b3ff5d814d85715a2245
1 /*
2 * linux/include/video/mmp_disp.h
3 * Header file for Marvell MMP Display Controller
5 * Copyright (C) 2012 Marvell Technology Group Ltd.
6 * Authors: Zhou Zhu <zzhu3@marvell.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
18 * You should have received a copy of the GNU General Public License along with
19 * this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef _MMP_DISP_H_
24 #define _MMP_DISP_H_
25 #include <linux/kthread.h>
27 enum {
28 PIXFMT_UYVY = 0,
29 PIXFMT_VYUY,
30 PIXFMT_YUYV,
31 PIXFMT_YUV422P,
32 PIXFMT_YVU422P,
33 PIXFMT_YUV420P,
34 PIXFMT_YVU420P,
35 PIXFMT_RGB565 = 0x100,
36 PIXFMT_BGR565,
37 PIXFMT_RGB1555,
38 PIXFMT_BGR1555,
39 PIXFMT_RGB888PACK,
40 PIXFMT_BGR888PACK,
41 PIXFMT_RGB888UNPACK,
42 PIXFMT_BGR888UNPACK,
43 PIXFMT_RGBA888,
44 PIXFMT_BGRA888,
45 PIXFMT_RGB666, /* for output usage */
46 PIXFMT_PSEUDOCOLOR = 0x200,
49 static inline int pixfmt_to_stride(int pix_fmt)
51 switch (pix_fmt) {
52 case PIXFMT_RGB565:
53 case PIXFMT_BGR565:
54 case PIXFMT_RGB1555:
55 case PIXFMT_BGR1555:
56 case PIXFMT_UYVY:
57 case PIXFMT_VYUY:
58 case PIXFMT_YUYV:
59 return 2;
60 case PIXFMT_RGB888UNPACK:
61 case PIXFMT_BGR888UNPACK:
62 case PIXFMT_RGBA888:
63 case PIXFMT_BGRA888:
64 return 4;
65 case PIXFMT_RGB888PACK:
66 case PIXFMT_BGR888PACK:
67 return 3;
68 case PIXFMT_YUV422P:
69 case PIXFMT_YVU422P:
70 case PIXFMT_YUV420P:
71 case PIXFMT_YVU420P:
72 case PIXFMT_PSEUDOCOLOR:
73 return 1;
74 default:
75 return 0;
79 /* parameters used by path/overlay */
80 /* overlay related para: win/addr */
81 struct mmp_win {
82 /* position/size of window */
83 u16 xsrc;
84 u16 ysrc;
85 u16 xdst;
86 u16 ydst;
87 u16 xpos;
88 u16 ypos;
89 u16 left_crop;
90 u16 right_crop;
91 u16 up_crop;
92 u16 bottom_crop;
93 int pix_fmt;
96 struct mmp_addr {
97 /* phys address */
98 u32 phys[6];
101 /* path related para: mode */
102 struct mmp_mode {
103 const char *name;
104 u32 refresh;
105 u32 xres;
106 u32 yres;
107 u32 left_margin;
108 u32 right_margin;
109 u32 upper_margin;
110 u32 lower_margin;
111 u32 hsync_len;
112 u32 vsync_len;
113 u32 hsync_invert;
114 u32 vsync_invert;
115 u32 invert_pixclock;
116 u32 pixclock_freq;
117 int pix_fmt_out;
120 /* main structures */
121 struct mmp_path;
122 struct mmp_overlay;
123 struct mmp_panel;
125 /* status types */
126 enum {
127 MMP_OFF = 0,
128 MMP_ON,
131 static inline const char *stat_name(int stat)
133 switch (stat) {
134 case MMP_OFF:
135 return "OFF";
136 case MMP_ON:
137 return "ON";
138 default:
139 return "UNKNOWNSTAT";
143 struct mmp_overlay_ops {
144 /* should be provided by driver */
145 void (*set_fetch)(struct mmp_overlay *overlay, int fetch_id);
146 void (*set_onoff)(struct mmp_overlay *overlay, int status);
147 void (*set_win)(struct mmp_overlay *overlay, struct mmp_win *win);
148 int (*set_addr)(struct mmp_overlay *overlay, struct mmp_addr *addr);
151 /* overlay describes a z-order indexed slot in each path. */
152 struct mmp_overlay {
153 int id;
154 const char *name;
155 struct mmp_path *path;
157 /* overlay info: private data */
158 int dmafetch_id;
159 struct mmp_addr addr;
160 struct mmp_win win;
162 /* state */
163 int open_count;
164 int status;
165 struct mutex access_ok;
167 struct mmp_overlay_ops *ops;
170 /* panel type */
171 enum {
172 PANELTYPE_ACTIVE = 0,
173 PANELTYPE_SMART,
174 PANELTYPE_TV,
175 PANELTYPE_DSI_CMD,
176 PANELTYPE_DSI_VIDEO,
179 struct mmp_panel {
180 /* use node to register to list */
181 struct list_head node;
182 const char *name;
183 /* path name used to connect to proper path configed */
184 const char *plat_path_name;
185 struct device *dev;
186 int panel_type;
187 void *plat_data;
188 int (*get_modelist)(struct mmp_panel *panel,
189 struct mmp_mode **modelist);
190 void (*set_mode)(struct mmp_panel *panel,
191 struct mmp_mode *mode);
192 void (*set_onoff)(struct mmp_panel *panel,
193 int status);
196 struct mmp_path_ops {
197 int (*check_status)(struct mmp_path *path);
198 struct mmp_overlay *(*get_overlay)(struct mmp_path *path,
199 int overlay_id);
200 int (*get_modelist)(struct mmp_path *path,
201 struct mmp_mode **modelist);
203 /* follow ops should be provided by driver */
204 void (*set_mode)(struct mmp_path *path, struct mmp_mode *mode);
205 void (*set_onoff)(struct mmp_path *path, int status);
206 /* todo: add query */
209 /* path output types */
210 enum {
211 PATH_OUT_PARALLEL,
212 PATH_OUT_DSI,
213 PATH_OUT_HDMI,
216 /* path is main part of mmp-disp */
217 struct mmp_path {
218 /* use node to register to list */
219 struct list_head node;
221 /* init data */
222 struct device *dev;
224 int id;
225 const char *name;
226 int output_type;
227 struct mmp_panel *panel;
228 void *plat_data;
230 /* dynamic use */
231 struct mmp_mode mode;
233 /* state */
234 int open_count;
235 int status;
236 struct mutex access_ok;
238 struct mmp_path_ops ops;
240 /* layers */
241 int overlay_num;
242 struct mmp_overlay overlays[0];
245 extern struct mmp_path *mmp_get_path(const char *name);
246 static inline void mmp_path_set_mode(struct mmp_path *path,
247 struct mmp_mode *mode)
249 if (path)
250 path->ops.set_mode(path, mode);
252 static inline void mmp_path_set_onoff(struct mmp_path *path, int status)
254 if (path)
255 path->ops.set_onoff(path, status);
257 static inline int mmp_path_get_modelist(struct mmp_path *path,
258 struct mmp_mode **modelist)
260 if (path)
261 return path->ops.get_modelist(path, modelist);
262 return 0;
264 static inline struct mmp_overlay *mmp_path_get_overlay(
265 struct mmp_path *path, int overlay_id)
267 if (path)
268 return path->ops.get_overlay(path, overlay_id);
269 return NULL;
271 static inline void mmp_overlay_set_fetch(struct mmp_overlay *overlay,
272 int fetch_id)
274 if (overlay)
275 overlay->ops->set_fetch(overlay, fetch_id);
277 static inline void mmp_overlay_set_onoff(struct mmp_overlay *overlay,
278 int status)
280 if (overlay)
281 overlay->ops->set_onoff(overlay, status);
283 static inline void mmp_overlay_set_win(struct mmp_overlay *overlay,
284 struct mmp_win *win)
286 if (overlay)
287 overlay->ops->set_win(overlay, win);
289 static inline int mmp_overlay_set_addr(struct mmp_overlay *overlay,
290 struct mmp_addr *addr)
292 if (overlay)
293 return overlay->ops->set_addr(overlay, addr);
294 return 0;
298 * driver data is set from each detailed ctrl driver for path usage
299 * it defined a common interface that plat driver need to implement
301 struct mmp_path_info {
302 /* driver data, set when registed*/
303 const char *name;
304 struct device *dev;
305 int id;
306 int output_type;
307 int overlay_num;
308 void (*set_mode)(struct mmp_path *path, struct mmp_mode *mode);
309 void (*set_onoff)(struct mmp_path *path, int status);
310 struct mmp_overlay_ops *overlay_ops;
311 void *plat_data;
314 extern struct mmp_path *mmp_register_path(
315 struct mmp_path_info *info);
316 extern void mmp_unregister_path(struct mmp_path *path);
317 extern void mmp_register_panel(struct mmp_panel *panel);
318 extern void mmp_unregister_panel(struct mmp_panel *panel);
320 /* defintions for platform data */
321 /* interface for buffer driver */
322 struct mmp_buffer_driver_mach_info {
323 const char *name;
324 const char *path_name;
325 int overlay_id;
326 int dmafetch_id;
327 int default_pixfmt;
330 /* interface for controllers driver */
331 struct mmp_mach_path_config {
332 const char *name;
333 int overlay_num;
334 int output_type;
335 u32 path_config;
336 u32 link_config;
339 struct mmp_mach_plat_info {
340 const char *name;
341 const char *clk_name;
342 int path_num;
343 struct mmp_mach_path_config *paths;
346 /* interface for panel drivers */
347 struct mmp_mach_panel_info {
348 const char *name;
349 void (*plat_set_onoff)(int status);
350 const char *plat_path_name;
352 #endif /* _MMP_DISP_H_ */