Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3860850rwb; Sun, 9 Oct 2022 12:29:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62VztloeNlikni2CwQGeDr1Q4BLlpleWZQ1jeqhpNqpCdmdZXVAnrEOY8rTS73qeJaiSn1 X-Received: by 2002:a05:6a00:a22:b0:54e:6a90:fbef with SMTP id p34-20020a056a000a2200b0054e6a90fbefmr15746694pfh.53.1665343753789; Sun, 09 Oct 2022 12:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665343753; cv=none; d=google.com; s=arc-20160816; b=Txrx2Cuy2qHcSrWaW1Hqs4Ar04BvD2NOutBSuk9HFmwLCGUuLDxReMb5Jj+UjXhWFZ /77pgDLNAv50/kwkv1CX/8lr7e1dDaKki6OqImXL1TnSwvZ8sb3AYPonxwJZ/3t6Aj7B 3+dm/JkB/uePMykg279Vt66YuV2qRLo9JIPWFbTLly/hBfWT2dZ8rXg7QocMqHpYLeff nCIysgltX85lPvdyrkFhhQCM88QF0Bfmn/DPTJMrV59F6W1MwfjUDYwOrdntaKYYgSDC OJ6fgH3ZIszhfOTrdt28xT9XOC9R8AbtFgDavrpSxGoX8J6opqShjyKrOkoS4hXfvdWQ NnCQ== 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=YBXju//OokG1XgiPqLSPB7SJFGrIB20Yq8Xm6VIzdNo=; b=CILIMiklf1HEoRhCloY+u2JQO58/vxLa0KAjh7I0bLbKG53D2qsGmdqPLkRS3UwlXb nVa76llQd3F3rDDaawjuxXs9kQB+ovMMJCB7QlPsayTFQUkSo+5GDHQXUWahsL/m9I0e 4dCnVoP9TUIgC/7+ZP0nrfFutb0JMmgIgih5Ro0Rn3Yb0/JSTHXbNJXP52SG//aStQLj oCpPsU8W1hlMgvG7U2x5Sj4b3pZophhw9fvtdLvZlwRSoWW9pJdN2NT8LKF55zpAst4o Zi9B6nDlkvHEznai7OLh8614qKZarQ6EVwcm9j+7vOU6aBjnpl4lthAOUqrkcYZnYb6N vlqw== 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 q11-20020a65624b000000b0044f2a51ef42si9237506pgv.475.2022.10.09.12.29.01; Sun, 09 Oct 2022 12:29:13 -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 S230366AbiJISxw (ORCPT + 99 others); Sun, 9 Oct 2022 14:53:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbiJISxk (ORCPT ); Sun, 9 Oct 2022 14:53:40 -0400 Received: from relay01.th.seeweb.it (relay01.th.seeweb.it [IPv6:2001:4b7a:2000:18::162]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E89A529829; Sun, 9 Oct 2022 11:53:38 -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-r1.th.seeweb.it (Postfix) with ESMTPSA id E7C1A1F95B; Sun, 9 Oct 2022 20:53:36 +0200 (CEST) From: Marijn Suijten To: phone-devel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Marijn Suijten , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , Vinod Koul , Douglas Anderson , Vladimir Lypak , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/10] drm/msm/dpu1: Account for DSC's bits_per_pixel having 4 fractional bits Date: Sun, 9 Oct 2022 20:53:14 +0200 Message-Id: <20221009185316.462522-2-marijn.suijten@somainline.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221009184824.457416-1-marijn.suijten@somainline.org> References: <20221009184824.457416-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 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") Signed-off-by: Marijn Suijten Reviewed-by: Abhinav Kumar Reviewed-by: Dmitry Baryshkov Reviewed-by: Vinod Koul --- 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