From patchwork Tue Aug 31 09:34:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13580 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 F2A50BD87D for ; Tue, 31 Aug 2021 09:34:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B180F6916A; Tue, 31 Aug 2021 11:34:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="NWg7rXbj"; dkim-atps=neutral Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B24C669169 for ; Tue, 31 Aug 2021 11:34:47 +0200 (CEST) Received: by mail-pl1-x62c.google.com with SMTP id n18so854727plp.7 for ; Tue, 31 Aug 2021 02:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=57tKIuEBA859JTYpRptWPWiS7SHHF7e4yXerawVnHqA=; b=NWg7rXbjEANHITLJjr8qnE4XyQf6ieq4ROBMh2dv7n1UfUKZbYNpSLs2Lfhj5bjVvI 77bfcPlZCjZoDU8BOm2nxt4/e24tx0PLQhI2s5AH1V0AM4Omk8Jcg8b8zPeEL1udtG/p sQ2BuvlyhgSMcqVG3shK+h6XIe5GGIqsxuIaQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=57tKIuEBA859JTYpRptWPWiS7SHHF7e4yXerawVnHqA=; b=dX+tP5OzRojYwbg0Tqal4fx0pMPgyNzdlItK/RlUxu1+NLpTp8hBDrPMNIpTUbpFOh JPm9m6d2Xi/TO2jxd3rdXPdhNN/Pa5lv2eHfCnz6G5wtEXteOF1NX9PZEvDSRm6oFKPn pRk+BfAc+v+qXZPfYXSi/OoBdx0wZg6uh/RY7SxU5+EP3BX0NIhmE0LoVjJwWH+L8PLw E1vHKGmuX09m2zL+krVzkE1p74kDO2bQX+d8c6CAepYFDEx8rbrfCdqFXJh5RDKbQ49L cErgIxf9kEftyiJqnZ9dfgoPRTlSa1r2dPBI9ZzdUFnMTlNgEM4RYsHEdrQ3rGPm32a/ v5vQ== X-Gm-Message-State: AOAM530tcrslxkssvEcn325LvO/HB2gI1NQDiWrGkEMTv/nYS5KFNntf 6u0wJU5B/OnTB7a1dd+EpkxNblGBUOn6cA== X-Google-Smtp-Source: ABdhPJxhERb7uSugtlfnAb6e/PRq43PJjcw/vZq0RgVgmYCO9SzuP7ZH5UVI1rLiG9IcHTh4erKa/A== X-Received: by 2002:a17:90a:b390:: with SMTP id e16mr4436101pjr.49.1630402486040; Tue, 31 Aug 2021 02:34:46 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3c62:aba4:18ea:5441]) by smtp.gmail.com with ESMTPSA id w5sm19787885pgp.79.2021.08.31.02.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 02:34:45 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 31 Aug 2021 18:34:37 +0900 Message-Id: <20210831093439.853586-2-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.259.gc128427fd7-goog In-Reply-To: <20210831093439.853586-1-hiroh@chromium.org> References: <20210831093439.853586-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/3] android: camera_stream: Create post processor in configure() 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" CameraStream creates PostProcessor and FrameBufferAllocator in the constructor. CameraStream assumes that a used post processor is JPEG post processor. Since we need to support various post processors, we would rather move the creation to configure() so as to return an error code if no proper post processor is found. This also moves FrameBufferAllocator and Mutex creation for consistency. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/android/camera_device.h | 1 + src/android/camera_stream.cpp | 36 ++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/android/camera_device.h b/src/android/camera_device.h index a5576927..296c2f18 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -48,6 +48,7 @@ public: unsigned int id() const { return id_; } camera3_device_t *camera3Device() { return &camera3Device_; } + const CameraCapabilities *capabilities() const { return &capabilities_; } const std::shared_ptr &camera() const { return camera_; } const std::string &maker() const { return maker_; } diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 01909ec7..fb10bf06 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -10,6 +10,7 @@ #include #include "camera_buffer.h" +#include "camera_capabilities.h" #include "camera_device.h" #include "camera_metadata.h" #include "jpeg/post_processor_jpeg.h" @@ -47,20 +48,6 @@ CameraStream::CameraStream(CameraDevice *const cameraDevice, : cameraDevice_(cameraDevice), config_(config), type_(type), camera3Stream_(camera3Stream), index_(index) { - if (type_ == Type::Internal || type_ == Type::Mapped) { - /* - * \todo There might be multiple post-processors. The logic - * which should be instantiated here, is deferred for the - * future. For now, we only have PostProcessorJpeg and that - * is what we instantiate here. - */ - postProcessor_ = std::make_unique(cameraDevice_); - } - - if (type == Type::Internal) { - allocator_ = std::make_unique(cameraDevice_->camera()); - mutex_ = std::make_unique(); - } } const StreamConfiguration &CameraStream::configuration() const @@ -75,15 +62,30 @@ Stream *CameraStream::stream() const int CameraStream::configure() { - if (postProcessor_) { + if (type_ == Type::Internal || type_ == Type::Mapped) { + const PixelFormat outFormat = + cameraDevice_->capabilities()->toPixelFormat(camera3Stream_->format); StreamConfiguration output = configuration(); - output.pixelFormat = formats::MJPEG; + output.pixelFormat = outFormat; + switch (outFormat) { + case formats::MJPEG: + postProcessor_ = std::make_unique(cameraDevice_); + break; + + default: + LOG(HAL, Error) << "Unsupported format: " << outFormat; + return -EINVAL; + } + int ret = postProcessor_->configure(configuration(), output); if (ret) return ret; } - if (allocator_) { + if (type_ == Type::Internal) { + allocator_ = std::make_unique(cameraDevice_->camera()); + mutex_ = std::make_unique(); + int ret = allocator_->allocate(stream()); if (ret < 0) return ret;