From patchwork Thu Jun 9 07:27: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: 12874942 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 F14A8C43334 for ; Thu, 9 Jun 2022 07:32:56 +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=e2KRPjk8GA0vcD6124fsjIS/r/6p/foOfWGKVN9SAt0=; b=16iM5fK9epz3I5 JxWRFg45Gk2mZg1hEuiBZLf342DJG1Qy5/ZUc21sZoV3JIDBu1OElJ5Nn9m5navBEFHL7lL0TJopG kM4Z53gzTG7CnnZB+A3K9hfsSb54+ucYIDgbSSlPWYBTyhZRcKrholVeiPse8OtjjNi4lyhosAG3h KVDkU1/oh8x0OszQIF2RIh8E7JcJ+3jzmL2/L9q95F/iThjWJ9bEgFQ/QvGpu5j+bwRQzogIV7HTN bZpVg9un3Ii1bfl9Qv7mJS+PwGbzTFsvlrKxgUYmM9BWElW7AutuzlAhGgT+hDlGPhNA0dR96v9qv jSEXsdlAy/HLbT3dcBVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzCdp-00HQaW-Jw; Thu, 09 Jun 2022 07:31:43 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzCaU-00HOmw-4M for linux-arm-kernel@lists.infradead.org; Thu, 09 Jun 2022 07:28:15 +0000 Received: by mail-pl1-x634.google.com with SMTP id i15so2839103plr.1 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=YFGTvrOOGZU0eIzCPkHniuyCy0u3FZhQy5sSyzwpJ2wPuIVkwBef57kn11sBOmyvFf xQzVRNQgQLlYFW/uM0CKtvhqi0k4PC1noNLdI8txyICKUeU9dOkHyEZCN2CJoOZ7jlti Ez4MW/haF5wDcIyz0lPQ6Nb3Pmrmw7c4pXyTQTUcvPwM3+UzOaU6Q2cP76irh366HLMo 3e9rv7emSTKVVgwJESWUOOb8Nj3u6XKqo2yK2u/u6BHl8cTEJ04Oqt43EgTvxo8Jl39U g70l+EQjyMBsQn9XcOMcYfxD6gf2KvDw6F00etYXX/2mghh0p0AHZ+NtuPg3Ac/HJ/rA Vp+Q== X-Gm-Message-State: AOAM532UUhx2XaDbrWUFF2xgOXVhSp7tt65zJsE4NMIQQgIL0b0c5lbI CNPJcmyyELY0LnI/Dir2CZalNQ== X-Google-Smtp-Source: ABdhPJx0y6DchLUvvk/yuIYEnoMtoscHMuzTnupHjzPr0+cwAebGuaRDhnVQTQoMdt/AcKvuivAq0Q== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_002814_223597_47DDDED4 X-CRM114-Status: GOOD ( 19.51 ) 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(). 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 Reviewed-by: Doug Anderson Reviewed-by: Stephen Boyd --- 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)