1 /**************************************************************************
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
7 Contact: SooChan Lim <sc1.lim@samsung.com>
8 Sangjin LEE <lsj119@samsung.com>
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
39 #include <sys/types.h>
40 #include <sys/fcntl.h>
47 #include "xdbg_log_int.h"
48 #include "xdbg_types.h"
52 #define API __attribute__ ((visibility("default")))
55 typedef struct _xdbgVblankInfo
58 unsigned int client_idx;
62 struct xorg_list link;
63 } XDbgVblankInfo, *XDbgVblankInfoPtr;
65 typedef struct _xdbgPageFlipInfo
68 unsigned int client_idx;
71 struct xorg_list link;
72 } XDbgPageFlipInfo, *XDbgPageFlipInfoPtr;
74 static int init_drmevent = 0;
75 static struct xorg_list vblank_event_list;
76 static struct xorg_list pageflip_event_list;
79 xDbgLogDrmEventInit ()
83 xorg_list_init (&vblank_event_list);
84 xorg_list_init (&pageflip_event_list);
88 xDbgLogDrmEventDeInit ()
90 /* TODO: delete all link(xorg_list_del) in the two list */
94 xDbgLogDrmEventAddVblank ( int crtc_pipe, unsigned int client_idx, unsigned int draw_id, int flag)
96 XDbgVblankInfoPtr pVblankInfo = NULL;
98 pVblankInfo = calloc (1, sizeof (XDbgVblankInfo));
102 pVblankInfo->crtc_pipe = crtc_pipe;
103 pVblankInfo->client_idx = client_idx;
104 pVblankInfo->draw_id = draw_id;
105 pVblankInfo->flag = flag;
106 pVblankInfo->time =GetTimeInMillis();
108 xorg_list_init(&pVblankInfo->link);
109 xorg_list_add(&pVblankInfo->link, &vblank_event_list);
111 return (void *)pVblankInfo;
115 xDbgLogDrmEventRemoveVblank (void *vblank_data)
117 XDbgVblankInfoPtr pVblankInfo = (XDbgVblankInfoPtr) vblank_data;
119 xorg_list_del (&pVblankInfo->link);
125 xDbgLogDrmEventAddPageflip (int crtc_pipe, unsigned int client_idx, unsigned int draw_id)
127 XDbgPageFlipInfoPtr pPageFlipInfo = NULL;
129 pPageFlipInfo = calloc (1, sizeof (XDbgPageFlipInfo));
133 pPageFlipInfo->crtc_pipe = crtc_pipe;
134 pPageFlipInfo->client_idx = client_idx;
135 pPageFlipInfo->draw_id = draw_id;
136 pPageFlipInfo->time =GetTimeInMillis();
138 xorg_list_init(&pPageFlipInfo->link);
139 xorg_list_add(&pPageFlipInfo->link, &pageflip_event_list);
141 return (void *)pPageFlipInfo;
145 xDbgLogDrmEventRemovePageflip (void *pageflip_data)
147 XDbgPageFlipInfoPtr pPageFlipInfo = (XDbgPageFlipInfoPtr) pageflip_data;
149 xorg_list_del (&pPageFlipInfo->link);
150 free (pPageFlipInfo);
151 pPageFlipInfo = NULL;
155 xDbgLogDrmEventPendingLists ( char *reply, int *len)
157 XDbgVblankInfoPtr vblank_ref = NULL;
158 XDbgVblankInfoPtr vblank_next = NULL;
159 XDbgPageFlipInfoPtr flip_ref = NULL;
160 XDbgPageFlipInfoPtr flip_next = NULL;
161 Bool check_flip = FALSE;
162 Bool check_vblank = FALSE;
166 XDBG_REPLY ("drmevent_pending is not supported.\n");
171 XDBG_REPLY ("[vblank event pending]\n");
172 xorg_list_for_each_entry_safe (vblank_ref, vblank_next, &vblank_event_list, link)
176 if (vblank_ref->flag > -1)
178 XDBG_REPLY ("req_time client_id draw_id crtc_pipe vblank_type\n");
179 XDBG_REPLY ("[%10.3f] %5d 0x%x %5d %5d\n",
180 (double)vblank_ref->time/1000.0,
181 (unsigned int)vblank_ref->client_idx,
182 (unsigned int)vblank_ref->draw_id, vblank_ref->crtc_pipe, vblank_ref->flag);
186 XDBG_REPLY ("req_time vblank_type\n");
187 XDBG_REPLY ("[%10.3f] %d\n", (double)vblank_ref->time/1000.0, vblank_ref->flag);
191 XDBG_REPLY ("\t no pending events\n");
193 XDBG_REPLY ("[flip event pending]\n");
194 xorg_list_for_each_entry_safe (flip_ref, flip_next, &pageflip_event_list, link)
198 XDBG_REPLY ("req_time client_id draw_id crtc_pipe\n");
199 XDBG_REPLY ("[%10.3f] %5d 0x%x %4d\n",
200 (double)flip_ref->time/1000.0, (unsigned int)flip_ref->client_idx,
201 (unsigned int)flip_ref->draw_id, flip_ref->crtc_pipe);
204 XDBG_REPLY ("\t no pending events\n");