Ov5640 camera RAW10 format on i.MX8MM

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

Ov5640 camera RAW10 format on i.MX8MM

5,421 Views
lauranao
Contributor I

Hi all,

I'm trying to configure ov5640 camera on the i.MX8MM platform to work in RAW 10-bit mode.

I'm using a custom board board with Android based on the p9.0.0-1.0.0_ga release from NXP.

I configured the ov5640 to work in 10-bit mode and output RAW BGGR format by setting the following registers in the camera driver (ov5640_mipi_v2.c):

{0x3034, 0x1A, 0, 0}, // MIPI mode: 10-bit

{0x4300, 0x00, 0, 0}, // Output data format: RAW BGGR

{0x501F, 0x03, 0, 0}, // ISP Format: ISP RAW (DPC)

I also added the RAW 10 media bus format to the supported colour formats in the ov5640 driver:

static const struct ov5640_datafmt ov5640_colour_fmts[] = {
    {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
    {MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_RAW}
};

I added support for the V4L2_PIX_FMT_SBGGR10 format in mx6s_capture.c driver. I also configured the following registers, based on what is reported in the i.MX8M Mini reference manual:

- CSI_CSICR1: set bit 0 (PIXEL_BIT) to 1 (i.e. 10-bit per pixel)

- CSI_CSICR18: set bits 25~30 (MIPI_DATA_FORMAT) to 0x2B (i.e. RAW10 format)

With this configuration, resulting raw image is very noisy (see attached image).

By looking at the interrupts, I can see multiple `32e30000.mipi_csi` interrupts firing when the frame is captured. By enabling additional debug in the mxc_mipi_csi.c driver, I noticed these interrupts signal multiple errors on the bus:

[   84.310700] ov5640_mipisubdev 5-003c: s_stream: 1
[   84.380096] CRC Error: 1
[   84.382639] Frame Start: 1
[   84.385425] CRC Error: 2
[   84.387986] CRC Error: 3
[   84.390568] CRC Error: 4
[   84.393153] CRC Error: 5
[   84.395735] CRC Error: 6
[   84.398313] CRC Error: 7
[   84.400885] CRC Error: 8
[   84.403464] CRC Error: 9
[   84.406022] CRC Error: 10
[   84.408675] CRC Error: 11
[   84.411343] CRC Error: 12
[   84.413980] CRC Error: 13
[   84.416643] CRC Error: 14
[   84.419305] CRC Error: 15
[   84.421947] CRC Error: 16
[   84.424624] CRC Error: 17
[   84.427278] Lost Frame Start Error: 1
[   84.430944] CRC Error: 18
[   84.433563] Frame End: 1

Do you have any advice on how to further debug this issue? Is there any other register I'm missing for configuring 10-bit mode for the MIPI CSI bus?

Any help would be appreciated.

Thanks,

Laura

Tags (2)
0 Kudos
4 Replies

3,991 Views
drgeneral
Contributor I

Hey Laura

Any success on this? We are trying this as well with our own interpreter but not having good success decoding the bitstream that comes back to us. 

0 Kudos

3,991 Views
igorpadykov
NXP Employee
NXP Employee

Hi Laura

one can try with linux

linux/arch/arm64/boot/dts/freescale/fsl-imx8mm-evk.dts

fsl-imx8mm-evk.dts\freescale\dts\boot\arm64\arch - linux-imx - i.MX Linux kernel 

https://community.nxp.com/thread/505857 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,991 Views
lauranao
Contributor I

Hi Igor,

Thanks for your reply.
I tried switching to Linux and capturing some RAW8 and RAW10 frames using v4l-utils as follows:

v4l2-ctl -d /dev/video0 --verbose --set-fmt--video=width=2592,height=1944,pixelformat=BA81 --stream-mmap --stream-count=1 --stream-to=raw8_2592x1944.raw

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

Unfortunately raw images are still not looking right (see screenshots attached, after I converted the raw captures from bayer to rgb). CRC errors like the ones below are reported in the kernel log when the frame is captured, both for 8-bit and 10-bit formats:

6,15197,289730726,-;mxc_mipi-csi.0: CRC Error: 1
6,15198,289730734,-;mxc_mipi-csi.0: Frame Start: 1
6,15199,289730738,-;mxc_mipi-csi.0: status: 01000002
6,15200,289730773,-;mxc_mipi-csi.0: CRC Error: 2
6,15201,289730778,-;mxc_mipi-csi.0: status: 00000002
6,15202,289730795,-;mxc_mipi-csi.0: CRC Error: 3
6,15203,289730799,-;mxc_mipi-csi.0: status: 00000002
6,15204,289730809,-;mxc_mipi-csi.0: CRC Error: 4

...

Do you have any insight on what might be causing these CRC errors on Linux during 8-bit raw capture too?

On the board I'm using, different drivers are selected for ov5640 and MIPI CSI controller than the one for the imx8mm-evk, specifically ov5640_mipi_v2, mx6s_capture and mxc_mipi_csi. Apart from this, configuration for the csi endpoint in the device tree looks pretty much the same as the one in the imx8mm-evk dt.

As for the discussion on the second link, I already modified the register suggested for enabling bayer format (cr18 register).

Are you aware of any specific PLL configuration for 10-bit MIPI mode? Not sure, but I'm guessing that might be a possible cause for the images being corrupted.

Thanks for your help,

Best,

Laura

0 Kudos

3,991 Views
igorpadykov
NXP Employee
NXP Employee

Hi Laura

could you try with latest Linux L4.19.35

linux-imx - i.MX Linux kernel 

Best regards
igor

0 Kudos