if (DISPLAY_INFO(display)->cursor_needs_physical)
base = plane_state->phys_dma_addr; else
base = intel_plane_ggtt_offset(plane_state);
return base + plane_state->view.color_plane[0].offset;
}
static u32 intel_cursor_position(conststruct intel_crtc_state *crtc_state, conststruct intel_plane_state *plane_state, bool early_tpt)
{ int x = plane_state->uapi.dst.x1; int y = plane_state->uapi.dst.y1;
u32 pos = 0;
/* * Formula from Bspec: * MAX(-1 * <Cursor vertical size from CUR_CTL base on cursor mode * select setting> + 1, CUR_POS Y Position - Update region Y position
*/ if (early_tpt)
y = max(-1 * drm_rect_height(&plane_state->uapi.dst) + 1,
y - crtc_state->psr2_su_area.y1);
if (x < 0) {
pos |= CURSOR_POS_X_SIGN;
x = -x;
}
pos |= CURSOR_POS_X(x);
if (y < 0) {
pos |= CURSOR_POS_Y_SIGN;
y = -y;
}
pos |= CURSOR_POS_Y(y);
return pos;
}
staticbool intel_cursor_size_ok(conststruct intel_plane_state *plane_state)
{ conststruct drm_mode_config *config =
&plane_state->uapi.plane->dev->mode_config; int width = drm_rect_width(&plane_state->uapi.dst); int height = drm_rect_height(&plane_state->uapi.dst);
/* * Put the final coordinates back so that the src * coordinate checks will see the right values.
*/
drm_rect_translate_to(&plane_state->uapi.src,
src_x << 16, src_y << 16);
/* ILK+ do this automagically in hardware */ if (HAS_GMCH(display) && rotation & DRM_MODE_ROTATE_180) { conststruct drm_framebuffer *fb = plane_state->hw.fb; int src_w = drm_rect_width(&plane_state->uapi.src) >> 16; int src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
if (fb && fb->modifier != DRM_FORMAT_MOD_LINEAR) {
drm_dbg_kms(display->drm, "[PLANE:%d:%s] cursor cannot be tiled\n",
plane->base.base.id, plane->base.name); return -EINVAL;
}
ret = intel_plane_check_clipping(plane_state, crtc_state,
DRM_PLANE_NO_SCALING,
DRM_PLANE_NO_SCALING, true); if (ret) return ret;
/* Use the unclipped src/dst rectangles, which we program to hw */
plane_state->uapi.src = src;
plane_state->uapi.dst = dst;
/* final plane coordinates will be relative to the plane's pipe */
drm_rect_translate(&plane_state->uapi.dst,
-crtc_state->pipe_src.x1,
-crtc_state->pipe_src.y1);
ret = intel_cursor_check_surface(plane_state); if (ret) return ret;
if (!plane_state->uapi.visible) return 0;
ret = intel_plane_check_src_coordinates(plane_state); if (ret) return ret;
staticbool i845_cursor_size_ok(conststruct intel_plane_state *plane_state)
{ int width = drm_rect_width(&plane_state->uapi.dst);
/* * 845g/865g are only limited by the width of their cursors, * the height is arbitrary up to the precision of the register.
*/ return intel_cursor_size_ok(plane_state) && IS_ALIGNED(width, 64);
}
ret = intel_check_cursor(crtc_state, plane_state); if (ret) return ret;
/* if we want to turn off the cursor ignore width and height */ if (!fb) return 0;
/* Check for which cursor types we support */ if (!i845_cursor_size_ok(plane_state)) {
drm_dbg_kms(display->drm, "[PLANE:%d:%s] cursor dimension %dx%d not supported\n",
plane->base.base.id, plane->base.name,
drm_rect_width(&plane_state->uapi.dst),
drm_rect_height(&plane_state->uapi.dst)); return -EINVAL;
}
base = intel_cursor_base(plane_state);
pos = intel_cursor_position(crtc_state, plane_state, false);
}
/* On these chipsets we can only modify the base/size/stride * whilst the cursor is disabled.
*/ if (plane->cursor.base != base ||
plane->cursor.size != size ||
plane->cursor.cntl != cntl) {
intel_de_write_fw(display, CURCNTR(display, PIPE_A), 0);
intel_de_write_fw(display, CURBASE(display, PIPE_A), base);
intel_de_write_fw(display, CURSIZE(display, PIPE_A), size);
intel_de_write_fw(display, CURPOS(display, PIPE_A), pos);
intel_de_write_fw(display, CURCNTR(display, PIPE_A), cntl);
if (display->platform.sandybridge || display->platform.ivybridge)
cntl |= MCURSOR_TRICKLE_FEED_DISABLE;
switch (drm_rect_width(&plane_state->uapi.dst)) { case 64:
cntl |= MCURSOR_MODE_64_ARGB_AX; break; case 128:
cntl |= MCURSOR_MODE_128_ARGB_AX; break; case 256:
cntl |= MCURSOR_MODE_256_ARGB_AX; break; default:
MISSING_CASE(drm_rect_width(&plane_state->uapi.dst)); return 0;
}
if (plane_state->hw.rotation & DRM_MODE_ROTATE_180)
cntl |= MCURSOR_ROTATE_180;
/* Wa_22012358565:adl-p */ if (DISPLAY_VER(display) == 13)
cntl |= MCURSOR_ARB_SLOTS(1);
return cntl;
}
staticbool i9xx_cursor_size_ok(conststruct intel_plane_state *plane_state)
{ struct intel_display *display = to_intel_display(plane_state); int width = drm_rect_width(&plane_state->uapi.dst); int height = drm_rect_height(&plane_state->uapi.dst);
if (!intel_cursor_size_ok(plane_state)) returnfalse;
/* Cursor width is limited to a few power-of-two sizes */ switch (width) { case 256: case 128: case 64: break; default: returnfalse;
}
/* * IVB+ have CUR_FBC_CTL which allows an arbitrary cursor * height from 8 lines up to the cursor width, when the * cursor is not rotated. Everything else requires square * cursors.
*/ if (HAS_CUR_FBC(display) &&
plane_state->hw.rotation & DRM_MODE_ROTATE_0) { if (height < 8 || height > width) returnfalse;
} else { if (height != width) returnfalse;
}
ret = intel_check_cursor(crtc_state, plane_state); if (ret) return ret;
/* if we want to turn off the cursor ignore width and height */ if (!fb) return 0;
/* Check for which cursor types we support */ if (!i9xx_cursor_size_ok(plane_state)) {
drm_dbg_kms(display->drm, "[PLANE:%d:%s] cursor dimension %dx%d not supported\n",
plane->base.base.id, plane->base.name,
drm_rect_width(&plane_state->uapi.dst),
drm_rect_height(&plane_state->uapi.dst)); return -EINVAL;
}
/* * There's something wrong with the cursor on CHV pipe C. * If it straddles the left edge of the screen then * moving it away from the edge or disabling it often * results in a pipe underrun, and often that can lead to * dead pipe (constant underrun reported, and it scans * out just a solid color). To recover from that, the * display power well must be turned off and on again. * Refuse the put the cursor into that compromised position.
*/ if (display->platform.cherryview && pipe == PIPE_C &&
plane_state->uapi.visible && plane_state->uapi.dst.x1 < 0) {
drm_dbg_kms(display->drm, "[PLANE:%d:%s] cursor not allowed to straddle the left screen edge\n",
plane->base.base.id, plane->base.name); return -EINVAL;
}
if (drm_rect_height(&plane_state->psr2_sel_fetch_area) > 0) { if (crtc_state->enable_psr2_su_region_et) {
u32 val = intel_cursor_position(crtc_state, plane_state, true);
static u32 skl_cursor_wm_reg_val(conststruct skl_wm_level *level)
{
u32 val = 0;
if (level->enable)
val |= CUR_WM_EN; if (level->ignore_lines)
val |= CUR_WM_IGNORE_LINES;
val |= REG_FIELD_PREP(CUR_WM_BLOCKS_MASK, level->blocks);
val |= REG_FIELD_PREP(CUR_WM_LINES_MASK, level->lines);
if (plane_state && plane_state->uapi.visible) { int width = drm_rect_width(&plane_state->uapi.dst); int height = drm_rect_height(&plane_state->uapi.dst);
base = intel_cursor_base(plane_state);
pos = intel_cursor_position(crtc_state, plane_state, false);
}
/* * On some platforms writing CURCNTR first will also * cause CURPOS to be armed by the CURBASE write. * Without the CURCNTR write the CURPOS write would * arm itself. Thus we always update CURCNTR before * CURPOS. * * On other platforms CURPOS always requires the * CURBASE write to arm the update. Additionally * a write to any of the cursor register will cancel * an already armed cursor update. Thus leaving out * the CURBASE write after CURPOS could lead to a * cursor that doesn't appear to move, or even change * shape. Thus we always write CURBASE. * * The other registers are armed by the CURBASE write * except when the plane is getting enabled at which time * the CURCNTR write arms the update.
*/
if (DISPLAY_VER(display) >= 9)
skl_write_cursor_wm(dsb, plane, crtc_state);
if (plane_state)
i9xx_cursor_update_sel_fetch_arm(dsb, plane, crtc_state, plane_state); else
i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state);
/* * Not 100% correct for planes that can move between pipes, * but that's only the case for gen2-3 which don't have any * display power wells.
*/
power_domain = POWER_DOMAIN_PIPE(plane->pipe);
wakeref = intel_display_power_get_if_enabled(display, power_domain); if (!wakeref) returnfalse;
val = intel_de_read(display, CURCNTR(display, plane->pipe));
/* * When crtc is inactive or there is a modeset pending, * wait for it to complete in the slowpath. * PSR2 selective fetch also requires the slow path as * PSR2 plane and transcoder registers can only be updated during * vblank. * * FIXME joiner fastpath would be good
*/ if (!crtc_state->hw.active ||
intel_crtc_needs_modeset(crtc_state) ||
intel_crtc_needs_fastset(crtc_state) ||
crtc_state->joiner_pipes) goto slow;
/* * Don't do an async update if there is an outstanding commit modifying * the plane. This prevents our async update's changes from getting * overridden by a previous synchronous update's state.
*/ if (old_plane_state->uapi.commit &&
!try_wait_for_completion(&old_plane_state->uapi.commit->hw_done)) goto slow;
/* * If any parameters change that may affect watermarks, * take the slowpath. Only changing fb or position should be * in the fastpath.
*/ if (old_plane_state->uapi.crtc != &crtc->base ||
old_plane_state->uapi.src_w != src_w ||
old_plane_state->uapi.src_h != src_h ||
old_plane_state->uapi.crtc_w != crtc_w ||
old_plane_state->uapi.crtc_h != crtc_h ||
!old_plane_state->uapi.fb != !fb) goto slow;
new_plane_state = to_intel_plane_state(intel_plane_duplicate_state(&plane->base)); if (!new_plane_state) return -ENOMEM;
new_crtc_state = to_intel_crtc_state(intel_crtc_duplicate_state(&crtc->base)); if (!new_crtc_state) {
ret = -ENOMEM; goto out_free;
}
/* Swap plane state */
plane->base.state = &new_plane_state->uapi;
/* * We cannot swap crtc_state as it may be in use by an atomic commit or * page flip that's running simultaneously. If we swap crtc_state and * destroy the old state, we will cause a use-after-free there. * * Only update active_planes, which is needed for our internal * bookkeeping. Either value will do the right thing when updating * planes atomically. If the cursor was part of the atomic update then * we would have taken the slowpath.
*/
crtc_state->active_planes = new_crtc_state->active_planes;
if (!drm_WARN_ON(display->drm, drm_crtc_vblank_get(&crtc->base))) { /* * TODO: maybe check if we're still in PSR * and skip the vblank evasion entirely?
*/
intel_psr_wait_for_idle_locked(crtc_state);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.