From patchwork Wed Jun 17 16:40:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11610255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BDAF90 for ; Wed, 17 Jun 2020 16:41:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6AFA521532 for ; Wed, 17 Jun 2020 16:41:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ebALz5Zc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6AFA521532 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B82A56E98B; Wed, 17 Jun 2020 16:41:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by gabe.freedesktop.org (Postfix) with ESMTPS id 35B0F6E98B for ; Wed, 17 Jun 2020 16:40:54 +0000 (UTC) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DEC03DC3; Wed, 17 Jun 2020 18:40:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1592412050; bh=bVaYQZTf+RgPFKMW2r9nBqtm0idCSxHm+2h/JHNlRCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ebALz5Zcaww9IzhUh6Ojokzey62ZqQPaJ5kSQRAeNhcdeq7MSzFJv66k2FQmh/EZJ 3vMqKebvtfNKF32h3hl6PSZzIH4Kq4Hxt/zP7RScgqUCwynNmBWhU/C9q2JrPMFmnP oxXBxTg+Ho/xuZdWtu24C3sMuWGLhxtSOP2qAVf4= From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 14/22] drm: mxsfb: Enable vblank handling Date: Wed, 17 Jun 2020 19:40:07 +0300 Message-Id: <20200617164015.30448-15-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200617164015.30448-1-laurent.pinchart@ideasonboard.com> References: <20200617164015.30448-1-laurent.pinchart@ideasonboard.com> 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: , Cc: Marek Vasut , robert.chiras@nxp.com, leonard.crestez@nxp.com, linux-imx@nxp.com, kernel@pengutronix.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Enable vblank handling when the CRTC is turned on and disable it when it is turned off. This requires moving vblank init after the KMS pipeline initialisation, otherwise drm_vblank_init() gets called with 0 CRTCs. Signed-off-by: Laurent Pinchart Reviewed-by: Emil Velikov Reviewed-by: Stefan Agner --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 15 +++++++++------ drivers/gpu/drm/mxsfb/mxsfb_kms.c | 6 +++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index 752373803055..cece90101731 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -161,12 +161,6 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) pm_runtime_enable(drm->dev); - ret = drm_vblank_init(drm, drm->mode_config.num_crtc); - if (ret < 0) { - dev_err(drm->dev, "Failed to initialise vblank\n"); - goto err_vblank; - } - /* Modeset init */ drm_mode_config_init(drm); @@ -176,6 +170,15 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) goto err_vblank; } + ret = drm_vblank_init(drm, drm->mode_config.num_crtc); + if (ret < 0) { + dev_err(drm->dev, "Failed to initialise vblank\n"); + goto err_vblank; + } + + /* Start with vertical blanking interrupt reporting disabled. */ + drm_crtc_vblank_off(&mxsfb->crtc); + ret = mxsfb_attach_bridge(mxsfb); if (ret) { dev_err(drm->dev, "Cannot connect bridge: %d\n", ret); diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c index a8172fd6cd41..aa9e962bb026 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c @@ -322,8 +322,10 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc, dma_addr_t paddr; pm_runtime_get_sync(drm->dev); - mxsfb_enable_axi_clk(mxsfb); + + drm_crtc_vblank_on(crtc); + mxsfb_crtc_mode_set_nofb(mxsfb); /* Write cur_buf as well to avoid an initial corrupt frame */ @@ -353,6 +355,8 @@ static void mxsfb_crtc_atomic_disable(struct drm_crtc *crtc, } spin_unlock_irq(&drm->event_lock); + drm_crtc_vblank_off(crtc); + mxsfb_disable_axi_clk(mxsfb); pm_runtime_put_sync(drm->dev); }