{"id":9362,"url":"https://patchwork.libcamera.org/api/patches/9362/?format=json","web_url":"https://patchwork.libcamera.org/patch/9362/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200822134605.17666-3-laurent.pinchart@ideasonboard.com>","date":"2020-08-22T13:46:04","name":"[libcamera-devel,2/3] v4l2: camera_proxy: Store v4l2_pix_format instead of v4l2_format","commit_ref":"852b9d0a7636fd7fa34cb424a9992642af4826b9","pull_url":null,"state":"accepted","archived":false,"hash":"f3b3da25dbfccb3b90d190e0d41dc050c60d954b","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9362/mbox/","series":[{"id":1232,"url":"https://patchwork.libcamera.org/api/series/1232/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1232","date":"2020-08-22T13:46:02","name":"v4l2: Miscellaneous cleanups","version":1,"mbox":"https://patchwork.libcamera.org/series/1232/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9362/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9362/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 63EDABE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 22 Aug 2020 13:46:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 127516279A;\n\tSat, 22 Aug 2020 15:46:30 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 79BEC6212A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 22 Aug 2020 15:46:28 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 197B829E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 22 Aug 2020 15:46:28 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"hmwJQiRs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1598103988;\n\tbh=ZW/pjwbnH6j1zhvwvj/rLDCoZ6wMTIDazASCnShZz1Y=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=hmwJQiRs8yW90QWf9/8BqNmLpLgygombsh1LvTJ95yJTgM3l43rPWwvFf6F5JWkKU\n\tEcHR2grKxTZhx6GiTllmUQ5pnlHep2jJ11625kCsyXxscK7kS1n4Wc8p9cYxfEKP/V\n\tyUcIiOB55cBNbnZBm424V3sOhOM0Mpcczw5V3X9o=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 22 Aug 2020 16:46:04 +0300","Message-Id":"<20200822134605.17666-3-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200822134605.17666-1-laurent.pinchart@ideasonboard.com>","References":"<20200822134605.17666-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 2/3] v4l2: camera_proxy: Store\n\tv4l2_pix_format instead of v4l2_format","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The V4L2 compatibility layer only uses the fmt.pix field of\ncurV4L2Format_. There's no need to cache the full v4l2_format, store\nv4l2_pix_format only and rename the member variable from curV4L2Format_\nto v4l2PixFormat_. While at it, group the V4L2-related member variables\ntogether in the V4L2CameraProxy class.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/v4l2/v4l2_camera_proxy.cpp | 32 ++++++++++++++++----------------\n src/v4l2/v4l2_camera_proxy.h   |  5 +++--\n 2 files changed, 19 insertions(+), 18 deletions(-)","diff":"diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 079257f4bf22..80287d8f164e 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -167,17 +167,17 @@ void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)\n \tconst PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat);\n \tconst Size &size = streamConfig.size;\n \n-\tcurV4L2Format_.fmt.pix.width        = size.width;\n-\tcurV4L2Format_.fmt.pix.height       = size.height;\n-\tcurV4L2Format_.fmt.pix.pixelformat  = info.v4l2Format;\n-\tcurV4L2Format_.fmt.pix.field        = V4L2_FIELD_NONE;\n-\tcurV4L2Format_.fmt.pix.bytesperline = streamConfig.stride;\n-\tcurV4L2Format_.fmt.pix.sizeimage    = streamConfig.frameSize;\n-\tcurV4L2Format_.fmt.pix.colorspace   = V4L2_COLORSPACE_SRGB;\n-\tcurV4L2Format_.fmt.pix.priv         = V4L2_PIX_FMT_PRIV_MAGIC;\n-\tcurV4L2Format_.fmt.pix.ycbcr_enc    = V4L2_YCBCR_ENC_DEFAULT;\n-\tcurV4L2Format_.fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT;\n-\tcurV4L2Format_.fmt.pix.xfer_func    = V4L2_XFER_FUNC_DEFAULT;\n+\tv4l2PixFormat_.width        = size.width;\n+\tv4l2PixFormat_.height       = size.height;\n+\tv4l2PixFormat_.pixelformat  = info.v4l2Format;\n+\tv4l2PixFormat_.field        = V4L2_FIELD_NONE;\n+\tv4l2PixFormat_.bytesperline = streamConfig.stride;\n+\tv4l2PixFormat_.sizeimage    = streamConfig.frameSize;\n+\tv4l2PixFormat_.colorspace   = V4L2_COLORSPACE_SRGB;\n+\tv4l2PixFormat_.priv         = V4L2_PIX_FMT_PRIV_MAGIC;\n+\tv4l2PixFormat_.ycbcr_enc    = V4L2_YCBCR_ENC_DEFAULT;\n+\tv4l2PixFormat_.quantization = V4L2_QUANTIZATION_DEFAULT;\n+\tv4l2PixFormat_.xfer_func    = V4L2_XFER_FUNC_DEFAULT;\n \n \tsizeimage_ = streamConfig.frameSize;\n }\n@@ -291,7 +291,7 @@ int V4L2CameraProxy::vidioc_g_fmt(V4L2CameraFile *file, struct v4l2_format *arg)\n \t\treturn -EINVAL;\n \n \tmemset(&arg->fmt, 0, sizeof(arg->fmt));\n-\targ->fmt.pix = curV4L2Format_.fmt.pix;\n+\targ->fmt.pix = v4l2PixFormat_;\n \n \treturn 0;\n }\n@@ -488,8 +488,8 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n \tif (bufferCount_ > 0)\n \t\tfreeBuffers();\n \n-\tSize size(curV4L2Format_.fmt.pix.width, curV4L2Format_.fmt.pix.height);\n-\tV4L2PixelFormat v4l2Format = V4L2PixelFormat(curV4L2Format_.fmt.pix.pixelformat);\n+\tSize size(v4l2PixFormat_.width, v4l2PixFormat_.height);\n+\tV4L2PixelFormat v4l2Format = V4L2PixelFormat(v4l2PixFormat_.pixelformat);\n \tint ret = vcam_->configure(&streamConfig_, size,\n \t\t\t\t   PixelFormatInfo::info(v4l2Format).format,\n \t\t\t\t   arg->count);\n@@ -511,9 +511,9 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n \tfor (unsigned int i = 0; i < arg->count; i++) {\n \t\tstruct v4l2_buffer buf = {};\n \t\tbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;\n-\t\tbuf.length = curV4L2Format_.fmt.pix.sizeimage;\n+\t\tbuf.length = v4l2PixFormat_.sizeimage;\n \t\tbuf.memory = V4L2_MEMORY_MMAP;\n-\t\tbuf.m.offset = i * curV4L2Format_.fmt.pix.sizeimage;\n+\t\tbuf.m.offset = i * v4l2PixFormat_.sizeimage;\n \t\tbuf.index = i;\n \t\tbuf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;\n \ndiff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\nindex 79eb87bcea51..92a79abb9e21 100644\n--- a/src/v4l2/v4l2_camera_proxy.h\n+++ b/src/v4l2/v4l2_camera_proxy.h\n@@ -73,13 +73,14 @@ private:\n \tunsigned int refcount_;\n \tunsigned int index_;\n \n-\tstruct v4l2_format curV4L2Format_;\n \tStreamConfiguration streamConfig_;\n-\tstruct v4l2_capability capabilities_;\n \tunsigned int bufferCount_;\n \tunsigned int currentBuf_;\n \tunsigned int sizeimage_;\n \n+\tstruct v4l2_capability capabilities_;\n+\tstruct v4l2_pix_format v4l2PixFormat_;\n+\n \tstd::vector<struct v4l2_buffer> buffers_;\n \tstd::map<void *, unsigned int> mmaps_;\n \n","prefixes":["libcamera-devel","2/3"]}