Commit graph

2973 commits

Author SHA1 Message Date
Laurent Pinchart
d6e48e5e7c libcamera: pipeline: simple: Move converter to SimpleCameraData
To use multiple cameras at the same time, each camera instance will need
its own converter. Store the converter in SimpleCameraData, and open it
in init().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31 22:44:11 +03:00
Laurent Pinchart
8c9e1926b9 libcamera: pipeline: simple: Add pipeline pad reservation mechanism
The cameras created by the same pipeline handler instance may share
hardware resources, prohibiting usage of multiple cameras concurrently.
Implement a heuristic to reserve resources and handle mutual exclusiong
in a generic way.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31 22:44:11 +03:00
Laurent Pinchart
f69b19667f libcamera: pipeline: simple: Open all video devices at match() time
Move opening of video devices at match() time, the same way as subdevs
are opened, to make the handling of V4L2 video devices and subdevices
more consistent.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31 22:44:11 +03:00
Laurent Pinchart
2b31458763 libcamera: pipeline: simple: Store all entity devices in common map
Merge the SimplePipelineHandler videos_ and subdevs_ maps, which
respectively store V4L2 video devices and subdevices associated with
entities, into a single entities_ map that contains an EntityData
structure. This gathers all data about entities in a single place,
allowing for easy extension of entity data in the future.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31 22:44:11 +03:00
Laurent Pinchart
41a8f8a9cc libcamera: pipeline: simple: Store video node entity in camera data
Store the entity corresponding to the video node at the end of the
pipeline in the SimpleCameraData::entities_ list. This requires special
handling of the video node in the loops that iterate over all entities,
but will be useful to implement mutually exclusive access to entities
for concurrent camera usage.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31 22:44:11 +03:00
Laurent Pinchart
0e8d6903b2 libcamera: pipeline: simple: Delay opening of video device until init()
The video device is currently opened in the SimpleCameraData
constructor. This requires opening the video devices on-demand the first
time they're accessed, which gets in the way of refactoring of
per-entity data storage in the pipeline handler.

Move opening of the video device to the SimpleCameraData::init()
function. The on-demand open mechanism isn't touched yet, it will be
refactored later.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31 22:44:11 +03:00
Laurent Pinchart
0f65875baf libcamera: pipeline: simple: Add sink and source pads to entity data
Record the sink and source pads through which an entity is traversed in
the list of entities stored in the camera data. This prepares for
implementing mutually exclusive access to entities between cameras.

The debug message that displays detected pipelines now prints pads to
describe the pipeline more precisely:

[0:00:35.901275750] [260] DEBUG SimplePipeline simple.cpp:404 Found pipeline: [imx290 2-001a|0] -> [0|csis-32e40000.csi|1] -> [0|mxc_isi.0|1] -> [0|mxc_isi.0.capture]

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31 22:44:10 +03:00
Laurent Pinchart
a376aa331a libcamera: media_object: Expose entity type
Add a new field to the MediaEntity class to identify the type of
interface it exposes to userspace. The MediaEntity constructor is
changed to take a media_v2_interface pointer instead of just the device
node major and minor to have access to the interface type.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31 22:44:10 +03:00
Laurent Pinchart
2e4fc65f77 ipa: libipa: histogram: Fix typo
"weighted", derived from the verb "to weight", comes from Middle English
weight, weiȝte, weght, wight, from Old English wiht, ġewiht, from
Proto-Germanic *wihtiz, from Proto-Indo-European *weǵʰ-. In none of
those does the t come before the h.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-08-31 22:44:10 +03:00
Hirokazu Honda
75df3c7139 libcamera: mapped_framebuffer: Rename maps() to planes()
MappedFrameBuffer::maps() returns planes_. This renames the function
name to planes().

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-31 15:18:53 +03:00
Laurent Pinchart
1c877bd868 android: generic_camera_buffer: Fix bufferLength_ initialization
The bufferLength_ member variabled is checked to have a positive value
before being used, to catch usage before the variable is set. The
variable is initialized to zero at construction time, which renders the
checks useless.

Fix this by initializing the variable to -1 at construction time.

Fixes: c5e2ed7806 ("android: camera_buffer: Map buffer in the first plane() call")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-08-31 15:18:43 +03:00
Jacopo Mondi
88009711be android: Refuse Manual template if not supported
If the camera devices does not support the MANUAL_SENSOR capabilities
there is no point in generating a request template for the Manual
capture use case.

This change fixes CTS tests
android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceManualTemplate
android.hardware.camera2.cts.NativeCameraDeviceTest#testCameraDeviceCreateCaptureRequest

For devices that do not support MANUAL_SENSOR capabilities.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-31 12:09:35 +02:00
Umang Jain
5fc426fbfe ipu3: cio2: Tweak sensor size selection policy
Do not compare higher precision of the ratios, as it might lead to
absurd selection of sensor size for a relatively low requested
resolution size.

For example:
The imx258 driver supports the following sensor resolutions:

 - 4208x3118 = 1.349583066
 - 2104x1560 = 1.348717949
 - 1048x780  = 1.343589744

It can be inferred that, that the aspect ratio only differs by a small
mantissa with each other. It does not makes sense to select a 4208x3118
for a requested size of say 640x480 or 1280x720, which is what is
happening currently.
($) cam -c1 -swidth=640,height=480,role=raw
    - CIO2 configuration: 4208x3118-SGRBG10_IPU3 [*]

In order to address this constraint, only compare the ratio with single
precision to make a better decision on the sensor resolution policy
selection.

($) cam -c1 -srole=raw,width=640,height=480
    - CIO2 configuration: 1048x780-SGRBG10_IPU3 [*]

[*] Please revert 0536a9aa7189("ipu3: Disallow raw only camera configuration")
    if the configuration is reported as invalid.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-31 12:39:50 +05:30
Umang Jain
58b053c021 ipu3: cio2: Change sensor size selection policy
The current implementation of getSensorFormat() prioritizes sensor
sizes that match the output size FOV ratio.

Modify the frame size selection procedure to prioritize resolutions
with the same FOV as the sensor's native one, to avoid cropping in the
sensor pixel array.

For example:

- on a Soraka device equipped with ov13858 as back sensor, with a
  native resolution of 4224x3136 (4:3), when requested to select the
  sensor output size to produce 1080p (16:9) a frame size of 2112x1188
  (16:9) is selected causing the ImgU configuration procedure to fail.
  If a resolution with the same FOV as the sensor's native size, such
  as 2112x1568 (4:3), is selected the pipeline works correctly.

Suggested-by:: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-31 12:27:02 +05:30
Umang Jain
fd9068ce44 ipu3: cio2: Replicate CameraSensor::getFormats() to a member function
This prepares a base to introduce custom selection of sensor format
based on platform(Soraka or Nautilus) constraints. The changes in
selection policy will be introduced in a subsequent patch.

The function is copied from CameraSensor::getFormat() in the IPU3
pipeline handler code to be later changed on top.

The copy is not verbatim and has a minor change as follows:
CameraSensor::getFormats() has access to a V4L2Subdevice::Formats
internally and use it directly to iterate over supported camera sensor
frame sizes. The copy is adapted to use the CameraSensor::sizes(mbusCode)
instead, to enumerate over the supported frame sizes as per
mbusCodesToPixelFormat map.

No functional changes in this patch.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-31 12:26:58 +05:30
Umang Jain
a18c9f0490 libcamera: camera_sensor: Transform CameraSensor::sizes()
In CameraSensor, the mbusCodes() and sizes() accessor functions
retrieves all the supported media bus codes and the supported sizes
respectively. However, this is quite limiting since the caller
probably isn't in a position to match which range of sizes are
supported for a particular mbusCode.

Hence, the caller is most likely interested to know about the sizes
supported for a particular media bus code. This patch transforms the
existing CameraSensor::sizes() to CameraSensor::sizes(mbuscode) to
achieve that goal.

The patch also transforms existing CIO2Device::sizes() in IPU3 pipeline
handler to CIO2Device::sizes(PixelFormat) on a similar principle. The
function is then plumbed to CameraSensor::sizes(mbusCode) to enumerate
the per-format sizes as required in
PipelineHandlerIPU3::generateConfiguration().

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-31 12:26:54 +05:30
Hirokazu Honda
887dbdb439 libcamera: framebuffer: Add assertion to detect offset is unfilled
The offset variable is introduced to FrameBuffer::Plane. In order to
detect that the plane is used while the offset is not set, this adds
the assertion to FrameBuffer::planes(). It should be removed in the
future.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-30 18:59:10 +03:00
Hirokazu Honda
dde91916f1 android: camera_device: Fill offset and right length in CreateFrameBuffer()
CameraDevice::CreateFrameBuffer() fills the length of the buffer to
each FrameBuffer::Plane::length. It should rather be the length of
plane. This also changes CreateFrameBuffer() to fill offset of
FrameBuffer::Plane.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-30 18:59:10 +03:00
Hirokazu Honda
94fb6b2f4d libcamera: v4l2_videodevice: Create color-format planes in createBuffer()
V4L2VideDevice::createBuffer() creates the same number of
FrameBuffer::Planes as V4L2 format planes. Therefore, if the v4l2 format
single is single-planar format, the created number of
FrameBuffer::Planes is 1. It should rather create the same number of
FrameBuffer::Planes as the color format planes.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-30 18:58:36 +03:00
Hirokazu Honda
e5e7cdf701 gstreamer: gstlibcameraallocator: Use offset in creating a buffer
The plane length is the length of the plane size. The buffer length
to be allocated for a plane is the offset and the length of
FrameBuffer::Plane.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-30 18:08:02 +03:00
Hirokazu Honda
1d2263dd3d qcam: main_window: Use offset mapping FrameBuffer
FrameBuffer::Plane has offset info now. This uses the offset
in mapping FrameBuffer in MainWindow.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-30 18:08:02 +03:00
Hirokazu Honda
73994ec6bc ipa: rkisp1: Use offset in mapping IPABuffer
IPABuffer is represented by FrameBuffer. FrameBuffer::Plane has
now an offset. This uses the offset variable to map the IPABuffer.
The mapped IPABuffer is represented and managed as MappedFrameBuffer.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-30 18:08:02 +03:00
Hirokazu Honda
470513b6a7 cam: file_sink: Use offset in mapping FrameBuffer
This fixes the way of mapping FrameBuffer in FrameSink by
using offset.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-30 18:08:02 +03:00
Hirokazu Honda
8708904fad libcamera: mapped_framebuffer: Return plane begin address by MappedBuffer::maps()
MappedBuffer::maps() returns std::vector<MappedBuffer::Plane>.
Plane has the address, but the address points the beginning of the
buffer containing the plane.
This makes the Plane point the beginning of the plane. So
MappedBuffer::maps()[i].data() returns the address of i-th plane.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-30 18:08:02 +03:00
Hirokazu Honda
86a47fdcd9 libcamera: framebuffer: Add offset to FrameBuffer::Plane
This adds offset to FrameBuffer::Plane. It enables representing frame
buffers that store planes in the same dmabuf at different offsets, as
for instance required by the V4L2 NV12 pixel format.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-30 18:08:02 +03:00
Laurent Pinchart
a000a1f6e3 package: gentoo: Select build type through debug USE flag
Make the build type selectable between debug and plain through the debug
USE flag.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-28 00:30:06 +03:00
Laurent Pinchart
c352419371 package: gentoo: Add USE flags to build documentation and tests
Add two new use flags, doc and test, to select building of documentation
and tests instead of unconditionally disabling them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-28 00:30:05 +03:00
Laurent Pinchart
90b09f1892 package: gentoo: Add dependencies on openssl and gnutls
The libcamera build system requires openssl to sign IPA modules, and
gnutls is required at runtime to verify signatures. Add dependencies to
both.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-28 00:30:05 +03:00
Laurent Pinchart
bc78feb5d8 package: gentoo: Update Python versions
The Gentoo Python3 supported versions are now 3.6 to 3.10. Update the
package accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-28 00:30:05 +03:00
Laurent Pinchart
605b58efb1 utils: checkstyle.py: Use single-quoted strings when possible
checkstyle.py uses single-quoted strings in most locations already.
There are a few locations where this wouldn't be convenient (when the
string itself contains a single quote, which would then require
escaping), but there are also a few other locations where double quotes
are used when single quotes would work fine. Change those to standardize
on single-quoted strings.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-27 19:26:03 +03:00
Kieran Bingham
d1cdaeb6f0 clang-format: Remove unsupported option
The CaseSensitive option requires clang-format 12 which is not widely
available.

Remove the option, to fix clang-format uses until a solution which
supports clang-format version specific configurations can be merged.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-27 14:04:21 +01:00
Kieran Bingham
183c834b93 Documentation: Explicitly enable Dot
The dot package is identified as a required package for the Documentation, and
already marked as a required dependency with meson.

If meson can not find 'dot', then the documentation will not be built,
so we can explicitly enable it in our Doxyfile.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-27 14:03:47 +01:00
Kieran Bingham
3fc1d1ed51 Documentation: Remove obsoleted config
The CLASS_DIAGRAMS option has become obsolete, and we already define the
default value.

Remove it.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-27 14:03:47 +01:00
Kieran Bingham
b1d818beb4 base: class: Remove undesired semi-colon from LIBCAMERA_O_PTR
The LIBCAMERA_O_PTR() define adds the ';' at the end of the
templated call to _o().

While this works for the only current user in camera_manager.cpp, even
the statement there adds another semi-colon following it.

The addition of the semi-colon in the define unnecessarily prohibits the
macro from being used in places other than the end of a statement.

Remove it.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-27 11:55:05 +01:00
Jacopo Mondi
643cc403fe libcamera: camera configuration: Add at() function in doc
The documentation suggests to use CameraConfiguration::operator[] to
access the StreamConfiguration it contains, but as CameraConfiguration
instances are generated by the Camera class and are returned wrapped in
a unique_ptr<>, the usage of operator[] would require an awkward syntax such
as (*config)[i].

Better to suggest the usage of the CameraConfiguration::at() function
instead to access the StreamConfigurations.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-27 09:49:16 +02:00
Hirokazu Honda
6453e75c7a android: camera_buffer: Add stride/offset/size function
This adds getter functions of stride, offset and size to CameraBuffer
interface.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-27 00:52:32 +03:00
Hirokazu Honda
c5e2ed7806 android: camera_buffer: Map buffer in the first plane() call
CameraBuffer implementation maps a given buffer_handle_t in
constructor. Mapping is redundant to only know the plane info like
stride and offset. Mapping should be executed later in the first
plane() call.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-27 00:52:11 +03:00
Hirokazu Honda
7bfe7d7056 android: generic_camera_buffer: Correct buffer mapping
buffer_handle_t doesn't provide sufficient info to map a buffer
properly. cros::CameraBufferManager enables handling the buffer on
ChromeOS, but no way is provided for other platforms.

Therefore, we put the assumption that planes are in the same buffer
and they are consecutive. This modifies the way of mapping in
generic_camera_buffer with the assumption.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-27 00:51:56 +03:00
Nicolas Dufresne
be05f8d1da gstreamer: Fix usage of default size for fixation
Pipeline managers sets a default value to StreamConfiguration::size. The
original fixation code was attempting to use it, but as it was truncating
the caps to its first structure it would never actually find a best match.

In this patch, instead of truncating, we weight various matches using the
product of the width and height delta. We also split delta from ranges
apart and prefer fixed size over them as ranges are not reliable.

This patch also removes the related todo, as it seems that libcamera core
won't go further then providing this default value and won't be sorting the
format and size lists.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-26 16:51:18 +01:00
Nicolas Dufresne
d3be776654 libcamerasrc: Fix deadlock on EOS
It's not allowed in GStreamer to push events while holding the object
lock. This reduce the scope into which we hold the object lock. In
fact we don't need to protect against gst_task_resume() concurrency
when we stop the task as resume only do something if the task is paused.

This fixes a deadlock when running multiple instances of libcamerasrc
and closing one of the streaming window.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-26 16:42:54 +03:00
Nicolas Dufresne
9c49106b97 gstreamer: Fix concurrent access issues to CameraManager
It's not allowed to have multiple instances of CameraManager. This
requirement is not easy for GStreamer were the device monitor and
the camerasrc, or two camerasrc instances don't usually have any
interaction between each other. Fix this by implementing a minimalist
singleton around CameraManager constructor and start()/stop()
operations.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-26 16:42:52 +03:00
Nicolas Dufresne
1ca5513396 gstreamer: Fix deadlock when last allocator ref is held by buffer
This deadlock occurs when a buffer is holding the last reference on
the allocator. In gst_libcamera_allocator_release() we must drop the
object lock before dropping the last ref of that object since the
destructor will lock it again causing deadlock.

This was notice while switching camera or resolution in Cheese software.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-26 16:42:35 +03:00
Vedant Paranjape
af1f731f47 test: gstreamer: Disable gstreamer registry forks
ASan needs to be loaded first before gstreamer is loaded. This was not
possible, so verify_asan_link_order was disabled. Better way to tackle
this issue was disabling forks on the gstreamer side.

verify_asan_link_order=0 disables the check on ASan side which checks if
ASan was loaded before any other shared objects. Since, gstreamer spawns
a child helper process while building the registry, we needed to disable
this check. But with gst_registry_fork_set_enabled() it is possible to
disable spawning this child helper process, so this ensures that ASan is
loaded before any other shared object is loaded.

Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-26 16:36:14 +03:00
Vedant Paranjape
dac58fdd2a test: gstreamer: Clean up memory management
This patch simplifies memory management, i.e., by replacing bare
pointers with g_autoptr or g_autofree according to use case.

While at it also update time representation of timeout variable with
GST_SECOND.

Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-26 16:36:14 +03:00
Kieran Bingham
e89d8c7e50 Documentation: application-developer: Fix up spelling error
Fix a minor spelling error.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-25 21:35:03 +01:00
Kieran Bingham
6b9645d894 Documentation: application-developer: Fix reference to cam BufferWriter
The BufferWriter class has been replaced by the FileSink.

Adapt the reference, to match the source code.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-25 21:35:03 +01:00
Kieran Bingham
e590ca3004 Documentation: application-developer: Recommend unique_ptr for CameraManager
The CameraManager object should be deleted when it is no longer used to
prevent it from leaking.

When the application closes, the memory will be released, but it would
show up in reports from memory validation tools such as valgrind if not
handled correctly.

Recommend best-practices in the guide and ensure it is automatically
cleaned up when the CameraManager goes out of scope.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-25 21:35:03 +01:00
Kieran Bingham
d2783171dd Documentation: application-developer: Clean up build instructions
The build and run instructions read as if meson is the only way to
compile the application. Although this is recommended, it is not
required - adapt the language to fit better.

While here, fix the naming of the simple_cam meson object to match
the other usages of 'simple-cam'.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-25 21:35:03 +01:00
Kieran Bingham
fe8b72a595 Documentation: application-developer: Remove irrelevant TODO
This TODO has no real meaning, and isn't an action. Remove it.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-25 21:35:03 +01:00
Kieran Bingham
5c624e5561 README.rst: Update gstreamer element guidance
The Gstreamer gstlibcamerasrc element operates better with the
glimagesink, as it can perform direct renders or hardware accellerated
image format conversion.

Further extend the sample commands to demonstrate how to specify a fixed
width and height parameter to the pipeline.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-25 21:34:50 +01:00