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 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice (including the next
17 * paragraph) shall be included in all copies or substantial portions of the
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
29 #ifndef _EXYNOS_DRM_DRV_H_
30 #define _EXYNOS_DRM_DRV_H_
32 #include <linux/module.h>
37 #ifdef CONFIG_EXYNOS_IOMMU
38 #include <mach/sysmmu.h>
39 #include <linux/of_platform.h>
42 #ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
43 #include "linux/kds.h"
44 #include <linux/dma-buf.h>
49 #define MAX_FB_BUFFER 4
50 #define DEFAULT_ZPOS -1
53 struct exynos_drm_overlay;
55 struct exynos_drm_gem_object;
56 struct exynos_drm_display;
58 extern unsigned int drm_vblank_offdelay;
61 * Exynos drm common overlay structure.
63 * @fb_x: offset x on a framebuffer to be displayed.
64 * - the unit is screen coordinates.
65 * @fb_y: offset y on a framebuffer to be displayed.
66 * - the unit is screen coordinates.
67 * @fb_width: width of a framebuffer.
68 * @fb_height: height of a framebuffer.
69 * @fb_pitch: pitch of a framebuffer.
70 * @crtc_x: offset x on hardware screen.
71 * @crtc_y: offset y on hardware screen.
72 * @crtc_width: window width to be displayed (hardware screen).
73 * @crtc_height: window height to be displayed (hardware screen).
74 * @mode_width: width of screen mode.
75 * @mode_height: height of screen mode.
76 * @refresh: refresh rate.
77 * @scan_flag: interlace or progressive way.
78 * (it could be DRM_MODE_FLAG_*)
79 * @bpp: pixel size.(in bit)
80 * @pixel_format: fourcc pixel format of this overlay
81 * @dma_addr: array of bus(accessed by dma) address to the memory region
82 * allocated for a overlay.
83 * @vaddr: array of virtual memory addresss to this overlay.
84 * @zpos: order of overlay layer(z position).
85 * @default_win: a window to be enabled.
86 * @color_key: color key on or off.
87 * @index_color: if using color key feature then this value would be used
89 * @local_path: in case of lcd type, local path mode on or off.
90 * @transparency: transparency on or off.
91 * @activated: activated or not.
93 * this structure is common to exynos SoC and its contents would be copied
94 * to hardware specific overlay info.
96 struct exynos_drm_overlay {
99 unsigned int fb_width;
100 unsigned int fb_height;
101 unsigned int fb_pitch;
104 unsigned int crtc_width;
105 unsigned int crtc_height;
106 unsigned int mode_width;
107 unsigned int mode_height;
108 unsigned int refresh;
109 unsigned int scan_flag;
111 uint32_t pixel_format;
112 dma_addr_t dma_addr[MAX_FB_BUFFER];
113 void __iomem *vaddr[MAX_FB_BUFFER];
118 unsigned int index_color;
125 * Exynos drm private structure.
127 struct exynos_drm_private {
128 struct drm_fb_helper *fb_helper;
131 * wait_vsync_event is set to zero by crtc whenever a VSYNC interrupt
132 * is received. After setting wait_vsync_event to 0, wait_vsync_queue
135 wait_queue_head_t wait_vsync_queue;
136 atomic_t wait_vsync_event;
139 * created crtc object would be contained at this array and
140 * this array is used to be aware of which crtc did it request vblank.
142 struct drm_crtc *crtc[MAX_CRTC];
144 #ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
145 struct kds_callback kds_cb;
146 struct kds_callback kds_cb_rm_fb;
151 * Exynos drm sub driver structure.
153 * @list: sub driver has its own list object to register to exynos drm driver.
154 * @dev: pointer to device object for subdrv device driver.
155 * @drm_dev: pointer to drm_device and this pointer would be set
156 * when sub driver calls exynos_drm_subdrv_register().
157 * @display: A pointer to the display structure for this sub driver
158 * @probe: this callback would be called by exynos drm driver after
159 * subdrv is registered to it.
160 * @remove: this callback is used to release resources created
162 * @open: this would be called with drm device file open.
163 * @close: this would be called with drm device file close.
164 * @encoder: encoder object owned by this sub driver.
165 * @connector: connector object owned by this sub driver.
167 struct exynos_drm_subdrv {
168 struct list_head list;
170 struct drm_device *drm_dev;
171 struct exynos_drm_display *display;
173 int (*probe)(struct drm_device *drm_dev,
174 struct exynos_drm_subdrv *subdrv);
175 void (*remove)(struct drm_device *dev);
176 int (*open)(struct drm_device *drm_dev, struct device *dev,
177 struct drm_file *file);
178 void (*close)(struct drm_device *drm_dev, struct device *dev,
179 struct drm_file *file);
181 struct drm_encoder *encoder;
182 struct drm_connector *connector;
186 * this function calls a probe callback registered to sub driver list and
187 * create its own encoder and connector and then set drm_device object
190 int exynos_drm_device_register(struct drm_device *dev);
192 * this function calls a remove callback registered to sub driver list and
193 * destroy its own encoder and connetor.
195 int exynos_drm_device_unregister(struct drm_device *dev);
198 * this function would be called by sub drivers such as display controller
199 * or hdmi driver to register this sub driver object to exynos drm driver
200 * and when a sub driver is registered to exynos drm driver a probe callback
201 * of the sub driver is called and creates its own encoder and connector.
203 int exynos_drm_subdrv_register(struct exynos_drm_subdrv *drm_subdrv);
205 /* this function removes subdrv list from exynos drm driver */
206 int exynos_drm_subdrv_unregister(struct exynos_drm_subdrv *drm_subdrv);
208 void exynos_fimd_dp_attach(struct device *dev);
210 int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file);
211 void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file);
214 * exynos specific framebuffer structure.
216 * @fb: drm framebuffer obejct.
217 * @exynos_gem_obj: array of exynos specific gem object containing a gem object.
219 struct exynos_drm_fb {
220 struct drm_framebuffer fb;
221 struct exynos_drm_gem_obj *exynos_gem_obj[MAX_FB_BUFFER];
222 #ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
223 struct drm_crtc *crtc;
224 struct kds_resource_set *kds_res_set;
225 struct kds_resource_set *kds_res_set_rm_fb;
226 struct dma_buf *dma_buf;
231 * Exynos specific crtc structure.
233 * @drm_crtc: crtc object.
234 * @overlay: contain information common to display controller and hdmi and
235 * contents of this overlay object would be copied to sub driver size.
236 * @event: vblank event that is currently queued for flip
237 * @pipe: a crtc index created at load() with a new crtc object creation
238 * and the crtc object would be set to private->crtc array
239 * to get a crtc object corresponding to this pipe from private->crtc
240 * array when irq interrupt occured. the reason of using this pipe is that
241 * drm framework doesn't support multiple irq yet.
242 * we can refer to the crtc to current hardware interrupt occured through
244 * @dpms: store the crtc dpms value
245 * @flip_pending: there is a flip pending that we need to process next vblank
247 struct exynos_drm_crtc {
248 struct drm_crtc drm_crtc;
249 struct exynos_drm_overlay overlay;
250 #ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
251 struct drm_pending_vblank_event *event;
252 struct kds_resource_set *current_kds;
253 struct kds_resource_set *pending_kds;
254 struct kds_resource_set *future_kds;
255 struct kds_resource_set *future_kds_extra;
259 unsigned int flip_in_flight;
260 atomic_t flip_pending;
263 #define to_exynos_fb(x) container_of(x, struct exynos_drm_fb, fb)
264 #define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\
267 extern struct platform_driver fimd_driver;
268 extern struct platform_driver hdmi_driver;
269 extern struct platform_driver dp_driver;
270 extern struct platform_driver mixer_driver;
271 extern struct platform_driver exynos_drm_common_hdmi_driver;
272 extern struct platform_driver vidi_driver;
273 #ifdef CONFIG_EXYNOS_IOMMU
274 extern struct dma_iommu_mapping *exynos_drm_common_mapping;