No V4L2 controls implemented on OV5640 mipi driver

cancel
Showing results for 
Search instead for 
Did you mean: 

No V4L2 controls implemented on OV5640 mipi driver

Jump to solution
1,785 Views
greivin_fallas
Contributor II

Hi all,

I am using the OV5640 mipi camera driver as reference to create a custom driver for a customer on the i.mx6 dartboard evaluation kit. Some V4L2 controls were requested on the driver but the OV5640 does not support any control.

Sending outputs when testing controls with OV5640 camera:

No controls listed

root@var-som-mx6:~# v4l2-ctl -d /dev/video0 -l
root@var-som-mx6:~#

Controls always marked as uknown

root@var-som-mx6:~# v4l2-ctl -d /dev/video0 --get-ctrl=gain
unknown control 'gain'
root@var-som-mx6:~# v4l2-ctl -d /dev/video0 --set-ctrl=gain=100
unknown control 'gain'
root@var-som-mx6:~#
root@var-som-mx6:~# v4l2-ctl -d /dev/video0 --get-ctrl=exposure
unknown control 'exposure'
root@var-som-mx6:~#

How can I implement controls on the driver?
Any example/help will be appreciated.

Thanks.

Labels (5)
0 Kudos
1 Solution
997 Views
greivin_fallas
Contributor II

Hi all,

I did not find a correct way to enable camera controls using V4L2 utils (V4L2-ctl) or YAVTA.

The only way that I found to use controls on the driver was using v4l2 set/get calls from imxv4l2videosrc.
I had to create extra properties on the imxv4l2videosrc plugins to accept gain/exposure as properties, after processing the received value, it was send to V4L2 core through V4L2 IOCTL.

static int v4l2_s_ctrl(GstImxV4l2VideoSrc *v4l2src, int id, int value)
{
    struct v4l2_control control;
    int ret;

    GST_LOG_OBJECT(v4l2src, "VIDIOC_S_CTRL(%s, %d)", ctrl_name(id), value);

    control.id = id;
    control.value = value;
    ret = ioctl(GST_IMX_FD_OBJECT_GET_FD(v4l2src->fd_obj_v4l), VIDIOC_S_CTRL, &control);

    if (ret < 0)
        GST_LOG_OBJECT(v4l2src, "VIDIOC_S_CTRL(%s, %d) failed", ctrl_name(id), value);
    else
        GST_LOG_OBJECT(v4l2src, "VIDIOC_S_CTRL(%s, %d) succeed", ctrl_name(id), value);

    return ret;
}

The V4L2 core processes the control ID and calls the custom callback from driver according to V4L2 control ID. 

v4l2_s_ctrl(v4l2src, V4L2_CID_EXPOSURE, v4l2src->custom_exposure);

Switch-case from V4L2 core that processes the V4L2 ID (mxc_v4l2_capture.c):

case V4L2_CID_EXPOSURE:
        pr_debug("mxc_v4l2_s_ctrl: V4L2_CID_EXPOSURE\n");
        if (cam->sensor) {
            ret = vidioc_int_s_ctrl(cam->sensor, c); //calls driver's set controls function
        } else {
            pr_err("ERROR: v4l2 capture: slave not found!\n");
            ret = -ENODEV;
        }
        break;

I hope this helps other developers to implement V4L2 controls.
Regards,
Greivin F.

View solution in original post

0 Kudos
3 Replies
997 Views
manuelleiva
Contributor I

I have the same problem reported by Greivin

I can't list the controls of the driver using  v4l2-ctl -d /dev/video0 -l therefore  v4l2-ctl can't read or write a control neither. I have seen that mxc_v4l2_capture.c does implement VIDIOC_QUERYCTRL 

Can you confirm if NXP kernel doesn't support the standard procedure to read and write a v4l2 control?

Is there some patch to add this support?

Thanks.

Regards,

-Manuel

0 Kudos
998 Views
greivin_fallas
Contributor II

Hi all,

I did not find a correct way to enable camera controls using V4L2 utils (V4L2-ctl) or YAVTA.

The only way that I found to use controls on the driver was using v4l2 set/get calls from imxv4l2videosrc.
I had to create extra properties on the imxv4l2videosrc plugins to accept gain/exposure as properties, after processing the received value, it was send to V4L2 core through V4L2 IOCTL.

static int v4l2_s_ctrl(GstImxV4l2VideoSrc *v4l2src, int id, int value)
{
    struct v4l2_control control;
    int ret;

    GST_LOG_OBJECT(v4l2src, "VIDIOC_S_CTRL(%s, %d)", ctrl_name(id), value);

    control.id = id;
    control.value = value;
    ret = ioctl(GST_IMX_FD_OBJECT_GET_FD(v4l2src->fd_obj_v4l), VIDIOC_S_CTRL, &control);

    if (ret < 0)
        GST_LOG_OBJECT(v4l2src, "VIDIOC_S_CTRL(%s, %d) failed", ctrl_name(id), value);
    else
        GST_LOG_OBJECT(v4l2src, "VIDIOC_S_CTRL(%s, %d) succeed", ctrl_name(id), value);

    return ret;
}

The V4L2 core processes the control ID and calls the custom callback from driver according to V4L2 control ID. 

v4l2_s_ctrl(v4l2src, V4L2_CID_EXPOSURE, v4l2src->custom_exposure);

Switch-case from V4L2 core that processes the V4L2 ID (mxc_v4l2_capture.c):

case V4L2_CID_EXPOSURE:
        pr_debug("mxc_v4l2_s_ctrl: V4L2_CID_EXPOSURE\n");
        if (cam->sensor) {
            ret = vidioc_int_s_ctrl(cam->sensor, c); //calls driver's set controls function
        } else {
            pr_err("ERROR: v4l2 capture: slave not found!\n");
            ret = -ENODEV;
        }
        break;

I hope this helps other developers to implement V4L2 controls.
Regards,
Greivin F.

View solution in original post

0 Kudos
997 Views
jimmychan
NXP TechSupport
NXP TechSupport

Please check the Chapter 6.1 in i.MX_Reference_Manual.pdf for the camera and V4L2 in details.

Document can be downloaded from here:

i.MX Software | NXP 

0 Kudos