Camera sensor os02g10 MIPI CSI for IMX8MM

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Camera sensor os02g10 MIPI CSI for IMX8MM

ソリューションへジャンプ
2,371件の閲覧回数
btarnowski
Contributor III

Hi all.

I got the driver for os02g10 from:

https://github.com/Shaggy013/kernel-5.10

I added driver as a patch.

 

My DeviceTree looks that:

 

            csi1_bridge: csi1_bridge@32e20000 {
                compatible = "fsl,imx8mm-csi", "fsl,imx8mq-csi", "fsl,imx6s-csi";
                reg = <0x32e20000 0x1000>;
                interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&clk IMX8MM_CLK_DISP_AXI_ROOT>,
                         <&clk IMX8MM_CLK_CSI1_ROOT>,
                         <&clk IMX8MM_CLK_DISP_APB_ROOT>;
                clock-names = "disp-axi", "csi_mclk", "disp_dcic";
                power-domains = <&dispmix_pd>;
                status = "disabled";
            };

            mipi_csi_1: mipi_csi@32e30000 {
                compatible = "fsl,imx8mm-mipi-csi";
                reg = <0x32e30000 0x1000>;
                interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
                clock-frequency = <360000000>;
                clocks = <&clk IMX8MM_CLK_CSI1_CORE>,
                         <&clk IMX8MM_CLK_CSI1_PHY_REF>,
                         <&clk IMX8MM_CLK_DISP_AXI_ROOT>,
                         <&clk IMX8MM_CLK_DISP_APB_ROOT>;
                clock-names = "mipi_clk", "phy_clk", "disp_axi", "disp_apb";
                bus-width = <2>;
                resets = <&mipi_csi_resets>;
                power-domains = <&mipi_pd>;
                status = "disabled";
            };

    os02g10: os02g10@3c {
		compatible = "ovti,os02g10";
		reg = <0x3c>; // spec (manual) says that I2c addres is 0x3d 
        status = "okay";
		pinctrl-names = "rockchip,camera_default", "rockchip,camera_sleep";		
		pinctrl-0 = <&pinctrl_csi_pwdn>, <&pinctrl_csi_rst>, <&pinctrl_mux_oe>;
		pinctrl-1 = <&pinctrl_csi_pwdn>, <&pinctrl_csi_rst>, <&pinctrl_mux_oe>;
		csi_id = <0>;
        pwdn-gpios = <&gpio2 16 GPIO_ACTIVE_HIGH>;
        reset-gpios = <&gpio2 13 GPIO_ACTIVE_HIGH>;
        mux-gpios = <&gpio2 14 GPIO_ACTIVE_HIGH>;
		mclk = <24000000>;
		mclk_source = <0>;
		rockchip,camera-module-index = <1>;
		rockchip,camera-module-facing = "back";
		rockchip,camera-module-name = "OS02G10 camera";
		rockchip,camera-module-lens-name = "1//2.9 inch 15*";
		rockchip,camera-hdr-mode = <0>; // kernel-5.10\include\uapi\linux\rk-camera-module.h:307  (enum rkmodule_hdr_mode)
		mipi_csi;

		port {
			os02g10_ep: endpoint {
				remote-endpoint = <&mipi1_sensor_ep>;
			};
		};
    };
};

&csi1_bridge {
    fsl,mipi-mode;
	status = "okay";
	port {
		csi1_ep: endpoint {
			remote-endpoint = <&csi1_mipi_ep>;
		};
	};
};

&mipi_csi_1 {
	status = "okay";
	port {
        #address-cells = <1>;
        #size-cells = <0>;
            
		    mipi1_sensor_ep: endpoint@1 {
            reg = <1>;
			remote-endpoint = <&os02g10_ep>;
			data-lanes = <2>;
			csis-hs-settle = <13>;
			csis-clk-settle = <2>;
			csis-wclk;
            };
           
            csi1_mipi_ep: endpoint@2 {
            reg = <2>;
			remote-endpoint = <&csi1_ep>;
        };
	};
};

&clk {
    init-on-array = <IMX8MM_CLK_UART4_ROOT
                     IMX8MM_CLK_AHB IMX8MM_CLK_DRAM_CORE
                     IMX8MM_CLK_NOC IMX8MM_CLK_NOC_APB
                     IMX8MM_CLK_USB_BUS
                     IMX8MM_CLK_MAIN_AXI IMX8MM_CLK_AUDIO_AHB
                     IMX8MM_CLK_DRAM_APB IMX8MM_CLK_A53_DIV
                     IMX8MM_ARM_PLL_OUT IMX8MM_CLK_DISP_AXI
                     IMX8MM_CLK_DISP_APB
                    >;
};

 

 

I modified probe function for camera driver and for mxc_mipi-csi.c, mx6s-csi.c

Before I had 2 times format match error but I added to the mx6s-csi

 

{
.name		= "RAWRGB10 (SBGGR10)",
.fourcc	= V4L2_PIX_FMT_SBGGR10,
.pixelformat	= V4L2_PIX_FMT_SBGGR10,
.mbus_code	= MEDIA_BUS_FMT_SBGGR10_1X10,
.bpp		= 1,
}

 

and added to mxc_mipi-csi.c

 

{
.code = MEDIA_BUS_FMT_SBGGR10_1X10,
.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW10,
.data_alignment = 8,
 }

 

 

and v4l2 API works, there is no error. Below my command to get picture

 

v4l2-ctl -d /dev/video0 --verbose --set-fmt-video=width=1920,height=1080,pixelformat=BG10  --stream-mmap --stream-count=1 --stream-to=bb001.raw

 

and the result with my debug messages

 

mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_s_power
os02g10 3-003c: in function: os02g10_s_power
os02g10 3-003c: in function: os02g10_runtime_resume
os02g10 3-003c: in function: __os02g10_power_on

os02g10 3-003c: OS02G10_REG_SOFTWARE_RESET
mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_clk_enable
mxc_mipi-csi 32e30000.mipi_csi: enable mipi_clk returns: 0
mxc_mipi-csi 32e30000.mipi_csi: enable phy_clk returns: 0
mxc_mipi-csi 32e30000.mipi_csi: enable disp_axi returns: 0
mxc_mipi-csi 32e30000.mipi_csi: enable disp_apb returns: 0

VIDIOC_QUERYCAP: ok
VIDIOC_G_FMT: ok

mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_enum_mbus_code
os02g10 3-003c: in function: os02g10_enum_mbus_code
mxc_mipi-csi 32e30000.mipi_csi: camera sensor format (media-bus-format.h): 0x3007
mxc_mipi-csi 32e30000.mipi_csi: supported format0 by mipi-csi driver:    0x2008
mxc_mipi-csi 32e30000.mipi_csi: supported format1 by mipi-csi driver:    0x2007
mxc_mipi-csi 32e30000.mipi_csi: supported format2 by mipi-csi driver:    0x3001
mxc_mipi-csi 32e30000.mipi_csi: supported format3 by mipi-csi driver:    0x3007
mx6s-csi 32e20000.csi1_bridge: in function: mx6s_vidioc_enum_fmt_vid_cap - format RAWRGB10 (SBGGR10)
mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_set_fmt

VIDIOC_S_FMT: ok
Format Video Capture:
        Width/Height      : 1920/1080

mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_enum_mbus_code
os02g10 3-003c: in function: os02g10_enum_mbus_code
mxc_mipi-csi 32e30000.mipi_csi: camera sensor format (media-bus-format.h): 0x3007
mxc_mipi-csi 32e30000.mipi_csi: supported format0 by mipi-csi driver:    0x2008
mxc_mipi-csi 32e30000.mipi_csi: supported format1 by mipi-csi driver:    0x2007
mxc_mipi-csi 32e30000.mipi_csi: supported format2 by mipi-csi driver:    0x3001
mxc_mipi-csi 32e30000.mipi_csi: supported format3 by mipi-csi driver:    0x3007
mx6s-csi 32e20000.csi1_bridge: in function: mx6s_vidioc_enum_fmt_vid_cap - format RAWRGB10 (SBGGR10)


        Pixel Format      : 'BG10' (10-bit Bayer BGBG/GRGR)
        Field             : None
        Bytes per Line    : 1920
        Size Image        : 2073600
        Colorspace        : sRGB
        Transfer Function : Default (maps to sRGB)
        YCbCr/HSV Encoding: ITU-R 601
        Quantization      : Full Range
        Flags:

mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_s_stream
mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_clear_counters
mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_start_stream
mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_sw_reset: REG CMN_CTRL 0x32E30004 = 0x00004000
mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_set_params
mxc_mipi-csi 32e30000.mipi_csi: in function: __mipi_csis_set_format
mxc_mipi-csi.0: fmt: 0x3007, 1920 x 1080
mxc_mipi-csi 32e30000.mipi_csi: in function: __mipi_csis_set_format: REG ISPRESOL_CH0 0x32E30044 = 0x04380780
mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_set_hsync_settle: REG DPHYCTRL 0x32E30024=0x0d800000
mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_set_params: REG CMN_CTRL 0x32E30004 = 0x00004104
mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_system_enable: REG CMN_CTRL 0x32E30004=0x00004105

VIDIOC_REQBUFS returned 0 (Success)
VIDIOC_QUERYBUF returned 0 (Success)
VIDIOC_QUERYBUF returned 0 (Success)
VIDIOC_QUERYBUF returned 0 (Success)
VIDIOC_QUERYBUF returned 0 (Success)
VIDIOC_QBUF returned 0 (Success)
VIDIOC_QBUF returned 0 (Success)
VIDIOC_QBUF returned 0 (Success)
VIDIOC_QBUF returned 0 (Success)

mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_system_enable: REG DPHYCTRL 0x32E30024=0x0d800007
mxc_mipi-csi 32e30000.mipi_csi: in function: mipi_csis_enable_interrupts: REG CSIS_INTMSK 0x32E30010 = 0xf00fffff
mxc_mipi-csi.0: --- mipi_csis_start_stream ---
mxc_mipi-csi.0: 0x04 CMM CTRL : 0x00004105
mxc_mipi-csi.0: 0x08 CLK CTRL : 0x000f0000
mxc_mipi-csi.0: 0x10 INT MASK0: 0xf00fffff
mxc_mipi-csi.0: 0x14 INT SRC0 : 0x00000000
mxc_mipi-csi.0: 0x18 INT MASK1: 0x00000000
mxc_mipi-csi.0: 0x1c INT SRC1 : 0x00000000
mxc_mipi-csi.0: 0x20 PHY STAT : 0x000000f1
mxc_mipi-csi.0: 0x24 PHY CTRL : 0x0d800007
mxc_mipi-csi.0: 0x30 PHY M/S-L: 0x000001f4
mxc_mipi-csi.0: 0x34 PHY M/S-H: 0x00000000
mxc_mipi-csi.0: 0x38 PHY S-CTL: 0x00000000
mxc_mipi-csi.0: 0x3C PHY S-CTH: 0x00000000
mxc_mipi-csi.0: 0x40 ISP CONF : 0x000000ac
mxc_mipi-csi.0: 0x44 ISP RESOL: 0x04380780
mxc_mipi-csi.0: 0x48 ISP SYNC : 0x04380780
os02g10 3-003c: in function: os02g10_s_stream
os02g10 3-003c: in function: __os02g10_start_stream
os02g10 3-003c: in function: __os02g10_start_stream  __v4l2_ctrl_handler_setup returns: 0
os02g10 3-003c: in function: os02g10_s_stream: unlock_and_return

               VIDIOC_STREAMON returned 0 (Success)

 

 

After that nothing is going to happen, just waiting and waiting and nothing.

I can not observe any traffic on MIPI DATA and MIPI CLK lines by 20MHz oscilloscope. (I know the bandwidth is low but for data lines there should be anything seen - any change but there is completely silence) 

Im not sure if clk node is correct and maybe there is no match &clk node with mipi_csi clocks by clock names. Has anyone experience with it?

What can I do ?

 

ラベル(1)
0 件の賞賛
返信
1 解決策
2,354件の閲覧回数
btarnowski
Contributor III

I got it to work.
.bpp has to be = 2
but main issue was with hardware

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
2,355件の閲覧回数
btarnowski
Contributor III

I got it to work.
.bpp has to be = 2
but main issue was with hardware

0 件の賞賛
返信