On 2018-02-27 05:34 AM, Michel Dänzer wrote:
On 2018-02-26 09:15 PM, Harry Wentland wrote:
From: "Leo (Sunpeng) Li" <sunpeng...@amd.com>

Non-legacy LUT size should reflect hw capability. Change size from 256
to 4096.

However, X doesn't seem to play with legacy LUTs of such size.
Therefore, check for legacy lut when updating DC states, and update
accordingly.

v2: Use a macro for the maximum drm LUT value.

Signed-off-by: Leo (Sunpeng) Li <sunpeng...@amd.com>
Reviewed-by: Harry Wentland <harry.wentl...@amd.com>
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |  2 +-
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h  |  4 +-
  .../drm/amd/display/amdgpu_dm/amdgpu_dm_color.c    | 77 ++++++++++++++++------
  3 files changed, 61 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index bb9405daa087..f782518fc424 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3228,7 +3228,7 @@ static int amdgpu_dm_crtc_init(struct 
amdgpu_display_manager *dm,
        dm->adev->mode_info.crtcs[crtc_index] = acrtc;
        drm_crtc_enable_color_mgmt(&acrtc->base, MAX_COLOR_LUT_ENTRIES,
                                   true, MAX_COLOR_LUT_ENTRIES);
-       drm_mode_crtc_set_gamma_size(&acrtc->base, MAX_COLOR_LUT_ENTRIES);
+       drm_mode_crtc_set_gamma_size(&acrtc->base, 
MAX_COLOR_LEGACY_LUT_ENTRIES);

This means userspace can't set gamma ramps with more than 256 entries,
since drm_mode_gamma_set_ioctl returns an error if the sizes don't
match. We should just fix userspace which tries to use the wrong size.

It seems X hard-codes 256 entries for the legacy lut, ignoring what the
kernel requests:

xf86CrtcCreate in xserver/hw/xfree86/modes/xf86Crtc.c (~line 120):

/* Preallocate gamma at a sensible size. */
crtc->gamma_size = 256;


I confirmed this as well via a printk on the user LUT size in
drm_mode_gamma_set_ioctl (after reverting to 4096 gamma size, of course).

I'm not sure if modifying that line in X will be straightforward. It's
worth noting that drm_mode_crtc_set_gamma_size() only sets the legacy
gamma size. Non-legacy gamma (de/regamma) sizes are reported via a mode
property, and does not conflict with legacy size. Therefore, reporting a
different size for legacy shouldn't be an issue, AFAIK; as long as we
check the DRM lut size and update DC accordingly, which we're doing.

Leo



_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to