From patchwork Wed Jun 16 15:11:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 12617 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7F2E6BD78E for ; Wed, 16 Jun 2021 15:11:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AA64B6894C; Wed, 16 Jun 2021 17:11:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="umfyBfWd"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 246B76029A for ; Wed, 16 Jun 2021 17:11:57 +0200 (CEST) Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A64BF3E5; Wed, 16 Jun 2021 17:11:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1623856316; bh=VNDzYnreqGSL1phM61ixg4Cnczoqx3enBMNp8nqVDJU=; h=From:To:Cc:Subject:Date:From; b=umfyBfWduaDOnAxTnjPMNlIF+7aVR9U0f7OmcXYC6H+Rl4GwGpmzJ5Bck8h3VgQI6 pDdxZ9cU5xOR5A5cLQRubRZwAzZ6kg479D8h2vCnBX7vJ4hudm98FqegAynBTo54Kz 8NLjKidrRfXS6olLbTp/NTFGgldevIEV2LXmRbiE= From: Kieran Bingham To: libcamera devel Date: Wed, 16 Jun 2021 16:11:46 +0100 Message-Id: <20210616151152.3856595-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 0/6] libcamera-platform: Split library functionality X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The main libcamera.so shared library contains more than the implementation of our camera framework and consists of the android hal interface, as well as various helpers and platform abstractions to assist with things like reading files, logging, or thread management. This (horrendously large, and painful) series aims to split and refactor the code base to extract re-usable functionality which might be shared with IPA modules (or other applications) while keeping the libcamera public API concise. To do this, this series splits out and creates new shared objects: libcamera-hal.so ... libcamera-helpers.so ... libcamera.so ... libcamera-platform.so With libcamara-platform at the lowest layer, this library is used by libcamera to handle core internal functionality - but it is important to note that this is not intended to form part of the public API of libcamera itself. libcamera.so remains the integral implementation and library to operate complex cameras within linux. On top of that is some functionality which builds 'on top' of the libcamera API, and is optional for applications or users of libcamera to make use of. In particular, at the moment this impelements a mapped_buffer object which helps manage lifetime of mmap operations on libcamera buffers. Finally on top of all of that, the existing android camera HAL which has historically been linked directly into the libcamera.so is now split and has it's own life as libcamera-hal.so. While some core elements of the previously 'internal' components of libcamera have been moved to libcamera-platform, not all have - I have only moved the minimum needed to support building an external IPA for the IPU3 which makes use of these components. It may make sense to move more internal or abstraction classes to libcamera-platform, but that can be done on an as required basis. It may also be possible in the future that the libcamera-platform layer provides a means to abstracting the main libcamera interface to support the API on other platforms, but this is not anticipated in the short term. Kieran Bingham (6): android: Split HAL to its own shared library libcamera-platform: Introduce new platform library libcamera-platform: Move utils to the platform library libcamera-platform: Move extended platform functionality libcamera-platform: Move File to platform library libcamera-helpers: Provide helper library Documentation/Doxyfile.in | 6 +- Documentation/guides/pipeline-handler.rst | 3 +- Documentation/meson.build | 2 + include/libcamera/camera.h | 5 +- include/libcamera/camera_manager.h | 5 +- .../buffer.h => helpers/mapped_buffer.h} | 10 +- include/libcamera/helpers/meson.build | 10 + include/libcamera/internal/camera_sensor.h | 3 +- .../libcamera/internal/device_enumerator.h | 2 +- include/libcamera/internal/event_notifier.h | 4 +- .../libcamera/internal/ipa_data_serializer.h | 3 +- include/libcamera/internal/ipa_manager.h | 3 +- include/libcamera/internal/ipa_module.h | 3 +- include/libcamera/internal/ipc_pipe.h | 4 +- include/libcamera/internal/ipc_unixsocket.h | 2 +- include/libcamera/internal/media_device.h | 4 +- include/libcamera/internal/meson.build | 10 - include/libcamera/internal/pipeline_handler.h | 3 +- include/libcamera/internal/process.h | 2 +- include/libcamera/internal/v4l2_device.h | 4 +- include/libcamera/internal/v4l2_subdevice.h | 3 +- include/libcamera/internal/v4l2_videodevice.h | 5 +- include/libcamera/ipa/ipa_interface.h | 3 +- include/libcamera/meson.build | 5 +- .../libcamera/{ => platform}/bound_method.h | 6 +- .../{internal => platform}/event_dispatcher.h | 6 +- .../event_dispatcher_poll.h | 8 +- .../libcamera/{internal => platform}/file.h | 6 +- .../libcamera/{internal => platform}/log.h | 8 +- include/libcamera/platform/meson.build | 21 +++ .../{internal => platform}/message.h | 8 +- include/libcamera/{ => platform}/object.h | 8 +- .../{internal => platform}/semaphore.h | 8 +- include/libcamera/{ => platform}/signal.h | 10 +- .../libcamera/{internal => platform}/thread.h | 13 +- .../libcamera/{internal => platform}/timer.h | 10 +- .../libcamera/{internal => platform}/utils.h | 8 +- include/libcamera/request.h | 3 +- src/android/camera3_hal.cpp | 2 +- src/android/camera_device.cpp | 7 +- src/android/camera_device.h | 9 +- src/android/camera_hal_config.cpp | 2 +- src/android/camera_hal_manager.cpp | 2 +- src/android/camera_metadata.cpp | 2 +- src/android/camera_stream.h | 2 +- src/android/camera_worker.h | 4 +- src/android/jpeg/encoder_libjpeg.cpp | 3 +- src/android/jpeg/encoder_libjpeg.h | 3 +- src/android/jpeg/exif.cpp | 4 +- src/android/jpeg/post_processor_jpeg.cpp | 2 +- src/android/jpeg/post_processor_jpeg.h | 2 +- src/android/jpeg/thumbnailer.cpp | 2 +- src/android/jpeg/thumbnailer.h | 3 +- src/android/meson.build | 13 +- src/android/mm/cros_camera_buffer.cpp | 2 +- src/android/mm/generic_camera_buffer.cpp | 5 +- src/android/post_processor.h | 2 +- src/android/yuv/post_processor_yuv.cpp | 3 +- src/ipa/ipu3/ipu3.cpp | 5 +- src/ipa/ipu3/ipu3_agc.cpp | 2 +- src/ipa/ipu3/ipu3_awb.cpp | 2 +- src/ipa/ipu3/meson.build | 2 +- src/ipa/libipa/histogram.cpp | 2 +- src/ipa/raspberrypi/cam_helper.hpp | 3 +- .../raspberrypi/controller/agc_algorithm.hpp | 3 +- src/ipa/raspberrypi/controller/agc_status.h | 2 +- src/ipa/raspberrypi/controller/camera_mode.h | 2 +- src/ipa/raspberrypi/controller/controller.cpp | 2 +- .../raspberrypi/controller/device_status.h | 2 +- src/ipa/raspberrypi/controller/rpi/agc.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/agc.hpp | 2 +- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/awb.cpp | 2 +- .../controller/rpi/black_level.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 2 +- .../raspberrypi/controller/rpi/contrast.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/dpc.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/focus.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/geq.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/lux.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/lux.hpp | 2 +- src/ipa/raspberrypi/controller/rpi/noise.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/sdn.cpp | 2 +- .../raspberrypi/controller/rpi/sharpen.cpp | 2 +- src/ipa/raspberrypi/meson.build | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 5 +- src/ipa/rkisp1/rkisp1.cpp | 2 +- src/ipa/vimc/vimc.cpp | 4 +- src/libcamera-helpers/mapped_buffer.cpp | 171 ++++++++++++++++++ .../bound_method.cpp | 11 +- .../event_dispatcher.cpp | 7 +- .../event_dispatcher_poll.cpp | 13 +- .../file.cpp | 6 +- src/{libcamera => libcamera-platform}/log.cpp | 8 +- src/libcamera-platform/meson.build | 51 ++++++ .../message.cpp | 9 +- .../object.cpp | 17 +- .../semaphore.cpp | 6 +- .../signal.cpp | 6 +- .../thread.cpp | 12 +- .../timer.cpp | 14 +- .../utils.cpp | 8 +- src/libcamera/buffer.cpp | 151 +--------------- src/libcamera/byte_stream_buffer.cpp | 2 +- src/libcamera/camera.cpp | 5 +- src/libcamera/camera_manager.cpp | 8 +- src/libcamera/camera_sensor.cpp | 3 +- src/libcamera/camera_sensor_properties.cpp | 2 +- src/libcamera/control_serializer.cpp | 3 +- src/libcamera/controls.cpp | 5 +- src/libcamera/delayed_controls.cpp | 3 +- src/libcamera/device_enumerator.cpp | 3 +- src/libcamera/device_enumerator_sysfs.cpp | 3 +- src/libcamera/device_enumerator_udev.cpp | 3 +- src/libcamera/event_notifier.cpp | 6 +- src/libcamera/file_descriptor.cpp | 2 +- src/libcamera/formats.cpp | 2 +- src/libcamera/framebuffer_allocator.cpp | 3 +- src/libcamera/geometry.cpp | 2 +- src/libcamera/ipa_data_serializer.cpp | 2 +- src/libcamera/ipa_manager.cpp | 7 +- src/libcamera/ipa_module.cpp | 7 +- src/libcamera/ipa_proxy.cpp | 5 +- src/libcamera/ipc_pipe.cpp | 2 +- src/libcamera/ipc_pipe_unixsocket.cpp | 9 +- src/libcamera/ipc_unixsocket.cpp | 3 +- src/libcamera/media_device.cpp | 2 +- src/libcamera/media_object.cpp | 3 +- src/libcamera/meson.build | 32 +--- src/libcamera/pipeline/ipu3/cio2.h | 2 +- src/libcamera/pipeline/ipu3/frames.h | 2 +- src/libcamera/pipeline/ipu3/imgu.cpp | 5 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 5 +- .../pipeline/raspberrypi/dma_heaps.cpp | 2 +- .../pipeline/raspberrypi/raspberrypi.cpp | 6 +- .../pipeline/raspberrypi/rpi_stream.cpp | 2 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 5 +- src/libcamera/pipeline/rkisp1/rkisp1_path.h | 3 +- src/libcamera/pipeline/simple/converter.cpp | 8 +- src/libcamera/pipeline/simple/converter.h | 4 +- src/libcamera/pipeline/simple/simple.cpp | 3 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 5 +- src/libcamera/pipeline/vimc/vimc.cpp | 5 +- src/libcamera/pipeline_handler.cpp | 5 +- src/libcamera/process.cpp | 5 +- src/libcamera/request.cpp | 3 +- src/libcamera/stream.cpp | 5 +- src/libcamera/sysfs.cpp | 4 +- src/libcamera/v4l2_device.cpp | 5 +- src/libcamera/v4l2_pixelformat.cpp | 3 +- src/libcamera/v4l2_subdevice.cpp | 5 +- src/libcamera/v4l2_videodevice.cpp | 3 +- src/meson.build | 9 +- src/v4l2/v4l2_camera.cpp | 2 +- src/v4l2/v4l2_camera.h | 2 +- src/v4l2/v4l2_camera_proxy.cpp | 7 +- src/v4l2/v4l2_compat_manager.cpp | 4 +- test/camera-sensor.cpp | 3 +- test/camera/buffer_import.cpp | 7 +- test/camera/capture.cpp | 6 +- test/event-dispatcher.cpp | 6 +- test/event-thread.cpp | 5 +- test/event.cpp | 7 +- test/file-descriptor.cpp | 2 +- test/file.cpp | 2 +- test/hotplug-cameras.cpp | 8 +- test/ipa/ipa_interface_test.cpp | 7 +- test/ipc/unixsocket.cpp | 7 +- test/ipc/unixsocket_ipc.cpp | 10 +- test/log/log_api.cpp | 2 +- test/log/log_process.cpp | 11 +- test/mapped-buffer.cpp | 3 +- test/meson.build | 14 +- test/message.cpp | 4 +- test/object-delete.cpp | 5 +- test/object-invoke.cpp | 7 +- test/object.cpp | 7 +- test/pixel-format.cpp | 2 +- test/process/process_test.cpp | 10 +- .../ipa_data_serializer_test.cpp | 5 +- test/signal-threads.cpp | 6 +- test/signal.cpp | 4 +- test/threads.cpp | 2 +- test/timer-thread.cpp | 6 +- test/timer.cpp | 6 +- test/utils.cpp | 2 +- test/v4l2_subdevice/list_formats.cpp | 3 +- test/v4l2_videodevice/buffer_sharing.cpp | 6 +- test/v4l2_videodevice/capture_async.cpp | 6 +- test/v4l2_videodevice/formats.cpp | 3 +- test/v4l2_videodevice/v4l2_m2mdevice.cpp | 7 +- .../module_ipa_proxy.cpp.tmpl | 5 +- .../module_ipa_proxy.h.tmpl | 3 +- .../module_ipa_proxy_worker.cpp.tmpl | 7 +- 194 files changed, 738 insertions(+), 574 deletions(-) rename include/libcamera/{internal/buffer.h => helpers/mapped_buffer.h} (81%) create mode 100644 include/libcamera/helpers/meson.build rename include/libcamera/{ => platform}/bound_method.h (97%) rename include/libcamera/{internal => platform}/event_dispatcher.h (79%) rename include/libcamera/{internal => platform}/event_dispatcher_poll.h (82%) rename include/libcamera/{internal => platform}/file.h (91%) rename include/libcamera/{internal => platform}/log.h (95%) create mode 100644 include/libcamera/platform/meson.build rename include/libcamera/{internal => platform}/message.h (86%) rename include/libcamera/{ => platform}/object.h (88%) rename include/libcamera/{internal => platform}/semaphore.h (74%) rename include/libcamera/{ => platform}/signal.h (93%) rename include/libcamera/{internal => platform}/thread.h (83%) rename include/libcamera/{internal => platform}/timer.h (80%) rename include/libcamera/{internal => platform}/utils.h (97%) create mode 100644 src/libcamera-helpers/mapped_buffer.cpp rename src/{libcamera => libcamera-platform}/bound_method.cpp (93%) rename src/{libcamera => libcamera-platform}/event_dispatcher.cpp (96%) rename src/{libcamera => libcamera-platform}/event_dispatcher_poll.cpp (96%) rename src/{libcamera => libcamera-platform}/file.cpp (99%) rename src/{libcamera => libcamera-platform}/log.cpp (99%) create mode 100644 src/libcamera-platform/meson.build rename src/{libcamera => libcamera-platform}/message.cpp (96%) rename src/{libcamera => libcamera-platform}/object.cpp (96%) rename src/{libcamera => libcamera-platform}/semaphore.cpp (95%) rename src/{libcamera => libcamera-platform}/signal.cpp (98%) rename src/{libcamera => libcamera-platform}/thread.cpp (98%) rename src/{libcamera => libcamera-platform}/timer.cpp (93%) rename src/{libcamera => libcamera-platform}/utils.cpp (99%)