From: Xinliang Liu <xinliang.liu@linaro.org>
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
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
Subject: [PATCH v5 05/11] drm/hisilicon: Add vblank driver for ADE
Date: Tue, 23 Feb 2016 11:00:25 +0800 [thread overview]
Message-ID: <1456196431-19923-6-git-send-email-xinliang.liu@linaro.org> (raw)
In-Reply-To: <1456196431-19923-1-git-send-email-xinliang.liu@linaro.org>
Add vblank irq handle.
v5: None.
v4: None.
v3:
- Remove hisi_get_crtc_from_index func.
- A few cleanup.
v2:
- Remove abtraction layer.
Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
---
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 fae5f0afadb8..918897fa4e9e 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
@@ -292,6 +292,59 @@ static void ade_set_medianoc_qos(struct ade_crtc *acrtc)
SOCKET_QOS_EN, SOCKET_QOS_EN);
}
+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;
@@ -967,6 +1020,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,
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-02-23 3:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-23 3:00 [PATCH v5 00/11] Add DRM Driver for HiSilicon Kirin hi6220 SoC Xinliang Liu
2016-02-23 3:00 ` [PATCH v5 01/11] drm/hisilicon: Add device tree binding for hi6220 display subsystem Xinliang Liu
2016-02-23 18:37 ` Mark Rutland
2016-02-25 2:21 ` Xinliang Liu
2016-02-26 2:21 ` Xinliang Liu
2016-02-23 3:00 ` [PATCH v5 02/11] drm/hisilicon: Add hisilicon kirin drm master driver Xinliang Liu
2016-02-23 3:00 ` [PATCH v5 03/11] drm/hisilicon: Add crtc driver for ADE Xinliang Liu
2016-02-23 3:00 ` [PATCH v5 04/11] drm/hisilicon: Add plane " Xinliang Liu
2016-02-23 3:00 ` Xinliang Liu [this message]
2016-02-23 3:00 ` [PATCH v5 06/11] drm/hisilicon: Add cma fbdev and hotplug Xinliang Liu
2016-02-23 3:00 ` [PATCH v5 07/11] drm/hisilicon: Add designware dsi encoder driver Xinliang Liu
2016-02-23 3:00 ` [PATCH v5 08/11] drm/hisilicon: Add designware dsi host driver Xinliang Liu
2016-02-23 3:00 ` [PATCH v5 09/11] drm/hisilicon: Add support for external bridge Xinliang Liu
2016-02-23 3:00 ` [PATCH v5 10/11] MAINTAINERS: Add maintainer for hisilicon DRM driver Xinliang Liu
2016-02-23 3:00 ` [PATCH v5 11/11] arm64: dts: hisilicon: Add display subsystem DT nodes for hi6220 Xinliang Liu
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=1456196431-19923-6-git-send-email-xinliang.liu@linaro.org \
--to=xinliang.liu@linaro.org \
--cc=airlied@linux.ie \
--cc=andy.green@linaro.org \
--cc=architt@codeaurora.org \
--cc=benjamin.gaignard@linaro.org \
--cc=bintian.wang@huawei.com \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=daniel@ffwll.ch \
--cc=daniel@fooishbar.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=guodong.xu@linaro.org \
--cc=haojian.zhuang@linaro.org \
--cc=liguozhu@hisilicon.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=puck.chen@hisilicon.com \
--cc=robh@kernel.org \
--cc=w.f@huawei.com \
--cc=will.deacon@arm.com \
--cc=xuwei5@hisilicon.com \
--cc=xuyiping@hisilicon.com \
--cc=zourongrong@huawei.com \
/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).