aboutsummaryrefslogtreecommitdiffstats
path: root/exynos
diff options
context:
space:
mode:
authorTobias Jakobi2015-11-29 21:12:13 -0600
committerEmil Velikov2015-12-18 11:42:54 -0600
commit2191ed904f9301d25d16c8b462ab029a81810601 (patch)
tree8c9298cc4fdb5b87c2b391702683b588ddb7450c /exynos
parentd6ffb997263402eebdcb029e061ae0221925f643 (diff)
downloadexternal-libdrm-2191ed904f9301d25d16c8b462ab029a81810601.tar.gz
external-libdrm-2191ed904f9301d25d16c8b462ab029a81810601.tar.xz
external-libdrm-2191ed904f9301d25d16c8b462ab029a81810601.zip
exynos: Introduce exynos_handle_event()
Used to handle kernel events specific to the Exynos platform. Currently only G2D events are handled. Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de> Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
Diffstat (limited to 'exynos')
-rwxr-xr-xexynos/exynos-symbol-check1
-rw-r--r--exynos/exynos_drm.c76
-rw-r--r--exynos/exynos_drm.h12
-rw-r--r--exynos/exynos_drmif.h26
4 files changed, 115 insertions, 0 deletions
diff --git a/exynos/exynos-symbol-check b/exynos/exynos-symbol-check
index 1a1be89e..c3ddbe4d 100755
--- a/exynos/exynos-symbol-check
+++ b/exynos/exynos-symbol-check
@@ -22,6 +22,7 @@ exynos_device_destroy
22exynos_prime_fd_to_handle 22exynos_prime_fd_to_handle
23exynos_prime_handle_to_fd 23exynos_prime_handle_to_fd
24exynos_vidi_connection 24exynos_vidi_connection
25exynos_handle_event
25g2d_blend 26g2d_blend
26g2d_copy 27g2d_copy
27g2d_copy_with_scale 28g2d_copy_with_scale
diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c
index df9b8ed4..e689781d 100644
--- a/exynos/exynos_drm.c
+++ b/exynos/exynos_drm.c
@@ -32,6 +32,7 @@
32#include <stdio.h> 32#include <stdio.h>
33#include <string.h> 33#include <string.h>
34#include <errno.h> 34#include <errno.h>
35#include <unistd.h>
35 36
36#include <sys/mman.h> 37#include <sys/mman.h>
37#include <linux/stddef.h> 38#include <linux/stddef.h>
@@ -42,6 +43,8 @@
42#include "exynos_drm.h" 43#include "exynos_drm.h"
43#include "exynos_drmif.h" 44#include "exynos_drmif.h"
44 45
46#define U642VOID(x) ((void *)(unsigned long)(x))
47
45/* 48/*
46 * Create exynos drm device object. 49 * Create exynos drm device object.
47 * 50 *
@@ -374,3 +377,76 @@ exynos_vidi_connection(struct exynos_device *dev, uint32_t connect,
374 377
375 return 0; 378 return 0;
376} 379}
380
381static void
382exynos_handle_vendor(int fd, struct drm_event *e, void *ctx)
383{
384 struct drm_exynos_g2d_event *g2d;
385 struct exynos_event_context *ectx = ctx;
386
387 switch (e->type) {
388 case DRM_EXYNOS_G2D_EVENT:
389 if (ectx->version < 1 || ectx->g2d_event_handler == NULL)
390 break;
391 g2d = (struct drm_exynos_g2d_event *)e;
392 ectx->g2d_event_handler(fd, g2d->cmdlist_no, g2d->tv_sec,
393 g2d->tv_usec, U642VOID(g2d->user_data));
394 break;
395
396 default:
397 break;
398 }
399}
400
401int
402exynos_handle_event(struct exynos_device *dev, struct exynos_event_context *ctx)
403{
404 char buffer[1024];
405 int len, i;
406 struct drm_event *e;
407 struct drm_event_vblank *vblank;
408 drmEventContextPtr evctx = &ctx->base;
409
410 /* The DRM read semantics guarantees that we always get only
411 * complete events. */
412 len = read(dev->fd, buffer, sizeof buffer);
413 if (len == 0)
414 return 0;
415 if (len < (int)sizeof *e)
416 return -1;
417
418 i = 0;
419 while (i < len) {
420 e = (struct drm_event *) &buffer[i];
421 switch (e->type) {
422 case DRM_EVENT_VBLANK:
423 if (evctx->version < 1 ||
424 evctx->vblank_handler == NULL)
425 break;
426 vblank = (struct drm_event_vblank *) e;
427 evctx->vblank_handler(dev->fd,
428 vblank->sequence,
429 vblank->tv_sec,
430 vblank->tv_usec,
431 U642VOID (vblank->user_data));
432 break;
433 case DRM_EVENT_FLIP_COMPLETE:
434 if (evctx->version < 2 ||
435 evctx->page_flip_handler == NULL)
436 break;
437 vblank = (struct drm_event_vblank *) e;
438 evctx->page_flip_handler(dev->fd,
439 vblank->sequence,
440 vblank->tv_sec,
441 vblank->tv_usec,
442 U642VOID (vblank->user_data));
443 break;
444 default:
445 exynos_handle_vendor(dev->fd, e, evctx);
446 break;
447 }
448 i += e->length;
449 }
450
451 return 0;
452}
diff --git a/exynos/exynos_drm.h b/exynos/exynos_drm.h
index 256c02f0..c3af0ac5 100644
--- a/exynos/exynos_drm.h
+++ b/exynos/exynos_drm.h
@@ -157,4 +157,16 @@ struct drm_exynos_g2d_exec {
157#define DRM_IOCTL_EXYNOS_G2D_EXEC DRM_IOWR(DRM_COMMAND_BASE + \ 157#define DRM_IOCTL_EXYNOS_G2D_EXEC DRM_IOWR(DRM_COMMAND_BASE + \
158 DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec) 158 DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec)
159 159
160/* EXYNOS specific events */
161#define DRM_EXYNOS_G2D_EVENT 0x80000000
162
163struct drm_exynos_g2d_event {
164 struct drm_event base;
165 __u64 user_data;
166 __u32 tv_sec;
167 __u32 tv_usec;
168 __u32 cmdlist_no;
169 __u32 reserved;
170};
171
160#endif 172#endif
diff --git a/exynos/exynos_drmif.h b/exynos/exynos_drmif.h
index c7c1d442..626e3998 100644
--- a/exynos/exynos_drmif.h
+++ b/exynos/exynos_drmif.h
@@ -54,6 +54,25 @@ struct exynos_bo {
54 uint32_t name; 54 uint32_t name;
55}; 55};
56 56
57#define EXYNOS_EVENT_CONTEXT_VERSION 1
58
59/*
60 * Exynos Event Context structure.
61 *
62 * @base: base context (for core events).
63 * @version: version info similar to the one in 'drmEventContext'.
64 * @g2d_event_handler: handler for G2D events.
65 */
66struct exynos_event_context {
67 drmEventContext base;
68
69 int version;
70
71 void (*g2d_event_handler)(int fd, unsigned int cmdlist_no,
72 unsigned int tv_sec, unsigned int tv_usec,
73 void *user_data);
74};
75
57/* 76/*
58 * device related functions: 77 * device related functions:
59 */ 78 */
@@ -83,4 +102,11 @@ int exynos_prime_fd_to_handle(struct exynos_device *dev, int fd,
83int exynos_vidi_connection(struct exynos_device *dev, uint32_t connect, 102int exynos_vidi_connection(struct exynos_device *dev, uint32_t connect,
84 uint32_t ext, void *edid); 103 uint32_t ext, void *edid);
85 104
105/*
106 * event handling related functions:
107 */
108int exynos_handle_event(struct exynos_device *dev,
109 struct exynos_event_context *ctx);
110
111
86#endif /* EXYNOS_DRMIF_H_ */ 112#endif /* EXYNOS_DRMIF_H_ */