dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Marijn Suijten <marijn.suijten@somainline.org>
To: phone-devel@vger.kernel.org, Rob Clark <robdclark@gmail.com>,
	Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	Vinod Koul <vkoul@kernel.org>
Cc: freedreno@lists.freedesktop.org,
	Douglas Anderson <dianders@chromium.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Jami Kettunen <jami.kettunen@somainline.org>,
	Vladimir Lypak <vladimir.lypak@gmail.com>,
	linux-arm-msm@vger.kernel.org,
	Konrad Dybcio <konrad.dybcio@somainline.org>,
	Abhinav Kumar <quic_abhinavk@quicinc.com>,
	dri-devel@lists.freedesktop.org,
	Javier Martinez Canillas <javierm@redhat.com>,
	David Airlie <airlied@linux.ie>,
	Martin Botka <martin.botka@somainline.org>,
	~postmarketos/upstreaming@lists.sr.ht,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@somainline.org>,
	Alex Deucher <alexander.deucher@amd.com>,
	Marijn Suijten <marijn.suijten@somainline.org>,
	Sean Paul <sean@poorly.run>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/7] drm/msm/dsi: Remove useless math in DSC calculations
Date: Wed,  5 Oct 2022 20:16:51 +0200	[thread overview]
Message-ID: <20221005181657.784375-2-marijn.suijten@somainline.org> (raw)
In-Reply-To: <20221005181657.784375-1-marijn.suijten@somainline.org>

Multiplying a value by 2 and adding 1 to it always results in a value
that is uneven, and that 1 gets truncated immediately when performing
integer division by 2 again.  There is no "rounding" possible here.

After that target_bpp_x16 is used to store a multiplication of
bits_per_pixel by 16 which is only ever read to immediately be divided
by 16 again, and is elided in much the same way.

Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
---
 drivers/gpu/drm/msm/dsi/dsi_host.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 8e4bc586c262..70077d1f0f21 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1784,7 +1784,6 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
 	int hrd_delay;
 	int pre_num_extra_mux_bits, num_extra_mux_bits;
 	int slice_bits;
-	int target_bpp_x16;
 	int data;
 	int final_value, final_scale;
 	int i;
@@ -1864,14 +1863,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
 	data = 2048 * (dsc->rc_model_size - dsc->initial_offset + num_extra_mux_bits);
 	dsc->slice_bpg_offset = DIV_ROUND_UP(data, groups_total);
 
-	/* bpp * 16 + 0.5 */
-	data = dsc->bits_per_pixel * 16;
-	data *= 2;
-	data++;
-	data /= 2;
-	target_bpp_x16 = data;
-
-	data = (dsc->initial_xmit_delay * target_bpp_x16) / 16;
+	data = dsc->initial_xmit_delay * dsc->bits_per_pixel;
 	final_value =  dsc->rc_model_size - data + num_extra_mux_bits;
 	dsc->final_offset = final_value;
 
-- 
2.38.0


  reply	other threads:[~2022-10-05 18:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 18:16 [PATCH v2 0/7] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
2022-10-05 18:16 ` Marijn Suijten [this message]
2022-10-05 21:14   ` [PATCH v2 1/7] drm/msm/dsi: Remove useless math in DSC calculations Abhinav Kumar
2022-10-05 18:16 ` [PATCH v2 2/7] drm/msm/dsi: Remove repeated calculation of slice_per_intf Marijn Suijten
2022-10-05 18:16 ` [PATCH v2 3/7] drm/msm/dsi: Use DIV_ROUND_UP instead of conditional increment on modulo Marijn Suijten
2022-10-05 21:34   ` Abhinav Kumar
2022-10-05 18:16 ` [PATCH v2 4/7] drm/msm/dsi: Reuse earlier computed dsc->slice_chunk_size Marijn Suijten
2022-10-05 21:37   ` Abhinav Kumar
2022-10-05 18:16 ` [PATCH v2 5/7] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits Marijn Suijten
2022-10-05 19:31   ` Dmitry Baryshkov
2022-10-05 20:58     ` Marijn Suijten
2022-10-05 21:06       ` Dmitry Baryshkov
2022-10-05 21:08       ` Marijn Suijten
2022-10-05 21:11         ` Dmitry Baryshkov
2022-10-05 21:33           ` Marijn Suijten
2022-10-05 18:16 ` [PATCH v2 6/7] drm/msm/dpu1: " Marijn Suijten
2022-10-05 18:16 ` [PATCH v2 7/7] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits Marijn Suijten

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=20221005181657.784375-2-marijn.suijten@somainline.org \
    --to=marijn.suijten@somainline.org \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=angelogioacchino.delregno@somainline.org \
    --cc=dianders@chromium.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jami.kettunen@somainline.org \
    --cc=javierm@redhat.com \
    --cc=konrad.dybcio@somainline.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.botka@somainline.org \
    --cc=phone-devel@vger.kernel.org \
    --cc=quic_abhinavk@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=sean@poorly.run \
    --cc=tzimmermann@suse.de \
    --cc=vkoul@kernel.org \
    --cc=vladimir.lypak@gmail.com \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /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).