From patchwork Mon May 30 14:24:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Parent X-Patchwork-Id: 12864679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2AF71C433F5 for ; Mon, 30 May 2022 14:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ru5Ev5Hsn1elD890Ilem9SQ3Ez8UXlAq6fIP6czT07k=; b=yBuTtGFL/KIdWs 1yLS7W3vaiRkgG2ghMpzGplm7730MhyOT8e7tb/dVG+q2/K7xKiXSqwBzUMCeqlbNJ6jvZgvLawAy ZC9HKNTtOADDwy+vPpmEAF+Bc34tNv/YMwoP0935jr4eDUCNs0JMN3bWbkYfbkN1sx3KthEIi6fLO WICTT0j2sjvMWxkos+Rb5SwGj+bc4Cnj/aGG/e8l81GUA/3q6lU2leBUzSIarPvwbPI2PwxlBINqK 18EyhM0MoVFwN69+sIWlDyqK8zWWhy5IHu+6TD++sBpjpSj1Q3PHiRI74WXFdIlOCS0MbSA0OztDU dBg3AGrDrKuocbqTL/4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nvga1-007JIj-Lc; Mon, 30 May 2022 14:41:13 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nvgJe-007BQv-40 for linux-arm-kernel@lists.infradead.org; Mon, 30 May 2022 14:24:20 +0000 Received: by mail-wr1-x435.google.com with SMTP id q7so3902661wrg.5 for ; Mon, 30 May 2022 07:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rUAWdJ1Rf6hO8ecNBUpnATX0ltMJMJR8PSAH4KO8bJM=; b=LXAGdGTLAayi/VD6RlJh8cDSac2FGSYcJt/uGESSMobfyQL1XbIq81Ywa+yllK/x2E sJAS1Rtf5zCjVFmHW4pfy9Tm5dcA5ZVlkEAgvw2NGpz9WZyyL1fOivsSvW9ytr3I57tI +6fjo5tQhXgr2qaexjNggNiuq6T69aTHW9odw2YHwZzw+W6m95HcY+q9sBmorz9c0xYk bA0W/CuhgZRg2uQS5Mkr9/Y/bZpmCfybLP6mrXZw7koQ3b+VufvplHhXB5NVUCdaMUoW TCkVYinu9AA7khJHktcQJTHSDsPEUzbWColgtl13bs4lm9K4PQIRKfICpI7XOPwBSQPj 1kIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rUAWdJ1Rf6hO8ecNBUpnATX0ltMJMJR8PSAH4KO8bJM=; b=EU/VH9cgcVlOew4UhR8Fw8qG1yEJ3gZ95ynlhAsgZ6EV8Y5q0Vq2jY6G2+RIihXW+8 vZquNwU2M8t1dAyrCO2v7KmXYw+5HJ83/kGm3dCnJIJf1baKkcOlOlLV+qbmSnTlF4qG 94u/KKpR4m3bbt305l6nNl5wCwy9X5LnXe4ZvbJF1qPiJgfgruVX9Cko91JrwBtK/FJr yfze9sg9Dvrt7RWREkOrOvj64MMDU/GH1qMiJ+DzBnMFS35T5ennbVdCS6LpPXELpimY SMyzFHF09P7NrqPZCMoKPkdU4r/dSxUBTS5Gz1M+mP6d48wTkcfZxe3eTtd+0Jc1Vl58 Hi7g== X-Gm-Message-State: AOAM532UjdrY4TemuZMX+8x4i48+LsU+/NffD8b5HFwMcJAvrbwIP1KQ ewCpzewkjgkYLqa8sVp3YAe4Iw== X-Google-Smtp-Source: ABdhPJwUdn2UEohzLhlkvTp89uivSBFAQcrCfQrdg/myp0CdGWHmaAJLOG8f0NAC612sXpmZ9kB+sw== X-Received: by 2002:a05:6000:1288:b0:210:154:ea50 with SMTP id f8-20020a056000128800b002100154ea50mr21132673wrx.213.1653920656629; Mon, 30 May 2022 07:24:16 -0700 (PDT) Received: from localhost.localdomain ([88.160.162.107]) by smtp.gmail.com with ESMTPSA id y4-20020a056000168400b0020d10a249eesm9134310wrd.13.2022.05.30.07.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 07:24:15 -0700 (PDT) From: Fabien Parent To: Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger Cc: Fabien Parent , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/mediatek: fix crtc index computation Date: Mon, 30 May 2022 16:24:07 +0200 Message-Id: <20220530142407.781187-1-fparent@baylibre.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220530_072418_200649_DF505747 X-CRM114-Status: GOOD ( 14.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The code always assume that the main path is enabled, which is not always the case. When the main path is not enabled, the CRTC index of the ext path is incorrect which makes the secondary path not usable. Fix the CRTC index calculation. Signed-off-by: Fabien Parent --- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 46 +++++++++++++++------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index 5d7504a72b11..6f2abfc608fb 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -430,25 +430,47 @@ int mtk_ddp_comp_get_id(struct device_node *node, return -EINVAL; } +static bool mtk_drm_comp_is_enabled(struct drm_device *drm, + const enum mtk_ddp_comp_id *path, + unsigned int path_len) +{ + struct mtk_drm_private *priv = drm->dev_private; + + return path && path_len && !!priv->comp_node[path[path_len - 1]]; +} + unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm, struct device *dev) { struct mtk_drm_private *private = drm->dev_private; - unsigned int ret = 0; + unsigned int index = 0; - if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path, private->data->main_len, + if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path, + private->data->main_len, private->ddp_comp)) - ret = BIT(0); - else if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path, - private->data->ext_len, private->ddp_comp)) - ret = BIT(1); - else if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path, - private->data->third_len, private->ddp_comp)) - ret = BIT(2); - else - DRM_INFO("Failed to find comp in ddp table\n"); + return BIT(index); + + if (mtk_drm_comp_is_enabled(drm, private->data->main_path, + private->data->main_len)) + index++; - return ret; + if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path, + private->data->ext_len, + private->ddp_comp)) + return BIT(index); + + if (mtk_drm_comp_is_enabled(drm, private->data->ext_path, + private->data->ext_len)) + index++; + + if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path, + private->data->third_len, + private->ddp_comp)) + return BIT(index); + + DRM_INFO("Failed to find comp in ddp table\n"); + + return 0; } int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,