[PATCH 2/2] drm/amd/display: Move fixpt_from_s3132 to amdgpu_dm
Alex Deucher
alexdeucher at gmail.com
Wed Jan 3 14:42:22 UTC 2024
On Thu, Dec 21, 2023 at 3:50 PM Harry Wentland <harry.wentland at amd.com> wrote:
>
> Other environments don't like the unary minus operator on
> an unsigned value.
>
> Signed-off-by: Harry Wentland <harry.wentland at amd.com>
Series is:
Acked-by: Alex Deucher <alexander.deucher at amd.com>
> ---
> .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 18 +++++++++++++++---
> .../gpu/drm/amd/display/include/fixed31_32.h | 12 ------------
> 2 files changed, 15 insertions(+), 15 deletions(-)
>
> 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 36bf65a8cd6e..9b527bffe11a 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
> @@ -85,6 +85,18 @@ void amdgpu_dm_init_color_mod(void)
> setup_x_points_distribution();
> }
>
> +static inline struct fixed31_32 amdgpu_dm_fixpt_from_s3132(__u64 x)
> +{
> + struct fixed31_32 val;
> +
> + /* If negative, convert to 2's complement. */
> + if (x & (1ULL << 63))
> + x = -(x & ~(1ULL << 63));
> +
> + val.value = x;
> + return val;
> +}
> +
> #ifdef AMD_PRIVATE_COLOR
> /* Pre-defined Transfer Functions (TF)
> *
> @@ -430,7 +442,7 @@ static void __drm_ctm_to_dc_matrix(const struct drm_color_ctm *ctm,
> }
>
> /* gamut_remap_matrix[i] = ctm[i - floor(i/4)] */
> - matrix[i] = dc_fixpt_from_s3132(ctm->matrix[i - (i / 4)]);
> + matrix[i] = amdgpu_dm_fixpt_from_s3132(ctm->matrix[i - (i / 4)]);
> }
> }
>
> @@ -452,7 +464,7 @@ static void __drm_ctm_3x4_to_dc_matrix(const struct drm_color_ctm_3x4 *ctm,
> */
> for (i = 0; i < 12; i++) {
> /* gamut_remap_matrix[i] = ctm[i - floor(i/4)] */
> - matrix[i] = dc_fixpt_from_s3132(ctm->matrix[i]);
> + matrix[i] = amdgpu_dm_fixpt_from_s3132(ctm->matrix[i]);
> }
> }
>
> @@ -1136,7 +1148,7 @@ amdgpu_dm_plane_set_color_properties(struct drm_plane_state *plane_state,
> uint32_t shaper_size, lut3d_size, blend_size;
> int ret;
>
> - dc_plane_state->hdr_mult = dc_fixpt_from_s3132(dm_plane_state->hdr_mult);
> + dc_plane_state->hdr_mult = amdgpu_dm_fixpt_from_s3132(dm_plane_state->hdr_mult);
>
> shaper_lut = __extract_blob_lut(dm_plane_state->shaper_lut, &shaper_size);
> shaper_size = shaper_lut != NULL ? shaper_size : 0;
> diff --git a/drivers/gpu/drm/amd/display/include/fixed31_32.h b/drivers/gpu/drm/amd/display/include/fixed31_32.h
> index 84da1dd34efd..d4cf7ead1d87 100644
> --- a/drivers/gpu/drm/amd/display/include/fixed31_32.h
> +++ b/drivers/gpu/drm/amd/display/include/fixed31_32.h
> @@ -69,18 +69,6 @@ static const struct fixed31_32 dc_fixpt_epsilon = { 1LL };
> static const struct fixed31_32 dc_fixpt_half = { 0x80000000LL };
> static const struct fixed31_32 dc_fixpt_one = { 0x100000000LL };
>
> -static inline struct fixed31_32 dc_fixpt_from_s3132(__u64 x)
> -{
> - struct fixed31_32 val;
> -
> - /* If negative, convert to 2's complement. */
> - if (x & (1ULL << 63))
> - x = -(x & ~(1ULL << 63));
> -
> - val.value = x;
> - return val;
> -}
> -
> /*
> * @brief
> * Initialization routines
> --
> 2.43.0
>
More information about the amd-gfx
mailing list