From patchwork Tue Jun 7 09:05:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 12871608 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 3CF4CC43334 for ; Tue, 7 Jun 2022 09:19:54 +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:References:In-Reply-To: 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: List-Owner; bh=B1ZOncO8SboqpZoaTeYFnfsoD/itqLZ5ta1Th0cbxGQ=; b=om5JMIpu1/eTnA BSvSrr+hIO29CiGtWGkC1EZoDRgoCgVPpNGvMUjUNY8yS6sc9TW7XIRU2lK2J96sQ66ScLq/dK1aT Gv+lP+HLJqPcq/F3qTtuKIonV9KqPyH5Th1JCHqkXdloLA6M6jB9ghfMNtnPRA7xtAmfd+DhEb63O ItbBsYYXzf3fMfTNlcQfy7ZpVFSMPn1ueGcuD4xG408N2gG2zX4eAies1STKXMKvtuToGdR/RED+7 W7TTcbVv2L1HYvR9JJtfkm1A3jyX+lmNcSx/URR5nnTI8nmWw4Zzh1cDN0og8towbu0650GZvVBXO ev7rUESmSeV7SrEwqocQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyVLp-0069MD-4A; Tue, 07 Jun 2022 09:18:13 +0000 Received: from mail-pf1-f172.google.com ([209.85.210.172]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyVAQ-0063Pe-Tg for linux-arm-kernel@lists.infradead.org; Tue, 07 Jun 2022 09:06:28 +0000 Received: by mail-pf1-f172.google.com with SMTP id w21so15037393pfc.0 for ; Tue, 07 Jun 2022 02:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lndmMwy1Xi5onPK/2gR/uuIgcJtx+Xqka0AqhZOCETk=; b=nEwqxsOomZ0VyeLUG6ZdtIT5DHvDyUz42wh0TrdWqyIV7DES04zqZT/xTI4m/jl4wJ 7spZlLhVnaPE9NGehQBm6p/6cay1FPtBmqiYv//gBqWsA0rsYdzGXBPrKChzufa8M3X8 yHZDSKUIaIuf8HkJxNNZ8scTGDOI7mvF2sKjc= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=lndmMwy1Xi5onPK/2gR/uuIgcJtx+Xqka0AqhZOCETk=; b=Nw44siDTiACkB/aI1VeKHNA/ApREt8LfepMdVZqNrAWlfdsK9PKY2ifTG9Kkc0S5a3 wT1hUOpAzVKBXbCkBaf+XaL9/lJFHim3uZhT9mOW+d6Loiw8zWsT7Ohdd6WNGO1lA9zh DjNrd1LD+GnZBPOfRlaG0BVqKRKyW4y8pUxxqIzWGFn9Ge63z+sR+JCV7lyMbmQkkvO8 OAh5qeVxT0kp4t2xrLORyYq1C7eh8QOf8scrjRP5+klPllmYw5JztkwQuoYsSqwORSdJ Ui4ExKijMmpL9CJQACf2/LzWLufEBvz6vPM+db1VvHxiJSQdNMFIjQ9ylkGi/eOFJD08 z8cQ== X-Gm-Message-State: AOAM532cUyjtIn0juVF0majuKsibpqZzkwPOqgxexzUhEucNcLO77fd/ yQ/hQJ/J5UpiLv8vcD6M+BZs/Q== X-Google-Smtp-Source: ABdhPJy9/p/zRGqxgyYDjGPvzOwSsGPu3zYSpJfyIjbAxG5xTl/4JRnWDwLQuIRLjKB4AcijPvphZQ== X-Received: by 2002:a63:8641:0:b0:3fd:94e8:a650 with SMTP id x62-20020a638641000000b003fd94e8a650mr11053873pgd.367.1654592783556; Tue, 07 Jun 2022 02:06:23 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:40b7:55ce:10ee:c7a0]) by smtp.gmail.com with ESMTPSA id t27-20020aa7947b000000b0051c0fe8fb8csm4507010pfq.95.2022.06.07.02.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:06:23 -0700 (PDT) From: Hsin-Yi Wang To: Chun-Kuang Hu Cc: Hans de Goede , Thierry Reding , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Rob Clark , Stephen Boyd , Douglas Anderson , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 8/8] drm/mediatek: Config orientation property if panel provides it Date: Tue, 7 Jun 2022 17:05:49 +0800 Message-Id: <20220607090549.2345795-9-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607090549.2345795-1-hsinyi@chromium.org> References: <20220607090549.2345795-1-hsinyi@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220607_020626_982089_37BBE909 X-CRM114-Status: GOOD ( 18.93 ) 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 Panel orientation property should be set before drm_dev_register(). Mediatek drm driver calls drm_dev_register() in .bind(). However, most panels sets orientation property relatively late, mostly in .get_modes() callback, since this is when they are able to get the connector and binds the orientation property to it, though the value should be known when the panel is probed. Let the drm driver check if the remote end point is a panel and if it contains the orientation property. If it does, set it before drm_dev_register() is called. Signed-off-by: Hsin-Yi Wang Reviewed-by: Hans de Goede Reviewed-by: AngeloGioacchino Del Regno --- v4->v5: - use the new function in v5. - don't use drm_of_find_panel_or_bridge(). --- drivers/gpu/drm/mediatek/mtk_dsi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index d9f10a33e6fa..998b1237e193 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -185,6 +185,7 @@ struct mtk_dsi { struct drm_encoder encoder; struct drm_bridge bridge; struct drm_bridge *next_bridge; + struct drm_panel *panel; struct drm_connector *connector; struct phy *phy; @@ -822,6 +823,10 @@ static int mtk_dsi_encoder_init(struct drm_device *drm, struct mtk_dsi *dsi) ret = PTR_ERR(dsi->connector); goto err_cleanup_encoder; } + + /* Read panel orientation */ + drm_connector_set_orientation_from_panel(dsi->connector, dsi->panel); + drm_connector_attach_encoder(dsi->connector, &dsi->encoder); return 0; @@ -836,6 +841,16 @@ static int mtk_dsi_bind(struct device *dev, struct device *master, void *data) int ret; struct drm_device *drm = data; struct mtk_dsi *dsi = dev_get_drvdata(dev); + struct device_node *panel_node; + + /* Get panel if existed */ + panel_node = of_graph_get_remote_node(dev->of_node, 0, 0); + if (panel_node) { + dsi->panel = of_drm_find_panel(panel_node); + if (IS_ERR(dsi->panel)) + dsi->panel = NULL; + of_node_put(panel_node); + } ret = mtk_dsi_encoder_init(drm, dsi); if (ret)