From patchwork Wed Jun 8 09:48:16 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: 12873118 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 D7A70CCA47B for ; Wed, 8 Jun 2022 09:51:52 +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=unTtpp3z3Z4JRaAMR/X7x5HxLy8dp31DnZ32JA62oQs=; b=JsGnWVd9xgig/U JmgDKK86sQvVkgM7e7MB3FoQXw+1t/ToumWOYIDEZtaNp5afb/fD919Gij4Lta6XMMgAZasG/mB+E OP/U85y5wydHzOTnCUGI8XC1JitmL49YPHBs3GLHR6OJVD1nLbrfJ2pXwE9fbuGmtzNNZoHZpkC/e eCG3+IP0Cehv2G2lfIbj2J7mbsA463duevsoAks0s/YhoQz0hmTg+sGMecRc4BMZ9nx1LUhmkGWsV Pt34GQonMpwqdHpuuSq7Gw5+otnOMwdvsWbHlHAx2hA1ipM6uS8QjZFATXuRq22DL9G9w8P40wOju 09cYfgRrxVeAhNmWbJ+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nysKl-00CU1r-BQ; Wed, 08 Jun 2022 09:50:39 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nysJ0-00CTDJ-9L for linux-arm-kernel@lists.infradead.org; Wed, 08 Jun 2022 09:48:52 +0000 Received: by mail-pg1-x52c.google.com with SMTP id c14so18370735pgu.13 for ; Wed, 08 Jun 2022 02:48:47 -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=BEB2zHdExy2JKoB2FnnXWzAZLyF7rSGKqnEw/8nOqCs=; b=BFMw6WULQCXhZ0tMZpRPApSUFdvzdpcdbu7DQ5CIROH9eKmlQdSvTvQvryO95/iwNh KjlKG2uLJlvDV3lsqovmLOB1RgNHoYkLjGCexXy9vCymrGL+byGXwuwL9r0yXNb0mdcf mXOpu12iRggJxkgYZEBDa+j0NDJ2POeM1/G5I= 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=BEB2zHdExy2JKoB2FnnXWzAZLyF7rSGKqnEw/8nOqCs=; b=A4au5RMH/vXwGvp9+Q1AJYAgTt/4HbhXMickgC5a2OI/aGMbwc0Pr+Gs6uJDdGZ3c/ ifpKtCewNbLkgObtXGKFTyZ/uIXoE0FC6eZVpdWu7gqmI733JE0pZ6rlyArtCmggfumB pMlfhats1ASGHjN/95PARGfpyQbSP+NXyCknJIXzeGmq68YKQjRaA9X+AcC21cco/dWB pCUGLLVsjogVcMunUYSZsS4o+byQjkqAqw6YXOlsW8jJCpBRcwaIPYwFIVq9vB1M8kmD zQwQvGREc7+fM+mbTYLp+v0Azbnt9XYk/U7XrDXV7mlq3spbSSwmUjy0MbelacnTrMoD rFJg== X-Gm-Message-State: AOAM533GvYPCFSJcqUMKdMH5NuwL9/L/kDtFFGu17r/iKZ8YBG++q7B7 cqiPJ5WNWlUYEAsSYaDNk7aLGw== X-Google-Smtp-Source: ABdhPJx3PhU71x1q1DzxQGfjWbLB3CXS9FckTrvMBw6DjrgI8cNdYqfg0cuniygWSY3E6OgqeEJ2xg== X-Received: by 2002:a63:8a44:0:b0:3fc:a1f8:806d with SMTP id y65-20020a638a44000000b003fca1f8806dmr29776837pgd.363.1654681727327; Wed, 08 Jun 2022 02:48:47 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:c46b:e7b1:f6c8:5eb8]) by smtp.gmail.com with ESMTPSA id t10-20020a17090a950a00b001e28e80a8d6sm13584038pjo.38.2022.06.08.02.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 02:48:46 -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 v6 8/8] drm: Config orientation property if panel provides it Date: Wed, 8 Jun 2022 17:48:16 +0800 Message-Id: <20220608094816.2898692-9-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608094816.2898692-1-hsinyi@chromium.org> References: <20220608094816.2898692-1-hsinyi@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220608_024850_380006_56409112 X-CRM114-Status: GOOD ( 21.16 ) 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 --- v5->v6: mtk_dsi is using panel bridge, we don't need to obtain the panel in mtk_dsi. Instead, drm_connector_set_orientation_from_panel() can be called from drm_bridge_connector_init(). --- drivers/gpu/drm/bridge/panel.c | 36 ++++++++++++++++++++++++++ drivers/gpu/drm/drm_bridge_connector.c | 8 +++++- include/drm/drm_bridge.h | 3 +++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index 0ee563eb2b6f..53c98cba719b 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -170,6 +170,17 @@ 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. + */ +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 +280,31 @@ 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 + * if the bridge is a panel bridge. + * + * @connector: The connector to be set panel orientation. + * @bridge: The drm_bridge to be transformed to panel bridge. + */ +int drm_panel_bridge_set_orientation(struct drm_connector *connector, + struct drm_bridge *bridge) +{ + struct panel_bridge *panel_bridge; + + if (!bridge) + return 0; + + if (bridge->funcs != &panel_bridge_bridge_funcs) + return 0; + + 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 6b3dad03d77d..1c7d936523df 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 f27b4060faa2..b0691d728139 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -917,10 +917,13 @@ 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,