From patchwork Mon Nov 30 03:12:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyungwon Hwang X-Patchwork-Id: 7720821 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DC8829FC46 for ; Mon, 30 Nov 2015 03:12:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EFC1A2053B for ; Mon, 30 Nov 2015 03:12:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 973602062E for ; Mon, 30 Nov 2015 03:12:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 02A186E4BE; Sun, 29 Nov 2015 19:12:33 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5DCB66E0C4 for ; Sun, 29 Nov 2015 19:12:31 -0800 (PST) Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NYL00M1QY8ROE30@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 30 Nov 2015 12:12:27 +0900 (KST) Received: from epcpdlpp15 ( [172.20.52.115]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 1E.F1.04972.B9EBB565; Mon, 30 Nov 2015 12:12:27 +0900 (KST) X-AuditID: cbfee68e-f793c6d00000136c-b0-565bbe9be70d Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id E1.20.13906.B9EBB565; Mon, 30 Nov 2015 12:12:27 +0900 (KST) Received: from localhost.localdomain ([10.252.82.145]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NYL00MGBY8OW830@mmp2.samsung.com>; Mon, 30 Nov 2015 12:12:27 +0900 (KST) From: Hyungwon Hwang To: dri-devel@lists.freedesktop.org, emil.l.velikov@gmail.com, jy0922.shim@samsung.com, inki.dae@samsung.com, human.hwang@samsung.com, tjakobi@math.uni-bielefeld.de Subject: [PATCH v3 1/9] exynos: Introduce exynos_handle_event() Date: Mon, 30 Nov 2015 12:12:13 +0900 Message-id: <1448853141-27791-2-git-send-email-human.hwang@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1448853141-27791-1-git-send-email-human.hwang@samsung.com> References: <1448853141-27791-1-git-send-email-human.hwang@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKLMWRmVeSWpSXmKPExsWyRsSkWHf2vugwg7UfTSyufH3PZrHn6j0m i6Uz+lgtJt2fwGLx4t5FFou21R9YHdg8ds66y+5xv/s4k8e/Y+wefVtWMQawRHHZpKTmZJal FunbJXBlTN69kqngvUbF12Mv2RsYryl0MXJySAiYSFx4/pQNwhaTuHBvPZDNxSEkMItR4u2+ X8wwRXtfvmGES8z++5AJwvnBKPF1zlawdjYBPYkF136wg9giAisYJeYsdQKxhQXsJY7ePAs0 iYODRUBVorUlCCTMK+AuMW3yT1aIBXISJ49NBrM5BTwk1u18wwRiCwHVzL65GGyxhEA7u8Te n+/BEiwCAhLfJh9iAZkpISArsekA1KGSEgdX3GCZwCi0gJFhFaNoakFyQXFSepGRXnFibnFp Xrpecn7uJkZg6J7+96xvB+PNA9aHGAU4GJV4eCXMosOEWBPLiitzDzGaAm2YyCwlmpwPjJC8 knhDYzMjC1MTU2Mjc0szJXHeBKmfwUIC6YklqdmpqQWpRf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EpQIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Tobias Jakobi Used to handle kernel events specific to the Exynos platform. Currently only G2D events are handled. Signed-off-by: Tobias Jakobi Signed-off-by: Hyungwon Hwang --- Changes for v2: Adapt to container approach. v3: Add exynos_handle_event() to Exynos symbol test. v4: exynos_handle_event() became not to use drmHandleEvent() for Exynos-dependent callback exynos/exynos-symbol-check | 1 + exynos/exynos_drm.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++ exynos/exynos_drm.h | 12 ++++++++ exynos/exynos_drmif.h | 26 ++++++++++++++++ 4 files changed, 115 insertions(+) -- 1.9.1 diff --git a/exynos/exynos-symbol-check b/exynos/exynos-symbol-check index 1a1be89..c3ddbe4 100755 --- a/exynos/exynos-symbol-check +++ b/exynos/exynos-symbol-check @@ -22,6 +22,7 @@ exynos_device_destroy exynos_prime_fd_to_handle exynos_prime_handle_to_fd exynos_vidi_connection +exynos_handle_event g2d_blend g2d_copy g2d_copy_with_scale diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c index df9b8ed..e689781 100644 --- a/exynos/exynos_drm.c +++ b/exynos/exynos_drm.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,8 @@ #include "exynos_drm.h" #include "exynos_drmif.h" +#define U642VOID(x) ((void *)(unsigned long)(x)) + /* * Create exynos drm device object. * @@ -374,3 +377,76 @@ exynos_vidi_connection(struct exynos_device *dev, uint32_t connect, return 0; } + +static void +exynos_handle_vendor(int fd, struct drm_event *e, void *ctx) +{ + struct drm_exynos_g2d_event *g2d; + struct exynos_event_context *ectx = ctx; + + switch (e->type) { + case DRM_EXYNOS_G2D_EVENT: + if (ectx->version < 1 || ectx->g2d_event_handler == NULL) + break; + g2d = (struct drm_exynos_g2d_event *)e; + ectx->g2d_event_handler(fd, g2d->cmdlist_no, g2d->tv_sec, + g2d->tv_usec, U642VOID(g2d->user_data)); + break; + + default: + break; + } +} + +int +exynos_handle_event(struct exynos_device *dev, struct exynos_event_context *ctx) +{ + char buffer[1024]; + int len, i; + struct drm_event *e; + struct drm_event_vblank *vblank; + drmEventContextPtr evctx = &ctx->base; + + /* The DRM read semantics guarantees that we always get only + * complete events. */ + len = read(dev->fd, buffer, sizeof buffer); + if (len == 0) + return 0; + if (len < (int)sizeof *e) + return -1; + + i = 0; + while (i < len) { + e = (struct drm_event *) &buffer[i]; + switch (e->type) { + case DRM_EVENT_VBLANK: + if (evctx->version < 1 || + evctx->vblank_handler == NULL) + break; + vblank = (struct drm_event_vblank *) e; + evctx->vblank_handler(dev->fd, + vblank->sequence, + vblank->tv_sec, + vblank->tv_usec, + U642VOID (vblank->user_data)); + break; + case DRM_EVENT_FLIP_COMPLETE: + if (evctx->version < 2 || + evctx->page_flip_handler == NULL) + break; + vblank = (struct drm_event_vblank *) e; + evctx->page_flip_handler(dev->fd, + vblank->sequence, + vblank->tv_sec, + vblank->tv_usec, + U642VOID (vblank->user_data)); + break; + default: + exynos_handle_vendor(dev->fd, e, evctx); + break; + } + i += e->length; + } + + return 0; +} diff --git a/exynos/exynos_drm.h b/exynos/exynos_drm.h index 256c02f..c3af0ac 100644 --- a/exynos/exynos_drm.h +++ b/exynos/exynos_drm.h @@ -157,4 +157,16 @@ struct drm_exynos_g2d_exec { #define DRM_IOCTL_EXYNOS_G2D_EXEC DRM_IOWR(DRM_COMMAND_BASE + \ DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec) +/* EXYNOS specific events */ +#define DRM_EXYNOS_G2D_EVENT 0x80000000 + +struct drm_exynos_g2d_event { + struct drm_event base; + __u64 user_data; + __u32 tv_sec; + __u32 tv_usec; + __u32 cmdlist_no; + __u32 reserved; +}; + #endif diff --git a/exynos/exynos_drmif.h b/exynos/exynos_drmif.h index c7c1d44..626e399 100644 --- a/exynos/exynos_drmif.h +++ b/exynos/exynos_drmif.h @@ -54,6 +54,25 @@ struct exynos_bo { uint32_t name; }; +#define EXYNOS_EVENT_CONTEXT_VERSION 1 + +/* + * Exynos Event Context structure. + * + * @base: base context (for core events). + * @version: version info similar to the one in 'drmEventContext'. + * @g2d_event_handler: handler for G2D events. + */ +struct exynos_event_context { + drmEventContext base; + + int version; + + void (*g2d_event_handler)(int fd, unsigned int cmdlist_no, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data); +}; + /* * device related functions: */ @@ -83,4 +102,11 @@ int exynos_prime_fd_to_handle(struct exynos_device *dev, int fd, int exynos_vidi_connection(struct exynos_device *dev, uint32_t connect, uint32_t ext, void *edid); +/* + * event handling related functions: + */ +int exynos_handle_event(struct exynos_device *dev, + struct exynos_event_context *ctx); + + #endif /* EXYNOS_DRMIF_H_ */