Split out the SSC/REF_CLK and FEC margin part of the BW overhead from drm_dp_bw_overhead(), as it doesn't depend on the timings of the stream. This allows calculating the BW of a stream whose symbol alignment padding is accounted for by other means, for instance by an effective bpp.
Signed-off-by: Arun R Murthy <[email protected]> --- drivers/gpu/drm/display/drm_dp_helper.c | 86 +++++++++++++++++++++------------ include/drm/display/drm_dp_helper.h | 1 + 2 files changed, 57 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c index 488fd123a01adb7c063d14e3952370726a3b65d6..576c62c2268a684b2c370190249d537b070bf41a 100644 --- a/drivers/gpu/drm/display/drm_dp_helper.c +++ b/drivers/gpu/drm/display/drm_dp_helper.c @@ -4773,45 +4773,23 @@ int drm_dp_link_symbol_cycles(int lane_count, int pixels, int dsc_slice_count, EXPORT_SYMBOL(drm_dp_link_symbol_cycles); /** - * drm_dp_bw_overhead - Calculate the BW overhead of a DP link stream - * @lane_count: DP link lane count - * @hactive: pixel count of the active period in one scanline of the stream - * @dsc_slice_count: number of slices for DSC or '0' for non-DSC - * @bpp_x16: bits per pixel in .4 binary fixed point + * drm_dp_bw_margin_overhead - Calculate the margin BW overhead of a DP link stream * @flags: DRM_DP_OVERHEAD_x flags * - * Calculate the BW allocation overhead of a DP link stream, depending - * on the link's - * - @lane_count - * - SST/MST mode (@flags / %DRM_DP_OVERHEAD_MST) - * - symbol size (@flags / %DRM_DP_OVERHEAD_UHBR) + * Calculate the part of the BW allocation overhead of a DP link stream which + * only depends on the link's * - FEC mode (@flags / %DRM_DP_OVERHEAD_FEC) * - SSC/REF_CLK mode (@flags / %DRM_DP_OVERHEAD_SSC_REF_CLK) - * as well as the stream's - * - @hactive timing - * - @bpp_x16 color depth - * - compression mode (@dsc_slice_count != 0) - * Note that this overhead doesn't account for the 8b/10b, 128b/132b - * channel coding efficiency, for that see - * @drm_dp_link_bw_channel_coding_efficiency(). + * and not on the stream's timings, that is the overhead excluding the one + * from the symbol alignment padding calculated by drm_dp_bw_overhead(). This + * is useful if the symbol alignment is accounted for in another way, for + * instance by the stream's effective bpp. * * Returns the overhead as 100% + overhead% in 1ppm units. */ -int drm_dp_bw_overhead(int lane_count, int hactive, - int dsc_slice_count, - int bpp_x16, unsigned long flags) +int drm_dp_bw_margin_overhead(unsigned long flags) { - int symbol_size = flags & DRM_DP_BW_OVERHEAD_UHBR ? 32 : 8; - bool is_mst = flags & DRM_DP_BW_OVERHEAD_MST; u32 overhead = 1000000; - int symbol_cycles; - - if (lane_count == 0 || hactive == 0 || bpp_x16 == 0) { - DRM_DEBUG_KMS("Invalid BW overhead params: lane_count %d, hactive %d, bpp_x16 " FXP_Q4_FMT "\n", - lane_count, hactive, - FXP_Q4_ARGS(bpp_x16)); - return 0; - } /* * DP Standard v2.1 2.6.4.1 @@ -4845,6 +4823,54 @@ int drm_dp_bw_overhead(int lane_count, int hactive, WARN_ON((flags & DRM_DP_BW_OVERHEAD_UHBR) && (flags & DRM_DP_BW_OVERHEAD_FEC)); + return overhead; +} +EXPORT_SYMBOL(drm_dp_bw_margin_overhead); + +/** + * drm_dp_bw_overhead - Calculate the BW overhead of a DP link stream + * @lane_count: DP link lane count + * @hactive: pixel count of the active period in one scanline of the stream + * @dsc_slice_count: number of slices for DSC or '0' for non-DSC + * @bpp_x16: bits per pixel in .4 binary fixed point + * @flags: DRM_DP_OVERHEAD_x flags + * + * Calculate the BW allocation overhead of a DP link stream, depending + * on the link's + * - @lane_count + * - SST/MST mode (@flags / %DRM_DP_OVERHEAD_MST) + * - symbol size (@flags / %DRM_DP_OVERHEAD_UHBR) + * - FEC mode (@flags / %DRM_DP_OVERHEAD_FEC) + * - SSC/REF_CLK mode (@flags / %DRM_DP_OVERHEAD_SSC_REF_CLK) + * as well as the stream's + * - @hactive timing + * - @bpp_x16 color depth + * - compression mode (@dsc_slice_count != 0) + * Note that this overhead doesn't account for the 8b/10b, 128b/132b + * channel coding efficiency, for that see + * @drm_dp_link_bw_channel_coding_efficiency(). + * + * Returns the overhead as 100% + overhead% in 1ppm units. + */ +int drm_dp_bw_overhead(int lane_count, int hactive, + int dsc_slice_count, + int bpp_x16, unsigned long flags) +{ + int symbol_size = flags & DRM_DP_BW_OVERHEAD_UHBR ? 32 : 8; + bool is_mst = flags & DRM_DP_BW_OVERHEAD_MST; + u32 overhead; + int symbol_cycles; + + if (lane_count == 0 || hactive == 0 || bpp_x16 == 0) { + DRM_DEBUG_KMS("Invalid BW overhead params: lane_count %d, hactive %d, bpp_x16 " + FXP_Q4_FMT "\n", + lane_count, hactive, + FXP_Q4_ARGS(bpp_x16)); + return 0; + } + + overhead = drm_dp_bw_margin_overhead(flags); + symbol_cycles = drm_dp_link_symbol_cycles(lane_count, hactive, dsc_slice_count, bpp_x16, symbol_size, diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h index 5b05a7fbe174a6497bb98cab34dc3f5607233815..a568da6b249b52914c253a92d815e5a96fd773f5 100644 --- a/include/drm/display/drm_dp_helper.h +++ b/include/drm/display/drm_dp_helper.h @@ -1028,6 +1028,7 @@ int drm_dp_pcon_convert_rgb_to_ycbcr(struct drm_dp_aux *aux, u8 color_spc); #define DRM_DP_BW_OVERHEAD_FEC BIT(3) #define DRM_DP_BW_OVERHEAD_DSC BIT(4) +int drm_dp_bw_margin_overhead(unsigned long flags); int drm_dp_bw_overhead(int lane_count, int hactive, int dsc_slice_count, int bpp_x16, unsigned long flags); -- 2.25.1
