Commit graph

3641 commits

Author SHA1 Message Date
Laurent Pinchart
27fb47f70b libcamera: yaml_parser: Extend YamlObject::size() to dictionaries
Dictionaries have a size too, extend the size() function to support
them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-16 02:43:47 +03:00
Laurent Pinchart
27483e971f libcamera: yaml_object: Turn Type into an enum class
Turn the Type enum into an enum class to force qualifying 'List' and
'Dictionary' in the YamlObject namespace scope. This will help avoiding
ambiguities when adding iterator support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-16 02:43:46 +03:00
Jacopo Mondi
1735d176bc android: camera_device: Print the correct number of completed streams
When a request completes, a debug message is generated to help
identify the request and the number of streams it contains.

The printed number of streams is however the number of output buffers
requested by the camera framework, not the number of streams generated
by libcamera. In facts, some output buffers are generated by
post-processing, and not directly from the camera.

As the debug message prints the libcamera identifier for the Request, it
is more logical to print the number of streams generated by the camera
instead of the total number of streams.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-10 11:48:10 +02:00
Hirokazu Honda
246d3f631b android: camera_device: Use YUV post-processor
When creating the list of StreamConfiguration to be requested to the camera,
map NV12 streams of equal size and format together, so that they will be
generated by using the YUV post-processor.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-10 11:48:09 +02:00
Jacopo Mondi
7ea83eba0d android: camera_device: Postpone mapped streams handling
Mapped streams are generated by post-processing and always require a
source buffer to process image data from.

In case a Mapped stream is requested but its source stream is not, it
is required to allocate a buffer on the fly and add it to the
libcamera::Request.

Make sure a source stream is available for all mapped streams, and if
that's not the case, add a dedicated buffer to the request for that
purpose.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-10 11:48:09 +02:00
Jacopo Mondi
1261ff9e93 android: camera_stream: Create allocator unconditionally
Originally buffer allocation was only required for Internal streams
which are not backed by a frame buffer provided by the Android
framework.

Now that mapped streams can be generated without the corresponding
source stream being part of the Android's provided stream list, also
buffers of type Mapped can be required to allocate buffers on demand.

Create CameraStream::allocator_ and the associated mutex unconditionally
for all types of stream.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-10 11:48:09 +02:00
Hirokazu Honda
fec64fb75a android: camera_stream: Add sourceStream
Add a sourceStream field to the CameraStream class, meant to contain a
reference to the direct stream which produces actual image data for
streams of type CameraStream::Mapped.

The sourceStream of mapped streams will be used in later patches to make
sure for each Mapped stream at least one libcamera::Stream is queued to
the libcamera::Camera.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-10 11:48:09 +02:00
Tomi Valkeinen
b4d4b78c82 py: examples: Add simple-cam.py
Add a Python version of simple-cam from:

https://git.libcamera.org/libcamera/simple-cam.git

Let's keep this in the libcamera repository until the Python API has
stabilized a bit more, and then we could move this to the simple-cam
repo.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-08 20:16:25 +03:00
Tomi Valkeinen
d6cfb08060 py: examples: Add simple-continuous-capture.py
Add a slightly more complex, and I think a more realistic, example,
where the script reacts to events and re-queues the buffers.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-08 20:16:21 +03:00
Tomi Valkeinen
ab21acb9c0 py: examples: Add simple-capture.py
Add an example to showcase the more-or-less minimal capture case.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-08 20:16:19 +03:00
Tomi Valkeinen
d0b310b465 Documentation: Add python-bindings.rst
Add a basic doc for the Python bindings. While not really proper
documentation yet, the file and the examples should give enough guidance
for users who are somewhat familiar with libcamera.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-08 17:31:23 +03:00
Laurent Pinchart
6132521b47 libcamera: base: log: Color the log prefix
Add coloring to the log prefix to increase log readability.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-06 15:09:49 +03:00
Laurent Pinchart
5757038946 libcamera: base: log: Add coloring to the log output
Extend the logger to support coloring messages. The log level is
colorized with per-level colors, and the category with a fixed color.
This makes the log output more readable.

Coloring is enabled by default when logging to std::cerr, and can be
disabled by setting the LIBCAMERA_LOG_NO_COLOR environment variable.
When logging to a file with LIBCAMERA_LOG_FILE, coloring is disabled. It
can be enabled for file logging using the logSetFile() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-06 15:09:42 +03:00
Naushir Patuck
7ee7dc3369 camera_sensor: Suppress error message if test patterns are unavailable
If a sensor driver does not support test patterns (e.g. IMX477),
libcamera throws an unnecessary error message during initialisation when
it sets the test pattern to off.

Fix this by moving the error message into setTestPatternMode() where the
pipeline handler explicitly requests to set a test pattern.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-06 15:08:34 +03:00
Jacopo Mondi
161d24377c libcamera: request: Add operator<<()
With the recent addition of operator<<() in most libcamera core classes
to replace usage of the toString() function the Request class was left
behind.

Add operator<<() for the Request class and reimplement toString().

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-05 14:48:08 +02:00
Christian Rauch
38e427f605 libcamera: ipu3: Fix rogue whitespace
Fix a comment line wrongly indented with spaces instead of tabs.

Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-05 00:58:09 +03:00
Tomi Valkeinen
7ef83e0228 py: Merge read_event() and get_ready_requests()
We always call CameraManager.read_event() and
CameraManager.get_ready_requests(), so to simplify the use merge the
read_event() into the get_ready_requests().

This has the side effect that get_ready_requests() will now block if
there is no event ready. If we ever need to call get_ready_requests() in
a polling manner we will need a new function which behaves differently.

However, afaics the only sensible way to manage the event loop is to use
select/poll on the eventfd and then call get_ready_requests() once,
which is the use case what the current merged function supports.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-04 02:21:05 +03:00
Tomi Valkeinen
b4bb5ce629 utils: checkstyle.py: Fix color bleed
If issue.line is None, the the terminal color is never reset back to
normal. This causes the yellow color to bleed.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-03 23:35:22 +03:00
Laurent Pinchart
30d55d584a libcamera: v4l2_subdevice: Add YUV8_1X24 media bus format
The format is used by the i.MX8 ISI driver that will be supported by the
simple pipeline handler.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-06-03 17:56:45 +03:00
Laurent Pinchart
afed56621e libcamera: v4l2_subdevice: Add RGB565_1X16 media bus format
The format is used by the i.MX8 ISI driver that will be supported by the
simple pipeline handler.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-06-03 17:56:45 +03:00
Laurent Pinchart
f8ee23655b libcamera: v4l2_subdevice: Use MEDIA_BUS_FMT_* macros
The V4L2_MBUS_FMT_* macros that define media bus formats are deprecated.
Use the MEDIA_BUS_FMT_* macros instead.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-06-03 17:56:45 +03:00
Laurent Pinchart
3b9fe4ae99 libcamera: formats: Add YUV444 and YVU444 pixel formats
Extend planar YUV format support with 4:4:4 formats. Those formats are
used by the i.MX8 ISI driver that will be supported by the simple
pipeline handler.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-06-03 17:56:44 +03:00
Laurent Pinchart
111f9f5af2 libcamera: formats: Add YVU422 pixel format
The YVU422 pixel format is defined in both DRM and V4L2. libcamera
already supports YUV422, add support for the opposite chroma order.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2022-06-03 17:56:31 +03:00
Tomi Valkeinen
dfcf638a0a py: cam: cam_qt: mmap the fbs only once
Instead of doing an mmap and munmap every time a Request is complete,
mmap all the buffers once at the start of the program.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-01 12:09:10 +03:00
Tomi Valkeinen
958d9187aa py: MappedFrameBuffer: Add 'fb' property
Add 'fb' property to expose the underlying FrameBuffer.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-01 12:09:07 +03:00
Tomi Valkeinen
43192f4321 py: MappedFrameBuffer: Support non-contextmanager use
Implement non-contextmanager use to MappedFrameBuffer so that we can
either:

with MappedFrameBuffer(fb) as mfb:
	...

or

mfb = MappedFrameBuffer(fb)
mfb.mmap()
...
mfb.munmap()

While at it, improve the error handling a bit.

Note that the mmap() returns self. In other words, one can do this:

mfb = MappedFrameBuffer(fb).mmap()
...
mfb.munmap()

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-01 12:09:06 +03:00
Tomi Valkeinen
fbd6c4d1c8 py: Implement FrameBufferPlane
Implement FrameBufferPlane class and adjust the methods and uses
accordingly.

Note that we don't expose the fd as a SharedFD, but as an int.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-01 12:09:02 +03:00
Tomi Valkeinen
e8317de05c py: Add FrameMetadataPlane
Add FrameMetadataPlane class and adjust the methods and uses
accordingly.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-01 12:08:58 +03:00
Tomi Valkeinen
80e0ff355e py: Add Request.__str__()
Add Request.__str__() which maps directly to Request::toString().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-01 12:08:56 +03:00
Tomi Valkeinen
7330474762 py: cam: Drop PIL dependency
We can use Qt directly to accomplish the same as we do with PIL.

A minor downside is that loading MJPEG frame with Qt produces a "Corrupt
JPEG data" warning. The resulting picture looks fine, though. So add a
message handler to ignore that warning.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-01 12:08:54 +03:00
Tomi Valkeinen
0971ea7c8b py: cam: Move conversion funcs to helpers.py
Move conversion functions from cam_qt.py to helpers.py to clean up the
code and so that they can be used from other cam renderers.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-01 12:08:51 +03:00
Tomi Valkeinen
679b73640a py: unittests: Fix test_select()
The test_select() currently uses self.assertTrue(len(ready_reqs) > 0) to
see that cm.get_ready_requests() returns something. This is not always
the case, as there may be two eventfd events queued, and the first call
to cm.get_ready_requests() returns all the requests, and thus the second
call returns none.

Remove the self.assertTrue(len(ready_reqs) > 0) assert.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-01 12:08:47 +03:00
Tomi Valkeinen
9f5b790800 py: unittests: Fix test_sleep()
Waiting for 0.5 secs and expecting that the requests have been completed
is... bad. Fix the test case by using cam.read_event() as a blocking
wait, and wait until we have received all the requests that we queued.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-01 12:08:42 +03:00
Laurent Pinchart
207e52b8d3 libcamera: base: log: Log to std::cerr if log file can't be opened
If the log file specified through LIBCAMERA_LOG_FILE can't be opened,
logging is currently completely disabled. This doesn't match the
documented behaviour that tells std::cerr is used instead. Fix it to
match the documentation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-01 12:08:40 +03:00
Laurent Pinchart
8a606e6c67 libcamera: base: log: Replace stderr with std::cerr in documentation
While std::cerr and stderr both target the same file by default, this
may be overridden by applications. Update the documentation to use
std::cerr instead of stderr to be accurate.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-01 12:08:39 +03:00
Laurent Pinchart
95c1ff8eb6 libcamera: base: log: Remove unnecessary local variable
The output local variable in Logger::logSetTarget() isn't necessary.
Remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-01 12:08:38 +03:00
Laurent Pinchart
5517ffbff6 libcamera: Use "..." instead of <...> consistently for internal headers
libcamera uses double quotes for #include directives for internal
headers. A few <...> have found their way in the code base over time.
Fix them.

While at it, move an Android header include to the right location.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-01 12:08:36 +03:00
Laurent Pinchart
7a529a9e35 utils: checkstyle: Ensure "..." include style for internal headers
libcamera uses the "..." include style for internal headers. Enforce it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-01 12:08:34 +03:00
Laurent Pinchart
c58ac2f498 utils: checkstyle: Run the CLangFormatter last
The IncludeOrderFormatter will be extended with more formatting rules
that should be applied before clang-format gets run, as it will
influence its output.

Add a priority mechanism for formatters, and give a negative priority to
the CLangFormatter to make it run last.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-01 12:08:29 +03:00
Laurent Pinchart
2094ac4f8c libcamera: Fix incorrect toString() to operator<<() conversions
Commit 8a845ab078 ("libcamera: Replace toString with operator<<() for
format classes") incorrectly converted some of the toString() usages,
resulting in pointer values being printed instead of formats. Fix it.

Fixes: 8a845ab078 ("libcamera: Replace toString with operator<<() for format classes")
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>
2022-06-01 12:08:22 +03:00
Tomi Valkeinen
e115a69135 py: Use ln --relative to create symlinks
We create symlinks from the Python bindings build dir to the source dir
so that 1) the build dir can be used to use the bindings, and 2) to
allow modifications of the source .py files to be used right away
without rebuilding.

The symlinks were recently fixed and changed to use absolute paths.
However, absolute paths ruin one main use case I have: using the
bindings from the build dir via nfs from an ARM device.

So move back to relative paths, but accomplish this with the --relative
parameter for ln, instead of guessing the right relative path as was
done before the above-mentioned fix.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-27 22:03:46 +03:00
Tomi Valkeinen
a69b73cc58 py: Generate bindings for properties
Generate bindings for properties in a very similar way as done for
controls. We do need to distinguish between the two, and thus I added
--properties flag to gen-py-controls.py.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-27 22:03:44 +03:00
Tomi Valkeinen
7a0a464dd1 py: Rename 'efd' to 'event_fd'
Perhaps it's better to have a more descriptive name here. I also
considered just renaming 'efd' to 'fd', but 'event_fd' won.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-27 22:03:41 +03:00
Tomi Valkeinen
1698442aa8 py: Re-structure the controls API
Add ControlInfo class and change the controls related methods to
resemble the C++ API (e.g. no more string based control methods).

We don't implement ControlList or ControlInfoMap but just expose the
same data via standard Python dict.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-27 22:03:38 +03:00
Tomi Valkeinen
3c82ae3821 py: Re-implement controls geneneration
The Python bindings controls generation was not very good. It only
covered the enums and they were in the main namespace.

This adds the controls somewhat similarly to the C++ side. We will have
e.g.:

libcamera.controls.Brightness
libcamera.controls.AeMeteringModeEnum.CentreWeighted

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-27 22:03:34 +03:00
Tomi Valkeinen
6eb1143e27 py: cam: Convert ctx and state to classes
Convert ctx and state dicts to classes. No functional changes.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-27 22:03:30 +03:00
Tomi Valkeinen
bb1cbd53d2 py: cam: Drop WA_ShowWithoutActivating
Drop WA_ShowWithoutActivating from the Qt renderers. I added the flag
during development phase as I didn't want the window to take the focus,
but it should be removed now.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-27 22:02:47 +03:00
Tomi Valkeinen
19d870d6d8 py: MappedFrameBuffer: Add type hints & docs
Add a few type hints and (minimal) docs to MappedFrameBuffer.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-27 22:02:44 +03:00
Tomi Valkeinen
9e4388cca5 py: Move MappedFrameBuffer to libcamera.utils
Move MappedFrameBuffer to libcamera.utils, instead of extending
FrameBuffer class with a new mmap() method. This keeps us more aligned
to the C++ API.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-27 22:02:41 +03:00
Tomi Valkeinen
210ce547a4 py: Add CameraManager.read_event()
Add CameraManager.read_event() so that the user does not need to call
os.read().

We use eventfd, and we must always read 8 bytes. Hiding that inside
read_event() makes sense.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-27 22:02:31 +03:00