blob: 47dd2b0f4aa5fd2fae94834212905b08ece2185b [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
Inki Dae1c248b72011-10-04 19:19:01 +090023static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
24{
Joonyoung Shimd2716c82011-11-04 17:04:45 +090025 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
Inki Dae1c248b72011-10-04 19:19:01 +090026
Joonyoung Shimd2716c82011-11-04 17:04:45 +090027 DRM_DEBUG_KMS("crtc[%d] mode[%d]\n", crtc->base.id, mode);
28
Inki Daeec05da92011-12-06 11:06:54 +090029 if (exynos_crtc->dpms == mode) {
30 DRM_DEBUG_KMS("desired dpms mode is same as previous one.\n");
31 return;
32 }
33
Inki Dae20cd2642013-05-21 16:55:58 +090034 if (mode > DRM_MODE_DPMS_ON) {
35 /* wait for the completion of page flip. */
YoungJun Choe35d7222014-07-17 18:01:17 +090036 if (!wait_event_timeout(exynos_crtc->pending_flip_queue,
37 !atomic_read(&exynos_crtc->pending_flip),
38 HZ/20))
39 atomic_set(&exynos_crtc->pending_flip, 0);
Andrzej Hajdad6948b22014-10-10 14:31:55 +020040 drm_crtc_vblank_off(crtc);
Inki Dae20cd2642013-05-21 16:55:58 +090041 }
42
Gustavo Padovan93bca242015-01-18 18:16:23 +090043 if (exynos_crtc->ops->dpms)
44 exynos_crtc->ops->dpms(exynos_crtc, mode);
Sean Paul080be03d2014-02-19 21:02:55 +090045
Joonyoung Shimcf5188a2012-06-27 14:27:09 +090046 exynos_crtc->dpms = mode;
Andrzej Hajdad6948b22014-10-10 14:31:55 +020047
48 if (mode == DRM_MODE_DPMS_ON)
49 drm_crtc_vblank_on(crtc);
Inki Dae1c248b72011-10-04 19:19:01 +090050}
51
52static void exynos_drm_crtc_prepare(struct drm_crtc *crtc)
53{
Inki Dae1c248b72011-10-04 19:19:01 +090054 /* drm framework doesn't check NULL. */
55}
56
57static void exynos_drm_crtc_commit(struct drm_crtc *crtc)
58{
Joonyoung Shimd2716c82011-11-04 17:04:45 +090059 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
Gustavo Padovan9d5310c2014-11-13 22:17:46 -020060 struct exynos_drm_plane *exynos_plane = to_exynos_plane(crtc->primary);
Joonyoung Shimd2716c82011-11-04 17:04:45 +090061
Inki Dae50caf252012-08-20 21:29:25 +090062 exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
Sean Paul080be03d2014-02-19 21:02:55 +090063
Gustavo Padovan93bca242015-01-18 18:16:23 +090064 if (exynos_crtc->ops->win_commit)
65 exynos_crtc->ops->win_commit(exynos_crtc, exynos_plane->zpos);
Sean Paul080be03d2014-02-19 21:02:55 +090066
Gustavo Padovan93bca242015-01-18 18:16:23 +090067 if (exynos_crtc->ops->commit)
68 exynos_crtc->ops->commit(exynos_crtc);
Inki Dae1c248b72011-10-04 19:19:01 +090069}
70
71static bool
72exynos_drm_crtc_mode_fixup(struct drm_crtc *crtc,
Laurent Pincharte811f5a2012-07-17 17:56:50 +020073 const struct drm_display_mode *mode,
Inki Dae1c248b72011-10-04 19:19:01 +090074 struct drm_display_mode *adjusted_mode)
75{
Sean Paul4b405262014-01-30 16:19:19 -050076 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
Sean Paul4b405262014-01-30 16:19:19 -050077
Gustavo Padovan93bca242015-01-18 18:16:23 +090078 if (exynos_crtc->ops->mode_fixup)
79 return exynos_crtc->ops->mode_fixup(exynos_crtc, mode,
80 adjusted_mode);
Sean Paul4b405262014-01-30 16:19:19 -050081
Inki Dae1c248b72011-10-04 19:19:01 +090082 return true;
83}
84
85static int
86exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
87 struct drm_display_mode *adjusted_mode, int x, int y,
88 struct drm_framebuffer *old_fb)
89{
Andrzej Hajda72ed6cc2014-09-19 14:58:53 +020090 struct drm_framebuffer *fb = crtc->primary->fb;
Joonyoung Shim4070d212012-06-27 14:27:05 +090091 unsigned int crtc_w;
92 unsigned int crtc_h;
Gustavo Padovanadf56912014-11-27 14:56:09 -020093 int ret;
Joonyoung Shimaeb29222012-06-27 14:27:01 +090094
Inki Dae1de425b2012-03-16 18:47:04 +090095 /*
96 * copy the mode data adjusted by mode_fixup() into crtc->mode
97 * so that hardware can be seet to proper mode.
98 */
99 memcpy(&crtc->mode, adjusted_mode, sizeof(*adjusted_mode));
Inki Dae1c248b72011-10-04 19:19:01 +0900100
Gustavo Padovanadf56912014-11-27 14:56:09 -0200101 ret = exynos_check_plane(crtc->primary, fb);
102 if (ret < 0)
103 return ret;
104
Andrzej Hajda72ed6cc2014-09-19 14:58:53 +0200105 crtc_w = fb->width - x;
106 crtc_h = fb->height - y;
Gustavo Padovanadf56912014-11-27 14:56:09 -0200107 exynos_plane_mode_set(crtc->primary, crtc, fb, 0, 0,
108 crtc_w, crtc_h, x, y, crtc_w, crtc_h);
109
110 return 0;
Inki Dae1c248b72011-10-04 19:19:01 +0900111}
112
Gustavo Padovanfd092d72014-11-13 22:30:00 -0200113static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
Inki Dae1c248b72011-10-04 19:19:01 +0900114 struct drm_framebuffer *old_fb)
115{
Joonyoung Shim4070d212012-06-27 14:27:05 +0900116 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
Andrzej Hajda72ed6cc2014-09-19 14:58:53 +0200117 struct drm_framebuffer *fb = crtc->primary->fb;
Joonyoung Shim4070d212012-06-27 14:27:05 +0900118 unsigned int crtc_w;
119 unsigned int crtc_h;
Inki Dae1c248b72011-10-04 19:19:01 +0900120
Inki Dae32aeab12012-09-14 13:29:47 +0900121 /* when framebuffer changing is requested, crtc's dpms should be on */
122 if (exynos_crtc->dpms > DRM_MODE_DPMS_ON) {
123 DRM_ERROR("failed framebuffer changing request.\n");
124 return -EPERM;
125 }
126
Andrzej Hajda72ed6cc2014-09-19 14:58:53 +0200127 crtc_w = fb->width - x;
128 crtc_h = fb->height - y;
Joonyoung Shim4070d212012-06-27 14:27:05 +0900129
Gustavo Padovan0e0a6492014-11-25 11:21:17 -0200130 return exynos_update_plane(crtc->primary, crtc, fb, 0, 0,
131 crtc_w, crtc_h, x, y, crtc_w, crtc_h);
Inki Dae1c248b72011-10-04 19:19:01 +0900132}
133
Joonyoung Shima365d9e2012-06-27 14:27:10 +0900134static void exynos_drm_crtc_disable(struct drm_crtc *crtc)
135{
Sean Paula9c4cd22014-01-30 16:19:17 -0500136 struct drm_plane *plane;
137 int ret;
Joonyoung Shima365d9e2012-06-27 14:27:10 +0900138
Joonyoung Shima365d9e2012-06-27 14:27:10 +0900139 exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
Sean Paula9c4cd22014-01-30 16:19:17 -0500140
Matt Roper08863272014-04-01 15:22:31 -0700141 drm_for_each_legacy_plane(plane, &crtc->dev->mode_config.plane_list) {
Sean Paula9c4cd22014-01-30 16:19:17 -0500142 if (plane->crtc != crtc)
143 continue;
144
145 ret = plane->funcs->disable_plane(plane);
146 if (ret)
147 DRM_ERROR("Failed to disable plane %d\n", ret);
148 }
Joonyoung Shima365d9e2012-06-27 14:27:10 +0900149}
150
Inki Dae1c248b72011-10-04 19:19:01 +0900151static struct drm_crtc_helper_funcs exynos_crtc_helper_funcs = {
152 .dpms = exynos_drm_crtc_dpms,
153 .prepare = exynos_drm_crtc_prepare,
154 .commit = exynos_drm_crtc_commit,
155 .mode_fixup = exynos_drm_crtc_mode_fixup,
156 .mode_set = exynos_drm_crtc_mode_set,
157 .mode_set_base = exynos_drm_crtc_mode_set_base,
Joonyoung Shima365d9e2012-06-27 14:27:10 +0900158 .disable = exynos_drm_crtc_disable,
Inki Dae1c248b72011-10-04 19:19:01 +0900159};
160
161static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc,
Keith Packarded8d1972013-07-22 18:49:58 -0700162 struct drm_framebuffer *fb,
163 struct drm_pending_vblank_event *event,
164 uint32_t page_flip_flags)
Inki Dae1c248b72011-10-04 19:19:01 +0900165{
166 struct drm_device *dev = crtc->dev;
167 struct exynos_drm_private *dev_priv = dev->dev_private;
168 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
Matt Roperf4510a22014-04-01 15:22:40 -0700169 struct drm_framebuffer *old_fb = crtc->primary->fb;
Gustavo Padovan8b9c4502014-11-25 16:18:34 -0200170 unsigned int crtc_w, crtc_h;
Inki Dae1c248b72011-10-04 19:19:01 +0900171 int ret = -EINVAL;
172
Inki Daeef6223d2012-09-11 18:25:21 +0900173 /* when the page flip is requested, crtc's dpms should be on */
174 if (exynos_crtc->dpms > DRM_MODE_DPMS_ON) {
175 DRM_ERROR("failed page flip request.\n");
176 return -EINVAL;
177 }
178
Inki Dae1c248b72011-10-04 19:19:01 +0900179 mutex_lock(&dev->struct_mutex);
180
Inki Daeccf4d882011-10-14 13:29:51 +0900181 if (event) {
182 /*
183 * the pipe from user always is 0 so we can set pipe number
184 * of current owner to event.
185 */
186 event->pipe = exynos_crtc->pipe;
187
Inki Dae1c248b72011-10-04 19:19:01 +0900188 ret = drm_vblank_get(dev, exynos_crtc->pipe);
189 if (ret) {
190 DRM_DEBUG("failed to acquire vblank counter\n");
Inki Daeccf4d882011-10-14 13:29:51 +0900191
Inki Dae1c248b72011-10-04 19:19:01 +0900192 goto out;
193 }
194
Imre Deak85473322012-11-02 13:30:47 +0200195 spin_lock_irq(&dev->event_lock);
Inki Daec5614ae2012-02-15 11:25:20 +0900196 list_add_tail(&event->base.link,
197 &dev_priv->pageflip_event_list);
Inki Dae20cd2642013-05-21 16:55:58 +0900198 atomic_set(&exynos_crtc->pending_flip, 1);
Imre Deak85473322012-11-02 13:30:47 +0200199 spin_unlock_irq(&dev->event_lock);
Inki Daec5614ae2012-02-15 11:25:20 +0900200
Matt Roperf4510a22014-04-01 15:22:40 -0700201 crtc->primary->fb = fb;
Gustavo Padovan8b9c4502014-11-25 16:18:34 -0200202 crtc_w = fb->width - crtc->x;
203 crtc_h = fb->height - crtc->y;
204 ret = exynos_update_plane(crtc->primary, crtc, fb, 0, 0,
205 crtc_w, crtc_h, crtc->x, crtc->y,
206 crtc_w, crtc_h);
Inki Dae1c248b72011-10-04 19:19:01 +0900207 if (ret) {
Matt Roperf4510a22014-04-01 15:22:40 -0700208 crtc->primary->fb = old_fb;
Imre Deak85473322012-11-02 13:30:47 +0200209
210 spin_lock_irq(&dev->event_lock);
Inki Dae1c248b72011-10-04 19:19:01 +0900211 drm_vblank_put(dev, exynos_crtc->pipe);
Inki Daeccf4d882011-10-14 13:29:51 +0900212 list_del(&event->base.link);
YoungJun Choe35d7222014-07-17 18:01:17 +0900213 atomic_set(&exynos_crtc->pending_flip, 0);
Imre Deak85473322012-11-02 13:30:47 +0200214 spin_unlock_irq(&dev->event_lock);
Inki Dae1c248b72011-10-04 19:19:01 +0900215
216 goto out;
217 }
Inki Dae1c248b72011-10-04 19:19:01 +0900218 }
219out:
220 mutex_unlock(&dev->struct_mutex);
221 return ret;
222}
223
224static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
225{
226 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
227 struct exynos_drm_private *private = crtc->dev->dev_private;
228
Inki Dae1c248b72011-10-04 19:19:01 +0900229 private->crtc[exynos_crtc->pipe] = NULL;
230
231 drm_crtc_cleanup(crtc);
232 kfree(exynos_crtc);
233}
234
235static struct drm_crtc_funcs exynos_crtc_funcs = {
236 .set_config = drm_crtc_helper_set_config,
237 .page_flip = exynos_drm_crtc_page_flip,
238 .destroy = exynos_drm_crtc_destroy,
239};
240
Gustavo Padovan93bca242015-01-18 18:16:23 +0900241struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
Gustavo Padovan7ee14cd2015-04-03 21:03:40 +0900242 struct drm_plane *plane,
Gustavo Padovan93bca242015-01-18 18:16:23 +0900243 int pipe,
244 enum exynos_drm_output_type type,
245 struct exynos_drm_crtc_ops *ops,
246 void *ctx)
Inki Dae1c248b72011-10-04 19:19:01 +0900247{
248 struct exynos_drm_crtc *exynos_crtc;
Gustavo Padovaneb88e422014-11-26 16:43:27 -0200249 struct exynos_drm_private *private = drm_dev->dev_private;
Inki Dae1c248b72011-10-04 19:19:01 +0900250 struct drm_crtc *crtc;
Andrzej Hajda72ed6cc2014-09-19 14:58:53 +0200251 int ret;
Inki Dae1c248b72011-10-04 19:19:01 +0900252
Inki Dae1c248b72011-10-04 19:19:01 +0900253 exynos_crtc = kzalloc(sizeof(*exynos_crtc), GFP_KERNEL);
Sachin Kamat38bb5252013-08-19 19:04:55 +0900254 if (!exynos_crtc)
Gustavo Padovan93bca242015-01-18 18:16:23 +0900255 return ERR_PTR(-ENOMEM);
Inki Dae1c248b72011-10-04 19:19:01 +0900256
Inki Dae20cd2642013-05-21 16:55:58 +0900257 init_waitqueue_head(&exynos_crtc->pending_flip_queue);
258 atomic_set(&exynos_crtc->pending_flip, 0);
Sean Paul080be03d2014-02-19 21:02:55 +0900259
260 exynos_crtc->dpms = DRM_MODE_DPMS_OFF;
Gustavo Padovane09f2b02014-11-04 18:25:27 -0200261 exynos_crtc->pipe = pipe;
Gustavo Padovan5d1741a2014-11-05 19:51:35 -0200262 exynos_crtc->type = type;
Gustavo Padovan93bca242015-01-18 18:16:23 +0900263 exynos_crtc->ops = ops;
264 exynos_crtc->ctx = ctx;
Joonyoung Shimb5d2eb32012-06-27 14:27:04 +0900265
Gustavo Padovan357193c2014-11-03 18:20:29 -0200266 crtc = &exynos_crtc->base;
Inki Dae1c248b72011-10-04 19:19:01 +0900267
Gustavo Padovane09f2b02014-11-04 18:25:27 -0200268 private->crtc[pipe] = crtc;
Inki Dae1c248b72011-10-04 19:19:01 +0900269
Gustavo Padovaneb88e422014-11-26 16:43:27 -0200270 ret = drm_crtc_init_with_planes(drm_dev, crtc, plane, NULL,
Andrzej Hajda72ed6cc2014-09-19 14:58:53 +0200271 &exynos_crtc_funcs);
272 if (ret < 0)
273 goto err_crtc;
274
Inki Dae1c248b72011-10-04 19:19:01 +0900275 drm_crtc_helper_add(crtc, &exynos_crtc_helper_funcs);
276
Gustavo Padovan93bca242015-01-18 18:16:23 +0900277 return exynos_crtc;
Andrzej Hajda72ed6cc2014-09-19 14:58:53 +0200278
279err_crtc:
280 plane->funcs->destroy(plane);
Andrzej Hajda72ed6cc2014-09-19 14:58:53 +0200281 kfree(exynos_crtc);
Gustavo Padovan93bca242015-01-18 18:16:23 +0900282 return ERR_PTR(ret);
Inki Dae1c248b72011-10-04 19:19:01 +0900283}
284
Sean Paul080be03d2014-02-19 21:02:55 +0900285int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)
Inki Dae1c248b72011-10-04 19:19:01 +0900286{
287 struct exynos_drm_private *private = dev->dev_private;
Inki Daeec05da92011-12-06 11:06:54 +0900288 struct exynos_drm_crtc *exynos_crtc =
Sean Paul080be03d2014-02-19 21:02:55 +0900289 to_exynos_crtc(private->crtc[pipe]);
Inki Dae1c248b72011-10-04 19:19:01 +0900290
Inki Daeec05da92011-12-06 11:06:54 +0900291 if (exynos_crtc->dpms != DRM_MODE_DPMS_ON)
292 return -EPERM;
293
Gustavo Padovan93bca242015-01-18 18:16:23 +0900294 if (exynos_crtc->ops->enable_vblank)
295 exynos_crtc->ops->enable_vblank(exynos_crtc);
Inki Dae1c248b72011-10-04 19:19:01 +0900296
297 return 0;
298}
299
Sean Paul080be03d2014-02-19 21:02:55 +0900300void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe)
Inki Dae1c248b72011-10-04 19:19:01 +0900301{
302 struct exynos_drm_private *private = dev->dev_private;
Inki Daeec05da92011-12-06 11:06:54 +0900303 struct exynos_drm_crtc *exynos_crtc =
Sean Paul080be03d2014-02-19 21:02:55 +0900304 to_exynos_crtc(private->crtc[pipe]);
Inki Dae1c248b72011-10-04 19:19:01 +0900305
Inki Daeec05da92011-12-06 11:06:54 +0900306 if (exynos_crtc->dpms != DRM_MODE_DPMS_ON)
307 return;
308
Gustavo Padovan93bca242015-01-18 18:16:23 +0900309 if (exynos_crtc->ops->disable_vblank)
310 exynos_crtc->ops->disable_vblank(exynos_crtc);
Inki Dae1c248b72011-10-04 19:19:01 +0900311}
Rahul Sharma663d8762013-01-03 05:44:04 -0500312
Sean Paul080be03d2014-02-19 21:02:55 +0900313void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe)
Rahul Sharma663d8762013-01-03 05:44:04 -0500314{
315 struct exynos_drm_private *dev_priv = dev->dev_private;
316 struct drm_pending_vblank_event *e, *t;
Sean Paul080be03d2014-02-19 21:02:55 +0900317 struct drm_crtc *drm_crtc = dev_priv->crtc[pipe];
Inki Dae20cd2642013-05-21 16:55:58 +0900318 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(drm_crtc);
Rahul Sharma663d8762013-01-03 05:44:04 -0500319 unsigned long flags;
320
Rahul Sharma663d8762013-01-03 05:44:04 -0500321 spin_lock_irqsave(&dev->event_lock, flags);
322
323 list_for_each_entry_safe(e, t, &dev_priv->pageflip_event_list,
324 base.link) {
325 /* if event's pipe isn't same as crtc then ignore it. */
Sean Paul080be03d2014-02-19 21:02:55 +0900326 if (pipe != e->pipe)
Rahul Sharma663d8762013-01-03 05:44:04 -0500327 continue;
328
Rob Clarkc5cca972013-05-22 11:48:40 +0900329 list_del(&e->base.link);
330 drm_send_vblank_event(dev, -1, e);
Sean Paul080be03d2014-02-19 21:02:55 +0900331 drm_vblank_put(dev, pipe);
Inki Dae20cd2642013-05-21 16:55:58 +0900332 atomic_set(&exynos_crtc->pending_flip, 0);
333 wake_up(&exynos_crtc->pending_flip_queue);
Rahul Sharma663d8762013-01-03 05:44:04 -0500334 }
335
336 spin_unlock_irqrestore(&dev->event_lock, flags);
337}
Sean Paul080be03d2014-02-19 21:02:55 +0900338
Sean Paul080be03d2014-02-19 21:02:55 +0900339void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb)
340{
Gustavo Padovan93bca242015-01-18 18:16:23 +0900341 struct exynos_drm_crtc *exynos_crtc;
Sean Paul080be03d2014-02-19 21:02:55 +0900342 struct drm_device *dev = fb->dev;
343 struct drm_crtc *crtc;
344
345 /*
346 * make sure that overlay data are updated to real hardware
347 * for all encoders.
348 */
349 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
Gustavo Padovan93bca242015-01-18 18:16:23 +0900350 exynos_crtc = to_exynos_crtc(crtc);
Sean Paul080be03d2014-02-19 21:02:55 +0900351
352 /*
353 * wait for vblank interrupt
354 * - this makes sure that overlay data are updated to
355 * real hardware.
356 */
Gustavo Padovan93bca242015-01-18 18:16:23 +0900357 if (exynos_crtc->ops->wait_for_vblank)
358 exynos_crtc->ops->wait_for_vblank(exynos_crtc);
Sean Paul080be03d2014-02-19 21:02:55 +0900359 }
360}
Inki Daef37cd5e2014-05-09 14:25:20 +0900361
362int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev,
363 unsigned int out_type)
364{
365 struct drm_crtc *crtc;
366
367 list_for_each_entry(crtc, &drm_dev->mode_config.crtc_list, head) {
368 struct exynos_drm_crtc *exynos_crtc;
369
370 exynos_crtc = to_exynos_crtc(crtc);
Gustavo Padovan5d1741a2014-11-05 19:51:35 -0200371 if (exynos_crtc->type == out_type)
Gustavo Padovan8a326ed2014-11-04 18:44:47 -0200372 return exynos_crtc->pipe;
Inki Daef37cd5e2014-05-09 14:25:20 +0900373 }
374
375 return -EPERM;
376}
YoungJun Cho5595d4d2014-07-17 18:01:19 +0900377
378void exynos_drm_crtc_te_handler(struct drm_crtc *crtc)
379{
Gustavo Padovan93bca242015-01-18 18:16:23 +0900380 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
YoungJun Cho5595d4d2014-07-17 18:01:19 +0900381
Gustavo Padovan93bca242015-01-18 18:16:23 +0900382 if (exynos_crtc->ops->te_handler)
383 exynos_crtc->ops->te_handler(exynos_crtc);
YoungJun Cho5595d4d2014-07-17 18:01:19 +0900384}