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: 9504507 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 E70A760710 for ; Mon, 9 Jan 2017 11:57:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7F08284B6 for ; Mon, 9 Jan 2017 11:57:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCD97284B9; Mon, 9 Jan 2017 11:57:14 +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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 768D0284B6 for ; Mon, 9 Jan 2017 11:57:14 +0000 (UTC) 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-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" X-Virus-Scanned: ClamAV using ClamSMTP 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,