-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bcm2835-camera.c: bug in timestamp computation #1318
Comments
That does look quirky to say the least. Running some dummy numbers through I think I agree with you. I think they were trying to handle one of the arithmetic wrapping conditions (handling secs and usecs is awkward - kernel 4.5 switches to raw usecs), but have got it wrong. Lines 368-372 do it properly. If you could enable the debug logging(*) and provide a sample set of the log lines from line 374 ("Convert start time....") then I'd be happier to confirm it with that. Otherwise I'll try it for myself tonight. (*) load with "sudo modprobe bcm2835-v4l2 debug=1", or there's a kernel parameter under /sys that you can modify but I can never remember the path to it. |
Here's the output:
If you add the GPU offset, it's fairly obvious that the computed time is After adding back the second, the timestamp would actually reflect when the start of frame interrupt is received by the GPU (captured by BTW, I did a grep of https://github.com/raspberrypi/linux/blob/rpi-4.1.y/drivers/media/usb/uvc/uvc_video.c#L679 |
Agreed with both your debug and patch. Happy to approve a PR for it. Quite plausibly that code was copied from UVC - it looks like it was me who added that code, but I have no memory of it. It was November 2013! PTS from the GPU is from the frame start interrupt, so 29ms sound pretty reasonable for VGA. It'll take 23ms to get the rest of the frame in as the mode runs at a max of 42fps, so I'm quite chuffed at only another 6ms to get the frame completed and shipped across to the kernel. |
kernel: bcm2835-camera: fix a bug in computation of frame timestamp See: raspberrypi/linux#1318 kernel: BCM270X_DT: Add pi3-disable-bt overlay
kernel: bcm2835-camera: fix a bug in computation of frame timestamp See: raspberrypi/linux#1318 kernel: BCM270X_DT: Add pi3-disable-bt overlay
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown raspberrypi#817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes raspberrypi#1318 V4L2 driver updates (raspberrypi#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO raspberrypi#1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 raspberrypi#1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: raspberrypi#1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown #817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes #1318 V4L2 driver updates (#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO #1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 #1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: #1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown raspberrypi#817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes raspberrypi#1318 V4L2 driver updates (raspberrypi#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO raspberrypi#1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 raspberrypi#1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: raspberrypi#1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown raspberrypi#817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes raspberrypi#1318 V4L2 driver updates (raspberrypi#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO raspberrypi#1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 raspberrypi#1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: raspberrypi#1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown raspberrypi#817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes raspberrypi#1318 V4L2 driver updates (raspberrypi#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO raspberrypi#1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 raspberrypi#1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: raspberrypi#1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown raspberrypi#817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes raspberrypi#1318 V4L2 driver updates (raspberrypi#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO raspberrypi#1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 raspberrypi#1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: raspberrypi#1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown raspberrypi#817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes raspberrypi#1318 V4L2 driver updates (raspberrypi#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO raspberrypi#1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 raspberrypi#1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: raspberrypi#1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown raspberrypi#817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes raspberrypi#1318 V4L2 driver updates (raspberrypi#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO raspberrypi#1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 raspberrypi#1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: raspberrypi#1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
- Supports raw YUV capture, preview, JPEG and H264. - Uses videobuf2 for data transfer, using dma_buf. - Uses 3.6.10 timestamping - Camera power based on use - Uses immutable input mode on video encoder Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Luke Diamand <[email protected]> V4L2: Fixes from 6by9 V4L2: Fix EV values. Add manual shutter speed control V4L2 EV values should be in units of 1/1000. Corrected. Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should give manual shutter control. Requires manual exposure mode to be selected first. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct JPEG Q-factor range Should be 1-100, not 0-100 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue of driver jamming if STREAMON failed. Fix issue where the driver was left in a partially enabled state if STREAMON failed, and would then reject many IOCTLs as it thought it was streaming. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix ISO controls. Driver was passing the index to the GPU, and not the desired ISO value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add flicker avoidance controls Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker avoidance frequencies. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for frame rate control. Add support for frame rate (or time per frame as V4L2 inverts it) control via s_parm. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Improve G_FBUF handling so we pass conformance Return some sane numbers for get framebuffer so that we pass conformance. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix information advertised through g_vidfmt Width and height were being stored based on incorrect values. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for inline H264 headers Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to control H264 inline headers. Requires firmware fix to work correctly, otherwise format has to be set to H264 before this parameter is set. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix JPEG timestamp issue JPEG images were coming through from the GPU with timestamp of 0. Detect this and give current system time instead of some invalid value. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix issue when switching down JPEG resolution. JPEG buffer size calculation is based on input resolution. Input resolution was being configured after output port format. Caused failures if switching from one JPEG resolution to a smaller one. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable MJPEG encoding Requires GPU firmware update to support MJPEG encoder. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct flag settings for compressed formats Set flags field correctly on enum_fmt_vid_cap for compressed image formats. Signed-off-by: Dave Stevenson <[email protected]> V4L2: H264 profile & level ctrls, FPS control and auto exp pri Several control handling updates. H264 profile and level controls. Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to select whether AE is allowed to override the framerate specified. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Correct BGR24 to RGB24 in format table Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add additional pixel formats. Correct colourspace Adds the other flavours of YUYV, and NV12. Corrects the overlay advertised colourspace. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Drop logging msg from info to debug Signed-off-by: Dave Stevenson <[email protected]> V4L2: Initial pass at scene modes. Only supports exposure mode and metering modes. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add manual white balance control. Adds support for V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE. Only has an effect if V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has V4L2_WHITE_BALANCE_MANUAL selected. Signed-off-by: Dave Stevenson <[email protected]> config: Enable V4L / MMAL driver V4L2: Increase the MMAL timeout to 3sec MJPEG codec flush is now taking longer and results in a kernel panic if the driver has stopped waiting for the result when it finally completes. Increase the timeout value from 1 to 3secs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for setting H264_I_PERIOD Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD to set the frequency with which I frames are produced. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Enable GPU function for removing padding from images. GPU can now support arbitrary strides, although may require additional processing to achieve it. Enable this feature so that the images delivered are the size requested. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for V4L2_PIX_FMT_BGR32 Signed-off-by: Dave Stevenson <[email protected]> V4L2: Set the colourspace to avoid odd YUV-RGB conversions Removes the amiguity from the conversion routines and stops them dropping back to the SD vs HD choice of coeffs. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Make video/still threshold a run-time param Move the define for at what resolution the driver switches from a video mode capture to a stills mode capture to module parameters. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Fix incorrect pool sizing Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add option to disable enum_framesizes. Gstreamer's handling of a driver that advertises V4L2_FRMSIZE_TYPE_STEPWISE to define the supported resolutions is broken. See bug https://bugzilla.gnome.org/show_bug.cgi?id=726521 Optional parameter of gst_v4l2src_is_broken added. If non-zero, the driver claims not to support that ioctl, and gstreamer should be happy again (it guesses a set of defaults for itself). Signed-off-by: Dave Stevenson <[email protected]> V4L2: Add support for more image formats Adds YVU420 (YV12), YVU420SP (NV21), and BGR888. Signed-off-by: Dave Stevenson <[email protected]> V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD Request to extend the range from the fairly arbitrary 1000 frames (33 seconds at 30fps). Extend out to the max range supported (int32 value). Also allow 0, which is handled by the codec as only send an I-frame on the first frame and never again. There may be an exception if it detects a significant scene change, but there's no easy way around that. Signed-off-by: Dave Stevenson <[email protected]> bcm2835-camera: stop_streaming now has a void return BCM2835-V4L2: Fix compliance test failures VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due to reporting V4L2_COLORSPACE_JPEG when the colour format wasn't V4L2_PIX_FMT_JPEG. Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats. bcm2835 camera planar/packed stride length Added a field to the mmal_fmt struct used to compute the bytes per line when using a particular format. This results in the correct stride being calculated even when the format is planar. Signed-off-by: Garrett Wilson <[email protected]> bcm2835: camera: check for scene not being found static analysis by cppcheck detected some potential NULL pointer dereference issues: [drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null pointer dereference: scene (and lines 858, 859 too) it is possible that scene is not found because of an invalue ctrl->val and is therefore NULL and hence causing a null pointer dereference. Signed-off-by: Colin Ian King <[email protected]> bcm2835: memcpy port data to m rather than rmsg static analysis by cppcheck detected a memcpy to rmsg which is not actually initialized at that point. The memcpy should be copying to variable m instead. Signed-off-by: Colin Ian King <[email protected]> BCM2835-V4L2: Return buffers to videobuf2 on shutdown raspberrypi#817 Fixes the kernel warning from videobuf2 as buffers are now returned as they are being flushed on stop_streaming. squash: Fixup bcm2835-camera for changes in kernel 4.4 api v4l2: Fix up driver to upstream timestamp changes bcm2835-camera: fix a bug in computation of frame timestamp Fixes raspberrypi#1318 V4L2 driver updates (raspberrypi#1393) * BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO raspberrypi#1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add a video_nr parameter. Adds a kernel parameter "video_nr" to specify the preferred /dev/videoX device node. https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=136120&p=905545 Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add support for multiple cameras Ask GPU on load how many cameras have been detected, and enumerate that number of devices. Only applicable on the Compute Module as no other device exposes multiple CSI2 interfaces. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Add control of the overlay location and alpha. Actually do something useful in vidioc_s_fmt_vid_overlay and vidioc_try_fmt_vid_overlay, rather than effectively having read-only fields. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: V4L2-Compliance failure fix VIDIOC_TRY_FMT was failing due to bytesperline not being set correctly by default. Signed-off-by: Dave Stevenson <[email protected]> * BCM2835-V4L2: Make all module parameters static Clean up to correct variable scope Signed-off-by: Dave Stevenson <[email protected]> V4L2: Request maximum resolution from GPU Get resolution information about the sensors from the GPU and advertise it correctly. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-V4L2: Increase minimum resolution to 32x32 raspberrypi#1498 showed up that 16x16 is failing to work on the GPU for some reason. GPU bug being tracked on raspberrypi/firmware#607 Workaround here by increasing minimum resolution via V4L2 to 32x32. Signed-off-by: Dave Stevenson <[email protected]> [media]: bcm2835-camera: fix compilation error There is an error when compiling rpi-4.6.y branch: CC [M] drivers/media/platform/bcm2835/bcm2835-camera.o drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .queue_setup = queue_setup, ^ drivers/media/platform/bcm2835/bcm2835-camera.c:639:17: note: (near initialization for 'bm2835_mmal_video_qops.queue_setup') The const void *parg in setup_queue callback is not needed since commit: df9ecb0. This commit removes it. Signed-off-by: Slawomir Stepien <[email protected]> bcm2835-camera: Fix max/min error when looping over cameras/resolutions See: raspberrypi#1447 (comment) BCM2835-V4L2: Correct handling for BGR24 vs RGB24. There was a bug in the GPU firmware that had reversed these two formats. Detect the old firmware, and reverse the formats if necessary. Signed-off-by: Dave Stevenson <[email protected]> BCM2835-v4l2: Fix a conformance test failure Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK warn: v4l2-test-formats.cpp(1195): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME. fail: v4l2-test-formats.cpp(1118): node->has_frmintervals && !cap->capability
I'm using the official raspberry pi camera (connected to CSI connector) with second gen rpi, and I'm using v4l2 API to capture a camera frame on demand. However, the timestamp assigned to the received camera frame buffer (
struct v4l2_buffer
) is consistently around ~900ms in the past. The requested frame resolution is 640x480.Digging through the camera driver, I noticed the following line, which tries to add the offset from the delay in capturing the frame from GPU:
https://github.com/raspberrypi/linux/blob/rpi-4.1.y/drivers/media/platform/bcm2835/bcm2835-camera.c#L362
Specifically,
I don't understand why
1
is being subtracted fromtv_sec
, and possibly explains the approx. 1 second delay in timestamp that I'm seeing. Can someone more familiar with the camera driver explain this? If this is a bug, the following patch should fix the issue (I can provide a pull request if needed):The text was updated successfully, but these errors were encountered: