From 7d6a727f2db27c45dda51b74784b95aa298528e2 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 3 Apr 2013 18:01:36 +0900 Subject: [PATCH] add fpsdebug Change-Id: I1fd8592da3305ec2b318f8c6d0b961bb8ff16eb2 --- configure.ac | 10 +- lib/Makefile.am | 6 +- lib/xdbg.h | 1 + lib/xdbg_log_fpsdebug.c | 187 ++++++++++++++++++++++++++++++++++++ lib/xdbg_log_fpsdebug.h | 44 +++++++++ module/Makefile.am | 1 + module/xdbg_module_command.c | 25 +++++ module/xdbg_module_fpsdebug.c | 44 +++++++++ module/xdbg_module_fpsdebug.h | 40 ++++++++ module/xdbg_module_plist.h | 6 +- packaging/xorg-x11-module-xdbg.spec | 1 + 11 files changed, 355 insertions(+), 10 deletions(-) create mode 100755 lib/xdbg_log_fpsdebug.c create mode 100755 lib/xdbg_log_fpsdebug.h create mode 100755 module/xdbg_module_fpsdebug.c create mode 100755 module/xdbg_module_fpsdebug.h diff --git a/configure.ac b/configure.ac index 04b51d0..7f86074 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved. -# +# # Contact: Boram Park -# +# # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including @@ -9,11 +9,11 @@ # distribute, sub license, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: -# +# # The above copyright notice and this permission notice (including the # next paragraph) shall be included in all copies or substantial portions # of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -49,7 +49,7 @@ AC_ARG_WITH(xorg-module-dir, [moduledir="$libdir/xorg/modules"]) # Checks for pkg-config packages -PKG_CHECK_MODULES(XDBG, xorg-server x11 dbus-1 bigreqsproto compositeproto damageproto dmxproto dri2proto fixesproto fontsproto gestureproto inputproto kbproto randrproto recordproto renderproto resourceproto scrnsaverproto videoproto xcmiscproto xextproto xf86bigfontproto xf86dgaproto xf86driproto xf86vidmodeproto xineramaproto xproto) +PKG_CHECK_MODULES(XDBG, xorg-server x11 dbus-1 bigreqsproto compositeproto damageproto dmxproto dri2proto fixesproto fontsproto gestureproto inputproto kbproto randrproto recordproto renderproto resourceproto scrnsaverproto videoproto xcmiscproto xextproto xf86bigfontproto xf86dgaproto xf86driproto xf86vidmodeproto xineramaproto xproto libdrm) AC_SUBST([XDBG_CFLAGS]) AC_SUBST([XDBG_LIBS]) diff --git a/lib/Makefile.am b/lib/Makefile.am index b2d46c7..0891b29 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -36,14 +36,16 @@ libxdbg_log_la_SOURCES = \ xdbg_log_klog.c \ xdbg_log_dlog.c \ xdbg_log_drmevent.c \ - xdbg_log_plist.c + xdbg_log_plist.c \ + xdbg_log_fpsdebug.c xdbgincludedir = $(includedir)/xdbg xdbginclude_HEADERS = \ xdbg.h \ xdbg_log.h \ xdbg_log_drmevent.h \ - xdbg_log_plist.h + xdbg_log_plist.h \ + xdbg_log_fpsdebug.h pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = xdbg.pc diff --git a/lib/xdbg.h b/lib/xdbg.h index b489317..a18723a 100755 --- a/lib/xdbg.h +++ b/lib/xdbg.h @@ -36,5 +36,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include #endif /* __XDBG_H__ */ diff --git a/lib/xdbg_log_fpsdebug.c b/lib/xdbg_log_fpsdebug.c new file mode 100755 index 0000000..618efe3 --- /dev/null +++ b/lib/xdbg_log_fpsdebug.c @@ -0,0 +1,187 @@ +/************************************************************************** + +xdbg + +Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + +Contact: SooChan Lim + Sangjin LEE + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include "xorg-server.h" +#include "xdbg.h" +#include "xdbg_log_fpsdebug.h" + +#ifndef API +#define API __attribute__ ((visibility("default"))) +#endif + +static Bool g_on = FALSE; + +struct _fpsDebug +{ + int nPanCount; + CARD32 tStart, tCur, tLast; + OsTimerPtr fpsTimer; + int connector_type; + int cid; +}; + +static struct +{ + int type; + const char *name; +} connector_list[] = +{ + { DRM_MODE_CONNECTOR_Unknown, "unknown" }, + { DRM_MODE_CONNECTOR_VGA, "VGA" }, + { DRM_MODE_CONNECTOR_DVII, "DVI-I" }, + { DRM_MODE_CONNECTOR_DVID, "DVI-D" }, + { DRM_MODE_CONNECTOR_DVIA, "DVI-A" }, + { DRM_MODE_CONNECTOR_Composite, "composite" }, + { DRM_MODE_CONNECTOR_SVIDEO, "s-video" }, + { DRM_MODE_CONNECTOR_LVDS, "LVDS" }, + { DRM_MODE_CONNECTOR_Component, "component" }, + { DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" }, + { DRM_MODE_CONNECTOR_DisplayPort, "displayport" }, + { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" }, + { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" }, + { DRM_MODE_CONNECTOR_TV, "TV" }, + { DRM_MODE_CONNECTOR_eDP, "embedded displayport" }, + { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, +}; + +static int +_get_connector_id (int connector_type) +{ + int num = sizeof (connector_list) / sizeof (connector_list[0]); + int i; + int cid = 0; + + for (i = 0; i < num; i++) + { + if (connector_type == connector_list[i].type) + { + cid = i; + break; + } + } + + return cid; +} + + +static int +_fps_print_fps (FpsDebugPtr pFpsDebug, int isTimeOut) +{ + double sec; + + sec = (double) (pFpsDebug->tLast - pFpsDebug->tStart) /1000.0; + ErrorF ("[Xorg..V][%s][FB:(%3dframes %3.1ffps)] Dur:%3.3f...%s\n", + connector_list[pFpsDebug->cid].name, pFpsDebug->nPanCount, pFpsDebug->nPanCount / sec, + sec, isTimeOut ? "[TimeOut]" : ""); + pFpsDebug->nPanCount = 0; + + return 0; +} + +static CARD32 +_fps_frame_timeout (OsTimerPtr timer, CARD32 now, pointer arg) +{ + _fps_print_fps (arg, TRUE); + + return 0; +} + + +API FpsDebugPtr +xDbgLogFpsDebugCreate () +{ + FpsDebugPtr pFpsDebug = NULL; + + pFpsDebug = calloc (1, sizeof (struct _fpsDebug)); + if (!pFpsDebug) + { + XDBG_ERROR (MXDBG, "fail to allocate the FpsDebug\n"); + return NULL; + } + + return pFpsDebug; +} + +API void +xDbgLogFpsDebugDestroy (FpsDebugPtr pFpsDebug) +{ + if (!pFpsDebug) + return; + + free (pFpsDebug); + pFpsDebug = NULL; +} + +API void +xDbgLogFpsDebugCount (FpsDebugPtr pFpsDebug, int connector_type) +{ + /* if fpsdebug is off, do not count fps */ + if (!g_on) + return; + + if (!pFpsDebug) + return; + + if (connector_type != pFpsDebug->connector_type) + { + pFpsDebug->connector_type = connector_type; + pFpsDebug->cid = _get_connector_id (connector_type); + } + + pFpsDebug->tCur = GetTimeInMillis(); + if (pFpsDebug->nPanCount && pFpsDebug->tStart + 1000 <= pFpsDebug->tCur) + _fps_print_fps (pFpsDebug, FALSE); + + if (pFpsDebug->nPanCount == 0) + pFpsDebug->tStart = pFpsDebug->tLast; + + pFpsDebug->nPanCount++; + pFpsDebug->tLast = pFpsDebug->tCur; + pFpsDebug->fpsTimer = TimerSet (pFpsDebug->fpsTimer + , 0, 1000 + , _fps_frame_timeout, pFpsDebug); +} + +API void +xDbgLogFpsDebug (int on) +{ + if (g_on != on) + g_on = on; +} + diff --git a/lib/xdbg_log_fpsdebug.h b/lib/xdbg_log_fpsdebug.h new file mode 100755 index 0000000..0229c51 --- /dev/null +++ b/lib/xdbg_log_fpsdebug.h @@ -0,0 +1,44 @@ +/************************************************************************** + +xdbg + +Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + +Contact: SooChan Lim + Sangjin LEE + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +#ifndef __XDBG_LOG_FPSDEBUG_H__ +#define __XDBG_LOG_FPSDEBUG_H__ + +typedef struct _fpsDebug *FpsDebugPtr; + +FpsDebugPtr xDbgLogFpsDebugCreate (void); +void xDbgLogFpsDebugDestroy (FpsDebugPtr pFpsDebug); +void xDbgLogFpsDebugCount (FpsDebugPtr pFpsDebug, int connector_type); + +void xDbgLogFpsDebug (int on); + +#endif /* __XDBG_LOG_FPSDEBUG_H__ */ + diff --git a/module/Makefile.am b/module/Makefile.am index 89de644..107709f 100644 --- a/module/Makefile.am +++ b/module/Makefile.am @@ -41,6 +41,7 @@ libxdbg_la_SOURCES = \ xdbg_module_command.c \ xdbg_module_clist.c \ xdbg_module_plist.c \ + xdbg_module_fpsdebug.c \ xdbg_module_evlog.c \ xdbg_module_evlog_request.c \ xdbg_module_evlog_event.c \ diff --git a/module/xdbg_module_command.c b/module/xdbg_module_command.c index 822682f..57ad1f2 100755 --- a/module/xdbg_module_command.c +++ b/module/xdbg_module_command.c @@ -48,6 +48,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_module_plist.h" #include "xdbg_module_evlog.h" #include "xdbg_module_drmevent.h" +#include "xdbg_module_fpsdebug.h" #include "xdbg_module_command.h" static Bool @@ -276,6 +277,24 @@ _CommandDrmEventPending (int pid, int argc, char **argv, char *reply, int *len, xDbgModuleDrmEventPending (pMod, reply, len); } +static void +_CommandFpsDebug (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod) +{ + int on; + + if (argc != 3) + { + XDBG_REPLY ("Error : too few arguments\n"); + return; + } + + on = atoi (argv[2]); + + xDbgModuleFpsDebug (pMod, on, reply, len); + + XDBG_REPLY ("Success\n"); +} + static struct { const char *Cmd; @@ -341,6 +360,12 @@ static struct NULL, "", _CommandDrmEventPending }, + + { + "fpsdebug", "to print fps", "[0-1]", + NULL, "[OFF:0/ON:1]", + _CommandFpsDebug + }, }; static void _CommandPrintUsage (char *reply, int *len, const char * exec) diff --git a/module/xdbg_module_fpsdebug.c b/module/xdbg_module_fpsdebug.c new file mode 100755 index 0000000..f4d6e1e --- /dev/null +++ b/module/xdbg_module_fpsdebug.c @@ -0,0 +1,44 @@ +/************************************************************************** + +xdbg + +Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + +Contact: Boram Park + Sangjin LEE + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xdbg.h" +#include "xdbg_module_types.h" + +void +xDbgModuleFpsDebug (XDbgModule *pMod, int on, char *reply, int *len) +{ + xDbgLogFpsDebug (on); +} + diff --git a/module/xdbg_module_fpsdebug.h b/module/xdbg_module_fpsdebug.h new file mode 100755 index 0000000..596c223 --- /dev/null +++ b/module/xdbg_module_fpsdebug.h @@ -0,0 +1,40 @@ +/************************************************************************** + +xdbg + +Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + +Contact: Boram Park + Sangjin LEE + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +#ifndef __XDBG_MODULE_FPSDEBUG_H__ +#define __XDBG_MODULE_FPSDEBUG_H__ + +#include "xdbg_module_types.h" + +void xDbgModuleFpsDebug (XDbgModule *pMod, int on, char *reply, int *len); + + +#endif /* __XDBG_MODULE_FPSDEBUG_H__ */ diff --git a/module/xdbg_module_plist.h b/module/xdbg_module_plist.h index 8288b8e..b15aa58 100755 --- a/module/xdbg_module_plist.h +++ b/module/xdbg_module_plist.h @@ -29,11 +29,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ -#ifndef __XDBG_MODULE_RLIST_H__ -#define __XDBG_MODULE_RLIST_H__ +#ifndef __XDBG_MODULE_PLIST_H__ +#define __XDBG_MODULE_PLIST_H__ #include "xdbg_module_types.h" void xDbgModulePList (XDbgModule *pMod, char *reply, int *remain); -#endif /* __XDBG_MODULE_CLIENT_LIST_H__ */ \ No newline at end of file +#endif /* __XDBG_MODULE_PLIST_H__ */ \ No newline at end of file diff --git a/packaging/xorg-x11-module-xdbg.spec b/packaging/xorg-x11-module-xdbg.spec index 2d7db48..a7e52f3 100644 --- a/packaging/xorg-x11-module-xdbg.spec +++ b/packaging/xorg-x11-module-xdbg.spec @@ -34,6 +34,7 @@ BuildRequires: pkgconfig(xf86driproto) BuildRequires: pkgconfig(xf86vidmodeproto) BuildRequires: pkgconfig(xineramaproto) BuildRequires: pkgconfig(xproto) +BuildRequires: pkgconfig(libdrm) %description -- 2.7.4