Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2257679rwb; Wed, 5 Oct 2022 11:19:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7kPsfWM+1xKoSNJTUA9UYH5wkVO8Kf0Uo6IGVR/kP8E7VrpP0rATi3GQifZ7CdmvUamZnn X-Received: by 2002:a17:906:58cb:b0:787:8485:8555 with SMTP id e11-20020a17090658cb00b0078784858555mr709006ejs.252.1664993986248; Wed, 05 Oct 2022 11:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664993986; cv=none; d=google.com; s=arc-20160816; b=TiaM7FsKf5cZ7dG06/l4YEVuRbI0945Cm6Kj4EPQ+qIwhigWPQw3kF692r9xE2msAG X3ARPeeQyJ4IWWjsA8xu5TBRFeQmeXowz0ABLeaD8aum6h7BbkYGXdFFj4FQPHWhc5hh /v6hJQxwdh3xrXxFhTep+yjB+dvVz7ON8S6VM8YrAmoRXhwahoi0+yxxXTakd82Mokg2 n2RWtJILfCXBW2lhu4qbChbt0fqBA9D5NnJCWKn3fDo9VYXowMqReicpD1+8Qo9BU8Et xBPZY9RNd/ujTujDMZkmOQaVwKlenBYapzPGjiyA5yXp1zNEFMHFCK6DyrTTM+A9Ux2p Uusg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=srA5DW8UbvnAbPywu4YZQLdBOqFfKUn/jIYPioWHZzg=; b=xYuLU3nBZyjHoCZJflih3mbTw7xmOZ6WTwKXkkvnX6mpOm4hEF/BOIjibXPDD3RKLh A6QXs2Mj37AGl1siClIeXoashqkth2lS9dWAKDWvVcq3KnUffGdDPqhfIFMV+ELhymUW F1Az5VjJHD8JK8EboKtopm2egKOO7jseLDsyikkfN78tw+O5i6I/Ytq45vvnuYnm/JBc EY+9vpdNwEItiC+vzlhG6X/lM7vKzpbRc79Iq2p0IWZn6QGEY1bMjwY17cT+c3jk9sTN cvpel7gimUec52hhtRNXoFL2Y4xguAWube8MLbkPJjDIq53/YJZdDjh6GZ1Gw58QOdy/ vFfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020a170906974300b00787f71033b9si15440003ejy.802.2022.10.05.11.19.17; Wed, 05 Oct 2022 11:19:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230415AbiJESRU (ORCPT + 99 others); Wed, 5 Oct 2022 14:17:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230231AbiJESRO (ORCPT ); Wed, 5 Oct 2022 14:17:14 -0400 Received: from relay06.th.seeweb.it (relay06.th.seeweb.it [IPv6:2001:4b7a:2000:18::167]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C74684E85C for ; Wed, 5 Oct 2022 11:17:13 -0700 (PDT) Received: from localhost.localdomain (94-209-172-39.cable.dynamic.v4.ziggo.nl [94.209.172.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r2.th.seeweb.it (Postfix) with ESMTPSA id D57D83F63B; Wed, 5 Oct 2022 20:17:10 +0200 (CEST) From: Marijn Suijten To: phone-devel@vger.kernel.org, Rob Clark , Dmitry Baryshkov , Vinod Koul Cc: ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Marijn Suijten , Daniel Vetter , Abhinav Kumar , Sean Paul , Thomas Zimmermann , Javier Martinez Canillas , Alex Deucher , Douglas Anderson , Vladimir Lypak , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, David Airlie Subject: [PATCH v2 1/7] drm/msm/dsi: Remove useless math in DSC calculations Date: Wed, 5 Oct 2022 20:16:51 +0200 Message-Id: <20221005181657.784375-2-marijn.suijten@somainline.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221005181657.784375-1-marijn.suijten@somainline.org> References: <20221005181657.784375-1-marijn.suijten@somainline.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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