imx8m mini mipi csi采图异常

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

imx8m mini mipi csi采图异常

23,178 Views
chinaman
Fresh Out Contributor

Dear all:

   本人现在使用imx8m mini mipi csi接口采集图像,sensor是 sony imx334,它的配置是 891Mbps,4 lanes, 3824x2176,30fps,10bits raw data。使用的bsp是4.14.98,由于内核不支持10bits raw data,我们做了如下修改:

mx6s_capture.c作如下添加修改

static struct mx6s_fmt formats[] = {
{
.name = "UYVY-16",
.fourcc = V4L2_PIX_FMT_UYVY,
.pixelformat = V4L2_PIX_FMT_UYVY,
.mbus_code = MEDIA_BUS_FMT_UYVY8_2X8,
.bpp = 2,
}, {
.name = "YUYV-16",
.fourcc = V4L2_PIX_FMT_YUYV,
.pixelformat = V4L2_PIX_FMT_YUYV,
.mbus_code = MEDIA_BUS_FMT_YUYV8_2X8,
.bpp = 2,
}, {
.name = "YUV32 (X-Y-U-V)",
.fourcc = V4L2_PIX_FMT_YUV32,
.pixelformat = V4L2_PIX_FMT_YUV32,
.mbus_code = MEDIA_BUS_FMT_AYUV8_1X32,
.bpp = 4,
}, {
.name = "RAWRGB8 (SBGGR8)",
.fourcc = V4L2_PIX_FMT_SBGGR8,
.pixelformat = V4L2_PIX_FMT_SBGGR8,
.mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8,
.bpp = 1,
}, {
.name = "RAWRGB10 (SBGGR10)",
.fourcc = V4L2_PIX_FMT_SBGGR10,
.pixelformat = V4L2_PIX_FMT_SBGGR10,
.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,
.bpp = 2,
}
};

static int mx6s_configure_csi(struct mx6s_csi_dev *csi_dev)
{
struct v4l2_pix_format *pix = &csi_dev->pix;
u32 cr1, cr18;
u32 width;

if (pix->field == V4L2_FIELD_INTERLACED) {
csi_deinterlace_enable(csi_dev, true);
csi_buf_stride_set(csi_dev, csi_dev->pix.width);
csi_deinterlace_mode(csi_dev, csi_dev->std);
} else {
csi_deinterlace_enable(csi_dev, false);
csi_buf_stride_set(csi_dev, 0);
}

switch (csi_dev->fmt->pixelformat) {
case V4L2_PIX_FMT_YUV32:
case V4L2_PIX_FMT_SBGGR8:
width = pix->width;
break;
case V4L2_PIX_FMT_SBGGR10:
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YUYV:
if (csi_dev->csi_mipi_mode == true)
width = pix->width;
else
/* For parallel 8-bit sensor input */
width = pix->width * 2;
break;
default:
pr_debug(" case not supported\n");
return -EINVAL;
}
csi_set_imagpara(csi_dev, width, pix->height);

if (csi_dev->csi_mipi_mode == true) {
cr1 = csi_read(csi_dev, CSI_CSICR1);
cr1 &= ~BIT_GCLK_MODE;
csi_write(csi_dev, cr1, CSI_CSICR1);

cr18 = csi_read(csi_dev, CSI_CSICR18);
cr18 &= ~BIT_MIPI_DATA_FORMAT_MASK;
cr18 |= BIT_DATA_FROM_MIPI;

switch (csi_dev->fmt->pixelformat) {
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YUYV:
cr18 |= BIT_MIPI_DATA_FORMAT_YUV422_8B;
break;
case V4L2_PIX_FMT_SBGGR8:
cr18 |= BIT_MIPI_DATA_FORMAT_RAW8;
break;
case V4L2_PIX_FMT_SBGGR10:
cr18 |= BIT_MIPI_DATA_FORMAT_RAW10;
break;
default:
pr_debug(" fmt not supported\n");
return -EINVAL;
}

csi_write(csi_dev, cr18, CSI_CSICR18);
}
return 0;
}

mxc_mipi_csi.c做如下修改:

static const struct csis_pix_format mipi_csis_formats[] = {
{
.code = MEDIA_BUS_FMT_YUYV8_2X8,
.fmt_reg = MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT,
.data_alignment = 16,
}, {
.code = MEDIA_BUS_FMT_VYUY8_2X8,
.fmt_reg = MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT,
.data_alignment = 16,
}, {
.code = MEDIA_BUS_FMT_SBGGR8_1X8,
.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW8,
.data_alignment = 8,
}, {
.code = MEDIA_BUS_FMT_SBGGR10_1X10,
.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW10,
.data_alignment = 16,
}
};

fsl-imx8mm-evk.dts作如下修改

&mipi_csi_1 {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
port {
mipi1_sensor_ep: endpoint1 {
remote-endpoint = <&ov5640_mipi1_ep>;
data-lanes = <4>;
csis-hs-settle = <16>;
csis-clk-settle = <0>;
csis-wclk;
};

csi1_mipi_ep: endpoint2 {
remote-endpoint = <&csi1_ep>;
};
};
};

还有一些imx334的驱动文件添加,经过上面的修改编译烧写镜像后,抓图软件是能采集到图像,但是图像是错位的花屏的,错误图像在附件。

请大家帮我看看哪里出错了啊。

谢谢~~~

手动阀
Labels (1)
0 Kudos
Reply
26 Replies

16,208 Views
chinaman
Fresh Out Contributor

pastedImage_1.png

像这个样子的

手动阀
0 Kudos
Reply

11,508 Views
weidong_sun
NXP TechSupport
NXP TechSupport

再试试  .bpp  = 2的效果,这个是调整color的。

现在情况比之前好很多了。

Weidong

0 Kudos
Reply

2,026 Views
henry812000
Contributor I

请教下, imx8 mini平台目前取图时间较长,达到了50ms,请问是什么方面配置不正确吗?   mipi cmos输出帧率有60fps

0 Kudos
Reply

3,525 Views
chinaman
Fresh Out Contributor

Dear Wigros:

 将bpp改为2后图像是这样子的,就是清晰了些,但是还是在分屏。

pastedImage_1.png

手动阀
0 Kudos
Reply

3,525 Views
weidong_sun
NXP TechSupport
NXP TechSupport

OK, CPU端代码保持不变。

现在换成OV5640 RAW10来测试一下它的效果,看看是否有类似问题,做个参考。

因为我们的MIPI CSI-2+camera,往往要求camera先上电,然后是MIPI CSI-2,这个在OV5640 driver里有体现。所以试试OV5640,看看是不是这个原因产生的问题。

Weidong

0 Kudos
Reply

3,504 Views
chinaman
Fresh Out Contributor

Dear Wigros:

           ov5640是OK的,没问题的,10bits raw data能正常采图,我们的imx334驱动也是参照ov5640的写出来的,

           经过反复测试上电顺序与ov5640是一致的;

手动阀
0 Kudos
Reply