2 * Copyright (c) 2014 The Linux Foundation. All rights reserved.
3 * Copyright (C) 2013 Red Hat
4 * Author: Rob Clark <robdclark@gmail.com>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
21 #include <linux/sort.h>
22 #include <drm/drm_mode.h>
24 #include "drm_crtc_helper.h"
25 #include "drm_flip_work.h"
27 #define CURSOR_WIDTH 64
28 #define CURSOR_HEIGHT 64
30 #define SSPP_MAX (SSPP_RGB3 + 1) /* TODO: Add SSPP_MAX in mdp5.xml.h */
38 /* layer mixer used for this CRTC (+ its lock): */
39 #define GET_LM_ID(crtc_id) ((crtc_id == 3) ? 5 : crtc_id)
41 spinlock_t lm_lock; /* protect REG_MDP5_LM_* registers */
43 /* CTL used for this CRTC: */
46 /* if there is a pending flip, these will be non-null: */
47 struct drm_pending_vblank_event *event;
49 #define PENDING_CURSOR 0x1
50 #define PENDING_FLIP 0x2
53 /* for unref'ing cursor bo's after scanout completes: */
54 struct drm_flip_work unref_cursor_work;
56 struct mdp_irq vblank;
60 /* protect REG_MDP5_LM_CURSOR* registers and cursor scanout_bo*/
63 /* current cursor being scanned out: */
64 struct drm_gem_object *scanout_bo;
65 uint32_t width, height;
69 #define to_mdp5_crtc(x) container_of(x, struct mdp5_crtc, base)
71 static struct mdp5_kms *get_kms(struct drm_crtc *crtc)
73 struct msm_drm_private *priv = crtc->dev->dev_private;
74 return to_mdp5_kms(to_mdp_kms(priv->kms));
77 static void request_pending(struct drm_crtc *crtc, uint32_t pending)
79 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
81 atomic_or(pending, &mdp5_crtc->pending);
82 mdp_irq_register(&get_kms(crtc)->base, &mdp5_crtc->vblank);
85 #define mdp5_lm_get_flush(lm) mdp_ctl_flush_mask_lm(lm)
87 static void crtc_flush(struct drm_crtc *crtc, u32 flush_mask)
89 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
91 DBG("%s: flush=%08x", mdp5_crtc->name, flush_mask);
92 mdp5_ctl_commit(mdp5_crtc->ctl, flush_mask);
96 * flush updates, to make sure hw is updated to new scanout fb,
97 * so that we can safely queue unref to current fb (ie. next
98 * vblank we know hw is done w/ previous scanout_fb).
100 static void crtc_flush_all(struct drm_crtc *crtc)
102 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
103 struct drm_plane *plane;
104 uint32_t flush_mask = 0;
106 /* this should not happen: */
107 if (WARN_ON(!mdp5_crtc->ctl))
110 drm_atomic_crtc_for_each_plane(plane, crtc) {
111 flush_mask |= mdp5_plane_get_flush(plane);
113 flush_mask |= mdp5_ctl_get_flush(mdp5_crtc->ctl);
114 flush_mask |= mdp5_lm_get_flush(mdp5_crtc->lm);
116 crtc_flush(crtc, flush_mask);
119 /* if file!=NULL, this is preclose potential cancel-flip path */
120 static void complete_flip(struct drm_crtc *crtc, struct drm_file *file)
122 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
123 struct drm_device *dev = crtc->dev;
124 struct drm_pending_vblank_event *event;
125 struct drm_plane *plane;
128 spin_lock_irqsave(&dev->event_lock, flags);
129 event = mdp5_crtc->event;
131 /* if regular vblank case (!file) or if cancel-flip from
132 * preclose on file that requested flip, then send the
135 if (!file || (event->base.file_priv == file)) {
136 mdp5_crtc->event = NULL;
137 DBG("%s: send event: %p", mdp5_crtc->name, event);
138 drm_send_vblank_event(dev, mdp5_crtc->id, event);
141 spin_unlock_irqrestore(&dev->event_lock, flags);
143 drm_atomic_crtc_for_each_plane(plane, crtc) {
144 mdp5_plane_complete_flip(plane);
147 if (mdp5_crtc->ctl && !crtc->state->enable) {
148 mdp5_ctl_release(mdp5_crtc->ctl);
149 mdp5_crtc->ctl = NULL;
153 static void unref_cursor_worker(struct drm_flip_work *work, void *val)
155 struct mdp5_crtc *mdp5_crtc =
156 container_of(work, struct mdp5_crtc, unref_cursor_work);
157 struct mdp5_kms *mdp5_kms = get_kms(&mdp5_crtc->base);
159 msm_gem_put_iova(val, mdp5_kms->id);
160 drm_gem_object_unreference_unlocked(val);
163 static void mdp5_crtc_destroy(struct drm_crtc *crtc)
165 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
167 drm_crtc_cleanup(crtc);
168 drm_flip_work_cleanup(&mdp5_crtc->unref_cursor_work);
173 static bool mdp5_crtc_mode_fixup(struct drm_crtc *crtc,
174 const struct drm_display_mode *mode,
175 struct drm_display_mode *adjusted_mode)
181 * blend_setup() - blend all the planes of a CRTC
183 * When border is enabled, the border color will ALWAYS be the base layer.
184 * Therefore, the first plane (private RGB pipe) will start at STAGE0.
185 * If disabled, the first plane starts at STAGE_BASE.
188 * Border is not enabled here because the private plane is exactly
189 * the CRTC resolution.
191 static void blend_setup(struct drm_crtc *crtc)
193 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
194 struct mdp5_kms *mdp5_kms = get_kms(crtc);
195 struct drm_plane *plane;
196 const struct mdp5_cfg_hw *hw_cfg;
197 uint32_t lm = mdp5_crtc->lm, blend_cfg = 0;
199 #define blender(stage) ((stage) - STAGE_BASE)
201 hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
203 spin_lock_irqsave(&mdp5_crtc->lm_lock, flags);
205 /* ctl could be released already when we are shutting down: */
209 drm_atomic_crtc_for_each_plane(plane, crtc) {
210 enum mdp_mixer_stage_id stage =
211 to_mdp5_plane_state(plane->state)->stage;
214 * Note: This cannot happen with current implementation but
215 * we need to check this condition once z property is added
217 BUG_ON(stage > hw_cfg->lm.nb_stages);
221 REG_MDP5_LM_BLEND_OP_MODE(lm, blender(stage)),
222 MDP5_LM_BLEND_OP_MODE_FG_ALPHA(FG_CONST) |
223 MDP5_LM_BLEND_OP_MODE_BG_ALPHA(BG_CONST));
224 mdp5_write(mdp5_kms, REG_MDP5_LM_BLEND_FG_ALPHA(lm,
225 blender(stage)), 0xff);
226 mdp5_write(mdp5_kms, REG_MDP5_LM_BLEND_BG_ALPHA(lm,
227 blender(stage)), 0x00);
229 blend_cfg |= mdp_ctl_blend_mask(mdp5_plane_pipe(plane), stage);
230 DBG("%s: blending pipe %s on stage=%d", mdp5_crtc->name,
231 pipe2name(mdp5_plane_pipe(plane)), stage);
234 DBG("%s: lm%d: blend config = 0x%08x", mdp5_crtc->name, lm, blend_cfg);
235 mdp5_ctl_blend(mdp5_crtc->ctl, lm, blend_cfg);
238 spin_unlock_irqrestore(&mdp5_crtc->lm_lock, flags);
241 static void mdp5_crtc_mode_set_nofb(struct drm_crtc *crtc)
243 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
244 struct mdp5_kms *mdp5_kms = get_kms(crtc);
246 struct drm_display_mode *mode;
248 if (WARN_ON(!crtc->state))
251 mode = &crtc->state->adjusted_mode;
253 DBG("%s: set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
254 mdp5_crtc->name, mode->base.id, mode->name,
255 mode->vrefresh, mode->clock,
256 mode->hdisplay, mode->hsync_start,
257 mode->hsync_end, mode->htotal,
258 mode->vdisplay, mode->vsync_start,
259 mode->vsync_end, mode->vtotal,
260 mode->type, mode->flags);
262 spin_lock_irqsave(&mdp5_crtc->lm_lock, flags);
263 mdp5_write(mdp5_kms, REG_MDP5_LM_OUT_SIZE(mdp5_crtc->lm),
264 MDP5_LM_OUT_SIZE_WIDTH(mode->hdisplay) |
265 MDP5_LM_OUT_SIZE_HEIGHT(mode->vdisplay));
266 spin_unlock_irqrestore(&mdp5_crtc->lm_lock, flags);
269 static void mdp5_crtc_disable(struct drm_crtc *crtc)
271 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
272 struct mdp5_kms *mdp5_kms = get_kms(crtc);
274 DBG("%s", mdp5_crtc->name);
276 if (WARN_ON(!mdp5_crtc->enabled))
279 /* set STAGE_UNUSED for all layers */
280 mdp5_ctl_blend(mdp5_crtc->ctl, mdp5_crtc->lm, 0x00000000);
282 mdp_irq_unregister(&mdp5_kms->base, &mdp5_crtc->err);
283 mdp5_disable(mdp5_kms);
285 mdp5_crtc->enabled = false;
288 static void mdp5_crtc_enable(struct drm_crtc *crtc)
290 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
291 struct mdp5_kms *mdp5_kms = get_kms(crtc);
293 DBG("%s", mdp5_crtc->name);
295 if (WARN_ON(mdp5_crtc->enabled))
298 mdp5_enable(mdp5_kms);
299 mdp_irq_register(&mdp5_kms->base, &mdp5_crtc->err);
301 crtc_flush_all(crtc);
303 mdp5_crtc->enabled = true;
307 struct drm_plane *plane;
308 struct mdp5_plane_state *state;
311 static int pstate_cmp(const void *a, const void *b)
313 struct plane_state *pa = (struct plane_state *)a;
314 struct plane_state *pb = (struct plane_state *)b;
315 return pa->state->zpos - pb->state->zpos;
318 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
319 struct drm_crtc_state *state)
321 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
322 struct mdp5_kms *mdp5_kms = get_kms(crtc);
323 struct drm_plane *plane;
324 struct drm_device *dev = crtc->dev;
325 struct plane_state pstates[STAGE3 + 1];
328 DBG("%s: check", mdp5_crtc->name);
330 /* request a free CTL, if none is already allocated for this CRTC */
331 if (state->enable && !mdp5_crtc->ctl) {
332 mdp5_crtc->ctl = mdp5_ctlm_request(mdp5_kms->ctlm, crtc);
333 if (WARN_ON(!mdp5_crtc->ctl))
337 /* verify that there are not too many planes attached to crtc
338 * and that we don't have conflicting mixer stages:
340 drm_atomic_crtc_state_for_each_plane(plane, state) {
341 struct drm_plane_state *pstate;
343 if (cnt >= ARRAY_SIZE(pstates)) {
344 dev_err(dev->dev, "too many planes!\n");
348 pstate = state->state->plane_states[drm_plane_index(plane)];
350 /* plane might not have changed, in which case take
354 pstate = plane->state;
356 pstates[cnt].plane = plane;
357 pstates[cnt].state = to_mdp5_plane_state(pstate);
362 sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
364 for (i = 0; i < cnt; i++) {
365 pstates[i].state->stage = STAGE_BASE + i;
366 DBG("%s: assign pipe %s on stage=%d", mdp5_crtc->name,
367 pipe2name(mdp5_plane_pipe(pstates[i].plane)),
368 pstates[i].state->stage);
374 static void mdp5_crtc_atomic_begin(struct drm_crtc *crtc)
376 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
377 DBG("%s: begin", mdp5_crtc->name);
380 static void mdp5_crtc_atomic_flush(struct drm_crtc *crtc)
382 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
383 struct drm_device *dev = crtc->dev;
386 DBG("%s: event: %p", mdp5_crtc->name, crtc->state->event);
388 WARN_ON(mdp5_crtc->event);
390 spin_lock_irqsave(&dev->event_lock, flags);
391 mdp5_crtc->event = crtc->state->event;
392 spin_unlock_irqrestore(&dev->event_lock, flags);
395 * If no CTL has been allocated in mdp5_crtc_atomic_check(),
396 * it means we are trying to flush a CRTC whose state is disabled:
397 * nothing else needs to be done.
399 if (unlikely(!mdp5_crtc->ctl))
403 crtc_flush_all(crtc);
404 request_pending(crtc, PENDING_FLIP);
407 static int mdp5_crtc_set_property(struct drm_crtc *crtc,
408 struct drm_property *property, uint64_t val)
414 static void get_roi(struct drm_crtc *crtc, uint32_t *roi_w, uint32_t *roi_h)
416 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
417 uint32_t xres = crtc->mode.hdisplay;
418 uint32_t yres = crtc->mode.vdisplay;
421 * Cursor Region Of Interest (ROI) is a plane read from cursor
422 * buffer to render. The ROI region is determined by the visibility of
423 * the cursor point. In the default Cursor image the cursor point will
424 * be at the top left of the cursor image, unless it is specified
425 * otherwise using hotspot feature.
427 * If the cursor point reaches the right (xres - x < cursor.width) or
428 * bottom (yres - y < cursor.height) boundary of the screen, then ROI
429 * width and ROI height need to be evaluated to crop the cursor image
431 * (xres-x) will be new cursor width when x > (xres - cursor.width)
432 * (yres-y) will be new cursor height when y > (yres - cursor.height)
434 *roi_w = min(mdp5_crtc->cursor.width, xres -
435 mdp5_crtc->cursor.x);
436 *roi_h = min(mdp5_crtc->cursor.height, yres -
437 mdp5_crtc->cursor.y);
440 static int mdp5_crtc_cursor_set(struct drm_crtc *crtc,
441 struct drm_file *file, uint32_t handle,
442 uint32_t width, uint32_t height)
444 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
445 struct drm_device *dev = crtc->dev;
446 struct mdp5_kms *mdp5_kms = get_kms(crtc);
447 struct drm_gem_object *cursor_bo, *old_bo;
448 uint32_t blendcfg, cursor_addr, stride;
451 enum mdp5_cursor_alpha cur_alpha = CURSOR_ALPHA_PER_PIXEL;
452 uint32_t flush_mask = mdp_ctl_flush_mask_cursor(0);
453 uint32_t roi_w, roi_h;
456 if ((width > CURSOR_WIDTH) || (height > CURSOR_HEIGHT)) {
457 dev_err(dev->dev, "bad cursor size: %dx%d\n", width, height);
461 if (NULL == mdp5_crtc->ctl)
466 return mdp5_ctl_set_cursor(mdp5_crtc->ctl, false);
469 cursor_bo = drm_gem_object_lookup(dev, file, handle);
473 ret = msm_gem_get_iova(cursor_bo, mdp5_kms->id, &cursor_addr);
478 drm_fb_get_bpp_depth(DRM_FORMAT_ARGB8888, &depth, &bpp);
479 stride = width * (bpp >> 3);
481 spin_lock_irqsave(&mdp5_crtc->cursor.lock, flags);
482 old_bo = mdp5_crtc->cursor.scanout_bo;
484 mdp5_crtc->cursor.scanout_bo = cursor_bo;
485 mdp5_crtc->cursor.width = width;
486 mdp5_crtc->cursor.height = height;
488 get_roi(crtc, &roi_w, &roi_h);
490 mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_STRIDE(lm), stride);
491 mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_FORMAT(lm),
492 MDP5_LM_CURSOR_FORMAT_FORMAT(CURSOR_FMT_ARGB8888));
493 mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_IMG_SIZE(lm),
494 MDP5_LM_CURSOR_IMG_SIZE_SRC_H(height) |
495 MDP5_LM_CURSOR_IMG_SIZE_SRC_W(width));
496 mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_SIZE(lm),
497 MDP5_LM_CURSOR_SIZE_ROI_H(roi_h) |
498 MDP5_LM_CURSOR_SIZE_ROI_W(roi_w));
499 mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_BASE_ADDR(lm), cursor_addr);
501 blendcfg = MDP5_LM_CURSOR_BLEND_CONFIG_BLEND_EN;
502 blendcfg |= MDP5_LM_CURSOR_BLEND_CONFIG_BLEND_ALPHA_SEL(cur_alpha);
503 mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_BLEND_CONFIG(lm), blendcfg);
505 spin_unlock_irqrestore(&mdp5_crtc->cursor.lock, flags);
507 ret = mdp5_ctl_set_cursor(mdp5_crtc->ctl, true);
511 flush_mask |= mdp5_ctl_get_flush(mdp5_crtc->ctl);
512 crtc_flush(crtc, flush_mask);
516 drm_flip_work_queue(&mdp5_crtc->unref_cursor_work, old_bo);
517 /* enable vblank to complete cursor work: */
518 request_pending(crtc, PENDING_CURSOR);
523 static int mdp5_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
525 struct mdp5_kms *mdp5_kms = get_kms(crtc);
526 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
527 uint32_t flush_mask = mdp_ctl_flush_mask_cursor(0);
532 /* In case the CRTC is disabled, just drop the cursor update */
533 if (unlikely(!crtc->state->enable))
536 mdp5_crtc->cursor.x = x = max(x, 0);
537 mdp5_crtc->cursor.y = y = max(y, 0);
539 get_roi(crtc, &roi_w, &roi_h);
541 spin_lock_irqsave(&mdp5_crtc->cursor.lock, flags);
542 mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_SIZE(mdp5_crtc->lm),
543 MDP5_LM_CURSOR_SIZE_ROI_H(roi_h) |
544 MDP5_LM_CURSOR_SIZE_ROI_W(roi_w));
545 mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_START_XY(mdp5_crtc->lm),
546 MDP5_LM_CURSOR_START_XY_Y_START(y) |
547 MDP5_LM_CURSOR_START_XY_X_START(x));
548 spin_unlock_irqrestore(&mdp5_crtc->cursor.lock, flags);
550 crtc_flush(crtc, flush_mask);
555 static const struct drm_crtc_funcs mdp5_crtc_funcs = {
556 .set_config = drm_atomic_helper_set_config,
557 .destroy = mdp5_crtc_destroy,
558 .page_flip = drm_atomic_helper_page_flip,
559 .set_property = mdp5_crtc_set_property,
560 .reset = drm_atomic_helper_crtc_reset,
561 .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
562 .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
563 .cursor_set = mdp5_crtc_cursor_set,
564 .cursor_move = mdp5_crtc_cursor_move,
567 static const struct drm_crtc_helper_funcs mdp5_crtc_helper_funcs = {
568 .mode_fixup = mdp5_crtc_mode_fixup,
569 .mode_set_nofb = mdp5_crtc_mode_set_nofb,
570 .disable = mdp5_crtc_disable,
571 .enable = mdp5_crtc_enable,
572 .atomic_check = mdp5_crtc_atomic_check,
573 .atomic_begin = mdp5_crtc_atomic_begin,
574 .atomic_flush = mdp5_crtc_atomic_flush,
577 static void mdp5_crtc_vblank_irq(struct mdp_irq *irq, uint32_t irqstatus)
579 struct mdp5_crtc *mdp5_crtc = container_of(irq, struct mdp5_crtc, vblank);
580 struct drm_crtc *crtc = &mdp5_crtc->base;
581 struct msm_drm_private *priv = crtc->dev->dev_private;
584 mdp_irq_unregister(&get_kms(crtc)->base, &mdp5_crtc->vblank);
586 pending = atomic_xchg(&mdp5_crtc->pending, 0);
588 if (pending & PENDING_FLIP) {
589 complete_flip(crtc, NULL);
592 if (pending & PENDING_CURSOR)
593 drm_flip_work_commit(&mdp5_crtc->unref_cursor_work, priv->wq);
596 static void mdp5_crtc_err_irq(struct mdp_irq *irq, uint32_t irqstatus)
598 struct mdp5_crtc *mdp5_crtc = container_of(irq, struct mdp5_crtc, err);
600 DBG("%s: error: %08x", mdp5_crtc->name, irqstatus);
603 uint32_t mdp5_crtc_vblank(struct drm_crtc *crtc)
605 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
606 return mdp5_crtc->vblank.irqmask;
609 void mdp5_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file)
611 DBG("cancel: %p", file);
612 complete_flip(crtc, file);
615 /* set interface for routing crtc->encoder: */
616 void mdp5_crtc_set_intf(struct drm_crtc *crtc, int intf,
617 enum mdp5_intf intf_id)
619 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
620 struct mdp5_kms *mdp5_kms = get_kms(crtc);
621 uint32_t flush_mask = 0;
625 /* now that we know what irq's we want: */
626 mdp5_crtc->err.irqmask = intf2err(intf);
627 mdp5_crtc->vblank.irqmask = intf2vblank(intf);
628 mdp_irq_update(&mdp5_kms->base);
630 spin_lock_irqsave(&mdp5_kms->resource_lock, flags);
631 intf_sel = mdp5_read(mdp5_kms, REG_MDP5_DISP_INTF_SEL);
635 intf_sel &= ~MDP5_DISP_INTF_SEL_INTF0__MASK;
636 intf_sel |= MDP5_DISP_INTF_SEL_INTF0(intf_id);
639 intf_sel &= ~MDP5_DISP_INTF_SEL_INTF1__MASK;
640 intf_sel |= MDP5_DISP_INTF_SEL_INTF1(intf_id);
643 intf_sel &= ~MDP5_DISP_INTF_SEL_INTF2__MASK;
644 intf_sel |= MDP5_DISP_INTF_SEL_INTF2(intf_id);
647 intf_sel &= ~MDP5_DISP_INTF_SEL_INTF3__MASK;
648 intf_sel |= MDP5_DISP_INTF_SEL_INTF3(intf_id);
655 mdp5_write(mdp5_kms, REG_MDP5_DISP_INTF_SEL, intf_sel);
656 spin_unlock_irqrestore(&mdp5_kms->resource_lock, flags);
658 DBG("%s: intf_sel=%08x", mdp5_crtc->name, intf_sel);
659 mdp5_ctl_set_intf(mdp5_crtc->ctl, intf);
660 flush_mask |= mdp5_ctl_get_flush(mdp5_crtc->ctl);
661 flush_mask |= mdp5_lm_get_flush(mdp5_crtc->lm);
663 crtc_flush(crtc, flush_mask);
666 int mdp5_crtc_get_lm(struct drm_crtc *crtc)
668 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
673 return mdp5_crtc->lm;
676 /* initialize crtc */
677 struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
678 struct drm_plane *plane, int id)
680 struct drm_crtc *crtc = NULL;
681 struct mdp5_crtc *mdp5_crtc;
683 mdp5_crtc = kzalloc(sizeof(*mdp5_crtc), GFP_KERNEL);
685 return ERR_PTR(-ENOMEM);
687 crtc = &mdp5_crtc->base;
690 mdp5_crtc->lm = GET_LM_ID(id);
692 spin_lock_init(&mdp5_crtc->lm_lock);
693 spin_lock_init(&mdp5_crtc->cursor.lock);
695 mdp5_crtc->vblank.irq = mdp5_crtc_vblank_irq;
696 mdp5_crtc->err.irq = mdp5_crtc_err_irq;
698 snprintf(mdp5_crtc->name, sizeof(mdp5_crtc->name), "%s:%d",
699 pipe2name(mdp5_plane_pipe(plane)), id);
701 drm_crtc_init_with_planes(dev, crtc, plane, NULL, &mdp5_crtc_funcs);
703 drm_flip_work_init(&mdp5_crtc->unref_cursor_work,
704 "unref cursor", unref_cursor_worker);
706 drm_crtc_helper_add(crtc, &mdp5_crtc_helper_funcs);
709 mdp5_plane_install_properties(plane, &crtc->base);