/** * DOC: atomic plane helpers * * The functions here are used by the atomic plane helper functions to * implement legacy plane updates (i.e., drm_plane->update_plane() and * drm_plane->disable_plane()). This allows plane updates to use the * atomic state infrastructure and perform plane updates as separate * prepare/check/commit/cleanup steps.
*/
/** * intel_plane_destroy - destroy a plane * @plane: plane to destroy * * Common destruction function for all types of planes (primary, cursor, * sprite).
*/ void intel_plane_destroy(struct drm_plane *plane)
{
drm_plane_cleanup(plane);
kfree(to_intel_plane(plane));
}
/** * intel_plane_duplicate_state - duplicate plane state * @plane: drm plane * * Allocates and returns a copy of the plane state (both common and * Intel-specific) for the specified plane. * * Returns: The newly allocated plane state, or NULL on failure.
*/ struct drm_plane_state *
intel_plane_duplicate_state(struct drm_plane *plane)
{ struct intel_plane_state *intel_state;
bool intel_plane_format_mod_supported_async(struct drm_plane *plane,
u32 format,
u64 modifier)
{ if (!plane->funcs->format_mod_supported(plane, format, modifier)) returnfalse;
return intel_plane_can_async_flip(to_intel_plane(plane),
format, modifier);
}
unsignedint intel_plane_pixel_rate(conststruct intel_crtc_state *crtc_state, conststruct intel_plane_state *plane_state)
{ /* * Note we don't check for plane visibility here as * we want to use this when calculating the cursor * watermarks even if the cursor is fully offscreen. * That depends on the src/dst rectangles being * correctly populated whenever the watermark code * considers the cursor to be visible, whether or not * it is actually visible. * * See: intel_wm_plane_visible() and intel_check_cursor()
*/
/* * Src coordinates are already rotated by 270 degrees for * the 90/270 degree plane rotation cases (to match the * GTT mapping), hence no need to account for rotation here.
*/
width = drm_rect_width(&plane_state->uapi.src) >> 16;
height = drm_rect_height(&plane_state->uapi.src) >> 16;
/* UV plane does 1/2 pixel sub-sampling */ if (color_plane == 1) {
width /= 2;
height /= 2;
}
/* * No need to check against the cdclk state if * the min cdclk for the plane doesn't increase. * * Ie. we only ever increase the cdclk due to plane * requirements. This can reduce back and forth * display blinking due to constant cdclk changes.
*/ if (new_crtc_state->min_cdclk[plane->id] <=
old_crtc_state->min_cdclk[plane->id]) return 0;
cdclk_state = intel_atomic_get_cdclk_state(state); if (IS_ERR(cdclk_state)) return PTR_ERR(cdclk_state);
/* * No need to recalculate the cdclk state if * the min cdclk for the pipe doesn't increase. * * Ie. we only ever increase the cdclk due to plane * requirements. This can reduce back and forth * display blinking due to constant cdclk changes.
*/ if (new_crtc_state->min_cdclk[plane->id] <=
intel_cdclk_min_cdclk(cdclk_state, crtc->pipe)) return 0;
/* damage property tracking enabled from display version 12 onwards */ if (DISPLAY_VER(display) < 12) return;
if (!drm_atomic_helper_damage_merged(&old_uapi_plane_state->uapi,
&new_uapi_plane_state->uapi,
damage)) /* Incase helper fails, mark whole plane region as damage */
*damage = drm_plane_state_src(&new_uapi_plane_state->uapi);
}
/* * For the joiner secondary uapi.crtc will point at * the primary crtc. So we explicitly assign the right * secondary crtc to hw.crtc. uapi.crtc!=NULL simply * indicates the plane is logically enabled on the uapi level.
*/
plane_state->hw.crtc = from_plane_state->uapi.crtc ? &crtc->base : NULL;
plane_state->hw.fb = from_plane_state->uapi.fb; if (plane_state->hw.fb)
drm_framebuffer_get(plane_state->hw.fb);
if (!new_crtc_state->uapi.async_flip) returnfalse;
/* * In platforms after DISPLAY13, we might need to override * first async flip in order to change watermark levels * as part of optimization. * * And let's do this for all skl+ so that we can eg. change the * modifier as well. * * TODO: For older platforms there is less reason to do this as * only X-tile is supported with async flips, though we could * extend this so other scanout parameters (stride/etc) could * be changed as well...
*/ return DISPLAY_VER(display) < 9 || old_crtc_state->uapi.async_flip;
}
/* Must disable CxSR around plane enable/disable */ if (turn_on || turn_off) returntrue;
if (!old_visible || !new_visible) returnfalse;
/* * Most plane control register updates are blocked while in CxSR. * * Tiling mode is one exception where the primary plane can * apparently handle it, whereas the sprites can not (the * sprite issue being only relevant on VLV/CHV where CxSR * is actually possible with a sprite enabled).
*/ if (plane->id == PLANE_PRIMARY) {
old_ctl &= ~DISP_TILED;
new_ctl &= ~DISP_TILED;
}
/* * ILK/SNB DVSACNTR/Sprite Enable * IVB SPR_CTL/Sprite Enable * "When in Self Refresh Big FIFO mode, a write to enable the * plane will be internally buffered and delayed while Big FIFO * mode is exiting." * * Which means that enabling the sprite can take an extra frame * when we start in big FIFO mode (LP1+). Thus we need to drop * down to LP0 and wait for vblank in order to make sure the * sprite gets enabled on the next vblank after the register write. * Doing otherwise would risk enabling the sprite one frame after * we've already signalled flip completion. We can resume LP1+ * once the sprite has been enabled. * * With experimental results seems this is needed also for primary * plane, not only sprite plane.
*/ if (turn_on) returntrue;
/* * WaCxSRDisabledForSpriteScaling:ivb * IVB SPR_SCALE/Scaling Enable * "Low Power watermarks must be disabled for at least one * frame before enabling sprite scaling, and kept disabled * until sprite scaling is disabled." * * ILK/SNB DVSASCALE/Scaling Enable * "When in Self Refresh Big FIFO mode, scaling enable will be * masked off while Big FIFO mode is exiting." * * Despite the w/a only being listed for IVB we assume that * the ILK/SNB note has similar ramifications, hence we apply * the w/a on all three platforms.
*/ return !intel_plane_is_scaled(old_plane_state) &&
intel_plane_is_scaled(new_plane_state);
}
if (!was_crtc_enabled && drm_WARN_ON(display->drm, was_visible))
was_visible = false;
/* * Visibility is calculated as if the crtc was on, but * after scaler setup everything depends on it being off * when the crtc isn't active. * * FIXME this is wrong for watermarks. Watermarks should also * be computed as if the pipe would be active. Perhaps move * per-plane wm computation to the .check_plane() hook, and * only combine the results from all planes in the current place?
*/ if (!is_crtc_enabled) {
intel_plane_set_invisible(new_crtc_state, new_plane_state);
visible = false;
}
if (intel_plane_do_async_flip(plane, old_crtc_state, new_crtc_state)) {
new_crtc_state->do_async_flip = true;
new_crtc_state->async_flip_planes |= BIT(plane->id);
} elseif (plane->need_async_flip_toggle_wa &&
new_crtc_state->uapi.async_flip) { /* * On platforms with double buffered async flip bit we * set the bit already one frame early during the sync * flip (see {i9xx,skl}_plane_update_arm()). The * hardware will therefore be ready to perform a real * async flip during the next commit, without having * to wait yet another frame for the bit to latch.
*/
new_crtc_state->async_flip_planes |= BIT(plane->id);
}
/* * Since we only write non-arming registers here, * the order does not matter even for skl+.
*/
for_each_new_intel_plane_in_state(state, plane, new_plane_state, i) { if (crtc->pipe != plane->pipe ||
!(update_mask & BIT(plane->id))) continue;
/* TODO: for mailbox updates this should be skipped */ if (new_plane_state->uapi.visible ||
new_plane_state->is_y_plane)
intel_plane_update_noarm(dsb, plane,
new_crtc_state, new_plane_state);
}
}
/* * TODO: for mailbox updates intel_plane_update_noarm() * would have to be called here as well.
*/ if (new_plane_state->uapi.visible ||
new_plane_state->is_y_plane)
intel_plane_update_arm(dsb, plane, new_crtc_state, new_plane_state); else
intel_plane_disable_arm(dsb, plane, new_crtc_state);
}
}
/* * TODO: for mailbox updates intel_plane_update_noarm() * would have to be called here as well.
*/ if (new_plane_state->uapi.visible)
intel_plane_update_arm(dsb, plane, new_crtc_state, new_plane_state); else
intel_plane_disable_arm(dsb, plane, new_crtc_state);
}
}
/* * FIXME: This might need further adjustment for seamless scaling * with phase information, for the 2p2 and 2p1 scenarios.
*/
plane_state->uapi.visible = drm_rect_clip_scaled(src, dst, clip);
/* * FIXME hsub/vsub vs. block size is a mess. Pre-tgl CCS * abuses hsub/vsub so we can't use them here. But as they * are limited to 32bpp RGB formats we don't actually need * to check anything.
*/ if (fb->modifier == I915_FORMAT_MOD_Y_TILED_CCS ||
fb->modifier == I915_FORMAT_MOD_Yf_TILED_CCS) return 0;
/* * Hardware doesn't handle subpixel coordinates. * Adjust to (macro)pixel boundary, but be careful not to * increase the source viewport size, because that could * push the downscaling factor out of bounds.
*/
src_x = src->x1 >> 16;
src_w = drm_rect_width(src) >> 16;
src_y = src->y1 >> 16;
src_h = drm_rect_height(src) >> 16;
/** * intel_prepare_plane_fb - Prepare fb for usage on plane * @_plane: drm plane to prepare for * @_new_plane_state: the plane state being prepared * * Prepares a framebuffer for usage on a display plane. Generally this * involves pinning the underlying object and updating the frontbuffer tracking * bits. Some older platforms need special physical address handling for * cursor planes. * * Returns 0 on success, negative error code on failure.
*/ staticint
intel_prepare_plane_fb(struct drm_plane *_plane, struct drm_plane_state *_new_plane_state)
{ struct i915_sched_attr attr = { .priority = I915_PRIORITY_DISPLAY }; struct intel_plane *plane = to_intel_plane(_plane); struct intel_display *display = to_intel_display(plane); struct intel_plane_state *new_plane_state =
to_intel_plane_state(_new_plane_state); struct intel_atomic_state *state =
to_intel_atomic_state(new_plane_state->uapi.state); struct intel_plane_state *old_plane_state =
intel_atomic_get_old_plane_state(state, plane); struct drm_gem_object *obj = intel_fb_bo(new_plane_state->hw.fb); struct drm_gem_object *old_obj = intel_fb_bo(old_plane_state->hw.fb); int ret;
if (old_obj) { conststruct intel_crtc_state *new_crtc_state =
intel_atomic_get_new_crtc_state(state,
to_intel_crtc(old_plane_state->hw.crtc));
/* Big Hammer, we also need to ensure that any pending * MI_WAIT_FOR_EVENT inside a user batch buffer on the * current scanout is retired before unpinning the old * framebuffer. Note that we rely on userspace rendering * into the buffer attached to the pipe they are waiting * on. If not, userspace generates a GPU hang with IPEHR * point to the MI_WAIT_FOR_EVENT. * * This should only fail upon a hung GPU, in which case we * can safely continue.
*/ if (intel_crtc_needs_modeset(new_crtc_state)) {
ret = add_dma_resv_fences(old_obj->resv,
&new_plane_state->uapi); if (ret < 0) return ret;
}
}
if (!obj) return 0;
ret = intel_plane_pin_fb(new_plane_state, old_plane_state); if (ret) return ret;
ret = drm_gem_plane_helper_prepare_fb(&plane->base, &new_plane_state->uapi); if (ret < 0) goto unpin_fb;
if (new_plane_state->uapi.fence) {
i915_gem_fence_wait_priority(new_plane_state->uapi.fence,
&attr);
/* * We declare pageflips to be interactive and so merit a small bias * towards upclocking to deliver the frame on time. By only changing * the RPS thresholds to sample more regularly and aim for higher * clocks we can hopefully deliver low power workloads (like kodi) * that are not quite steady state without resorting to forcing * maximum clocks following a vblank miss (see do_rps_boost()).
*/
intel_display_rps_mark_interactive(display, state, true);
return 0;
unpin_fb:
intel_plane_unpin_fb(new_plane_state);
return ret;
}
/** * intel_cleanup_plane_fb - Cleans up an fb after plane use * @plane: drm plane to clean up for * @_old_plane_state: the state from the previous modeset * * Cleans up a framebuffer that has just been removed from a plane.
*/ staticvoid
intel_cleanup_plane_fb(struct drm_plane *plane, struct drm_plane_state *_old_plane_state)
{ struct intel_display *display = to_intel_display(plane->dev); struct intel_plane_state *old_plane_state =
to_intel_plane_state(_old_plane_state); struct intel_atomic_state *state =
to_intel_atomic_state(old_plane_state->uapi.state); struct drm_gem_object *obj = intel_fb_bo(old_plane_state->hw.fb);
/* Handle Y-tiling, only if DPT is enabled (otherwise disabling tiling is easier) * All DPT hardware have 128-bytes width tiling, so Y-tile dimension is 32x32 * pixels for 32bits pixels.
*/ #define YTILE_WIDTH 32 #define YTILE_HEIGHT 32 #define YTILE_SIZE (YTILE_WIDTH * YTILE_HEIGHT * 4)
if (crtc_state->enable_psr2_sel_fetch) { /* Force a full update for psr2 */
intel_psr2_panic_force_full_update(display, crtc_state);
}
/* Flush the cache and don't disable tiling if it's the fbdev framebuffer.*/ if (intel_fb == intel_fbdev_framebuffer(display->fbdev.fbdev)) { struct iosys_map map;
if (fb->modifier && iplane->disable_tiling)
iplane->disable_tiling(iplane);
}
staticunsignedint (*intel_get_tiling_func(u64 fb_modifier))(unsignedint width, unsignedint x, unsignedint y)
{ switch (fb_modifier) { case I915_FORMAT_MOD_Y_TILED: case I915_FORMAT_MOD_Y_TILED_CCS: case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC: case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS: case I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS: return intel_ytile_get_offset; case I915_FORMAT_MOD_4_TILED: case I915_FORMAT_MOD_4_TILED_DG2_RC_CCS: case I915_FORMAT_MOD_4_TILED_DG2_MC_CCS: case I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC: case I915_FORMAT_MOD_4_TILED_MTL_RC_CCS: case I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC: case I915_FORMAT_MOD_4_TILED_MTL_MC_CCS: case I915_FORMAT_MOD_4_TILED_BMG_CCS: case I915_FORMAT_MOD_4_TILED_LNL_CCS: return intel_4tile_get_offset; case I915_FORMAT_MOD_X_TILED: case I915_FORMAT_MOD_Yf_TILED: case I915_FORMAT_MOD_Yf_TILED_CCS: default: /* Not supported yet */ return NULL;
}
}
if (intel_fb == intel_fbdev_framebuffer(display->fbdev.fbdev)) {
intel_fbdev_get_map(display->fbdev.fbdev, &sb->map[0]);
} else { int ret; /* Can't disable tiling if DPT is in use */ if (intel_fb_uses_dpt(fb)) { if (fb->format->cpp[0] != 4) return -EOPNOTSUPP;
intel_fb->panic_tiling = intel_get_tiling_func(fb->modifier); if (!intel_fb->panic_tiling) return -EOPNOTSUPP;
}
sb->private = intel_fb;
ret = intel_bo_panic_setup(sb); if (ret) return ret;
}
sb->width = fb->width;
sb->height = fb->height; /* Use the generic linear format, because tiling, RC, CCS, CC * will be disabled in disable_tiling()
*/
sb->format = drm_format_info(fb->format->format);
sb->pitch[0] = fb->pitches[0];
/* * Destroy all old plane links and make the Y plane invisible * in the crtc_state->active_planes mask.
*/
for_each_new_intel_plane_in_state(state, plane, plane_state, i) { if (plane->pipe != crtc->pipe) continue;
if (plane_state->planar_linked_plane)
unlink_nv12_plane(crtc_state, plane_state);
}
if ((crtc_state->nv12_planes & BIT(plane->id)) == 0) continue;
for_each_intel_plane_on_crtc(display->drm, crtc, y_plane) { if (!icl_is_nv12_y_plane(display, y_plane->id)) continue;
if (crtc_state->active_planes & BIT(y_plane->id)) continue;
y_plane_state = intel_atomic_get_plane_state(state, y_plane); if (IS_ERR(y_plane_state)) return PTR_ERR(y_plane_state);
break;
}
if (!y_plane_state) {
drm_dbg_kms(display->drm, "[CRTC:%d:%s] need %d free Y planes for planar YUV\n",
crtc->base.base.id, crtc->base.name,
hweight8(crtc_state->nv12_planes)); return -EINVAL;
}
/* * We want all the joined pipes to have the same * set of planes in the atomic state, to make sure * state copying always works correctly, and the * UV<->Y plane linkage is always up to date. * Keep pulling planes in until we've determined * the full set of affected planes. A bit complicated * on account of each pipe being capable of selecting * their own Y planes independently of the other pipes, * and the selection being done from the set of * inactive planes.
*/ do { struct intel_crtc *crtc;
for_each_intel_crtc_in_pipe_mask(state->base.dev, crtc, joined_pipes) { int ret;
ret = intel_crtc_add_planes_to_state(state, crtc, affected_planes); if (ret) return ret;
}
ret = icl_check_nv12_planes(state, crtc); if (ret) return ret;
/* * On some platforms the number of active planes affects * the planes' minimum cdclk calculation. Add such planes * to the state before we compute the minimum cdclk.
*/ if (!active_planes_affects_min_cdclk(display)) continue;
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.