dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Kuogee Hsieh <quic_khsieh@quicinc.com>
To: <dri-devel@lists.freedesktop.org>, <robdclark@gmail.com>,
	<sean@poorly.run>, <swboyd@chromium.org>, <dianders@chromium.org>,
	<vkoul@kernel.org>, <daniel@ffwll.ch>, <airlied@gmail.com>,
	<agross@kernel.org>, <dmitry.baryshkov@linaro.org>,
	<andersson@kernel.org>
Cc: quic_sbillaka@quicinc.com, linux-arm-msm@vger.kernel.org,
	quic_abhinavk@quicinc.com, linux-kernel@vger.kernel.org,
	Kuogee Hsieh <quic_khsieh@quicinc.com>,
	freedreno@lists.freedesktop.org
Subject: [PATCH v1 02/14] drm/msm/dp: add dsc factor into calculation of supported bpp
Date: Mon, 23 Jan 2023 10:24:22 -0800	[thread overview]
Message-ID: <1674498274-6010-3-git-send-email-quic_khsieh@quicinc.com> (raw)
In-Reply-To: <1674498274-6010-1-git-send-email-quic_khsieh@quicinc.com>

When FEC enabled, it introduces 2.5% overhead into link capacity.
This factor have to be considered into calculation supported bpp.

Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
---
 drivers/gpu/drm/msm/dp/dp_panel.c | 45 +++++++++++++++++++++++++++++++++------
 1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c b/drivers/gpu/drm/msm/dp/dp_panel.c
index 5078247..36dad05 100644
--- a/drivers/gpu/drm/msm/dp/dp_panel.c
+++ b/drivers/gpu/drm/msm/dp/dp_panel.c
@@ -11,7 +11,7 @@
 #include <drm/drm_edid.h>
 #include <drm/drm_print.h>
 
-#define DSC_TGT_BPP 8
+#define DSC_TGT_BPP 10
 
 struct dp_panel_private {
 	struct device *dev;
@@ -122,20 +122,51 @@ static u32 dp_panel_get_supported_bpp(struct dp_panel *dp_panel,
 		u32 mode_edid_bpp, u32 mode_pclk_khz)
 {
 	struct dp_link_info *link_info;
-	const u32 max_supported_bpp = 30, min_supported_bpp = 18;
-	u32 bpp = 0, data_rate_khz = 0;
+	struct dp_panel_private *panel;
+	const u32 max_supported_bpp = 30;
+	u32 min_supported_bpp = 18;
+	u32 bpp = 0, link_bitrate = 0, mode_bitrate;
+	s64 rate_fp = 0;
+
+	panel = container_of(dp_panel, struct dp_panel_private, dp_panel);
+
+	if (dp_panel->dsc_en)
+		min_supported_bpp = 24;
 
 	bpp = min_t(u32, mode_edid_bpp, max_supported_bpp);
 
 	link_info = &dp_panel->link_info;
-	data_rate_khz = link_info->num_lanes * link_info->rate * 8;
 
-	while (bpp > min_supported_bpp) {
-		if (mode_pclk_khz * bpp <= data_rate_khz)
+	rate_fp = drm_int2fixp(link_info->num_lanes * link_info->rate * 8);
+
+	if (dp_panel->fec_en)
+		rate_fp = drm_fixp_div(rate_fp, dp_panel->fec_overhead_fp);
+
+	link_bitrate = drm_fixp2int(rate_fp);
+
+	for (; bpp > min_supported_bpp; bpp -= 6) {
+		if (dp_panel->dsc_en) {
+			if (bpp == 30 && !(dp_panel->sink_dsc_caps.color_depth & DP_DSC_10_BPC))
+				continue;
+			else if (bpp == 24 && !(dp_panel->sink_dsc_caps.color_depth & DP_DSC_8_BPC))
+				continue;
+
+			mode_bitrate = mode_pclk_khz * DSC_TGT_BPP;
+		} else {
+			mode_bitrate = mode_pclk_khz * bpp;
+		}
+
+		if (mode_bitrate <= link_bitrate)
 			break;
-		bpp -= 6;
 	}
 
+	if (bpp < min_supported_bpp)
+		DRM_ERROR("bpp %d is below minimum supported bpp %d\n", bpp,
+				min_supported_bpp);
+
+	if (dp_panel->dsc_en && bpp != 24 && bpp != 30 && bpp != 36)
+		DRM_ERROR("bpp %d is not supported when dsc is enabled\n", bpp);
+
 	return bpp;
 }
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


  parent reply	other threads:[~2023-01-23 18:25 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-23 18:24 [PATCH v1 00/14] add display port DSC feature Kuogee Hsieh
2023-01-23 18:24 ` [PATCH v1 01/14] drm/msm/dp: add dpcd read of both dsc and fec capability Kuogee Hsieh
2023-01-23 22:17   ` Dmitry Baryshkov
2023-01-23 18:24 ` Kuogee Hsieh [this message]
2023-01-23 23:38   ` [PATCH v1 02/14] drm/msm/dp: add dsc factor into calculation of supported bpp kernel test robot
2023-01-23 18:24 ` [PATCH v1 03/14] drm/msm/dp: add configure mainlink_levels base on lane number Kuogee Hsieh
2023-01-23 22:34   ` Dmitry Baryshkov
2023-01-23 18:24 ` [PATCH v1 04/14] drm/msm/dp: correct configure Colorimetry Indicator Field at MISC0 Kuogee Hsieh
2023-01-23 22:41   ` Dmitry Baryshkov
2023-01-24  0:49   ` kernel test robot
2023-01-23 18:24 ` [PATCH v1 05/14] drm/msm/dp: upgrade tu calculation base on newest algorithm Kuogee Hsieh
2023-01-23 23:56   ` Dmitry Baryshkov
2023-01-24  0:08   ` kernel test robot
2023-01-23 18:24 ` [PATCH v1 06/14] drm/msm/dp: add display compression related struct Kuogee Hsieh
2023-01-23 22:46   ` Dmitry Baryshkov
2023-01-24 15:15   ` Neil Armstrong
2023-01-23 18:24 ` [PATCH v1 07/14] drm/msm/dp: add dsc helper functions Kuogee Hsieh
2023-01-23 22:02   ` Dmitry Baryshkov
2023-01-23 22:08   ` Marijn Suijten
2023-01-23 18:24 ` [PATCH v1 08/14] drm/msm/dp: add dsc supporting functions to DP controller Kuogee Hsieh
2023-01-23 22:30   ` Dmitry Baryshkov
2023-01-23 18:24 ` [PATCH v1 09/14] drm/msm/dsi: export struct msm_compression_info to dpu encoder Kuogee Hsieh
2023-01-23 22:06   ` Dmitry Baryshkov
2023-01-24 15:06   ` Neil Armstrong
2023-01-30 20:27   ` Marijn Suijten
2023-01-23 18:24 ` [PATCH v1 10/14] drm/msm/disp/dpu: add supports of DSC encoder v1.2 engine Kuogee Hsieh
2023-01-23 20:11   ` Marijn Suijten
2023-01-24 23:52     ` Kuogee Hsieh
2023-01-30 20:16       ` Marijn Suijten
2023-01-30 21:22         ` Abhinav Kumar
2023-01-30 22:31           ` Marijn Suijten
2023-01-30 22:39             ` Abhinav Kumar
2023-01-24  7:44   ` Dmitry Baryshkov
2023-01-24 15:18   ` Neil Armstrong
2023-01-23 18:24 ` [PATCH v1 11/14] drm/msm/disp/dpu1: add supports of new flush mechanism Kuogee Hsieh
2023-01-23 21:43   ` Dmitry Baryshkov
2023-01-23 18:24 ` [PATCH v1 12/14] drm/msm/disp/dpu1: revise timing engine programming to work for DSC Kuogee Hsieh
2023-01-23 21:39   ` Dmitry Baryshkov
2023-01-24  9:11   ` Dmitry Baryshkov
2023-01-24 17:55     ` Kuogee Hsieh
2023-01-24 21:37       ` Dmitry Baryshkov
2023-01-24 23:36       ` Marijn Suijten
2023-01-25  9:08         ` Neil Armstrong
2023-01-23 18:24 ` [PATCH v1 13/14] drm/msm/disp/dpu1: add dsc supporting functions to dpu encoder Kuogee Hsieh
2023-01-25  9:01   ` Neil Armstrong
2023-01-23 18:24 ` [PATCH v1 14/14] drm/msm/disp/dpu1: add sc7280 dsc block and sub block Kuogee Hsieh
2023-01-23 20:19   ` Marijn Suijten
2023-01-23 18:34 ` [PATCH v1 00/14] add display port DSC feature Marijn Suijten
2023-01-24  0:10 ` Dmitry Baryshkov
2023-01-25  0:28 ` Abhinav Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1674498274-6010-3-git-send-email-quic_khsieh@quicinc.com \
    --to=quic_khsieh@quicinc.com \
    --cc=agross@kernel.org \
    --cc=airlied@gmail.com \
    --cc=andersson@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=dianders@chromium.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_abhinavk@quicinc.com \
    --cc=quic_sbillaka@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=sean@poorly.run \
    --cc=swboyd@chromium.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).