IMX8M mini mipi ov5640 is OK!

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

IMX8M mini mipi ov5640 is OK!

jianfeichang
Contributor IV
1 0 2,374

开发板是imx8M mini,我们自己做的板子,使用官方镜像yocto 4.14.98,OV5640 mipi摄像头,验证及其测试:

root@imx8mmevk:~# uname -a
Linux imx8mmevk 4.14.98-imx_4.14.98_2.0.0_ga+g5d6cbea #1 SMP PREEMPT Thu Dec 12 08:23:58 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux

 

我这里用的是I2C4的接口,所以设备树修改arch/arm64/boot/dts/freescale/fsl-imx8mm-evk.dts

&i2c4 {
    clock-frequency = <100000>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c4>;
    status = "okay";

    ov5640_mipi: ov5640_mipi@3c {
        compatible = "ovti,ov5640_mipi";
        reg = <0x3c>;
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_csi_pwn>, <&pinctrl_csi_rst>;
        clocks = <&clk IMX8MM_CLK_CLKO1_DIV>;
        clock-names = "csi_mclk";
        assigned-clocks = <&clk IMX8MM_CLK_CLKO1_SRC>,
                    <&clk IMX8MM_CLK_CLKO1_DIV>;
        assigned-clock-parents = <&clk IMX8MM_CLK_24M>;
                    assigned-clock-rates = <0>, <24000000>;
        csi_id = <0>;
        pwn-gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;
    //  rst-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
        mclk = <24000000>;
        mclk_source = <0>;
        port {
            ov5640_mipi1_ep: endpoint {

                 remote-endpoint = <&mipi1_sensor_ep>;
            };
        };
    };
};

I2C4、PWN、res等等引脚有占用,请把他们注释掉即可,内核默认是增加这个驱动的

  │ Symbol: MXC_CAMERA_OV5640_MIPI_V2 [=y]                                  │ 
  │ Type  : tristate                                                        │ 
  │ Prompt: OmniVision ov5640 camera support using mipi                     │ 
  │   Location:                                                             │ 
  │     -> Device Drivers                                                   │ 
  │       -> Multimedia support (MEDIA_SUPPORT [=y])                        │ 
  │         -> V4L platform devices (V4L_PLATFORM_DRIVERS [=y])             │ 
  │           -> MXC Camera/V4L2 PRP Features support

驱动不用修改,路径drivers/media/platform/mxc/capture/ov5640_mipi_v2.c

 

编译烧写开机,查看设备,可以发现如下信息,DOVDD等等找不到,应该是从imx6上移植过来的,imx8上这些引脚都已经用电路接好,不需要用程序控制,当然你也可以从设备树添加这些,不过没什么意义。我就把res-gpios添加,后来又加上没什么效果。上边设备树可以看到,我注释掉了。

root@imx8mmevk:~# dmesg |grep 5640
[    1.915242] ov5640_mipi 3-003c: No sensor reset pin available
[    1.921033] ov5640_mipi 3-003c: 3-003c supply DOVDD not found, using dummy regulator
[    1.928836] ov5640_mipi 3-003c: 3-003c supply DVDD not found, using dummy regulator
[    1.936552] ov5640_mipi 3-003c: 3-003c supply AVDD not found, using dummy regulator
[    3.103770] mxc_mipi-csi 32e30000.mipi_csi: Registered sensor subdevice: ov5640_mipi 3-003c
[    3.112716] ov5640_mipi 3-003c: Camera is found
root@imx8mmevk:~#

 

查看摄像头功能和信息,是vide0,YUYV格式

root@imx8mmevk:~# v4l2-ctl -D -d /dev/video0 --list-formats-ext
Driver Info (not using libv4l2):[  200.736512] ov5640_mipi 3-003c: Please assign pixel format, width and height

 Driver name   : mx6s-csi
 Card type     : i.MX6S_CSI
 Bus info      : platform:32e20000.csi1_bridge
 Driver version: 4.14.98
 Capabilities  : 0x84200001
  Video Capture
  Streaming
  Extended Pix Format
  Device Capabilities
 Device Caps   : 0x04200001
  Video Capture
  Streaming
  Extended Pix Format
ioctl: VIDIOC_ENUM_FMT
 Index       : 0
 Type        : Video Capture
 Pixel Format: 'YUYV'
 Name        : YUYV 4:2:2
  Size: Discrete 640x480
   Interval: Discrete 0.033s (30.000 fps)
  Size: Discrete 320x240
   Interval: Discrete 0.033s (30.000 fps)
  Size: Discrete 720x480
   Interval: Discrete 0.033s (30.000 fps)
  Size: Discrete 1280x720
   Interval: Discrete 0.033s (30.000 fps)
  Size: Discrete 1920x1080
   Interval: Discrete 0.033s (30.000 fps)
  Size: Discrete 2592x1944
   Interval: Discrete 0.067s (15.000 fps)
  Size: Discrete 0x0

root@imx8mmevk:~#

 

使用官方的指令测试,是可以显示到界面的,此时界面上有图像,没有什么问题哦。

root@imx8mmevk:~# gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-1920,height=1080 ! waylandsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[  291.739794] ov5640_mipi 3-003c: s_stream: 1

 

然后我用自己写的V4L2程序采集,这里默认是采集的是YUYV图像,640*480,保存成 test-mmap.yuv格式,当然也可以让他自动转换成RGB显示在屏幕上,不过我还没有做。

root@imx8mmevk:~# ./wx

capabilities: 84200001
driver: mx6s-csi
card: i.MX6S_CSI
bus_info: platform:32e20000.csi1_bridge
version: 4.14.98

we are here11
{ pixelformat = 'YUYV', description = 'YUYV 4:2:2' }
we are here22
************** main, line = 139
we are here33
we are here44
we are here55
cjf__1
[  463.023861] ov5640_mipi 3-003c: s_stream: 1
buf.index dq is 0,
[  463.204929] ov5640_mipi 3-003c: s_stream: 0

root@imx8mmevk:~# ls -l
-rwxrwxrwx 1 root root  614400 Feb 20 20:31 test-mmap.yuv
-rwxrwxrwx 1 root root   23416 Feb 20 20:28 wx
root@imx8mmevk:~#

 

然后把文件拷贝出来,使用yuv工具打开查看,图像显示正常!希望对你们有帮助,谢谢!

QQ图片20191213173905.png

Tags (1)