]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: Move DSC functions from dc.c to dc_dsc.c
authorWenjing Liu <wenjing.liu@amd.com>
Tue, 11 Apr 2023 00:00:46 +0000 (20:00 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 20 May 2024 20:19:08 +0000 (16:19 -0400)
Move dsc functions from dc.c to dc_dsc.c.

Co-developed-by: George Shen <george.shen@amd.com>
Signed-off-by: George Shen <george.shen@amd.com>
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c

index 0208b28517ac6630370ab339306efe0c8c262bab..6f534c2e76b7dded2a97766a65977ae2dc96afbe 100644 (file)
@@ -5979,102 +5979,3 @@ struct dc_power_profile dc_get_power_profile_for_dc_state(const struct dc_state
 
        return profile;
 }
-
-/* Need to account for padding due to pixel-to-symbol packing
- * for uncompressed 128b/132b streams.
- */
-static uint32_t apply_128b_132b_stream_overhead(
-       const struct dc_crtc_timing *timing, const uint32_t kbps)
-{
-       uint32_t total_kbps = kbps;
-#if defined(CONFIG_DRM_AMD_DC_FP)
-       if (dc_get_disable_128b_132b_stream_overhead())
-               return kbps;
-#endif
-
-       if (!timing->flags.DSC) {
-               struct fixed31_32 bpp;
-               struct fixed31_32 overhead_factor;
-
-               bpp = dc_fixpt_from_int(kbps);
-               bpp = dc_fixpt_div_int(bpp, timing->pix_clk_100hz / 10);
-
-               /* Symbols_per_HActive = HActive * bpp / (4 lanes * 32-bit symbol size)
-                * Overhead_factor = ceil(Symbols_per_HActive) / Symbols_per_HActive
-                */
-               overhead_factor = dc_fixpt_from_int(timing->h_addressable);
-               overhead_factor = dc_fixpt_mul(overhead_factor, bpp);
-               overhead_factor = dc_fixpt_div_int(overhead_factor, 128);
-               overhead_factor = dc_fixpt_div(
-                       dc_fixpt_from_int(dc_fixpt_ceil(overhead_factor)),
-                       overhead_factor);
-
-               total_kbps = dc_fixpt_ceil(
-                       dc_fixpt_mul_int(overhead_factor, total_kbps));
-       }
-
-       return total_kbps;
-}
-
-uint32_t dc_bandwidth_in_kbps_from_timing(
-       const struct dc_crtc_timing *timing,
-       const enum dc_link_encoding_format link_encoding)
-{
-       uint32_t bits_per_channel = 0;
-       uint32_t kbps;
-
-#if defined(CONFIG_DRM_AMD_DC_FP)
-       if (timing->flags.DSC)
-               return dc_dsc_stream_bandwidth_in_kbps(timing,
-                               timing->dsc_cfg.bits_per_pixel,
-                               timing->dsc_cfg.num_slices_h,
-                               timing->dsc_cfg.is_dp);
-#endif
-
-       switch (timing->display_color_depth) {
-       case COLOR_DEPTH_666:
-               bits_per_channel = 6;
-               break;
-       case COLOR_DEPTH_888:
-               bits_per_channel = 8;
-               break;
-       case COLOR_DEPTH_101010:
-               bits_per_channel = 10;
-               break;
-       case COLOR_DEPTH_121212:
-               bits_per_channel = 12;
-               break;
-       case COLOR_DEPTH_141414:
-               bits_per_channel = 14;
-               break;
-       case COLOR_DEPTH_161616:
-               bits_per_channel = 16;
-               break;
-       default:
-               ASSERT(bits_per_channel != 0);
-               bits_per_channel = 8;
-               break;
-       }
-
-       kbps = timing->pix_clk_100hz / 10;
-       kbps *= bits_per_channel;
-
-       if (timing->flags.Y_ONLY != 1) {
-               /*Only YOnly make reduce bandwidth by 1/3 compares to RGB*/
-               kbps *= 3;
-               if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR420)
-                       kbps /= 2;
-               else if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR422)
-                       kbps = kbps * 2 / 3;
-       }
-
-       if (link_encoding == DC_LINK_ENCODING_DP_128b_132b)
-               kbps = apply_128b_132b_stream_overhead(timing, kbps);
-
-       if (link_encoding == DC_LINK_ENCODING_HDMI_FRL &&
-                       timing->vic == 0 && timing->hdmi_vic == 0 &&
-                       timing->frl_uncompressed_video_bandwidth_in_kbps != 0)
-               kbps = timing->frl_uncompressed_video_bandwidth_in_kbps;
-
-       return kbps;
-}
index dd7091628b3c7a9df2b694323f30e7fa654f7a81..b9d10e95ef7a51ab90293c4dd75694b475644204 100644 (file)
@@ -49,6 +49,102 @@ static bool disable_128b_132b_stream_overhead;
 #define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
 #endif
 
+/* Need to account for padding due to pixel-to-symbol packing
+ * for uncompressed 128b/132b streams.
+ */
+static uint32_t apply_128b_132b_stream_overhead(
+       const struct dc_crtc_timing *timing, const uint32_t kbps)
+{
+       uint32_t total_kbps = kbps;
+
+       if (disable_128b_132b_stream_overhead)
+               return kbps;
+
+       if (!timing->flags.DSC) {
+               struct fixed31_32 bpp;
+               struct fixed31_32 overhead_factor;
+
+               bpp = dc_fixpt_from_int(kbps);
+               bpp = dc_fixpt_div_int(bpp, timing->pix_clk_100hz / 10);
+
+               /* Symbols_per_HActive = HActive * bpp / (4 lanes * 32-bit symbol size)
+                * Overhead_factor = ceil(Symbols_per_HActive) / Symbols_per_HActive
+                */
+               overhead_factor = dc_fixpt_from_int(timing->h_addressable);
+               overhead_factor = dc_fixpt_mul(overhead_factor, bpp);
+               overhead_factor = dc_fixpt_div_int(overhead_factor, 128);
+               overhead_factor = dc_fixpt_div(
+                       dc_fixpt_from_int(dc_fixpt_ceil(overhead_factor)),
+                       overhead_factor);
+
+               total_kbps = dc_fixpt_ceil(
+                       dc_fixpt_mul_int(overhead_factor, total_kbps));
+       }
+
+       return total_kbps;
+}
+
+uint32_t dc_bandwidth_in_kbps_from_timing(
+       const struct dc_crtc_timing *timing,
+       const enum dc_link_encoding_format link_encoding)
+{
+       uint32_t bits_per_channel = 0;
+       uint32_t kbps;
+
+       if (timing->flags.DSC)
+               return dc_dsc_stream_bandwidth_in_kbps(timing,
+                               timing->dsc_cfg.bits_per_pixel,
+                               timing->dsc_cfg.num_slices_h,
+                               timing->dsc_cfg.is_dp);
+
+       switch (timing->display_color_depth) {
+       case COLOR_DEPTH_666:
+               bits_per_channel = 6;
+               break;
+       case COLOR_DEPTH_888:
+               bits_per_channel = 8;
+               break;
+       case COLOR_DEPTH_101010:
+               bits_per_channel = 10;
+               break;
+       case COLOR_DEPTH_121212:
+               bits_per_channel = 12;
+               break;
+       case COLOR_DEPTH_141414:
+               bits_per_channel = 14;
+               break;
+       case COLOR_DEPTH_161616:
+               bits_per_channel = 16;
+               break;
+       default:
+               ASSERT(bits_per_channel != 0);
+               bits_per_channel = 8;
+               break;
+       }
+
+       kbps = timing->pix_clk_100hz / 10;
+       kbps *= bits_per_channel;
+
+       if (timing->flags.Y_ONLY != 1) {
+               /*Only YOnly make reduce bandwidth by 1/3 compares to RGB*/
+               kbps *= 3;
+               if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR420)
+                       kbps /= 2;
+               else if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR422)
+                       kbps = kbps * 2 / 3;
+       }
+
+       if (link_encoding == DC_LINK_ENCODING_DP_128b_132b)
+               kbps = apply_128b_132b_stream_overhead(timing, kbps);
+
+       if (link_encoding == DC_LINK_ENCODING_HDMI_FRL &&
+                       timing->vic == 0 && timing->hdmi_vic == 0 &&
+                       timing->frl_uncompressed_video_bandwidth_in_kbps != 0)
+               kbps = timing->frl_uncompressed_video_bandwidth_in_kbps;
+
+       return kbps;
+}
+
 /* Forward Declerations */
 static bool decide_dsc_bandwidth_range(
                const uint32_t min_bpp_x16,