1 // SPDX-License-Identifier: MIT
3 * Copyright © 2020 Intel Corporation
5 #include <linux/kernel.h>
7 #include <drm/drm_atomic_helper.h>
8 #include <drm/drm_atomic_uapi.h>
9 #include <drm/drm_blend.h>
10 #include <drm/drm_damage_helper.h>
11 #include <drm/drm_fourcc.h>
14 #include "intel_atomic.h"
15 #include "intel_atomic_plane.h"
16 #include "intel_cursor.h"
18 #include "intel_display.h"
19 #include "intel_display_types.h"
21 #include "intel_fb_pin.h"
22 #include "intel_frontbuffer.h"
23 #include "intel_psr.h"
24 #include "intel_psr_regs.h"
25 #include "intel_vblank.h"
26 #include "skl_watermark.h"
28 #include "gem/i915_gem_object.h"
31 static const u32 intel_cursor_formats[] = {
35 static u32 intel_cursor_base(const struct intel_plane_state *plane_state)
37 struct drm_i915_private *dev_priv =
38 to_i915(plane_state->uapi.plane->dev);
39 const struct drm_framebuffer *fb = plane_state->hw.fb;
40 struct drm_i915_gem_object *obj = intel_fb_obj(fb);
43 if (DISPLAY_INFO(dev_priv)->cursor_needs_physical)
44 base = i915_gem_object_get_dma_address(obj, 0);
46 base = intel_plane_ggtt_offset(plane_state);
48 return base + plane_state->view.color_plane[0].offset;
51 static u32 intel_cursor_position(const struct intel_crtc_state *crtc_state,
52 const struct intel_plane_state *plane_state,
55 int x = plane_state->uapi.dst.x1;
56 int y = plane_state->uapi.dst.y1;
61 * MAX(-1 * <Cursor vertical size from CUR_CTL base on cursor mode
62 * select setting> + 1, CUR_POS Y Position - Update region Y position
65 y = max(-1 * drm_rect_height(&plane_state->uapi.dst) + 1,
66 y - crtc_state->psr2_su_area.y1);
69 pos |= CURSOR_POS_X_SIGN;
72 pos |= CURSOR_POS_X(x);
75 pos |= CURSOR_POS_Y_SIGN;
78 pos |= CURSOR_POS_Y(y);
83 static bool intel_cursor_size_ok(const struct intel_plane_state *plane_state)
85 const struct drm_mode_config *config =
86 &plane_state->uapi.plane->dev->mode_config;
87 int width = drm_rect_width(&plane_state->uapi.dst);
88 int height = drm_rect_height(&plane_state->uapi.dst);
90 return width > 0 && width <= config->cursor_width &&
91 height > 0 && height <= config->cursor_height;
94 static int intel_cursor_check_surface(struct intel_plane_state *plane_state)
96 struct drm_i915_private *dev_priv =
97 to_i915(plane_state->uapi.plane->dev);
98 unsigned int rotation = plane_state->hw.rotation;
103 ret = intel_plane_compute_gtt(plane_state);
107 if (!plane_state->uapi.visible)
110 src_x = plane_state->uapi.src.x1 >> 16;
111 src_y = plane_state->uapi.src.y1 >> 16;
113 intel_add_fb_offsets(&src_x, &src_y, plane_state, 0);
114 offset = intel_plane_compute_aligned_offset(&src_x, &src_y,
117 if (src_x != 0 || src_y != 0) {
118 drm_dbg_kms(&dev_priv->drm,
119 "Arbitrary cursor panning not supported\n");
124 * Put the final coordinates back so that the src
125 * coordinate checks will see the right values.
127 drm_rect_translate_to(&plane_state->uapi.src,
128 src_x << 16, src_y << 16);
130 /* ILK+ do this automagically in hardware */
131 if (HAS_GMCH(dev_priv) && rotation & DRM_MODE_ROTATE_180) {
132 const struct drm_framebuffer *fb = plane_state->hw.fb;
133 int src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
134 int src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
136 offset += (src_h * src_w - 1) * fb->format->cpp[0];
139 plane_state->view.color_plane[0].offset = offset;
140 plane_state->view.color_plane[0].x = src_x;
141 plane_state->view.color_plane[0].y = src_y;
146 static int intel_check_cursor(struct intel_crtc_state *crtc_state,
147 struct intel_plane_state *plane_state)
149 const struct drm_framebuffer *fb = plane_state->hw.fb;
150 struct drm_i915_private *i915 = to_i915(plane_state->uapi.plane->dev);
151 const struct drm_rect src = plane_state->uapi.src;
152 const struct drm_rect dst = plane_state->uapi.dst;
155 if (fb && fb->modifier != DRM_FORMAT_MOD_LINEAR) {
156 drm_dbg_kms(&i915->drm, "cursor cannot be tiled\n");
160 ret = intel_atomic_plane_check_clipping(plane_state, crtc_state,
161 DRM_PLANE_NO_SCALING,
162 DRM_PLANE_NO_SCALING,
167 /* Use the unclipped src/dst rectangles, which we program to hw */
168 plane_state->uapi.src = src;
169 plane_state->uapi.dst = dst;
171 /* final plane coordinates will be relative to the plane's pipe */
172 drm_rect_translate(&plane_state->uapi.dst,
173 -crtc_state->pipe_src.x1,
174 -crtc_state->pipe_src.y1);
176 ret = intel_cursor_check_surface(plane_state);
180 if (!plane_state->uapi.visible)
183 ret = intel_plane_check_src_coordinates(plane_state);
191 i845_cursor_max_stride(struct intel_plane *plane,
192 u32 pixel_format, u64 modifier,
193 unsigned int rotation)
198 static u32 i845_cursor_ctl_crtc(const struct intel_crtc_state *crtc_state)
202 if (crtc_state->gamma_enable)
203 cntl |= CURSOR_PIPE_GAMMA_ENABLE;
208 static u32 i845_cursor_ctl(const struct intel_crtc_state *crtc_state,
209 const struct intel_plane_state *plane_state)
211 return CURSOR_ENABLE |
213 CURSOR_STRIDE(plane_state->view.color_plane[0].mapping_stride);
216 static bool i845_cursor_size_ok(const struct intel_plane_state *plane_state)
218 int width = drm_rect_width(&plane_state->uapi.dst);
221 * 845g/865g are only limited by the width of their cursors,
222 * the height is arbitrary up to the precision of the register.
224 return intel_cursor_size_ok(plane_state) && IS_ALIGNED(width, 64);
227 static int i845_check_cursor(struct intel_crtc_state *crtc_state,
228 struct intel_plane_state *plane_state)
230 const struct drm_framebuffer *fb = plane_state->hw.fb;
231 struct drm_i915_private *i915 = to_i915(plane_state->uapi.plane->dev);
234 ret = intel_check_cursor(crtc_state, plane_state);
238 /* if we want to turn off the cursor ignore width and height */
242 /* Check for which cursor types we support */
243 if (!i845_cursor_size_ok(plane_state)) {
244 drm_dbg_kms(&i915->drm,
245 "Cursor dimension %dx%d not supported\n",
246 drm_rect_width(&plane_state->uapi.dst),
247 drm_rect_height(&plane_state->uapi.dst));
251 drm_WARN_ON(&i915->drm, plane_state->uapi.visible &&
252 plane_state->view.color_plane[0].mapping_stride != fb->pitches[0]);
254 switch (fb->pitches[0]) {
261 drm_dbg_kms(&i915->drm, "Invalid cursor stride (%u)\n",
266 plane_state->ctl = i845_cursor_ctl(crtc_state, plane_state);
271 /* TODO: split into noarm+arm pair */
272 static void i845_cursor_update_arm(struct intel_plane *plane,
273 const struct intel_crtc_state *crtc_state,
274 const struct intel_plane_state *plane_state)
276 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
277 u32 cntl = 0, base = 0, pos = 0, size = 0;
279 if (plane_state && plane_state->uapi.visible) {
280 unsigned int width = drm_rect_width(&plane_state->uapi.dst);
281 unsigned int height = drm_rect_height(&plane_state->uapi.dst);
283 cntl = plane_state->ctl |
284 i845_cursor_ctl_crtc(crtc_state);
286 size = CURSOR_HEIGHT(height) | CURSOR_WIDTH(width);
288 base = intel_cursor_base(plane_state);
289 pos = intel_cursor_position(crtc_state, plane_state, false);
292 /* On these chipsets we can only modify the base/size/stride
293 * whilst the cursor is disabled.
295 if (plane->cursor.base != base ||
296 plane->cursor.size != size ||
297 plane->cursor.cntl != cntl) {
298 intel_de_write_fw(dev_priv, CURCNTR(PIPE_A), 0);
299 intel_de_write_fw(dev_priv, CURBASE(PIPE_A), base);
300 intel_de_write_fw(dev_priv, CURSIZE(PIPE_A), size);
301 intel_de_write_fw(dev_priv, CURPOS(PIPE_A), pos);
302 intel_de_write_fw(dev_priv, CURCNTR(PIPE_A), cntl);
304 plane->cursor.base = base;
305 plane->cursor.size = size;
306 plane->cursor.cntl = cntl;
308 intel_de_write_fw(dev_priv, CURPOS(PIPE_A), pos);
312 static void i845_cursor_disable_arm(struct intel_plane *plane,
313 const struct intel_crtc_state *crtc_state)
315 i845_cursor_update_arm(plane, crtc_state, NULL);
318 static bool i845_cursor_get_hw_state(struct intel_plane *plane,
321 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
322 enum intel_display_power_domain power_domain;
323 intel_wakeref_t wakeref;
326 power_domain = POWER_DOMAIN_PIPE(PIPE_A);
327 wakeref = intel_display_power_get_if_enabled(dev_priv, power_domain);
331 ret = intel_de_read(dev_priv, CURCNTR(PIPE_A)) & CURSOR_ENABLE;
335 intel_display_power_put(dev_priv, power_domain, wakeref);
341 i9xx_cursor_max_stride(struct intel_plane *plane,
342 u32 pixel_format, u64 modifier,
343 unsigned int rotation)
345 return plane->base.dev->mode_config.cursor_width * 4;
348 static u32 i9xx_cursor_ctl_crtc(const struct intel_crtc_state *crtc_state)
350 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
351 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
354 if (DISPLAY_VER(dev_priv) >= 11)
357 if (crtc_state->gamma_enable)
358 cntl = MCURSOR_PIPE_GAMMA_ENABLE;
360 if (crtc_state->csc_enable)
361 cntl |= MCURSOR_PIPE_CSC_ENABLE;
363 if (DISPLAY_VER(dev_priv) < 5 && !IS_G4X(dev_priv))
364 cntl |= MCURSOR_PIPE_SEL(crtc->pipe);
369 static u32 i9xx_cursor_ctl(const struct intel_crtc_state *crtc_state,
370 const struct intel_plane_state *plane_state)
372 struct drm_i915_private *dev_priv =
373 to_i915(plane_state->uapi.plane->dev);
376 if (IS_SANDYBRIDGE(dev_priv) || IS_IVYBRIDGE(dev_priv))
377 cntl |= MCURSOR_TRICKLE_FEED_DISABLE;
379 switch (drm_rect_width(&plane_state->uapi.dst)) {
381 cntl |= MCURSOR_MODE_64_ARGB_AX;
384 cntl |= MCURSOR_MODE_128_ARGB_AX;
387 cntl |= MCURSOR_MODE_256_ARGB_AX;
390 MISSING_CASE(drm_rect_width(&plane_state->uapi.dst));
394 if (plane_state->hw.rotation & DRM_MODE_ROTATE_180)
395 cntl |= MCURSOR_ROTATE_180;
397 /* Wa_22012358565:adl-p */
398 if (DISPLAY_VER(dev_priv) == 13)
399 cntl |= MCURSOR_ARB_SLOTS(1);
404 static bool i9xx_cursor_size_ok(const struct intel_plane_state *plane_state)
406 struct drm_i915_private *dev_priv =
407 to_i915(plane_state->uapi.plane->dev);
408 int width = drm_rect_width(&plane_state->uapi.dst);
409 int height = drm_rect_height(&plane_state->uapi.dst);
411 if (!intel_cursor_size_ok(plane_state))
414 /* Cursor width is limited to a few power-of-two sizes */
425 * IVB+ have CUR_FBC_CTL which allows an arbitrary cursor
426 * height from 8 lines up to the cursor width, when the
427 * cursor is not rotated. Everything else requires square
430 if (HAS_CUR_FBC(dev_priv) &&
431 plane_state->hw.rotation & DRM_MODE_ROTATE_0) {
432 if (height < 8 || height > width)
442 static int i9xx_check_cursor(struct intel_crtc_state *crtc_state,
443 struct intel_plane_state *plane_state)
445 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
446 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
447 const struct drm_framebuffer *fb = plane_state->hw.fb;
448 enum pipe pipe = plane->pipe;
451 ret = intel_check_cursor(crtc_state, plane_state);
455 /* if we want to turn off the cursor ignore width and height */
459 /* Check for which cursor types we support */
460 if (!i9xx_cursor_size_ok(plane_state)) {
461 drm_dbg(&dev_priv->drm,
462 "Cursor dimension %dx%d not supported\n",
463 drm_rect_width(&plane_state->uapi.dst),
464 drm_rect_height(&plane_state->uapi.dst));
468 drm_WARN_ON(&dev_priv->drm, plane_state->uapi.visible &&
469 plane_state->view.color_plane[0].mapping_stride != fb->pitches[0]);
471 if (fb->pitches[0] !=
472 drm_rect_width(&plane_state->uapi.dst) * fb->format->cpp[0]) {
473 drm_dbg_kms(&dev_priv->drm,
474 "Invalid cursor stride (%u) (cursor width %d)\n",
476 drm_rect_width(&plane_state->uapi.dst));
481 * There's something wrong with the cursor on CHV pipe C.
482 * If it straddles the left edge of the screen then
483 * moving it away from the edge or disabling it often
484 * results in a pipe underrun, and often that can lead to
485 * dead pipe (constant underrun reported, and it scans
486 * out just a solid color). To recover from that, the
487 * display power well must be turned off and on again.
488 * Refuse the put the cursor into that compromised position.
490 if (IS_CHERRYVIEW(dev_priv) && pipe == PIPE_C &&
491 plane_state->uapi.visible && plane_state->uapi.dst.x1 < 0) {
492 drm_dbg_kms(&dev_priv->drm,
493 "CHV cursor C not allowed to straddle the left screen edge\n");
497 plane_state->ctl = i9xx_cursor_ctl(crtc_state, plane_state);
502 static void i9xx_cursor_disable_sel_fetch_arm(struct intel_plane *plane,
503 const struct intel_crtc_state *crtc_state)
505 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
506 enum pipe pipe = plane->pipe;
508 if (!crtc_state->enable_psr2_sel_fetch)
511 intel_de_write_fw(dev_priv, PLANE_SEL_FETCH_CTL(pipe, plane->id), 0);
514 static void i9xx_cursor_update_sel_fetch_arm(struct intel_plane *plane,
515 const struct intel_crtc_state *crtc_state,
516 const struct intel_plane_state *plane_state)
518 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
519 enum pipe pipe = plane->pipe;
521 if (!crtc_state->enable_psr2_sel_fetch)
524 if (drm_rect_height(&plane_state->psr2_sel_fetch_area) > 0) {
525 if (crtc_state->enable_psr2_su_region_et) {
526 u32 val = intel_cursor_position(crtc_state, plane_state,
528 intel_de_write_fw(dev_priv, CURPOS_ERLY_TPT(pipe), val);
531 intel_de_write_fw(dev_priv, PLANE_SEL_FETCH_CTL(pipe, plane->id),
534 i9xx_cursor_disable_sel_fetch_arm(plane, crtc_state);
538 /* TODO: split into noarm+arm pair */
539 static void i9xx_cursor_update_arm(struct intel_plane *plane,
540 const struct intel_crtc_state *crtc_state,
541 const struct intel_plane_state *plane_state)
543 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
544 enum pipe pipe = plane->pipe;
545 u32 cntl = 0, base = 0, pos = 0, fbc_ctl = 0;
547 if (plane_state && plane_state->uapi.visible) {
548 int width = drm_rect_width(&plane_state->uapi.dst);
549 int height = drm_rect_height(&plane_state->uapi.dst);
551 cntl = plane_state->ctl |
552 i9xx_cursor_ctl_crtc(crtc_state);
555 fbc_ctl = CUR_FBC_EN | CUR_FBC_HEIGHT(height - 1);
557 base = intel_cursor_base(plane_state);
558 pos = intel_cursor_position(crtc_state, plane_state, false);
562 * On some platforms writing CURCNTR first will also
563 * cause CURPOS to be armed by the CURBASE write.
564 * Without the CURCNTR write the CURPOS write would
565 * arm itself. Thus we always update CURCNTR before
568 * On other platforms CURPOS always requires the
569 * CURBASE write to arm the update. Additonally
570 * a write to any of the cursor register will cancel
571 * an already armed cursor update. Thus leaving out
572 * the CURBASE write after CURPOS could lead to a
573 * cursor that doesn't appear to move, or even change
574 * shape. Thus we always write CURBASE.
576 * The other registers are armed by the CURBASE write
577 * except when the plane is getting enabled at which time
578 * the CURCNTR write arms the update.
581 if (DISPLAY_VER(dev_priv) >= 9)
582 skl_write_cursor_wm(plane, crtc_state);
585 i9xx_cursor_update_sel_fetch_arm(plane, crtc_state,
588 i9xx_cursor_disable_sel_fetch_arm(plane, crtc_state);
590 if (plane->cursor.base != base ||
591 plane->cursor.size != fbc_ctl ||
592 plane->cursor.cntl != cntl) {
593 if (HAS_CUR_FBC(dev_priv))
594 intel_de_write_fw(dev_priv, CUR_FBC_CTL(pipe),
596 intel_de_write_fw(dev_priv, CURCNTR(pipe), cntl);
597 intel_de_write_fw(dev_priv, CURPOS(pipe), pos);
598 intel_de_write_fw(dev_priv, CURBASE(pipe), base);
600 plane->cursor.base = base;
601 plane->cursor.size = fbc_ctl;
602 plane->cursor.cntl = cntl;
604 intel_de_write_fw(dev_priv, CURPOS(pipe), pos);
605 intel_de_write_fw(dev_priv, CURBASE(pipe), base);
609 static void i9xx_cursor_disable_arm(struct intel_plane *plane,
610 const struct intel_crtc_state *crtc_state)
612 i9xx_cursor_update_arm(plane, crtc_state, NULL);
615 static bool i9xx_cursor_get_hw_state(struct intel_plane *plane,
618 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
619 enum intel_display_power_domain power_domain;
620 intel_wakeref_t wakeref;
625 * Not 100% correct for planes that can move between pipes,
626 * but that's only the case for gen2-3 which don't have any
627 * display power wells.
629 power_domain = POWER_DOMAIN_PIPE(plane->pipe);
630 wakeref = intel_display_power_get_if_enabled(dev_priv, power_domain);
634 val = intel_de_read(dev_priv, CURCNTR(plane->pipe));
636 ret = val & MCURSOR_MODE_MASK;
638 if (DISPLAY_VER(dev_priv) >= 5 || IS_G4X(dev_priv))
641 *pipe = REG_FIELD_GET(MCURSOR_PIPE_SEL_MASK, val);
643 intel_display_power_put(dev_priv, power_domain, wakeref);
648 static bool intel_cursor_format_mod_supported(struct drm_plane *_plane,
649 u32 format, u64 modifier)
651 if (!intel_fb_plane_supports_modifier(to_intel_plane(_plane), modifier))
654 return format == DRM_FORMAT_ARGB8888;
658 intel_legacy_cursor_update(struct drm_plane *_plane,
659 struct drm_crtc *_crtc,
660 struct drm_framebuffer *fb,
661 int crtc_x, int crtc_y,
662 unsigned int crtc_w, unsigned int crtc_h,
663 u32 src_x, u32 src_y,
664 u32 src_w, u32 src_h,
665 struct drm_modeset_acquire_ctx *ctx)
667 struct intel_plane *plane = to_intel_plane(_plane);
668 struct intel_crtc *crtc = to_intel_crtc(_crtc);
669 struct drm_i915_private *i915 = to_i915(plane->base.dev);
670 struct intel_plane_state *old_plane_state =
671 to_intel_plane_state(plane->base.state);
672 struct intel_plane_state *new_plane_state;
673 struct intel_crtc_state *crtc_state =
674 to_intel_crtc_state(crtc->base.state);
675 struct intel_crtc_state *new_crtc_state;
676 struct intel_vblank_evade_ctx evade;
680 * When crtc is inactive or there is a modeset pending,
681 * wait for it to complete in the slowpath.
682 * PSR2 selective fetch also requires the slow path as
683 * PSR2 plane and transcoder registers can only be updated during
686 * FIXME bigjoiner fastpath would be good
688 if (!crtc_state->hw.active ||
689 intel_crtc_needs_modeset(crtc_state) ||
690 intel_crtc_needs_fastset(crtc_state) ||
691 crtc_state->bigjoiner_pipes)
695 * Don't do an async update if there is an outstanding commit modifying
696 * the plane. This prevents our async update's changes from getting
697 * overridden by a previous synchronous update's state.
699 if (old_plane_state->uapi.commit &&
700 !try_wait_for_completion(&old_plane_state->uapi.commit->hw_done))
704 * If any parameters change that may affect watermarks,
705 * take the slowpath. Only changing fb or position should be
708 if (old_plane_state->uapi.crtc != &crtc->base ||
709 old_plane_state->uapi.src_w != src_w ||
710 old_plane_state->uapi.src_h != src_h ||
711 old_plane_state->uapi.crtc_w != crtc_w ||
712 old_plane_state->uapi.crtc_h != crtc_h ||
713 !old_plane_state->uapi.fb != !fb)
716 new_plane_state = to_intel_plane_state(intel_plane_duplicate_state(&plane->base));
717 if (!new_plane_state)
720 new_crtc_state = to_intel_crtc_state(intel_crtc_duplicate_state(&crtc->base));
721 if (!new_crtc_state) {
726 drm_atomic_set_fb_for_plane(&new_plane_state->uapi, fb);
728 new_plane_state->uapi.src_x = src_x;
729 new_plane_state->uapi.src_y = src_y;
730 new_plane_state->uapi.src_w = src_w;
731 new_plane_state->uapi.src_h = src_h;
732 new_plane_state->uapi.crtc_x = crtc_x;
733 new_plane_state->uapi.crtc_y = crtc_y;
734 new_plane_state->uapi.crtc_w = crtc_w;
735 new_plane_state->uapi.crtc_h = crtc_h;
737 intel_plane_copy_uapi_to_hw_state(new_plane_state, new_plane_state, crtc);
739 ret = intel_plane_atomic_check_with_state(crtc_state, new_crtc_state,
740 old_plane_state, new_plane_state);
744 ret = intel_plane_pin_fb(new_plane_state);
748 intel_frontbuffer_flush(to_intel_frontbuffer(new_plane_state->hw.fb),
749 ORIGIN_CURSOR_UPDATE);
750 intel_frontbuffer_track(to_intel_frontbuffer(old_plane_state->hw.fb),
751 to_intel_frontbuffer(new_plane_state->hw.fb),
752 plane->frontbuffer_bit);
754 /* Swap plane state */
755 plane->base.state = &new_plane_state->uapi;
758 * We cannot swap crtc_state as it may be in use by an atomic commit or
759 * page flip that's running simultaneously. If we swap crtc_state and
760 * destroy the old state, we will cause a use-after-free there.
762 * Only update active_planes, which is needed for our internal
763 * bookkeeping. Either value will do the right thing when updating
764 * planes atomically. If the cursor was part of the atomic update then
765 * we would have taken the slowpath.
767 crtc_state->active_planes = new_crtc_state->active_planes;
769 intel_vblank_evade_init(crtc_state, crtc_state, &evade);
771 intel_psr_lock(crtc_state);
773 if (!drm_WARN_ON(&i915->drm, drm_crtc_vblank_get(&crtc->base))) {
775 * TODO: maybe check if we're still in PSR
776 * and skip the vblank evasion entirely?
778 intel_psr_wait_for_idle_locked(crtc_state);
782 intel_vblank_evade(&evade);
784 drm_crtc_vblank_put(&crtc->base);
789 if (new_plane_state->uapi.visible) {
790 intel_plane_update_noarm(plane, crtc_state, new_plane_state);
791 intel_plane_update_arm(plane, crtc_state, new_plane_state);
793 intel_plane_disable_arm(plane, crtc_state);
798 intel_psr_unlock(crtc_state);
800 intel_plane_unpin_fb(old_plane_state);
804 intel_crtc_destroy_state(&crtc->base, &new_crtc_state->uapi);
806 intel_plane_destroy_state(&plane->base, &new_plane_state->uapi);
808 intel_plane_destroy_state(&plane->base, &old_plane_state->uapi);
812 return drm_atomic_helper_update_plane(&plane->base, &crtc->base, fb,
813 crtc_x, crtc_y, crtc_w, crtc_h,
814 src_x, src_y, src_w, src_h, ctx);
817 static const struct drm_plane_funcs intel_cursor_plane_funcs = {
818 .update_plane = intel_legacy_cursor_update,
819 .disable_plane = drm_atomic_helper_disable_plane,
820 .destroy = intel_plane_destroy,
821 .atomic_duplicate_state = intel_plane_duplicate_state,
822 .atomic_destroy_state = intel_plane_destroy_state,
823 .format_mod_supported = intel_cursor_format_mod_supported,
827 intel_cursor_plane_create(struct drm_i915_private *dev_priv,
830 struct intel_plane *cursor;
834 cursor = intel_plane_alloc();
839 cursor->i9xx_plane = (enum i9xx_plane_id) pipe;
840 cursor->id = PLANE_CURSOR;
841 cursor->frontbuffer_bit = INTEL_FRONTBUFFER(pipe, cursor->id);
843 if (IS_I845G(dev_priv) || IS_I865G(dev_priv)) {
844 cursor->max_stride = i845_cursor_max_stride;
845 cursor->update_arm = i845_cursor_update_arm;
846 cursor->disable_arm = i845_cursor_disable_arm;
847 cursor->get_hw_state = i845_cursor_get_hw_state;
848 cursor->check_plane = i845_check_cursor;
850 cursor->max_stride = i9xx_cursor_max_stride;
851 cursor->update_arm = i9xx_cursor_update_arm;
852 cursor->disable_arm = i9xx_cursor_disable_arm;
853 cursor->get_hw_state = i9xx_cursor_get_hw_state;
854 cursor->check_plane = i9xx_check_cursor;
857 cursor->cursor.base = ~0;
858 cursor->cursor.cntl = ~0;
860 if (IS_I845G(dev_priv) || IS_I865G(dev_priv) || HAS_CUR_FBC(dev_priv))
861 cursor->cursor.size = ~0;
863 modifiers = intel_fb_plane_get_modifiers(dev_priv, INTEL_PLANE_CAP_NONE);
865 ret = drm_universal_plane_init(&dev_priv->drm, &cursor->base,
866 0, &intel_cursor_plane_funcs,
867 intel_cursor_formats,
868 ARRAY_SIZE(intel_cursor_formats),
870 DRM_PLANE_TYPE_CURSOR,
871 "cursor %c", pipe_name(pipe));
878 if (DISPLAY_VER(dev_priv) >= 4)
879 drm_plane_create_rotation_property(&cursor->base,
882 DRM_MODE_ROTATE_180);
884 zpos = DISPLAY_RUNTIME_INFO(dev_priv)->num_sprites[pipe] + 1;
885 drm_plane_create_zpos_immutable_property(&cursor->base, zpos);
887 if (DISPLAY_VER(dev_priv) >= 12)
888 drm_plane_enable_fb_damage_clips(&cursor->base);
890 intel_plane_helper_add(cursor);
895 intel_plane_free(cursor);