Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp175593iol; Thu, 9 Jun 2022 01:14:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhoaAec3ySLS47ZptqKyeRke4Tfny/e9YL65ac0QsjvUjagzPIZr6llLbc4X1icJki5oUy X-Received: by 2002:a17:906:9b96:b0:711:d21c:1b0b with SMTP id dd22-20020a1709069b9600b00711d21c1b0bmr17012938ejc.365.1654762494138; Thu, 09 Jun 2022 01:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654762494; cv=none; d=google.com; s=arc-20160816; b=L2nq2GXcWUU6WY7u4PtQbztHH+r4ZKirTfn8LhwkjtPcaaoXwqE4fK5Xpy8rhsHr4X tJO4s/Ul/SJ8wUi/ZYsupyumBtnX8b0DeGp1/end31NCeo7EhmVd9rscrNBFNrDA5uav VJuowz6lMCbV0gKiJOwtuOXuN3D7xdbBmsLaaKQt2WzbDIQ87Bk7jeULz/V61TB8ufaH bxL8hMmL42jNVctL8Hvmjl44bKhWBCKFAnSWSvoNtn0LpQ+BlwI+wDVkdPt03vBGPnZf 6za29Y3iQw7nxsG0tcGeYFBB7EeaMQYmudAyLZvuDEZflb5Hj1kLhfzJ6Z/dOfkpxada 3OuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EU3KV+nUfeIhuNF/Ro7jf0eLAkt330a3bAydA7XSi+w=; b=uTYPhHMNjl42TFxeOTEwbmE/33n1IWrlTmvvFSq1f0ByCdUConD7TB/T4P6UgM2HVZ s4GzuZj4livDex9JpcQr7VVyzyC7Zv5hz/ESXkUWJhZd0XRRTzcDrcWEb95TwhNHnhMK VNzGBeUYY+WQxUWcbOTzPPZgKTF3iaKSVOziiV99f+y7Nf+4fCXW0ONox+ex7inSvbNk NNBOef03XKst3VXVIN+SANPHsR2R/ZTr8y65WK+hY3h6B8dsYG1fwo7E8YZCZI3eKu/V c1AbyuoLC5ONtBIXKujBC6z/7XRXqlsVje0nNWJzfsgyvZD0aCY4Ok6w+6S3tt/KaInN 4mkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VqbUTr3H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs4-20020a1709073e8400b006ff49b183e9si21729036ejc.971.2022.06.09.01.14.06; Thu, 09 Jun 2022 01:14:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VqbUTr3H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238888AbiFIH2t (ORCPT + 99 others); Thu, 9 Jun 2022 03:28:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240178AbiFIH2T (ORCPT ); Thu, 9 Jun 2022 03:28:19 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 894D4157E87 for ; Thu, 9 Jun 2022 00:28:11 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id q18so19575452pln.12 for ; Thu, 09 Jun 2022 00:28:11 -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=EU3KV+nUfeIhuNF/Ro7jf0eLAkt330a3bAydA7XSi+w=; b=VqbUTr3H73qk7OZZz/TA+W+HpQdKZ3GSi8c1Gz+F66d9XD1DhQZtcZj9tYoGnBFCMH 9jxzZQrJD2AuqpJhiITLGgJFsgqcH4cZdZ4DMvOA/HAXrFenxq9XEcffHdqI51W5b0+R vgKEqD5AT7EuudEvdhCxmhMR6bB4DJJnlMh60= 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=EU3KV+nUfeIhuNF/Ro7jf0eLAkt330a3bAydA7XSi+w=; b=uoFmfiziMMoj9CUY17Eje0IW6EcnULeI3Zkphv0JXg4mTbXuzuiig+exytfYx85+Fw aCv8sTW8qTlXu8ENxffA4YGSP3FM8XsHfLKhgq/RsHF39aDpWj0WxonHMWu7b9u9lOTE Uk/vOS90nuLWB9T459lah4O88ST8heSA24IrcNeu8xVRl3GrwI1MyYhEBDqvHTcccmqL Ct/u1kinYGzjtFuZIuJd+nHUV8AVmfanvdQqc81rTTfi77sCGsf+WSdqIMzmsL72E3FR eajqpe3wJx/xILFks2nF/iCxybzvyWAHH+7J5ev8gYsdWHdQut7wKzFjbMq0hgPqY9Do Hwdg== X-Gm-Message-State: AOAM531W1aNRzIrpOPOtlI5p0ewY4hzd5WD41E04gHHVyz3UOL3US34C RTDSiYAcoob2GOMAacAk+zASJw== X-Received: by 2002:a17:903:24f:b0:15c:e3b8:a640 with SMTP id j15-20020a170903024f00b0015ce3b8a640mr38088332plh.5.1654759691087; Thu, 09 Jun 2022 00:28:11 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:5119:d95b:c6cd:77fb]) by smtp.gmail.com with ESMTPSA id p16-20020a1709027ed000b0016403cae7desm15312221plb.276.2022.06.09.00.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 00:28:10 -0700 (PDT) From: Hsin-Yi Wang To: Hans de Goede , Sam Ravnborg , Stephen Boyd , Douglas Anderson Cc: Thierry Reding , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Philipp Zabel , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, Rob Clark , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 8/8] drm: Config orientation property if panel provides it Date: Thu, 9 Jun 2022 15:27:23 +0800 Message-Id: <20220609072722.3488207-9-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220609072722.3488207-1-hsinyi@chromium.org> References: <20220609072722.3488207-1-hsinyi@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 Panel orientation property should be set before drm_dev_register(). Some 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. In drm_bridge_connector_init(), if a bridge is a panel bridge, use it to set the connector's panel orientation property. Suggested-by: Doug Anderson Signed-off-by: Hsin-Yi Wang --- v6->v7: remove redundant check and fix config issue. --- drivers/gpu/drm/bridge/panel.c | 34 ++++++++++++++++++++++++++ drivers/gpu/drm/drm_bridge_connector.c | 8 +++++- include/drm/drm_bridge.h | 14 +++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index 0ee563eb2b6f9..4277bf4f032be 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -170,6 +170,19 @@ static const struct drm_bridge_funcs panel_bridge_bridge_funcs = { .debugfs_init = panel_bridge_debugfs_init, }; +/** + * drm_bridge_is_panel - Checks if a drm_bridge is a panel_bridge. + * + * @bridge: The drm_bridge to be checked. + * + * Returns true if the bridge is a panel bridge, or false otherwise. + */ +bool drm_bridge_is_panel(const struct drm_bridge *bridge) +{ + return bridge->funcs == &panel_bridge_bridge_funcs; +} +EXPORT_SYMBOL(drm_bridge_is_panel); + /** * drm_panel_bridge_add - Creates a &drm_bridge and &drm_connector that * just calls the appropriate functions from &drm_panel. @@ -269,6 +282,27 @@ void drm_panel_bridge_remove(struct drm_bridge *bridge) } EXPORT_SYMBOL(drm_panel_bridge_remove); +/** + * drm_panel_bridge_set_orientation - Set the connector's panel orientation + * from the bridge that can be transformed to panel bridge. + * + * @connector: The connector to be set panel orientation. + * @bridge: The drm_bridge to be transformed to panel bridge. + * + * Returns 0 on success, negative errno on failure. + */ +int drm_panel_bridge_set_orientation(struct drm_connector *connector, + struct drm_bridge *bridge) +{ + struct panel_bridge *panel_bridge; + + panel_bridge = drm_bridge_to_panel_bridge(bridge); + + return drm_connector_set_orientation_from_panel(connector, + panel_bridge->panel); +} +EXPORT_SYMBOL(drm_panel_bridge_set_orientation); + static void devm_drm_panel_bridge_release(struct device *dev, void *res) { struct drm_bridge **bridge = res; diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c index 6b3dad03d77d0..1c7d936523df5 100644 --- a/drivers/gpu/drm/drm_bridge_connector.c +++ b/drivers/gpu/drm/drm_bridge_connector.c @@ -331,7 +331,7 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, struct drm_bridge_connector *bridge_connector; struct drm_connector *connector; struct i2c_adapter *ddc = NULL; - struct drm_bridge *bridge; + struct drm_bridge *bridge, *panel_bridge = NULL; int connector_type; bridge_connector = kzalloc(sizeof(*bridge_connector), GFP_KERNEL); @@ -373,6 +373,9 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, if (bridge->ddc) ddc = bridge->ddc; + + if (drm_bridge_is_panel(bridge)) + panel_bridge = bridge; } if (connector_type == DRM_MODE_CONNECTOR_Unknown) { @@ -392,6 +395,9 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; + if (panel_bridge) + drm_panel_bridge_set_orientation(connector, panel_bridge); + return connector; } EXPORT_SYMBOL_GPL(drm_bridge_connector_init); diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index f27b4060faa2f..bd11bbe5e9b33 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -917,16 +917,30 @@ void drm_bridge_hpd_notify(struct drm_bridge *bridge, enum drm_connector_status status); #ifdef CONFIG_DRM_PANEL_BRIDGE +bool drm_bridge_is_panel(const struct drm_bridge *bridge); struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel); struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel, u32 connector_type); void drm_panel_bridge_remove(struct drm_bridge *bridge); +int drm_panel_bridge_set_orientation(struct drm_connector *connector, + struct drm_bridge *bridge); struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev, struct drm_panel *panel); struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev, struct drm_panel *panel, u32 connector_type); struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge); +#else +static inline bool drm_bridge_is_panel(const struct drm_bridge *bridge) +{ + return false; +} + +static inline int drm_panel_bridge_set_orientation(struct drm_connector *connector, + struct drm_bridge *bridge) +{ + return -EINVAL; +} #endif #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL_BRIDGE) -- 2.36.1.255.ge46751e96f-goog