From patchwork Sat Jul 4 13:31:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 8630 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 7C6DCBD792 for ; Sat, 4 Jul 2020 13:32:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4922560E47; Sat, 4 Jul 2020 15:32:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Jq292s/Y"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DFD7960E42 for ; Sat, 4 Jul 2020 15:32:12 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 766CB296; Sat, 4 Jul 2020 15:32:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593869532; bh=f0zrgE54vqdyST4DKNOV4UlKIZAgc6geK+ko1HvxXIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jq292s/Yn0oKcx8IqD//jixiBMt6y2KW3gOs+2bHlZMp/5LF3ev/KwPQgVKeQsv0s DnKZmLs8at9ZqFv1cv98C0Z0y4fw9BrUl7vFzAiRpH0kZMYvBLUAE6RDbOnaDBOFil 3AqDKVX1CnsDfwq4OUadnOdFQtV53OTZoHlHnIBA= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 22:31:27 +0900 Message-Id: <20200704133140.1738660-10-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704133140.1738660-1-paul.elder@ideasonboard.com> References: <20200704133140.1738660-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 09/22] v4l2: v4l2_camera_proxy: Get stride and frameSize from stream config 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" The stride and frameSize should be obtained through StreamConfiguration rather than PixelFormatInfo, as pipeline handlers might have different values (eg. for alignment). Get the stride and frameSize values from StreamConfiguration instead of from PixelFormatInfo. This also removes the need for V4L2CameraProxy::calculateSizeImage, so remove it. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- New in v3 --- src/v4l2/v4l2_camera_proxy.cpp | 42 ++++------------------------------ src/v4l2/v4l2_camera_proxy.h | 1 - 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 6a31415..9121d3d 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -71,7 +71,6 @@ int V4L2CameraProxy::open(V4L2CameraFile *file) vcam_->getStreamConfig(&streamConfig_); setFmtFromConfig(streamConfig_); - sizeimage_ = calculateSizeImage(streamConfig_); files_.insert(file); @@ -166,30 +165,20 @@ bool V4L2CameraProxy::validateMemoryType(uint32_t memory) void V4L2CameraProxy::setFmtFromConfig(StreamConfiguration &streamConfig) { const PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat); - Size size = streamConfig.size; - curV4L2Format_.fmt.pix.width = size.width; - curV4L2Format_.fmt.pix.height = size.height; + curV4L2Format_.fmt.pix.width = streamConfig.size.width; + curV4L2Format_.fmt.pix.height = streamConfig.size.height; curV4L2Format_.fmt.pix.pixelformat = info.v4l2Format; curV4L2Format_.fmt.pix.field = V4L2_FIELD_NONE; - curV4L2Format_.fmt.pix.bytesperline = info.stride(size.width, 0); - curV4L2Format_.fmt.pix.sizeimage = info.frameSize(size); + curV4L2Format_.fmt.pix.bytesperline = streamConfig.stride; + curV4L2Format_.fmt.pix.sizeimage = streamConfig.frameSize; curV4L2Format_.fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; curV4L2Format_.fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; curV4L2Format_.fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; curV4L2Format_.fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT; curV4L2Format_.fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; -} - -unsigned int V4L2CameraProxy::calculateSizeImage(StreamConfiguration &streamConfig) -{ - /* - * \todo Merge this method with setFmtFromConfig (need imageSize to - * support all libcamera formats first, or filter out MJPEG for now). - */ - const PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat); - return info.frameSize(streamConfig.size); + sizeimage_ = streamConfig.frameSize; } void V4L2CameraProxy::querycap(std::shared_ptr camera) @@ -359,12 +348,6 @@ int V4L2CameraProxy::vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg) if (ret < 0) return -EINVAL; - unsigned int sizeimage = calculateSizeImage(streamConfig_); - if (sizeimage == 0) - return -EINVAL; - - sizeimage_ = sizeimage; - setFmtFromConfig(streamConfig_); return 0; @@ -505,21 +488,6 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf if (ret < 0) return -EINVAL; - sizeimage_ = calculateSizeImage(streamConfig_); - /* - * If we return -EINVAL here then the application will think that we - * don't support streaming mmap. Since we don't support readwrite and - * userptr either, the application will get confused and think that - * we don't support anything. - * On the other hand, if the set format at the time of reqbufs has a - * zero sizeimage we'll get a floating point exception when we try to - * stream it. - */ - if (sizeimage_ == 0) - LOG(V4L2Compat, Warning) - << "sizeimage of at least one format is zero. " - << "Streaming this format will cause a floating point exception."; - setFmtFromConfig(streamConfig_); arg->count = streamConfig_.bufferCount; diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h index 49184a1..e962694 100644 --- a/src/v4l2/v4l2_camera_proxy.h +++ b/src/v4l2/v4l2_camera_proxy.h @@ -40,7 +40,6 @@ private: bool validateBufferType(uint32_t type); bool validateMemoryType(uint32_t memory); void setFmtFromConfig(StreamConfiguration &streamConfig); - unsigned int calculateSizeImage(StreamConfiguration &streamConfig); void querycap(std::shared_ptr camera); void tryFormat(struct v4l2_format *arg); enum v4l2_priority maxPriority();