From patchwork Mon Jul 26 23:13:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 485877 Delivered-To: patch@linaro.org Received: by 2002:a17:907:d92:0:0:0:0 with SMTP id go18csp4069976ejc; Mon, 26 Jul 2021 16:15:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3BnCile4bj+5p4iXRI2v0tFIBwwUOyVzkMqi48ZTMEteJb8amJA/xVgA0MoYTO/1jIhIf X-Received: by 2002:a17:906:d977:: with SMTP id rp23mr19358611ejb.512.1627341346325; Mon, 26 Jul 2021 16:15:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627341346; cv=none; d=google.com; s=arc-20160816; b=hAZ2z69P2a5xMSVSHa7gVAZcIl17zknG4FXb9lLDlod5/m3B5j8KInA/qM4pO0Llg0 YWK4ohmqhE+VfmSIPQXNGGyVOMWnXnX/IjYr9yI1cVga6ZmdDgqFEGb1ld1lE+daGHwv /yNe+hjqw0SL361ZYNdvPA6EqqW7gQrf0mvAMePelRVYRtPaO/HVw8EWHXr6dYcbyj2Z TCV+dXN1QS4qiN0TbGw4Gp7jauCxzM56M90ubX52Q+mbTpfBVWp2KeUOM1Y1t7mD9Rv/ BfR7t0TWNudnIrFqhEe0Livl6nDP4msQ5WuAz0bD7yR+cgTV53kVIOPim1HAi1/BKxtn 4mlw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=WMU3dlNhHc2GMbUZbls+/71C5/GmwZOSbo7SVTlRAII=; b=eAty3tH1v/4YlxhkZ0UCtLkoiJzySoT8zsRDtmThRFEm5gK1tIBQArUT7nRRqSn4mG 7oAPQ++GS7ZT0cF1OdDkJ/f//ENS0GyuTKHNp1yfR4jls+Zpty7hmaR6mihMduC3ovxv 2Uv3CyiQ10oEN5eY+A6Vq5fkIgbTf1jagJ/w00r3TXd+OHNBH/NQ6MMlk/gaHXO1Pv7h 4qwQdb+dCFD0QAxsbdberE/C+CRtazgyfgq5xity5YuRxJ6ohHdhByQWNua9Zvsv5FKN vol664z/JDycAtMd4o5FojyGyigkFQM3G3KmHEJHri4j3/dgl97/s1njeHhj9sTxtb7R uI/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SrG2N5ee; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si1169165ejb.219.2021.07.26.16.15.46; Mon, 26 Jul 2021 16:15:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SrG2N5ee; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233859AbhGZWfP (ORCPT + 17 others); Mon, 26 Jul 2021 18:35:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233742AbhGZWfO (ORCPT ); Mon, 26 Jul 2021 18:35:14 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDD2EC061757 for ; Mon, 26 Jul 2021 16:15:41 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id 19-20020a9d08930000b02904b98d90c82cso11651657otf.5 for ; Mon, 26 Jul 2021 16:15:41 -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:mime-version :content-transfer-encoding; bh=WMU3dlNhHc2GMbUZbls+/71C5/GmwZOSbo7SVTlRAII=; b=SrG2N5ee7wquGKS/862qxUTzO2dKuqeTGjZPhO2vDmpyz9CVonrM3b0AeITcFeUF0R nxV4P7inceNPdw9ot1cdNIevGjAdU2t4ErvoBTzBb0ZioMgm8OteeqEbwHGte3Wyv07L tegS1YfM34a1398S69XYI5WSLkI1OKTVMA+2T9XlpqwvOqW/9to9tmh8VtLVCAvqf6g5 qc8mU1gFCDARhCm/A2dHENlXeZBB2iSYhBu/3JUb79EJLjmoK5c3+ZsSErTXnpkYAYDW pdwnmOdg65hpHzev1PagDul17VbBEunNoJfq5El08Q39O5LyBgTDXiGXaCFbNySB7MM4 o+hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WMU3dlNhHc2GMbUZbls+/71C5/GmwZOSbo7SVTlRAII=; b=m70/pl2KAmqSGiX+g+tfBCHPSvkCcS/LXvXbv4Qi880X4mCyknjQ03lHjoYg95tsmN 3UbWSr24SjeZtuxlEI4UbD5SIh8bJwLSN1ngscmgBBnl+2Q3rUevluldrIGhxP3CGbHl xmRyRVEs0xwMWk+9KKXXUfYevgqlGONDOIs7yDuY0dJeWFUXGWRL1LOPbwRRbVwo5sVL Fhsnbyb2Gheokvvnxm4DpDXVcSqyz4cNAAhGKnVZLC7m06xLnr1BlubUcCTU08VCPpty EJ90RMW5vqk+YzsQEG9yhoBOjnpYs1vNMfEyAqiJhRf4pCuvFRiWD5cCtfhkUPTL9bdO s1JQ== X-Gm-Message-State: AOAM533rShRB3Z7k6LLgfKLE02Eiak8oagXVXzz9bl+dvo5Rcc8/7oQl HtD/WazUBUCH+2xDEKAFTCZrTQ== X-Received: by 2002:a9d:1911:: with SMTP id j17mr13055960ota.70.1627341341218; Mon, 26 Jul 2021 16:15:41 -0700 (PDT) Received: from localhost.localdomain (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id n7sm260844otf.45.2021.07.26.16.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:15:40 -0700 (PDT) From: Bjorn Andersson To: Rob Clark , Sean Paul , David Airlie , Daniel Vetter Cc: Kuogee Hsieh , Abhinav Kumar , Stephen Boyd , Chandan Uddaraju , Vara Reddy , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [RFC] drm/msm/dp: Allow attaching a drm_panel Date: Mon, 26 Jul 2021 16:13:51 -0700 Message-Id: <20210726231351.655302-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org eDP panels might need some power sequencing and backlight management, so make it possible to associate a drm_panel with a DP instance and prepare and enable the panel accordingly. Signed-off-by: Bjorn Andersson --- This solves my immediate problem on my 8cx laptops, of indirectly controlling the backlight during DPMS. But my panel is powered when I boot it and as such I get the hpd interrupt and I don't actually have to deal with a power on sequence - so I'm posting this as an RFC, hoping to get some input on these other aspects. If this is acceptable I'd be happy to write up an accompanying DT binding change that marks port 2 of the DP controller's of_graph as a reference to the attached panel. drivers/gpu/drm/msm/dp/dp_display.c | 15 +++++++++++++-- drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_parser.c | 19 +++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_parser.h | 1 + 4 files changed, 34 insertions(+), 2 deletions(-) -- 2.29.2 diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 206bf7806f51..1db5a3f752d2 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" @@ -252,6 +253,8 @@ static int dp_display_bind(struct device *dev, struct device *master, goto end; } + dp->dp_display.drm_panel = dp->parser->drm_panel; + rc = dp_aux_register(dp->aux, drm); if (rc) { DRM_ERROR("DRM DP AUX register failed\n"); @@ -867,8 +870,10 @@ 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) { + drm_panel_prepare(dp_display->drm_panel); + return 0; } @@ -886,6 +891,8 @@ static int dp_display_enable(struct dp_display_private *dp, u32 data) if (!rc) dp_display->power_on = true; + drm_panel_enable(dp_display->drm_panel); + return rc; } @@ -915,6 +922,8 @@ static int dp_display_disable(struct dp_display_private *dp, u32 data) if (!dp_display->power_on) return 0; + drm_panel_disable(dp_display->drm_panel); + /* wait only if audio was enabled */ if (dp_display->audio_enabled) { /* signal the disconnect event */ @@ -939,8 +948,10 @@ 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) { + drm_panel_unprepare(dp_display->drm_panel); + return 0; } diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 8b47cdabb67e..ce337824c95d 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_panel *drm_panel; bool is_connected; bool audio_enabled; bool power_on; diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index fc8a6452f641..e6a6e9007bfd 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" @@ -276,6 +277,20 @@ static int dp_parser_clock(struct dp_parser *parser) return 0; } +static int dp_parser_find_panel(struct dp_parser *parser) +{ + struct device_node *np = parser->pdev->dev.of_node; + int rc; + + rc = drm_of_find_panel_or_bridge(np, 2, 0, &parser->drm_panel, NULL); + if (rc == -ENODEV) + rc = 0; + else if (rc) + DRM_ERROR("failed to acquire DRM panel: %d\n", rc); + + return rc; +} + static int dp_parser_parse(struct dp_parser *parser) { int rc = 0; @@ -297,6 +312,10 @@ static int dp_parser_parse(struct dp_parser *parser) if (rc) return rc; + 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 3266b529c090..994ca9336acd 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -122,6 +122,7 @@ struct dp_parser { struct dp_display_data disp_data; const struct dp_regulator_cfg *regulator_cfg; u32 max_dp_lanes; + struct drm_panel *drm_panel; int (*parse)(struct dp_parser *parser); };