Hi Arjan/Kristen,

I made some modifications on the patch (use 'sd->v4l2_dev->dev' rather than 
'&c->adapter->dev ' )
And, also merged it based on the latest version (0.95). Please review.

From: Yong He <yong.m...@intel.com>
Subject: [patch] mrstov5640: use linux debug print mechanism #9826

Bug 9826 - camera driver is very noisy.

Signed-off-by: He, Yong <yong.m...@intel.com>

----
Index: linux-2.6.37/drivers/staging/mrstci/mrstov5640/mrstov5640.c
===================================================================
--- linux-2.6.37/drivers/staging/mrstci/mrstov5640/mrstov5640.c (revision 105)
+++ linux-2.6.37/drivers/staging/mrstci/mrstov5640/mrstov5640.c (working copy)
@@ -24,6 +24,8 @@
  * Yong He <yong.m...@intel.com>
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -50,10 +52,6 @@
 
 #define DRIVER_VERSION "0.95"
 
-static int mrstov5640_debug = 3;
-module_param(mrstov5640_debug, int, 0644);
-MODULE_PARM_DESC(mrstov5640_debug, "Debug level (0-1)");
-
 #define GPIO_FLASH 45
 static int ov5640_flash=0;
 
@@ -61,20 +59,9 @@
 #define V4L2_CID_FLASH_STROBE                   
(V4L2_CID_CAMERA_CLASS_BASE+17) 
 #endif
 
-#define dprintk(level, fmt, arg...) do {                       \
-       if (mrstov5640_debug >= level)                                  \
-               printk(KERN_DEBUG "ov5640@%s: " fmt "\n", \
-                      __func__, ## arg); } \
-       while (0)
+#define DBG_entering   pr_debug("entering %s\n", __func__);
+#define DBG_leaving    pr_debug("leaving %s\n", __func__);
 
-#define eprintk(fmt, arg...)   \
-       printk(KERN_ERR "ov5640@%s: line %d: " fmt "\n",        \
-              __func__, __LINE__, ## arg);
-
-#define DBG_entering   dprintk(2, "entering");
-#define DBG_leaving    dprintk(2, "leaving");
-#define DBG_line       dprintk(2, " line: %d", __LINE__);
-
 static inline struct ci_sensor_config *to_sensor_config(struct v4l2_subdev *sd)
 {
        return container_of(sd, struct ci_sensor_config, sd);
@@ -272,7 +259,6 @@
        *value = ret_val;
 
        ret = (ret == 2) ? 0 : -1;
-       dprintk( 4, " && ov5640_read  \t\t\t(0x%04x) ------> 
0x%02x",reg,*value);
        return ret;
 }
 
@@ -300,7 +286,6 @@
        if (reg == 0x3008 && (value & 0x80))
                msleep(3);
        ret = (ret == 1) ? 0 : -1;
-       dprintk( 4, "&& ov5640_write \t\t\t(0x%04x) <------ 0x%02x",reg,value);
        return ret;
 }
 
@@ -357,7 +342,8 @@
 static int ov5640_set_aec_agc(struct i2c_client *c, int on)
 {
        int ret = 0;
-       dprintk(3, "ov5640_set_aec_agc: (%d)", on);
+       struct v4l2_subdev *sd = i2c_get_clientdata(c);
+       dev_dbg(sd->v4l2_dev->dev, "ov5640_set_aec_agc: (%d)", on);
 
        if (on)
                ret = ov5640_write(c, 0x3503, 0x00);
@@ -399,19 +385,21 @@
                unsigned int x, unsigned int y)
 {
        int ret = 0;
+       struct v4l2_subdev *sd = i2c_get_clientdata(c);
        DBG_entering;
 
        if (x > OV5640_FOCUS_NORMALIZED_W) {
-               dprintk(1, "Error focus point x = %d\n", x);
+               dev_dbg(sd->v4l2_dev->dev, "Error focus point x = %d\n", x);
                return -1;
        }
 
        if (y > OV5640_FOCUS_NORMALIZED_H) {
-               dprintk(1, "Error focus point y = %d\n", y);
+               dev_dbg(sd->v4l2_dev->dev, "Error focus point y = %d\n", y);
                return -1;
        }
 
-       dprintk(3, "ov5640_af_change_pos x = %d, y = %d\n", x, y);
+       dev_dbg(sd->v4l2_dev->dev,
+                       "ov5640_af_change_pos x = %d, y = %d\n", x, y);
 
        ret += ov5640_write(c, 0x3024, x);
        ret += ov5640_write(c, 0x3025, y);
@@ -477,6 +465,7 @@
 {
        int ret;
        u8 val;
+       struct v4l2_subdev *sd = i2c_get_clientdata(c);
        DBG_entering;
 
        if (ov5640_status.fw_inited !=  OV5640_FW_RESET) {
@@ -488,7 +477,7 @@
 
        ret = ov5640_write_array(c, ov5640_reg_fw);
        if (ret > OV5640_FW_LOAD_EXPECTED_MAX_MISMATCH) {
-               dprintk(1, "AF Load FW Failed = %d!!\n", ret);
+               dev_dbg(sd->v4l2_dev->dev, "AF Load FW Failed = %d!!\n", ret);
                goto __ov5640_af_init_exit;
        } else {
                /* firmware start */
@@ -500,7 +489,7 @@
        /* check if firmware started */
        ov5640_read(c, 0x3029, &val);
        if (val == 0xff) {
-               dprintk(1, "AF FW is not running!\n");
+               dev_dbg(sd->v4l2_dev->dev, "AF FW is not running!\n");
                ret = -1;
                goto __ov5640_af_init_exit;
        }
@@ -518,6 +507,7 @@
 {
        int ret;
        unsigned long flags;
+       struct v4l2_subdev *sd = i2c_get_clientdata(c);
        DBG_entering;
 
        spin_lock_irqsave(&ov5640_status.state_lock, flags);
@@ -534,7 +524,8 @@
 
        /* Set registers into default config value */
        ret = ov5640_write_array(c, ov5640_def_reg);
-       dprintk( 1, "[ov5640-wr-reg] <----------- load ov5640 default 
settings\n");
+       dev_dbg(sd->v4l2_dev->dev, "[ov5640-wr-reg] <-----------"
+                       " load ov5640 default settings\n");
        ret += ov5640_set_aec_agc(c, 1);
        ov5640_set_data_pin_in(c);
 
@@ -567,19 +558,20 @@
                spin_unlock_irqrestore(&ov5640_status.state_lock, flags);
        }
 
-       dprintk(1, "PM: ov5640 standby called\n");
+       printk(KERN_INFO "PM: ov5640 standby called\n");
 }
 
 static void ov5640_wakeup(struct v4l2_subdev *sd, int hw_reinit)
 {
        unsigned long flags;
-       dprintk(1, "PM: ov5640 wakeup called\n");
+
+       printk(KERN_INFO "PM: ov5640 wakeup called\n");
        spin_lock_irqsave(&ov5640_status.state_lock, flags);
 
        if (ov5640_status.power == OV5640_POWER_OFF) {
                ov5640_status.power = OV5640_POWER_ON;
                spin_unlock_irqrestore(&ov5640_status.state_lock, flags);
-               dprintk(1, "PM: ov5640 switch OFF to ON.\n");
+               printk(KERN_INFO "PM: ov5640 switch OFF to ON.\n");
                gpio_set_value(GPIO_STDBY_PIN, 0);
        } else {
                spin_unlock_irqrestore(&ov5640_status.state_lock, flags);
@@ -666,7 +658,7 @@
        struct ov5640_res_struct *res_index, *p = NULL;
        int dis, last_dis = ov5640_res->width + ov5640_res->height;
 
-       dprintk(1, "&&&&&  before %dx%d", *w, *h);
+       pr_debug("&&&&&  before %dx%d", *w, *h);
        for (res_index = ov5640_res;
             res_index < ov5640_res + N_RES;
             res_index++) {
@@ -699,7 +691,7 @@
        *w = res_index->width;
        *h = res_index->height;
 
-       dprintk(1, "&&&&&  after %dx%d", *w, *h);
+       pr_debug("&&&&&  after %dx%d", *w, *h);
        return 0;
 }
 
@@ -724,11 +716,11 @@
 {
        int ret = 0;
        DBG_entering;
-       dprintk(1, "&&&&&  before %dx%d", fmt->width,
-               fmt->height);
+       dev_dbg(sd->v4l2_dev->dev, "&&&&&  before %dx%d",
+                       fmt->width,     fmt->height);
        ret = ov5640_try_res(&fmt->width, &fmt->height);
-       dprintk(1, "&&&&&  after %dx%d", fmt->width,
-               fmt->height);
+       dev_dbg(sd->v4l2_dev->dev, "&&&&&  after %dx%d",
+                       fmt->width,     fmt->height);
        DBG_leaving;
        return ret;
 }
@@ -865,10 +857,12 @@
        val = ov5640_setting_ext[idx].REG_3a0d;
        ret += ov5640_write(c, 0x3a0d, val);
 
-       dprintk(3, "ov5640_set_b_filter: ov5640_setting_ext[%d]."
+       dev_dbg(sd->v4l2_dev->dev,
+                       "ov5640_set_b_filter: ov5640_setting_ext[%d]."
                        "REG_3a08w  <- 0x%x", idx,
                        ov5640_setting_ext[idx].REG_3a08w);
-       dprintk(3, "ov5640_set_b_filter: ov5640_setting_ext[%d]."
+       dev_dbg(sd->v4l2_dev->dev,
+                       "ov5640_set_b_filter: ov5640_setting_ext[%d]."
                        "REG_3a0aw  <- 0x%x", idx,
                        ov5640_setting_ext[idx].REG_3a0aw);
 
@@ -910,13 +904,13 @@
        else
                ov5640_status.expo.lightfreq = 60;
 
-       dprintk(3, "ov5640_save_expo_val: "
+       dev_dbg(sd->v4l2_dev->dev, "ov5640_save_expo_val: "
                        "ov5640_status.preview.gain16    -> 0x%x",
                        ov5640_status.preview.gain16);
-       dprintk(3, "ov5640_save_expo_val: "
+       dev_dbg(sd->v4l2_dev->dev, "ov5640_save_expo_val: "
                        "ov5640_status.preview.shutter16  -> 0x%x",
                        ov5640_status.preview.shutter16);
-       dprintk(3, "ov5640_save_expo_val: "
+       dev_dbg(sd->v4l2_dev->dev, "ov5640_save_expo_val: "
                        "ov5640_status.expo.lightfreq -> 0x%x",
                        ov5640_status.expo.lightfreq);
 
@@ -940,7 +934,7 @@
        ret += ov5640_write(c, 0x350B, val);
        val = (ov5640_status.snapshot.gain16>>8);
        ret += ov5640_write(c, 0x350A, val);
-       dprintk(3, "ov5640_set_gain: ov5640_status.snapshot"
+       dev_dbg(sd->v4l2_dev->dev, "ov5640_set_gain: ov5640_status.snapshot"
                        ".gain16 <- 0x%x", ov5640_status.snapshot.gain16);
 
        return ret;
@@ -973,8 +967,10 @@
        x *= (ov5640_status.preview.shutter16/16);
 
        y = ov5640_setting_ext[cap_idx].REG_380cw;
-       dprintk(3, "ov5640_restore_expo: x = 0x%Lx,  y = 0x%Lx", x, y);
-       dprintk(3, "ov5640_setting_ext[pre_idx].REG_380cw = 0x%x,"
+       dev_dbg(sd->v4l2_dev->dev,
+                       "ov5640_restore_expo: x = 0x%Lx,  y = 0x%Lx", x, y);
+       dev_dbg(sd->v4l2_dev->dev,
+                       "ov5640_setting_ext[pre_idx].REG_380cw = 0x%x,"
                        "ov5640_status.preview.gain16 = 0x%x,"
                        "ov5640_status.preview.shutter16 = 0x%x",
                        ov5640_setting_ext[pre_idx].REG_380cw,
@@ -984,10 +980,12 @@
        x =  (x*ov5640_setting_ext[cap_idx].sysclk + 8)>>4;
        y =  (y*ov5640_setting_ext[pre_idx].sysclk + 8)>>4;
 
-       dprintk(3, "ov5640_restore_expo: x2 = 0x%Lx,  y2 = 0x%Lx", x, y);
+       dev_dbg(sd->v4l2_dev->dev,
+               "ov5640_restore_expo: x2 = 0x%Lx,  y2 = 0x%Lx", x, y);
        exposure = do_div(x, y);
        exposure = x;
-       dprintk(3, "ov5640_restore_expo: exposure = 0x%Lx", exposure);
+       dev_dbg(sd->v4l2_dev->dev,
+               "ov5640_restore_expo: exposure = 0x%Lx", exposure);
 
        maxgain16 = 0x01fc; /* 32x */
 
@@ -1065,10 +1063,10 @@
        val = ((ov5640_status.snapshot.shutter16>>16)&0x0F);
        ov5640_write(c, 0x3500, val);
 
-       dprintk(3, "ov5640_restore_expo: "
+       dev_dbg(sd->v4l2_dev->dev, "ov5640_restore_expo: "
                        "frmshuttermax               <- 0x%x",
                        frmshuttermax);
-       dprintk(3, "ov5640_restore_expo: "
+       dev_dbg(sd->v4l2_dev->dev, "ov5640_restore_expo: "
                        "ov5640_status.preview.shutter16  <- 0x%x",
                        ov5640_status.snapshot.shutter16);
 
@@ -1108,11 +1106,13 @@
                        ov5640_status.current_res_i = target_res_index;
                        spin_unlock_irqrestore(
                                        &ov5640_status.state_lock, flags);
-                       dprintk(3, "[ov5640-wr-reg] <----------- "
+                       dev_dbg(sd->v4l2_dev->dev,
+                                       "[ov5640-wr-reg] <----------- "
                                        "changing res from index-%d to index-%d 
(%dx%d)",
                                        previous_res_i,
                                        target_res_index, width, height);
-                       dprintk(3, "[ov5640-wr-reg] <----------- "
+                       dev_dbg(sd->v4l2_dev->dev,
+                                       "[ov5640-wr-reg] <----------- "
                                        "Set resolutiojn Configs");
                        ov5640_save_hw_status(client);
                        ret += ov5640_write_array(client, res_index->regs);
@@ -1126,7 +1126,10 @@
                } else {
                        spin_unlock_irqrestore(
                                        &ov5640_status.state_lock, flags);
-                       dprintk(3, "[ov5640-wr-reg] <----------- same res 
index-%d (%dx%d)", target_res_index,width, height);
+                       dev_dbg(sd->v4l2_dev->dev,
+                                       "[ov5640-wr-reg] <----------- "
+                                       "same res index-%d (%dx%d)",
+                                       target_res_index, width, height);
                }
 
                /* Marked current sensor res as being "used" */
@@ -1140,7 +1143,8 @@
                }
 
                for (index = 0; index < N_RES; index++)
-                       dprintk(2, "index = %d, used = %d\n", index,
+                       dev_dbg(sd->v4l2_dev->dev,
+                               "index = %d, used = %d\n", index,
                                ov5640_res[index].used);
 
        }
@@ -1614,19 +1618,22 @@
        struct i2c_client *client = v4l2_get_subdevdata(sd);
        DBG_entering;
 
-       dprintk( 1, "[ov5640-wr-reg] <----------- ov5640: s_stream %d 
\n",enable);
+       dev_dbg(sd->v4l2_dev->dev, "[ov5640-wr-reg]"
+                       " <----------- ov5640: s_stream %d\n", enable);
 
        if (enable) {
                unsigned char v;
                int af_fw_status;
                ov5640_read(client, 0x3008, &v);
                if ((v & 0xff) != 0x02) {
-                       dprintk( 1, "[ov5640-wr-reg] <----------- set stream 
on, sleep 300 ms for sensor adjusting...\n");
+                       dev_dbg(sd->v4l2_dev->dev, "[ov5640-wr-reg]"
+                                       " <----------- set stream on, sleep 300 
ms"
+                                       " for sensor adjusting...\n");
                        ov5640_write(client, 0x3008, 0x02);
                        ov5640_set_aec_agc(client, 1);
                        af_fw_status = ov5640_af_init(client);
                        if (af_fw_status != 0) {
-                               dprintk(1, "ov5640_af_init error - (%d)\n",
+                               dev_dbg(sd->v4l2_dev->dev, "ov5640_af_init 
error - (%d)\n",
                                                af_fw_status);
                        }
                        msleep(300);
@@ -1670,7 +1677,8 @@
        DBG_entering;
 
        res_index = find_OV5640_res_index(fival->width, fival->height);
-       dprintk( 1, "find res index %d (%dx%d)\n",res_index,fival->width, 
fival->height);
+       dev_dbg(sd->v4l2_dev->dev, "find res index %d (%dx%d)\n",
+                       res_index, fival->width, fival->height);
 
        if (res_index >= N_RES)
                return -EINVAL;
@@ -1693,7 +1701,8 @@
        fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
        fival->discrete.numerator = 1;
        fival->discrete.denominator = ov5640_res[res_index].fps[index];
-       dprintk( 1, "find FPS index-%d 
(%d)\n",index,fival->discrete.denominator);
+       dev_dbg(sd->v4l2_dev->dev, "find FPS index-%d (%d)\n",
+                       index, fival->discrete.denominator);
 
        DBG_leaving;
 
@@ -1714,7 +1723,8 @@
                        if (target_fps == 
ov5640_res[ov5640_status.current_res_i].fps[fps_i]) {
                                /* found the target fps*/
                                u8 val;
-                               dprintk( 1, "set sensor FPS to %d\n", 
target_fps);
+                               dev_dbg(sd->v4l2_dev->dev,
+                                       "set sensor FPS to %d\n", target_fps);
                                ov5640_read(client, 0x3008, &val);
                                if (val == 0x02) ov5640_s_stream(sd, 0);
 
@@ -1727,12 +1737,16 @@
                        }
                }
                if (fps_i >= OV5640_N_FPS) {
-                       dprintk( 1, "Warning!! target FPS %d/%d is not found in 
sensor supported table.\n",
-                                       
param->parm.capture.timeperframe.denominator, 
param->parm.capture.timeperframe.numerator);
+                       dev_dbg(sd->v4l2_dev->dev,
+                               "Warning!! target FPS %d/%d is not found"
+                               " in sensor supported table.\n",
+                               param->parm.capture.timeperframe.denominator,
+                               param->parm.capture.timeperframe.numerator);
                        return -EINVAL;
                }
        } else {
-               dprintk( 1, "Warning!! current_res (%d) is not used??\n",
+               dev_dbg(sd->v4l2_dev->dev,
+                               "Warning!! current_res (%d) is not used??\n",
                                ov5640_status.current_res_i);
        }
 
@@ -1770,8 +1784,6 @@
 {
        struct i2c_client *client = v4l2_get_subdevdata(sd);
 
-       dprintk( 1, "[ov5640-wr-reg] <----------- ov5640_s_register 0x%04x 
(0x%02x)\n",
-                       (unsigned int)(reg->reg & 0xffff),(unsigned 
int)(reg->val & 0xff));
        ov5640_write(client, reg->reg & 0xffff, reg->val & 0xff);
        return 0;
 }
        Signed-off-by: Yong He <yong.m...@intel.com>
-- Yong
Phone (+86) 21-61166334
Lab (+86) 21-61167881





Attachment: linux-2.6.37-camera-debug-printk-ov5640.patch
Description: linux-2.6.37-camera-debug-printk-ov5640.patch

_______________________________________________
MeeGo-kernel mailing list
MeeGo-kernel@lists.meego.com
http://lists.meego.com/listinfo/meego-kernel

Reply via email to