blob: 5067bf45476c814af4b630fae446ebc88329b1e6 [file] [log] [blame]
Inki Dae1c248b72011-10-04 19:19:01 +09001/* exynos_drm_crtc.c
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 *
Inki Daed81aecb2012-12-18 02:30:17 +09009 * 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.
Inki Dae1c248b72011-10-04 19:19:01 +090013 */
14
David Howells760285e2012-10-02 18:01:07 +010015#include <drm/drmP.h>
16#include <drm/drm_crtc_helper.h>
Inki Dae1c248b72011-10-04 19:19:01 +090017
Mark Browne30655d2013-08-13 00:46:40 +010018#include "exynos_drm_crtc.h"
Inki Dae1c248b72011-10-04 19:19:01 +090019#include "exynos_drm_drv.h"
Inki Dae1c248b72011-10-04 19:19:01 +090020#include "exynos_drm_encoder.h"
Joonyoung Shimb5d2eb32012-06-27 14:27:04 +090021#include "exynos_drm_plane.h"
Inki Dae1c248b72011-10-04 19:19:01 +090022
23#define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\
24 drm_crtc)
25
Joonyoung Shim3b8d1cf2012-06-27 14:27:11 +090026enum exynos_crtc_mode {
27 CRTC_MODE_NORMAL, /* normal mode */
28 CRTC_MODE_BLANK, /* The private plane of crtc is blank */
29};
30
Inki Dae1c248b72011-10-04 19:19:01 +090031/*
Inki Dae1c248b72011-10-04 19:19:01 +090032 * Exynos specific crtc structure.
33 *
34 * @drm_crtc: crtc object.
Joonyoung Shimb5d2eb32012-06-27 14:27:04 +090035 * @drm_plane: pointer of private plane object for this crtc
Sean Paul080be03d2014-02-19 21:02:55 +090036 * @manager: the manager associated with this crtc
Inki Dae1c248b72011-10-04 19:19:01 +090037 * @pipe: a crtc index created at load() with a new crtc object creation
38 * and the crtc object would be set to private->crtc array
39 * to get a crtc object corresponding to this pipe from private->crtc
Masanari Iidac6b78bc2013-10-24 16:02:57 +090040 * array when irq interrupt occurred. the reason of using this pipe is that
Inki Dae1c248b72011-10-04 19:19:01 +090041 * drm framework doesn't support multiple irq yet.
Masanari Iidac6b78bc2013-10-24 16:02:57 +090042 * we can refer to the crtc to current hardware interrupt occurred through
Inki Dae1c248b72011-10-04 19:19:01 +090043 * this pipe value.
Inki Daeec05da92011-12-06 11:06:54 +090044 * @dpms: store the crtc dpms value
Joonyoung Shim3b8d1cf2012-06-27 14:27:11 +090045 * @mode: store the crtc mode value
Inki Dae1c248b72011-10-04 19:19:01 +090046 */
47struct exynos_drm_crtc {
48 struct drm_crtc drm_crtc;
Joonyoung Shimb5d2eb32012-06-27 14:27:04 +090049 struct drm_plane *plane;
Sean Paul080be03d2014-02-19 21:02:55 +090050 struct exynos_drm_manager *manager;
Inki Dae1c248b72011-10-04 19:19:01 +090051 unsigned int pipe;
Inki Daeec05da92011-12-06 11:06:54 +090052 unsigned int dpms;
Joonyoung Shim3b8d1cf2012-06-27 14:27:11 +090053 enum exynos_crtc_mode mode;
Inki Dae20cd2642013-05-21 16:55:58 +090054 wait_queue_head_t pending_flip_queue;
55 atomic_t pending_flip;
Inki Dae1c248b72011-10-04 19:19:01 +090056};
57
Inki Dae1c248b72011-10-04 19:19:01 +090058static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
59{
Joonyoung Shimd2716c82011-11-04 17:04:45 +090060 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
Sean Paul080be03d2014-02-19 21:02:55 +090061 struct exynos_drm_manager *manager = exynos_crtc->manager;
Inki Dae1c248b72011-10-04 19:19:01 +090062
Joonyoung Shimd2716c82011-11-04 17:04:45 +090063 DRM_DEBUG_KMS("crtc[%d] mode[%d]\n", crtc->base.id, mode);
64
Inki Daeec05da92011-12-06 11:06:54 +090065 if (exynos_crtc->dpms == mode) {
66 DRM_DEBUG_KMS("desired dpms mode is same as previous one.\n");
67 return;
68 }
69
Inki Dae20cd2642013-05-21 16:55:58 +090070 if (mode > DRM_MODE_DPMS_ON) {
71 /* wait for the completion of page flip. */
72 wait_event(exynos_crtc->pending_flip_queue,
73 atomic_read(&exynos_crtc->pending_flip) == 0);
74 drm_vblank_off(crtc->dev, exynos_crtc->pipe);
75 }
76
Sean Paul080be03d2014-02-19 21:02:55 +090077 if (manager->ops->dpms)
78 manager->ops->dpms(manager, mode);
79
Joonyoung Shimcf5188a2012-06-27 14:27:09 +090080 exynos_crtc->dpms = mode;
Inki Dae1c248b72011-10-04 19:19:01 +090081}
82
83static void exynos_drm_crtc_prepare(struct drm_crtc *crtc)
84{
Inki Dae1c248b72011-10-04 19:19:01 +090085 /* drm framework doesn't check NULL. */
86}
87
88static void exynos_drm_crtc_commit(struct drm_crtc *crtc)
89{
Joonyoung Shimd2716c82011-11-04 17:04:45 +090090 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
Sean Paul080be03d2014-02-19 21:02:55 +090091 struct exynos_drm_manager *manager = exynos_crtc->manager;
Joonyoung Shimd2716c82011-11-04 17:04:45 +090092
Inki Dae50caf252012-08-20 21:29:25 +090093 exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
Sean Paul080be03d2014-02-19 21:02:55 +090094
Joonyoung Shim4070d212012-06-27 14:27:05 +090095 exynos_plane_commit(exynos_crtc->plane);
Sean Paul080be03d2014-02-19 21:02:55 +090096
97 if (manager->ops->commit)
98 manager->ops->commit(manager);
99
Joonyoung Shimcf5188a2012-06-27 14:27:09 +0900100 exynos_plane_dpms(exynos_crtc->plane, DRM_MODE_DPMS_ON);
Inki Dae1c248b72011-10-04 19:19:01 +0900101}
102
103static bool
104exynos_drm_crtc_mode_fixup(struct drm_crtc *crtc,
Laurent Pincharte811f5a2012-07-17 17:56:50 +0200105 const struct drm_display_mode *mode,
Inki Dae1c248b72011-10-04 19:19:01 +0900106 struct drm_display_mode *adjusted_mode)
107{
Inki Dae1c248b72011-10-04 19:19:01 +0900108 /* drm framework doesn't check NULL */
109 return true;
110}
111
112static int
113exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
114 struct drm_display_mode *adjusted_mode, int x, int y,
115 struct drm_framebuffer *old_fb)
116{
Joonyoung Shimaeb29222012-06-27 14:27:01 +0900117 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
Joonyoung Shim4070d212012-06-27 14:27:05 +0900118 struct drm_plane *plane = exynos_crtc->plane;
119 unsigned int crtc_w;
120 unsigned int crtc_h;
Joonyoung Shimaeb29222012-06-27 14:27:01 +0900121 int ret;
122
Inki Dae1de425b2012-03-16 18:47:04 +0900123 /*
124 * copy the mode data adjusted by mode_fixup() into crtc->mode
125 * so that hardware can be seet to proper mode.
126 */
127 memcpy(&crtc->mode, adjusted_mode, sizeof(*adjusted_mode));
Inki Dae1c248b72011-10-04 19:19:01 +0900128
Joonyoung Shim4070d212012-06-27 14:27:05 +0900129 crtc_w = crtc->fb->width - x;
130 crtc_h = crtc->fb->height - y;
131
132 ret = exynos_plane_mode_set(plane, crtc, crtc->fb, 0, 0, crtc_w, crtc_h,
133 x, y, crtc_w, crtc_h);
Joonyoung Shimaeb29222012-06-27 14:27:01 +0900134 if (ret)
135 return ret;
136
Joonyoung Shim4070d212012-06-27 14:27:05 +0900137 plane->crtc = crtc;
138 plane->fb = crtc->fb;
139
Joonyoung Shimaeb29222012-06-27 14:27:01 +0900140 return 0;
Inki Dae1c248b72011-10-04 19:19:01 +0900141}
142
Inki Dae7fd65df2013-05-12 16:09:33 +0900143static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y,
Inki Dae1c248b72011-10-04 19:19:01 +0900144 struct drm_framebuffer *old_fb)
145{
Joonyoung Shim4070d212012-06-27 14:27:05 +0900146 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
147 struct drm_plane *plane = exynos_crtc->plane;
148 unsigned int crtc_w;
149 unsigned int crtc_h;
Inki Dae1c248b72011-10-04 19:19:01 +0900150 int ret;
151
Inki Dae32aeab12012-09-14 13:29:47 +0900152 /* when framebuffer changing is requested, crtc's dpms should be on */
153 if (exynos_crtc->dpms > DRM_MODE_DPMS_ON) {
154 DRM_ERROR("failed framebuffer changing request.\n");
155 return -EPERM;
156 }
157
Joonyoung Shim4070d212012-06-27 14:27:05 +0900158 crtc_w = crtc->fb->width - x;
159 crtc_h = crtc->fb->height - y;
160
161 ret = exynos_plane_mode_set(plane, crtc, crtc->fb, 0, 0, crtc_w, crtc_h,
162 x, y, crtc_w, crtc_h);
Inki Dae1c248b72011-10-04 19:19:01 +0900163 if (ret)
164 return ret;
165
Joonyoung Shimbebab8f2012-06-27 14:27:07 +0900166 exynos_drm_crtc_commit(crtc);
Inki Dae1c248b72011-10-04 19:19:01 +0900167
Joonyoung Shim4070d212012-06-27 14:27:05 +0900168 return 0;
Inki Dae1c248b72011-10-04 19:19:01 +0900169}
170
Inki Dae7fd65df2013-05-12 16:09:33 +0900171static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
172 struct drm_framebuffer *old_fb)
173{
174 return exynos_drm_crtc_mode_set_commit(crtc, x, y, old_fb);
175}
176
Joonyoung Shima365d9e2012-06-27 14:27:10 +0900177static void exynos_drm_crtc_disable(struct drm_crtc *crtc)
178{
179 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
180
Joonyoung Shima365d9e2012-06-27 14:27:10 +0900181 exynos_plane_dpms(exynos_crtc->plane, DRM_MODE_DPMS_OFF);
182 exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
183}
184
Inki Dae1c248b72011-10-04 19:19:01 +0900185static struct drm_crtc_helper_funcs exynos_crtc_helper_funcs = {
186 .dpms = exynos_drm_crtc_dpms,
187 .prepare = exynos_drm_crtc_prepare,
188 .commit = exynos_drm_crtc_commit,
189 .mode_fixup = exynos_drm_crtc_mode_fixup,
190 .mode_set = exynos_drm_crtc_mode_set,
191 .mode_set_base = exynos_drm_crtc_mode_set_base,
Joonyoung Shima365d9e2012-06-27 14:27:10 +0900192 .disable = exynos_drm_crtc_disable,
Inki Dae1c248b72011-10-04 19:19:01 +0900193};
194
195static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc,
Keith Packarded8d1972013-07-22 18:49:58 -0700196 struct drm_framebuffer *fb,
197 struct drm_pending_vblank_event *event,
198 uint32_t page_flip_flags)
Inki Dae1c248b72011-10-04 19:19:01 +0900199{
200 struct drm_device *dev = crtc->dev;
201 struct exynos_drm_private *dev_priv = dev->dev_private;
202 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
203 struct drm_framebuffer *old_fb = crtc->fb;
204 int ret = -EINVAL;
205
Inki Daeef6223d2012-09-11 18:25:21 +0900206 /* when the page flip is requested, crtc's dpms should be on */
207 if (exynos_crtc->dpms > DRM_MODE_DPMS_ON) {
208 DRM_ERROR("failed page flip request.\n");
209 return -EINVAL;
210 }
211
Inki Dae1c248b72011-10-04 19:19:01 +0900212 mutex_lock(&dev->struct_mutex);
213
Inki Daeccf4d882011-10-14 13:29:51 +0900214 if (event) {
215 /*
216 * the pipe from user always is 0 so we can set pipe number
217 * of current owner to event.
218 */
219 event->pipe = exynos_crtc->pipe;
220
Inki Dae1c248b72011-10-04 19:19:01 +0900221 ret = drm_vblank_get(dev, exynos_crtc->pipe);
222 if (ret) {
223 DRM_DEBUG("failed to acquire vblank counter\n");
Inki Daeccf4d882011-10-14 13:29:51 +0900224
Inki Dae1c248b72011-10-04 19:19:01 +0900225 goto out;
226 }
227
Imre Deak85473322012-11-02 13:30:47 +0200228 spin_lock_irq(&dev->event_lock);
Inki Daec5614ae2012-02-15 11:25:20 +0900229 list_add_tail(&event->base.link,
230 &dev_priv->pageflip_event_list);
Inki Dae20cd2642013-05-21 16:55:58 +0900231 atomic_set(&exynos_crtc->pending_flip, 1);
Imre Deak85473322012-11-02 13:30:47 +0200232 spin_unlock_irq(&dev->event_lock);
Inki Daec5614ae2012-02-15 11:25:20 +0900233
Inki Dae1c248b72011-10-04 19:19:01 +0900234 crtc->fb = fb;
Inki Dae7fd65df2013-05-12 16:09:33 +0900235 ret = exynos_drm_crtc_mode_set_commit(crtc, crtc->x, crtc->y,
Joonyoung Shim4070d212012-06-27 14:27:05 +0900236 NULL);
Inki Dae1c248b72011-10-04 19:19:01 +0900237 if (ret) {
238 crtc->fb = old_fb;
Imre Deak85473322012-11-02 13:30:47 +0200239
240 spin_lock_irq(&dev->event_lock);
Inki Dae1c248b72011-10-04 19:19:01 +0900241 drm_vblank_put(dev, exynos_crtc->pipe);
Inki Daeccf4d882011-10-14 13:29:51 +0900242 list_del(&event->base.link);
Imre Deak85473322012-11-02 13:30:47 +0200243 spin_unlock_irq(&dev->event_lock);
Inki Dae1c248b72011-10-04 19:19:01 +0900244
245 goto out;
246 }
Inki Dae1c248b72011-10-04 19:19:01 +0900247 }
248out:
249 mutex_unlock(&dev->struct_mutex);
250 return ret;
251}
252
253static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
254{
255 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
256 struct exynos_drm_private *private = crtc->dev->dev_private;
257
Inki Dae1c248b72011-10-04 19:19:01 +0900258 private->crtc[exynos_crtc->pipe] = NULL;
259
260 drm_crtc_cleanup(crtc);
261 kfree(exynos_crtc);
262}
263
Joonyoung Shim3b8d1cf2012-06-27 14:27:11 +0900264static int exynos_drm_crtc_set_property(struct drm_crtc *crtc,
265 struct drm_property *property,
266 uint64_t val)
267{
268 struct drm_device *dev = crtc->dev;
269 struct exynos_drm_private *dev_priv = dev->dev_private;
270 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
271
Joonyoung Shim3b8d1cf2012-06-27 14:27:11 +0900272 if (property == dev_priv->crtc_mode_property) {
273 enum exynos_crtc_mode mode = val;
274
275 if (mode == exynos_crtc->mode)
276 return 0;
277
278 exynos_crtc->mode = mode;
279
280 switch (mode) {
281 case CRTC_MODE_NORMAL:
282 exynos_drm_crtc_commit(crtc);
283 break;
284 case CRTC_MODE_BLANK:
285 exynos_plane_dpms(exynos_crtc->plane,
286 DRM_MODE_DPMS_OFF);
287 break;
288 default:
289 break;
290 }
291
292 return 0;
293 }
294
295 return -EINVAL;
296}
297
Inki Dae1c248b72011-10-04 19:19:01 +0900298static struct drm_crtc_funcs exynos_crtc_funcs = {
299 .set_config = drm_crtc_helper_set_config,
300 .page_flip = exynos_drm_crtc_page_flip,
301 .destroy = exynos_drm_crtc_destroy,
Joonyoung Shim3b8d1cf2012-06-27 14:27:11 +0900302 .set_property = exynos_drm_crtc_set_property,
Inki Dae1c248b72011-10-04 19:19:01 +0900303};
304
Joonyoung Shim3b8d1cf2012-06-27 14:27:11 +0900305static const struct drm_prop_enum_list mode_names[] = {
306 { CRTC_MODE_NORMAL, "normal" },
307 { CRTC_MODE_BLANK, "blank" },
308};
309
310static void exynos_drm_crtc_attach_mode_property(struct drm_crtc *crtc)
311{
312 struct drm_device *dev = crtc->dev;
313 struct exynos_drm_private *dev_priv = dev->dev_private;
314 struct drm_property *prop;
315
Joonyoung Shim3b8d1cf2012-06-27 14:27:11 +0900316 prop = dev_priv->crtc_mode_property;
317 if (!prop) {
318 prop = drm_property_create_enum(dev, 0, "mode", mode_names,
319 ARRAY_SIZE(mode_names));
320 if (!prop)
321 return;
322
323 dev_priv->crtc_mode_property = prop;
324 }
325
326 drm_object_attach_property(&crtc->base, prop, 0);
327}
328
Sean Paul080be03d2014-02-19 21:02:55 +0900329int exynos_drm_crtc_create(struct exynos_drm_manager *manager)
Inki Dae1c248b72011-10-04 19:19:01 +0900330{
331 struct exynos_drm_crtc *exynos_crtc;
Sean Paul080be03d2014-02-19 21:02:55 +0900332 struct exynos_drm_private *private = manager->drm_dev->dev_private;
Inki Dae1c248b72011-10-04 19:19:01 +0900333 struct drm_crtc *crtc;
334
Inki Dae1c248b72011-10-04 19:19:01 +0900335 exynos_crtc = kzalloc(sizeof(*exynos_crtc), GFP_KERNEL);
Sachin Kamat38bb5252013-08-19 19:04:55 +0900336 if (!exynos_crtc)
Inki Dae1c248b72011-10-04 19:19:01 +0900337 return -ENOMEM;
Inki Dae1c248b72011-10-04 19:19:01 +0900338
Inki Dae20cd2642013-05-21 16:55:58 +0900339 init_waitqueue_head(&exynos_crtc->pending_flip_queue);
340 atomic_set(&exynos_crtc->pending_flip, 0);
Sean Paul080be03d2014-02-19 21:02:55 +0900341
342 exynos_crtc->dpms = DRM_MODE_DPMS_OFF;
343 exynos_crtc->manager = manager;
344 exynos_crtc->pipe = manager->pipe;
345 exynos_crtc->plane = exynos_plane_init(manager->drm_dev,
346 1 << manager->pipe, true);
Joonyoung Shimb5d2eb32012-06-27 14:27:04 +0900347 if (!exynos_crtc->plane) {
348 kfree(exynos_crtc);
349 return -ENOMEM;
350 }
351
Inki Dae1c248b72011-10-04 19:19:01 +0900352 crtc = &exynos_crtc->drm_crtc;
353
Sean Paul080be03d2014-02-19 21:02:55 +0900354 private->crtc[manager->pipe] = crtc;
Inki Dae1c248b72011-10-04 19:19:01 +0900355
Sean Paul080be03d2014-02-19 21:02:55 +0900356 drm_crtc_init(manager->drm_dev, crtc, &exynos_crtc_funcs);
Inki Dae1c248b72011-10-04 19:19:01 +0900357 drm_crtc_helper_add(crtc, &exynos_crtc_helper_funcs);
358
Joonyoung Shim3b8d1cf2012-06-27 14:27:11 +0900359 exynos_drm_crtc_attach_mode_property(crtc);
360
Inki Dae1c248b72011-10-04 19:19:01 +0900361 return 0;
362}
363
Sean Paul080be03d2014-02-19 21:02:55 +0900364int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)
Inki Dae1c248b72011-10-04 19:19:01 +0900365{
366 struct exynos_drm_private *private = dev->dev_private;
Inki Daeec05da92011-12-06 11:06:54 +0900367 struct exynos_drm_crtc *exynos_crtc =
Sean Paul080be03d2014-02-19 21:02:55 +0900368 to_exynos_crtc(private->crtc[pipe]);
369 struct exynos_drm_manager *manager = exynos_crtc->manager;
Inki Dae1c248b72011-10-04 19:19:01 +0900370
Inki Daeec05da92011-12-06 11:06:54 +0900371 if (exynos_crtc->dpms != DRM_MODE_DPMS_ON)
372 return -EPERM;
373
Sean Paul080be03d2014-02-19 21:02:55 +0900374 if (manager->ops->enable_vblank)
375 manager->ops->enable_vblank(manager);
Inki Dae1c248b72011-10-04 19:19:01 +0900376
377 return 0;
378}
379
Sean Paul080be03d2014-02-19 21:02:55 +0900380void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe)
Inki Dae1c248b72011-10-04 19:19:01 +0900381{
382 struct exynos_drm_private *private = dev->dev_private;
Inki Daeec05da92011-12-06 11:06:54 +0900383 struct exynos_drm_crtc *exynos_crtc =
Sean Paul080be03d2014-02-19 21:02:55 +0900384 to_exynos_crtc(private->crtc[pipe]);
385 struct exynos_drm_manager *manager = exynos_crtc->manager;
Inki Dae1c248b72011-10-04 19:19:01 +0900386
Inki Daeec05da92011-12-06 11:06:54 +0900387 if (exynos_crtc->dpms != DRM_MODE_DPMS_ON)
388 return;
389
Sean Paul080be03d2014-02-19 21:02:55 +0900390 if (manager->ops->disable_vblank)
391 manager->ops->disable_vblank(manager);
Inki Dae1c248b72011-10-04 19:19:01 +0900392}
Rahul Sharma663d8762013-01-03 05:44:04 -0500393
Sean Paul080be03d2014-02-19 21:02:55 +0900394void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe)
Rahul Sharma663d8762013-01-03 05:44:04 -0500395{
396 struct exynos_drm_private *dev_priv = dev->dev_private;
397 struct drm_pending_vblank_event *e, *t;
Sean Paul080be03d2014-02-19 21:02:55 +0900398 struct drm_crtc *drm_crtc = dev_priv->crtc[pipe];
Inki Dae20cd2642013-05-21 16:55:58 +0900399 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(drm_crtc);
Rahul Sharma663d8762013-01-03 05:44:04 -0500400 unsigned long flags;
401
Rahul Sharma663d8762013-01-03 05:44:04 -0500402 spin_lock_irqsave(&dev->event_lock, flags);
403
404 list_for_each_entry_safe(e, t, &dev_priv->pageflip_event_list,
405 base.link) {
406 /* if event's pipe isn't same as crtc then ignore it. */
Sean Paul080be03d2014-02-19 21:02:55 +0900407 if (pipe != e->pipe)
Rahul Sharma663d8762013-01-03 05:44:04 -0500408 continue;
409
Rob Clarkc5cca972013-05-22 11:48:40 +0900410 list_del(&e->base.link);
411 drm_send_vblank_event(dev, -1, e);
Sean Paul080be03d2014-02-19 21:02:55 +0900412 drm_vblank_put(dev, pipe);
Inki Dae20cd2642013-05-21 16:55:58 +0900413 atomic_set(&exynos_crtc->pending_flip, 0);
414 wake_up(&exynos_crtc->pending_flip_queue);
Rahul Sharma663d8762013-01-03 05:44:04 -0500415 }
416
417 spin_unlock_irqrestore(&dev->event_lock, flags);
418}
Sean Paul080be03d2014-02-19 21:02:55 +0900419
420void exynos_drm_crtc_plane_mode_set(struct drm_crtc *crtc,
421 struct exynos_drm_overlay *overlay)
422{
423 struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager;
424
425 if (manager->ops->win_mode_set)
426 manager->ops->win_mode_set(manager, overlay);
427}
428
429void exynos_drm_crtc_plane_commit(struct drm_crtc *crtc, int zpos)
430{
431 struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager;
432
433 if (manager->ops->win_commit)
434 manager->ops->win_commit(manager, zpos);
435}
436
437void exynos_drm_crtc_plane_enable(struct drm_crtc *crtc, int zpos)
438{
439 struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager;
440
441 if (manager->ops->win_enable)
442 manager->ops->win_enable(manager, zpos);
443}
444
445void exynos_drm_crtc_plane_disable(struct drm_crtc *crtc, int zpos)
446{
447 struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager;
448
449 if (manager->ops->win_disable)
450 manager->ops->win_disable(manager, zpos);
451}
452
453void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb)
454{
455 struct exynos_drm_manager *manager;
456 struct drm_device *dev = fb->dev;
457 struct drm_crtc *crtc;
458
459 /*
460 * make sure that overlay data are updated to real hardware
461 * for all encoders.
462 */
463 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
464 manager = to_exynos_crtc(crtc)->manager;
465
466 /*
467 * wait for vblank interrupt
468 * - this makes sure that overlay data are updated to
469 * real hardware.
470 */
471 if (manager->ops->wait_for_vblank)
472 manager->ops->wait_for_vblank(manager);
473 }
474}