3026 codec: add debug interface
authoryj <yangjie@rock-chips.com>
Thu, 10 Oct 2013 07:23:35 +0000 (15:23 +0800)
committeryj <yangjie@rock-chips.com>
Thu, 10 Oct 2013 07:23:35 +0000 (15:23 +0800)
sound/soc/codecs/rk3026_codec.c

index ecadd523e7c3bd17537b0d6b8802f858325b4a11..2d3ee646eb07f6bc2222517dc3629bc372019602 100755 (executable)
 #include "../../../drivers/headset_observe/rk_headset.h"
 #endif
 
-#if 0
-#define        DBG(x...)       printk(x)
-#else
-#define        DBG(x...)
-#endif
+static int debug;
+module_param(debug, int, S_IRUGO|S_IWUSR);
+
+#define dbg_codec(level, fmt, arg...) do {                     \
+       if (debug >= level)                                     \
+       printk(fmt , ## arg); } while (0)
+
+#define        DBG(fmt,...)    dbg_codec(1,fmt,## __VA_ARGS__)
+
 
 /* volume setting
  *  0: -39dB
@@ -351,7 +355,7 @@ static unsigned int rk3026_codec_read(struct snd_soc_codec *codec, unsigned int
        }
 
        value = readl_relaxed(rk3026_priv->regbase+reg);
-       DBG("%s : reg = 0x%x, val= 0x%x\n", __func__, reg, value);
+       dbg_codec(2,"%s : reg = 0x%x, val= 0x%x\n", __func__, reg, value);
 
        return value;
 }
@@ -376,7 +380,7 @@ static int rk3026_codec_write(struct snd_soc_codec *codec, unsigned int reg, uns
                rk3026_write_reg_cache(codec, reg, value);
        }
                
-       DBG("%s : reg = 0x%x, val = 0x%x, new_value=%d\n", __func__, reg, value,new_value);
+       dbg_codec(2,"%s : reg = 0x%x, val = 0x%x, new_value=%d\n", __func__, reg, value,new_value);
        return 0;
 }