Analog Camera Module on Embedded Linux, preview is random pixel data

I am trying to run the standard gstreamer pipeline to display a preview as shown on How to use Analogue Camera Adapter on Embedded Linux

I went through the modprobe steps for the Apalis T30. Then, instead of a preview image, random pixel data is displayed when I issue the command:

gst-launch v4l2src ! deinterlace tff=1 method=4 ! nv_omx_videomixer ! nv_gl_eglimagesink

I have connected a known good (checked with scope) NTSC camera to X5 on the analog camera board (I also tried connecting to all video inputs with same result). I installed jumpers on the Apalis eval board per the analog camera module data sheet.

Jumpers on analog camera module were left as factory defaults (and checked against data sheet). Appropriate power LED is lit on the analog camera module.

The following is displayed on the console. There is an I2C error reading address 0x20 which may be the cause of the problem (address should be 0x40?). Can anyone offer some guidance as to how to fix this?

[  264.657466] nvavp nvavp: using SMMU at ff00000 to load AVP kernel
[  264.672469] nvavp nvavp: read firmware from 'nvavp_os_0ff00000.bin' (15484 bytes)
[  264.700039] nvavp nvavp: entry=00000094 control=00004a60 debug=00005260 size=15460
[  264.707879] nvavp nvavp: AVP os at vaddr=f0d01000 paddr=ff00000 reset_addr=0ff00094
[  264.737094] nvavp nvavp: read ucode firmware from 'nvavp_vid_ucode_alt.bin' (26888 bytes)
[  264.751453] nvavp nvavp: using SMMU at ff00000 to load AVP kernel
[  264.757807] nvavp nvavp: AVP os at vaddr=f0d01000 paddr=ff00000 reset_addr=0ff00094
NvxLiteH264DecoderInit : Opening TVMR H264 block 
NvxLiteH264DecoderInit : Opening TVMR H264 block 
[  265.216799] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.222647] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.228919] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.234660] max9526 2-0020: Read: retry ... 0
[  265.262128] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.267971] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.274241] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.279977] max9526 2-0020: Read: retry ... 1
[  265.311858] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.317699] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.323970] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.329706] max9526 2-0020: Read: retry ... 2
[  265.362068] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.367910] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.374182] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.379916] max9526 2-0020: Read: retry ... 3
[  265.411853] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.417695] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.423966] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.429701] max9526 2-0020: Read: retry ... 4
[  265.461858] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.467699] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.473971] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.479705] max9526 2-0020: Read: retry ... 5
[  265.511847] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.517689] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.523961] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.541615] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.547457] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.553727] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.559421] max9526 2-0020: Write: retry ... 0
[  265.581648] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.587491] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.593761] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.599757] max9526 2-0020: Write: retry ... 1
[  265.621603] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.627444] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.633715] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.639451] max9526 2-0020: Write: retry ... 2
[  265.671872] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.677713] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.683985] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.689899] max9526 2-0020: Write: retry ... 3
[  265.711625] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.717471] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.723741] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.729469] max9526 2-0020: Write: retry ... 4
[  265.761874] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.767717] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.773988] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.779727] max9526 2-0020: Write: retry ... 5
[  265.811849] tegra-i2c tegra-i2c.2: I2c error status 0x00000008
[  265.817690] tegra-i2c tegra-i2c.2: no acknowledge from address 0x20
[  265.823961] tegra-i2c tegra-i2c.2: Packet status 0x00010009
[  265.829698] max9526 2-0020: Write failed. Err[-121]
[  265.834612] max9526 2-0020: Unable to turn on decoder
[  267.571697] vi vi: Timeout on VI syncpt
[  267.575550] vi vi: buffer_addr = 0x00a31000
[  267.579739] vi vi: VIP_INPUT_STATUS = 0x46ac0000
[  269.581580] vi vi: Timeout on VI syncpt
[  269.585431] vi vi: buffer_addr = 0x00a31000
[  269.589620] vi vi: VIP_INPUT_STATUS = 0x18020000
[  271.591914] vi vi: Timeout on VI syncpt
[  271.595766] vi vi: buffer_addr = 0x00a31000
[  271.599954] vi vi: VIP_INPUT_STATUS = 0x42270000
[  273.601568] vi vi: Timeout on VI syncpt
[  273.605419] vi vi: buffer_addr = 0x00a31000
[  273.609606] vi vi: VIP_INPUT_STATUS = 0x59580000
[  275.611667] vi vi: Timeout on VI syncpt
[  275.615514] vi vi: buffer_addr = 0x00a31000
[  275.619810] vi vi: VIP_INPUT_STATUS = 0x357d0000
[  277.621553] vi vi: Timeout on VI syncpt
[  277.625490] vi vi: buffer_addr = 0x00a31000
[  277.629682] vi vi: VIP_INPUT_STATUS = 0x83e00000
[  279.631558] vi vi: Timeout on VI syncpt
[  279.635407] vi vi: buffer_addr = 0x00a31000
[  279.639594] vi vi: VIP_INPUT_STATUS = 0x6e6d0000
[  281.641556] vi vi: Timeout on VI syncpt
[  281.645407] vi vi: buffer_addr = 0x00a31000
[  281.649594] vi vi: VIP_INPUT_STATUS = 0x4e610000

I suspect that your jumper settings are not quite kosher. As follows what I set my test module at: JP2 2-3, JP3 open. All the other jumpers should not matter in the MAX9526 case.

Please note that given me being located in Europe I use a PAL camera for testing. I believe it should work with NTSC ones as well however I am not quite sure whether any code changes might be required.

I do get some I2C errors as well but they stem from them OmniVision kernel modules being loaded by default as well. You can work around this by just (re-)moving those modules as follows:

root@apalis-t30:~# mv /lib/modules/3.1.10-V2.5b3+gc8ead50/kernel/drivers/media/video/ov* .

And as follows running the camera:

root@apalis-t30:~# modprobe videobuf2-memops
root@apalis-t30:~# modprobe videobuf2-dma-nvmap
root@apalis-t30:~# modprobe max9526
root@apalis-t30:~# modprobe tegra_v4l2_camera
[  164.072380] vi vi: initialized
[  164.075479] soc-camera-pdrv soc-camera-pdrv.0: Probing soc-camera-pdrv.0
[  164.102317] soc-camera-pdrv soc-camera-pdrv.1: Probing soc-camera-pdrv.1
[  164.119009] soc-camera-pdrv soc-camera-pdrv.2: Probing soc-camera-pdrv.2
[  164.135724] soc-camera-pdrv soc-camera-pdrv.3: Probing soc-camera-pdrv.3
[  164.150178] max9526 2-0020: max9526 2-0020 decoder driver registered !!
[  164.159258] vi vi: Providing format YUV422 (UYVY) packed using code 8200
[  164.166058] vi vi: Providing format YUV422 (VYUY) packed using code 8200
[  164.172813] vi vi: Providing format YUV422 (YUYV) packed using code 8200
[  164.179522] vi vi: Providing format YUV422 (YVYU) packed using code 8200
[  164.186258] vi vi: Providing format YUV420 (YU12) planar using code 8200
[  164.192989] vi vi: Providing format YVU420 (YV12) planar using code 8200
[  164.199693] vi vi: Providing format Bayer 8 BGBG.. GRGR.. using code 8200
[  164.206558] vi vi: Providing format Bayer 10 BGBG.. GRGR.. using code 8200
[  164.213473] vi vi: Providing format YUV422 (UYVY) packed using code 8198
[  164.220179] vi vi: Providing format YUV422 (VYUY) packed using code 8198
[  164.226908] vi vi: Providing format YUV422 (YUYV) packed using code 8198
[  164.233634] vi vi: Providing format YUV422 (YVYU) packed using code 8198
[  164.240339] vi vi: Providing format YUV420 (YU12) planar using code 8198
[  164.247062] vi vi: Providing format YVU420 (YV12) planar using code 8198
[  164.253786] vi vi: Providing format Bayer 8 BGBG.. GRGR.. using code 8198
[  164.260578] vi vi: Providing format Bayer 10 BGBG.. GRGR.. using code 8198
[  164.270071] soc-camera-pdrv soc-camera-pdrv.4: Probing soc-camera-pdrv.4
[  164.299905] soc-camera-pdrv soc-camera-pdrv.5: Probing soc-camera-pdrv.5
[  164.317707] soc-camera-pdrv soc-camera-pdrv.6: Probing soc-camera-pdrv.6
[  164.334469] vi vi: Tegra camera driver loaded.
root@apalis-t30:~# gst-launch v4l2src ! deinterlace tff=1 method=4 ! nv_omx_videomixer ! nv_gl_eglimagesink
[  231.553942] nvavp nvavp: using SMMU at ff00000 to load AVP kernel
[  231.577024] nvavp nvavp: read firmware from 'nvavp_os_0ff00000.bin' (15484 bytes)
[  231.604280] nvavp nvavp: entry=00000094 control=00004a60 debug=00005260 size=15460
[  231.612336] nvavp nvavp: AVP os at vaddr=e8c41000 paddr=ff00000 reset_addr=0ff00094
[  231.645751] nvavp nvavp: read ucode firmware from 'nvavp_vid_ucode_alt.bin' (26888 bytes)
[  231.659951] nvavp nvavp: using SMMU at ff00000 to load AVP kernel
[  231.666307] nvavp nvavp: AVP os at vaddr=e8c41000 paddr=ff00000 reset_addr=0ff00094
NvxLiteH264DecoderInit : Opening TVMR H264 block 
NvxLiteH264DecoderInit : Opening TVMR H264 block 
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

Thank you for your quick response. You were exactly right on the jumpers: JP2 is 2-3 but JP3 was installed and should have been open. After fixing that (and removing the OmniVision modules as you suggested) I get only one video frame every 20 seconds and it looks like it is in the wrong color space. Appears to be black and white video with some streaks of false color. At the top of the video is the bottom 3/4 or so of the video frame. At the bottom of the video is the top 1/4 of the video frame, repeated twice. Here is what I’m typing in with the response:

root@apalis-t30:~# modprobe videobuf2-dma-nvmap
root@apalis-t30:~# modprobe max9526
root@apalis-t30:~# modprobe tegra_v4l2_camera
[  146.478019] vi vi: initialized
[  146.481120] soc-camera-pdrv soc-camera-pdrv.0: Probing soc-camera-pdrv.0
[  146.504644] soc-camera-pdrv soc-camera-pdrv.1: Probing soc-camera-pdrv.1
[  146.521302] soc-camera-pdrv soc-camera-pdrv.2: Probing soc-camera-pdrv.2
[  146.538026] soc-camera-pdrv soc-camera-pdrv.3: Probing soc-camera-pdrv.3
[  146.552577] max9526 2-0020: max9526 2-0020 decoder driver registered !!
[  146.559345] vi vi: Providing format YUV422 (UYVY) packed using code 8200
[  146.568391] vi vi: Providing format YUV422 (VYUY) packed using code 8200
[  146.575616] vi vi: Providing format YUV422 (YUYV) packed using code 8200
[  146.582376] vi vi: Providing format YUV422 (YVYU) packed using code 8200
[  146.589084] vi vi: Providing format YUV420 (YU12) planar using code 8200
[  146.595825] vi vi: Providing format YVU420 (YV12) planar using code 8200
[  146.602601] vi vi: Providing format Bayer 8 BGBG.. GRGR.. using code 8200
[  146.609395] vi vi: Providing format Bayer 10 BGBG.. GRGR.. using code 8200
[  146.616603] vi vi: Providing format YUV422 (UYVY) packed using code 8198
[  146.623352] vi vi: Providing format YUV422 (VYUY) packed using code 8198
[  146.630058] vi vi: Providing format YUV422 (YUYV) packed using code 8198
[  146.636789] vi vi: Providing format YUV422 (YVYU) packed using code 8198
[  146.643514] vi vi: Providing format YUV420 (YU12) planar using code 8198
[  146.650218] vi vi: Providing format YVU420 (YV12) planar using code 8198
[  146.656940] vi vi: Providing format Bayer 8 BGBG.. GRGR.. using code 8198
[  146.663751] vi vi: Providing format Bayer 10 BGBG.. GRGR.. using code 8198
[  146.673513] soc-camera-pdrv soc-camera-pdrv.4: Probing soc-camera-pdrv.4
[  146.685930] ------------[ cut here ]------------
[  146.690581] WARNING: at /build/linuxdev/oe-core_V2.5/build/out-glibc/work-shared/apalis-t30/kernel-source/arch/arm/mach-tegra/powergate.c:795 tegra_powergate_partition+0xa0/0xb8()
[  146.712905] soc-camera-pdrv soc-camera-pdrv.5: Probing soc-camera-pdrv.5
[  146.730823] soc-camera-pdrv soc-camera-pdrv.6: Probing soc-camera-pdrv.6
[  146.740985] Could not Powergate Partition 2, all clks not disabled
[  146.748011] Modules linked in: tegra_v4l2_camera(+) max9526 videobuf2_dma_nvmap videobuf2_memops
[  146.757169] [] (unwind_backtrace+0x0/0xe8) from [] (dump_stack+0x20/0x24)
[  146.771464] vi vi: Tegra camera driver loaded.
root@apalis-t30:~# 
[  146.782185] [] (dump_stack+0x20/0x24) from [] (warn_slowpath_common+0x5c/0x74)
[  146.792829] [] (warn_slowpath_common+0x5c/0x74) from [] (warn_slowpath_fmt+0x40/0x48)
root@apalis-t30:~# [  146.802843] [] (warn_slowpath_fmt+0x40/0x48) from (tegra_powergate_partition+0xa0/0xb8)
[  146.814449] [] (tegra_powergate_partition+0xa0/0xb8) from [] (tegra_camera_deactivate+0xd4/0xf4 [tegra_v4l2_camera])
[  146.826777] [] (tegra_camera_deactivate+0xd4/0xf4 [tegra_v4l2_camera]) from (tegra_camera_remove_device+0x48/0x58 [tegra_v4l2_camera])
[  146.840917] [] (tegra_camera_remove_device+0x48/0x58 [tegra_v4l2_camera]) from (soc_camera_close+0x6c/0xb8)
[  146.852704] [] (soc_camera_close+0x6c/0xb8) from [] (v4l2_release+0x54/0x74)
[  146.861517] [] (v4l2_release+0x54/0x74) from [] (fput+0x120/0x1dc)
[  146.869480] [] (fput+0x120/0x1dc) from [] (filp_close+0x74/0x80)
[  146.877963] [] (filp_close+0x74/0x80) from [] (sys_close+0x9c/0xd4)
[  146.886503] [] (sys_close+0x9c/0xd4) from [] (ret_fast_syscall+0x0/0x30)
[  146.894940] ---[ end trace 6c77e1f1dc26bfa3 ]---
root@apalis-t30:~# gst-launch v4l2src ! deinterlace tff=1 method=4 ! nv_omx_videomixer ! nv_gl_eglimagesink
[  554.061702] nvavp nvavp: using SMMU at ff00000 to load AVP kernel
[  554.076386] nvavp nvavp: read firmware from 'nvavp_os_0ff00000.bin' (15484 bytes)
[  554.110666] nvavp nvavp: entry=00000094 control=00004a60 debug=00005260 size=15460
[  554.118496] nvavp nvavp: AVP os at vaddr=f0d01000 paddr=ff00000 reset_addr=0ff00094
[  554.137419] nvavp nvavp: read ucode firmware from 'nvavp_vid_ucode_alt.bin' (26888 bytes)
[  554.151282] nvavp nvavp: using SMMU at ff00000 to load AVP kernel
[  554.157637] nvavp nvavp: AVP os at vaddr=f0d01000 paddr=ff00000 reset_addr=0ff00094
NvxLiteH264DecoderInit : Opening TVMR H264 block 
NvxLiteH264DecoderInit : Opening TVMR H264 block 
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[  555.122068] MC_DECERR (0x2001002E): 00c0f000 vi_v (non-secure write )
[  555.138800] MC_DECERR (0x2001002E): 00c162f0 vi_v (non-secure write )
[  555.145271] MC_DECERR (0x2001002E): 00c20fa0 vi_v (non-secure write )
[  555.151731] MC_DECERR (0x2001002E): 00c256e0 vi_v (non-secure write )
[  555.158623] Too many MC errors; throttling prints
[  556.611620] vi vi: Timeout on VI syncpt
[  556.615485] vi vi: buffer_addr = 0x00a47000
[  556.619701] vi vi: VIP_INPUT_STATUS = 0x007900a9
[  558.621644] vi vi: Timeout on VI syncpt
[  558.625519] vi vi: buffer_addr = 0x00a47000
[  558.629715] vi vi: VIP_INPUT_STATUS = 0x00f2001e
[  560.631692] vi vi: Timeout on VI syncpt
[  560.635544] vi vi: buffer_addr = 0x00a47000
[  560.639733] vi vi: VIP_INPUT_STATUS = 0x016a009a
[  562.641691] vi vi: Timeout on VI syncpt
[  562.645540] vi vi: buffer_addr = 0x00a47000
[  562.649727] vi vi: VIP_INPUT_STATUS = 0x01e30010
[  564.651693] vi vi: Timeout on VI syncpt
[  564.655545] vi vi: buffer_addr = 0x00a47000
[  564.659733] vi vi: VIP_INPUT_STATUS = 0x025b008c
[  566.661594] vi vi: Timeout on VI syncpt
[  566.665446] vi vi: buffer_addr = 0x00a47000
[  566.669634] vi vi: VIP_INPUT_STATUS = 0x02d30106
[  568.671824] vi vi: Timeout on VI syncpt
[  568.675674] vi vi: buffer_addr = 0x00a47000
[  568.679863] vi vi: VIP_INPUT_STATUS = 0x034c007e
[  570.681587] vi vi: Timeout on VI syncpt
[  570.685437] vi vi: buffer_addr = 0x00a47000
[  570.689624] vi vi: VIP_INPUT_STATUS = 0x03c400f6
[  572.691585] vi vi: Timeout on VI syncpt
[  572.695435] vi vi: buffer_addr = 0x00a47000
[  572.699624] vi vi: VIP_INPUT_STATUS = 0x043d006c
[  574.701592] vi vi: Timeout on VI syncpt
[  574.705442] vi vi: buffer_addr = 0x00a47000
[  574.709631] vi vi: VIP_INPUT_STATUS = 0x04b500e7
[  576.741687] vi vi: Timeout on VI syncpt
[  576.745538] vi vi: buffer_addr = 0x00a47000
[  576.749726] vi vi: VIP_INPUT_STATUS = 0x00790029
[  578.751593] vi vi: Timeout on VI syncpt
[  578.755443] vi vi: buffer_addr = 0x00a47000
[  578.759632] vi vi: VIP_INPUT_STATUS = 0x00f100a3
[  580.761583] vi vi: Timeout on VI syncpt
[  580.765433] vi vi: buffer_addr = 0x00a47000
[  580.769622] vi vi: VIP_INPUT_STATUS = 0x016a0018

Please see my answer below. It was too big to fit into a comment on your answer.

I suspect this having to do with NTSC vs. PAL. Unfortunately I never tried NTSC but I do know one of my Brazilian colleagues having tried it once. Let me find out what exactly might have to be tuned for proper NTSC operation.

When I tried the Analog Camera Module I was using the ADV7180 chip but anyway I had several problems with format automatic selection.

I would like to suggest you take a look in this file
http://pdfserv.maximintegrated.com/en/an/AN734.pdf

Here you can see all the formats and what size each format use.

Than try to identify what format you camera use.

After that I suggest you make some tests using printk in the file:

linux-toradex/drivers/media/video/max9526.c

And check what parameters are really used.

I hope it helps you.

@allen.mann Did you ever manage to find a solution to this problem? We’re seeing exactly the same video artifacts when using an NTSC camera and are unsure how to resolve it.

Anyone from Toradex provide further information?

Kind regards,
Kevin

Kevin,

I concluded that the driver supports PAL but does not correctly support NTSC. I made a number of changes to the driver but ultimately did not solve the problem. After further analysis I determined that I need to use a different video decoder chip/driver so I didn’t work on this problem any more.

Regards,

Allen