add fpsdebug
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 3 Apr 2013 09:01:36 +0000 (18:01 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 3 Apr 2013 12:05:11 +0000 (21:05 +0900)
Change-Id: I1fd8592da3305ec2b318f8c6d0b961bb8ff16eb2

configure.ac
lib/Makefile.am
lib/xdbg.h
lib/xdbg_log_fpsdebug.c [new file with mode: 0755]
lib/xdbg_log_fpsdebug.h [new file with mode: 0755]
module/Makefile.am
module/xdbg_module_command.c
module/xdbg_module_fpsdebug.c [new file with mode: 0755]
module/xdbg_module_fpsdebug.h [new file with mode: 0755]
module/xdbg_module_plist.h
packaging/xorg-x11-module-xdbg.spec

index 04b51d0..7f86074 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
-# 
+#
 # Contact: Boram Park <boram1288.park@samsung.com>
-# 
+#
 # 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])
 
index b2d46c7..0891b29 100644 (file)
@@ -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
index b489317..a18723a 100755 (executable)
@@ -36,5 +36,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <xdbg_log.h>
 #include <xdbg_log_drmevent.h>
 #include <xdbg_log_plist.h>
+#include <xdbg_log_fpsdebug.h>
 
 #endif  /* __XDBG_H__ */
diff --git a/lib/xdbg_log_fpsdebug.c b/lib/xdbg_log_fpsdebug.c
new file mode 100755 (executable)
index 0000000..618efe3
--- /dev/null
@@ -0,0 +1,187 @@
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+         Sangjin LEE <lsj119@samsung.com>
+
+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 <stdio.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <xf86drm.h>
+#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 (executable)
index 0000000..0229c51
--- /dev/null
@@ -0,0 +1,44 @@
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+         Sangjin LEE <lsj119@samsung.com>
+
+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__ */
+
index 89de644..107709f 100644 (file)
@@ -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 \
index 822682f..57ad1f2 100755 (executable)
@@ -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 (executable)
index 0000000..f4d6e1e
--- /dev/null
@@ -0,0 +1,44 @@
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+         Sangjin LEE <lsj119@samsung.com>
+
+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 (executable)
index 0000000..596c223
--- /dev/null
@@ -0,0 +1,40 @@
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+         Sangjin LEE <lsj119@samsung.com>
+
+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__ */
index 8288b8e..b15aa58 100755 (executable)
@@ -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
index 2d7db48..a7e52f3 100644 (file)
@@ -34,6 +34,7 @@ BuildRequires:  pkgconfig(xf86driproto)
 BuildRequires:  pkgconfig(xf86vidmodeproto)
 BuildRequires:  pkgconfig(xineramaproto)
 BuildRequires:  pkgconfig(xproto)
+BuildRequires:  pkgconfig(libdrm)
 
 
 %description