From: Michael Walle <mwalle@kernel.org>
To: "Nícolas F . R . A . Prado" <nfraprado@collabora.com>,
"Chun-Kuang Hu" <chunkuang.hu@kernel.org>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>
Cc: Jitao Shi <jitao.shi@mediatek.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
"Nancy . Lin" <nancy.lin@mediatek.com>,
linux-mediatek@lists.infradead.org,
Stu Hsieh <stu.hsieh@mediatek.com>,
Michael Walle <mwalle@kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] drm/mediatek: dpi/dsi: fix possible_crtcs calculation
Date: Tue, 29 Aug 2023 15:19:41 +0200 [thread overview]
Message-ID: <20230829131941.3353439-2-mwalle@kernel.org> (raw)
In-Reply-To: <20230829131941.3353439-1-mwalle@kernel.org>
mtk_drm_find_possible_crtc_by_comp() assumed that the main path will
always have the CRTC with id 0, the ext id 1 and the third id 2. This
is only true if the paths are all available. But paths are optional (see
also comment in mtk_drm_kms_init()), e.g. the main path might not be
enabled or available at all. Then the CRTC IDs will shift one up, e.g.
ext will be 1 and the third path will be 2.
To fix that, dynamically calculate the IDs by the precence of the paths.
Fixes: 5aa8e7647676 ("drm/mediatek: dpi/dsi: Change the getting possible_crtc way")
Suggested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 41 ++++++++++++++-------
1 file changed, 27 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
index 771f4e173353..f3064bff64e8 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
@@ -526,21 +526,34 @@ 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;
-
- 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");
+ int i = 0;
+
+ if (private->data->main_path) {
+ if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
+ private->data->main_len,
+ private->ddp_comp))
+ return BIT(i);
+ i++;
+ }
+
+ if (private->data->ext_path) {
+ if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
+ private->data->ext_len,
+ private->ddp_comp))
+ return BIT(i);
+ i++;
+ }
- return ret;
+ if (private->data->third_path) {
+ if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
+ private->data->third_len,
+ private->ddp_comp))
+ return BIT(i);
+ i++;
+ }
+
+ 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,
--
2.39.2
next prev parent reply other threads:[~2023-08-29 13:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 13:19 [PATCH 1/2] drm/mediathek: fix kernel oops if no crtc is found Michael Walle
2023-08-29 13:19 ` Michael Walle [this message]
2023-08-29 17:50 ` [PATCH 2/2] drm/mediatek: dpi/dsi: fix possible_crtcs calculation Nícolas F. R. A. Prado
2023-08-30 10:55 ` Michael Walle
2023-08-29 16:00 ` [PATCH 1/2] drm/mediathek: fix kernel oops if no crtc is found Nícolas F. R. A. Prado
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230829131941.3353439-2-mwalle@kernel.org \
--to=mwalle@kernel.org \
--cc=airlied@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jitao.shi@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=nancy.lin@mediatek.com \
--cc=nfraprado@collabora.com \
--cc=p.zabel@pengutronix.de \
--cc=stu.hsieh@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox