Patch Detail
Show a patch.
GET /api/patches/2045/?format=api
{ "id": 2045, "url": "https://patchwork.libcamera.org/api/patches/2045/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2045/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190928152238.23752-4-laurent.pinchart@ideasonboard.com>", "date": "2019-09-28T15:22:29", "name": "[libcamera-devel,03/12] libcamera: controls: Use explicit 32-bit integer types", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "62f3f5919f2e97ada1defb994a83b3a0fe9054bf", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2045/mbox/", "series": [ { "id": 511, "url": "https://patchwork.libcamera.org/api/series/511/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=511", "date": "2019-09-28T15:22:26", "name": "Improve the application-facing controls API", "version": 1, "mbox": "https://patchwork.libcamera.org/series/511/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2045/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2045/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DAA5C6165B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 28 Sep 2019 17:22:56 +0200 (CEST)", "from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 83CAD593\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 28 Sep 2019 17:22:56 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1569684176;\n\tbh=rfhEtD2c3JPd1l6nJmBNhTqn22HZWOdbIWN5uQbLS4Y=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=oWQypt+EGI9zck1PPG6LIYv1kzV//XFWECJGy5bMvwC1PMcDHrflBqFXqTN7Bfehn\n\tsbd16MScWBnUyjsxSVxJGf9VPmL8xV4s/Ool71opxGK5atX2AyyzV+mmku2t/188A1\n\ty4oglRnC0HK9+AkaupRyO14CRW1rY4+TjmJksq78=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 28 Sep 2019 18:22:29 +0300", "Message-Id": "<20190928152238.23752-4-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190928152238.23752-1-laurent.pinchart@ideasonboard.com>", "References": "<20190928152238.23752-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 03/12] libcamera: controls: Use explicit\n\t32-bit integer types", "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": "Sat, 28 Sep 2019 15:22:57 -0000" }, "content": "Make the control API more explicit when dealing with integer controls by\nspecifying the size. We already do so for 64-bit integers, using int64_t\nand ControlTypeInteger64, do the same for 32-bit integers.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/controls.h | 6 ++---\n src/libcamera/controls.cpp | 36 ++++++++++++++---------------\n src/libcamera/pipeline/uvcvideo.cpp | 10 ++++----\n src/libcamera/pipeline/vimc.cpp | 6 ++---\n test/controls/control_info.cpp | 10 ++++----\n test/controls/control_list.cpp | 16 ++++++-------\n test/controls/control_value.cpp | 6 ++---\n 7 files changed, 46 insertions(+), 44 deletions(-)", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 0886370f0901..a3089064c4b5 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -21,7 +21,7 @@ class Camera;\n enum ControlType {\n \tControlTypeNone,\n \tControlTypeBool,\n-\tControlTypeInteger,\n+\tControlTypeInteger32,\n \tControlTypeInteger64,\n };\n \n@@ -30,7 +30,7 @@ class ControlValue\n public:\n \tControlValue();\n \tControlValue(bool value);\n-\tControlValue(int value);\n+\tControlValue(int32_t value);\n \tControlValue(int64_t value);\n \n \tControlType type() const { return type_; };\n@@ -48,7 +48,7 @@ private:\n \n \tunion {\n \t\tbool bool_;\n-\t\tint integer_;\n+\t\tint32_t integer32_;\n \t\tint64_t integer64_;\n \t};\n };\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 88aab88db327..295ccd55a622 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -31,8 +31,8 @@ LOG_DEFINE_CATEGORY(Controls)\n * Invalid type, for empty values\n * \\var ControlTypeBool\n * The control stores a boolean value\n- * \\var ControlTypeInteger\n- * The control stores an integer value\n+ * \\var ControlTypeInteger32\n+ * The control stores a 32-bit integer value\n * \\var ControlTypeInteger64\n * The control stores a 64-bit integer value\n */\n@@ -63,8 +63,8 @@ ControlValue::ControlValue(bool value)\n * \\brief Construct an integer ControlValue\n * \\param[in] value Integer value to store\n */\n-ControlValue::ControlValue(int value)\n-\t: type_(ControlTypeInteger), integer_(value)\n+ControlValue::ControlValue(int32_t value)\n+\t: type_(ControlTypeInteger32), integer32_(value)\n {\n }\n \n@@ -115,17 +115,17 @@ const bool &ControlValue::get<bool>() const\n }\n \n template<>\n-const int &ControlValue::get<int>() const\n+const int32_t &ControlValue::get<int32_t>() const\n {\n-\tASSERT(type_ == ControlTypeInteger || type_ == ControlTypeInteger64);\n+\tASSERT(type_ == ControlTypeInteger32 || type_ == ControlTypeInteger64);\n \n-\treturn integer_;\n+\treturn integer32_;\n }\n \n template<>\n const int64_t &ControlValue::get<int64_t>() const\n {\n-\tASSERT(type_ == ControlTypeInteger || type_ == ControlTypeInteger64);\n+\tASSERT(type_ == ControlTypeInteger32 || type_ == ControlTypeInteger64);\n \n \treturn integer64_;\n }\n@@ -138,10 +138,10 @@ void ControlValue::set<bool>(const bool &value)\n }\n \n template<>\n-void ControlValue::set<int>(const int &value)\n+void ControlValue::set<int32_t>(const int32_t &value)\n {\n-\ttype_ = ControlTypeInteger;\n-\tinteger_ = value;\n+\ttype_ = ControlTypeInteger32;\n+\tinteger32_ = value;\n }\n \n template<>\n@@ -163,8 +163,8 @@ std::string ControlValue::toString() const\n \t\treturn \"<None>\";\n \tcase ControlTypeBool:\n \t\treturn bool_ ? \"True\" : \"False\";\n-\tcase ControlTypeInteger:\n-\t\treturn std::to_string(integer_);\n+\tcase ControlTypeInteger32:\n+\t\treturn std::to_string(integer32_);\n \tcase ControlTypeInteger64:\n \t\treturn std::to_string(integer64_);\n \t}\n@@ -186,35 +186,35 @@ std::string ControlValue::toString() const\n \n /**\n * \\var Brightness\n- * ControlType: Integer\n+ * ControlType: Integer32\n *\n * Specify a fixed brightness parameter.\n */\n \n /**\n * \\var Contrast\n- * ControlType: Integer\n+ * ControlType: Integer32\n *\n * Specify a fixed contrast parameter.\n */\n \n /**\n * \\var Saturation\n- * ControlType: Integer\n+ * ControlType: Integer32\n *\n * Specify a fixed saturation parameter.\n */\n \n /**\n * \\var ManualExposure\n- * ControlType: Integer\n+ * ControlType: Integer32\n *\n * Specify a fixed exposure time in milli-seconds\n */\n \n /**\n * \\var ManualGain\n- * ControlType: Integer\n+ * ControlType: Integer32\n *\n * Specify a fixed gain parameter\n */\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 81c548af2c64..0d56758e3e1d 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -235,24 +235,24 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)\n \n \t\tswitch (ci->id()) {\n \t\tcase Brightness:\n-\t\t\tcontrols.add(V4L2_CID_BRIGHTNESS, value.get<int>());\n+\t\t\tcontrols.add(V4L2_CID_BRIGHTNESS, value.get<int32_t>());\n \t\t\tbreak;\n \n \t\tcase Contrast:\n-\t\t\tcontrols.add(V4L2_CID_CONTRAST, value.get<int>());\n+\t\t\tcontrols.add(V4L2_CID_CONTRAST, value.get<int32_t>());\n \t\t\tbreak;\n \n \t\tcase Saturation:\n-\t\t\tcontrols.add(V4L2_CID_SATURATION, value.get<int>());\n+\t\t\tcontrols.add(V4L2_CID_SATURATION, value.get<int32_t>());\n \t\t\tbreak;\n \n \t\tcase ManualExposure:\n \t\t\tcontrols.add(V4L2_CID_EXPOSURE_AUTO, 1);\n-\t\t\tcontrols.add(V4L2_CID_EXPOSURE_ABSOLUTE, value.get<int>());\n+\t\t\tcontrols.add(V4L2_CID_EXPOSURE_ABSOLUTE, value.get<int32_t>());\n \t\t\tbreak;\n \n \t\tcase ManualGain:\n-\t\t\tcontrols.add(V4L2_CID_GAIN, value.get<int>());\n+\t\t\tcontrols.add(V4L2_CID_GAIN, value.get<int32_t>());\n \t\t\tbreak;\n \n \t\tdefault:\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 3e34e7a0edbf..e549dc64b996 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -288,15 +288,15 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)\n \n \t\tswitch (ci->id()) {\n \t\tcase Brightness:\n-\t\t\tcontrols.add(V4L2_CID_BRIGHTNESS, value.get<int>());\n+\t\t\tcontrols.add(V4L2_CID_BRIGHTNESS, value.get<int32_t>());\n \t\t\tbreak;\n \n \t\tcase Contrast:\n-\t\t\tcontrols.add(V4L2_CID_CONTRAST, value.get<int>());\n+\t\t\tcontrols.add(V4L2_CID_CONTRAST, value.get<int32_t>());\n \t\t\tbreak;\n \n \t\tcase Saturation:\n-\t\t\tcontrols.add(V4L2_CID_SATURATION, value.get<int>());\n+\t\t\tcontrols.add(V4L2_CID_SATURATION, value.get<int32_t>());\n \t\t\tbreak;\n \n \t\tdefault:\ndiff --git a/test/controls/control_info.cpp b/test/controls/control_info.cpp\nindex faefaaa444d9..2aba568a302e 100644\n--- a/test/controls/control_info.cpp\n+++ b/test/controls/control_info.cpp\n@@ -26,13 +26,14 @@ protected:\n \t\tControlInfo info(Brightness);\n \n \t\tif (info.id() != Brightness ||\n-\t\t info.type() != ControlTypeInteger ||\n+\t\t info.type() != ControlTypeInteger32 ||\n \t\t info.name() != std::string(\"Brightness\")) {\n \t\t\tcout << \"Invalid control identification for Brightness\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tif (info.min().get<int>() != 0 || info.max().get<int>() != 0) {\n+\t\tif (info.min().get<int32_t>() != 0 ||\n+\t\t info.max().get<int32_t>() != 0) {\n \t\t\tcout << \"Invalid control range for Brightness\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -44,13 +45,14 @@ protected:\n \t\tinfo = ControlInfo(Contrast, 10, 200);\n \n \t\tif (info.id() != Contrast ||\n-\t\t info.type() != ControlTypeInteger ||\n+\t\t info.type() != ControlTypeInteger32 ||\n \t\t info.name() != std::string(\"Contrast\")) {\n \t\t\tcout << \"Invalid control identification for Contrast\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tif (info.min().get<int>() != 10 || info.max().get<int>() != 200) {\n+\t\tif (info.min().get<int32_t>() != 10 ||\n+\t\t info.max().get<int32_t>() != 200) {\n \t\t\tcout << \"Invalid control range for Contrast\" << endl;\n \t\t\treturn TestFail;\n \t\t}\ndiff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp\nindex 0402e7c23dba..5215840b1c4e 100644\n--- a/test/controls/control_list.cpp\n+++ b/test/controls/control_list.cpp\n@@ -96,7 +96,7 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tif (list[Brightness].get<int>() != 255) {\n+\t\tif (list[Brightness].get<int32_t>() != 255) {\n \t\t\tcout << \"Incorrest Brightness control value\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -125,8 +125,8 @@ protected:\n \t\t/*\n \t\t * Test control value retrieval and update through ControlInfo.\n \t\t */\n-\t\tif (list[brightness].get<int>() != 64 ||\n-\t\t list[contrast].get<int>() != 128) {\n+\t\tif (list[brightness].get<int32_t>() != 64 ||\n+\t\t list[contrast].get<int32_t>() != 128) {\n \t\t\tcout << \"Failed to retrieve control value\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -134,8 +134,8 @@ protected:\n \t\tlist[brightness] = 10;\n \t\tlist[contrast] = 20;\n \n-\t\tif (list[brightness].get<int>() != 10 ||\n-\t\t list[contrast].get<int>() != 20) {\n+\t\tif (list[brightness].get<int32_t>() != 10 ||\n+\t\t list[contrast].get<int32_t>() != 20) {\n \t\t\tcout << \"Failed to update control value\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -185,9 +185,9 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tif (newList[Brightness].get<int>() != 10 ||\n-\t\t newList[Contrast].get<int>() != 20 ||\n-\t\t newList[Saturation].get<int>() != 255) {\n+\t\tif (newList[Brightness].get<int32_t>() != 10 ||\n+\t\t newList[Contrast].get<int32_t>() != 20 ||\n+\t\t newList[Saturation].get<int32_t>() != 255) {\n \t\t\tcout << \"New list contains incorrect values\" << endl;\n \t\t\treturn TestFail;\n \t\t}\ndiff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp\nindex 397c43f799ad..a1ffa842f29e 100644\n--- a/test/controls/control_value.cpp\n+++ b/test/controls/control_value.cpp\n@@ -27,7 +27,7 @@ protected:\n \t\t << \" Bool: \" << boolean.toString()\n \t\t << endl;\n \n-\t\tif (integer.get<int>() != 1234) {\n+\t\tif (integer.get<int32_t>() != 1234) {\n \t\t\tcerr << \"Failed to get Integer\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -56,8 +56,8 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tvalue.set<int>(10);\n-\t\tif (value.get<int>() != 10) {\n+\t\tvalue.set<int32_t>(10);\n+\t\tif (value.get<int32_t>() != 10) {\n \t\t\tcerr << \"Failed to get Integer\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n", "prefixes": [ "libcamera-devel", "03/12" ] }