Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2258320rwb; Wed, 5 Oct 2022 11:20:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AovlIgJMMqfsByfrP4Ne+V/vh3bRpmhGdtOIirq+rxbowAk0T3tDR9t5Q7Ypm5HRt9r0V X-Received: by 2002:a17:907:6e1d:b0:78d:17df:5e39 with SMTP id sd29-20020a1709076e1d00b0078d17df5e39mr662058ejc.601.1664994026625; Wed, 05 Oct 2022 11:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664994026; cv=none; d=google.com; s=arc-20160816; b=RXogXbE3li8nx5unG8JQ278JQkxqaYro9t8ChTMSiFaLsY9KEXMrdNf/1Z0YnhJikU WRVZIuQ7KO5xhLPvmwSKfOGGXJvXJtGMGaxNCQ51JDwI7SLH+m0Nw6ut2PflOyGluv12 Ztt/x88holEBzU0V1hLAAWcvG7MmsYo03evZxdbkSre2HTnSH8NfcGiBV2nRAQBSOznE 0CjYBtPR4ciPbdfbnsFoX8aq4cLB9e9L8edLiCwv7EwgX3CgxRvfr6EI7BxxYJk/CPl6 R39fcS3FWtvlIoAluEpvFzkHcTxJmPJP4ONMShdi3GPghNRX7beTIzStUZGYM2thqeAF CJDw== 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=nbilf0ZPPCt8KWve7kG5vsj0drpgdL2Q/luzWO1vR8s=; b=yHGn4yeTf/RBfCZDb0g8bc4CChWLewTF+b6uoRXqsQg4UsfA/yUDqdStXYvlX2/kL7 m1djuL+0hWyMKynhDLK86w2BLbTPHF6jnAOM26bN8nVtdn9zTUwKB6qXzcdgus0nuR5+ 9cKT7MtmuWYcN2Q0AhSiM9BiP/aQqVD2FxjqqrNjIhz702fISYQtus0L/Lp9+oe3ww6S wLmmrjoza2LCgrn+hgJBxOwLDBmiQ4TySRpLYrwtzrSI7PEbBZ/UnvurOQ0bBhEPV/Hh jKvVY/sfon0rtAlunS92L8tyTdAzhU2fffyaBfHQAOlkvbZyGaioGdn/3BjCu8N/GoUG ouAQ== 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 tz14-20020a170907c78e00b00783f0b53b8csi11084544ejc.690.2022.10.05.11.19.56; Wed, 05 Oct 2022 11:20:26 -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 S230521AbiJESRo (ORCPT + 99 others); Wed, 5 Oct 2022 14:17:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbiJESR0 (ORCPT ); Wed, 5 Oct 2022 14:17:26 -0400 Received: from relay07.th.seeweb.it (relay07.th.seeweb.it [5.144.164.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B887A4F3AB; Wed, 5 Oct 2022 11:17:24 -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 989963EEFE; Wed, 5 Oct 2022 20:17:22 +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 6/7] drm/msm/dpu1: Account for DSC's bits_per_pixel having 4 fractional bits Date: Wed, 5 Oct 2022 20:16:56 +0200 Message-Id: <20221005181657.784375-7-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,RCVD_IN_DNSWL_NONE, 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 According to the comment this DPU register contains the bits per pixel as a 6.4 fractional value, conveniently matching the contents of bits_per_pixel in struct drm_dsc_config which also uses 4 fractional bits. However, the downstream source this implementation was copy-pasted from has its bpp field stored _without_ fractional part. This makes the entire convoluted math obsolete as it is impossible to pull those 4 fractional bits out of thin air, by somehow trying to reuse the lowest 2 bits of a non-fractional bpp (lsb = bpp % 4??). The rest of the code merely attempts to keep the integer part a multiple of 4, which is rendered useless thanks to data |= dsc->bits_per_pixel << 12; already filling up those bits anyway (but not on downstream). Fixes: c110cfd1753e ("drm/msm/disp/dpu1: Add support for DSC") Reviewed-by: Abhinav Kumar Reviewed-by: Dmitry Baryshkov Reviewed-by: Vinod Koul Signed-off-by: Marijn Suijten --- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c index 46cc2afd2bb9..c63e6eef1ba6 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c @@ -47,7 +47,7 @@ static void dpu_hw_dsc_config(struct dpu_hw_dsc *hw_dsc, u32 initial_lines) { struct dpu_hw_blk_reg_map *c = &hw_dsc->hw; - u32 data, lsb, bpp; + u32 data; u32 slice_last_group_size; u32 det_thresh_flatness; bool is_cmd_mode = !(mode & DSC_MODE_VIDEO); @@ -61,14 +61,7 @@ static void dpu_hw_dsc_config(struct dpu_hw_dsc *hw_dsc, data = (initial_lines << 20); data |= ((slice_last_group_size - 1) << 18); /* bpp is 6.4 format, 4 LSBs bits are for fractional part */ - data |= dsc->bits_per_pixel << 12; - lsb = dsc->bits_per_pixel % 4; - bpp = dsc->bits_per_pixel / 4; - bpp *= 4; - bpp <<= 4; - bpp |= lsb; - - data |= bpp << 8; + data |= (dsc->bits_per_pixel << 8); data |= (dsc->block_pred_enable << 7); data |= (dsc->line_buf_depth << 3); data |= (dsc->simple_422 << 2); -- 2.38.0