imx6 TVP5150 Camera

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

imx6 TVP5150 Camera

3,949 Views
akbar123
Contributor III

Hi,

I want to use TVP5150 decoder with imx6q.

Here are what I have done till now:

Physical Connection:

TVP5150 is connected to parallel port of CSI0 of IPU0, i.e. IPU1_CSI0_DATA12 to IPU1_CSI0_DATA19 Pins.

Device Tree:

TVP5150 node is defined under i2c1 as follow:

 

tvp5150@5c {
	compatible = "ti,tvp5150";
	reg = <0x5c>;
	pdn-gpios = <&gpio7 13 GPIO_ACTIVE_LOW>;
	reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;

	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ipu1_csi0>;
	clocks = <&clks 201>;
	clock-names = "csi_mclk";
	csi_id = <0>;
	mclk = <24000000>;
	mclk_source = <0>;

	port {
	        tvp5150_to_ipu1_csi0_mux: endpoint {
		     remote-endpoint = <&ipu1_csi0_mux_from_parallel_sensor>;
		};
	};
};

 

IPU0 node is as follow:

 

ipu1: ipu@2400000 {
	#address-cells = <1>;
	#size-cells = <0>;
	compatible = "fsl,imx6q-ipu";
	reg = <0x2400000 0x400000>;
	interrupts = <0 6 IRQ_TYPE_LEVEL_HIGH>,
			<0 5 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&clks IMX6QDL_CLK_IPU1>,
		<&clks IMX6QDL_CLK_IPU1_DI0>, <&clks IMX6QDL_CLK_IPU1_DI1>,
		<&clks IMX6QDL_CLK_IPU1_DI0_SEL>, <&clks IMX6QDL_CLK_IPU1_DI1_SEL>,
		<&clks IMX6QDL_CLK_LDB_DI0>, <&clks IMX6QDL_CLK_LDB_DI1>;
        clock-names = "bus","di0", "di1","di0_sel", "di1_sel","ldb_di0", "ldb_di1";
	resets = <&src 2>;
	bypass_reset = <0>;

	status = "okay";

	ipu1_csi0: port@0 {
		reg = <0>;
		ipu1_csi0_from_ipu1_csi0_mux: endpoint {
			bus-width = <8>;
	                data-shift = <12>; /* Lines 19:12 used */
	                hsync-active = <1>;
	                vsync-active = <1>;
                        remote-endpoint = <&ipu1_csi0_mux_to_ipu1_csi0>;
		};
	};
         /* Some Other stuffs are here */
};

 

IPU0 Mux node is as follow:

 

ipu1_csi0_mux {
         compatible = "video-mux";
         mux-controls = <&mux 0>;
         #address-cells = <1>;
         #size-cells = <0>;

         status = "okay";

         port@0 {
             reg = <0>;

             ipu1_csi0_mux_from_mipi_vc0: endpoint {
                   remote-endpoint = <&mipi_vc0_to_ipu1_csi0_mux>;
              };
         };

          port@1 {
               reg = <1>;

                ipu1_csi0_mux_from_parallel_sensor: endpoint {
                      remote-endpoint = <&tvp5150_to_ipu1_csi0_mux>;
                };
         };

         port@2 {
             reg = <2>;

              ipu1_csi0_mux_to_ipu1_csi0: endpoint {
                   remote-endpoint = <&ipu1_csi0_from_ipu1_csi0_mux>;
               };
         };
};

 

V4L2 capture node is as follow:

 

v4l2_cap_0 {
    	compatible = "fsl,imx6q-v4l2-capture";
     	ipu_id = <0>;
     	csi_id = <0>;
     	mclk_source = <0>;
     	status = "okay";
};

 

Kernel Configuration:

I have built kernel with imx_v7_defconfig and now these modules are loaded at startup:

 

# lsmod 
Module                  Size  Used by    Not tainted
mxc_v4l2_capture       53248  0 
ipu_bg_overlay_sdc     16384  1 mxc_v4l2_capture
ipu_still              16384  1 mxc_v4l2_capture
v4l2_int_device        16384  1 mxc_v4l2_capture
ipu_prp_enc            16384  1 mxc_v4l2_capture
ipu_csi_enc            16384  1 mxc_v4l2_capture
ipu_fg_overlay_sdc     16384  1 mxc_v4l2_capture
imx_vdoa               16384  0 
tvp5150                32768  0 
evbug                  16384  0 

 

Representation:

TVP5150 is probed successfully with the following message:

      tvp5150 1-005c: tvp5150 (4.0) chip found @ 0xb8 (21a4000.i2c)
      tvp5150 1-005c: tvp5150am1 detected.

The /dev/video0 is now available, but in kernel log there is an error:

      ERROR: v4l2 capture: slave not found!

Questions:

Q1- What is wrong with my settings that the /dev/video0 is not opened?

Q2- Does v4l2 capture works as bridge to initialize subdevices such as TVP5150 and create video device representation (/dev/video0)?


Any example Kernel Configuration and Device Tree can be helpful


Thanks in advance

Labels (4)
Tags (1)
0 Kudos
Reply
11 Replies

3,730 Views
akbar123
Contributor III

Hi,

After a lot of test, now the NTSC video is stable (does not roll), BUT it's a little shifted right and there are two pictures in it. The same happen to PAL video. I changed the following to get this result (More notably the mclk=27000000

 

//In probe function
tvp5150_data.mclk = 27000000;

//In ioctl_g_ifparm function
p->u.bt656.clock_curr = tvp5150_data.mclk;
pr_debug("   clock_curr=mclk=%d\n", tvp5150_data.mclk);
p->if_type = V4L2_IF_TYPE_BT656;
p->u.bt656.mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT;
p->u.bt656.clock_min = TVP5150_XCLK_MIN;
p->u.bt656.clock_max = TVP5150_XCLK_MAX;
p->u.bt656.bt_sync_correct = 0;  /* Indicate external vsync */

p->u.bt656.nobt_hs_inv = 1;
p->u.bt656.latch_clk_inv = 1;

 

The attached image is the result by using the following command:

$ gst-launch-1.0 imxv4l2videosrc device=/dev/video0 num-buffers=1 ! imxvpuenc_jpeg ! filesink location=/home/ntscIssue.jpg

I guess there are some wrong configurations such as the above one.

My problem is not with width and height as it's as follow for NTSC:

 

{   /*! NTSC */
    .v4l2_id = V4L2_STD_NTSC,
    .name = "NTSC",
    .raw_width = 720,		/* SENS_FRM_WIDTH */
    .raw_height = 525,		/* SENS_FRM_HEIGHT */
    .active_width = 720,	/* ACT_FRM_WIDTH */
    .active_height = 480,	/* ACT_FRM_HEIGHT */
    .active_top = 13,
    .active_left = 0,
},

 

 

Question1: What could be the problem of having a right-shifted with two pictures in a frame?

Question2: How can I get the received frame information, e.g. #lines and #pixels in each line, so that I can confirm whether the configuration is right?

 

Thanks for your help

0 Kudos
Reply

3,720 Views
igorpadykov
NXP Employee
NXP Employee

what bsp used in the case, may be recommended to try with latest nxp linux from

source.codeaurora.org/external/imx/linux-imx repository

https://source.codeaurora.org/external/imx/linux-imx/tree/?h=lf-5.10.y

documentation

https://www.nxp.com/design/software/embedded-software/i-mx-software/embedded-linux-for-i-mx-applicat...

 

Best regards
igor

0 Kudos
Reply

3,715 Views
akbar123
Contributor III

Hi,

I'm using the latest version, linux-lf-5.10.52-2.1.0

0 Kudos
Reply

3,711 Views
igorpadykov
NXP Employee
NXP Employee

unfortunately tvp5150 is not "officially" supported in nxp bsps, sorry.

For support with integration may be recommended to proceed with help of   https://contact.nxp.com/new-prof-svcs-sw-tech

 

Best regards
igor

0 Kudos
Reply

3,936 Views
igorpadykov
NXP Employee
NXP Employee

Hi Asghar

 

unfortunately TVP5150 is not supported in NXP BSPs, one can look at compulab

cl-som-imx6-linux (attached are dts files):

https://mediawiki.compulab.com/w/index.php?title=CM-FX6_Freescale_i.MX6_SW_Resources

https://github.com/compulab-yokneam/imx6/blob/master/m6/kernel_imx/0061-ARM-i.MX6-tvp5150-add-tvp515...

 

Best regards
igor

0 Kudos
Reply

3,788 Views
akbar123
Contributor III

Hi,

I used compulab TVP5150 driver (with a little change for bug fix ... in attachment) with imx6q capture subsystem (imx_v4l2_capture.c).

I want to use TVP5150AM1 with a NTSC Camera connected to imx6q IPU0_CSI0. Now, The video goes up as you can see in the attached file. I guess the problem might be with wrong height, But as I double check its size is 720*480 in driver.

I use two other PAL Cameras, It's ok, but sometimes for a few seconds at first, the video goes up like the NSTC one but then it becomes ok.

 

I use the below Gstreamer command to dispaly camera on screen:

$ gst-launch-1.0 imxv4l2videosrc device=/dev/video0 ! imxg2dvideosink framebuffer=/dev/fb0

 

This is the DT node:

tvp5150@5c {
    compatible = "my,tvp5150";
    reg = <0x5c>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_ipu1_csi0>;
    clocks = <&clks 201>;
    clock-names = "csi_mclk";
    csi_id = <0>;
    mclk = <27000000>;
    mclk_source = <0>;

    status = "okay";
};

 

Question: What could be the problem with NTSC and how to solve it?

Thanks for your help

0 Kudos
Reply

3,776 Views
igorpadykov
NXP Employee
NXP Employee
0 Kudos
Reply

3,818 Views
akbar123
Contributor III

Hi,

The problem is that mxc_v4l2_capture.c module needs to be aware of its slave by calling  v4l2_int_device_register in the slave driver, i.e. tvp5150.

By inspecting Linux source code, I figured out that there are two drivers fo ov5640, one in driver/media/i2c and another one in driver/media/platform/mxc/capture. The one available in the platform/mxc/capture registers ov5640 in a way that is understandable by mxc_v4l2_capture (This is what stated in Porting Guide in Camera Sensor Chapter). So I used the same way for TVP5150. Fortunately compulab has done this and used their driver

Now, the problem is that I can't get a good image. Trying some gstreamer commands, I guess that I don't make a proper pipeline to get the image.

 

Question: How to make a pipeline for streaming frames of a NTSC camera over network? what about the PAL Camera?

Right now, I use the following commands to stream frames on network, But the receive Video Stream has the problem of frames go up. I guess I don't set the frame size right and this causes to get the pixels of previous frame in the next frame which causes the image go up continuously

 

imx6 Transmitter:

$ gst-launch-1.0 imxv4l2videosrc device=/dev/video0 ! rtpvrawpay ! udpsink host=10.0.0.2 port=5001 sync=false async=false -v

 

x86 Receiver:

gst-launch-1.0 udpsrc port=5001 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, sampling=(string)YCbCr-4:2:2, depth=(string)8,width=(string)720, height=(string)576, colorimetry=(string)BT601-5, payload=(int)96, ssrc=(uint)155528026, timestamp-offset=(uint)2270520902, seqnum-offset=(uint)27437,a-framerate=(string)30" ! rtpvrawdepay ! videoconvert ! queue ! xvimagesink sync=false

 

Thanks in advance

0 Kudos
Reply

3,813 Views
igorpadykov
NXP Employee
NXP Employee

for streaming on network may be useful to look at  i.MX Linux User’s Guide​

sect.7.3.10 Web camera, RTP/UDP MPEGTS streaming

 

Best regards
igor

0 Kudos
Reply

3,920 Views
akbar123
Contributor III

Hi,

I guess my question is more related to imx6 than to tvp5150

tvp5150 is probed successfully, but I guess the video chain does not detected it.

Could you please ask NXP engineers to help me with this problem? I searched Internet and came up with some results about this problem BUT NO useful information found

Helping to solve this problem will help others as well in future

 

Thanks in advance for your help

0 Kudos
Reply

3,888 Views
igorpadykov
NXP Employee
NXP Employee

for "..video chain does not detected it.."  and general understanding how

video chain works one can look for example on

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/De-interlace-Capture-Device/ta-p/1114964

https://source.codeaurora.org/external/imx/imx-test/tree/test/mxc_v4l2_test?h=lf-5.10.52_2.1.0

Chapter 14 Supporting Cameras with CSI   i.MX Porting Guide

 

Best regards
igor

0 Kudos
Reply