Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp753964ybt; Wed, 8 Jul 2020 10:48:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxD0cLZzTieZhmc8UuiySA1VoPdfuLi5elg8pjVxtHc5E6UM1M8bEVufb0VWnp/tWkDnJiH X-Received: by 2002:a05:6402:543:: with SMTP id i3mr47559186edx.182.1594230493128; Wed, 08 Jul 2020 10:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594230493; cv=none; d=google.com; s=arc-20160816; b=CexXkyLsGMki3aV+0mSdFGEPwt4CUsMfnhvfd7J69EF3HaQXMGjodTdF+MZNqbE17t C3a205hx9IFovmAz0dwkPPJNYd6OJnXf9pCfvssnvBHrQPfrtuQrb6vzRW55r7hooWv+ QHyjcuoLBS8oSHb4yCOo6Iu5BU6UgQ8N6x12hvLd40iQs3UxAjjzeQocfyYXFUw88HSZ +Xt/I6G7n4alP1pxY8wq8NLhV3nCz2Lt7d6XLy3wJ4o1akRPS7sB9P1nOnaEFThMzPvh O1LCxUyOq8O0jba0u197teyN3TYTctQstqUcQZV2SDf4O2jP8l4eoY+bo1IAIGQmren1 XUDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=OPwpf7AJPvnM3wfC6Osbwbhj72RnySra1ptXGlxgjKQ=; b=LPmEOEvNPsAh00MPVn1VDXUDjHA462PUcwvGG2JKRi1NW9Sr+LZNnjG+sMgorCI7Tj vGYYSIOVXXk1Rd3IVMxHge6+1hM+1yvTEbHsUJiqKjNBJBio3Dn73rROcRUk5NJZ8o8Q EVErXFc1EzaVow1J0bxBvvr9VZnGIDw9JQ+fig87bhG8mcdReMYBbEK/z+gMq7QsDMJn NN/bK241CBd93MvsiTLHILQH/LDkmGdcEL50dwliTQuKv3FS/DM6wHlP7etn5Sc369no wt2GecMuAtGoQO4HJvTRD1pEkgM6n6mstzVXeKHRKgpJE1jnvzsFAcJ+CVcM9IHm+M1u OmFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=Qn3zo2ep; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=plSLuGpG; 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=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p10si428268eds.221.2020.07.08.10.47.49; Wed, 08 Jul 2020 10:48:13 -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=@cerno.tech header.s=fm3 header.b=Qn3zo2ep; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=plSLuGpG; 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=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728200AbgGHRor (ORCPT + 99 others); Wed, 8 Jul 2020 13:44:47 -0400 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:34247 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727949AbgGHRoP (ORCPT ); Wed, 8 Jul 2020 13:44:15 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 0F682FD0; Wed, 8 Jul 2020 13:44:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 08 Jul 2020 13:44:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=OPwpf7AJPvnM3 wfC6Osbwbhj72RnySra1ptXGlxgjKQ=; b=Qn3zo2epNnLJX2+cTzS1mpRUixldV jg1JIHcy+Ky8Fo9I1bjz0qiq/TXkA8RgHxvOJju60uX5SOsLIIkso09921ffrBcA d3VNvINM87eFqgWjvQmlH3kKygvqFbOLTY+XnGGD6nw4MhQuRnZ8u9XHfObywizo fLM1VAVjPGXAF0vsJSXM6I+m64ryluoFdmKZfv6nTTuFV5vJfxQM3Jzp5uzkVGkp JPVSyP35naljP77ttykvnXBp1IX6lutBw+GCX8F9cB/19bv7JdygbroYPeVBBK4Z oyPnYAipc5lDAkKCaKddIH90fVjKZGjod8bVFRZLnVkp8etq7stl/n8Eg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=OPwpf7AJPvnM3wfC6Osbwbhj72RnySra1ptXGlxgjKQ=; b=plSLuGpG AxCPACYMy5oEzEYvxXVFICOEc/+N7f0zSih5y/MMBv2emIILWLG+6Yq2fR+lWxkQ EfuSrQaCpaF9cH/hUJGcxWW+G7cX51RrCx3YMdGPN+fNb7GN6aW+hLrOshhl7mIb NuTD1Az17E/gJncyJcRRTNBAnIjqYOcmzKVVsIIjjpHRLyp8IdzNDK/X6056PDWd oZ4q8BdZJO7nJ3oD1uvD30hIbP79MsYI93q420z+hgAqKrf6X0iQJqJ9Ryaldk6b 5faWDGQrvRuktbD/FwtFNtBY6oV71WAyuZLgtLsTzgFAmZ/Z0AM+pbC0DAqvpEul V9TzILXS59f3sw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudejgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepfeevhfdvvdeivdeihefftddvtefgieegffevhfeilefgfeeuteevudejgedu lefhnecuffhomhgrihhnpegsrghsvgdrphhoshhtnecukfhppeeltddrkeelrdeikedrje einecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgr gihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 4C41B306005F; Wed, 8 Jul 2020 13:44:13 -0400 (EDT) From: Maxime Ripard To: Nicolas Saenz Julienne , Eric Anholt Cc: dri-devel@lists.freedesktop.org, linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Stevenson , Tim Gover , Phil Elwell , Maxime Ripard Subject: [PATCH v4 71/78] drm/vc4: hdmi: Implement finer-grained hooks Date: Wed, 8 Jul 2020 19:42:19 +0200 Message-Id: <496aecbe04aa460572d4ff02a64e77ca01368316.1594230107.git-series.maxime@cerno.tech> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to prevent some pixels getting stuck in an unflushable FIFO on bcm2711, we need to enable the HVS, the pixelvalve (the CRTC) and the HDMI controller (the encoder) in an intertwined way, and with tight delays. However, the atomic callbacks don't really provide a way to work with either constraints, so we need to roll our own callbacks so that we can provide those guarantees. Since those callbacks have been implemented and called in the CRTC code, we can just implement them in the HDMI driver now. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 39 +++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 00592c1ada73..bbe521ab000b 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -320,12 +320,17 @@ static void vc4_hdmi_set_infoframes(struct drm_encoder *encoder) vc4_hdmi_set_audio_infoframe(encoder); } -static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder) +static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder) { struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); - int ret; HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0); +} + +static void vc4_hdmi_encoder_post_crtc_powerdown(struct drm_encoder *encoder) +{ + struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); + int ret; if (vc4_hdmi->variant->phy_disable) vc4_hdmi->variant->phy_disable(vc4_hdmi); @@ -341,6 +346,10 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder) DRM_ERROR("Failed to release power domain: %d\n", ret); } +static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder) +{ +} + static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, bool enable) { u32 csc_ctl; @@ -449,11 +458,10 @@ static void vc4_hdmi_recenter_fifo(struct vc4_hdmi *vc4_hdmi) "VC4_HDMI_FIFO_CTL_RECENTER_DONE"); } -static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) +static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder) { struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); - struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder); unsigned long pixel_rate, hsm_rate; int ret; @@ -521,6 +529,13 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) if (vc4_hdmi->variant->set_timings) vc4_hdmi->variant->set_timings(vc4_hdmi, mode); +} + +static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder) +{ + struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; + struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder); + struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); if (vc4_encoder->hdmi_monitor && drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED) { @@ -536,6 +551,13 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) } HDMI_WRITE(HDMI_FIFO_CTL, VC4_HDMI_FIFO_CTL_MASTER_SLAVE_N); +} + +static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder) +{ + struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); + struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder); + int ret; HDMI_WRITE(HDMI_VID_CTL, HDMI_READ(HDMI_VID_CTL) | @@ -582,6 +604,10 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) vc4_hdmi_recenter_fifo(vc4_hdmi); } +static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) +{ +} + static enum drm_mode_status vc4_hdmi_encoder_mode_valid(struct drm_encoder *encoder, const struct drm_display_mode *mode) @@ -1362,6 +1388,11 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) dev_set_drvdata(dev, vc4_hdmi); encoder = &vc4_hdmi->encoder.base.base; vc4_hdmi->encoder.base.type = variant->encoder_type; + vc4_hdmi->encoder.base.pre_crtc_configure = vc4_hdmi_encoder_pre_crtc_configure; + vc4_hdmi->encoder.base.pre_crtc_enable = vc4_hdmi_encoder_pre_crtc_enable; + vc4_hdmi->encoder.base.post_crtc_enable = vc4_hdmi_encoder_post_crtc_enable; + vc4_hdmi->encoder.base.post_crtc_disable = vc4_hdmi_encoder_post_crtc_disable; + vc4_hdmi->encoder.base.post_crtc_powerdown = vc4_hdmi_encoder_post_crtc_powerdown; vc4_hdmi->pdev = pdev; vc4_hdmi->variant = variant; -- git-series 0.9.1