From patchwork Wed Sep 1 08:03:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13592 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 7300FBD87D for ; Wed, 1 Sep 2021 08:03:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3AF5869168; Wed, 1 Sep 2021 10:03:16 +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="OdvJp5TU"; dkim-atps=neutral Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CD42D6916E for ; Wed, 1 Sep 2021 10:03:13 +0200 (CEST) Received: by mail-pj1-x1029.google.com with SMTP id ot2-20020a17090b3b4200b0019127f8ed87so3600629pjb.1 for ; Wed, 01 Sep 2021 01:03:13 -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=163iNKmkPLmRLJvUl/VhxyT4wAkZR03NjKv/9xsqY4Q=; b=OdvJp5TUrHc9jPH6XLhy1Tr14SkUwOg1O3eR1ZBVG4iRxrqcXrjUz27YPgN+9X27BL qTvKuebMzHDqFEnzk3/B4Fbc81QPUGLRVUVDU1VInYs83wE0NQ1rWBByMkzeZWUDMhIJ EM9u66cYqAfzT1zHQ+1KjBhDwQD7RE5pK4iNU= 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=163iNKmkPLmRLJvUl/VhxyT4wAkZR03NjKv/9xsqY4Q=; b=uLe6v2U9K0AMgOxDtQd5jy5H1Z5z3W84IEzmG1et0Ez0DMYaDR6gsjV0AUEihKdTGn yjmQ14BYVTPPEeHQHwhaNhjlyNsIMxuk4u2fb/dtwAzZILFlRkDKMJmokGdKAYvCsVQE 5KGnQ9SPCOeSeLG6leeJbPSXRv4Iuls1kpKLh/oZR4pqzePybXrw0FEOtToi/jGnvL7y 1nacEE/VQsTt5me3O2WP3eeD64h7TMmxXU+1BSC+Mi8JTt0ET+pQFKB3troxoBtCtk4E nmVCAddsIFm4qTYpnr3ksmEJTRypw1FRfQ8cpuZW4GeziyzB6fFhgG75pcYudKi1bHau Ly6Q== X-Gm-Message-State: AOAM532SbfvWYYh7ljllkoLx+KsxwqX5JpW8gvK3oV3uLbP39j3p7kG/ 2fZ8o49AlowRTEme0Zeew0e+MGdJn34Log== X-Google-Smtp-Source: ABdhPJxxjhitWOmpCbB6sbCdY/qaN/SgurZrFxHGdrC5GfKlUbFtAVq7rscL+HzWV3OyCbxY3LBNyg== X-Received: by 2002:a17:90a:aa17:: with SMTP id k23mr10386473pjq.47.1630483392169; Wed, 01 Sep 2021 01:03:12 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:af31:7c67:f02a:bccc]) by smtp.gmail.com with ESMTPSA id n15sm20487092pff.149.2021.09.01.01.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 01:03:11 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Sep 2021 17:03:02 +0900 Message-Id: <20210901080302.68525-3-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.259.gc128427fd7-goog In-Reply-To: <20210901080302.68525-1-hiroh@chromium.org> References: <20210901080302.68525-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 --- src/android/camera_device.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 324b997f..51d5370e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -618,12 +618,38 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) continue; } + /* + * Always add GRALLOC_USAGE_HW_CAMERA_WRITE to the usage on + * ChromeOS because cros::CameraBufferManager imports the stream + * buffer with the usage. + */ +#if defined(OS_CHROMEOS) + stream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE; +#endif + + /* + * 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; }