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 **************************************************************************/
38 #include <sys/types.h>
40 #include "xorg-server.h"
42 #include "xdbg_log_int.h"
43 #include "xdbg_types.h"
44 #include "xdbg_log_fpsdebug.h"
47 #define API __attribute__ ((visibility("default")))
50 #define FPS_DEBUG_TIMER_INTERVAL 500
52 static int init_fpsdebug = 0;
53 static Bool g_on = FALSE;
58 CARD32 tStart, tCur, tLast;
70 { DRM_MODE_CONNECTOR_Unknown, "unknown" },
71 { DRM_MODE_CONNECTOR_VGA, "VGA" },
72 { DRM_MODE_CONNECTOR_DVII, "DVI-I" },
73 { DRM_MODE_CONNECTOR_DVID, "DVI-D" },
74 { DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
75 { DRM_MODE_CONNECTOR_Composite, "composite" },
76 { DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
77 { DRM_MODE_CONNECTOR_LVDS, "LVDS" },
78 { DRM_MODE_CONNECTOR_Component, "component" },
79 { DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
80 { DRM_MODE_CONNECTOR_DisplayPort, "displayport" },
81 { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
82 { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
83 { DRM_MODE_CONNECTOR_TV, "TV" },
84 { DRM_MODE_CONNECTOR_eDP, "embedded displayport" },
85 { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
89 _get_connector_id (int connector_type)
91 int num = sizeof (connector_list) / sizeof (connector_list[0]);
95 for (i = 0; i < num; i++)
97 if (connector_type == connector_list[i].type)
109 _fps_print_fps (FpsDebugPtr pFpsDebug, int isTimeOut)
113 sec = (double) (pFpsDebug->tLast - pFpsDebug->tStart) /1000.0;
114 ErrorF ("[Xorg..V][%s][FB:(%3dframes %3.1ffps)] Dur:%3.3f...%s\n",
115 connector_list[pFpsDebug->cid].name, pFpsDebug->nPanCount, pFpsDebug->nPanCount / sec,
116 sec, isTimeOut ? "[TimeOut]" : "");
117 pFpsDebug->nPanCount = 0;
123 _fps_frame_timeout (OsTimerPtr timer, CARD32 now, pointer arg)
125 _fps_print_fps (arg, TRUE);
132 xDbgLogFpsDebugCreate ()
134 FpsDebugPtr pFpsDebug = NULL;
138 pFpsDebug = calloc (1, sizeof (struct _fpsDebug));
141 XDBG_ERROR (MXDBG, "fail to allocate the FpsDebug\n");
149 xDbgLogFpsDebugDestroy (FpsDebugPtr pFpsDebug)
159 xDbgLogFpsDebugCount (FpsDebugPtr pFpsDebug, int connector_type)
161 /* if fpsdebug is off, do not count fps */
165 if (connector_type != pFpsDebug->connector_type)
167 pFpsDebug->connector_type = connector_type;
168 pFpsDebug->cid = _get_connector_id (connector_type);
171 pFpsDebug->tCur = GetTimeInMillis();
172 if (pFpsDebug->nPanCount && pFpsDebug->tStart + FPS_DEBUG_TIMER_INTERVAL <= pFpsDebug->tCur)
173 _fps_print_fps (pFpsDebug, FALSE);
175 if (pFpsDebug->nPanCount == 0)
176 pFpsDebug->tStart = pFpsDebug->tLast;
178 pFpsDebug->nPanCount++;
179 pFpsDebug->tLast = pFpsDebug->tCur;
180 pFpsDebug->fpsTimer = TimerSet (pFpsDebug->fpsTimer
181 , 0, FPS_DEBUG_TIMER_INTERVAL
182 , _fps_frame_timeout, pFpsDebug);
186 xDbgLogFpsDebug (char *reply, int *len, int on)
190 XDBG_REPLY ("fps_debug is not supported.\n");