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

Re: Official V4L2 driver

Thu Sep 07, 2017 9:07 am

KeithG wrote:
Thu Sep 07, 2017 8:01 am
Hi,
My first post, hope I'm in the right place. I have just updated my rpi2B with a clean image of the new OS Stretch, now my camera will not work. I cannot find the bcm2835-v4l2 driver on the machine, motion does not start, when I use dmesg I get : bcm2835-v4l2: error -1 while loading driver.
Do I need a file? where do I get it?
If you do

Code: Select all

ls /lib/modules/`uname -r`/kernel/drivers/media/platform/bcm2835
it should list bcm2835-v4l2.ko ("uname -r" should expand to the currently running kernel version).

Check first whether "vcgencmd version" reports the camera as found, and that raspistill or raspivid work. If not then it's much easier to debug using those instead of the V4L2 driver.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

KeithG
Posts: 4
Joined: Thu Sep 07, 2017 7:38 am

Re: Official V4L2 driver

Thu Sep 07, 2017 3:02 pm

hi 6by9,
thanks for the prompt reply. Yes the bcm2835-v4l2.ko is there. vcgencmd returns with
Aug 8 2017 12:05:45
Copyright (c) 2012 Broadcom
version 196063438d7bb0769861c86f948ae653727adb7e (clean) (release)

raspistill -o test.jpg
returns
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
mmal: Failed to create camera component
mmal: main: Failed to create camera component
mmal: Camera is not detected. Please check carefully the camera module is installed correctly
the camera was working before the upgrade. I have checked the orientation of the ribbon

raspivid -t 5000 -o video.h264
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
mmal: Failed to create camera component
mmal: main: Failed to create camera component
mmal: Camera is not detected. Please check carefully the camera module is installed correctly

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

Re: Official V4L2 driver

Thu Sep 07, 2017 3:10 pm

KeithG wrote:
Thu Sep 07, 2017 3:02 pm
hi 6by9,
thanks for the prompt reply. Yes the bcm2835-v4l2.ko is there. vcgencmd returns with
Aug 8 2017 12:05:45
Copyright (c) 2012 Broadcom
version 196063438d7bb0769861c86f948ae653727adb7e (clean) (release)
Doh, I need to proof read - the command should have been "vcgencmd get_camera", which should return with "supported=1 detected=1" if it has found the camera.
The output from raspistill implies a hardware issue, but vcgencmd would confirm.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

KeithG
Posts: 4
Joined: Thu Sep 07, 2017 7:38 am

Re: Official V4L2 driver

Thu Sep 07, 2017 3:44 pm

vcgencmd get_camera returns
supported=1 detected=0
I take it this does not look good
I have removed the camera ribbon both ends and reconnected it. No change.

KeithG
Posts: 4
Joined: Thu Sep 07, 2017 7:38 am

Re: Official V4L2 driver

Thu Sep 07, 2017 3:58 pm

I have been looking at the camera board with a magnifying glass and noticed that the ribbon from the sensor to j2 was not flat against the connector. When I touched it, it clicked. So I rebooted the pi and reran the command. I now detects the camera and raspistill/raspivid produce files.
thanks for all of your help 6by9.

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

Re: Official V4L2 driver

Thu Sep 07, 2017 3:59 pm

KeithG wrote:
Thu Sep 07, 2017 3:44 pm
vcgencmd get_camera returns
supported=1 detected=0
I take it this does not look good
I have removed the camera ribbon both ends and reconnected it. No change.
That means the GPU can't talk to the camera over the I2C bus, so totally unrelated to the V4L2 driver.
The quick things to check:
- flex connectors are the correct way up and seated properly (sounds like you've already done that one)
- if a V1.3 camera module, does the LED come on?
- the little connector between the camera PCB and the camera module itself can become dislodged. Push down on top of it to make sure it is fully home.
...
And you've just replied with that last one being the cause!
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

jatta
Posts: 1
Joined: Thu Mar 16, 2017 11:35 am

Re: Official V4L2 driver

Tue Oct 17, 2017 1:46 pm

Hey guys,

What are the best settings for cctv at night?

I'm using:

[*]PI NoIR camera with external IR illuminator
[*]MotionEyeOS for surveillance

The image/video quality at night is perfect with:

[*]scene_mode=8 (night)
[*]exposure_dynamic_framerate=1
[*]color_effects=1 (black/white)

But the caveat with this is that moving subjects such as cars and people are blurred out due to the long exposure:
dynamic-exposure-framerate-enabled.png
dynamic-exposure-framerate-enabled.png (54.83 KiB) Viewed 3000 times
If I keep the same settings but disable exposure_dynamic_framerate the image is too dark :| :
current-settings-dynamic-exposure-disabled.png
current-settings-dynamic-exposure-disabled.png (69.27 KiB) Viewed 3000 times
I wouldn't be surprised if I am understanding the settings incorrectly so any pointers are much appreciated!

y3egjsk
Posts: 5
Joined: Thu Oct 26, 2017 1:55 pm

Re: Official V4L2 driver

Wed Nov 15, 2017 4:40 pm

I am running an application to display 1920x1080 video acquired in YUYV from
the Raspberry Pi v2 camera. That application uses the bcm2835-v4l2 device driver to access
the camera. The application uses the VIDIOC_S_FMT ioctl to set the YUYV format. I am running
using ioctls to set V4L2_CID_EXPOSURE_ABSOLUTE to 10000 (1 second exposures) and
V4L2_CID_AUTO_EXPOSURE set to V4L2_EXPOSURE_MANUAL.

If I run the program immediately after reboot, and loading the device driver I get a very dark image.

If I reboot, load the device driver, and run this --
v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=4
before my program, the YUYV image is a dramatically brighter, properly exposed image.

I just double checked that the VIDIOC_S_FMT ioctl in my program has the correct parameters either way.

Something somewhere is getting initialized by the temporary .h264 mode. Any ideas on what that could be?
Is .h264 mode more heavily tested than the YUYV mode?

Steve

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

Re: Official V4L2 driver

Thu Nov 16, 2017 10:01 am

y3egjsk wrote:
Wed Nov 15, 2017 4:40 pm
I am running an application to display 1920x1080 video acquired in YUYV from
the Raspberry Pi v2 camera. That application uses the bcm2835-v4l2 device driver to access
the camera. The application uses the VIDIOC_S_FMT ioctl to set the YUYV format. I am running
using ioctls to set V4L2_CID_EXPOSURE_ABSOLUTE to 10000 (1 second exposures) and
V4L2_CID_AUTO_EXPOSURE set to V4L2_EXPOSURE_MANUAL.

If I run the program immediately after reboot, and loading the device driver I get a very dark image.

If I reboot, load the device driver, and run this --
v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=4
before my program, the YUYV image is a dramatically brighter, properly exposed image.

I just double checked that the VIDIOC_S_FMT ioctl in my program has the correct parameters either way.

Something somewhere is getting initialized by the temporary .h264 mode. Any ideas on what that could be?
Is .h264 mode more heavily tested than the YUYV mode?
This is most likely due to the camera support not neatly mapping on to V4L2.
We have the concept of a stills capture vs a video capture, where one is optimised for image quality and the other is optimised for speed.
H264 and MJPEG obviously fall into the video category. JPEG falls into the stills. But what about RGB and YUV raw pixel formats?
The default imnplementation assumes that anything <= 720p is video, and above that is stills. From your report I suspect there may be a bug in asking for stills with fixed exposure, but I haven't got time to look into it at the moment.
As a workaround there are module parameters max_video_width and max_video_height that allow you to specify your own point to switch between video and stills. If you load the driver with "sudo modprobe bcm2835-v4l2 max_video_width=1920 max_video_height=1080" your YUYV frame will be judged to be a video mode and I expect will respond correctly to V4L2_CID_EXPOSURE_ABSOLUTE.

If it does fix it, you can create a file in /etc/modprobe.d with the contents

Code: Select all

options bcm2835-v4l2 max_video_width=1920
options bcm2835-v4l2 max_video_height=1080
to make the change automatic.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

y3egjsk
Posts: 5
Joined: Thu Oct 26, 2017 1:55 pm

Re: Official V4L2 driver

Thu Nov 16, 2017 3:50 pm

Thanks 6by9! The max_video_height and max_video_width did not make a difference in the behavior. You should know that with this problem, the image does respond throughout the range of V4L2_CID_EXPOSURE_ABSOLUTE, it is just that the exposure varies thru a much darker range. With my temporary set to h264, the image varies over a brighter range. When using 640x480 mode, things are brighter still, and my workaround is not needed.

It is very helpful to know that 720p (1280x720) is at the top of the default YUYV video threshold. This image is just as bright as the 640x480, and does not need any workaround, either the h264 I used, or the driver load parameters you mentioned.

Since this is for astrophotography, brightness and resolution are important. Switching to 1280x720 is big improvement. I appreciate your answer!

Steve

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

Re: Official V4L2 driver

Thu Nov 16, 2017 4:21 pm

y3egjsk wrote:
Thu Nov 16, 2017 3:50 pm
Thanks 6by9! The max_video_height and max_video_width did not make a difference in the behavior. You should know that with this problem, the image does respond throughout the range of V4L2_CID_EXPOSURE_ABSOLUTE, it is just that the exposure varies thru a much darker range. With my temporary set to h264, the image varies over a brighter range. When using 640x480 mode, things are brighter still, and my workaround is not needed.

It is very helpful to know that 720p (1280x720) is at the top of the default YUYV video threshold. This image is just as bright as the 640x480, and does not need any workaround, either the h264 I used, or the driver load parameters you mentioned.

Since this is for astrophotography, brightness and resolution are important. Switching to 1280x720 is big improvement. I appreciate your answer!
It sounds like we may have a typo then.
If you run "dmesg" to print out the kernel log, loading the V4L2 driver should have logged

Code: Select all

bcm2835-v4l2: V4L2 device registered as video0 - stills mode > 1920x1080
Having said that, playing with qv4l2(*), JPEG appears at 1280x720 appears to be giving a different image brightness to any of the raw image formats at that resolution. Switching up to 1280x960(**) (ie stills mode) appears to give similar results between the two. So something appears to be wrong there, but it'll require a fair amount of investigation to find out what.

I assume you are setting a low frame rate too if you want 1sec exposures. Either that or setting V4L2_CID_EXPOSURE_AUTO_PRIORITY so that AE is allowed to alter the frame rate as required.

(*) one of the standard V4L2 test apps available with apt-get. Uncheck "Use OpenGL Rendering" from the Capture menu to get it to work.
(**) Annoyingly you can't change resolution in qv4l2. Quit the app, run "v4l2-ctl -v width=1280,height=960" (or whatever resolution), and then rerun qv4l2 (remembering to disable OpenGL again).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

y3egjsk
Posts: 5
Joined: Thu Oct 26, 2017 1:55 pm

Re: Official V4L2 driver

Thu Nov 16, 2017 11:55 pm

Hi 6by9,
My script that starts my program always sets the frame rate to 1 fps before starting the application.
v4l2-ctl -p 1

The application is now set up to run at 1920x1080 (with the .h264 prelim setup), 1280x720, and at 640x480.
I will probably run at 1280x720, since this is somewhat brighter video than the 1920x1080.

sudo dmesg
The log shows
bcm2835-v4l2: V4L2 device registered as video - stills mode > 1280x720
sometimes the message shows stills mode > 1920x1080.
The value shown in the log doesn't seem to affect the behavior.
Doing things the same way after a reboot produces the same video characteristics, but sometimes different log messages.

Steve

Gearloose
Posts: 2
Joined: Wed Dec 27, 2017 10:03 pm

Re: Official V4L2 driver

Wed Jan 10, 2018 1:04 pm

Hello,

I'm trying to build a simple project to monitor (with the official camera) a room and also control some relays.
I've been trying for some time now to figure out how to feed the video to a web page hosted by the Raspberry Pi 3 (I'm using nginx).
The idia is to access the page form my mobile, view the video and/or control the relays status.

I tried the raspivid and, nc, raspvid and vlc with or without transcoding and now V4L2 with vlc without success.
I'm very sure I'm doing something wrong since I do not fully understand the encoding I need to use so it is more like trial and error based on the examples in forums.

How could I feed the video in a format stream-able from http?
Do you have any working example?

Thank you!

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

Re: Official V4L2 driver

Wed Jan 10, 2018 3:34 pm

Gearloose wrote:
Wed Jan 10, 2018 1:04 pm
Hello,

I'm trying to build a simple project to monitor (with the official camera) a room and also control some relays.
I've been trying for some time now to figure out how to feed the video to a web page hosted by the Raspberry Pi 3 (I'm using nginx).
The idia is to access the page form my mobile, view the video and/or control the relays status.

I tried the raspivid and, nc, raspvid and vlc with or without transcoding and now V4L2 with vlc without success.
I'm very sure I'm doing something wrong since I do not fully understand the encoding I need to use so it is more like trial and error based on the examples in forums.

How could I feed the video in a format stream-able from http?
Do you have any working example?

Thank you!
Please start a new thread - you're likely to get little attention buried on page 21 of a generic thread.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

mrtom31
Posts: 3
Joined: Sat Mar 31, 2018 4:38 pm

Re: Official V4L2 driver

Sat Mar 31, 2018 5:13 pm

Hi,

I tried to install v4l2 with commands from post and installation failed:

Code: Select all

autoreconf -vfi

configure.ac:79: installing 'build-aux/missing'
contrib/cobalt-ctl/Makefile.am: installing 'build-aux/depcomp'
autoreconf: automake failed with exit status: 1

phill54
Posts: 3
Joined: Thu Feb 07, 2013 7:56 am

Re: Official V4L2 driver

Tue Apr 24, 2018 9:09 am

Code: Select all

[email protected]:~ $ sudo apt-get install autoconf gettext libtool libjpeg62-dev
[sudo] password for phill54:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libjpeg62-dev : Depends: libjpeg62 (= 1:6b2-2)
E: Unable to correct problems, you have held broken packages.
so i tried "libjpeg-dev" instead of "libjpeg62-dev", and the installer reported no problem
then:

Code: Select all

[email protected]:~/v4l-utils $ autoreconf -vfi
autoreconf: Entering directory `.'
[...]
configure.ac:88: installing 'build-aux/config.guess'
configure.ac:95: error: required file 'build-aux/config.rpath' not found
[...]
contrib/cobalt-ctl/Makefile.am: installing 'build-aux/depcomp'
autoreconf: automake failed with exit status: 1
So, how do i fix this? :-) Thanks for the help.
btw, i'm on

Code: Select all

[email protected]:~/v4l-utils $ uname -r
4.14.34-v7+

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

Re: Official V4L2 driver

Tue Apr 24, 2018 9:20 am

Are you following the first post verbatim, having skipped the first line
EDIT: the default kernel includes v4l2 driver and the latest raspbian image includes the v4l2 utilities (like v4l2-ctl) so the initial steps can be skipped. Skip forward to the modprobe line.
"sudo apt install v4l-utils" will get you a recent enough version of all the tools.

If you really want to build from source, then things have changed slightly in the 4 years since the first post. Read the README file in the v4l-utils repo as it includes the full build steps - https://git.linuxtv.org/v4l-utils.git/tree/README#n23
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

lkt
Posts: 5
Joined: Sun May 06, 2018 5:42 pm

Re: Official V4L2 driver

Fri May 18, 2018 8:52 pm

Is there any way to set the quantisation parameter with this? (-qp on raspivid)

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

Re: Official V4L2 driver

Sat May 19, 2018 4:57 pm

lkt wrote:
Fri May 18, 2018 8:52 pm
Is there any way to set the quantisation parameter with this? (-qp on raspivid)
Not currently, but it looks like V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP, V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP, V4L2_CID_MPEG_VIDEO_H264_MIN_QP, and V4L2_CID_MPEG_VIDEO_H264_MAX_QP (see https://www.linuxtv.org/downloads/v4l-d ... -reference) may offer an option to implement them.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

zim
Posts: 3
Joined: Wed Aug 01, 2018 4:19 pm

Re: Official V4L2 driver

Wed Aug 01, 2018 4:32 pm

Hi all,

I've started interacting with my new PiNoIR camera v2 using the v4l2 C API, and I must say that until now it's a bit of a let-down.

First I queried the device capabilities, and it's telling me that I can capture in RGB3 or BGR3 format in any resolution from 32x32 up to 3280x2464 with a step-size of 2. So far so good. But each time I try to set the pixel format with VIDIOC_S_FMT ioctl, I get error 22 (Invalid argument). This was at a resolution of 32x32. I kept hitting my head against a wall and tried with many other formats, and only 2-3 seemed to work (MJPEG and NV21 I think). Finally I tried with a different resolution, and at 320x240, I managed to set the format to RGB4, but the buffer isn't filled correctly (using mmapped io). Anyway, some wasted time later I tried 1024x1024, and didn't get the error anymore, but my program hangs when trying to stream. Finally, when setting it to 1920x1080, I'm able to actually capture images and write them to files, but the resolution if far too large for my intentions.

Questions:
- Can any of the device capabilities reported by the v4l2 driver for bcm2835 actually be trusted, especially concerning resolutions available?
- How can I capture a 320x240 image (or similar size) in BGR3, RGB3 or similar format using v4l2? Is it even possible? Or will I need to convert needlessly from JPEG each time?

I'd be really glad if anyone can help me with these problems.

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

Re: Official V4L2 driver

Sun Aug 05, 2018 1:37 pm

zim wrote:
Wed Aug 01, 2018 4:32 pm
Hi all,

I've started interacting with my new PiNoIR camera v2 using the v4l2 C API, and I must say that until now it's a bit of a let-down.

First I queried the device capabilities, and it's telling me that I can capture in RGB3 or BGR3 format in any resolution from 32x32 up to 3280x2464 with a step-size of 2. So far so good. But each time I try to set the pixel format with VIDIOC_S_FMT ioctl, I get error 22 (Invalid argument). This was at a resolution of 32x32. I kept hitting my head against a wall and tried with many other formats, and only 2-3 seemed to work (MJPEG and NV21 I think). Finally I tried with a different resolution, and at 320x240, I managed to set the format to RGB4, but the buffer isn't filled correctly (using mmapped io). Anyway, some wasted time later I tried 1024x1024, and didn't get the error anymore, but my program hangs when trying to stream. Finally, when setting it to 1920x1080, I'm able to actually capture images and write them to files, but the resolution if far too large for my intentions.

Questions:
- Can any of the device capabilities reported by the v4l2 driver for bcm2835 actually be trusted, especially concerning resolutions available?
Yes, all the resolutions should be available.
It does lie on the framerate achievable as there are too many permutations available. The Pi camera is not as simple as most USB cameras in that there are multiple processing steps involved, and some are less optimised than others.
zim wrote: - How can I capture a 320x240 image (or similar size) in BGR3, RGB3 or similar format using v4l2? Is it even possible? Or will I need to convert needlessly from JPEG each time?

Code: Select all

v4l2-ctl -v width=320,height=240,pixelformat=RGB3
v4l2-ctl --stream-mmap=3 --stream-count=100 --stream-to=file.rgb
Should save you a file that is a concatenation of 100 rgb images.
Have a look in the dmesg logs to see what it's complaining about if S_FMT is failing.

Please confirm which distribution and kernel you are running. "uname -a" and "cat /etc/os-release". If other than Raspbian with a 4.14 kernel then you're a little on your own. I have a bundle of updates coming, and I think there is a minor regression on the latest mainline kernel.

You don't say in what way you believe the buffer is not filled correctly, but you MUST also abide by the bytesperline value returned by the driver. It may not be width * bpp as the GPU has other requirements on the stride of the image (normally a multiple of 32 pixels). There's also a vertical padding requirement so sizeimage may well be greater than bytesperline * height.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

zim
Posts: 3
Joined: Wed Aug 01, 2018 4:19 pm

Re: Official V4L2 driver

Tue Aug 07, 2018 12:32 am

Hi 6by9,
Thanks for your answer and sorry for not providing more information. The error I'm encountering may be due to the fact that I'm using ArchLinux ARM instead of Raspbian. I'm on 4.14.59-1-ARCH and the dmesg log reads

Code: Select all

bcm2835-v4l2: vidioc_s_fmt_vid_cap: failed to setup mmal components: -3
This is the content of /boot/config.txt:

Code: Select all

gpu_mem=256
start_file=start_x.elf
fixup_file=fixup_x.dat
disable_camera_led=1
initramfs initramfs-linux.img followkernel
Here's just the code needed to trigger the error. When I change "RGB3" to "JPEG", the ioctl succeeds and I can capture images.

Code: Select all

#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/videodev2.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

const uint32_t WIDTH = 320;
const uint32_t HEIGHT = 240;

static int xioctl(int fd, int request, void *arg) {
    int r;
    do {
        r = ioctl (fd, request, arg);
    } while (-1 == r && EINTR == errno);

    return r;
}

static uint32_t encode_four_cc(const char *input) {
    return   (uint32_t)(input[0])
           | (uint32_t)(input[1]) << 8
           | (uint32_t)(input[2]) << 16
           | (uint32_t)(input[3]) << 24;
}

int main(int argc, char **argv) {
    const char *device = "/dev/video0";
    int fd = open(device, O_RDWR);
    if (fd < 0) {
        perror("open\n");
        exit(EXIT_FAILURE);
    }

    printf("Opened device \"%s\"\n", device);

    struct v4l2_format format = {
        .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
        .fmt.pix.pixelformat = encode_four_cc("RGB3"),
        .fmt.pix.width = WIDTH,
        .fmt.pix.height = HEIGHT
    };

    if (xioctl(fd, VIDIOC_S_FMT, &format) < 0) {
        perror("VIDIOC_S_FMT\n");
        exit(EXIT_FAILURE);
    }
    
    exit(EXIT_SUCCESS);
}
Please let me know if you have any idea, otherwise I'll make do with converting from JPEG for the time being.

EDIT: I get exactly the same error when I run this command:

Code: Select all

v4l2-ctl -v width=320,height=240,pixelformat=RGB3

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

Re: Official V4L2 driver

Tue Aug 07, 2018 9:34 am

OK, we do have a regression. YU12, YV12, NV12, and NV21 are all working, but anything that has a stride > width is failing.
I'd put in a mod recently to try and relax the alignment requirements, and it looks to be the candidate for failure.

If you revert the firmware to the version released on July 11th then that was the last one before my changes. Meanwhile I'll investigate what's gone wrong.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

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

Re: Official V4L2 driver

Tue Aug 07, 2018 9:52 am

That was an easy, but annoying, one. Two clauses in an if/else. I'd updated one but not the other.
I don't know when the next rpi-update is going to be done, but the fix should be in there. I'll be doing some more testing in the meantime.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

zim
Posts: 3
Joined: Wed Aug 01, 2018 4:19 pm

Re: Official V4L2 driver

Tue Aug 07, 2018 2:37 pm

Thank you for looking into it, and nice to know that there is a fix coming along!

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 7 guests