{"id":13590,"url":"https://patchwork.libcamera.org/api/1.1/patches/13590/?format=json","web_url":"https://patchwork.libcamera.org/patch/13590/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210901080302.68525-1-hiroh@chromium.org>","date":"2021-09-01T08:03:00","name":"[libcamera-devel,v4,1/3] android: camera_stream: Create post processor in configure()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"bb2e32d95920001d0c08370b71266385c0c7b134","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13590/mbox/","series":[{"id":2432,"url":"https://patchwork.libcamera.org/api/1.1/series/2432/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2432","date":"2021-09-01T08:03:00","name":"[libcamera-devel,v4,1/3] android: camera_stream: Create post processor in configure()","version":4,"mbox":"https://patchwork.libcamera.org/series/2432/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13590/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13590/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 017A2BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Sep 2021 08:03:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 752256916A;\n\tWed,  1 Sep 2021 10:03:12 +0200 (CEST)","from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com\n\t[IPv6:2607:f8b0:4864:20::102f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 44F0F60253\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Sep 2021 10:03:10 +0200 (CEST)","by mail-pj1-x102f.google.com with SMTP id fs6so1321638pjb.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 01 Sep 2021 01:03:10 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:af31:7c67:f02a:bccc])\n\tby smtp.gmail.com with ESMTPSA id\n\tn15sm20487092pff.149.2021.09.01.01.03.06\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 01 Sep 2021 01:03:07 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"XSLfgC79\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; h=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=cItemiujnNVa1yFezYOfz3GV3vHnQEPz+KUKqpEfyTA=;\n\tb=XSLfgC79Cn1YEjv9Tk5+NoTnXhBJFQWCbOFVdHicneUckm5Om/2G5OwGb8ZMdNbZsI\n\tuWYddaU0zWkoQK6CPpne3cKb+HjHnC6aGwixpnMPwqZOLYblcjU7fVocQgqIJlOGh6Ge\n\teNxq2jiSbqqHnrIPAfVUl3ZhkF+oYPQuYqzeg=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=cItemiujnNVa1yFezYOfz3GV3vHnQEPz+KUKqpEfyTA=;\n\tb=O8o+05U3e8W3YIygy3BDSbqRWiCUu16r8Zj/J80VJ0deCtbvx7m52CscBxKHmFisY5\n\tQw9AHTZA6HH8RRbSGWG7Ndgs1g++PShlU2WpBboxtOKuaVgbZ2u5pvuCQKLjqRmXuFi4\n\tMQSXKVTfTqczRJPNq7AXfkD7QCexmSe0t+DGXPFvBx4ixO4xOGvb4HJhuXb6cXcDZMPY\n\tKK2ACmsRVsrdLwHAj86E+l1iT55+VPs08s2Yr50ZMc0Tiweb4dsPn9Z+3PYHEz3a1OYB\n\t6JgabVu+QcMza1m7OL6K7z6uaISbkkrilYUYrTDBN9MC99ws93ETXfxVkXiUpG83SONk\n\tAHAg==","X-Gm-Message-State":"AOAM533KfV+Kl/THRhLpkaI55i4CDryGpK9l+CaqJna2y86hsTKCFM1x\n\tz+kXWLSSXBl+4G69RyfHJWR9amDtGSZPGA==","X-Google-Smtp-Source":"ABdhPJzUQb/0qlMGjVpIAJu8XzQbHrzQpBKofBPSDw7gLWDk3dR0yRKTouPghh6CmRVm+Rh+aoETAw==","X-Received":"by 2002:a17:90a:2c0c:: with SMTP id\n\tm12mr10318789pjd.107.1630483388257; \n\tWed, 01 Sep 2021 01:03:08 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  1 Sep 2021 17:03:00 +0900","Message-Id":"<20210901080302.68525-1-hiroh@chromium.org>","X-Mailer":"git-send-email 2.33.0.259.gc128427fd7-goog","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 1/3] android: camera_stream: Create\n\tpost processor in configure()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"CameraStream creates PostProcessor and FrameBufferAllocator in\nthe constructor. CameraStream assumes that a used post processor\nis JPEG post processor. Since we need to support various post\nprocessors, we would rather move the creation to configure() so\nas to return an error code if no proper post processor is found.\nThis also moves FrameBufferAllocator and Mutex creation for\nconsistency.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/android/camera_device.h   |  1 +\n src/android/camera_stream.cpp | 37 +++++++++++++++++++----------------\n 2 files changed, 21 insertions(+), 17 deletions(-)","diff":"diff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex a5576927..296c2f18 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -48,6 +48,7 @@ public:\n \n \tunsigned int id() const { return id_; }\n \tcamera3_device_t *camera3Device() { return &camera3Device_; }\n+\tconst CameraCapabilities *capabilities() const { return &capabilities_; }\n \tconst std::shared_ptr<libcamera::Camera> &camera() const { return camera_; }\n \n \tconst std::string &maker() const { return maker_; }\ndiff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex 01909ec7..3fce29c1 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -10,6 +10,7 @@\n #include <sys/mman.h>\n \n #include \"camera_buffer.h\"\n+#include \"camera_capabilities.h\"\n #include \"camera_device.h\"\n #include \"camera_metadata.h\"\n #include \"jpeg/post_processor_jpeg.h\"\n@@ -47,20 +48,6 @@ CameraStream::CameraStream(CameraDevice *const cameraDevice,\n \t: cameraDevice_(cameraDevice), config_(config), type_(type),\n \t  camera3Stream_(camera3Stream), index_(index)\n {\n-\tif (type_ == Type::Internal || type_ == Type::Mapped) {\n-\t\t/*\n-\t\t * \\todo There might be multiple post-processors. The logic\n-\t\t * which should be instantiated here, is deferred for the\n-\t\t * future. For now, we only have PostProcessorJpeg and that\n-\t\t * is what we instantiate here.\n-\t\t */\n-\t\tpostProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n-\t}\n-\n-\tif (type == Type::Internal) {\n-\t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n-\t\tmutex_ = std::make_unique<std::mutex>();\n-\t}\n }\n \n const StreamConfiguration &CameraStream::configuration() const\n@@ -75,15 +62,31 @@ Stream *CameraStream::stream() const\n \n int CameraStream::configure()\n {\n-\tif (postProcessor_) {\n+\tif (type_ == Type::Internal || type_ == Type::Mapped) {\n+\t\tconst PixelFormat outFormat =\n+\t\t\tcameraDevice_->capabilities()->toPixelFormat(camera3Stream_->format);\n \t\tStreamConfiguration output = configuration();\n-\t\toutput.pixelFormat = formats::MJPEG;\n+\t\toutput.pixelFormat = outFormat;\n+\n+\t\tswitch (outFormat) {\n+\t\tcase formats::MJPEG:\n+\t\t\tpostProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tLOG(HAL, Error) << \"Unsupported format: \" << outFormat;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n \t\tint ret = postProcessor_->configure(configuration(), output);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\n \n-\tif (allocator_) {\n+\tif (type_ == Type::Internal) {\n+\t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n+\t\tmutex_ = std::make_unique<std::mutex>();\n+\n \t\tint ret = allocator_->allocate(stream());\n \t\tif (ret < 0)\n \t\t\treturn ret;\n","prefixes":["libcamera-devel","v4","1/3"]}