From patchwork Sat Oct 16 22:18:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 515905 Delivered-To: patch@linaro.org Received: by 2002:ac0:cd8c:0:0:0:0:0 with SMTP id d12csp279662imp; Sat, 16 Oct 2021 15:17:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrgl4QsBjtlCSXene+T+UU/ilbsa0mHi9S7FG7+/6eauvFPLqOvkhjCmlzv6lyhKjjYTjE X-Received: by 2002:a17:902:c20c:b0:13a:3f4a:db58 with SMTP id 12-20020a170902c20c00b0013a3f4adb58mr18298147pll.12.1634422647428; Sat, 16 Oct 2021 15:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634422647; cv=none; d=google.com; s=arc-20160816; b=VlpS9tQ/KhOqDOlrCMLM6fzD3SXGWyNrtE4XlmVnPhnNEJhSWjiUqfjdVHkl2HXlRN MPYemItmlGsa+GW7PnRSSJ8H807XyN8Hzn/bfAFCwLGS5Db+fJBLjZIDVrcSlgPFe6iN yzivzPShxv6dTF3PwU4MNXxowvBM9e1KRhR81j7whPoD/vHQWLPXaNEBXBuizEPRO5+u I1haH6ZlB1oVxxxh/c+qA4VINhCqENyOK+YLrn2eSnoE0MSAkeNwFC4o+dLWGIHDgzsw m4AsmYF1dMsQFN2oM58TTOS6xFk8KmIZUqETEge1KsMU351x79Ejb8d3xBhirdoDIEbk 1WFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:delivered-to; bh=j8CkjnvD4XYRJbxbrS217o1yjl7s34UqdCCgpWSb1Mk=; b=aA4xuRVWZ3kMCbupVheg1u7Wt5NUtIg4CAewmSK2aC+YCWKrbZPuxR3G2sM9kSldCD 3z7NdOoGGkN57qsYrKoFbuqHzGSYYOFzajFkWruAVfK7JNusosHsNdJj9XskgVK8bOgP aoNlSOYOXlNc0mSl9zuleuOrs4+mMM77yauuco6bQE0mUmJs96Nk1JV0ghwemL+W/3XF zcfuqbo0m1oBGqfz1tcALzbz1qmuAyjbxIBr14cs0+xvS5Q//pSwIChIlN2muw0U3uGD NH0+nhq9LS3FjmjCdYgeKyz7VcT3d8LUvzDks98CD55E9clyyX0UyQQpljjGy66IotR4 pN8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AwNEKj9p; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id c4si14532609plg.374.2021.10.16.15.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Oct 2021 15:17:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AwNEKj9p; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 172996E8F6; Sat, 16 Oct 2021 22:17:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D7A36E8E8 for ; Sat, 16 Oct 2021 22:16:59 +0000 (UTC) Received: by mail-ot1-x329.google.com with SMTP id x33-20020a9d37a4000000b0054733a85462so181975otb.10 for ; Sat, 16 Oct 2021 15:16:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j8CkjnvD4XYRJbxbrS217o1yjl7s34UqdCCgpWSb1Mk=; b=AwNEKj9pbK/6em9liphva8EPTdEhaVRayPPdnsAA6F/l6pw8BaPCPLNq8bUoVeXjWQ Nw4FQj+jSQhS8ILFhIvZYoUDCQj9EY6nzxLW7Mq4V+hc0nfU1IN/PYnrDOu7WFNdwYV8 ESvgmjqGlyDtGmcPr7J9dMq54Dvwm27Sq16AegCuDSxdx8OJodxBGOWibYukb6zB9/Cj d7mjEGc5HKbgIMT659oc/daYTQxQO4n+wfZVgcf7BdRnMFvgcRnG3bCfMmS76TjXm7Ij Hi+ExykxQHHt/WvU9PA/FzGDhMyNAMesFXpYekBR7qDQOjI15PMzaA352oFoVgr0VB5g E18A== 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=j8CkjnvD4XYRJbxbrS217o1yjl7s34UqdCCgpWSb1Mk=; b=U71LO+ANPGhjY9u9ZjOwCRxSCh2vMClKkdjw0oXDbh9p02e1GH9buhe/qLILCJLoTF NUWszgD+8agozazWJMmMCIBqs6+5jXo9LoC8xqrjDJ95+aXpiXV+sSXVGDIdJ2bIJnq8 DhhhvSaQdoDAUM4lqDKnyAJI2FziWES8X4gL8NXk/s2yxg0+tap3u4eOrG4MksMNlZj/ +2Vzkyf4vi9/x56URI1m6SwGLL1qfwhtZQUo/FEzDNTM02IhundzEJLG0ZGkGvdqc8Yu r6+7x1Wq3w3P79kOgtjFgVXAoRqM6VDfQXYYzf0ay269nIEf9RmpwJ6/wVxP9BzCGd9N 0s6w== X-Gm-Message-State: AOAM530iCg9JkJoz983laize3pR6+aDfjKqattctcSg6j1Ya4HmYrV4j JlgVd6G/r81P54rS59oC99T/6Q== X-Received: by 2002:a9d:718e:: with SMTP id o14mr15089096otj.299.1634422618854; Sat, 16 Oct 2021 15:16:58 -0700 (PDT) Received: from localhost.localdomain ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id d15sm1747058oic.32.2021.10.16.15.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Oct 2021 15:16:58 -0700 (PDT) From: Bjorn Andersson To: Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Abhinav Kumar , Dmitry Baryshkov , Kalyan Thota , Kuogee Hsieh Cc: Rob Herring , Stephen Boyd , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/7] drm/msm/dp: Allow attaching a drm_panel Date: Sat, 16 Oct 2021 15:18:40 -0700 Message-Id: <20211016221843.2167329-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211016221843.2167329-1-bjorn.andersson@linaro.org> References: <20211016221843.2167329-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" eDP panels might need some power sequencing and backlight management, so make it possible to associate a drm_panel with an eDP instance and prepare and enable the panel accordingly. Now that we know which hardware instance is DP and which is eDP, parser->parse() is passed the connector_type and the parser is limited to only search for a panel in the eDP case. Signed-off-by: Bjorn Andersson --- Changes since v4: - None drivers/gpu/drm/msm/dp/dp_display.c | 9 ++++++--- drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_drm.c | 11 +++++++++++ drivers/gpu/drm/msm/dp/dp_parser.c | 30 ++++++++++++++++++++++++++++- drivers/gpu/drm/msm/dp/dp_parser.h | 3 ++- 5 files changed, 49 insertions(+), 5 deletions(-) -- 2.29.2 Reviewed-by: Stephen Boyd Reviewed-by: Abhinav Kumar diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 6913970c8cf9..c663cd619925 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "msm_drv.h" #include "msm_kms.h" @@ -230,12 +231,14 @@ static int dp_display_bind(struct device *dev, struct device *master, priv = drm->dev_private; priv->dp = &(dp->dp_display); - rc = dp->parser->parse(dp->parser); + rc = dp->parser->parse(dp->parser, dp->dp_display.connector_type); if (rc) { DRM_ERROR("device tree parsing failed\n"); goto end; } + dp->dp_display.panel_bridge = dp->parser->panel_bridge; + dp->aux->drm_dev = drm; rc = dp_aux_register(dp->aux); if (rc) { @@ -822,7 +825,7 @@ static int dp_display_set_mode(struct msm_dp *dp_display, return 0; } -static int dp_display_prepare(struct msm_dp *dp) +static int dp_display_prepare(struct msm_dp *dp_display) { return 0; } @@ -896,7 +899,7 @@ static int dp_display_disable(struct dp_display_private *dp, u32 data) return 0; } -static int dp_display_unprepare(struct msm_dp *dp) +static int dp_display_unprepare(struct msm_dp *dp_display) { return 0; } diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 75fcabcfbbdd..8e80e3bac394 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.h +++ b/drivers/gpu/drm/msm/dp/dp_display.h @@ -15,6 +15,7 @@ struct msm_dp { struct device *codec_dev; struct drm_connector *connector; struct drm_encoder *encoder; + struct drm_bridge *panel_bridge; bool is_connected; bool audio_enabled; bool power_on; diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c index f33e31523f56..76856c4ee1d6 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.c +++ b/drivers/gpu/drm/msm/dp/dp_drm.c @@ -5,6 +5,7 @@ #include #include +#include #include #include "msm_drv.h" @@ -160,5 +161,15 @@ struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display) drm_connector_attach_encoder(connector, dp_display->encoder); + if (dp_display->panel_bridge) { + ret = drm_bridge_attach(dp_display->encoder, + dp_display->panel_bridge, NULL, + DRM_BRIDGE_ATTACH_NO_CONNECTOR); + if (ret < 0) { + DRM_ERROR("failed to attach panel bridge: %d\n", ret); + return ERR_PTR(ret); + } + } + return connector; } diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index 4d6e047f803d..eb6bbfbea484 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ b/drivers/gpu/drm/msm/dp/dp_parser.c @@ -6,6 +6,7 @@ #include #include +#include #include #include "dp_parser.h" @@ -263,7 +264,28 @@ static int dp_parser_clock(struct dp_parser *parser) return 0; } -static int dp_parser_parse(struct dp_parser *parser) +static int dp_parser_find_panel(struct dp_parser *parser) +{ + struct device *dev = &parser->pdev->dev; + struct drm_panel *panel; + int rc; + + rc = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL); + if (rc) { + DRM_ERROR("failed to acquire DRM panel: %d\n", rc); + return rc; + } + + parser->panel_bridge = devm_drm_panel_bridge_add(dev, panel); + if (IS_ERR(parser->panel_bridge)) { + DRM_ERROR("failed to create panel bridge\n"); + return PTR_ERR(parser->panel_bridge); + } + + return 0; +} + +static int dp_parser_parse(struct dp_parser *parser, int connector_type) { int rc = 0; @@ -284,6 +306,12 @@ static int dp_parser_parse(struct dp_parser *parser) if (rc) return rc; + if (connector_type == DRM_MODE_CONNECTOR_eDP) { + rc = dp_parser_find_panel(parser); + if (rc) + return rc; + } + /* Map the corresponding regulator information according to * version. Currently, since we only have one supported platform, * mapping the regulator directly. diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h index dac10923abde..3172da089421 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -123,8 +123,9 @@ struct dp_parser { struct dp_display_data disp_data; const struct dp_regulator_cfg *regulator_cfg; u32 max_dp_lanes; + struct drm_bridge *panel_bridge; - int (*parse)(struct dp_parser *parser); + int (*parse)(struct dp_parser *parser, int connector_type); }; /**