From patchwork Wed Jun 1 08:18:23 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: 12866526 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 975E9C4332F for ; Wed, 1 Jun 2022 08:42:08 +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=ngpAfyzqVvAbpDelfQDyc9yAWFBjw6/PbzRWKmXffxM=; b=bDpqMCjG0gtyNf eVp8khbZiXFBjgxWZETFWE+WYfXQFh4GRfq7kSsnY5M8uq7ZfNXBmIxLzjIZUR4JfjBC9VZQ8T4Xn TgNxjs7Kpri52yMbXOoHKZfaqMXHPkjzXMW/ua8sDEv+HRM11X0fTpsiPzW6ZG01nwiqUN7iZCS/B Qs9geEQrnJKo9V7ub6Ci5DUjMYehWapvVcODYbujzXc6K9evAYsavdunwTqtWDdU/0NFjf9sIFAjF jJnWAEIzbBPM+My1QBodHDL7iImPDKaYfZ7It0eY+NVXPrL7iBvxQODsbTz0EMGfr0ynRIv6Gt7KB nZgMZEWbTF1ttqgR5UPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwJuS-00Eid3-OC; Wed, 01 Jun 2022 08:40:56 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwJuI-00EiZL-8f for linux-arm-kernel@bombadil.infradead.org; Wed, 01 Jun 2022 08:40:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=tde+IhIAyMS5phfhjLJ/xUjc9TpTeEZ8Vt0Thw0su/Y=; b=qDJZYxKxbS+X53gVAJeZlSSCEA FGRUJ6JEzE/SwEXkBFa656KTVPGW/mxLqdniZoi+NJnLup1QMITVT1fhD+wCcmjyrgoQ2oQgouMBk 2qW6a3TT7w6thI41+RR4eN4pSV5VueUoq7hqfuO5YI8cioafq/DmOlbELkF153xX845DeV9E1vUMD 4d1CnYjt7W31OCWVPQANmBzgx74M6vX/cTq3Xoz6VtOyWQJOBRN2kX6wk4UpU7PiQiM/xYMdxzvi1 UGmLGjGOE+HFsAsv4UwsBy0Cme6jrzti56Z2EEE8Aat4aeuDMfHW2cpawTQfvawhbSrymUJoc9xh6 EVeURdkA==; Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwJZH-003iSN-Cx for linux-arm-kernel@lists.infradead.org; Wed, 01 Jun 2022 08:19:07 +0000 Received: by mail-pl1-x62f.google.com with SMTP id w3so1071345plp.13 for ; Wed, 01 Jun 2022 01:19:00 -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=tde+IhIAyMS5phfhjLJ/xUjc9TpTeEZ8Vt0Thw0su/Y=; b=AvPaiVerLhPA7bu4ah3qZZGvu6x+scDrnj9QwMVpBGEzH3jZ7jjZctDsthGN2X75vw +gqQh9EYZiKEDVg457+bSPZMSAva31GxPBAHUAeqWSP4I5zE+e61zJti+EJ+Q8OnrZ/N KigOKjCuq65/FJ5z6+Tj+iW5NfPqCgjMotibk= 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=tde+IhIAyMS5phfhjLJ/xUjc9TpTeEZ8Vt0Thw0su/Y=; b=dMD8fjS/a44qq2GIS28mYLmz//Zc/6pXcFLQwwf/8H+S+CXDCkn6vdEuvfse7o9RQ0 y+7WjPw9v/87vFbPYl7jWWXycL8rHhjQi14ACAW9Rdlu2v551VzMbzpaQDINsvnPw+B/ 9DNCcvcX9nZVop6zXQhOcZ9+0na2WCk5WJJnGvsdKFheuVqFwlUNOmqBFi0dEkMkDPIh JN7SgEhzWxwFUdlDmkDjuifqUXjUlYcyMvgH1z9/XIUVigLxRVggvX68MYR674FkdvVQ 9e19v/J9lQyc12gMOYqTwyex/3VMOKgSl3vKVrsHoUy3sYvW0fzxApeGQob9s1cLIDyx sOhA== X-Gm-Message-State: AOAM531/agomNL0OBAvA3s4fgrwQdfTrGADQVQoO5yX+trTHRBr/nE9j tovJC+tpwUuWgX+r5y6Ax6ByeQ== X-Google-Smtp-Source: ABdhPJyJZ9Nd5iUhCD6MyJuY2jjn3E+5iA+mGbWJIcSz/UCeJVMvsyFTNMYYQQ2/CExPe30dQ0kFsA== X-Received: by 2002:a17:90b:1e44:b0:1e2:e772:5f08 with SMTP id pi4-20020a17090b1e4400b001e2e7725f08mr17755299pjb.129.1654071539081; Wed, 01 Jun 2022 01:18:59 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:dc30:e75c:ae95:f2d6]) by smtp.gmail.com with ESMTPSA id c3-20020aa78803000000b0050dc7628182sm824680pfo.92.2022.06.01.01.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 01:18:58 -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 8/8] drm/mediatek: Config orientation property if panel provides it Date: Wed, 1 Jun 2022 16:18:23 +0800 Message-Id: <20220601081823.1038797-9-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220601081823.1038797-1-hsinyi@chromium.org> References: <20220601081823.1038797-1-hsinyi@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_091904_859132_22DBBA3D X-CRM114-Status: GOOD ( 20.02 ) 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 --- The concept is the same as the previous version. https://patchwork.kernel.org/project/linux-mediatek/patch/20220530113033.124072-1-hsinyi@chromium.org/ The only difference is, it now uses the panel API instead of parsing orientation from the driver. --- drivers/gpu/drm/mediatek/mtk_dsi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index bd3f5b485085..12836a697f56 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,16 @@ 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 */ + if (dsi->panel) { + enum drm_panel_orientation orientation; + + orientation = drm_panel_get_orientation(dsi->panel); + if (orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN) + drm_connector_set_panel_orientation(dsi->connector, orientation); + } + drm_connector_attach_encoder(dsi->connector, &dsi->encoder); return 0; @@ -837,6 +848,9 @@ static int mtk_dsi_bind(struct device *dev, struct device *master, void *data) struct drm_device *drm = data; struct mtk_dsi *dsi = dev_get_drvdata(dev); + /* Get panel if existed */ + ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, &dsi->panel, NULL); + ret = mtk_dsi_encoder_init(drm, dsi); if (ret) return ret;