3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
5 * Inki Dae <inki.dae@samsung.com>
6 * Joonyoung Shim <jy0922.shim@samsung.com>
7 * Seung-Woo Kim <sw0312.kim@samsung.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
15 #ifndef _EXYNOS_DRM_DRV_H_
16 #define _EXYNOS_DRM_DRV_H_
19 #include <linux/module.h>
23 #define MAX_FB_BUFFER 4
24 #define DEFAULT_ZPOS -1
26 /* This enumerates device type. */
27 enum exynos_drm_device_type {
28 EXYNOS_DEVICE_TYPE_NONE,
29 EXYNOS_DEVICE_TYPE_CRTC,
30 EXYNOS_DEVICE_TYPE_CONNECTOR,
33 /* this enumerates display type. */
34 enum exynos_drm_output_type {
35 EXYNOS_DISPLAY_TYPE_NONE,
36 /* RGB or CPU Interface. */
37 EXYNOS_DISPLAY_TYPE_LCD,
39 EXYNOS_DISPLAY_TYPE_HDMI,
40 /* Virtual Display Interface. */
41 EXYNOS_DISPLAY_TYPE_VIDI,
45 * Exynos drm common overlay structure.
47 * @fb_x: offset x on a framebuffer to be displayed.
48 * - the unit is screen coordinates.
49 * @fb_y: offset y on a framebuffer to be displayed.
50 * - the unit is screen coordinates.
51 * @fb_width: width of a framebuffer.
52 * @fb_height: height of a framebuffer.
53 * @src_width: width of a partial image to be displayed from framebuffer.
54 * @src_height: height of a partial image to be displayed from framebuffer.
55 * @crtc_x: offset x on hardware screen.
56 * @crtc_y: offset y on hardware screen.
57 * @crtc_width: window width to be displayed (hardware screen).
58 * @crtc_height: window height to be displayed (hardware screen).
59 * @mode_width: width of screen mode.
60 * @mode_height: height of screen mode.
61 * @refresh: refresh rate.
62 * @scan_flag: interlace or progressive way.
63 * (it could be DRM_MODE_FLAG_*)
64 * @bpp: pixel size.(in bit)
65 * @pixel_format: fourcc pixel format of this overlay
66 * @dma_addr: array of bus(accessed by dma) address to the memory region
67 * allocated for a overlay.
68 * @zpos: order of overlay layer(z position).
69 * @index_color: if using color key feature then this value would be used
71 * @default_win: a window to be enabled.
72 * @color_key: color key on or off.
73 * @local_path: in case of lcd type, local path mode on or off.
74 * @transparency: transparency on or off.
75 * @activated: activated or not.
77 * this structure is common to exynos SoC and its contents would be copied
78 * to hardware specific overlay info.
80 struct exynos_drm_overlay {
83 unsigned int fb_width;
84 unsigned int fb_height;
85 unsigned int src_width;
86 unsigned int src_height;
89 unsigned int crtc_width;
90 unsigned int crtc_height;
91 unsigned int mode_width;
92 unsigned int mode_height;
94 unsigned int scan_flag;
97 uint32_t pixel_format;
98 dma_addr_t dma_addr[MAX_FB_BUFFER];
100 unsigned int index_color;
110 * Exynos DRM Display Structure.
111 * - this structure is common to analog tv, digital tv and lcd panel.
113 * @create_connector: initialize and register a new connector
114 * @remove: cleans up the display for removal
115 * @mode_fixup: fix mode data comparing to hw specific display mode.
116 * @mode_set: convert drm_display_mode to hw specific display mode and
117 * would be called by encoder->mode_set().
118 * @check_mode: check if mode is valid or not.
119 * @dpms: display device on or off.
120 * @commit: apply changes to hw
122 struct exynos_drm_display;
123 struct exynos_drm_display_ops {
124 int (*create_connector)(struct exynos_drm_display *display,
125 struct drm_encoder *encoder);
126 void (*remove)(struct exynos_drm_display *display);
127 void (*mode_fixup)(struct exynos_drm_display *display,
128 struct drm_connector *connector,
129 const struct drm_display_mode *mode,
130 struct drm_display_mode *adjusted_mode);
131 void (*mode_set)(struct exynos_drm_display *display,
132 struct drm_display_mode *mode);
133 int (*check_mode)(struct exynos_drm_display *display,
134 struct drm_display_mode *mode);
135 void (*dpms)(struct exynos_drm_display *display, int mode);
136 void (*commit)(struct exynos_drm_display *display);
140 * Exynos drm display structure, maps 1:1 with an encoder/connector
142 * @list: the list entry for this manager
143 * @type: one of EXYNOS_DISPLAY_TYPE_LCD and HDMI.
144 * @encoder: encoder object this display maps to
145 * @connector: connector object this display maps to
146 * @ops: pointer to callbacks for exynos drm specific functionality
147 * @ctx: A pointer to the display's implementation specific context
149 struct exynos_drm_display {
150 struct list_head list;
151 enum exynos_drm_output_type type;
152 struct drm_encoder *encoder;
153 struct drm_connector *connector;
154 struct exynos_drm_display_ops *ops;
158 * Exynos drm manager ops
160 * @dpms: control device power.
161 * @mode_fixup: fix mode data before applying it
162 * @mode_set: set the given mode to the manager
163 * @commit: set current hw specific display mode to hw.
164 * @enable_vblank: specific driver callback for enabling vblank interrupt.
165 * @disable_vblank: specific driver callback for disabling vblank interrupt.
166 * @wait_for_vblank: wait for vblank interrupt to make sure that
167 * hardware overlay is updated.
168 * @win_mode_set: copy drm overlay info to hw specific overlay info.
169 * @win_commit: apply hardware specific overlay data to registers.
170 * @win_enable: enable hardware specific overlay.
171 * @win_disable: disable hardware specific overlay.
172 * @te_handler: trigger to transfer video image at the tearing effect
173 * synchronization signal if there is a page flip request.
175 struct exynos_drm_manager;
176 struct exynos_drm_manager_ops {
177 void (*dpms)(struct exynos_drm_manager *mgr, int mode);
178 bool (*mode_fixup)(struct exynos_drm_manager *mgr,
179 const struct drm_display_mode *mode,
180 struct drm_display_mode *adjusted_mode);
181 void (*mode_set)(struct exynos_drm_manager *mgr,
182 const struct drm_display_mode *mode);
183 void (*commit)(struct exynos_drm_manager *mgr);
184 int (*enable_vblank)(struct exynos_drm_manager *mgr);
185 void (*disable_vblank)(struct exynos_drm_manager *mgr);
186 void (*wait_for_vblank)(struct exynos_drm_manager *mgr);
187 void (*win_mode_set)(struct exynos_drm_manager *mgr,
188 struct exynos_drm_overlay *overlay);
189 void (*win_commit)(struct exynos_drm_manager *mgr, int zpos);
190 void (*win_enable)(struct exynos_drm_manager *mgr, int zpos);
191 void (*win_disable)(struct exynos_drm_manager *mgr, int zpos);
192 void (*te_handler)(struct exynos_drm_manager *mgr);
196 * Exynos drm common manager structure, maps 1:1 with a crtc
198 * @list: the list entry for this manager
199 * @type: one of EXYNOS_DISPLAY_TYPE_LCD and HDMI.
200 * @drm_dev: pointer to the drm device
201 * @crtc: crtc object.
202 * @pipe: the pipe number for this crtc/manager
203 * @ops: pointer to callbacks for exynos drm specific functionality
204 * @ctx: A pointer to the manager's implementation specific context
206 struct exynos_drm_manager {
207 struct list_head list;
208 enum exynos_drm_output_type type;
209 struct drm_device *drm_dev;
210 struct drm_crtc *crtc;
212 struct exynos_drm_manager_ops *ops;
215 struct exynos_drm_g2d_private {
217 struct list_head inuse_cmdlist;
218 struct list_head event_list;
219 struct list_head userptr_list;
222 struct drm_exynos_file_private {
223 struct exynos_drm_g2d_private *g2d_priv;
224 struct device *ipp_dev;
228 * Exynos drm private structure.
230 * @da_start: start address to device address space.
231 * with iommu, device address space starts from this address
232 * otherwise default one.
233 * @da_space_size: size of device address space.
234 * if 0 then default value is used for it.
235 * @pipe: the pipe number for this crtc/manager.
237 struct exynos_drm_private {
238 struct drm_fb_helper *fb_helper;
240 /* list head for new event to be added. */
241 struct list_head pageflip_event_list;
244 * created crtc object would be contained at this array and
245 * this array is used to be aware of which crtc did it request vblank.
247 struct drm_crtc *crtc[MAX_CRTC];
248 struct drm_property *plane_zpos_property;
249 struct drm_property *crtc_mode_property;
251 unsigned long da_start;
252 unsigned long da_space_size;
258 * Exynos drm sub driver structure.
260 * @list: sub driver has its own list object to register to exynos drm driver.
261 * @dev: pointer to device object for subdrv device driver.
262 * @drm_dev: pointer to drm_device and this pointer would be set
263 * when sub driver calls exynos_drm_subdrv_register().
264 * @probe: this callback would be called by exynos drm driver after
265 * subdrv is registered to it.
266 * @remove: this callback is used to release resources created
268 * @open: this would be called with drm device file open.
269 * @close: this would be called with drm device file close.
271 struct exynos_drm_subdrv {
272 struct list_head list;
274 struct drm_device *drm_dev;
276 int (*probe)(struct drm_device *drm_dev, struct device *dev);
277 void (*remove)(struct drm_device *drm_dev, struct device *dev);
278 int (*open)(struct drm_device *drm_dev, struct device *dev,
279 struct drm_file *file);
280 void (*close)(struct drm_device *drm_dev, struct device *dev,
281 struct drm_file *file);
284 /* This function would be called by non kms drivers such as g2d and ipp. */
285 int exynos_drm_subdrv_register(struct exynos_drm_subdrv *drm_subdrv);
287 /* this function removes subdrv list from exynos drm driver */
288 int exynos_drm_subdrv_unregister(struct exynos_drm_subdrv *drm_subdrv);
290 int exynos_drm_device_subdrv_probe(struct drm_device *dev);
291 int exynos_drm_device_subdrv_remove(struct drm_device *dev);
292 int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file);
293 void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file);
295 #ifdef CONFIG_DRM_EXYNOS_IPP
296 int exynos_platform_device_ipp_register(void);
297 void exynos_platform_device_ipp_unregister(void);
299 static inline int exynos_platform_device_ipp_register(void) { return 0; }
300 static inline void exynos_platform_device_ipp_unregister(void) {}
304 #ifdef CONFIG_DRM_EXYNOS_DPI
305 struct exynos_drm_display * exynos_dpi_probe(struct device *dev);
306 int exynos_dpi_remove(struct exynos_drm_display *display);
308 static inline struct exynos_drm_display *
309 exynos_dpi_probe(struct device *dev) { return NULL; }
310 static inline int exynos_dpi_remove(struct exynos_drm_display *display)
316 #ifdef CONFIG_DRM_EXYNOS_VIDI
317 int exynos_drm_probe_vidi(void);
318 void exynos_drm_remove_vidi(void);
320 static inline int exynos_drm_probe_vidi(void) { return 0; }
321 static inline void exynos_drm_remove_vidi(void) {}
324 /* This function creates a encoder and a connector, and initializes them. */
325 int exynos_drm_create_enc_conn(struct drm_device *dev,
326 struct exynos_drm_display *display);
328 int exynos_drm_component_add(struct device *dev,
329 enum exynos_drm_device_type dev_type,
330 enum exynos_drm_output_type out_type);
332 void exynos_drm_component_del(struct device *dev,
333 enum exynos_drm_device_type dev_type);
335 extern struct platform_driver fimd_driver;
336 extern struct platform_driver dp_driver;
337 extern struct platform_driver dsi_driver;
338 extern struct platform_driver mixer_driver;
339 extern struct platform_driver hdmi_driver;
340 extern struct platform_driver exynos_drm_common_hdmi_driver;
341 extern struct platform_driver vidi_driver;
342 extern struct platform_driver g2d_driver;
343 extern struct platform_driver fimc_driver;
344 extern struct platform_driver rotator_driver;
345 extern struct platform_driver gsc_driver;
346 extern struct platform_driver ipp_driver;