dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Alex Hung <alex.hung@amd.com>
To: Melissa Wen <mwen@igalia.com>
Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	wayland-devel@lists.freedesktop.org, harry.wentland@amd.com,
	leo.liu@amd.com, ville.syrjala@linux.intel.com,
	pekka.paalanen@collabora.com, contact@emersion.fr,
	jadahl@redhat.com, sebastian.wick@redhat.com,
	shashank.sharma@amd.com, agoins@nvidia.com, joshua@froggi.es,
	mdaenzer@redhat.com, aleixpol@kde.org, xaver.hugl@gmail.com,
	victoria@system76.com, daniel@ffwll.ch, uma.shankar@intel.com,
	quic_naseer@quicinc.com, quic_cbraga@quicinc.com,
	quic_abhinavk@quicinc.com, marcan@marcan.st, Liviu.Dudau@arm.com,
	sashamcintosh@google.com, chaitanya.kumar.borah@intel.com,
	louis.chauvet@bootlin.com, Daniel Stone <daniels@collabora.com>
Subject: Re: [PATCH V9 42/43] drm/amd/display: add 3D LUT colorop
Date: Mon, 12 May 2025 21:29:13 -0600	[thread overview]
Message-ID: <9ba6b83c-6c29-4149-aa71-bc9f0ea51a7a@amd.com> (raw)
In-Reply-To: <lyrpq2f7ypi7htircam6o4sd2yfxqnkn4zlre3lbh3ffsbtjcn@onpawcyobyvu>



On 5/12/25 18:52, Melissa Wen wrote:
> On 04/29, Alex Hung wrote:
>> This adds support for a 3D LUT.
>>
>> The color pipeline now consists of the following colorops:
>> 1. 1D curve colorop
>> 2. Multiplier
>> 3. 3x4 CTM
>> 4. 1D curve colorop
>> 5. 1D LUT
>> 6. 3D LUT
>> 7. 1D curve colorop
>> 8. 1D LUT
>>
>> Signed-off-by: Alex Hung <alex.hung@amd.com>
>> Reviewed-by: Daniel Stone <daniels@collabora.com>
>> ---
>> V9:
>>   - Return a value in __set_dm_plane_colorop_3dlut
>>
>> v8:
>>   - Set initialized to 0 and return when drm_lut3d_size is 0 (Harry Wentland)
>>   - Rework tf->type = TF_TYPE_BYPASS for shaper (Harry Wentland & Leo Li)
>>
>> v7:
>>   - Simplify 3D LUT according to drm_colorop changes (Simon Ser)
>>
>>   .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 94 +++++++++++++++++++
>>   .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 20 ++++
>>   2 files changed, 114 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
>> index 313716f2003f..dfdd3f557570 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
>> @@ -1293,6 +1293,7 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,
>>   	struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func;
>>   	const struct drm_color_lut *shaper_lut;
>>   	struct drm_device *dev = colorop->dev;
>> +	bool enabled = false;
>>   	uint32_t shaper_size;
>>   	int i = 0, ret = 0;
>>   
>> @@ -1314,6 +1315,7 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,
>>   		ret = __set_output_tf(tf, 0, 0, false);
>>   		if (ret)
>>   			return ret;
>> +		enabled = true;
>>   	}
>>   
>>   	/* 1D LUT - SHAPER LUT */
>> @@ -1345,12 +1347,93 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,
>>   			ret = __set_output_tf(tf, shaper_lut, shaper_size, false);
>>   			if (ret)
>>   				return ret;
>> +			enabled = true;
>>   		}
>>   	}
>>   
>> +	if (!enabled)
>> +		tf->type = TF_TYPE_BYPASS;
>> +
>>   	return 0;
>>   }
>>   
>> +/* __set_colorop_3dlut - set DRM 3D LUT to DC stream
>> + * @drm_lut3d: user 3D LUT
>> + * @drm_lut3d_size: size of 3D LUT
>> + * @lut3d: DC 3D LUT
>> + *
>> + * Map user 3D LUT data to DC 3D LUT and all necessary bits to program it
>> + * on DCN accordingly.
>> + */
>> +static void __set_colorop_3dlut(const struct drm_color_lut *drm_lut3d,
>> +				uint32_t drm_lut3d_size,
>> +				struct dc_3dlut *lut)
>> +{
>> +	if (!drm_lut3d_size) {
>> +		lut->state.bits.initialized = 0;
>> +		return;
>> +	}
>> +
>> +	/* Only supports 17x17x17 3D LUT (12-bit) now */
>> +	lut->lut_3d.use_12bits = true;
>> +	lut->lut_3d.use_tetrahedral_9 = false;
>> +
>> +	lut->state.bits.initialized = 1;
>> +	__drm_3dlut_to_dc_3dlut(drm_lut3d, drm_lut3d_size, &lut->lut_3d,
>> +				lut->lut_3d.use_tetrahedral_9, 12);
>> +
>> +}
>> +
>> +static int
>> +__set_dm_plane_colorop_3dlut(struct drm_plane_state *plane_state,
>> +			     struct dc_plane_state *dc_plane_state,
>> +			     struct drm_colorop *colorop)
>> +{
>> +	struct drm_colorop *old_colorop;
>> +	struct drm_colorop_state *colorop_state = NULL, *new_colorop_state;
>> +	struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func;
>> +	struct drm_atomic_state *state = plane_state->state;
>> +	const struct amdgpu_device *adev = drm_to_adev(colorop->dev);
>> +	const struct drm_device *dev = colorop->dev;
>> +	const struct drm_color_lut *lut3d;
>> +	uint32_t lut3d_size;
>> +	int i = 0, ret = 0;
>> +
>> +	/* 3D LUT */
>> +	old_colorop = colorop;
>> +	for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) {
>> +		if (new_colorop_state->colorop == old_colorop &&
>> +		    new_colorop_state->colorop->type == DRM_COLOROP_3D_LUT) {
>> +			colorop_state = new_colorop_state;
>> +			break;
>> +		}
>> +	}
>> +
>> +	if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_3D_LUT) {
>> +		if (!adev->dm.dc->caps.color.dpp.hw_3d_lut) {
> 
> I wonder if this check is no longer accurate in DCN versions with MCM
> (MPC only) 3D LUT caps, such as DCN 3.2 and DCN 4.01.

The current goal is to validate on specific fixed platforms. We will add 
more platform-specific implemenation when we enable this on new DCN 
hardware.

In some case, new hardware may have a different color pipeline. For 
example, there can be no DRM_COLOROP_3D_LUT colorop in a color pipeline, 
and it is not necessary to check DCN versions. In other cases, we will 
need to check different DCN versions or different flags for sure.

> 
> Also, looking back those patches that introduced shaper and blnd tf and
> luts, I don't see similar validation, but IIRC shaper caps directly
> depends on 3d lut, for example. IIRC something around blnd func caps
> also changed in the above-mentioned DCN versions.
> 
> Melissa
 > >> +			drm_dbg(dev, "3D LUT is not supported by hardware\n");
>> +			return -EINVAL;
>> +		}
>> +
>> +		drm_dbg(dev, "3D LUT colorop with ID: %d\n", colorop->base.id);
>> +		lut3d = __extract_blob_lut(colorop_state->data, &lut3d_size);
>> +		lut3d_size = lut3d != NULL ? lut3d_size : 0;
>> +		__set_colorop_3dlut(lut3d, lut3d_size, &dc_plane_state->lut3d_func);
>> +
>> +		/* 3D LUT requires shaper. If shaper colorop is bypassed, enable shaper curve
>> +		 * with TRANSFER_FUNCTION_LINEAR
>> +		 */
>> +		if (tf->type == TF_TYPE_BYPASS) {
>> +			tf->type = TF_TYPE_DISTRIBUTED_POINTS;
>> +			tf->tf = TRANSFER_FUNCTION_LINEAR;
>> +			tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE;
>> +			ret = __set_output_tf(tf, NULL, 0, false);
>> +		}

shaper / 3dlut dependency is checked here.

>> +	}
>> +
>> +	return ret;
>> +}
>> +
>>   static int
>>   __set_dm_plane_colorop_blend(struct drm_plane_state *plane_state,
>>   			     struct dc_plane_state *dc_plane_state,
>> @@ -1522,6 +1605,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
>>   	if (!colorop)
>>   		return -EINVAL;
>>   
>> +	/* 3D LUT */
>> +	colorop = colorop->next;
>> +	if (!colorop) {
>> +		drm_dbg(dev, "no 3D LUT colorop found\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	ret = __set_dm_plane_colorop_3dlut(plane_state, dc_plane_state, colorop);
>> +	if (ret)
>> +		return ret;
>> +
>>   	/* 1D Curve & LUT - BLND TF & LUT */
>>   	colorop = colorop->next;
>>   	if (!colorop) {
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
>> index 10b3e3906461..e90774294971 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
>> @@ -49,6 +49,8 @@ const u64 amdgpu_dm_supported_blnd_tfs =
>>   
>>   #define MAX_COLOR_PIPELINE_OPS 10
>>   
>> +#define LUT3D_SIZE		17
>> +
>>   int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
>>   {
>>   	struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
>> @@ -145,6 +147,24 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
>>   
>>   	i++;
>>   
>> +	/* 3D LUT */
>> +	ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
>> +	if (!ops[i]) {
>> +		DRM_ERROR("KMS: Failed to allocate colorop\n");
>> +		ret = -ENOMEM;
>> +		goto cleanup;
>> +	}
>> +
>> +	ret = drm_plane_colorop_3dlut_init(dev, ops[i], plane, LUT3D_SIZE,
>> +				     DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL,
>> +				     DRM_COLOROP_FLAG_ALLOW_BYPASS);
>> +	if (ret)
>> +		goto cleanup;
>> +
>> +	drm_colorop_set_next_property(ops[i-1], ops[i]);
>> +
>> +	i++;
>> +
>>   	/* 1D curve - BLND TF */
>>   	ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
>>   	if (!ops[i]) {
>> -- 
>> 2.43.0
>>


  reply	other threads:[~2025-05-13  3:29 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30  1:10 [PATCH V9 00/43] Color Pipeline API w/ VKMS Alex Hung
2025-04-30  1:10 ` [PATCH V9 01/43] drm: Add helper for conversion from signed-magnitude Alex Hung
2025-04-30  1:10 ` [PATCH V9 02/43] drm/vkms: Add kunit tests for VKMS LUT handling Alex Hung
2025-04-30  1:10 ` [PATCH V9 03/43] drm/doc/rfc: Describe why prescriptive color pipeline is needed Alex Hung
2025-05-15  9:30   ` Simon Ser
2025-04-30  1:10 ` [PATCH V9 04/43] drm/colorop: Introduce new drm_colorop mode object Alex Hung
2025-04-30  1:10 ` [PATCH V9 05/43] drm/colorop: Add TYPE property Alex Hung
2025-04-30  1:10 ` [PATCH V9 06/43] drm/colorop: Add 1D Curve subtype Alex Hung
2025-04-30  1:10 ` [PATCH V9 07/43] drm/colorop: Add BYPASS property Alex Hung
2025-04-30  1:10 ` [PATCH V9 08/43] drm/colorop: Add NEXT property Alex Hung
2025-04-30  1:10 ` [PATCH V9 09/43] drm/colorop: Add atomic state print for drm_colorop Alex Hung
2025-04-30  1:10 ` [PATCH V9 10/43] drm/plane: Add COLOR PIPELINE property Alex Hung
2025-04-30  1:10 ` [PATCH V9 11/43] drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE Alex Hung
2025-04-30  1:10 ` [PATCH V9 12/43] Documentation/gpu: document drm_colorop Alex Hung
2025-04-30  1:10 ` [PATCH V9 13/43] drm/colorop: Add destroy functions for color pipeline Alex Hung
2025-05-15  9:34   ` Simon Ser
2025-04-30  1:10 ` [PATCH V9 14/43] drm/vkms: Add enumerated 1D curve colorop Alex Hung
2025-04-30  1:10 ` [PATCH V9 15/43] drm/vkms: Add kunit tests for linear and sRGB LUTs Alex Hung
2025-05-07 10:03   ` kernel test robot
2025-04-30  1:10 ` [PATCH V9 16/43] drm/colorop: Add 3x4 CTM type Alex Hung
2025-06-16 11:30   ` Borah, Chaitanya Kumar
2025-06-16 13:32     ` Pekka Paalanen
2025-06-17  5:33       ` Borah, Chaitanya Kumar
2025-06-17 15:25         ` Ville Syrjälä
2025-04-30  1:10 ` [PATCH V9 17/43] drm/vkms: Use s32 for internal color pipeline precision Alex Hung
2025-04-30  1:10 ` [PATCH V9 18/43] drm/vkms: add 3x4 matrix in color pipeline Alex Hung
2025-04-30  1:10 ` [PATCH V9 19/43] drm/tests: Add a few tests around drm_fixed.h Alex Hung
2025-04-30  1:10 ` [PATCH V9 20/43] drm/vkms: Add tests for CTM handling Alex Hung
2025-04-30  1:10 ` [PATCH V9 21/43] drm/colorop: pass plane_color_pipeline client cap to atomic check Alex Hung
2025-04-30  1:10 ` [PATCH V9 22/43] drm/colorop: define a new macro for_each_new_colorop_in_state Alex Hung
2025-05-12 18:32   ` Melissa Wen
2025-04-30  1:10 ` [PATCH V9 23/43] drm/amd/display: Ignore deprecated props when plane_color_pipeline set Alex Hung
2025-04-30  1:10 ` [PATCH V9 24/43] drm/amd/display: Add bypass COLOR PIPELINE Alex Hung
2025-05-12 18:41   ` Melissa Wen
2025-04-30  1:10 ` [PATCH V9 25/43] drm/amd/display: Skip color pipeline initialization for cursor plane Alex Hung
2025-04-30  1:10 ` [PATCH V9 26/43] drm/amd/display: Add support for sRGB EOTF in DEGAM block Alex Hung
2025-05-12 18:50   ` Melissa Wen
2025-05-13  7:42     ` Pekka Paalanen
2025-05-13 15:36       ` Melissa Wen
2025-05-13 20:39         ` Harry Wentland
2025-05-15 10:57           ` Pekka Paalanen
2025-04-30  1:10 ` [PATCH V9 27/43] drm/amd/display: Add support for sRGB Inverse EOTF in SHAPER block Alex Hung
2025-04-30  1:10 ` [PATCH V9 28/43] drm/amd/display: Add support for sRGB EOTF in BLND block Alex Hung
2025-04-30  1:10 ` [PATCH V9 29/43] drm/colorop: Add PQ 125 EOTF and its inverse Alex Hung
2025-04-30  1:11 ` [PATCH V9 30/43] drm/amd/display: Enable support for PQ 125 EOTF and Inverse Alex Hung
2025-04-30  1:11 ` [PATCH V9 31/43] drm/colorop: add BT2020/BT709 OETF and Inverse OETF Alex Hung
2025-05-15  9:35   ` Simon Ser
2025-04-30  1:11 ` [PATCH V9 32/43] drm/amd/display: Add support for BT.709 and BT.2020 TFs Alex Hung
2025-05-12 19:37   ` Melissa Wen
2025-04-30  1:11 ` [PATCH V9 33/43] drm/colorop: Add 1D Curve Custom LUT type Alex Hung
2025-04-30  1:11 ` [PATCH V9 34/43] drm/amd/display: add shaper and blend colorops for 1D Curve Custom LUT Alex Hung
2025-04-30  1:11 ` [PATCH V9 35/43] drm/amd/display: add 3x4 matrix colorop Alex Hung
2025-05-07 12:08   ` kernel test robot
2025-04-30  1:11 ` [PATCH V9 36/43] drm/colorop: Add mutliplier type Alex Hung
2025-05-12 20:02   ` Melissa Wen
2025-04-30  1:11 ` [PATCH V9 37/43] drm/amd/display: add multiplier colorop Alex Hung
2025-04-30  1:11 ` [PATCH V9 38/43] drm/amd/display: Swap matrix and multiplier Alex Hung
2025-04-30  1:11 ` [PATCH V9 39/43] drm/colorop: Define LUT_1D interpolation Alex Hung
2025-04-30  1:11 ` [PATCH V9 40/43] drm/colorop: allow non-bypass colorops Alex Hung
2025-05-15  9:37   ` Simon Ser
2025-04-30  1:11 ` [PATCH V9 41/43] drm/colorop: Add 3D LUT support to color pipeline Alex Hung
2025-04-30  1:11 ` [PATCH V9 42/43] drm/amd/display: add 3D LUT colorop Alex Hung
2025-05-13  0:52   ` Melissa Wen
2025-05-13  3:29     ` Alex Hung [this message]
2025-05-13 15:52       ` Melissa Wen
2025-04-30  1:11 ` [PATCH V9 43/43] drm/amd/display: Add AMD color pipeline doc Alex Hung
2025-05-13 15:59 ` [PATCH V9 00/43] Color Pipeline API w/ VKMS Melissa Wen
2025-05-15  9:45 ` Simon Ser
2025-05-15 14:10   ` Harry Wentland
2025-05-15 14:15     ` Simon Ser
2025-05-15 17:19     ` Daniel Stone
2025-05-15 18:02       ` Harry Wentland
2025-05-15 18:39         ` Daniel Stone
2025-05-15 19:59           ` Leandro Ribeiro
2025-05-17 11:51             ` Xaver Hugl
2025-05-21 19:48               ` Harry Wentland
2025-05-22  7:57                 ` Pekka Paalanen
2025-05-22 13:28                   ` Harry Wentland
2025-05-22 13:49                     ` Simon Ser
2025-05-22 13:54                       ` Harry Wentland
2025-05-22 15:27                         ` Pekka Paalanen
2025-05-22 15:49                           ` Harry Wentland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ba6b83c-6c29-4149-aa71-bc9f0ea51a7a@amd.com \
    --to=alex.hung@amd.com \
    --cc=Liviu.Dudau@arm.com \
    --cc=agoins@nvidia.com \
    --cc=aleixpol@kde.org \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=chaitanya.kumar.borah@intel.com \
    --cc=contact@emersion.fr \
    --cc=daniel@ffwll.ch \
    --cc=daniels@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=jadahl@redhat.com \
    --cc=joshua@froggi.es \
    --cc=leo.liu@amd.com \
    --cc=louis.chauvet@bootlin.com \
    --cc=marcan@marcan.st \
    --cc=mdaenzer@redhat.com \
    --cc=mwen@igalia.com \
    --cc=pekka.paalanen@collabora.com \
    --cc=quic_abhinavk@quicinc.com \
    --cc=quic_cbraga@quicinc.com \
    --cc=quic_naseer@quicinc.com \
    --cc=sashamcintosh@google.com \
    --cc=sebastian.wick@redhat.com \
    --cc=shashank.sharma@amd.com \
    --cc=uma.shankar@intel.com \
    --cc=victoria@system76.com \
    --cc=ville.syrjala@linux.intel.com \
    --cc=wayland-devel@lists.freedesktop.org \
    --cc=xaver.hugl@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).