Commit graph

1707 commits

Author SHA1 Message Date
Niklas Söderlund
75a9aebee5 libcamera: pipelines: Use sensor ID as camera name
Use the CameraSensor ID as the camera name in pipelines that uses a
CameraSensors, this is done in preparation of turning the camera name
into an ID. The CameraSensor ID meets the requirements that will be put
on camera ID.

Before this change example of camera names:

* OF based systems
    ov5695 7-0036
    ov2685 7-003c

* ACPI based systems
    ov13858 8-0010
    ov5670 10-0036

* VIMC
    VIMC Sensor B

After this change the same cameras are:

* OF based systems
    /base/i2c@ff160000/camera@36
    /base/i2c@ff160000/camera@36

* ACPI based systems
    \_SB_.PCI0.I2C2.CAM0
    \_SB_.PCI0.I2C4.CAM1

* VIMC
    platform/vimc.0 Sensor B

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 20:07:13 +02:00
Niklas Söderlund
082a5b2dfe libcamera: camera_sensor: Add accessors for sensor ID
Add an accessors so that the sensor ID can be used outside CameraSensor.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 20:07:13 +02:00
Niklas Söderlund
f23e6127ad libcamera: camera_sensor: Generate a sensor ID
The ID is generated from information in the firmware description of the
sensor if available or from module and model information if the sensor
is virtual (for example VIMC).

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-05 20:07:13 +02:00
Niklas Söderlund
1869d1b312 libcamera: v4l2_device: Add method to lookup device path
Add a method to lookup a V4L2 devices path in sysfs.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 20:07:13 +02:00
Niklas Söderlund
39efe73774 libcamera: sysfs: Add helper to lookup device firmware node path
A system's firmware description is recorded differently in sysfs
depending if the system uses DT or ACPI. Add a helper to abstract
this, allowing users not to care which of the two are used.

For DT-based systems, the path is the full name of the DT node that
represents the device. For ACPI-based systems, the path is the absolute
namespace path to the ACPI object that represents the device. In both
cases, the path is guaranteed to be unique and persistent as long as the
system firmware is not modified.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-05 20:07:13 +02:00
Niklas Söderlund
6ad3258cd3 libcamera: sysfs: Add helper to lookup sysfs path of a character device
Add a helper function to lookup the sysfs path of a character device.
Store the function in a new libcamera::sysfs namespace as there is not
class to host it.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 20:07:13 +02:00
David Plowman
79a834f24c libcamera: ipa: raspberrypi: ALSC: Improve behaviour when camera mode changes
Now that we stop the asynchronous thread on a SwitchMode, we would do
better to regenerate all the tables if the new camera mode crops in a
significantly different way to the old one. A few minor tweaks make
sense along with this:

* Reset the lambda values when we reset everything. It wouldn't make
  sense to re-start with the old mode's values.

* Use the last recorded colour temperature to generate new tables rather
  than any default value.

* Set the frame "phase" counter to ensure the adaptive procedure will
  run asap.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2020-08-05 17:49:00 +03:00
David Plowman
7f6b9121cc libcamera: ipa: raspberrypi: ALSC: Resample luminance table
This fixes a bug where the luminance correction table was not being
resampled according to the camera mode, in the same way as the colour
tables. This could be noticeable if any camera modes crop
aggressively.

This resampling can be done "up front" in the SwitchMode, as we have
only a single fixed luminance table. In order to protect the
recalculation of the table from the asynchronous thread (which reads
it) I've elected to wait for that thread to go idle (though I doubt it
would have mattered much). As a by-product of stopping the thread, it
no longer needs its own copy of the camera mode (async_camera_mode_).

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-05 17:48:55 +03:00
David Plowman
db552b0b92 libcamera: ipa: raspberrypi: ALSC: Improve locking in a few places
Fix up a few locations where we call notify_one() with the lock
held. In particular, restartAsync does not need to be called with the
lock held for its entire duration.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-05 17:48:55 +03:00
David Plowman
3a680a667f libcamera: ipa: raspberrypi: ALSC: Camera mode does not need to be atomic
In the libcamera framework, SwitchMode (which overwrites the
camera_mode) cannot run concurrently with Prepare (which uses it).

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-05 17:48:55 +03:00
Jacopo Mondi
09b1d0fced android: camera_device: Fix preview template
Add 5 controls to the generate preview template to comply with the
camera3 specification.

This change fixes CTS 9.0.r12 test:
android.hardware.camera2.cts.CameraDeviceTest#testCameraDevicePreviewTemplate

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 14:36:44 +02:00
Jacopo Mondi
8a02d4451c android: camera_device: Break-out request template
Currently the request template returned from
CameraDevice::constructDefaultRequestSettings() is the same for all
the supported template types.

To prepare to adjust the template depending on the use case, break out
the template generation to a dedicated function that supports the
PREVIEW use case. All the other template types use the
requestTemplatePreview() function and just update the capture intent
property.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 14:33:52 +02:00
Jacopo Mondi
29b59a9146 android: camera_metadata: Add method to update an entry
Add a method to update an existing metadata tag entry, by wrapping
the update_metadata_entry() function provided by the Android
metadata library.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 14:33:52 +02:00
Jacopo Mondi
3efc7e8834 andrdid: camera_device: Store const templates
The request capture templates stored in the
CameraDevice::requestTemplates_ should not be modified once created.

Store a const pointer to the request templates in the class member
map.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 14:33:52 +02:00
Jacopo Mondi
f2d19266a4 android: camera_metadata: Add const version of get()
Add a const version of the CameraMetadata::get() method to retrieve
a const pointer to the camera metadata wrapped by the class instance.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 14:33:52 +02:00
Jacopo Mondi
17a21b095a android: camera_metadata: Mark isValid() as const
The CameraMetadata::isValid() method does not modify the object state
and can be called on const instances of the CameraMetadata class.

Mark the method as const to allow that.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 14:33:52 +02:00
Niklas Söderlund
1074604c9e cam: Use the common cleanup function on failure
The different error paths in init() are out of sync. Instead of fixing
them switch to using the cleanup() function which does the right thing
for all cases.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2020-08-05 13:01:13 +02:00
Jacopo Mondi
375fef72f8 libcamera: ipu3: Fix compilation issues with gcc5
GCC5 does not provide prototypes for the math library functions defined
in the math.h header for the std:: namespace.

Include the C++ <cmath> header in place of <math.h> as it defines
overloads for the std::abs and std::fmod function.

This goes intentionally against the libcamera coding guidelines, and
is reported as warning by checkpatch.py.

Fixes: 968ab9bad0 ("libcamera: ipu3: imgu: Calculate ImgU pipe configuration")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 09:10:53 +02:00
Niklas Söderlund
7876d631d9 android: camera_device: Report RAW capability if supported
Probe the libcamera Camera for RAW support and if supported report RAW
capability in the static metadata reported to Android.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 23:44:09 +02:00
Niklas Söderlund
d4de037a8a android: camera_device: Map HAL RAW to libcamera RAW formats
Add a mapping from HAL RAW formats to the direct equivalent of libcamera
formats. With this change it is possible to capture RAW images as long
as the hardware can deliver frames in a format that is native to the
HAL.

More work is needed to deal with unpacked 8, 10 and 12 RAW formats as
they don't directly map to a native HAL format. Nor do they belong in
the RAW_OPAQUE category as the content format is generic and not
uncommonly supported by hardware.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-03 23:44:09 +02:00
Niklas Söderlund
8c1fedcb78 android: camera_device: Prepare for non-mandatory formats
When probing what formats a libcamera Camera supports we want to allow
to probe for non-mandatory formats. Add a new flag to indicate if a
format in camera3FormatsMap is mandatory or not.

All current defined formats are mandatory.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-03 23:44:09 +02:00
Umang Jain
70b65c6590 cam: Add --monitor option
Add --monitor to monitor new hotplug and unplug camera events from
the CameraManager.

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-03 14:19:13 +01:00
Kaaira Gupta
785d741861 libcamera: stream_option: use format name to set cam/qcam format
Replace hex input for pixel formats with their format names, for input in
cam and qcam.
Hence, remove the todo.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-03 11:48:47 +01:00
Kaaira Gupta
6b32eebf86 libcamera: pixel_format: Add a function to return format based on string
Add a function which retrieves pixel format corresponding to its name
from PixelFormatInfo.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-03 11:48:47 +01:00
Kaaira Gupta
c4b75cb66c libcamera: formats: PixelFormatInfo: Add name lookup function
Add a function which returns PixelFormatInfo, given format name as
a string.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-03 11:48:46 +01:00
Jacopo Mondi
2dd19efffc libcamera: ipu3: imgu: Rename configureInput()
The ImgUDevice::configureInput() function does not only configure the
input format but applies rectangles to the IF, BDS and GDC components.

Rename it to ImgUDevice::configure().

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:18 +02:00
Jacopo Mondi
15df621fb9 libcamera: ipu3: Configure ImgU with the computed parameters
Instrument the ImgUDevice::configureInput() function to use the provided
pipe configuration parameters to configure the IF, BDS and GDC
rectangles.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:18 +02:00
Jacopo Mondi
4ecbd0ea5a libcamera: ipu3: Validate the pipe configuration
Collect the desired ImgU pipe configuration while assigning
streams in the pipeline handler validate() function and ask the
ImgUDevice class to calculate the pipe configuration parameters.

If the requested pipe configuration results in a non-valid
configuration, return an error from the validate() function.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
968ab9bad0 libcamera: ipu3: imgu: Calculate ImgU pipe configuration
Instrument the ImgU component to dynamically calculate the image
manipulation pipeline intermediate sizes.

To correctly configure the ImgU it is necessary to program the IF, BDS
and GDC sizes, which are currently fixed to the input frame size.

The procedure used to calculate the intermediate sizes has been ported
from the pipe_config.py python script, available at:
https://github.com/intel/intel-ipu3-pipecfg
at revision:
61e83f2f7606 ("Add more information into README")

Define two structures (ImgUDevice::Pipe and ImgUDevice::PipeConfig)
to allow the pipeline handler to supply and retrieve configuration
parameters from the ImgU.

Finally, add a new operation to the ImgUDevice that calculates
the pipe configuration parameters based on the requested input and
output sizes.

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
d6a9ff0239 libcamera: ipu3: Remove camera_ from IPU3CameraConfiguration
The IPU3CameraConfiguration::camera_ shared pointer is not used.
Remove it.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
ed9fcf29e7 libcamera: ipu3: Remove streams from IPU3CameraConfiguration
The IPU3CameraConfiguration::streams_ field was used to keep an
association between the StreamConfiguration and the assigned streams
before CameraConfiguration::setStream() was called at configure() time.

The stream assignment was based on the order in which elements were
inserted in the vector, implementing a fragile association between
streams and their intended configurations.

As it is now possible to assign streams at validation time, there is no
need to keep that association in place, and the streams_ vector is now
unused.

Remove it and the associated accessor method from the
IPU3CameraConfiguration class.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
e0f8ce8454 libcamera: ipu3: Adjust and assign streams in validate()
Remove the adjustStream() and assignStream() methods, and perform stream
adjustment and assignment while iterating the StreamConfiguration
items.

The adjustStream() implementation had some arbitrary assumption, like
the main output having to be as large as the sensor resolution, and did
not take into account the different alignment requirements between the
main output and the viewfinder output.

The assignStream() implementation also assumes only full-size streams
can be produced by the main output, and having it as a separate function
prevents adjusting streams according to which output they are assigned.

Blend the two implementation in a single loop and perform the required
stream adjustment and assignment in one go.

As streams are now assigned at validate() time, remove the same
operation from the configure() function.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
420d5b23a7 libcamera: ipu3: cio2: Add a const sensor() method
Add a const version of the CIO2Device::sensor() method, that retrieves
a const pointer to the sensor_ class member, to be called by users
which only own a const reference to a CIO2Device class instance.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
4217c9f1aa libcamera: camera: Zero streams before validate()
The current implementation of the Camera::configure() method zeroes the
stream pointers assigned to the StreamConfiguration items before calling
the pipeline handler configure() operation, just after the
CameraConfiguration has been validated.

This discards the stream assignment performed at pipeline hander
validation time, requiring platforms that need to perform that early
assignment to maintain the association in place with custom data
structures.

To allow pipeline handlers to use StreamConfiguration::setStream() at
validate() time, zero the stream assignment before calling validate().

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
117e65cef2 libcamera: ipu3: Validate the stream combination
The IPU3 pipeline handler supports 2 processed RGB/YUV streams
and one RAW stream. Validate that the requested stream combination is
supported in the pipeline handler validate() implementation and return
an error in case it's not.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
320757897c libcamera: ipu3: Remove initialization of Size
The Size struct constructor defaults the width and height to 0.
Remove the empty braced-list initialization as it is not required.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
52a1332b48 libcamera: ipu3: Report StreamFormats
Report StreamFormats associated to each StreamConfiguration generated
by the IPU3 pipeline handler.

The StreamFormats are generated differently for RAW and processed
streams, with the former using the sensor enumerated resolutions and
the latter using a continuous range of sizes constructed by matching the
sensor capabilities with the platform constraints.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
3424fef3a5 libcamera: ipu3: Do not overwrite StreamConfiguration
The validate function overwrites the generated StreamConfiguration with
the one reported by the CIO2 unit when inspecting the RAW stream
configuration.

As we prepare to add StreamFormats to the IPU3 StreamConfiguration,
assigning to the CIO2 generated configuration would delete the
StreamFormats.

Fix this by updating relevant fields only in order to keep the
assigned StreamFormats.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:17 +02:00
Jacopo Mondi
6db776d55a libcamera: ipu3: cio2: Report format and sizes
Add two methods to the CIO2Device class to retrieve all the supported
PixelFormats and sizes.

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:16 +02:00
Jacopo Mondi
d181856edc libcamera: ipu3: Make sure the config is valid
Inspect the return status of validate() in the IPU3 pipeline handler
generateConfigurtion() implementation. If the generated configuration is
not valid, return a an empty configuration to the application.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:16 +02:00
Jacopo Mondi
ed98a81fc3 libcamera: ipu3: Remove streams from generateConfiguration
Remove stream assignment from the IPU3 pipeline handler
generateConfiguration() implementation.

The function aims to provide a suitable default for the requested use
cases. Defer stream assignment to validation and only initialize sizes
and formats.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:16 +02:00
Jacopo Mondi
dd0793ed1b libcamera: geometry: Add isNull() function to Rectangle class
It's common for code to check if a rectangle is null. Add a helper function
to do so and test the function in test/geometry.cpp

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:16 +02:00
Jacopo Mondi
d405d1fd5e libcamera: utils: Add alignUp and alignDown functions
Add to libcamera utils library two functions to round up or down a
value to an alignment and add a test in test/utils.cpp for the two
new functions.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:16 +02:00
Jacopo Mondi
4383252d93 libcamera: ipu3: Rename mbusCodesToInfo
The mbusCodesToInfo map actually maps media bus codes to PixelFormat
instances. Rename the map according to its actual function and while at
it drop the 'static' keyword as the map is already defined in an
anonymous namespace.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:16 +02:00
Niklas Söderlund
108b6a8a15 libcamera: device_enumerator_udev: Initialize monitor_ and notifier_ to nullptr
The monitor_ and notifier_ pointers are acted on in the destructor if
not set to nullptr, the pointers are however first initialized in
init() and enumerate(). Avoid acting on uninitialized pointers by
initializing them to nullptr in the constructor.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
2020-08-03 10:58:50 +02:00
Niklas Söderlund
f0f297c5f2 libcamera: device_enumerator_udev: Align class final declaration with sysfs subclass
Instead of marking each individual overloaded function with final mark
the whole class as final. This aligns the sysfs and udev based
DeviceEnumerator implementations.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
2020-08-03 10:43:36 +02:00
Umang Jain
f2df5abe5d libcamera: camera: Ensure deletion via deleteLater()
Object::deleteLater() ensures that the deletion of the Object
takes place in a thread it is bound to. Deleting the Object
in a different thread is a violation according to the libcamera
threading model.

On hot-unplug of a currently streaming camera, the last reference
of Camera when dropped from the application thread (for e.g. QCam's
thread), the destructor is then called from this thread. This is not
allowed by the libcamera threading model. Camera is meant to be deleted
in the thread it is bound to - in this case the CameraManager's thread.

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-31 23:33:38 +03:00
Umang Jain
9c5f821396 tests: Add a test case for the Object::deleteLater() API, to verify
- the object is deleted from the correct thread
- multiple deleteLater() calls delete the object once only

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-31 23:33:35 +03:00
Umang Jain
9558886f7a libcamera: object: Add deleteLater() support
This commit adds support to schedule the deletion of an Object to the
thread it is bound to (similar to [1]). An Object getting destroyed
by a different thread is considered as a violation as per the
libcamera threading model.

This will be useful for an Object where its ownership is shared via
shared pointers in different threads. If the thread which drops the
last reference of the Object is a different thread, the destructors
get called in that particular thread, not the one Object is bound to.
Hence, in order to resolve this kind of situation, the creation of
shared pointer can be accompanied by a custom deleter which in turns
use deleteLater() to ensure the Object is destroyed in its own thread.

[1] https://doc.qt.io/qt-5/qobject.html#deleteLater

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-31 23:33:32 +03:00
Umang Jain
3fe7c1cdb4 libcamera: thread: Support selective message dispatch to thread
Extend the current dispatchMessages() to support dispatching of
selective messsages according to the Message::Type passed in
the function argument. dispatchMessages() can now be called
explicitly to force deliver selected type's message to the
thread for processing (typically when event loop is not
running).

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-31 23:33:23 +03:00