From patchwork Fri Feb 28 03:29:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 2916 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 667CC6271F for ; Fri, 28 Feb 2020 04:29:41 +0100 (CET) X-Halon-ID: 8dbb4e34-59da-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 8dbb4e34-59da-11ea-9f85-005056917a89; Fri, 28 Feb 2020 04:29:40 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 28 Feb 2020 04:29:13 +0100 Message-Id: <20200228032913.497826-7-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200228032913.497826-1-niklas.soderlund@ragnatech.se> References: <20200228032913.497826-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 6/6] v4l2: camera_proxy: Switch to PixelFormat 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-List-Received-Date: Fri, 28 Feb 2020 03:29:41 -0000 Remove proxies for PixelFormat and use the interface directly. Signed-off-by: Niklas Söderlund --- src/v4l2/v4l2_camera_proxy.cpp | 28 +++++++++------------------- src/v4l2/v4l2_camera_proxy.h | 3 --- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index e9d7bfd8ee243b78..7ea3039e0455c3f9 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -141,7 +141,7 @@ void V4L2CameraProxy::setFmtFromConfig(StreamConfiguration &streamConfig) { curV4L2Format_.fmt.pix.width = streamConfig.size.width; curV4L2Format_.fmt.pix.height = streamConfig.size.height; - curV4L2Format_.fmt.pix.pixelformat = drmToV4L2(streamConfig.pixelFormat); + curV4L2Format_.fmt.pix.pixelformat = streamConfig.pixelFormat.v4l2(); curV4L2Format_.fmt.pix.field = V4L2_FIELD_NONE; curV4L2Format_.fmt.pix.bytesperline = bplMultiplier(curV4L2Format_.fmt.pix.pixelformat) * @@ -159,7 +159,7 @@ unsigned int V4L2CameraProxy::calculateSizeImage(StreamConfiguration &streamConf * \todo Merge this method with setFmtFromConfig (need imageSize to * support all libcamera formats first, or filter out MJPEG for now). */ - return imageSize(drmToV4L2(streamConfig.pixelFormat), + return imageSize(streamConfig.pixelFormat.v4l2(), streamConfig.size.width, streamConfig.size.height); } @@ -229,7 +229,7 @@ int V4L2CameraProxy::vidioc_enum_fmt(struct v4l2_fmtdesc *arg) /* \todo Add map from format to description. */ utils::strlcpy(reinterpret_cast(arg->description), "Video Format Description", sizeof(arg->description)); - arg->pixelformat = drmToV4L2(streamConfig_.formats().pixelformats()[arg->index]); + arg->pixelformat = streamConfig_.formats().pixelformats()[arg->index].v4l2(); return 0; } @@ -249,7 +249,7 @@ int V4L2CameraProxy::vidioc_g_fmt(struct v4l2_format *arg) void V4L2CameraProxy::tryFormat(struct v4l2_format *arg) { - PixelFormat format = v4l2ToDrm(arg->fmt.pix.pixelformat); + PixelFormat format = PixelFormat(arg->fmt.pix.pixelformat); const std::vector &formats = streamConfig_.formats().pixelformats(); if (std::find(formats.begin(), formats.end(), format) == formats.end()) @@ -262,11 +262,11 @@ void V4L2CameraProxy::tryFormat(struct v4l2_format *arg) arg->fmt.pix.width = size.width; arg->fmt.pix.height = size.height; - arg->fmt.pix.pixelformat = drmToV4L2(format); + arg->fmt.pix.pixelformat = format.v4l2(); arg->fmt.pix.field = V4L2_FIELD_NONE; - arg->fmt.pix.bytesperline = bplMultiplier(drmToV4L2(format)) * + arg->fmt.pix.bytesperline = bplMultiplier(format.v4l2()) * arg->fmt.pix.width; - arg->fmt.pix.sizeimage = imageSize(drmToV4L2(format), + arg->fmt.pix.sizeimage = imageSize(format.v4l2(), arg->fmt.pix.width, arg->fmt.pix.height); arg->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; @@ -283,7 +283,7 @@ int V4L2CameraProxy::vidioc_s_fmt(struct v4l2_format *arg) Size size(arg->fmt.pix.width, arg->fmt.pix.height); int ret = vcam_->configure(&streamConfig_, size, - v4l2ToDrm(arg->fmt.pix.pixelformat), + PixelFormat(arg->fmt.pix.pixelformat), bufferCount_); if (ret < 0) return -EINVAL; @@ -345,7 +345,7 @@ int V4L2CameraProxy::vidioc_reqbufs(struct v4l2_requestbuffers *arg) Size size(curV4L2Format_.fmt.pix.width, curV4L2Format_.fmt.pix.height); ret = vcam_->configure(&streamConfig_, size, - v4l2ToDrm(curV4L2Format_.fmt.pix.pixelformat), + PixelFormat(curV4L2Format_.fmt.pix.pixelformat), arg->count); if (ret < 0) return -EINVAL; @@ -584,13 +584,3 @@ unsigned int V4L2CameraProxy::imageSize(uint32_t format, unsigned int width, return width * height * multiplier / 8; } - -PixelFormat V4L2CameraProxy::v4l2ToDrm(uint32_t format) -{ - return PixelFormat(format); -} - -uint32_t V4L2CameraProxy::drmToV4L2(PixelFormat format) -{ - return format.v4l2(); -} diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h index c8e61adf80f1b93b..03495d6266ef610a 100644 --- a/src/v4l2/v4l2_camera_proxy.h +++ b/src/v4l2/v4l2_camera_proxy.h @@ -59,9 +59,6 @@ private: static unsigned int imageSize(uint32_t format, unsigned int width, unsigned int height); - static PixelFormat v4l2ToDrm(uint32_t format); - static uint32_t drmToV4L2(PixelFormat format); - unsigned int refcount_; unsigned int index_; bool nonBlocking_;