How do the application interface with ov5640 driver on imx8mp?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do the application interface with ov5640 driver on imx8mp?

Jump to solution
931 Views
Jayden_Soon
Contributor I

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

 

 

0 Kudos
1 Solution
846 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @Jayden_Soon 

I hope you are doing well.
 
Please share the logs of the error message that you got.
 
Please share if the is any v4l2 subdev node present under /dev,
 
ov5640.c driver uses V4L2_SUBDEV_FL_HAS_DEVNODE flag.So s_ctrl should be available using /dev/v4l-subdevX
 
Please refer to a below-mentioned thread where a similar issue is seen.
 
Please refer to V4L2 sub-devices for more details.
 
Thanks & Regards,
Sanket Parekh

View solution in original post

0 Kudos
8 Replies
900 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport
 
I hope you are doing well.
 
Please make sure that you have used the correct control value for IOCTL.
 
Please make sure that you have used the correct device tree for the ov5640 camera
 
One can refer to the mx8_v4l2_cap_drm.c example at imx-test.
 
Thanks & Regards,
Sanket Parekh
0 Kudos
876 Views
Jayden_Soon
Contributor I

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

0 Kudos
847 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @Jayden_Soon 

I hope you are doing well.
 
Please share the logs of the error message that you got.
 
Please share if the is any v4l2 subdev node present under /dev,
 
ov5640.c driver uses V4L2_SUBDEV_FL_HAS_DEVNODE flag.So s_ctrl should be available using /dev/v4l-subdevX
 
Please refer to a below-mentioned thread where a similar issue is seen.
 
Please refer to V4L2 sub-devices for more details.
 
Thanks & Regards,
Sanket Parekh

0 Kudos
814 Views
Jayden_Soon
Contributor I

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

 

 

0 Kudos
685 Views
riteshkrmehta
Contributor III

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...

Tags (1)
0 Kudos
670 Views
Jayden_Soon
Contributor I

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

0 Kudos
658 Views
riteshkrmehta
Contributor III

@Jayden_Soon ,

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

0 Kudos
792 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @Jayden_Soon,

I hope you are doing well.
 
Glad to know that this resolves your issue,
Can i mark this case as close now?
 
Thanks & Regards,
Sanket Parekh

0 Kudos