dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>
Cc: "nfraprado@collabora.com" <nfraprado@collabora.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"wenst@chromium.org" <wenst@chromium.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"kernel@collabora.com" <kernel@collabora.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v6 10/11] drm/mediatek: dp: Add .wait_hpd_asserted() for AUX bus
Date: Mon, 24 Jul 2023 08:43:57 +0000	[thread overview]
Message-ID: <a1240e5d0f8c9f06b571b11c62e917fe033076c7.camel@mediatek.com> (raw)
In-Reply-To: <20230717141438.274419-11-angelogioacchino.delregno@collabora.com>

[-- Attachment #1: Type: text/html, Size: 7795 bytes --]

[-- Attachment #2: Type: text/plain, Size: 4299 bytes --]

Hi, Angelo:

On Mon, 2023-07-17 at 16:14 +0200, AngeloGioacchino Del Regno wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  In order to support usecases in which the panel regulator can be
> switched on and off to save power, and usecases in which the panel
> regulator is off at boot, add a .wait_hpd_asserted() callback for
> the AUX bus: this will make sure to wait until the panel is fully
> ready after power-on before trying to communicate with it.
> 
> Also, parse the eDP display capabilities in that callback, so that
> we can also avoid using the .get_edid() callback from this bridge.
> 
> Since at this point the hpd machinery is performed in the new hpd
> callback and the detection and edid reading are done outside of
> this driver, assign the DRM_BRIDGE_OP_{DETECT, EDID, HPD} ops and
> register the bridge unconditionally at probe time only if we are
> probing full DisplayPort and not eDP while, for the latter, we
> register the bridge in the .done_probing() callback and only if
> the panel was found and triggered HPD.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Signed-off-by: AngeloGioacchino Del Regno <
> angelogioacchino.delregno@collabora.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_dp.c | 45 ++++++++++++++++++++++++++---
> --
>  1 file changed, 38 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c
> b/drivers/gpu/drm/mediatek/mtk_dp.c
> index acdd457b5449..e74295ba9707 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
> @@ -1920,6 +1920,31 @@ static irqreturn_t mtk_dp_hpd_event(int hpd,
> void *dev)
>  	return IRQ_WAKE_THREAD;
>  }
>  
> +static int mtk_dp_wait_hpd_asserted(struct drm_dp_aux *mtk_aux,
> unsigned long wait_us)
> +{
> +	struct mtk_dp *mtk_dp = container_of(mtk_aux, struct mtk_dp,
> aux);
> +	u32 val;
> +	int ret;
> +
> +	ret = regmap_read_poll_timeout(mtk_dp->regs,
> MTK_DP_TRANS_P0_3414,
> +				       val, !!(val &
> HPD_DB_DP_TRANS_P0_MASK),
> +				       wait_us / 100, wait_us);
> +	if (ret) {
> +		mtk_dp->train_info.cable_plugged_in = false;
> +		return ret;
> +	}
> +
> +	mtk_dp->train_info.cable_plugged_in = true;
> +
> +	ret = mtk_dp_parse_capabilities(mtk_dp);
> +	if (ret) {
> +		drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,
>  			   struct platform_device *pdev)
>  {
> @@ -2532,6 +2557,12 @@ static int mtk_dp_edp_link_panel(struct
> drm_dp_aux *mtk_aux)
>  		mtk_dp->next_bridge = NULL;
>  		return ret;
>  	}
> +
> +	/* For eDP, we add the bridge only if the panel was found */
> +	ret = devm_drm_bridge_add(dev, &mtk_dp->bridge);
> +	if (ret)
> +		return ret;
> +
>  	return 0;
>  }
>  
> @@ -2568,6 +2599,7 @@ static int mtk_dp_probe(struct platform_device
> *pdev)
>  	mtk_dp->aux.name = "aux_mtk_dp";
>  	mtk_dp->aux.dev = dev;
>  	mtk_dp->aux.transfer = mtk_dp_aux_transfer;
> +	mtk_dp->aux.wait_hpd_asserted = mtk_dp_wait_hpd_asserted;
>  	drm_dp_aux_init(&mtk_dp->aux);
>  
>  	spin_lock_init(&mtk_dp->irq_thread_lock);
> @@ -2600,15 +2632,8 @@ static int mtk_dp_probe(struct platform_device
> *pdev)
>  
>  	mtk_dp->bridge.funcs = &mtk_dp_bridge_funcs;
>  	mtk_dp->bridge.of_node = dev->of_node;
> -
> -	mtk_dp->bridge.ops =
> -		DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
> DRM_BRIDGE_OP_HPD;
>  	mtk_dp->bridge.type = mtk_dp->data->bridge_type;
>  
> -	ret = devm_drm_bridge_add(dev, &mtk_dp->bridge);
> -	if (ret)
> -		return dev_err_probe(dev, ret, "Failed to add
> bridge\n");
> -
>  	mtk_dp->need_debounce = true;
>  	timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0);
>  
> @@ -2647,6 +2672,12 @@ static int mtk_dp_probe(struct platform_device
> *pdev)
>  				return ret;
>  			}
>  		}
> +	} else {
> +		mtk_dp->bridge.ops = DRM_BRIDGE_OP_DETECT |
> +				     DRM_BRIDGE_OP_EDID |
> DRM_BRIDGE_OP_HPD;
> +		ret = devm_drm_bridge_add(dev, &mtk_dp->bridge);
> +		if (ret)
> +			return dev_err_probe(dev, ret, "Failed to add
> bridge\n");
>  	}
>  
>  	pm_runtime_enable(dev);
> -- 
> 2.40.1

  parent reply	other threads:[~2023-07-24  8:44 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 14:14 [PATCH v6 00/11] MediaTek DisplayPort: support eDP and aux-bus AngeloGioacchino Del Regno
2023-07-17 14:14 ` [PATCH v6 01/11] drm/mediatek: dp: Add missing error checks in mtk_dp_parse_capabilities AngeloGioacchino Del Regno
2023-07-18  8:02   ` CK Hu (胡俊光)
2023-07-20 15:56   ` Alexandre Mergnat
2023-07-17 14:14 ` [PATCH v6 02/11] drm/mediatek: dp: Move AUX and panel poweron/off sequence to function AngeloGioacchino Del Regno
2023-07-18  7:49   ` CK Hu (胡俊光)
2023-07-20 15:56   ` Alexandre Mergnat
2023-07-17 14:14 ` [PATCH v6 03/11] drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer() AngeloGioacchino Del Regno
2023-07-18  9:19   ` CK Hu (胡俊光)
2023-07-20 15:57   ` Alexandre Mergnat
2023-07-17 14:14 ` [PATCH v6 04/11] drm/mediatek: dp: Use devm variant of drm_bridge_add() AngeloGioacchino Del Regno
2023-07-18  9:33   ` CK Hu (胡俊光)
2023-07-20 15:58   ` Alexandre Mergnat
2023-07-17 14:14 ` [PATCH v6 05/11] drm/mediatek: dp: Move AUX_P0 setting to mtk_dp_initialize_aux_settings() AngeloGioacchino Del Regno
2023-07-20  2:01   ` CK Hu (胡俊光)
2023-07-20 15:59   ` Alexandre Mergnat
2023-07-17 14:14 ` [PATCH v6 06/11] drm/mediatek: dp: Enable event interrupt only when bridge attached AngeloGioacchino Del Regno
2023-07-20 13:03   ` Alexandre Mergnat
2023-07-17 14:14 ` [PATCH v6 07/11] drm/mediatek: dp: Avoid mutex locks if audio is not supported/enabled AngeloGioacchino Del Regno
2023-07-20 13:05   ` Alexandre Mergnat
2023-07-24  2:33   ` CK Hu (胡俊光)
2023-07-17 14:14 ` [PATCH v6 08/11] drm/mediatek: dp: Move PHY registration to new function AngeloGioacchino Del Regno
2023-07-20 13:58   ` Alexandre Mergnat
2023-07-17 14:14 ` [PATCH v6 09/11] drm/mediatek: dp: Add support for embedded DisplayPort aux-bus AngeloGioacchino Del Regno
2023-07-20 14:30   ` Alexandre Mergnat
2023-07-24  6:24   ` CK Hu (胡俊光)
2023-07-17 14:14 ` [PATCH v6 10/11] drm/mediatek: dp: Add .wait_hpd_asserted() for AUX bus AngeloGioacchino Del Regno
2023-07-20 15:03   ` Alexandre Mergnat
2023-07-24  8:43   ` CK Hu (胡俊光) [this message]
2023-07-17 14:14 ` [PATCH v6 11/11] drm/mediatek: dp: Don't register HPD interrupt handler for eDP case AngeloGioacchino Del Regno
2023-07-20 15:55   ` Alexandre Mergnat
2023-07-25  6:37   ` CK Hu (胡俊光)
2023-07-25  7:19     ` AngeloGioacchino Del Regno
2023-07-19  4:00 ` [PATCH v6 00/11] MediaTek DisplayPort: support eDP and aux-bus Chen-Yu Tsai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1240e5d0f8c9f06b571b11c62e917fe033076c7.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nfraprado@collabora.com \
    --cc=wenst@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).