From patchwork Mon Sep 27 10:48:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13943 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 8287DC3243 for ; Mon, 27 Sep 2021 10:48:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9B1296918D; Mon, 27 Sep 2021 12:48:31 +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="SG/uA4X5"; dkim-atps=neutral Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 93F446012C for ; Mon, 27 Sep 2021 12:48:29 +0200 (CEST) Received: by mail-pg1-x536.google.com with SMTP id m21so17373436pgu.13 for ; Mon, 27 Sep 2021 03:48:29 -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:mime-version :content-transfer-encoding; bh=kIgClH2jhSSOF5H3+OdYOPvse59Nf74Qs578mvWmcnQ=; b=SG/uA4X56SIdRe77W9MAMntB7n6gNIIjwNWdPbPiERfxJ2/j3iyrOv5KnFtTIPqdDC kbrAgfJESS0SwsGgxlsZZzyfsU9sfFUejnu9I8SjsxKH/6YlbV8txoczFw/HHNjJOHiD 3QPYbfDw713DErx4/v1uL837OnuyG1zwnBBq8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kIgClH2jhSSOF5H3+OdYOPvse59Nf74Qs578mvWmcnQ=; b=noFhyINZhiljTBBQmXQpY6lXuTtaeYScsnKUMM6YrBd+CpPzuYY3uMwM/rq4+L4KEd jRqWaj6blSrtne2SbeJhQ6oDVZaPssTEou5RAp7aeoaSjB7AXyZlMZ6oZekhF2U63hHn cYAdclYgzHiDwbwLOHEzpLgB5dx5r6TadG/CS8R24oovpIAaTjosa1fJraPL8sNigE+i T63JuoSmD1ke3sCRYSiJWnLitSL1/5LLKYGPQDioR2mcIT+EMdIFZGCN53EQ64nQjVu0 WXAQQM+QuoYMziN7VaqsantGrtWXVotZc5nezAWUpzML0xoKZSIRESMcWIwSNpaCl+RA v65A== X-Gm-Message-State: AOAM531vmbj+ficwkUWZhA4ypsL6S1qiRydOy11+LD9RWYv/vrqiNJuR g51V4Dxy8WBah1PDMMqCGBjrahDwpwqSYA== X-Google-Smtp-Source: ABdhPJx9+cKC583utNIx6f0pFkagLmxn9HwAjWAL8Ser3oFjEvPZlHZZHOZk5a5hiu/+mV7z0/GLzw== X-Received: by 2002:a63:125f:: with SMTP id 31mr15879657pgs.98.1632739707396; Mon, 27 Sep 2021 03:48:27 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:7cac:9967:6683:8845]) by smtp.gmail.com with ESMTPSA id b11sm18694452pge.57.2021.09.27.03.48.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 03:48:26 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Sep 2021 19:48:19 +0900 Message-Id: <20210927104821.2526508-1-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 0/2] android: Fix the issue with Type::Mapped only request 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" We have the problem that no buffer is not provided to a native camera if a request given in CameraDevice::processCaptureRequest() contains only streams that are resolved as CameraStream::Type::Mapped in CameraDevice::configureStreams(). See the example in below. ``` [0:27:06.863311142] [15203] DEBUG HAL camera_device.cpp:980 '\_SB_.PCI0.I2C2.CAM0': Queueing request 139090704005584 with 2 streams [0:27:06.863389502] [15203] DEBUG HAL camera_device.cpp:1005 '\_SB_.PCI0.I2C2.CAM0': 0 - (320x240)[0x00000022] -> (320x240)[NV12] (mapped) [0:27:06.863436331] [15203] DEBUG HAL camera_device.cpp:1005 '\_SB_.PCI0.I2C2.CAM0': 1 - (320x240)[0x00000021] -> (320x240)[NV12] (mapped) [0:27:06.863487886] [15203] DEBUG HAL camera_device.cpp:1043 '\_SB_.PCI0.I2C2.CAM0': buffers=0 [0:27:06.863561912] [15218] ERROR Camera camera.cpp:1031 Request contains no buffers ``` This patch series fixes the issue by looking up the stream alternatively sent to a native camera. To do that, we have to allocate a FrameBuffer for the stream. One possible way is to use FrameBufferAllocator. However, FrameBufferAllocator::allocate must be called when the state of Camera is Configured, but not Running. So we have to allocate buffers during configureStreams(). But allocating buffers for CameraStrems whose type is Direct wastes memory as they tends to not be used at all. I would rather have a new class that allocates FrameBuffers in a platform-dependent way, cros::CameraBufferManager on ChromeOS and gralloc API on other platforms. With this patch, android.hardware.camera2.cts.SurfaceViewPreviewTest#testDeferredSurfaces passed. Hirokazu Honda (2): android: Introduce PlatformFrameBufferAllocator android: Send alternative stream configuration if no buffer to be sent exists src/android/camera_device.cpp | 50 ++++++++-- src/android/camera_device.h | 4 + src/android/camera_stream.cpp | 37 +++++++- src/android/camera_stream.h | 10 +- src/android/frame_buffer.h | 53 +++++++++++ src/android/mm/cros_frame_buffer.cpp | 85 +++++++++++++++++ src/android/mm/generic_frame_buffer.cpp | 116 ++++++++++++++++++++++++ src/android/mm/meson.build | 6 +- 8 files changed, 344 insertions(+), 17 deletions(-) create mode 100644 src/android/frame_buffer.h create mode 100644 src/android/mm/cros_frame_buffer.cpp create mode 100644 src/android/mm/generic_frame_buffer.cpp --- 2.33.0.685.g46640cef36-goog