Unify the function to calculate the link symbol cycles for both dsc and
non-dsc case and export the function so that it can be used in the
respective platform display drivers for other calculations.

v2: unify the fn for both dsc and non-dsc case (Imre)

Signed-off-by: Arun R Murthy <arun.r.mur...@intel.com>
---
 drivers/gpu/drm/display/drm_dp_helper.c | 47 ++++++++++++++++-----------------
 include/drm/display/drm_dp_helper.h     |  3 +++
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_dp_helper.c 
b/drivers/gpu/drm/display/drm_dp_helper.c
index 
57828f2b7b5a0582ca4a6f2a9be2d5909fe8ad24..1a5ff9ba6505f312ee41eb3bcc8b53d318411c03
 100644
--- a/drivers/gpu/drm/display/drm_dp_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_helper.c
@@ -4393,25 +4393,30 @@ EXPORT_SYMBOL(drm_panel_dp_aux_backlight);
 #endif
 
 /* See DP Standard v2.1 2.6.4.4.1.1, 2.8.4.4, 2.8.7 */
-static int drm_dp_link_symbol_cycles(int lane_count, int pixels, int bpp_x16,
-                                    int symbol_size, bool is_mst)
+/**
+ * drm_dp_link_symbol_cycles - calculate the link symbol count
+ * @lane_coount: DP link lane count
+ * @pixels: horizontal active pixels
+ * @bpp_x16: bits per pixel in .4 binary fixed format
+ * @symbol_size: DP symbol size
+ * @is_mst: is mst or sst
+ * @slice_count: number of slices
+ *
+ * Calculate the link symbol cycles for both dsc and non dsc case and
+ * return the count.
+ */
+int drm_dp_link_symbol_cycles(int lane_count, int pixels, int bpp_x16,
+                             int symbol_size, bool is_mst, int slice_count)
 {
-       int cycles = DIV_ROUND_UP(pixels * bpp_x16, 16 * symbol_size * 
lane_count);
+       int pix = slice_count ? DIV_ROUND_UP(pixels, slice_count) : pixels;
+       int cycles = DIV_ROUND_UP(pix * bpp_x16, 16 * symbol_size * lane_count);
        int align = is_mst ? 4 / lane_count : 1;
+       int slice_data_cycles = ALIGN(cycles, align);
 
-       return ALIGN(cycles, align);
-}
-
-static int drm_dp_link_dsc_symbol_cycles(int lane_count, int pixels, int 
slice_count,
-                                        int bpp_x16, int symbol_size, bool 
is_mst)
-{
-       int slice_pixels = DIV_ROUND_UP(pixels, slice_count);
-       int slice_data_cycles = drm_dp_link_symbol_cycles(lane_count, 
slice_pixels,
-                                                         bpp_x16, symbol_size, 
is_mst);
-       int slice_eoc_cycles = is_mst ? 4 / lane_count : 1;
-
-       return slice_count * (slice_data_cycles + slice_eoc_cycles);
+       return slice_count ? (slice_count * (slice_data_cycles + align)) :
+                            slice_data_cycles;
 }
+EXPORT_SYMBOL(drm_dp_link_symbol_cycles);
 
 /**
  * drm_dp_bw_overhead - Calculate the BW overhead of a DP link stream
@@ -4486,15 +4491,9 @@ int drm_dp_bw_overhead(int lane_count, int hactive,
        WARN_ON((flags & DRM_DP_BW_OVERHEAD_UHBR) &&
                (flags & DRM_DP_BW_OVERHEAD_FEC));
 
-       if (flags & DRM_DP_BW_OVERHEAD_DSC)
-               symbol_cycles = drm_dp_link_dsc_symbol_cycles(lane_count, 
hactive,
-                                                             dsc_slice_count,
-                                                             bpp_x16, 
symbol_size,
-                                                             is_mst);
-       else
-               symbol_cycles = drm_dp_link_symbol_cycles(lane_count, hactive,
-                                                         bpp_x16, symbol_size,
-                                                         is_mst);
+       symbol_cycles = drm_dp_link_symbol_cycles(lane_count, hactive,
+                                                 bpp_x16, symbol_size,
+                                                 is_mst, dsc_slice_count);
 
        return DIV_ROUND_UP_ULL(mul_u32_u32(symbol_cycles * symbol_size * 
lane_count,
                                            overhead * 16),
diff --git a/include/drm/display/drm_dp_helper.h 
b/include/drm/display/drm_dp_helper.h
index 
d9614e2c89397536f44bb7258e894628ae1dccc9..22ae37e7870f1008acfc980a9b46d8dea1fbbe10
 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -972,4 +972,7 @@ int drm_dp_max_dprx_data_rate(int max_link_rate, int 
max_lanes);
 
 ssize_t drm_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, struct dp_sdp 
*sdp);
 
+int drm_dp_link_symbol_cycles(int lane_count, int pixels, int bpp_x16,
+                             int symbol_size, bool is_mst, int slice_count);
+
 #endif /* _DRM_DP_HELPER_H_ */

-- 
2.25.1

Reply via email to