AnsweredAssumed Answered

imx8m mini mipi csi采图异常

Question asked by songrui2008@126.com on Jun 20, 2020
Latest reply on Jul 8, 2020 by songrui2008@126.com

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的驱动文件添加,经过上面的修改编译烧写镜像后,抓图软件是能采集到图像,但是图像是错位的花屏的,错误图像在附件。

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

谢谢~~~

Attachments

Outcomes