From patchwork Thu Aug 5 13:45:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13208 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 BE699C3235 for ; Thu, 5 Aug 2021 13:45:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 682206880D; Thu, 5 Aug 2021 15:45:42 +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="CExvTRSE"; dkim-atps=neutral Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1997E68825 for ; Thu, 5 Aug 2021 15:45:41 +0200 (CEST) Received: by mail-pj1-x1032.google.com with SMTP id mt6so8902031pjb.1 for ; Thu, 05 Aug 2021 06:45:40 -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=FZ+qHQMj/SH7aTuzXMvDa5zWAyyLr8lbPyx3XK2oqUo=; b=CExvTRSENCqHLg0fH24ZiYL5BwfJGeClSoXLTMC+6yCqClVt0j16FtcrKfkJKCutxC JgAu+ZqLCKycXv3kvPwh7X+sG+aou6JpgmarC5Nl5S2ZR6iGjk0hnuCRfCsshqn+C9q+ S/UyxZ7vK0zzXwq9Zd//lYZFrP2UVmkDGm19A= 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=FZ+qHQMj/SH7aTuzXMvDa5zWAyyLr8lbPyx3XK2oqUo=; b=FktkaJvmM1h1QcHU6njuGC/bcBJSdtGASYft/GR6zC88hjQ2Fv7t4BiKxJ1Y5wm1bw ymt9jxOVfpQW3gfAx0HziyVZ9BOdnx3cc7aTJfNdg6btMpEXHte/TWB7tfdCuMt9o/yy zyYJIvWxgauyHNCMBe+68vTS16YWcqfo3jM3wndMhp/RTzN3bdU4U4CvGsbmgOrb62lA v+cL+VnvuEH0G/XTdQKKoJqau6kdHaVygFNQTK2+HfOyqAa5qAgZHVc9Tk7DfD1W+8Dc DCxFUx5fVOLdD8wfVZ1A8hqA9wnliT7BGjSB/Gt09fM7rkNOBpKyjYNVhthZT5lmmCh8 9oxQ== X-Gm-Message-State: AOAM532nQZ84ryN9Q4HMJ4l2c4einhB+0eDuvbyM9Q5Sv0jofhzpn2Z9 pMYg1XJNUaV+j1FxyC0fSaSNwZ3TFa4WOw== X-Google-Smtp-Source: ABdhPJyiQl7aE1RfqO8lzMdNkPQuzYjov06AWkjTvb/iro5LZtyyN0n/hccD3tUY+KGHaPxgblW6BQ== X-Received: by 2002:a17:902:e890:b029:12c:d39d:20bb with SMTP id w16-20020a170902e890b029012cd39d20bbmr4320124plg.83.1628171139046; Thu, 05 Aug 2021 06:45:39 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:490b:61c8:a52a:e6eb]) by smtp.gmail.com with ESMTPSA id b8sm6029381pjo.51.2021.08.05.06.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Aug 2021 06:45:38 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 5 Aug 2021 22:45:28 +0900 Message-Id: <20210805134530.825065-2-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210805134530.825065-1-hiroh@chromium.org> References: <20210805134530.825065-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] android: camera_stream: Create post porcessor 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 --- src/android/camera_device.h | 2 ++ src/android/camera_stream.cpp | 35 ++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 089a6204..cbc71be4 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -63,6 +63,8 @@ public: int processCaptureRequest(camera3_capture_request_t *request); void requestComplete(libcamera::Request *request); + libcamera::PixelFormat toPixelFormat(int format) const; + protected: std::string logPrefix() const override; diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index bf4a7b41..86263403 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -45,20 +45,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 @@ -73,15 +59,30 @@ Stream *CameraStream::stream() const int CameraStream::configure() { - if (postProcessor_) { + if (type_ == Type::Internal || type_ == Type::Mapped) { + const PixelFormat outFormat = + cameraDevice_->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;