Use of caps for controlling ov5640 V4L2 driver



I’m trying to control the behaviour of ov5640 driver based on V4L2 caps.
Available caps in the driver we are using are the following:
ov5640->saturation = v4l2_ctrl_new_std(&ov5640->ctrls, &ov5640_ctrl_ops, V4L2_CID_SATURATION, -4, 4, 1, 0); ov5640->hflip = v4l2_ctrl_new_std(&ov5640->ctrls, &ov5640_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0); ov5640->vflip = v4l2_ctrl_new_std(&ov5640->ctrls, &ov5640_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); ov5640->autogain = v4l2_ctrl_new_std(&ov5640->ctrls, &ov5640_ctrl_ops, V4L2_CID_AUTOGAIN, 0, 1, 1, 1); ov5640->autoexposure = v4l2_ctrl_new_std_menu(&ov5640->ctrls, &ov5640_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL, 0, V4L2_EXPOSURE_AUTO); ov5640->awb = v4l2_ctrl_new_std(&ov5640->ctrls, &ov5640_ctrl_ops, V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1); ov5640->pattern = v4l2_ctrl_new_std_menu_items(&ov5640->ctrls, &ov5640_ctrl_ops, V4L2_CID_TEST_PATTERN, ARRAY_SIZE(ov5640_test_pattern_menu) - 1, 0, 0, ov5640_test_pattern_menu);

I tried for example to enable the test pattern (implies changing a single I2C register in the camera config).
I tried with following command line (I also tried many variations), using extra-controls as for v4l2h264enc:
gst-launch-1.0 v4l2src extra-controls="controls,test_pattern=2;" device=/dev/video0 num-buffers=1 ! 'video/xraw,format=UYVY,width=2592,height=1944,framerate=10/1' ! jpegenc ! filesink location=image01_5MP.jpg

Result is an image without the test pattern. So I’m obviously not controlling anything…

Any idea on how to make use of the V4L2_CID_* options?
At the end of the day I would like to be able to change things like AEC, AGC, …

Thanks in advance for your support!



v4l2src works on the video device node (e.g. /dev/video0). The controls that the sensor driver exports are available on the subdev node of the camera sensor, e.g. /dev/v4l-subdev?

You can control them with e.g. yavta [1].
To list all controls on a subdev:
yavta --no-query -l /dev/v4l-subdev?

Then to set a control:
yavta --no-query -w '0x009f0903 1' /dev/v4l-subdev?



Hello Todor,

Thanks for your quick answer.
All right! Yavta is working well indeed.
Using the last subdev node I can indeed list controls and make good use of them.
I can see results while capturing frames afterwards.
I’ll try adding new controls to the driver. This way I will have configuration flexibility I was also looking for.

Do you now if there is a way to get “status”? Like knowing current value of a register of the sensor using a similar mechanism?



You can get or enumerate V4L2 controls.
What comes to sensor register values, you need to initiate a i2c read operation to read the current value. I’m not aware of a mechanism to do that beyond using the sensor driver itself.