From patchwork Wed Jul 22 13:30:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 8922 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 6DB54BDB1B for ; Wed, 22 Jul 2020 13:30:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B04E6099C; Wed, 22 Jul 2020 15:30:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="B8TAcVme"; dkim-atps=neutral Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D6436053C for ; Wed, 22 Jul 2020 15:30:36 +0200 (CEST) Received: by mail-pf1-x42f.google.com with SMTP id a14so1298884pfi.2 for ; Wed, 22 Jul 2020 06:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=poWeSreCTal/V0s2LiZRT7HUmka+2mMTBFWoj7kaSlo=; b=B8TAcVmeDfrEsTSbCN+045mcI65NDZVdUDPUEts8Ca2jUaUrVfOPxu8ELkIAWt2mUA yYW095xlgjc6ZKk2CKIRljtXGBUPK0W6RR8UIjp4VmnjbpveeDQQ55TfXeoMp90ougdg 2VeaYCwMozsifS5ShAUdxfoPx65tpw4gwFkJoRLx9+NZT3Jvb+J8oHdNyKiWi0jfkG3o vOovK/QpnMRa1LWY//Sr9LoeBaTgbXzxlOQNedXou4Q5hUUtr+h/uufYy+2gnYExrTsZ pqlWet5HEameVNmsDY5pSOz3RVWwc9z598rEVhQtwP7NRQaHY25anXOk0n79vmLJkMok +Jzg== 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; bh=poWeSreCTal/V0s2LiZRT7HUmka+2mMTBFWoj7kaSlo=; b=XNmkpv12cb9+cz5oOXnQ4sVcgRorDCLceEz8rK1piSF1giY/p/J9kjOVKz1zYeqiqa FxJTWDU017cUxwg995rW1DZE3h0AjKxCftwYsx9WFrNq5jDpQP8/nfnI3pT+/cvT6lcM a0Oxe9cKilh2rdedELcp5dHPStBlfBuzMv3y6nvZ6rRWvKZ23+npnUWh9Fk/wuKM5sh3 M2tJwtF1DgGqsAxrdaU8bT4ON0D9jwZecx1LujNav3mu5eaC5NJjaBsWAz0P5of5bQxl +8LWzrRHvtjtacaXojmbOn1QkoXdq008r/+flXw2D5QKwh2lfFZ9MGiS6SEORudvTDgK vYoQ== X-Gm-Message-State: AOAM531PpFdzXDPKQnWwpIdrZw9dhPYEpAKgJrOSRxvOtdIsT1pfi+dJ XtREixhUB81Vw0U8cKwgoeieoA== X-Google-Smtp-Source: ABdhPJzQ/OZ1ABZv/UANRJUMSdjl8fWUtRugh/g1FfRCgMTzpWr2lhV444VF0io4lH8Q4d32F60+Vg== X-Received: by 2002:a62:7e51:: with SMTP id z78mr29027453pfc.3.1595424634901; Wed, 22 Jul 2020 06:30:34 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id cv3sm6529541pjb.45.2020.07.22.06.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 06:30:34 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham Date: Wed, 22 Jul 2020 19:00:07 +0530 Message-Id: <20200722133009.26528-6-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200722133009.26528-1-kgupta@es.iitr.ac.in> References: <20200722133009.26528-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH 5/7] libcamera: pipeline: vimc: Take care of buffers 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: , Cc: Kaaira Gupta MIME-Version: 1.0 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Introduce a bufferReady function for RAW streams. Take care of exporting the correct buffers according to the stream required. Also start and stop the correct buffers accordingly. Signed-off-by: Kaaira Gupta --- src/libcamera/pipeline/vimc/vimc.cpp | 52 ++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index c2ed5b6..6010e1e 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -59,6 +59,7 @@ public: int init(); void bufferReady(FrameBuffer *buffer); + void bufferReadyRaw(FrameBuffer *buffer); MediaDevice *media_; CameraSensor *sensor_; @@ -433,29 +434,50 @@ int PipelineHandlerVimc::exportFrameBuffers(Camera *camera, Stream *stream, VimcCameraData *data = cameraData(camera); unsigned int count = stream->configuration().bufferCount; - return data->video_->exportBuffers(count, buffers); + if (stream == &data->rawStream_) + return data->raw_->exportBuffers(count, buffers); + else if (stream == &data->rgbStream_) + return data->video_->exportBuffers(count, buffers); + else + return -EINVAL; } int PipelineHandlerVimc::start(Camera *camera) { VimcCameraData *data = cameraData(camera); unsigned int count = data->rgbStream_.configuration().bufferCount; + unsigned int rCount = data->rawStream_.configuration().bufferCount; int ret = data->video_->importBuffers(count); if (ret < 0) return ret; + ret = data->raw_->importBuffers(rCount); + if (ret < 0) + return ret; + ret = data->ipa_->start(); if (ret) { data->video_->releaseBuffers(); + data->raw_->releaseBuffers(); return ret; } - ret = data->video_->streamOn(); - if (ret < 0) { - data->ipa_->stop(); - data->video_->releaseBuffers(); - return ret; + if (count) { + ret = data->video_->streamOn(); + if (ret < 0) { + data->ipa_->stop(); + data->video_->releaseBuffers(); + return ret; + } + } + if (rCount) { + ret = data->raw_->streamOn(); + if (ret < 0) { + data->ipa_->stop(); + data->raw_->releaseBuffers(); + return ret; + } } return 0; @@ -464,8 +486,10 @@ int PipelineHandlerVimc::start(Camera *camera) void PipelineHandlerVimc::stop(Camera *camera) { VimcCameraData *data = cameraData(camera); + data->raw_->streamOff(); data->video_->streamOff(); data->ipa_->stop(); + data->raw_->releaseBuffers(); data->video_->releaseBuffers(); } @@ -653,7 +677,21 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer) Request *request = buffer->request(); pipe_->completeBuffer(camera_, request, buffer); - pipe_->completeRequest(camera_, request); + if (!(request->hasPendingBuffers())) { + pipe_->completeRequest(camera_, request); + } + return; +} + +void VimcCameraData::bufferReadyRaw(FrameBuffer *buffer) +{ + Request *request = buffer->request(); + + pipe_->completeBuffer(camera_, request, buffer); + if (!(request->hasPendingBuffers())) { + pipe_->completeRequest(camera_, request); + } + return; } REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc);