imx6q 包含两路ipu ,支持四路csi同时输入,支持四路mipi/csi-2,两路parallel;
ipu0-csi0,ipu1-csi1,是mipi/parallel 复用通道;
可以通过设置图2的寄存器进行切换
设备树中对video channel 配置
v4l2_cap_0 {
compatible = “fsl,imx6q-v4l2-capture”;
ipu_id = <0>;
csi_id = <0>;
mclk_source = <0>;
status = “okay”;
};
v4l2_cap_1 {
compatible = "fsl,imx6q-v4l2-capture";
ipu_id = <0>;
csi_id = <1>;
mclk_source = <0>;
status = "okay";
};
v4l2_cap_2 {
compatible = "fsl,imx6q-v4l2-capture";
ipu_id = <1>;
csi_id = <0>;
mclk_source = <0>;
status = "okay";
};
v4l2_cap_3 {
compatible = "fsl,imx6q-v4l2-capture";
ipu_id = <1>;
csi_id = <1>;
mclk_source = <0>;
status = "okay";
};
当应用层操作video设备进行图像采集时需要设置
ioctl(fd_capture_v4l, VIDIOC_S_INPUT, &g_input);
static struct v4l2_input mxc_capture_inputs[MXC_V4L2_CAPTURE_NUM_INPUTS] = {
{
.index = 0,
.name = "CSI IC MEM",
.type = V4L2_INPUT_TYPE_CAMERA,
.audioset = 0,
.tuner = 0,
.std = V4L2_STD_UNKNOWN,
.status = 0,
},
{
.index = 1,
.name = "CSI MEM",
.type = V4L2_INPUT_TYPE_CAMERA,
.audioset = 0,
.tuner = 0,
.std = V4L2_STD_UNKNOWN,
.status = V4L2_IN_ST_NO_POWER,
},
};
当index设置0 表示图像采集经过ipu IC,index为1 表示camera图像不经过IC
此处的input设置还关系到取景框的设置:
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
struct v4l2_format fmt;
在mxc_v4l2_capture.c 文件中
static int mxc_v4l2_s_fmt(cam_data *cam, struct v4l2_format *f)
{
int retval = 0;
int size = 0;
int bytesperline = 0;
int *width, *height;
pr_debug("In MVC: mxc_v4l2_s_fmt\n");
switch (f->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
pr_debug(" type=V4L2_BUF_TYPE_VIDEO_CAPTURE\n");
if (!valid_mode(f->fmt.pix.pixelformat)) {
pr_err("ERROR: v4l2 capture: mxc_v4l2_s_fmt: format "
"not supported\n");
return -EINVAL;
}
/*
* Force the capture window resolution to be crop bounds
* for CSI MEM input mode.
*/
if (strcmp(mxc_capture_inputs[cam->current_input].name,
"CSI MEM") == 0) {
f->fmt.pix.width = cam->crop_current.width;
f->fmt.pix.height = cam->crop_current.height;
}
return retval;
}
如果设置 input 为 CSI MEM 模式 struct v4l2_format fmt 的 width 和height将无效;
如果input 设置为 CSI IC MEM 模式 struct v4l2_crop crop设置的width和height将无效
注意:
当使用ipu进行图像的采集和显示时,如果设置input为 CSI IC MEM 模式程序将出错,因为采集和显示同时使用到ipu IC硬件将会冲突;input 设置为 CSI MEM 采集和显示正常,,此时只有显示用到ipu IC 硬件;(此问题困扰了我好久) ;