1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * linux/include/video/mmp_disp.h
4 * Header file for Marvell MMP Display Controller
6 * Copyright (C) 2012 Marvell Technology Group Ltd.
7 * Authors: Zhou Zhu <zzhu3@marvell.com>
12 #include <linux/kthread.h>
22 PIXFMT_RGB565 = 0x100,
32 PIXFMT_RGB666, /* for output usage */
33 PIXFMT_PSEUDOCOLOR = 0x200,
36 static inline int pixfmt_to_stride(int pix_fmt)
47 case PIXFMT_RGB888UNPACK:
48 case PIXFMT_BGR888UNPACK:
52 case PIXFMT_RGB888PACK:
53 case PIXFMT_BGR888PACK:
59 case PIXFMT_PSEUDOCOLOR:
66 /* parameters used by path/overlay */
67 /* overlay related para: win/addr */
69 /* position/size of window */
82 * pitch[0]: graphics/video layer line length or y pitch
83 * pitch[1]/pitch[2]: video u/v pitch if non-zero
93 /* path related para: mode */
112 /* main structures */
123 static inline const char *stat_name(int stat)
131 return "UNKNOWNSTAT";
135 struct mmp_overlay_ops {
136 /* should be provided by driver */
137 void (*set_fetch)(struct mmp_overlay *overlay, int fetch_id);
138 void (*set_onoff)(struct mmp_overlay *overlay, int status);
139 void (*set_win)(struct mmp_overlay *overlay, struct mmp_win *win);
140 int (*set_addr)(struct mmp_overlay *overlay, struct mmp_addr *addr);
143 /* overlay describes a z-order indexed slot in each path. */
147 struct mmp_path *path;
149 /* overlay info: private data */
151 struct mmp_addr addr;
157 struct mutex access_ok;
159 struct mmp_overlay_ops *ops;
164 PANELTYPE_ACTIVE = 0,
172 /* use node to register to list */
173 struct list_head node;
175 /* path name used to connect to proper path configed */
176 const char *plat_path_name;
180 int (*get_modelist)(struct mmp_panel *panel,
181 struct mmp_mode **modelist);
182 void (*set_mode)(struct mmp_panel *panel,
183 struct mmp_mode *mode);
184 void (*set_onoff)(struct mmp_panel *panel,
188 struct mmp_path_ops {
189 int (*check_status)(struct mmp_path *path);
190 struct mmp_overlay *(*get_overlay)(struct mmp_path *path,
192 int (*get_modelist)(struct mmp_path *path,
193 struct mmp_mode **modelist);
195 /* follow ops should be provided by driver */
196 void (*set_mode)(struct mmp_path *path, struct mmp_mode *mode);
197 void (*set_onoff)(struct mmp_path *path, int status);
198 /* todo: add query */
201 /* path output types */
208 /* path is main part of mmp-disp */
210 /* use node to register to list */
211 struct list_head node;
219 struct mmp_panel *panel;
223 struct mmp_mode mode;
228 struct mutex access_ok;
230 struct mmp_path_ops ops;
234 struct mmp_overlay overlays[] __counted_by(overlay_num);
237 extern struct mmp_path *mmp_get_path(const char *name);
238 static inline void mmp_path_set_mode(struct mmp_path *path,
239 struct mmp_mode *mode)
242 path->ops.set_mode(path, mode);
244 static inline void mmp_path_set_onoff(struct mmp_path *path, int status)
247 path->ops.set_onoff(path, status);
249 static inline int mmp_path_get_modelist(struct mmp_path *path,
250 struct mmp_mode **modelist)
253 return path->ops.get_modelist(path, modelist);
256 static inline struct mmp_overlay *mmp_path_get_overlay(
257 struct mmp_path *path, int overlay_id)
260 return path->ops.get_overlay(path, overlay_id);
263 static inline void mmp_overlay_set_fetch(struct mmp_overlay *overlay,
267 overlay->ops->set_fetch(overlay, fetch_id);
269 static inline void mmp_overlay_set_onoff(struct mmp_overlay *overlay,
273 overlay->ops->set_onoff(overlay, status);
275 static inline void mmp_overlay_set_win(struct mmp_overlay *overlay,
279 overlay->ops->set_win(overlay, win);
281 static inline int mmp_overlay_set_addr(struct mmp_overlay *overlay,
282 struct mmp_addr *addr)
285 return overlay->ops->set_addr(overlay, addr);
290 * driver data is set from each detailed ctrl driver for path usage
291 * it defined a common interface that plat driver need to implement
293 struct mmp_path_info {
294 /* driver data, set when registed*/
300 void (*set_mode)(struct mmp_path *path, struct mmp_mode *mode);
301 void (*set_onoff)(struct mmp_path *path, int status);
302 struct mmp_overlay_ops *overlay_ops;
306 extern struct mmp_path *mmp_register_path(
307 struct mmp_path_info *info);
308 extern void mmp_unregister_path(struct mmp_path *path);
309 extern void mmp_register_panel(struct mmp_panel *panel);
310 extern void mmp_unregister_panel(struct mmp_panel *panel);
312 /* defintions for platform data */
313 /* interface for buffer driver */
314 struct mmp_buffer_driver_mach_info {
316 const char *path_name;
322 /* interface for controllers driver */
323 struct mmp_mach_path_config {
332 struct mmp_mach_plat_info {
334 const char *clk_name;
336 struct mmp_mach_path_config *paths;
339 /* interface for panel drivers */
340 struct mmp_mach_panel_info {
342 void (*plat_set_onoff)(int status);
343 const char *plat_path_name;
345 #endif /* _MMP_DISP_H_ */