From patchwork Wed Feb 13 15:10:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 573 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A90C610B3 for ; Wed, 13 Feb 2019 16:10:33 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 29FF99B0; Wed, 13 Feb 2019 16:10:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1550070633; bh=q7Ytn3pTi34DJTXfOeovbc/1Zs5DwSIecgKK/3ycftU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LhpZuA6SHDjMgm0d2cR21KQM5tElNYKalZY0m5Sp/JISC2CTqAHHgDXSDfN4gCiqW ORVLtUuLdZnWG/1D1kxT75LfxFNonLo3liVZKsjsBMBTnCCTc5ozaotQMKjx7rJWxC pv9Fx6JWXBxIDv9TVtwaSQQnatpSGdgVrvbiJ/qk= From: Kieran Bingham To: LibCamera Devel Date: Wed, 13 Feb 2019 15:10:23 +0000 Message-Id: <20190213151027.6376-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190213151027.6376-1-kieran.bingham@ideasonboard.com> References: <20190213151027.6376-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/8] libcamera: v4l2_device: Support queueing buffers to an output device X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Feb 2019 15:10:33 -0000 To queue a buffer to an output device, we must set the buffer properties. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/v4l2_device.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 83073c28b817..8c038239cf24 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -299,7 +299,15 @@ int V4L2Device::open() ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : V4L2_BUF_TYPE_VIDEO_OUTPUT; - fdEvent_ = new EventNotifier(fd_, EventNotifier::Read); + /* + * We wait for Read notifications on CAPTURE devices (POLLIN), and + * Write notifications for OUTPUT devices (POLLOUT). + */ + if (caps_.isCapture()) + fdEvent_ = new EventNotifier(fd_, EventNotifier::Read); + else + fdEvent_ = new EventNotifier(fd_, EventNotifier::Write); + fdEvent_->activated.connect(this, &V4L2Device::bufferAvailable); fdEvent_->setEnabled(false); @@ -679,6 +687,15 @@ int V4L2Device::queueBuffer(Buffer *buffer) buf.m.planes = planes; } + if (V4L2_TYPE_IS_OUTPUT(bufferType_)) { + buf.bytesused = buffer->bytesused_; + buf.sequence = buffer->sequence_; + /** + * \todo: Timestamp should be converted back to a struct + * timeval for passing back into V4L2. + */ + } + LOG(V4L2, Debug) << "Queueing buffer " << buf.index; ret = ioctl(fd_, VIDIOC_QBUF, &buf);