{"id":2916,"url":"https://patchwork.libcamera.org/api/patches/2916/?format=json","web_url":"https://patchwork.libcamera.org/patch/2916/","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":"<20200228032913.497826-7-niklas.soderlund@ragnatech.se>","date":"2020-02-28T03:29:13","name":"[libcamera-devel,RFC,6/6] v4l2: camera_proxy: Switch to PixelFormat","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"64d7b99ddb004f05cff7117a67ecdd84a069e4cd","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2916/mbox/","series":[{"id":694,"url":"https://patchwork.libcamera.org/api/series/694/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=694","date":"2020-02-28T03:29:07","name":"libcamera: PixelFormat: Turn into a class","version":1,"mbox":"https://patchwork.libcamera.org/series/694/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2916/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2916/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 667CC6271F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Feb 2020 04:29:41 +0100 (CET)","from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 8dbb4e34-59da-11ea-9f85-005056917a89;\n\tFri, 28 Feb 2020 04:29:40 +0100 (CET)"],"X-Halon-ID":"8dbb4e34-59da-11ea-9f85-005056917a89","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","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","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC 6/6] v4l2: camera_proxy: Switch to\n\tPixelFormat","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>","X-List-Received-Date":"Fri, 28 Feb 2020 03:29:41 -0000"},"content":"Remove proxies for PixelFormat and use the interface directly.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/v4l2/v4l2_camera_proxy.cpp | 28 +++++++++-------------------\n src/v4l2/v4l2_camera_proxy.h   |  3 ---\n 2 files changed, 9 insertions(+), 22 deletions(-)","diff":"diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex e9d7bfd8ee243b78..7ea3039e0455c3f9 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -141,7 +141,7 @@ void V4L2CameraProxy::setFmtFromConfig(StreamConfiguration &streamConfig)\n {\n \tcurV4L2Format_.fmt.pix.width = streamConfig.size.width;\n \tcurV4L2Format_.fmt.pix.height = streamConfig.size.height;\n-\tcurV4L2Format_.fmt.pix.pixelformat = drmToV4L2(streamConfig.pixelFormat);\n+\tcurV4L2Format_.fmt.pix.pixelformat = streamConfig.pixelFormat.v4l2();\n \tcurV4L2Format_.fmt.pix.field = V4L2_FIELD_NONE;\n \tcurV4L2Format_.fmt.pix.bytesperline =\n \t\tbplMultiplier(curV4L2Format_.fmt.pix.pixelformat) *\n@@ -159,7 +159,7 @@ unsigned int V4L2CameraProxy::calculateSizeImage(StreamConfiguration &streamConf\n \t * \\todo Merge this method with setFmtFromConfig (need imageSize to\n \t * support all libcamera formats first, or filter out MJPEG for now).\n \t */\n-\treturn imageSize(drmToV4L2(streamConfig.pixelFormat),\n+\treturn imageSize(streamConfig.pixelFormat.v4l2(),\n \t\t\t streamConfig.size.width,\n \t\t\t streamConfig.size.height);\n }\n@@ -229,7 +229,7 @@ int V4L2CameraProxy::vidioc_enum_fmt(struct v4l2_fmtdesc *arg)\n \t/* \\todo Add map from format to description. */\n \tutils::strlcpy(reinterpret_cast<char *>(arg->description), \"Video Format Description\",\n \t\t       sizeof(arg->description));\n-\targ->pixelformat = drmToV4L2(streamConfig_.formats().pixelformats()[arg->index]);\n+\targ->pixelformat = streamConfig_.formats().pixelformats()[arg->index].v4l2();\n \n \treturn 0;\n }\n@@ -249,7 +249,7 @@ int V4L2CameraProxy::vidioc_g_fmt(struct v4l2_format *arg)\n \n void V4L2CameraProxy::tryFormat(struct v4l2_format *arg)\n {\n-\tPixelFormat format = v4l2ToDrm(arg->fmt.pix.pixelformat);\n+\tPixelFormat format = PixelFormat(arg->fmt.pix.pixelformat);\n \tconst std::vector<PixelFormat> &formats =\n \t\tstreamConfig_.formats().pixelformats();\n \tif (std::find(formats.begin(), formats.end(), format) == formats.end())\n@@ -262,11 +262,11 @@ void V4L2CameraProxy::tryFormat(struct v4l2_format *arg)\n \n \targ->fmt.pix.width        = size.width;\n \targ->fmt.pix.height       = size.height;\n-\targ->fmt.pix.pixelformat  = drmToV4L2(format);\n+\targ->fmt.pix.pixelformat  = format.v4l2();\n \targ->fmt.pix.field        = V4L2_FIELD_NONE;\n-\targ->fmt.pix.bytesperline = bplMultiplier(drmToV4L2(format)) *\n+\targ->fmt.pix.bytesperline = bplMultiplier(format.v4l2()) *\n \t\t\t\t    arg->fmt.pix.width;\n-\targ->fmt.pix.sizeimage    = imageSize(drmToV4L2(format),\n+\targ->fmt.pix.sizeimage    = imageSize(format.v4l2(),\n \t\t\t\t\t      arg->fmt.pix.width,\n \t\t\t\t\t      arg->fmt.pix.height);\n \targ->fmt.pix.colorspace   = V4L2_COLORSPACE_SRGB;\n@@ -283,7 +283,7 @@ int V4L2CameraProxy::vidioc_s_fmt(struct v4l2_format *arg)\n \n \tSize size(arg->fmt.pix.width, arg->fmt.pix.height);\n \tint ret = vcam_->configure(&streamConfig_, size,\n-\t\t\t\t   v4l2ToDrm(arg->fmt.pix.pixelformat),\n+\t\t\t\t   PixelFormat(arg->fmt.pix.pixelformat),\n \t\t\t\t   bufferCount_);\n \tif (ret < 0)\n \t\treturn -EINVAL;\n@@ -345,7 +345,7 @@ int V4L2CameraProxy::vidioc_reqbufs(struct v4l2_requestbuffers *arg)\n \n \tSize size(curV4L2Format_.fmt.pix.width, curV4L2Format_.fmt.pix.height);\n \tret = vcam_->configure(&streamConfig_, size,\n-\t\t\t       v4l2ToDrm(curV4L2Format_.fmt.pix.pixelformat),\n+\t\t\t       PixelFormat(curV4L2Format_.fmt.pix.pixelformat),\n \t\t\t       arg->count);\n \tif (ret < 0)\n \t\treturn -EINVAL;\n@@ -584,13 +584,3 @@ unsigned int V4L2CameraProxy::imageSize(uint32_t format, unsigned int width,\n \n \treturn width * height * multiplier / 8;\n }\n-\n-PixelFormat V4L2CameraProxy::v4l2ToDrm(uint32_t format)\n-{\n-\treturn PixelFormat(format);\n-}\n-\n-uint32_t V4L2CameraProxy::drmToV4L2(PixelFormat format)\n-{\n-\treturn format.v4l2();\n-}\ndiff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\nindex c8e61adf80f1b93b..03495d6266ef610a 100644\n--- a/src/v4l2/v4l2_camera_proxy.h\n+++ b/src/v4l2/v4l2_camera_proxy.h\n@@ -59,9 +59,6 @@ private:\n \tstatic unsigned int imageSize(uint32_t format, unsigned int width,\n \t\t\t\t      unsigned int height);\n \n-\tstatic PixelFormat v4l2ToDrm(uint32_t format);\n-\tstatic uint32_t drmToV4L2(PixelFormat format);\n-\n \tunsigned int refcount_;\n \tunsigned int index_;\n \tbool nonBlocking_;\n","prefixes":["libcamera-devel","RFC","6/6"]}