Now all the DRM debug info will be reported if the boot option of
"drm.debug=1" is added. Sometimes it is inconvenient to get the debug 
info in KMS mode. We will get too much unrelated info.

This will separate several DRM debug levels and the debug level can be used 
to print the different debug info. And the debug level is controlled by the
module parameter of drm.debug

In this patch it is divided into four debug levels;
        drm_core, drm_driver, drm_kms, drm_mode.

At the same time we can get the different debug info by changing the debug
level. This can be done by adding the module parameter. Of course it can
be changed through the /sys/module/drm/parameters/debug after the system is
booted.

Four debug macro definitions are provided.
        DRM_DEBUG(fmt, args...)
        DRM_DEBUG_DRIVER(prefix, fmt, args...)
        DRM_DEBUG_KMS(prefix, fmt, args...)
        DRM_DEBUG_MODE(prefix, fmt, args...)

When the boot option of "drm.debug=4" is added, it will print the debug info
using DRM_DEBUG_KMS macro definition. 
When the boot option of "drm.debug=6" is added, it will print the debug info
using DRM_DEBUG_KMS/DRM_DEBUG_DRIVER.

Sometimes we expect to print the value of an array. 
For example: SDVO command, 
In such case the following four DRM debug macro definitions are added:
        DRM_LOG(fmt, args...)
        DRM_LOG_DRIVER(fmt, args...)
        DRM_LOG_KMS(fmt, args...)
        DRM_LOG_MODE(fmt, args...)
        
Signed-off-by: Zhao Yakui <yakui.z...@intel.com>
---
 drivers/gpu/drm/drm_stub.c |   17 +++++++++++-
 include/drm/drmP.h         |   61 +++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 72 insertions(+), 6 deletions(-)

Index: linux-2.6/drivers/gpu/drm/drm_stub.c
===================================================================
--- linux-2.6.orig/drivers/gpu/drm/drm_stub.c   2009-06-02 13:14:19.000000000 
+0800
+++ linux-2.6/drivers/gpu/drm/drm_stub.c        2009-06-02 13:26:35.000000000 
+0800
@@ -51,7 +51,22 @@
 struct class *drm_class;
 struct proc_dir_entry *drm_proc_root;
 struct dentry *drm_debugfs_root;
-
+void drm_ut_debug_printk(unsigned int request_level,
+                        const char *prefix,
+                        const char *function_name,
+                        const char *format, ...)
+{
+       va_list args;
+
+       if (drm_debug & request_level) {
+               if (function_name)
+                       printk(KERN_DEBUG "[%s:%s], ", prefix, function_name);
+               va_start(args, format);
+               vprintk(format, args);
+               va_end(args);
+       }
+}
+EXPORT_SYMBOL(drm_ut_debug_printk);
 static int drm_minor_get_id(struct drm_device *dev, int type)
 {
        int new_id;
Index: linux-2.6/include/drm/drmP.h
===================================================================
--- linux-2.6.orig/include/drm/drmP.h   2009-06-02 13:14:19.000000000 +0800
+++ linux-2.6/include/drm/drmP.h        2009-06-02 13:26:35.000000000 +0800
@@ -87,6 +87,15 @@
 #include "drm_os_linux.h"
 #include "drm_hashtab.h"
 
+#define DRM_UT_CORE            0x01
+#define DRM_UT_DRIVER          0x02
+#define DRM_UT_KMS             0x04
+#define DRM_UT_MODE            0x08
+
+extern void drm_ut_debug_printk(unsigned int request_level,
+                               const char *prefix,
+                               const char *function_name,
+                               const char *format, ...);
 /***********************************************************************/
 /** \name DRM template customization defaults */
 /*...@{*/
@@ -186,15 +195,57 @@
  * \param arg arguments
  */
 #if DRM_DEBUG_CODE
-#define DRM_DEBUG(fmt, arg...)                                         \
+#define DRM_DEBUG(fmt, args...)                                                
\
        do {                                                            \
-               if ( drm_debug )                        \
-                       printk(KERN_DEBUG                               \
-                              "[" DRM_NAME ":%s] " fmt ,       \
-                              __func__ , ##arg);                       \
+               drm_ut_debug_printk(DRM_UT_CORE, DRM_NAME,              \
+                                       __func__, fmt, ##args);         \
+       } while (0)
+
+#define DRM_DEBUG_DRIVER(prefix, fmt, args...)                         \
+       do {                                                            \
+               drm_ut_debug_printk(DRM_UT_DRIVER, prefix,              \
+                                       __func__, fmt, ##args);         \
+       } while (0)
+#define DRM_DEBUG_KMS(prefix, fmt, args...)                            \
+       do {                                                            \
+               drm_ut_debug_printk(DRM_UT_KMS, prefix,                 \
+                                        __func__, fmt, ##args);        \
+       } while (0)
+#define DRM_DEBUG_MODE(prefix, fmt, args...)                           \
+       do {                                                            \
+               drm_ut_debug_printk(DRM_UT_MODE, prefix,                \
+                                        __func__, fmt, ##args);        \
+       } while (0)
+#define DRM_LOG(fmt, args...)                                          \
+       do {                                                            \
+               drm_ut_debug_printk(DRM_UT_CORE, NULL,                  \
+                                       NULL, fmt, ##args);             \
+       } while (0)
+#define DRM_LOG_KMS(fmt, args...)                                      \
+       do {                                                            \
+               drm_ut_debug_printk(DRM_UT_KMS, NULL,                   \
+                                       NULL, fmt, ##args);             \
+       } while (0)
+#define DRM_LOG_MODE(fmt, args...)                                     \
+       do {                                                            \
+               drm_ut_debug_printk(DRM_UT_MODE, NULL,                  \
+                                       NULL, fmt, ##args);             \
+       } while (0)
+#define DRM_LOG_DRIVER(fmt, args...)                                   \
+       do {                                                            \
+               drm_ut_debug_printk(DRM_UT_DRIVER, NULL,                \
+                                       NULL, fmt, ##args);             \
        } while (0)
 #else
+#define DRM_DEBUG_DRIVER(prefix, fmt, args...) do { } while (0)
+#define DRM_DEBUG_KMS(prefix, fmt, args...)    do { } while (0)
+#define DRM_DEBUG_MODE(prefix, fmt, args...)   do { } while (0)
 #define DRM_DEBUG(fmt, arg...)          do { } while (0)
+#define DRM_LOG(fmt, arg...)           do { } while (0)
+#define DRM_LOG_KMS(fmt, args...) do { } while (0)
+#define DRM_LOG_MODE(fmt, arg...) do { } while (0)
+#define DRM_LOG_DRIVER(fmt, arg...) do { } while (0)
+
 #endif
 
 #define DRM_PROC_LIMIT (PAGE_SIZE-80)



------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to