From patchwork Thu Jan 5 04:37:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 18094 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 4CC1EC3291 for ; Thu, 5 Jan 2023 04:38:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 08999625F1; Thu, 5 Jan 2023 05:38:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1672893488; bh=mr5Sbr6Ad9FB1rrja5XwMm7+L+S22BtkUvzG9n9Aj04=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=PnSUeEMpZZXtz8DZrFohMknjUyY2Nd8g8RxrI88+SahCAEUeUy9X2yGSM8/j8MBVv 10hOGE9SOsPesmKTSBWiNffUOHGw/yXMV0Ky2ZrizjqUwhQpKZyn5L+eynlcfLwO+R oudl8l8DCNRTdeujIj2vLhaET34LcFathtxahSHsOnvVOK32kEJ9UW2v22dZTK7Ikj CPtc36DWx1xjklAEIxmMOB4m6DIQprN3fyEPZTTptKCPGO6kc/fp+dPPgDnBTkPbzW lyJjaGWEd9viYyH7wHx6blOE1TC9/KM3pUEU0qUnhmeOQpoDoBHM0kTuLhBcYXCB9q q6o0iNRVsvusw== Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6340B625F1 for ; Thu, 5 Jan 2023 05:38:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ZQCkgI8I"; dkim-atps=neutral Received: by mail-pj1-x1036.google.com with SMTP id c2-20020a17090a020200b00226c762ed23so861829pjc.5 for ; Wed, 04 Jan 2023 20:38:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hd42uG5tbVV4XTVn78gvQUXhPXrwSqPdQZFKksMQ2iI=; b=ZQCkgI8IG7n/XNiVoqiKsdRh9foZTg6vaeNRwZZwHcJvaZWHldWKtnbbrcRlbCPg/2 i9g1feXk4h4awnGT4t7RDwN/Mav+p5H06ufdMv7VCptfwGr82TIE+tBqwJFhUxTquwr2 wcgT6NH/BiPrc3VCitvdU73hiUfOFNvHojLdA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hd42uG5tbVV4XTVn78gvQUXhPXrwSqPdQZFKksMQ2iI=; b=hq0gG2EYuQpEGYyJQMtuF7vsZxefuRBW6W8verK0KAaumEds33N+Ykiz5DmunSCLOV u8CebLY/yZwr4p/MI74uHo0rtAmFnDqSFlAp9W50944GSp52+3TJkwOeMWZPRwUYLT2c DrS1qiQuJy+tyUScxGwi05ea+mpIOSwCkbtGgMOaHyCBB6NWXXrp0Lp20jryYVGbIbgU 5e8Zk1I5/LoADnp+DKblAf1DEepaKAuKCkM5VpHltoRyvt3Isbp3cgoevp4FKKikOlmq PS3bpe28WOrAJ6CXnYdQqJ1u0Ow65b/7SriyaXcfGcmE5BSN1IwSAi9WOwdpcIfhIlUC s7Ag== X-Gm-Message-State: AFqh2krJ83M+KKKB9rJaT4yAB/wOY8Kl9UsMFjDg/ikguXpvQm/EnIjw PeSRu0JyBlEBR/UZ93hT0VlabSg8GS9KxN9O X-Google-Smtp-Source: AMrXdXv7NvyAuNyUyTkT5Y1BoB23gB1p87N74+GkXypPpOAKGIqLtMGx5VdRwgJKvCDa/KSU5QHRqA== X-Received: by 2002:a05:6a21:99a4:b0:a3:94cd:1435 with SMTP id ve36-20020a056a2199a400b000a394cd1435mr81893332pzb.38.1672893482748; Wed, 04 Jan 2023 20:38:02 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (46.165.189.35.bc.googleusercontent.com. [35.189.165.46]) by smtp.gmail.com with ESMTPSA id x23-20020a170902b41700b00188c5f0f9e9sm25015200plr.199.2023.01.04.20.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 20:38:02 -0800 (PST) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Thu, 5 Jan 2023 04:37:25 +0000 Message-Id: <20230105043726.679968-9-chenghaoyang@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230105043726.679968-1-chenghaoyang@google.com> References: <20230105043726.679968-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 8/9] libcamera: pipeline: virtual: Queue 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: , X-Patchwork-Original-From: Harvey Yang via libcamera-devel From: Harvey Yang Reply-To: Harvey Yang Cc: Harvey Yang , Harvey Yang Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" [todo Use UDMA to allocate buffers in the exportFrameBuffers API] [todo Read frames from the virtual video if any] Currently we only use external buffers and complete them immediately with green frames. Signed-off-by: Harvey Yang --- src/libcamera/pipeline/virtual/virtual.cpp | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp index ef2901e7..db6fe14c 100644 --- a/src/libcamera/pipeline/virtual/virtual.cpp +++ b/src/libcamera/pipeline/virtual/virtual.cpp @@ -8,6 +8,8 @@ #include #include +#include +#include #include #include "libcamera/internal/camera.h" @@ -18,6 +20,17 @@ namespace libcamera { LOG_DEFINE_CATEGORY(VIRTUAL) +uint64_t CurrentTimestamp() +{ + struct timespec ts; + if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { + LOG(VIRTUAL, Error) << "Get clock time fails"; + return 0; + } + + return ts.tv_sec * 1'000'000'000LL + ts.tv_nsec; +} + class VirtualCameraData : public Camera::Private { public: @@ -214,6 +227,7 @@ int PipelineHandlerVirtual::exportFrameBuffers(Camera *camera, Stream *stream, (void)camera; (void)stream; (void)buffers; + // TODO: Use UDMA to allocate buffers. return -1; } @@ -221,19 +235,28 @@ int PipelineHandlerVirtual::start(Camera *camera, const ControlList *controls) { (void)camera; (void)controls; - return -1; + // TODO: Start reading the virtual video if any. + return 0; } void PipelineHandlerVirtual::stopDevice(Camera *camera) { (void)camera; + // TODO: Reset the virtual video if any. } int PipelineHandlerVirtual::queueRequestDevice(Camera *camera, Request *request) { (void)camera; - (void)request; - return -1; + + // TODO: Read from the virtual video if any. + for (auto it : request->buffers()) + completeBuffer(request, it.second); + + request->metadata().set(controls::SensorTimestamp, CurrentTimestamp()); + completeRequest(request); + + return 0; } bool PipelineHandlerVirtual::match(DeviceEnumerator *enumerator)