AnsweredAssumed Answered

How to enable two identical sensors mt9p031 as /dev/video0 and /dev/video1

Question asked by Evgeny Molchanov on Oct 6, 2015
Latest reply on Dec 4, 2015 by Evgeny Molchanov

Hello all.

Sorry for my english.

I'm using kernel 3.10.53 from Yocto.

I need to use two identical parallel data sensors from Aptina mt9p031 connected to iMX6Q CSI0 and CSI1.

 

I have already working both sensors at the same time by writing my own kernel module and capture data from sensors via pread function from user space.

But I want to use sensors with gstreamer, so i need to create /dev/video0 and /dev/video1

I have read this and this but both posts discuss connection one or two different sensors and each module support only one sensor.

Here is part of my dtsi file:

 

    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 = <1>;

        csi_id = <1>;

        mclk_source = <0>;

        status = "okay";

    };

 

    v4l2_out {

        compatible = "fsl,mxc_v4l2_output";

        status = "okay";

    };

 

...

 

&i2c3 {

    clock-frequency = <100000>;

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_i2c3_2>;

    status = "okay";

 

    camera1: camera1@48 {

        compatible = "aptina,mt9p031";

        reg = <0x48>;

        pinctrl-names = "default";

        pinctrl-0 = <&pinctrl_ipu1_4>;

        clocks = <&clks 200>;

        clock-names = "csi_mclk";

//        vaa = <&reg_2p8v>;  // 2.8v

//        vdd = <&reg_1p5v>;  // 1.5v

//        vdd_io = <&reg_1p5v>;  // 1.5v

//        pwn-gpios = <&gpio? ? ?>;

        reset-gpio = <&gpio1 4 GPIO_ACTIVE_LOW>;

        reset-delay-us = <5000>;

        initially-in-reset;

        oe-gpio = <&gpio5 20 0>;

        interrupt-parent = <&gpio5>;

        interrupts = <26 0>;

        csi_id = <0>;

        mclk = <24000000>;

        mclk_source = <0>;

        port {

            camera1_1: endpoint {

                input-clock-frequency = <24000000>;

                pixel-clock-frequency = <96000000>;

            };

        };

    };

 

    camera2: camera2@5D {

        compatible = "aptina,mt9p031";

        reg = <0x5D>;

        pinctrl-names = "default";

        pinctrl-0 = <&pinctrl_ipu2_1>;

        clocks = <&clks 200>;

        clock-names = "csi_mclk";

//        vaa = <&reg_2p8v>;  // 2.8v

//        vdd = <&reg_1p5v>;  // 1.5v

//        vdd_io = <&reg_1p5v>;  // 1.5v

//        pwn-gpios = <&gpio? ? ?>;

        reset-gpio = <&gpio2 27 GPIO_ACTIVE_LOW>;

        reset-delay-us = <5000>;

        initially-in-reset;

        oe-gpio = <&gpio3 10 0>;

        interrupt-parent = <&gpio3>;

        interrupts = <1 0>;

        csi_id = <1>;

        mclk = <24000000>;

        mclk_source = <0>;

        port {

            camera2_1: endpoint {

                input-clock-frequency = <24000000>;

                pixel-clock-frequency = <96000000>;

            };

        };

    };

 

};

sensors connected to i2c3 and they have different i2c addresses.

 

I have started write module in /drivers/media/platform/mxc/capture/mt9p031.c based on ov5642.c

I've implement only probe function and both sensors probed successfully.

/dev/video0 and /dev/video1 also created.

After this i try from user space get capabilites:

if (ioctl(file_device, VIDIOC_QUERYCAP, &device_params) == -1)

{

  printf ("\"VIDIOC_QUERYCAP\" error %d, %s\n", errno, strerror(errno));

  exit(EXIT_FAILURE);

}

 

printf("driver : %s\n",device_params.driver);

printf("card : %s\n",device_params.card);

printf("bus_info : %s\n",device_params.bus_info);

printf("version : %d.%d.%d\n",

     ((device_params.version >> 16) & 0xFF),

     ((device_params.version >> 8) & 0xFF),

     (device_params.version & 0xFF));

printf("capabilities: 0x%08x\n", device_params.capabilities);

printf("device capabilities: 0x%08x\n", device_params.device_caps);

 

and as result I get this:

root@imx6qsabresd:~# ./mt                                                 
############## mt9p031 driver in mt9p031_probe:                           
############## mt9p031 driver in mt9p031_reset:                           
camera mt9p031 at addr 0x48 is found                                      
############## mt9p031 driver in mt9p031_probe:                           
############## mt9p031 driver in mt9p031_reset:                           
camera mt9p031 at addr 0x5d is found
root@imx6qsabresd:~# ./catvd /dev/video1                                  
ERROR: v4l2 capture: slave not found!                                     
/dev/video1 error 11, Resource temporarily unavailable                    
root@imx6qsabresd:~# ./catvd /dev/video0                                  
driver : mxc_v4l2                                                         
card :                                                                    
bus_info :                                                                
version : 0.1.11                                                          
capabilities: 0x05000005                                                  
device capabilities: 0x00000000                                           

/dev/video0 return caps but /dev/video1 not

I know that the simple way is write two modules with dedicated parameters, but i hope it is possible to use one.

Outcomes