How to check v4l2_dbg message in the console

Hi All,

I want to know that how to check v4l2_dbg message in the console.

Target board is TX2 and source version is R28.1

I think that it will be control with console_loglevel. Is it right?

Anyway, Please let me know for that detail.

Thanks & BR,

hello nwlee,

there’s dynamic debug flags to enable the logs.
for example, you can follow below steps to enable the debug prints of channel.c.
thanks

$ sudo -i
# cd /sys/kernel/debug/dynamic_debug/
# echo file channel.c +p > control

Hello Jerry,

Thank you for your reply.
I’d like to see “v4l2_dbg” message in the kernel driver.

For example, I want to see v4l2_dbg message to dmesg command on console of the Linux_for_Tegra_tx2/sources/kernel/kernel-4.4/drivers/media/i2c/tc358840.c file.

Is it possible with your command without kernel build?

Thanks & BR,

Hi Jerry,

Could you please send me reply for upper contents?

Thanks & BR,

hello nwlee,

it depends on the log levels you set,
please refer to the definition of v4l2_dbg,
thanks

r28.1_sources/kernel/kernel-4.4/include/media/v4l2-common.h

#define v4l2_dbg(level, debug, dev, fmt, arg...)			\
    do { 								\
        if (debug >= (level))					\
            v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); 	\
    } while (0)

Hello Jerry,

Thank you for your support.
How can I modify this define parameter for example?

Thanks & BR,

hello nwlee,

if you’re working with v4l2_dbg,
there will be additional debug flags for each modules,
please check the debug flag as below path, and modify the parameter to change the log level.

/sys/module/name/parameters/debug

Hi Jerry,

I have check the debug flag as below path.

) cat /sys/module/tc358840/parameters/debug ) 0

On the TX2 board, the log level is 0.
This flag is not modified with sudo permission.
How can I modify this debug flag?

Thanks & BR,

Hi Jerry,

Could you let me know your idea for upper contents?

What I want to know, where is defined about log level.

Now, v4l2_dbg level is 0. I’d like to change with v4l2_dbg 1.

Please give me a your reply.

Thanks & BR,

hello nwlee,

there’s echo commands for you to change the debug flag dynamically.

Hello Jerry,

You mean the dinamic debug of the post #2?

I don’t understand exactly.

I have test as below.

sudo -i

cd /sys/kernel/debug/dynamic_debug/

echo file tc358840.c +p > control

Is it right? It is not working anything.

Please let me know detail.

Thanks & BR,

Hi Jerry,

Maybe, Is it possible that would be install v4l2-src and v4l2-ctl?

That is, Is the v4l2_dbg involved with v4l2-ctl? Or not, Is it just only set the log level?

How dosn’t it see the debug message with “dmesg”?

I want to konw with method as below.

A. kernel log level of the v4l2_dbg is set. (same with printk log level)
B. build the kernel.
C. boot and “dmesg” command on the console, v4l2_dbg log message check.
For example, v4l2_dbg(1, debug, sd, “%s: no valid signal\n”, func);
print output “%s: no valid signal”

Thanks & BR,

hello nwlee,

please refer to below code snippet in the tc358840 kernel driver.

static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "debug level (0-3)");

above paragraph will create the debug flags under its module.
and you should be able to control the value following below.

ehco 1 > /sys/module/tc358840/parameters/debug

please refer to v4l2_dbg function definition in comment #5, you should be able to saw below message while setting the debug flags.

v4l2_dbg(1, debug, sd, "%s: no valid signal\n", __func__);

Hi Jerry,

debug log level was changed well as below.

cat /sys/module/tc358840/parameters/debug 0 sudo -i
#ehco 1 > /sys/module/tc358840/parameters/debug
#exit
$ cat /sys/module/tc358840/parameters/debug
1

but, I can’t see the debug message with dmesg.

I think that v4l2_dbg function of the v4l2-common.h should be modified.

How can I modify for see the log message below function?

#define v4l2_dbg(level, debug, dev, fmt, arg…)
do {
if (debug >= (level))
v4l2_printk(KERN_DEBUG, dev, fmt , ## arg);
} while (0)

Could you let me know your idea?

Thanks & BR,

hello nwlee,

i’ve verified v4l2_dbg macro works.
since default imx274 did not enable this feature, please refer to below code snippet and steps as an example.
thanks

diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c
index 2c60402..c8815c0 100644
--- a/drivers/media/i2c/imx274.c
+++ b/drivers/media/i2c/imx274.c
@@ -58,6 +58,10 @@
 #define IMX274_1080P_MODE_MIN_VMAX             4620
 #define IMX274_1080P_MODE_OFFSET               112
 
+static int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "debug level (0-3)");
+
 struct imx274 {
        struct camera_common_power_rail power;
        int                             num_ctrls;
@@ -414,6 +418,7 @@ static int imx274_s_stream(struct v4l2_subdev *sd, int enable)
        int err;
 
        dev_dbg(&client->dev, "%s++\n", __func__);
+       v4l2_dbg(1, debug, sd, "[v4l2_dbg] %s++\n", __func__);
 
        imx274_write_table(priv, mode_table[IMX274_MODE_STOP_STREAM]);
 
@@ -463,6 +468,7 @@ static int imx274_s_stream(struct v4l2_subdev *sd, int enable)
        if (err)
                goto exit;
 
+       v4l2_dbg(1, debug, sd, "[v4l2_dbg] %s--\n", __func__);

enable the debug flag

# echo 1 > /sys/module/imx274/parameters/debug

execute the commands to launch the camera sensor, and saw below debug message,

[  114.925778] imx274 30-001a: [v4l2_dbg] imx274_s_stream++
[  114.967190] imx274 30-001a: [v4l2_dbg] imx274_s_stream--

Hello Jerry,

Thank you so much for your support.

v4l2_dbg is working well.

And, I have one more question.

How to output all log message.

That is, “v4l2_err” and “v4l2_warn” and “v4l2_info” etc…

Especially, I wonder “v4l2_info” message.

Could you please let me know for that?

Thanks & Best Regards,

Hi Jerry,

Could you let me know your idea for the my question of #16 post?

Thanks & BR,

Hello Jerry,

I’ve check log of the “v4l2_info”.

Please close this issue.

Thank you so much.

Thanks & BR,

Hi nwlee,

How did you get “v4l2_info” in dmesg for tc358840?
Which debug level did you include?

Look forward for your answer.

Best regards,
Ilija