Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amd/display: Use overlay cursor when color pipeline is active

Force overlay cursor mode when an underlying plane has a non-bypassed
color pipeline to avoid incorrect cursor transformation.

Reviewed-by: Sun peng (Leo) Li <sunpeng.li@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Alex Hung and committed by
Alex Deucher
d3a549f4 82f510ae

+49 -4
+49 -4
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 95 95 #include <drm/drm_utils.h> 96 96 #include <drm/drm_vblank.h> 97 97 #include <drm/drm_audio_component.h> 98 + #include <drm/drm_colorop.h> 98 99 #include <drm/drm_gem_atomic_helper.h> 99 100 100 101 #include <media/cec-notifier.h> ··· 12340 12339 */ 12341 12340 12342 12341 /** 12342 + * dm_plane_color_pipeline_active() - Check if a plane's color pipeline active. 12343 + * @state: DRM atomic state 12344 + * @plane: DRM plane to check 12345 + * @use_old: if true, inspect the old colorop states; otherwise the new ones 12346 + * 12347 + * A color pipeline may be selected (color_pipeline != NULL) but still is 12348 + * inactive if every colorop in the chain is bypassed. Only return 12349 + * true when at least one colorop has bypass == false, meaning the cursor 12350 + * would be subjected to the transformation in native mode. 12351 + * 12352 + * Return: true if the pipeline modifies pixels, false otherwise. 12353 + */ 12354 + static bool dm_plane_color_pipeline_active(struct drm_atomic_state *state, 12355 + struct drm_plane *plane, 12356 + bool use_old) 12357 + { 12358 + struct drm_colorop *colorop; 12359 + struct drm_colorop_state *old_colorop_state, *new_colorop_state; 12360 + int i; 12361 + 12362 + for_each_oldnew_colorop_in_state(state, colorop, old_colorop_state, new_colorop_state, i) { 12363 + struct drm_colorop_state *cstate = use_old ? old_colorop_state : new_colorop_state; 12364 + 12365 + if (cstate->colorop->plane != plane) 12366 + continue; 12367 + if (!cstate->bypass) 12368 + return true; 12369 + } 12370 + return false; 12371 + } 12372 + 12373 + /** 12343 12374 * dm_crtc_get_cursor_mode() - Determine the required cursor mode on crtc 12344 12375 * @adev: amdgpu device 12345 12376 * @state: DRM atomic state ··· 12382 12349 * the dm_crtc_state. 12383 12350 * 12384 12351 * The cursor should be enabled in overlay mode if there exists an underlying 12385 - * plane - on which the cursor may be blended - that is either YUV formatted, or 12386 - * scaled differently from the cursor. 12352 + * plane - on which the cursor may be blended - that is either YUV formatted, 12353 + * scaled differently from the cursor, or has a color pipeline active. 12387 12354 * 12388 12355 * Since zpos info is required, drm_atomic_normalize_zpos must be called before 12389 12356 * calling this function. ··· 12421 12388 12422 12389 /* 12423 12390 * Cursor mode can change if a plane's format changes, scale changes, is 12424 - * enabled/disabled, or z-order changes. 12391 + * enabled/disabled, z-order changes, or color management properties change. 12425 12392 */ 12426 12393 for_each_oldnew_plane_in_state(state, plane, old_plane_state, plane_state, i) { 12427 12394 int new_scale_w, new_scale_h, old_scale_w, old_scale_h; ··· 12443 12410 dm_get_plane_scale(plane_state, &new_scale_w, &new_scale_h); 12444 12411 dm_get_plane_scale(old_plane_state, &old_scale_w, &old_scale_h); 12445 12412 if (new_scale_w != old_scale_w || new_scale_h != old_scale_h) { 12413 + consider_mode_change = true; 12414 + break; 12415 + } 12416 + 12417 + if (dm_plane_color_pipeline_active(state, plane, true) != 12418 + dm_plane_color_pipeline_active(state, plane, false)) { 12446 12419 consider_mode_change = true; 12447 12420 break; 12448 12421 } ··· 12488 12449 12489 12450 /* Underlying plane is YUV format - use overlay cursor */ 12490 12451 if (amdgpu_dm_plane_is_video_format(plane_state->fb->format->format)) { 12452 + *cursor_mode = DM_CURSOR_OVERLAY_MODE; 12453 + return 0; 12454 + } 12455 + 12456 + /* Underlying plane has an active color pipeline - cursor would be transformed */ 12457 + if (dm_plane_color_pipeline_active(state, plane, false)) { 12491 12458 *cursor_mode = DM_CURSOR_OVERLAY_MODE; 12492 12459 return 0; 12493 12460 } ··· 12877 12832 goto fail; 12878 12833 } else if (required_cursor_mode == DM_CURSOR_OVERLAY_MODE) { 12879 12834 drm_dbg_driver(crtc->dev, 12880 - "[CRTC:%d:%s] Cannot enable native cursor due to scaling or YUV restrictions\n", 12835 + "[CRTC:%d:%s] Cannot enable native cursor due to scaling, YUV, or color pipeline restrictions\n", 12881 12836 crtc->base.id, crtc->name); 12882 12837 ret = -EINVAL; 12883 12838 goto fail;