OV7740 camera on I.MX6 using CSI0 in BT.656 mode

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

OV7740 camera on I.MX6 using CSI0 in BT.656 mode

11,005 Views
robert_lim
Contributor II

I am using an imx.6 Sabrelite (PN:BD-S1-imx6) from BoundaryDevices to develop a camera system. The camera sensor is the ov7740 from omnivision, attached to Sabrelite via CSI0 (8 data lines, pixelclock and camera system clock). As I do not have the possibility to connect the hsync and vsync signal this all has to work in BT.656 mode.

I am having issue getting images from the driver. The video for linux drivers hangs waiting for data and after a timeout breaks down the video4 linux pipeline.

The steps I have taken so far:

  1. Started with working kernel (boundary-imx_3.10.17_1.0.0_beta) and
  2. Made sure that the camera is detected and can be configured over I2C.
  3. Built a driver, OV7740.c, based on OV5642.c with the following changes:
    1. Replaced modes  to generate a 640x480 30 fps data on the OV7740     
    2. Changed the chip_id     
    3. Changed ov7740_data.pix.pixelformat to V4L2_PIX_FMT_YVU420     
    4. Added V4L2 required IOCTL functions

  1. Sensor is correctly detected on I2C
  2. PCLK and XCLK are correct
  3. Use tool: mxc_v4l2_capture.out and gstreamer to try to capture sensor data

The test encounter DQBUF failed during capturing, the error is as follow:

ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0 VIDIOC_DQBUF failed.

When trying to decipher the video for linux kernel module, it seems that this occurs when the data queue hasn't been filled until a certain timeout. The queue should be filled through the CSI interrupt handler. As I can see it now, it seems that the interrupt is never raised.

I have taken the following link which have similar problem using BT656 mode to capture in progressive mode as a reference:

https://community.freescale.com/thread/309869

https://community.freescale.com/docs/DOC-95412

For more info, below summarize our setting and dumped info to get the CSI BT656 without HSYNC/VSYNC working:

  1. function ioctl_g_ifparm() sets p->u.bt656.bt_sync_correct = 0:
  2. modify the code in mxc_v4l2_s_param(), let csi_param.clk_mode = IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE
  3. The CSI0 connects parallel, IOMUXC_GPR1 = 0x48693005 and IPU_CONF = 0x00000785

14010_14010.jpg1.JPG.jpg

14013_14013.jpg2.jpg

I think this is due to the CSI/IPU not setup properly for BT.656 mode without hsync/vsync signals. Please give some support on how to configure the CSI/IPU with this camera?

Thanks in advance.

30 Replies

2,969 Views
aurelienbouin
Contributor IV

Hello Thomas,

I am sorry I don't have more advice ...

What I knwo is that when CSI0 was not working with my hardware there was at least the CSI test mode working ...

It seems weird that for you it is not ...

Regards,

Aurelien

0 Kudos

2,968 Views
aurelienbouin
Contributor IV

Nobody ?

0 Kudos

2,969 Views
aurelienbouin
Contributor IV

I finally figured out what was wrong !!!

There is in the source linux file from freescale arch/arm/mach-imx/mach-imx6q.c a wonderful line : else if (of_machine_is_compatible("fsl,imx6dl-sabresd") ||

So if you try to use your own device tree file you won't get IOMUXC_GPR13 configured correctly !

By default IOMUXC_GPR13 has the value 0x00000008 and should be 0x0000000c for csi parallel use case ...

In your first line of your device tree you actually need to add compatible = XXX, "fsl,imx6dl-sabresd"; and then it will work ...

Hope it will help ...

2,969 Views
thomasquartier
Contributor II

Hi,

I'm trying to interface the OV7740 in HREF mode (ov7740 camera with custom i.MX6DL board using CSI0 in HREF (gated clock) mode)).

Did you make any other changes to the ov7740 / mxc_v4l2_capture / ipu drivers?

I having the same error:

     No interrupts on IPU

     camera_callback function is never called

     cam->enc_counter is never incremented

     VIDIOC_DQBUF ioctl fails

Regards,

Thomas

0 Kudos

2,969 Views
aureliencourrie
Contributor II

Hi Thomas,

Did you solved your problem ?? I've the same thing with my ov7740 :-(...

Thanks

Wee Do

0 Kudos

2,969 Views
thomasquartier
Contributor II

Hi,

Sorry for the late response.

Our problem is solved, it was a hardware configuration on our custom board.

Because of the wrong configuration we didn't receive the pixel clock on the i.MX6.

Regards,

Thomas

0 Kudos

2,969 Views
aurelienbouin
Contributor IV

Hello Thomas,

Are you sure you add in your dts the line

compatible = "yourcompany,imx6dl-yourboard", "fsl,imx6dl", "fsl,imx6dl-sabresd";

Because it calls something magical in arch/arm/mach-imx/mach-imx6q.c

if (of_machine_is_compatible("fsl,imx6dl-sabresd")

...

regmap_update_bits(gpr, IOMUXC_GPR13, 0x3F, 0x0C);

Which enable CS0 instead of MIPI ...

Else have you try the CSI test mode ?

With that line you should enable it :

devregs -c imx6dls 0x02630000 0x4008818; devregs -c imx6dls; devregs -c imx6dls  0x02630010 0x1000000;devregs -c imx6dls 0x02630004 0x04ff09ff

You should find the tool devregs on my github : aurelihein/devregs · GitHub

It is really usefull to set on the go registers ...

Hope it will help you

Aurelien

0 Kudos

2,969 Views
thomasquartier
Contributor II

Hi Aurelien,

Thanks for your reply!

The "fsl,imx6dl-sabresd" option is added to the list of compatible devices and the IOMUXC_GPR13 registers is set correct during boot.

I tried the camera in test mode and I have still the same error.

I used devregs to change registers while avconv was running (waiting for the DQBUF ioctl) but it didn't change anything.

More advice is welcome!

Regards,

Thomas

0 Kudos

2,969 Views
aureliencourrie
Contributor II

Hi Aurélien,

I have to use the ov7740 on custom board (with an imx6dl), so could you share your dts file you use for ov7740, please.

Thanks in adance

0 Kudos

2,969 Views
aurelienbouin
Contributor IV

Hi,

No problem

Do not forget in the compatible line to add "imx6dl-sabresd"

Like this

compatible = "yourcompany,imx6dl-yourboard", "fsl,imx6dl", "fsl,imx6dl-sabresd";

Since the HTML use here is %/!£$# use this link : dts_ov7740.dts - Pastebin.com

Sincerely,

Aurelien BOUIN

0 Kudos

2,969 Views
aureliencourrie
Contributor II

Hi,

Thank for your quick answer :-).

Unfortunately, I can't try it for now, i've not received my ov7740.

I'll try when I received it and keep you in touch.

Regards

0 Kudos

2,973 Views
YixingKong
Senior Contributor IV

Robert

Has the issue resolved? If yes, please close this DI and other one with the same title.

Thanks,

Yixing

0 Kudos

2,973 Views
robert_lim
Contributor II

Hi Yixing and QiangLi,

Thanks to all the advices, I have followed the suggestions but it was still not working on my system. Instead of keeping trial and error that behind my schedule, we added Vsync to make it works so as to go to the next work. But it just a workaround so that we can start with subsequent works, the product is stick to use BT656 without Vsync/Hsync, I will have to solve this problem in the future, it would be great if the issue is still open.

Thanks,

Robert

0 Kudos

2,973 Views
qiang_li-mpu_se
NXP Employee
NXP Employee

Hi Robert, you can also reference to that link: https://community.freescale.com/thread/295157

In that link, we verified iMX53 CSI without VSYNC and HSYNC connected (720x480P with BT1120). Currently we have no iMX6 reference board which can support BT656 progressive input, but the iMX6 and iMX5 CSI are same.

0 Kudos

2,973 Views
robert_lim
Contributor II

Thanks QiangLi,

Currently I am using VSYNC and HSYNC connected for BT656. I will try this and update status here afterwards :smileyhappy:

Appreciate your help.

Regards,

Robert

0 Kudos

2,973 Views
aurelienbouin
Contributor IV

Hello Robert,

I do have the same OV7740 sensor, and even with VSYNC and HSYNC connected I am unable to get any picture, i get the same error "mxc_v4l_dqueue timeout enc_counter 0 VIDIOC_DQBUF failed"

Could you share your source code it could really help me

Thank you for your help

Aurelien

0 Kudos

2,973 Views
aurelienbouin
Contributor IV

hello,

I am really unable to get any data from my sensor ... I use this configuration in dts :

   MX6QDL_PAD_CSI0_DAT12__IPU1_CSI0_DATA120x80000000
   MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA130x80000000
   MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA140x80000000
   MX6QDL_PAD_CSI0_DAT15__IPU1_CSI0_DATA150x80000000
   MX6QDL_PAD_CSI0_DAT16__IPU1_CSI0_DATA160x80000000
   MX6QDL_PAD_CSI0_DAT17__IPU1_CSI0_DATA170x80000000
   MX6QDL_PAD_CSI0_DAT18__IPU1_CSI0_DATA180x80000000
   MX6QDL_PAD_CSI0_DAT19__IPU1_CSI0_DATA190x80000000
   MX6QDL_PAD_CSI0_DATA_EN__IPU1_CSI0_DATA_EN 0x80000000
   MX6QDL_PAD_CSI0_PIXCLK__IPU1_CSI0_PIXCLK   0x80000000
   MX6QDL_PAD_CSI0_MCLK__IPU1_CSI0_HSYNC  0x80000000
   MX6QDL_PAD_CSI0_VSYNC__IPU1_CSI0_VSYNC 0x80000000

Here is my driver for ov7740 : ov7740.c - Pastebin.com

I keep getting : ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0

Here is a log if it can help solved the problem : http://pastebin.com/328M7EMK

I checked on the pins signals everything seemsnormal ... pixclock is here

Thank you for your support,

Sincerely

Aurelien BOUIN

0 Kudos

2,973 Views
pchevalier
Contributor I

can you update ?

I have the same problem !

Thanks :smileyhappy:

0 Kudos

2,973 Views
qiang_li-mpu_se
NXP Employee
NXP Employee

Hi Robert, if there is no EAV/SAV embedded on date line, the VSYNC and HSYNC pins are needed for BT656 input.

0 Kudos

2,973 Views
robert_lim
Contributor II

Hi Qiang Li,

The EAV/SAV was embedded on data line, as shown below:

scope_0.png

scope_1.png

scope_2.png

Thanks,

Robert

0 Kudos