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.