From: Shawn Guo <shawnguo@kernel.org>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Subject: [PATCH 1/4] drm: add vblank hooks to struct drm_crtc_funcs
Date: Mon, 9 Jan 2017 19:56:24 +0800 [thread overview]
Message-ID: <1483962987-19011-2-git-send-email-shawnguo@kernel.org> (raw)
In-Reply-To: <1483962987-19011-1-git-send-email-shawnguo@kernel.org>
From: Shawn Guo <shawn.guo@linaro.org>
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 <shawn.guo@linaro.org>
---
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,
--
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:[~2017-01-09 11:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-09 11:56 [PATCH 0/4] Add vblank hooks to struct drm_crtc_funcs Shawn Guo
2017-01-09 11:56 ` Shawn Guo [this message]
2017-01-10 10:39 ` [PATCH 1/4] drm: add " Daniel Vetter
2017-01-10 20:21 ` Laurent Pinchart
2017-01-09 11:56 ` [PATCH 2/4] drm: zte: zx_vou_enable[disable]_vblank can be static Shawn Guo
2017-01-09 11:56 ` [PATCH 3/4] drm: rockchip: remove struct rockchip_crtc_funcs Shawn Guo
2017-01-09 11:56 ` [PATCH 4/4] drm: imx: remove struct imx_drm_crtc and imx_drm_crtc_helper_funcs Shawn Guo
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=1483962987-19011-2-git-send-email-shawnguo@kernel.org \
--to=shawnguo@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
/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