From nobody Thu Nov 28 02:47:10 2024 Received: from mx.treblig.org (mx.treblig.org [46.235.229.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31CB114BF8A for ; Fri, 4 Oct 2024 22:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.229.95 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728082610; cv=none; b=XcT19Dynh/nsby1mnNvpT9ccCbEq8er+38hrPRxfLqcpZC0TVi7qtTf8wif5aCrrgcABXiqjFCZs5mmkIq2HonmrLXVz15ddcIvfu2QeQNx9oVgPY4VOkdJuYXnBTUiCbzXhmU4uB7q3ngdnmr4IZQtrgOweGcBFPYpkYWD21rI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728082610; c=relaxed/simple; bh=Insi0YGfQ88Vw355OVq2PkCxMwItARRGwB8n98yOyo8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=g1yz3/YoRbf6+94bGwJy1xw1H64iXYGHzgyxzDwzbRwscBTy4ECJ3ypbq0XIDNUNIqaIUngmVTHDNN77pZNfgIKVknS1QSd0u25l+WH+tlXwb2ViU2sdr7DzGJHkHYe9am4PbJEr+uZGc7YgxMzJVrBO1jzKxEAqVHSlQWAQQYI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=treblig.org; spf=pass smtp.mailfrom=treblig.org; dkim=pass (2048-bit key) header.d=treblig.org header.i=@treblig.org header.b=kiNgiya4; arc=none smtp.client-ip=46.235.229.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=treblig.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=treblig.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=treblig.org header.i=@treblig.org header.b="kiNgiya4" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=treblig.org ; s=bytemarkmx; h=MIME-Version:Message-ID:Date:Subject:From:Content-Type:From :Subject; bh=FN4JOMsiKWWAmejdS2L0j2XRB8TBUWM1mrrmECl6/d0=; b=kiNgiya4fZLu/PzQ 4NvTxWltAErUp1Mhhr6nxO6B6WvGjp5GL4aq0rcgfWcCQnsOhYYkmbkGxhJYVTZoNKu77e151ch3Q rnC9oB6gTCpaIHUs+Ls+Vs3azAMFgILib+hcIic/5x5a4B7drzWPIsc3Xcws0XKaX6hfBONyaOG0j DOiXxA2oKNUXI+iO6riy7++pxuWcUvzfuut5AEpjEXt4Tgw+CwLGB+TCGaJRc4KxzHiDo55FpOKSW H2zYXdsaTBsJ+wnT7tvTqCxF8l6zWIwl9ta+O5/mAJnTV4z0Gj87ZOH0OpfQxSLuUUaxVN+VQ4iqR SFQHekDM6pXK7XRkRg==; Received: from localhost ([127.0.0.1] helo=dalek.home.treblig.org) by mx.treblig.org with esmtp (Exim 4.96) (envelope-from ) id 1swrE3-0090pr-0H; Fri, 04 Oct 2024 22:56:43 +0000 From: linux@treblig.org To: harry.wentland@amd.com, sunpeng.li@amd.com, Rodrigo.Siqueira@amd.com, alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com Cc: airlied@gmail.com, simona@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, "Dr. David Alan Gilbert" Subject: [PATCH] drm/amd/display: Remove unused regamma functions Date: Fri, 4 Oct 2024 23:56:42 +0100 Message-ID: <20241004225642.280616-1-linux@treblig.org> X-Mailer: git-send-email 2.46.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" calculate_user_regamma_coeff() and calculate_user_regamma_ramp() were added in 2018 in commit 55a01d4023ce ("drm/amd/display: Add user_regamma to color module") but never used. Remove them and their helpers. Signed-off-by: Dr. David Alan Gilbert --- .../amd/display/modules/color/color_gamma.c | 307 ------------------ .../amd/display/modules/color/color_gamma.h | 11 - 2 files changed, 318 deletions(-) diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/driv= ers/gpu/drm/amd/display/modules/color/color_gamma.c index 3699e633801d..a71df052cf25 100644 --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c @@ -1399,71 +1399,6 @@ static void scale_gamma_dx(struct pwl_float_data *pw= l_rgb, pwl_rgb[i-1].b, 2), pwl_rgb[i-2].b); } =20 -/* todo: all these scale_gamma functions are inherently the same but - * take different structures as params or different format for ramp - * values. We could probably implement it in a more generic fashion - */ -static void scale_user_regamma_ramp(struct pwl_float_data *pwl_rgb, - const struct regamma_ramp *ramp, - struct dividers dividers) -{ - unsigned short max_driver =3D 0xFFFF; - unsigned short max_os =3D 0xFF00; - unsigned short scaler =3D max_os; - uint32_t i; - struct pwl_float_data *rgb =3D pwl_rgb; - struct pwl_float_data *rgb_last =3D rgb + GAMMA_RGB_256_ENTRIES - 1; - - i =3D 0; - do { - if (ramp->gamma[i] > max_os || - ramp->gamma[i + 256] > max_os || - ramp->gamma[i + 512] > max_os) { - scaler =3D max_driver; - break; - } - i++; - } while (i !=3D GAMMA_RGB_256_ENTRIES); - - i =3D 0; - do { - rgb->r =3D dc_fixpt_from_fraction( - ramp->gamma[i], scaler); - rgb->g =3D dc_fixpt_from_fraction( - ramp->gamma[i + 256], scaler); - rgb->b =3D dc_fixpt_from_fraction( - ramp->gamma[i + 512], scaler); - - ++rgb; - ++i; - } while (i !=3D GAMMA_RGB_256_ENTRIES); - - rgb->r =3D dc_fixpt_mul(rgb_last->r, - dividers.divider1); - rgb->g =3D dc_fixpt_mul(rgb_last->g, - dividers.divider1); - rgb->b =3D dc_fixpt_mul(rgb_last->b, - dividers.divider1); - - ++rgb; - - rgb->r =3D dc_fixpt_mul(rgb_last->r, - dividers.divider2); - rgb->g =3D dc_fixpt_mul(rgb_last->g, - dividers.divider2); - rgb->b =3D dc_fixpt_mul(rgb_last->b, - dividers.divider2); - - ++rgb; - - rgb->r =3D dc_fixpt_mul(rgb_last->r, - dividers.divider3); - rgb->g =3D dc_fixpt_mul(rgb_last->g, - dividers.divider3); - rgb->b =3D dc_fixpt_mul(rgb_last->b, - dividers.divider3); -} - /* * RS3+ color transform DDI - 1D LUT adjustment is composed with regamma h= ere * Input is evenly distributed in the output color space as specified in @@ -1663,106 +1598,6 @@ static bool calculate_interpolated_hardware_curve( return true; } =20 -/* The "old" interpolation uses a complicated scheme to build an array of - * coefficients while also using an array of 0-255 normalized to 0-1 - * Then there's another loop using both of the above + new scaled user ramp - * and we concatenate them. It also searches for points of interpolation a= nd - * uses enums for positions. - * - * This function uses a different approach: - * user ramp is always applied on X with 0/255, 1/255, 2/255, ..., 255/255 - * To find index for hwX , we notice the following: - * i/255 <=3D hwX < (i+1)/255 <=3D> i <=3D 255*hwX < i+1 - * See apply_lut_1d which is the same principle, but on 4K entry 1D LUT - * - * Once the index is known, combined Y is simply: - * user_ramp(index) + (hwX-index/255)*(user_ramp(index+1) - user_ramp(inde= x) - * - * We should switch to this method in all cases, it's simpler and faster - * ToDo one day - for now this only applies to ADL regamma to avoid regres= sion - * for regular use cases (sRGB and PQ) - */ -static void interpolate_user_regamma(uint32_t hw_points_num, - struct pwl_float_data *rgb_user, - bool apply_degamma, - struct dc_transfer_func_distributed_points *tf_pts) -{ - uint32_t i; - uint32_t color =3D 0; - int32_t index; - int32_t index_next; - struct fixed31_32 *tf_point; - struct fixed31_32 hw_x; - struct fixed31_32 norm_factor =3D - dc_fixpt_from_int(255); - struct fixed31_32 norm_x; - struct fixed31_32 index_f; - struct fixed31_32 lut1; - struct fixed31_32 lut2; - struct fixed31_32 delta_lut; - struct fixed31_32 delta_index; - const struct fixed31_32 one =3D dc_fixpt_from_int(1); - - i =3D 0; - /* fixed_pt library has problems handling too small values */ - while (i !=3D 32) { - tf_pts->red[i] =3D dc_fixpt_zero; - tf_pts->green[i] =3D dc_fixpt_zero; - tf_pts->blue[i] =3D dc_fixpt_zero; - ++i; - } - while (i <=3D hw_points_num + 1) { - for (color =3D 0; color < 3; color++) { - if (color =3D=3D 0) - tf_point =3D &tf_pts->red[i]; - else if (color =3D=3D 1) - tf_point =3D &tf_pts->green[i]; - else - tf_point =3D &tf_pts->blue[i]; - - if (apply_degamma) { - if (color =3D=3D 0) - hw_x =3D coordinates_x[i].regamma_y_red; - else if (color =3D=3D 1) - hw_x =3D coordinates_x[i].regamma_y_green; - else - hw_x =3D coordinates_x[i].regamma_y_blue; - } else - hw_x =3D coordinates_x[i].x; - - if (dc_fixpt_le(one, hw_x)) - hw_x =3D one; - - norm_x =3D dc_fixpt_mul(norm_factor, hw_x); - index =3D dc_fixpt_floor(norm_x); - if (index < 0 || index > 255) - continue; - - index_f =3D dc_fixpt_from_int(index); - index_next =3D (index =3D=3D 255) ? index : index + 1; - - if (color =3D=3D 0) { - lut1 =3D rgb_user[index].r; - lut2 =3D rgb_user[index_next].r; - } else if (color =3D=3D 1) { - lut1 =3D rgb_user[index].g; - lut2 =3D rgb_user[index_next].g; - } else { - lut1 =3D rgb_user[index].b; - lut2 =3D rgb_user[index_next].b; - } - - // we have everything now, so interpolate - delta_lut =3D dc_fixpt_sub(lut2, lut1); - delta_index =3D dc_fixpt_sub(norm_x, index_f); - - *tf_point =3D dc_fixpt_add(lut1, - dc_fixpt_mul(delta_index, delta_lut)); - } - ++i; - } -} - static void build_new_custom_resulted_curve( uint32_t hw_points_num, struct dc_transfer_func_distributed_points *tf_pts) @@ -1784,29 +1619,6 @@ static void build_new_custom_resulted_curve( } } =20 -static void apply_degamma_for_user_regamma(struct pwl_float_data_ex *rgb_r= egamma, - uint32_t hw_points_num, struct calculate_buffer *cal_buffer) -{ - uint32_t i; - - struct gamma_coefficients coeff; - struct pwl_float_data_ex *rgb =3D rgb_regamma; - const struct hw_x_point *coord_x =3D coordinates_x; - - build_coefficients(&coeff, TRANSFER_FUNCTION_SRGB); - - i =3D 0; - while (i !=3D hw_points_num + 1) { - rgb->r =3D translate_from_linear_space_ex( - coord_x->x, &coeff, 0, cal_buffer); - rgb->g =3D rgb->r; - rgb->b =3D rgb->r; - ++coord_x; - ++rgb; - ++i; - } -} - static bool map_regamma_hw_to_x_user( const struct dc_gamma *ramp, struct pixel_gamma_point *coeff128, @@ -1855,125 +1667,6 @@ static bool map_regamma_hw_to_x_user( =20 #define _EXTRA_POINTS 3 =20 -bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf, - const struct regamma_lut *regamma, - struct calculate_buffer *cal_buffer, - const struct dc_gamma *ramp) -{ - struct gamma_coefficients coeff; - const struct hw_x_point *coord_x =3D coordinates_x; - uint32_t i =3D 0; - - do { - coeff.a0[i] =3D dc_fixpt_from_fraction( - regamma->coeff.A0[i], 10000000); - coeff.a1[i] =3D dc_fixpt_from_fraction( - regamma->coeff.A1[i], 1000); - coeff.a2[i] =3D dc_fixpt_from_fraction( - regamma->coeff.A2[i], 1000); - coeff.a3[i] =3D dc_fixpt_from_fraction( - regamma->coeff.A3[i], 1000); - coeff.user_gamma[i] =3D dc_fixpt_from_fraction( - regamma->coeff.gamma[i], 1000); - - ++i; - } while (i !=3D 3); - - i =3D 0; - /* fixed_pt library has problems handling too small values */ - while (i !=3D 32) { - output_tf->tf_pts.red[i] =3D dc_fixpt_zero; - output_tf->tf_pts.green[i] =3D dc_fixpt_zero; - output_tf->tf_pts.blue[i] =3D dc_fixpt_zero; - ++coord_x; - ++i; - } - while (i !=3D MAX_HW_POINTS + 1) { - output_tf->tf_pts.red[i] =3D translate_from_linear_space_ex( - coord_x->x, &coeff, 0, cal_buffer); - output_tf->tf_pts.green[i] =3D translate_from_linear_space_ex( - coord_x->x, &coeff, 1, cal_buffer); - output_tf->tf_pts.blue[i] =3D translate_from_linear_space_ex( - coord_x->x, &coeff, 2, cal_buffer); - ++coord_x; - ++i; - } - - if (ramp && ramp->type =3D=3D GAMMA_CS_TFM_1D) - apply_lut_1d(ramp, MAX_HW_POINTS, &output_tf->tf_pts); - - // this function just clamps output to 0-1 - build_new_custom_resulted_curve(MAX_HW_POINTS, &output_tf->tf_pts); - output_tf->type =3D TF_TYPE_DISTRIBUTED_POINTS; - - return true; -} - -bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf, - const struct regamma_lut *regamma, - struct calculate_buffer *cal_buffer, - const struct dc_gamma *ramp) -{ - struct dc_transfer_func_distributed_points *tf_pts =3D &output_tf->tf_pts; - struct dividers dividers; - - struct pwl_float_data *rgb_user =3D NULL; - struct pwl_float_data_ex *rgb_regamma =3D NULL; - bool ret =3D false; - - if (regamma =3D=3D NULL) - return false; - - output_tf->type =3D TF_TYPE_DISTRIBUTED_POINTS; - - rgb_user =3D kcalloc(GAMMA_RGB_256_ENTRIES + _EXTRA_POINTS, - sizeof(*rgb_user), - GFP_KERNEL); - if (!rgb_user) - goto rgb_user_alloc_fail; - - rgb_regamma =3D kcalloc(MAX_HW_POINTS + _EXTRA_POINTS, - sizeof(*rgb_regamma), - GFP_KERNEL); - if (!rgb_regamma) - goto rgb_regamma_alloc_fail; - - dividers.divider1 =3D dc_fixpt_from_fraction(3, 2); - dividers.divider2 =3D dc_fixpt_from_int(2); - dividers.divider3 =3D dc_fixpt_from_fraction(5, 2); - - scale_user_regamma_ramp(rgb_user, ®amma->ramp, dividers); - - if (regamma->flags.bits.applyDegamma =3D=3D 1) { - apply_degamma_for_user_regamma(rgb_regamma, MAX_HW_POINTS, cal_buffer); - copy_rgb_regamma_to_coordinates_x(coordinates_x, - MAX_HW_POINTS, rgb_regamma); - } - - interpolate_user_regamma(MAX_HW_POINTS, rgb_user, - regamma->flags.bits.applyDegamma, tf_pts); - - // no custom HDR curves! - tf_pts->end_exponent =3D 0; - tf_pts->x_point_at_y1_red =3D 1; - tf_pts->x_point_at_y1_green =3D 1; - tf_pts->x_point_at_y1_blue =3D 1; - - if (ramp && ramp->type =3D=3D GAMMA_CS_TFM_1D) - apply_lut_1d(ramp, MAX_HW_POINTS, &output_tf->tf_pts); - - // this function just clamps output to 0-1 - build_new_custom_resulted_curve(MAX_HW_POINTS, tf_pts); - - ret =3D true; - - kfree(rgb_regamma); -rgb_regamma_alloc_fail: - kfree(rgb_user); -rgb_user_alloc_fail: - return ret; -} - bool mod_color_calculate_degamma_params(struct dc_color_caps *dc_caps, struct dc_transfer_func *input_tf, const struct dc_gamma *ramp, bool map_user_ramp) diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.h b/driv= ers/gpu/drm/amd/display/modules/color/color_gamma.h index ee5c466613de..97e55278940e 100644 --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.h +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.h @@ -115,15 +115,4 @@ bool mod_color_calculate_degamma_params(struct dc_colo= r_caps *dc_caps, struct dc_transfer_func *output_tf, const struct dc_gamma *ramp, bool mapUserRamp); =20 -bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf, - const struct regamma_lut *regamma, - struct calculate_buffer *cal_buffer, - const struct dc_gamma *ramp); - -bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf, - const struct regamma_lut *regamma, - struct calculate_buffer *cal_buffer, - const struct dc_gamma *ramp); - - #endif /* COLOR_MOD_COLOR_GAMMA_H_ */ --=20 2.46.2