From patchwork Tue Aug 31 09:34:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13582 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 AC171BD87D for ; Tue, 31 Aug 2021 09:34:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6531869174; Tue, 31 Aug 2021 11:34:53 +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="NxRCMWfu"; dkim-atps=neutral Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 656A66916F for ; Tue, 31 Aug 2021 11:34:51 +0200 (CEST) Received: by mail-pf1-x432.google.com with SMTP id 7so14464002pfl.10 for ; Tue, 31 Aug 2021 02:34:51 -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=kfdDR7CMTSehSAbQHQbZcEcBqDud9VmKWl34D7lM/4g=; b=NxRCMWfur2v91WZVM6YfMJlmMg1e/q6pt9Y+eAAz+Gi3oziNX8DCqZY8XMCLK7Gtxn erl8zYApTYMbm3VLrUCyoaTuCPWe9tAVqsa3ekPV75kU7wXtg0yvuxLAnbXVD2VTbY2E zD0Mi3I0umOxMcmOPewXFGryjDp0zswkuZt0c= 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=kfdDR7CMTSehSAbQHQbZcEcBqDud9VmKWl34D7lM/4g=; b=RWPDVxZvSAifzs9prPl/iBlW9FDH8y57e15VAm5LBm9wfrrqS5AGALDGvmnSg0PFK6 57uWjbBR9UUP5ync/CKCQ3XHqYoi72odX15AuZXbaBJ3aN6kU1d2zsl7Q+N25ImIOUZx gzQoxUQ3YcysyuvSSdIUihpBcku0C8T0swK9biQZkp3g2o5M/f53TBfjrS27bOGqV/a3 nCzNokXbZHHVd0qS+2CGuBUZ8vKI/JIGe2h8h2yS0azn0hzN3vr/5fhYR5NNNhfN8bVY xwC0PTEMFoSi64rFzuwBXl36aDEzb+eKJF53D9sn0EdFzyyOZsN2TcI3pcxpGHX31qqI EnNg== X-Gm-Message-State: AOAM531fwqulHhFVPpi3aML06v4ioXEJnvMxoBHBKXiBOoHjowvgUUNA L3ICrFKtaIuAcFU7UdqrCkRVj20a1LtrSA== X-Google-Smtp-Source: ABdhPJwqep0jFIVNhV/wHJ9PTBy6/sN/mfLHM7q99WHhOnPCcc02RC5DrU3tYhsdGwyjg3h5vpUYog== X-Received: by 2002:aa7:9e4d:0:b0:3f8:6326:a038 with SMTP id z13-20020aa79e4d000000b003f86326a038mr17696249pfq.73.1630402489624; Tue, 31 Aug 2021 02:34:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 02:34:49 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 31 Aug 2021 18:34:39 +0900 Message-Id: <20210831093439.853586-4-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 3/3] android: camera_device: Configure one stream for identical stream requests 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" An Android HAL client may request identical stream requests. It is redundant that a native camera device produces a separate stream for each of the identical requests. Configure camera one stream configuration for the identical stream requests. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 74a95a2a..1cb4e675 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -618,14 +618,32 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) continue; } + /* This stream will be produced by hardware. */ + stream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE; + + /* + * If a CameraStream with the same size and format of the + * current stream has already been requested, associate the two. + */ + auto iter = std::find_if( + streamConfigs.begin(), streamConfigs.end(), + [size, format](const Camera3StreamConfig &streamConfig) { + return streamConfig.config.size == size && + streamConfig.config.pixelFormat == format; + }); + if (iter != streamConfigs.end()) { + /* Add usage to copy the buffer in streams[0] to stream. */ + iter->streams[0].stream->usage |= GRALLOC_USAGE_SW_READ_OFTEN; + stream->usage |= GRALLOC_USAGE_SW_WRITE_OFTEN; + iter->streams.push_back({ stream, CameraStream::Type::Mapped }); + continue; + } + Camera3StreamConfig streamConfig; streamConfig.streams = { { stream, CameraStream::Type::Direct } }; streamConfig.config.size = size; streamConfig.config.pixelFormat = format; streamConfigs.push_back(std::move(streamConfig)); - - /* This stream will be produced by hardware. */ - stream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE; } /* Now handle the MJPEG streams, adding a new stream if required. */ @@ -1144,12 +1162,12 @@ void CameraDevice::requestComplete(Request *request) resultMetadata = std::make_unique(0, 0); } - /* Handle any JPEG compression. */ + /* Handle post-processing. */ for (camera3_stream_buffer_t &buffer : descriptor.buffers_) { CameraStream *cameraStream = static_cast(buffer.stream->priv); - if (cameraStream->camera3Stream().format != HAL_PIXEL_FORMAT_BLOB) + if (cameraStream->type() == CameraStream::Type::Direct) continue; FrameBuffer *src = request->findBuffer(cameraStream->stream());