Merge branch 'drm-intel-next' of git://people.freedesktop.org/~keithp/linux into...
[pandora-kernel.git] / drivers / gpu / drm / exynos / exynos_drm_drv.h
1 /* 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
32 #include "drm.h"
33
34 #define MAX_CRTC        2
35
36 struct drm_device;
37 struct exynos_drm_overlay;
38 struct drm_connector;
39
40 /* this enumerates display type. */
41 enum exynos_drm_output_type {
42         EXYNOS_DISPLAY_TYPE_NONE,
43         /* RGB or CPU Interface. */
44         EXYNOS_DISPLAY_TYPE_LCD,
45         /* HDMI Interface. */
46         EXYNOS_DISPLAY_TYPE_HDMI,
47 };
48
49 /*
50  * Exynos drm overlay ops structure.
51  *
52  * @mode_set: copy drm overlay info to hw specific overlay info.
53  * @commit: apply hardware specific overlay data to registers.
54  * @disable: disable hardware specific overlay.
55  */
56 struct exynos_drm_overlay_ops {
57         void (*mode_set)(struct device *subdrv_dev,
58                          struct exynos_drm_overlay *overlay);
59         void (*commit)(struct device *subdrv_dev);
60         void (*disable)(struct device *subdrv_dev);
61 };
62
63 /*
64  * Exynos drm common overlay structure.
65  *
66  * @offset_x: offset to x position.
67  * @offset_y: offset to y position.
68  * @width: window width.
69  * @height: window height.
70  * @bpp: pixel size.(in bit)
71  * @paddr: bus(accessed by dma) physical memory address to this overlay
72  *              and this is physically continuous.
73  * @vaddr: virtual memory addresss to this overlay.
74  * @buf_off: start offset of framebuffer to be displayed.
75  * @buf_offsize: this value has result from
76  *                      (framebuffer width - display width) * bpp.
77  * @line_size: line size to this overlay memory in bytes.
78  * @default_win: a window to be enabled.
79  * @color_key: color key on or off.
80  * @index_color: if using color key feature then this value would be used
81  *                      as index color.
82  * @local_path: in case of lcd type, local path mode on or off.
83  * @transparency: transparency on or off.
84  * @activated: activated or not.
85  *
86  * this structure is common to exynos SoC and its contents would be copied
87  * to hardware specific overlay info.
88  */
89 struct exynos_drm_overlay {
90         unsigned int offset_x;
91         unsigned int offset_y;
92         unsigned int width;
93         unsigned int height;
94         unsigned int bpp;
95         dma_addr_t paddr;
96         void __iomem *vaddr;
97         unsigned int buf_off;
98         unsigned int buf_offsize;
99         unsigned int line_size;
100
101         bool default_win;
102         bool color_key;
103         unsigned int index_color;
104         bool local_path;
105         bool transparency;
106         bool activated;
107 };
108
109 /*
110  * Exynos DRM Display Structure.
111  *      - this structure is common to analog tv, digital tv and lcd panel.
112  *
113  * @type: one of exynos_DISPLAY_TYPE_LCD and HDMI.
114  * @is_connected: check for that display is connected or not.
115  * @get_edid: get edid modes from display driver.
116  * @get_timing: get timing object from display driver.
117  * @check_timing: check if timing is valid or not.
118  * @power_on: display device on or off.
119  */
120 struct exynos_drm_display {
121         enum exynos_drm_output_type type;
122         bool (*is_connected)(struct device *dev);
123         int (*get_edid)(struct device *dev, struct drm_connector *connector,
124                                 u8 *edid, int len);
125         void *(*get_timing)(struct device *dev);
126         int (*check_timing)(struct device *dev, void *timing);
127         int (*power_on)(struct device *dev, int mode);
128 };
129
130 /*
131  * Exynos drm manager ops
132  *
133  * @mode_set: convert drm_display_mode to hw specific display mode and
134  *            would be called by encoder->mode_set().
135  * @commit: set current hw specific display mode to hw.
136  * @enable_vblank: specific driver callback for enabling vblank interrupt.
137  * @disable_vblank: specific driver callback for disabling vblank interrupt.
138  */
139 struct exynos_drm_manager_ops {
140         void (*mode_set)(struct device *subdrv_dev, void *mode);
141         void (*commit)(struct device *subdrv_dev);
142         int (*enable_vblank)(struct device *subdrv_dev);
143         void (*disable_vblank)(struct device *subdrv_dev);
144 };
145
146 /*
147  * Exynos drm common manager structure.
148  *
149  * @dev: pointer to device object for subdrv device driver.
150  *      sub drivers such as display controller or hdmi driver,
151  *      have their own device object.
152  * @ops: pointer to callbacks for exynos drm specific framebuffer.
153  *      these callbacks should be set by specific drivers such fimd
154  *      or hdmi driver and are used to control hardware global registers.
155  * @overlay_ops: pointer to callbacks for exynos drm specific framebuffer.
156  *      these callbacks should be set by specific drivers such fimd
157  *      or hdmi driver and are used to control hardware overlay reigsters.
158  * @display: pointer to callbacks for exynos drm specific framebuffer.
159  *      these callbacks should be set by specific drivers such fimd
160  *      or hdmi driver and are used to control display devices such as
161  *      analog tv, digital tv and lcd panel and also get timing data for them.
162  */
163 struct exynos_drm_manager {
164         struct device *dev;
165         int pipe;
166         struct exynos_drm_manager_ops *ops;
167         struct exynos_drm_overlay_ops *overlay_ops;
168         struct exynos_drm_display *display;
169 };
170
171 /*
172  * Exynos drm private structure.
173  */
174 struct exynos_drm_private {
175         struct drm_fb_helper *fb_helper;
176
177         /* for pageflip */
178         struct list_head pageflip_event_list;
179         bool pageflip_event;
180
181         /*
182          * created crtc object would be contained at this array and
183          * this array is used to be aware of which crtc did it request vblank.
184          */
185         struct drm_crtc *crtc[MAX_CRTC];
186 };
187
188 /*
189  * Exynos drm sub driver structure.
190  *
191  * @list: sub driver has its own list object to register to exynos drm driver.
192  * @drm_dev: pointer to drm_device and this pointer would be set
193  *      when sub driver calls exynos_drm_subdrv_register().
194  * @probe: this callback would be called by exynos drm driver after
195  *      subdrv is registered to it.
196  * @remove: this callback is used to release resources created
197  *      by probe callback.
198  * @manager: subdrv has its own manager to control a hardware appropriately
199  *      and we can access a hardware drawing on this manager.
200  * @encoder: encoder object owned by this sub driver.
201  * @connector: connector object owned by this sub driver.
202  */
203 struct exynos_drm_subdrv {
204         struct list_head list;
205         struct drm_device *drm_dev;
206
207         int (*probe)(struct drm_device *dev);
208         void (*remove)(struct drm_device *dev);
209
210         struct exynos_drm_manager manager;
211         struct drm_encoder *encoder;
212         struct drm_connector *connector;
213 };
214
215 /*
216  * this function calls a probe callback registered to sub driver list and
217  * create its own encoder and connector and then set drm_device object
218  * to global one.
219  */
220 int exynos_drm_device_register(struct drm_device *dev);
221 /*
222  * this function calls a remove callback registered to sub driver list and
223  * destroy its own encoder and connetor.
224  */
225 int exynos_drm_device_unregister(struct drm_device *dev);
226
227 /*
228  * this function would be called by sub drivers such as display controller
229  * or hdmi driver to register this sub driver object to exynos drm driver
230  * and when a sub driver is registered to exynos drm driver a probe callback
231  * of the sub driver is called and creates its own encoder and connector
232  * and then fb helper and drm mode group would be re-initialized.
233  */
234 int exynos_drm_subdrv_register(struct exynos_drm_subdrv *drm_subdrv);
235
236 /*
237  * this function removes subdrv list from exynos drm driver and fb helper
238  * and drm mode group would be re-initialized.
239  */
240 int exynos_drm_subdrv_unregister(struct exynos_drm_subdrv *drm_subdrv);
241
242 #endif