Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3848768rwb; Sun, 9 Oct 2022 12:15:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4zEOcErJlgWeXGBR8IsGGjXfl3ovyUGqOoOqElsbpELn7OQpiv9HaXgM0KROL9ryndVErK X-Received: by 2002:a17:90b:1e07:b0:202:bb50:1963 with SMTP id pg7-20020a17090b1e0700b00202bb501963mr27752682pjb.82.1665342925846; Sun, 09 Oct 2022 12:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665342925; cv=none; d=google.com; s=arc-20160816; b=yUexszjnS/Eji5dFcHm9HFW0avjjpQODu76p7a4UOZlmY9mR+XCCgIYL/WlghlhCeG oWQgmYqp5xHekZIgEedrUAkmtFNq+2cb5lmuju/ZnPv3LnvzOIrgLpUr7GHiNRE+PDqX CVGGQZGPikH9sNtn2jrocC4TR7x1SG+oeTggLepPX5/UE+hT39EQLmWfYrCDUNqhgcWr SNHGL8F/yPdBCZXVxH1KybRVvASIlQPWqFwud7im9fj3cgNDzp5JoJSaoVGTEEtrQL1e tovTrZ8gVd4Bl9zqT3/GBEBfYGsBgLJs2XGAtrt1So8oSyj7N/DcrBirocVkOmFa7zys EWzA== 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=n8ummcsOrmpWbHd+lQq91Lfgw38hNVna0Pr1c3DhCGg=; b=wp/xIfCS1XNXcSvuxFpYuSur/wyUpQO3AkBkB6ZsA/hqAMvZ92Kf4NMt092zgTdJjs 6GMewv9Fsp5A568yirRzprzqGhjtGwRqH3WcOth9R2uRqMPhdqKrO1aLNU9zMtj9bS0P FC1pMwKix16W75bXSNzqDCjAXUorV/CqBAJnIKrHMp+evaGus/hzqCCOdP5t4j5TZPaG EjjXQgycxB+GfBa9zweJuUoQeY4/b9TEB/72jPZvZMQi2R+n3qj+HoNPHo3UZh4dUmXS WTquVG83UU42uDrk0XyxqegUdULz2S8cp8uq2Pq+30U9sasGtLswZYEupwJARG+5JQxE o9xg== 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 o190-20020a62cdc7000000b00540cbd3cb18si8189651pfg.234.2022.10.09.12.15.14; Sun, 09 Oct 2022 12:15:25 -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 S229935AbiJISxt (ORCPT + 99 others); Sun, 9 Oct 2022 14:53:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230349AbiJISxe (ORCPT ); Sun, 9 Oct 2022 14:53:34 -0400 Received: from m-r1.th.seeweb.it (m-r1.th.seeweb.it [5.144.164.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF1542CE0F; Sun, 9 Oct 2022 11:53:32 -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 BCECA1F986; Sun, 9 Oct 2022 20:53:30 +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 08/10] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits Date: Sun, 9 Oct 2022 20:53:13 +0200 Message-Id: <20221009185316.462522-1-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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 drm_dsc_config's bits_per_pixel field holds a fractional value with 4 bits, which all panel drivers should adhere to for drm_dsc_pps_payload_pack() to generate a valid payload. All code in the DSI driver here seems to assume that this field doesn't contain any fractional bits, hence resulting in the wrong values being computed. Since none of the calculations leave any room for fractional bits or seem to indicate any possible area of support, disallow such values altogether. calculate_rc_params() in intel_vdsc.c performs an identical bitshift to get at this integer value. Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data") Signed-off-by: Marijn Suijten --- drivers/gpu/drm/msm/dsi/dsi_host.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index 7e6b7e506ae8..46032c576a59 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -34,7 +34,7 @@ #define DSI_RESET_TOGGLE_DELAY_MS 20 -static int dsi_populate_dsc_params(struct drm_dsc_config *dsc); +static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc); static int dsi_get_version(const void __iomem *base, u32 *major, u32 *minor) { @@ -909,6 +909,7 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi) u32 va_end = va_start + mode->vdisplay; u32 hdisplay = mode->hdisplay; u32 wc; + int ret; DBG(""); @@ -944,7 +945,9 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi) /* we do the calculations for dsc parameters here so that * panel can use these parameters */ - dsi_populate_dsc_params(dsc); + ret = dsi_populate_dsc_params(msm_host, dsc); + if (ret) + return; /* Divide the display by 3 but keep back/font porch and * pulse width same @@ -1770,9 +1773,15 @@ static char bpg_offset[DSC_NUM_BUF_RANGES] = { 2, 0, 0, -2, -4, -6, -8, -8, -8, -10, -10, -12, -12, -12, -12 }; -static int dsi_populate_dsc_params(struct drm_dsc_config *dsc) +static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc) { int i; + u16 bpp = dsc->bits_per_pixel >> 4; + + if (dsc->bits_per_pixel & 0xf) { + DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support fractional bits_per_pixel\n"); + return -EINVAL; + } if (dsc->bits_per_component != 8) { DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support bits_per_component != 8 yet\n"); @@ -1798,8 +1807,8 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc) dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i]; } - dsc->initial_offset = 6144; /* Not bpp 12 */ - if (dsc->bits_per_pixel != 8) + dsc->initial_offset = 6144; /* Not bpp 12 */ + if (bpp != 8) dsc->initial_offset = 2048; /* bpp = 12 */ if (dsc->bits_per_component <= 10) -- 2.38.0