// SPDX-License-Identifier: MIT /* * Copyright 2022 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: AMD *
*/ #include <drm/drm_vblank.h> #include <drm/drm_atomic_helper.h>
/** * amdgpu_dm_crtc_set_panel_sr_feature() - Manage panel self-refresh features. * * @vblank_work: is a pointer to a struct vblank_control_work object. * @vblank_enabled: indicates whether the DRM vblank counter is currently * enabled (true) or disabled (false). * @allow_sr_entry: represents whether entry into the self-refresh mode is * allowed (true) or not allowed (false). * * The DRM vblank counter enable/disable action is used as the trigger to enable * or disable various panel self-refresh features: * * Panel Replay and PSR SU * - Enable when: * - VRR is disabled * - vblank counter is disabled * - entry is allowed: usermode demonstrates an adequate number of fast * commits) * - CRC capture window isn't active * - Keep enabled even when vblank counter gets enabled * * PSR1 * - Enable condition same as above * - Disable when vblank counter is enabled
*/ staticvoid amdgpu_dm_crtc_set_panel_sr_feature( struct vblank_control_work *vblank_work, bool vblank_enabled, bool allow_sr_entry)
{ struct dc_link *link = vblank_work->stream->link; bool is_sr_active = (link->replay_settings.replay_allow_active ||
link->psr_settings.psr_allow_active); bool is_crc_window_active = false; bool vrr_active = amdgpu_dm_crtc_vrr_active_irq(vblank_work->acrtc);
if (vblank_work->enable)
dm->active_vblank_irq_count++; elseif (dm->active_vblank_irq_count)
dm->active_vblank_irq_count--;
if (dm->active_vblank_irq_count > 0)
dc_allow_idle_optimizations(dm->dc, false);
/* * Control PSR based on vblank requirements from OS * * If panel supports PSR SU, there's no need to disable PSR when OS is * submitting fast atomic commits (we infer this by whether the OS * requests vblank events). Fast atomic commits will simply trigger a * full-frame-update (FFU); a specific case of selective-update (SU) * where the SU region is the full hactive*vactive region. See * fill_dc_dirty_rects().
*/ if (vblank_work->stream && vblank_work->stream->link && vblank_work->acrtc) {
amdgpu_dm_crtc_set_panel_sr_feature(
vblank_work, vblank_work->enable,
vblank_work->acrtc->dm_irq_params.allow_sr_entry);
}
if (dm->active_vblank_irq_count == 0) {
dc_post_update_surfaces_to_stream(dm->dc);
dc_allow_idle_optimizations(dm->dc, true);
}
/* * IPS & self-refresh feature can cause vblank counter resets between * vblank disable and enable. * It may cause system stuck due to waiting for the vblank counter. * Call this function to estimate missed vblanks by using timestamps and * update the vblank counter in DRM.
*/ if (dc->caps.ips_support &&
dc->config.disable_ips != DMUB_IPS_DISABLE_ALL &&
sr_supported && vblank->config.disable_immediate)
drm_crtc_vblank_restore(crtc);
}
if (dc_supports_vrr(dm->dc->ctx->dce_version)) { if (enable) { /* vblank irq on -> Only need vupdate irq in vrr mode */ if (amdgpu_dm_crtc_vrr_active(acrtc_state))
rc = amdgpu_dm_crtc_set_vupdate_irq(crtc, true);
} else { /* vblank irq off -> vupdate irq off */
rc = amdgpu_dm_crtc_set_vupdate_irq(crtc, false);
}
}
/* * hubp surface flip interrupt * * We have no guarantee that the frontend index maps to the same * backend index - some even map to more than one. * * TODO: Use a different interrupt or check DC itself for the mapping.
*/ if (enable) {
rc = amdgpu_irq_get(adev, &adev->pageflip_irq, irq_type);
drm_dbg_vbl(crtc->dev, "Get pageflip_irq ret=%d\n", rc);
} else {
rc = amdgpu_irq_put(adev, &adev->pageflip_irq, irq_type);
drm_dbg_vbl(crtc->dev, "Put pageflip_irq ret=%d\n", rc);
}
if (rc) return rc;
#ifdefined(CONFIG_DRM_AMD_SECURE_DISPLAY) /* crtc vline0 interrupt, only available on DCN+ */ if (amdgpu_ip_version(adev, DCE_HWIP, 0) != 0) { if (enable) {
rc = amdgpu_irq_get(adev, &adev->vline0_irq, irq_type);
drm_dbg_vbl(crtc->dev, "Get vline0_irq ret=%d\n", rc);
} else {
rc = amdgpu_irq_put(adev, &adev->vline0_irq, irq_type);
drm_dbg_vbl(crtc->dev, "Put vline0_irq ret=%d\n", rc);
}
if (rc) return rc;
} #endif
if (amdgpu_in_reset(adev)) return 0;
if (dm->vblank_control_workqueue) {
work = kzalloc(sizeof(*work), GFP_ATOMIC); if (!work) return -ENOMEM;
#ifdef AMD_PRIVATE_COLOR /** * dm_crtc_additional_color_mgmt - enable additional color properties * @crtc: DRM CRTC * * This function lets the driver enable post-blending CRTC regamma transfer * function property in addition to DRM CRTC gamma LUT. Default value means * linear transfer function, which is the default CRTC gamma LUT behaviour * without this property.
*/ staticvoid
dm_crtc_additional_color_mgmt(struct drm_crtc *crtc)
{ struct amdgpu_device *adev = drm_to_adev(crtc->dev);
if (adev->dm.dc->caps.color.mpc.ogam_ram)
drm_object_attach_property(&crtc->base,
adev->mode_info.regamma_tf_property,
AMDGPU_TRANSFER_FUNCTION_DEFAULT);
}
if (!new_plane_state) { /* * The plane is enable on the CRTC and hasn't changed * state. This means that it previously passed * validation and is therefore enabled.
*/
num_active += 1; continue;
}
/* We need a framebuffer to be considered enabled. */
num_active += (new_plane_state->fb != NULL);
}
if (WARN_ON(unlikely(!dm_crtc_state->stream &&
amdgpu_dm_crtc_modeset_required(crtc_state, NULL, dm_crtc_state->stream)))) { return ret;
}
/* * We require the primary plane to be enabled whenever the CRTC is, otherwise * drm_mode_cursor_universal may end up trying to enable the cursor plane while all other * planes are disabled, which is not supported by the hardware. And there is legacy * userspace which stops using the HW cursor altogether in response to the resulting EINVAL.
*/ if (crtc_state->enable &&
!(crtc_state->plane_mask & drm_plane_mask(crtc->primary))) {
DRM_DEBUG_ATOMIC("Can't enable a CRTC without enabling the primary plane\n"); return -EINVAL;
}
/* * Only allow async flips for fast updates that don't change the FB * pitch, the DCC state, rotation, etc.
*/ if (crtc_state->async_flip &&
dm_crtc_state->update_type != UPDATE_TYPE_FAST) {
drm_dbg_atomic(crtc->dev, "[CRTC:%d:%s] async flips are only supported for fast updates\n",
crtc->base.id, crtc->name); return -EINVAL;
}
if (!state->legacy_cursor_update && amdgpu_dm_crtc_vrr_active(dm_crtc_state)) { struct drm_plane_state *primary_state;
/* Pull in primary plane for correct VRR handling */
primary_state = drm_atomic_get_plane_state(state, crtc->primary); if (IS_ERR(primary_state)) return PTR_ERR(primary_state);
}
/* In some use cases, like reset, no stream is attached */ if (!dm_crtc_state->stream) return 0;
if (dc_validate_stream(dc, dm_crtc_state->stream) == DC_OK) return 0;
DRM_DEBUG_ATOMIC("Failed DC stream validation\n"); return ret;
}
/* Don't enable DRM CRTC degamma property for DCE since it doesn't * support programmable degamma anywhere.
*/
is_dcn = dm->adev->dm.dc->caps.color.dpp.dcn_arch; /* Dont't enable DRM CRTC degamma property for DCN401 since the * pre-blending degamma LUT doesn't apply to cursor, and therefore * can't work similar to a post-blending degamma LUT as in other hw * versions. * TODO: revisit it once KMS plane color API is merged.
*/
drm_crtc_enable_color_mgmt(&acrtc->base,
(is_dcn &&
dm->adev->dm.dc->ctx->dce_version != DCN_VERSION_4_01) ?
MAX_COLOR_LUT_ENTRIES : 0, true, MAX_COLOR_LUT_ENTRIES);
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.