From patchwork Sat Feb 6 03:24:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang Liu X-Patchwork-Id: 8241071 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 35D6EBEEE5 for ; Sat, 6 Feb 2016 03:26:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B541202F2 for ; Sat, 6 Feb 2016 03:26:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 437EE20279 for ; Sat, 6 Feb 2016 03:25:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B8B87205A; Fri, 5 Feb 2016 19:25:58 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-f176.google.com (mail-pf0-f176.google.com [209.85.192.176]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F78F7205A for ; Fri, 5 Feb 2016 19:25:57 -0800 (PST) Received: by mail-pf0-f176.google.com with SMTP id n128so78265883pfn.3 for ; Fri, 05 Feb 2016 19:25:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dVdrC6iIdcESjfIfRA7s2OKLPSHp13d24ihphBs7xUY=; b=HTN2BMFsDh9xEy3M4sGokavqo4bNg1TRIFTJ2aPB74wS95qGt6kQWtsUzvpw5IPbRd Tbk3tv02SpYSWcMi6PbYDt1La0/VCBUzqCeMykOVig9HtTuOh0aDJRot63CgFZ4bD0XM Y24BlQZSaosoaWvlwvYjBQGgxQbpB9T2Msh98= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dVdrC6iIdcESjfIfRA7s2OKLPSHp13d24ihphBs7xUY=; b=cd1lI5Zl5VH+I1iULtRLlIIxkLpQmt0k/LmwPcYRYsQqEZL8HN8zUcL1W8qJV/V+A2 UaJCgNRuIziKUYdGm1n7y0FmPxDY0WBvQzIiOzhgIEZ0NA5f+5gv9WA8AKy/K4yj+AYT BTFZSofTsMtRpVUOybq72Y5oZUCqiSgJbTOzjzp1rDDQvMTgWSGXBvEMEx8cJQdRGIpT BhDckOAHqRdKoDWueyZ26/AcE7yFhw2ENpGhKhXPerKpRAmaw5KaboMMElCjlYhDn2xp nTCs0Avsg+4zHVBosPCNPOWrZue41xFfTbLDh3G8jAR2X6B8U/A7xe/LFPVlSeqSyOZz 7DRg== X-Gm-Message-State: AG10YOT73+iZsqHF0kvpyKHAoC0O1b+6roDDAamiEvRYuhH23CcanNhbenDWgqmkFSl8qZnk X-Received: by 10.98.71.130 with SMTP id p2mr24713723pfi.99.1454729157128; Fri, 05 Feb 2016 19:25:57 -0800 (PST) Received: from localhost.localdomain ([219.134.80.72]) by smtp.gmail.com with ESMTPSA id a21sm27472023pfj.40.2016.02.05.19.25.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Feb 2016 19:25:56 -0800 (PST) From: Xinliang Liu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, daniel@ffwll.ch, robh@kernel.org, daniel@fooishbar.org, architt@codeaurora.org, airlied@linux.ie, corbet@lwn.net, catalin.marinas@arm.com, will.deacon@arm.com, emil.l.velikov@gmail.com Subject: [PATCH v4 05/11] drm/hisilicon: Add vblank driver for ADE Date: Sat, 6 Feb 2016 11:24:52 +0800 Message-Id: <1454729098-79807-6-git-send-email-xinliang.liu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454729098-79807-1-git-send-email-xinliang.liu@linaro.org> References: <1454729098-79807-1-git-send-email-xinliang.liu@linaro.org> Cc: andy.green@linaro.org, xuyiping@hisilicon.com, guodong.xu@linaro.org, linux-doc@vger.kernel.org, w.f@huawei.com, zourongrong@huawei.com, linuxarm@huawei.com, xuwei5@hisilicon.com, bintian.wang@huawei.com, haojian.zhuang@linaro.org, benjamin.gaignard@linaro.org, puck.chen@hisilicon.com, liguozhu@hisilicon.com, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add vblank irq handle. v4: None. v3: - Remove hisi_get_crtc_from_index func. - A few cleanup. v2: - Remove abtraction layer. Signed-off-by: Xinliang Liu --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 62 +++++++++++++++++++++++++ drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 14 +++++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index ff70f1c3dd78..2a12e14ea6ab 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -295,6 +295,59 @@ static void ade_set_medianoc_qos(struct ade_crtc *acrtc) writel(val, reg); } +static int ade_enable_vblank(struct drm_device *dev, unsigned int pipe) +{ + struct kirin_drm_private *priv = dev->dev_private; + struct ade_crtc *acrtc = to_ade_crtc(priv->crtc[pipe]); + struct ade_hw_ctx *ctx = acrtc->ctx; + void __iomem *base = ctx->base; + + if (!ctx->power_on) + (void)ade_power_up(ctx); + + ade_update_bits(base + LDI_INT_EN, FRAME_END_INT_EN_OFST, + MASK(1), 1); + + return 0; +} + +static void ade_disable_vblank(struct drm_device *dev, unsigned int pipe) +{ + struct kirin_drm_private *priv = dev->dev_private; + struct ade_crtc *acrtc = to_ade_crtc(priv->crtc[pipe]); + struct ade_hw_ctx *ctx = acrtc->ctx; + void __iomem *base = ctx->base; + + if (!ctx->power_on) { + DRM_ERROR("power is down! vblank disable fail\n"); + return; + } + + ade_update_bits(base + LDI_INT_EN, FRAME_END_INT_EN_OFST, + MASK(1), 0); +} + +static irqreturn_t ade_irq_handler(int irq, void *data) +{ + struct ade_crtc *acrtc = data; + struct ade_hw_ctx *ctx = acrtc->ctx; + struct drm_crtc *crtc = &acrtc->base; + void __iomem *base = ctx->base; + u32 status; + + status = readl(base + LDI_MSK_INT); + DRM_DEBUG_VBL("LDI IRQ: status=0x%X\n", status); + + /* vblank irq */ + if (status & BIT(FRAME_END_INT_EN_OFST)) { + ade_update_bits(base + LDI_INT_CLR, FRAME_END_INT_EN_OFST, + MASK(1), 1); + drm_crtc_handle_vblank(crtc); + } + + return IRQ_HANDLED; +} + static void ade_display_enable(struct ade_crtc *acrtc) { struct ade_hw_ctx *ctx = acrtc->ctx; @@ -973,6 +1026,15 @@ int ade_drm_init(struct drm_device *dev) if (ret) return ret; + /* vblank irq init */ + ret = devm_request_irq(dev->dev, ctx->irq, ade_irq_handler, + DRIVER_IRQ_SHARED, dev->driver->name, acrtc); + if (ret) + return ret; + dev->driver->get_vblank_counter = drm_vblank_no_hw_counter; + dev->driver->enable_vblank = ade_enable_vblank; + dev->driver->disable_vblank = ade_disable_vblank; + return 0; } diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index 055729c1889c..723888feb760 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -32,6 +32,7 @@ static int kirin_drm_kms_cleanup(struct drm_device *dev) { struct kirin_drm_private *priv = dev->dev_private; + drm_vblank_cleanup(dev); dc_ops->cleanup(dev); drm_mode_config_cleanup(dev); devm_kfree(dev->dev, priv); @@ -85,11 +86,22 @@ static int kirin_drm_kms_init(struct drm_device *dev) goto err_dc_cleanup; } + /* vblank init */ + ret = drm_vblank_init(dev, dev->mode_config.num_crtc); + if (ret) { + DRM_ERROR("failed to initialize vblank.\n"); + goto err_unbind_all; + } + /* with irq_enabled = true, we can use the vblank feature. */ + dev->irq_enabled = true; + /* reset all the states of crtc/plane/encoder/connector */ drm_mode_config_reset(dev); return 0; +err_unbind_all: + component_unbind_all(dev->dev, dev); err_dc_cleanup: dc_ops->cleanup(dev); err_mode_config_cleanup: @@ -123,7 +135,7 @@ static int kirin_gem_cma_dumb_create(struct drm_file *file, static struct drm_driver kirin_drm_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | - DRIVER_ATOMIC, + DRIVER_ATOMIC | DRIVER_HAVE_IRQ, .fops = &kirin_drm_fops, .set_busid = drm_platform_set_busid,