lak4cyut
Posts: 5
Joined: Wed Aug 21, 2019 6:27 am

V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Wed Aug 21, 2019 8:52 am

Hi everyone,
I built a custom kernel to enable bcm2835-unicam and ov5647 kernel module and add ov5647 dt overlay, try to capture camera image via V4L2 official interface. (Of course I bought a Raspberry Pi official camera module - OV5647 version.)

Kernel base version: 4.19.64
Raspberry Pi: 3 model B v1.2
Camera Module: Raspbery Pi (OV5647) Rev 1.3

The good news is, I can capture the image, but the bad news is that image is abnormal (overlay & distortion).
(I put the image below)
Is there have anyone know why the image will wrong? Or have any idea to solve this problem?
Thanks for the help.

My capture command:
v4l2-ctl --device /dev/video0 --stream-mmap --stream-to=frame.raw --stream-count=1
frame2.jpg
frame2.jpg (79.79 KiB) Viewed 307 times
frame1.jpg
frame1.jpg (106.56 KiB) Viewed 307 times
frame.jpg
frame.jpg (122.32 KiB) Viewed 307 times
====================== Here is the complete story ====================
My finial goal is to connect my own camera sensor via V4L2 architecture on Raspberry Pi CSI-2.
So I plan to use bcm2835-unicam + write a subdev driver to control my camera sensor.

Before that, I want to study and make sure bcm2835-unicam driver is workable.
Therefore, I buy a official Raspberry Pi camera module (OV5647) and build a custom kernel to enable bcm2835-unicam & ov5647 kernel module.
Final step, reference to https://github.com/raspberrypi/firmware ... ays/README, enable ov5647 dt overlay.

Then... I encounter this problem....

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7431
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Thu Aug 22, 2019 12:31 pm

The ov5647 and bcm2835_unicam drivers should be in the standard kernel images built for Raspbian etc. Initially there should be no need to rebuild anything.
The ov5647 driver is pretty much vanilla Linux mainline - see https://github.com/torvalds/linux/blob/ ... c/ov5647.c
When first working on it I did have odd issues with short frames/dropped lines, but didn't dig too far as the mainline driver should "just work". You could try dropping the register set from raspiraw in to the driver instead, or at least analysing the differences. rapsiraw is known to work, although that is using 10bit Bayer mode instead of 8.
IIRC It was on this driver that I discovered the quirks of non-continuous clock mode and that the driver was running only in continuous clock. You can switch between them by changing the overlay (remove the "clock-noncontinuous;" line).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

lak4cyut
Posts: 5
Joined: Wed Aug 21, 2019 6:27 am

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Mon Aug 26, 2019 8:40 am

Hi 6by9,
First of all, I want to thank you of those information. It is helpful for me, I am a newbie on this scope (multimedia).
After remove "clock-noncontinuous;" on ov5647.dts and re-build it, the captured image has the chance become normal.

Then I reference the spec and your code, update the init-register settings, it finally become stable, thanks for your suggestion.

Now my problem is the RPi 3 seems cannot provide a good performance for play RAW (Bayer) stream.. It is very slow and lag...
But anyway, it is a huge step for me, thank you again.

Another question, actually, I don't really understand what it means, would you like to give me some info about that?
IIRC It was on this driver that I discovered the quirks of non-continuous clock mode and that the driver was running only in continuous clock. You can switch between them by changing the overlay (remove the "clock-noncontinuous;" line).

Return to “Camera board”