From patchwork Mon Jan 9 11:56:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 90409 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp43155qgi; Mon, 9 Jan 2017 03:57:43 -0800 (PST) X-Received: by 10.99.140.77 with SMTP id q13mr161436436pgn.109.1483963063454; Mon, 09 Jan 2017 03:57:43 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id g28si88540186pfk.140.2017.01.09.03.57.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jan 2017 03:57:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) 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 5E05689933; Mon, 9 Jan 2017 11:57:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6E9FF6E21F for ; Mon, 9 Jan 2017 11:57:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D56920306; Mon, 9 Jan 2017 11:57:04 +0000 (UTC) Received: from localhost.localdomain (li411-102.members.linode.com [106.187.91.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CBD4020351; Mon, 9 Jan 2017 11:57:00 +0000 (UTC) From: Shawn Guo To: Daniel Vetter Subject: [PATCH 1/4] drm: add vblank hooks to struct drm_crtc_funcs Date: Mon, 9 Jan 2017 19:56:24 +0800 Message-Id: <1483962987-19011-2-git-send-email-shawnguo@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483962987-19011-1-git-send-email-shawnguo@kernel.org> References: <1483962987-19011-1-git-send-email-shawnguo@kernel.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham 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 Cc: dri-devel@lists.freedesktop.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" From: Shawn Guo The vblank is mostly CRTC specific and implemented as part of CRTC driver. So having vblank hooks in struct drm_crtc_funcs should generally help to reduce code from client drivers in implementing drm_driver's vblank callbacks. Signed-off-by: Shawn Guo --- drivers/gpu/drm/drm_crtc.c | 36 ++++++++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 21 +++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 85a7452d0fb4..59ff00f48101 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -70,6 +70,42 @@ struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx) EXPORT_SYMBOL(drm_crtc_from_index); /** + * drm_crtc_enable_vblank - vblank enable callback helper + * @dev: DRM device + * @pipe: CRTC index + * + * It's a helper function as the generic vblank enable callback implementation, + * which calls into &drm_crtc_funcs.enable_vblank function. + */ +int drm_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe) +{ + struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe); + + if (crtc && crtc->funcs && crtc->funcs->enable_vblank) + return crtc->funcs->enable_vblank(crtc); + + return 0; +} +EXPORT_SYMBOL(drm_crtc_enable_vblank); + +/** + * drm_crtc_disable_vblank - vblank disable callback helper + * @dev: DRM device + * @pipe: CRTC index + * + * It's a helper function as the generic vblank disable callback implementation, + * which calls into &drm_crtc_funcs.disable_vblank function. + */ +void drm_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe) +{ + struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe); + + if (crtc && crtc->funcs && crtc->funcs->disable_vblank) + return crtc->funcs->disable_vblank(crtc); +} +EXPORT_SYMBOL(drm_crtc_disable_vblank); + +/** * drm_crtc_force_disable - Forcibly turn off a CRTC * @crtc: CRTC to turn off * diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index a5627eb8621f..20874b3903a6 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -599,6 +599,25 @@ struct drm_crtc_funcs { */ void (*atomic_print_state)(struct drm_printer *p, const struct drm_crtc_state *state); + + /** + * @enable_vblank: + * + * Enable vblank interrupts for the CRTC. + * + * Returns: + * + * Zero on success, appropriate errno if the vblank interrupt cannot + * be enabled. + */ + int (*enable_vblank)(struct drm_crtc *crtc); + + /** + * @disable_vblank: + * + * Disable vblank interrupts for the CRTC. + */ + void (*disable_vblank)(struct drm_crtc *crtc); }; /** @@ -831,6 +850,8 @@ void drm_crtc_get_hv_timing(const struct drm_display_mode *mode, int drm_mode_set_config_internal(struct drm_mode_set *set); struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx); +int drm_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe); +void drm_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe); /* Helpers */ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,