blob: 1d814175cd491d39d0411b31fa330c498f02c8c3 [file] [log] [blame]
Inki Dae1c248b72011-10-04 19:19:01 +09001/* exynos_drm_drv.h
2 *
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * Authors:
5 * Inki Dae <inki.dae@samsung.com>
6 * Joonyoung Shim <jy0922.shim@samsung.com>
7 * Seung-Woo Kim <sw0312.kim@samsung.com>
8 *
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:
15 *
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
18 * Software.
19 *
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.
27 */
28
29#ifndef _EXYNOS_DRM_DRV_H_
30#define _EXYNOS_DRM_DRV_H_
31
Inki Dae4f9eb942011-11-12 16:57:42 +090032#include <linux/module.h>
Inki Dae1c248b72011-10-04 19:19:01 +090033#include "drm.h"
34
Inki Daeb73d1232012-03-21 10:55:26 +090035#define MAX_CRTC 3
Joonyoung Shim864ee9e2011-12-08 17:54:07 +090036#define MAX_PLANE 5
Inki Daeb73d1232012-03-21 10:55:26 +090037#define MAX_FB_BUFFER 4
Joonyoung Shim864ee9e2011-12-08 17:54:07 +090038#define DEFAULT_ZPOS -1
Inki Dae1c248b72011-10-04 19:19:01 +090039
40struct drm_device;
41struct exynos_drm_overlay;
42struct drm_connector;
43
Inki Dae52c68812011-12-16 21:31:12 +090044extern unsigned int drm_vblank_offdelay;
45
Inki Dae1c248b72011-10-04 19:19:01 +090046/* this enumerates display type. */
47enum exynos_drm_output_type {
48 EXYNOS_DISPLAY_TYPE_NONE,
49 /* RGB or CPU Interface. */
50 EXYNOS_DISPLAY_TYPE_LCD,
51 /* HDMI Interface. */
52 EXYNOS_DISPLAY_TYPE_HDMI,
Inki Daeb73d1232012-03-21 10:55:26 +090053 /* Virtual Display Interface. */
54 EXYNOS_DISPLAY_TYPE_VIDI,
Inki Dae1c248b72011-10-04 19:19:01 +090055};
56
57/*
58 * Exynos drm overlay ops structure.
59 *
60 * @mode_set: copy drm overlay info to hw specific overlay info.
61 * @commit: apply hardware specific overlay data to registers.
62 * @disable: disable hardware specific overlay.
63 */
64struct exynos_drm_overlay_ops {
65 void (*mode_set)(struct device *subdrv_dev,
66 struct exynos_drm_overlay *overlay);
Joonyoung Shim864ee9e2011-12-08 17:54:07 +090067 void (*commit)(struct device *subdrv_dev, int zpos);
68 void (*disable)(struct device *subdrv_dev, int zpos);
Inki Dae1c248b72011-10-04 19:19:01 +090069};
70
71/*
72 * Exynos drm common overlay structure.
73 *
Inki Dae19c8b832011-10-14 13:29:46 +090074 * @fb_x: offset x on a framebuffer to be displayed.
75 * - the unit is screen coordinates.
76 * @fb_y: offset y on a framebuffer to be displayed.
77 * - the unit is screen coordinates.
78 * @fb_width: width of a framebuffer.
79 * @fb_height: height of a framebuffer.
80 * @crtc_x: offset x on hardware screen.
81 * @crtc_y: offset y on hardware screen.
82 * @crtc_width: window width to be displayed (hardware screen).
83 * @crtc_height: window height to be displayed (hardware screen).
84 * @mode_width: width of screen mode.
85 * @mode_height: height of screen mode.
86 * @refresh: refresh rate.
87 * @scan_flag: interlace or progressive way.
88 * (it could be DRM_MODE_FLAG_*)
Inki Dae1c248b72011-10-04 19:19:01 +090089 * @bpp: pixel size.(in bit)
Seung-Woo Kim229d3532011-12-15 14:36:22 +090090 * @pixel_format: fourcc pixel format of this overlay
91 * @dma_addr: array of bus(accessed by dma) address to the memory region
92 * allocated for a overlay.
93 * @vaddr: array of virtual memory addresss to this overlay.
Joonyoung Shim864ee9e2011-12-08 17:54:07 +090094 * @zpos: order of overlay layer(z position).
Inki Dae1c248b72011-10-04 19:19:01 +090095 * @default_win: a window to be enabled.
96 * @color_key: color key on or off.
97 * @index_color: if using color key feature then this value would be used
98 * as index color.
99 * @local_path: in case of lcd type, local path mode on or off.
100 * @transparency: transparency on or off.
101 * @activated: activated or not.
102 *
103 * this structure is common to exynos SoC and its contents would be copied
104 * to hardware specific overlay info.
105 */
106struct exynos_drm_overlay {
Inki Dae19c8b832011-10-14 13:29:46 +0900107 unsigned int fb_x;
108 unsigned int fb_y;
109 unsigned int fb_width;
110 unsigned int fb_height;
111 unsigned int crtc_x;
112 unsigned int crtc_y;
113 unsigned int crtc_width;
114 unsigned int crtc_height;
115 unsigned int mode_width;
116 unsigned int mode_height;
117 unsigned int refresh;
118 unsigned int scan_flag;
Inki Dae1c248b72011-10-04 19:19:01 +0900119 unsigned int bpp;
Inki Dae19c8b832011-10-14 13:29:46 +0900120 unsigned int pitch;
Seung-Woo Kim229d3532011-12-15 14:36:22 +0900121 uint32_t pixel_format;
122 dma_addr_t dma_addr[MAX_FB_BUFFER];
123 void __iomem *vaddr[MAX_FB_BUFFER];
Joonyoung Shim864ee9e2011-12-08 17:54:07 +0900124 int zpos;
Inki Dae1c248b72011-10-04 19:19:01 +0900125
126 bool default_win;
127 bool color_key;
128 unsigned int index_color;
129 bool local_path;
130 bool transparency;
131 bool activated;
132};
133
134/*
135 * Exynos DRM Display Structure.
136 * - this structure is common to analog tv, digital tv and lcd panel.
137 *
Inki Daea88cab22011-10-14 13:29:52 +0900138 * @type: one of EXYNOS_DISPLAY_TYPE_LCD and HDMI.
Inki Dae1c248b72011-10-04 19:19:01 +0900139 * @is_connected: check for that display is connected or not.
140 * @get_edid: get edid modes from display driver.
Eun-Chul Kim607c50d2012-02-14 15:59:46 +0900141 * @get_panel: get panel object from display driver.
Inki Dae1c248b72011-10-04 19:19:01 +0900142 * @check_timing: check if timing is valid or not.
143 * @power_on: display device on or off.
144 */
Inki Dae74ccc532011-10-19 17:23:07 +0900145struct exynos_drm_display_ops {
Inki Dae1c248b72011-10-04 19:19:01 +0900146 enum exynos_drm_output_type type;
147 bool (*is_connected)(struct device *dev);
148 int (*get_edid)(struct device *dev, struct drm_connector *connector,
149 u8 *edid, int len);
Eun-Chul Kim607c50d2012-02-14 15:59:46 +0900150 void *(*get_panel)(struct device *dev);
Inki Dae1c248b72011-10-04 19:19:01 +0900151 int (*check_timing)(struct device *dev, void *timing);
152 int (*power_on)(struct device *dev, int mode);
153};
154
155/*
156 * Exynos drm manager ops
157 *
Inki Daeec05da92011-12-06 11:06:54 +0900158 * @dpms: control device power.
159 * @apply: set timing, vblank and overlay data to registers.
Inki Dae1de425b2012-03-16 18:47:04 +0900160 * @mode_fixup: fix mode data comparing to hw specific display mode.
Inki Dae1c248b72011-10-04 19:19:01 +0900161 * @mode_set: convert drm_display_mode to hw specific display mode and
162 * would be called by encoder->mode_set().
Inki Dae1de425b2012-03-16 18:47:04 +0900163 * @get_max_resol: get maximum resolution to specific hardware.
Inki Dae1c248b72011-10-04 19:19:01 +0900164 * @commit: set current hw specific display mode to hw.
165 * @enable_vblank: specific driver callback for enabling vblank interrupt.
166 * @disable_vblank: specific driver callback for disabling vblank interrupt.
167 */
168struct exynos_drm_manager_ops {
Inki Daeec05da92011-12-06 11:06:54 +0900169 void (*dpms)(struct device *subdrv_dev, int mode);
170 void (*apply)(struct device *subdrv_dev);
Inki Dae1de425b2012-03-16 18:47:04 +0900171 void (*mode_fixup)(struct device *subdrv_dev,
172 struct drm_connector *connector,
173 struct drm_display_mode *mode,
174 struct drm_display_mode *adjusted_mode);
Inki Dae1c248b72011-10-04 19:19:01 +0900175 void (*mode_set)(struct device *subdrv_dev, void *mode);
Inki Dae1de425b2012-03-16 18:47:04 +0900176 void (*get_max_resol)(struct device *subdrv_dev, unsigned int *width,
177 unsigned int *height);
Inki Dae1c248b72011-10-04 19:19:01 +0900178 void (*commit)(struct device *subdrv_dev);
179 int (*enable_vblank)(struct device *subdrv_dev);
180 void (*disable_vblank)(struct device *subdrv_dev);
181};
182
183/*
184 * Exynos drm common manager structure.
185 *
186 * @dev: pointer to device object for subdrv device driver.
187 * sub drivers such as display controller or hdmi driver,
188 * have their own device object.
189 * @ops: pointer to callbacks for exynos drm specific framebuffer.
190 * these callbacks should be set by specific drivers such fimd
191 * or hdmi driver and are used to control hardware global registers.
192 * @overlay_ops: pointer to callbacks for exynos drm specific framebuffer.
193 * these callbacks should be set by specific drivers such fimd
194 * or hdmi driver and are used to control hardware overlay reigsters.
195 * @display: pointer to callbacks for exynos drm specific framebuffer.
196 * these callbacks should be set by specific drivers such fimd
197 * or hdmi driver and are used to control display devices such as
198 * analog tv, digital tv and lcd panel and also get timing data for them.
199 */
200struct exynos_drm_manager {
201 struct device *dev;
202 int pipe;
203 struct exynos_drm_manager_ops *ops;
204 struct exynos_drm_overlay_ops *overlay_ops;
Inki Dae74ccc532011-10-19 17:23:07 +0900205 struct exynos_drm_display_ops *display_ops;
Inki Dae1c248b72011-10-04 19:19:01 +0900206};
207
208/*
209 * Exynos drm private structure.
210 */
211struct exynos_drm_private {
212 struct drm_fb_helper *fb_helper;
213
Inki Daeccf4d882011-10-14 13:29:51 +0900214 /* list head for new event to be added. */
Inki Dae1c248b72011-10-04 19:19:01 +0900215 struct list_head pageflip_event_list;
Inki Dae1c248b72011-10-04 19:19:01 +0900216
217 /*
218 * created crtc object would be contained at this array and
219 * this array is used to be aware of which crtc did it request vblank.
220 */
221 struct drm_crtc *crtc[MAX_CRTC];
222};
223
224/*
225 * Exynos drm sub driver structure.
226 *
227 * @list: sub driver has its own list object to register to exynos drm driver.
Joonyoung Shim677e84c2012-04-05 20:49:27 +0900228 * @dev: pointer to device object for subdrv device driver.
Inki Dae1c248b72011-10-04 19:19:01 +0900229 * @drm_dev: pointer to drm_device and this pointer would be set
230 * when sub driver calls exynos_drm_subdrv_register().
Joonyoung Shim677e84c2012-04-05 20:49:27 +0900231 * @manager: subdrv has its own manager to control a hardware appropriately
232 * and we can access a hardware drawing on this manager.
Inki Dae1c248b72011-10-04 19:19:01 +0900233 * @probe: this callback would be called by exynos drm driver after
234 * subdrv is registered to it.
235 * @remove: this callback is used to release resources created
236 * by probe callback.
Joonyoung Shim9084f7b2012-03-16 18:47:09 +0900237 * @open: this would be called with drm device file open.
238 * @close: this would be called with drm device file close.
Inki Dae1c248b72011-10-04 19:19:01 +0900239 * @encoder: encoder object owned by this sub driver.
240 * @connector: connector object owned by this sub driver.
241 */
242struct exynos_drm_subdrv {
243 struct list_head list;
Joonyoung Shim677e84c2012-04-05 20:49:27 +0900244 struct device *dev;
Inki Dae1c248b72011-10-04 19:19:01 +0900245 struct drm_device *drm_dev;
Joonyoung Shim677e84c2012-04-05 20:49:27 +0900246 struct exynos_drm_manager *manager;
Inki Dae1c248b72011-10-04 19:19:01 +0900247
Inki Dae41c24342011-10-14 13:29:48 +0900248 int (*probe)(struct drm_device *drm_dev, struct device *dev);
Inki Dae1c248b72011-10-04 19:19:01 +0900249 void (*remove)(struct drm_device *dev);
Joonyoung Shim9084f7b2012-03-16 18:47:09 +0900250 int (*open)(struct drm_device *drm_dev, struct device *dev,
251 struct drm_file *file);
252 void (*close)(struct drm_device *drm_dev, struct device *dev,
253 struct drm_file *file);
Inki Dae1c248b72011-10-04 19:19:01 +0900254
Inki Dae1c248b72011-10-04 19:19:01 +0900255 struct drm_encoder *encoder;
256 struct drm_connector *connector;
257};
258
259/*
260 * this function calls a probe callback registered to sub driver list and
261 * create its own encoder and connector and then set drm_device object
262 * to global one.
263 */
264int exynos_drm_device_register(struct drm_device *dev);
265/*
266 * this function calls a remove callback registered to sub driver list and
267 * destroy its own encoder and connetor.
268 */
269int exynos_drm_device_unregister(struct drm_device *dev);
270
271/*
272 * this function would be called by sub drivers such as display controller
273 * or hdmi driver to register this sub driver object to exynos drm driver
274 * and when a sub driver is registered to exynos drm driver a probe callback
Joonyoung Shim132a5b92012-03-16 18:47:08 +0900275 * of the sub driver is called and creates its own encoder and connector.
Inki Dae1c248b72011-10-04 19:19:01 +0900276 */
277int exynos_drm_subdrv_register(struct exynos_drm_subdrv *drm_subdrv);
278
Joonyoung Shim132a5b92012-03-16 18:47:08 +0900279/* this function removes subdrv list from exynos drm driver */
Inki Dae1c248b72011-10-04 19:19:01 +0900280int exynos_drm_subdrv_unregister(struct exynos_drm_subdrv *drm_subdrv);
281
Joonyoung Shim9084f7b2012-03-16 18:47:09 +0900282int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file);
283void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file);
284
Joonyoung Shim132a5b92012-03-16 18:47:08 +0900285extern struct platform_driver fimd_driver;
286extern struct platform_driver hdmi_driver;
287extern struct platform_driver mixer_driver;
288extern struct platform_driver exynos_drm_common_hdmi_driver;
Inki Daeb73d1232012-03-21 10:55:26 +0900289extern struct platform_driver vidi_driver;
Inki Dae1c248b72011-10-04 19:19:01 +0900290#endif