Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5963418pxv; Thu, 29 Jul 2021 03:01:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwP4QwABH4jykekcA72r80VnFERew6Aj1ky+FBCHtZMBOMUx4p6vlyEkKDpGl01Htt701uP X-Received: by 2002:a17:907:a075:: with SMTP id ia21mr3807024ejc.147.1627552876660; Thu, 29 Jul 2021 03:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627552876; cv=none; d=google.com; s=arc-20160816; b=FgurYvRo0/4hViIRZBHy6oYHn86tGunM6/LJHi8+z9lY6Ofss/UvO3NGMei5T0wY98 P08jp7h1x1X+aUvo2IA9Zv7eOgt5qiYBB1EEH89l8aIGrYMtM4zOyTeh81ilULdb/4+S pFL5dV4zhrHIeDxmH2w3YkL4Y+YUzVlbFdpzSshQH8DPu8DXDcVADRg2h6/XQw5uWpMw tsM0spy6JuoGFU5pI3JtaOLlIkC+AzQE4/AC0atDtLxBxitE4SRen3GrFvsJrUyQykQI I1yRcoag2DVTiVuEvkOKfC6Ut0TMimdprx3BEKqHxPFKJWs8YoTPs+7vkn6mkUmsYFM1 jh/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=nIej11/PYcGeLGxt7QOR+AppfCQjgzk8NOs4YUKmoVs=; b=eyaF1BvnKVNu2J/DuOZekxZ8XoE8L9j8rK3rv2Rl3cXxhGpDgjvvqQlHRaouVSsrsk W3OwdoQpZyotlVMNAD2/VT1VIqykzGUC6EhPI7+lyUE8sUcTM4y3WAlMVaTvjCmRbwJP YAHy4K0n1lUUMfW6siQLP0fknAp2IzITp2Uu7Qu7ViF8b+Sy7FYnhC8pPAeUER3JG19d ZRgXTZ7D+hV3X2GI5ecqyqpZv9jl8mghDlFXd8WDklwKkCUmuF7qQ/08mEmpiA6ZVmMd zhf1ffuNOopsoRGJbOwOuUb52CMdAPe+bVoAv4IWr9ROqmJIHcdI8EZBkPrS4HwN975A iaxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="m6MS/ZA3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 k19si2174211eds.581.2021.07.29.03.00.53; Thu, 29 Jul 2021 03:01:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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="m6MS/ZA3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S235929AbhG2J7V (ORCPT + 99 others); Thu, 29 Jul 2021 05:59:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235544AbhG2J7U (ORCPT ); Thu, 29 Jul 2021 05:59:20 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE2CCC061765 for ; Thu, 29 Jul 2021 02:59:16 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id h9so6791349ljq.8 for ; Thu, 29 Jul 2021 02:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nIej11/PYcGeLGxt7QOR+AppfCQjgzk8NOs4YUKmoVs=; b=m6MS/ZA3IHYlnwTYoSS9WTrTqje10ox98fXiIHsiSs6fIpuUWgFw5PJ2vLzgiH9wXm oNfNwAKxV9xDmZdElU1gKVLdVXRyThDU+SXgY69YWjaRBJMBtxG0z3wQw7QWTapcts9O iN1OGi3uMFfiO74SU0ONms6KT5r1gWDPbABFRueW9HvNGsN6QmzU07E7pvIPOI8xZ3K5 zYg7Tw/HopP5eN/tkjneBmxwAy3udxo8HUBRPuFH6YrHRzIipKqcfi67LLC9yY8F/I15 YD19xIMW9/LGzpCQ3bwTc4kf7Yw+RkYA3Z1MMjpkJ62ao7I0D49Apn5ZdAQB1eZwmIgn hnHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nIej11/PYcGeLGxt7QOR+AppfCQjgzk8NOs4YUKmoVs=; b=WiAnjnpgfj/JBrF9EDRGtCyVNyQhdZF+rYJOEOECrhHYxKAphVDayHwK+n9HgizK3u WIBn/lybrBApOvpy6p9ajxgtuWfu8tXVbBScvfjwFys+hQdh0iOvWR7q9sOn8tMomWSv rKv6RVc5mDHYV4CnsZkGWjfF/FHwUoRovoZOUcJ65jvfsDvhze/3eR/dOcrpptI4dIDa +/HGTYF08B73hhxB6UXdj1yZtVb2dMYq+3d+eCtOW0Li7/isUSpIrKoMhWWK/H3ySBdl Vs72V2eBuEx66+O4Nk7RFF0MVNpWlkFO7PYbE9Q17e4/xJ7epptPmXB71tPig6IE9suP SZ6w== X-Gm-Message-State: AOAM530uGCczYCznxVjjjbk6+pnLZnT8egZPcmkMa4tY04ZQlisIpdQ2 nq536FvJvS2GJx53B8gSuuuc6Y+LWZm7tg== X-Received: by 2002:a2e:b0c5:: with SMTP id g5mr2418335ljl.41.1627552754933; Thu, 29 Jul 2021 02:59:14 -0700 (PDT) Received: from [192.168.1.211] ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id x3sm117577ljd.66.2021.07.29.02.59.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jul 2021 02:59:14 -0700 (PDT) Subject: Re: [RFC] drm/msm/dp: Allow attaching a drm_panel To: Bjorn Andersson , 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 References: <20210726231351.655302-1-bjorn.andersson@linaro.org> From: Dmitry Baryshkov Message-ID: <3bb5dc26-6779-6cb4-b9dd-e64c306e9ae6@linaro.org> Date: Thu, 29 Jul 2021 12:59:13 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210726231351.655302-1-bjorn.andersson@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/07/2021 02:13, Bjorn Andersson wrote: > 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 The idea looks good from my point of view. For v1 could you please extend it with the `if (panel)` checks and handling of the error codes. > --- > > 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(-) > > 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); > }; > -- With best wishes Dmitry