From patchwork Tue May 31 13:39:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yakir Yang X-Patchwork-Id: 9144851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 58AF460752 for ; Tue, 31 May 2016 13:39:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AC3A272D8 for ; Tue, 31 May 2016 13:39:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F4F12796F; Tue, 31 May 2016 13:39:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AF911272D8 for ; Tue, 31 May 2016 13:39:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b7jtf-0003VG-By; Tue, 31 May 2016 13:39:51 +0000 Received: from lucky1.263xmail.com ([211.157.147.130]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b7jtb-00036R-60 for linux-rockchip@lists.infradead.org; Tue, 31 May 2016 13:39:49 +0000 Received: from ykk?rock-chips.com (unknown [192.168.167.234]) by lucky1.263xmail.com (Postfix) with SMTP id 2E51C1EE4AF; Tue, 31 May 2016 21:39:21 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id CBC9B29E1; Tue, 31 May 2016 21:39:21 +0800 (CST) X-RL-SENDER: ykk@rock-chips.com X-FST-TO: yzq@rock-chips.com X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: ykk@rock-chips.com X-UNIQUE-TAG: <47736741245018da1111c14381850f2d> X-ATTACHMENT-NUM: 0 X-SENDER: ykk@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 16349U6FDQT; Tue, 31 May 2016 21:39:23 +0800 (CST) From: Yakir Yang To: Mark Yao , Inki Dae , Heiko Stuebner , tfiga@chromium.org, Jingoo Han Subject: [RFC PATCH v1 1/2] drm/rockchip: add a notify event about vblank enable/disable Date: Tue, 31 May 2016 21:39:19 +0800 Message-Id: <1464701959-9428-1-git-send-email-ykk@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464701856-8695-1-git-send-email-ykk@rock-chips.com> References: <1464701856-8695-1-git-send-email-ykk@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160531_063948_236166_F10CC45A X-CRM114-Status: GOOD ( 14.97 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org, David Airlie , daniel.vetter@ffwll.ch, emil.l.velikov@gmail.com, dianders@chromium.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Yakir Yang , Thierry Reding , Dan Carpenter MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP EDP PSR function is interesting in vblank enable or disable event, so it would be great introduce a way to notify encoder about this event. Signed-off-by: Yakir Yang --- drivers/gpu/drm/rockchip/Makefile | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_notify.c | 66 ++++++++++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_drm_notify.h | 29 +++++++++++ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 5 ++ 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_notify.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_notify.h diff --git a/drivers/gpu/drm/rockchip/Makefile b/drivers/gpu/drm/rockchip/Makefile index 05d0713..49fee8c 100644 --- a/drivers/gpu/drm/rockchip/Makefile +++ b/drivers/gpu/drm/rockchip/Makefile @@ -3,7 +3,7 @@ # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o \ - rockchip_drm_gem.o rockchip_drm_vop.o + rockchip_drm_gem.o rockchip_drm_vop.o rockchip_drm_notify.o rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o obj-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_notify.c b/drivers/gpu/drm/rockchip/rockchip_drm_notify.c new file mode 100644 index 0000000..84111d9 --- /dev/null +++ b/drivers/gpu/drm/rockchip/rockchip_drm_notify.c @@ -0,0 +1,66 @@ +#include "rockchip_drm_notify.h" + +static RAW_NOTIFIER_HEAD(vblank_chain); +static DEFINE_MUTEX(vblank_lock); + +/** + * rockchip_drm_vblank_enable - Send Vblank enable event. Will only enable send + * Vblank if there are 1 or fewer notifiers. + */ +void rockchip_drm_vblank_enable(void) +{ + mutex_lock(&vblank_lock); + raw_notifier_call_chain(&vblank_chain, VBLANK_ENABLE, NULL); + mutex_unlock(&vblank_lock); +} +EXPORT_SYMBOL_GPL(rockchip_drm_vblank_enable); + +/** + * rockchip_drm_vblank_disable - Send VBlank disable event. + */ +void rockchip_drm_vblank_disable(void) +{ + mutex_lock(&vblank_lock); + raw_notifier_call_chain(&vblank_chain, VBLANK_DISABLE, NULL); + mutex_unlock(&vblank_lock); +} +EXPORT_SYMBOL_GPL(rockchip_drm_vblank_disable); + +/** + * rockchip_drm_vblank_register_notifier - Add notifier to Vblank notifiers. + * + * Enable notifiers are called when we enable/disable vblank. This can be done + * through rockchip_drm_vblank_enable/disable or when there is more than one + * sync notifier. Must call rockchip_drm_vblank_lock before calling this. + * @nb The notifier to add + */ +int rockchip_drm_vblank_register_notifier(struct notifier_block *nb) +{ + int ret = 0; + + if (!nb) + return -EINVAL; + + ret = raw_notifier_chain_register(&vblank_chain, nb); + return ret; +} +EXPORT_SYMBOL_GPL(rockchip_drm_vblank_register_notifier); + +/** + * rockchip_drm_vblank_unregister_notifier - Remove notifier from Vblank + * notifiers. + * + * Must call rockchip_drm_vblank_lock before calling this. + * @nb The notifier to remove. + */ +int rockchip_drm_vblank_unregister_notifier(struct notifier_block *nb) +{ + int ret = 0; + + if (!nb) + return -EINVAL; + + ret = raw_notifier_chain_unregister(&vblank_chain, nb); + return ret; +} +EXPORT_SYMBOL_GPL(rockchip_drm_vblank_unregister_notifier); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_notify.h b/drivers/gpu/drm/rockchip/rockchip_drm_notify.h new file mode 100644 index 0000000..2f28afa --- /dev/null +++ b/drivers/gpu/drm/rockchip/rockchip_drm_notify.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2014 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __ROCKCHIP_DRM_NOTIFY_H +#define __ROCKCHIP_DRM_NOTIFY_H + +#include + +enum vblank_enable_op { + VBLANK_ENABLE = 0, + VBLANK_DISABLE, +}; + +void rockchip_drm_vblank_enable(void); +void rockchip_drm_vblank_disable(void); +int rockchip_drm_vblank_register_notifier(struct notifier_block *nb); +int rockchip_drm_vblank_unregister_notifier(struct notifier_block *nb); + +#endif /* __ROCKCHIP_DRM_NOTIFY_H */ diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 257501f..fb6ce4b 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -35,6 +35,7 @@ #include "rockchip_drm_gem.h" #include "rockchip_drm_fb.h" #include "rockchip_drm_vop.h" +#include "rockchip_drm_notify.h" #define __REG_SET_RELAXED(x, off, mask, shift, v, write_mask) \ vop_mask_write(x, off, mask, shift, v, write_mask, true) @@ -851,6 +852,8 @@ static int vop_crtc_enable_vblank(struct drm_crtc *crtc) spin_unlock_irqrestore(&vop->irq_lock, flags); + rockchip_drm_vblank_enable(); + return 0; } @@ -867,6 +870,8 @@ static void vop_crtc_disable_vblank(struct drm_crtc *crtc) VOP_INTR_SET_TYPE(vop, enable, FS_INTR, 0); spin_unlock_irqrestore(&vop->irq_lock, flags); + + rockchip_drm_vblank_disable(); } static void vop_crtc_wait_for_update(struct drm_crtc *crtc)