Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1264437lfc; Wed, 1 Jun 2022 13:31:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDV2l/EcMKBCw+zjQszkJYL8ZmIcqPVdAe2B9bMn5mV0qK+ZeYHJHP8V6pybULFJjzUwQJ X-Received: by 2002:a63:82c1:0:b0:3fc:8f89:473f with SMTP id w184-20020a6382c1000000b003fc8f89473fmr1014715pgd.218.1654115488275; Wed, 01 Jun 2022 13:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654115488; cv=none; d=google.com; s=arc-20160816; b=LW1FyN2z7K1TjRijJmHc5DgwKuAJPH9w8F4DAr9zwp88vjZs9LORpxMXxPWxXPveSa 9s0PxvG0Ek+oNRodGQgB526gn/fPZlIP7Vo0uszfKWi5b6LQzqHlB3NHpreReeYTsSek N/8P7nnBCyAJB1r6liRGApcd4vCQACYY/yA0LRV1QOBUth6WPf9SBMjloQ27l6EnDrF4 uYjvhCqB0IRjaU6/oG88DKGxwsTeAmVx5O7MCglalnwBzWsZGYSC2kDstee/1LF/Q+W2 ery2tB7dn+BUW6iYgj64MA+T0LuFpK+xd2wrVOti3Cdww1fRcGAbJ7R1lsp8tUZDaIC8 MHTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RTq2qApdr0XDjYdhICkGJiEtvpG4jeHig+budTOXpzw=; b=FYT51Tup/XPONj7r0EoEe2yuGb/K3d75l0r3DkPYVp+CYLTy/x/UD/92A3B0ep7FZx XF2I5keMbFQYcNL+qYD8lCR71HZmRi8W/SxX4biIUHePKHhlr+4ENnSKvXr/e0+LYudh ud1M9+ecaUJ7kKNfWOb+zh9HKIFtrGP7m7xZCuF1pR4auZn3bz8xVoTbQn3d1YKML/iP zMhSUuyRwJahEut+xGRJOmhkS9SwV1Ps/nhDu2yJrBFpT472li2in92COe7RBZkcU3b7 LnqWYITvl/+O7jECxjf03uRtvG/44OnaYEwrrCGyNLtPKVugex+N1h7XQ4I8qZAOHhxZ JANw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=N5bZXB4H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l11-20020a17090ac58b00b001e00edc0c6csi7093180pjt.121.2022.06.01.13.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:31:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=N5bZXB4H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CAAF26A02F; Wed, 1 Jun 2022 12:40:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351032AbiFAJab (ORCPT + 99 others); Wed, 1 Jun 2022 05:30:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351066AbiFAJa2 (ORCPT ); Wed, 1 Jun 2022 05:30:28 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8AF58A336 for ; Wed, 1 Jun 2022 02:30:25 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id fu3so1021725ejc.7 for ; Wed, 01 Jun 2022 02:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RTq2qApdr0XDjYdhICkGJiEtvpG4jeHig+budTOXpzw=; b=N5bZXB4HEnh1aE629ihk0RNtGOggnXdOo8MhyhV/pnh0CS3sIL/F0HjMn6dkeMJhys uvLvUCgQ22KIadzabZUoW8aH9DgEKYOj0O7xEDoueNU6mwjz5rjcJ9pvqB5Ab7qEQqf2 RzK5un4TdNweT81vZseW8sNyrkZ8icMt397oM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RTq2qApdr0XDjYdhICkGJiEtvpG4jeHig+budTOXpzw=; b=b8mAALY452MSEW3q8skoEq1oW2/MpL6/SAd1Yh/C2Rf3DyRO6Pn4V+Tx3Dyj383mQh n2AGrB6/rkOBPKKbFMbDByiyZ1OGooI9LtKmvtMJpjHGJ9kC3d1H1n5pYA/tE1HyHj8y lxUZUUEE3+drjbeOuE5fkEmCkzakGdk5cqt5cZE6NDvFmihamGv2p6/BkCMzsxO0gTky TctVBqjPbbcnHCacKQTwlSTFKtigHlKEMUQWHpQ+SJHFhNxXm5f+gVw6XnS1wHwHZ1WB qyyykKz+05ZetvEPA70jHz+7YC+0U+Wze1nWtumpsLJtxWeHi5Ph58AL0AXz66if+2z1 6Bdw== X-Gm-Message-State: AOAM53280B0sWBDHaitMET+0K4owpIzFZDLWWQuFte1PlqWBLVcGrb7O r1K57cilrMaAyiPrAddKQ4NLBZ9W6GdyVgFGuXA8rw== X-Received: by 2002:a17:907:160c:b0:6fe:c56f:751 with SMTP id hb12-20020a170907160c00b006fec56f0751mr46232867ejc.746.1654075824444; Wed, 01 Jun 2022 02:30:24 -0700 (PDT) MIME-Version: 1.0 References: <20220601081823.1038797-1-hsinyi@chromium.org> <20220601081823.1038797-9-hsinyi@chromium.org> In-Reply-To: From: Hsin-Yi Wang Date: Wed, 1 Jun 2022 17:29:58 +0800 Message-ID: Subject: Re: [PATCH 8/8] drm/mediatek: Config orientation property if panel provides it To: Hans de Goede Cc: Chun-Kuang Hu , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Wed, Jun 1, 2022 at 4:57 PM Hans de Goede wrote: > > Hi, > > On 6/1/22 10:18, Hsin-Yi Wang wrote: > > 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; > > drm_connector_set_panel_orientation() is a no-op when called with > DRM_MODE_PANEL_ORIENTATION_UNKNOWN, so the check for this is not > necessary. This allows this to be simplified to: > > /* Read panel orientation */ > if (dsi->panel) > drm_connector_set_panel_orientation(dsi->connector, > drm_panel_get_orientation(dsi->panel)); > > > Note since drm_panel_get_orientation() checks for a NULL panel, you could even > drop the "if (dsi->panel)", but I think the meaning of the code is more > clear with that present. > Will update this > > > > > > > @@ -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); > > + > > Check ret? or maybe not assign to ret ? I understand some errors are expected > so maybe something like: > > if (ret && ret != -ENODEV) > return ret; > I will choose not to assign ret. In some cases that the end point is a bridge (not panel), since we assign NULL to the bridge, we will get EPROBE_DEFER. If the panel fails at this stage, drm_connector_set_panel_orientation() is just a no-op. Let dsi still be able to be binded. > ? > > Note -ENODEV is probably not the right error the check for! > > Regards, > > Hans > > > > > ret = mtk_dsi_encoder_init(drm, dsi); > > if (ret) > > return ret; >