All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
To: linux-samsung-soc@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org, emil.l.velikov@gmail.com,
	jy0922.shim@samsung.com, inki.dae@samsung.com,
	human.hwang@samsung.com,
	Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Subject: [PATCH v2 01/13] drm: Implement drmHandleEvent2()
Date: Sun, 22 Nov 2015 19:48:31 +0100	[thread overview]
Message-ID: <1448218123-21292-2-git-send-email-tjakobi@math.uni-bielefeld.de> (raw)
In-Reply-To: <1448218123-21292-1-git-send-email-tjakobi@math.uni-bielefeld.de>

Basically this is an extended version of drmHandleEvent().

drmHandleEvent() only handles core events (like e.g. page flips),
but since kernel DRM drivers might use vendor-specific events
to signal userspace the completion of pending jobs, etc., its
desirable to provide a way to handle these without putting
vendor-specific code in the core libdrm.

To use this you provide drmHandleEvent2() with a function that
handles your non-core events.

The signature of that function looks like this:
void vendor(int fd, struct drm_event *e, void *ctx);

'fd' is the DRM file descriptor, 'e' the non-core event
and 'ctx' the event context (casted to void).

This way we don't have to maintain a copy of drmHandleEvent()
in the vendor code.

v2: Remove the opaque pointer, since this can be better
    handled with a container approach.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
---
 xf86drm.h     | 21 +++++++++++++++++++++
 xf86drmMode.c | 10 +++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/xf86drm.h b/xf86drm.h
index 481d882..1e474a3 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -750,8 +750,29 @@ typedef struct _drmEventContext {
 
 } drmEventContext, *drmEventContextPtr;
 
+typedef void (*drmEventVendorHandler)(int fd, struct drm_event *e, void *ctx);
+
 extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
 
+/*
+ * drmHandleEvent2() is an extended variant of drmHandleEvent() which
+ * allows handling of vendor-specific/non-core events.
+ * The function pointer 'vendorhandler' is used (if non-zero) to
+ * process non-core events. Users of have to prepare a container struct
+ * in the following way:
+ *
+ * struct vendor_event_context {
+ *		drmEventContext base;
+ *		int vendor_specific_data[num];
+ * };
+ *
+ * And then call:
+ * struct vendor_event_context ctx = {0};
+ * drmHandleEvent2(fd, &ctx.base, handler);
+ */
+extern int drmHandleEvent2(int fd, drmEventContextPtr evctx,
+	drmEventVendorHandler vendorhandler);
+
 extern char *drmGetDeviceNameFromFd(int fd);
 extern int drmGetNodeTypeFromFd(int fd);
 
diff --git a/xf86drmMode.c b/xf86drmMode.c
index ab6b519..89698da 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -867,7 +867,8 @@ int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
 	return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETGAMMA, &l);
 }
 
-int drmHandleEvent(int fd, drmEventContextPtr evctx)
+int drmHandleEvent2(int fd, drmEventContextPtr evctx,
+			drmEventVendorHandler vendorhandler)
 {
 	char buffer[1024];
 	int len, i;
@@ -910,6 +911,8 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
 						 U642VOID (vblank->user_data));
 			break;
 		default:
+			if (vendorhandler)
+				vendorhandler(fd, e, evctx);
 			break;
 		}
 		i += e->length;
@@ -918,6 +921,11 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
 	return 0;
 }
 
+int drmHandleEvent(int fd, drmEventContextPtr evctx)
+{
+	return drmHandleEvent2(fd, evctx, NULL);
+}
+
 int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id,
 		    uint32_t flags, void *user_data)
 {
-- 
2.4.9

  reply	other threads:[~2015-11-22 18:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-22 18:48 [PATCH v2 00/13] drm/exynos: async G2D and g2d_move() Tobias Jakobi
2015-11-22 18:48 ` Tobias Jakobi [this message]
2015-11-22 18:48 ` [PATCH v2 02/13] exynos: Introduce exynos_handle_event() Tobias Jakobi
2015-11-22 18:48 ` [PATCH v2 03/13] tests/exynos: add fimg2d performance analysis Tobias Jakobi
2015-11-22 18:48 ` [PATCH v2 04/13] exynos/fimg2d: add g2d_config_event Tobias Jakobi
2015-11-22 18:48 ` [PATCH v2 05/13] exynos: fimg2d: add g2d_exec2 Tobias Jakobi
2015-11-22 18:48 ` [PATCH v2 06/13] tests/exynos: add fimg2d event test Tobias Jakobi
2015-11-22 18:48 ` [PATCH v2 07/13] tests/exynos: use XRGB8888 for framebuffer Tobias Jakobi
2015-11-22 18:48 ` [PATCH v2 08/13] exynos: fimg2d: add g2d_set_direction Tobias Jakobi
2015-11-26 16:22   ` Emil Velikov
2015-11-26 16:41     ` Tobias Jakobi
2015-11-26 16:48       ` Emil Velikov
2015-11-27  2:03         ` Hyungwon Hwang
2015-11-22 18:48 ` [PATCH v2 09/13] exynos/fimg2d: add g2d_move Tobias Jakobi
2015-11-22 18:48 ` [PATCH v2 10/13] tests/exynos: add test for g2d_move Tobias Jakobi
2015-11-22 18:48 ` [PATCH v2 11/13] exynos/fimg2d: add exynos_bo_unmap() Tobias Jakobi
2015-11-22 18:48 ` [PATCH v2 12/13] exynos/fimg2d: add g2d_reset() to public API Tobias Jakobi
2015-11-22 18:48 ` [PATCH v2 13/13] exynos: bump version number Tobias Jakobi
2015-11-23  2:35 ` [PATCH v2 00/13] drm/exynos: async G2D and g2d_move() Hyungwon Hwang
2015-11-23  4:33   ` Inki Dae
2015-11-26 16:35 ` Emil Velikov
2015-11-27  2:11   ` Hyungwon Hwang
2015-11-27 13:47     ` Emil Velikov

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=1448218123-21292-2-git-send-email-tjakobi@math.uni-bielefeld.de \
    --to=tjakobi@math.uni-bielefeld.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=human.hwang@samsung.com \
    --cc=inki.dae@samsung.com \
    --cc=jy0922.shim@samsung.com \
    --cc=linux-samsung-soc@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.