I am developing with DART-MX8M-PLUS.
BSP : Yocto mx8mp-yocto-kirkstone-5.15-2.0.x-v1.2
I'm trying to interface with ov5640 driver (s_ctrl).
# Application Side
----------------------------------------------------------------------------------------------------------
int v4l2_Ctrl(int num, unsigned int id, int value)
{
struct v4l2_control control;
char dev_name[12];
int fd;
strcpy(dev_name, num==0 ? "/dev/video0" : "/dev/video1");
fd = open((const char *)dev_name, O_RDWR);
if(fd <= 0) {
printf("Cannot open %s device\n", dev_name);
return -1;
}
memset(&control, 0, sizeof (control));
control.id = id;
control.value = value;
if (ioctl(fd, VIDIOC_S_CTRL, &control) < 0) ==> Error occurs at ioctl.
perror("VIDIOC_S_CTRL");
return 0;
}
----------------------------------------------------------------------------------------------------------
And Below is a list that is not in s_ctrl of "driver/media/i2c/ov5640.c"
How do I connect to the ov5460 driver in my application?
----------------------------------------------------------------------------------------------------------
root@imx8mp-var-dart:~# v4l2-ctl -d /dev/video1 -l
User Controls
horizontal_flip 0x00980914 (bool) : default=0 value=0
vertical_flip 0x00980915 (bool) : default=0 value=0
alpha_component 0x00980929 (int) : min=0 max=255 step=1 default=0 value=0
----------------------------------------------------------------------------------------------------------
Thanks.
Best regards,
Jayden
Solved! Go to Solution.
Hi @Jayden_Soon
Hi Sanket,
The dts file is orignal for DART-MX8M-PLUS.
When I run the code below as you say, an error occur.
---------------------------------------------------------------------------------------------------------------
memset(&ctrl, 0, sizeof(ctrl));
ctrl.id = V4L2_CID_AUTOGAIN;
ctrl.value = 1;
ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
---------------------------------------------------------------------------------------------------------------
The interface doesn't seem to work with ov5640_s_ctrl.(drivers/media/i2c/ov5640.c)
---------------------------------------------------------------------------------------------------------------
static int ov5640_s_ctrl(struct v4l2_ctrl *ctrl)
{
struct v4l2_subdev *sd = ctrl_to_sd(ctrl);
struct ov5640_dev *sensor = to_ov5640_dev(sd);
int ret;
/* v4l2_ctrl_lock() locks our own mutex */
/*
* If the device is not powered up by the host driver do
* not apply any controls to H/W at this time. Instead
* the controls will be restored right after power-up.
*/
if (sensor->power_count == 0)
return 0;
switch (ctrl->id) {
case V4L2_CID_AUTOGAIN:
ret = ov5640_set_ctrl_gain(sensor, ctrl->val);
break;
---------------------------------------------------------------------------------------------------------------
Thanks,
Best regards,
Jayden
Hi @Jayden_Soon
Hi Sanket,
I modified it as below and it works fine.
//sensor->sd.flags |= V4L2_SUBDEV_FL_HAS_EVENTS;
sensor->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
Thank you so much for your reply.
Best regards,
Jadyen
Hi @Jayden_Soon ,
Is this solved the problem able to see all the controls in v4l2-ctl --list-ctrls -d <devnode> ??
I did same change but not solving. Can you please let me know what else need to change in driver ?
Thanks in advance...
Hi riteshkrmehta,
First, change it in your camera driver as below.
//sensor->sd.flags |= V4L2_SUBDEV_FL_HAS_EVENTS;
sensor->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
Then, it is connected to "v4l-subdev#". The registered controls will appear in the list.
# v4l2-ctl -d /dev/v4l-subdev2 --list-ctrl
Thanks.
Best regards,
Jayden
Thanks, Jayden its worked fine with me as well.
Actually, I was looking at the control for the final video node which is wrong, I need to look at subdev node which is actually the camera sensor node.
Thanks,
Ritesh Kumar
Hi @Jayden_Soon,