Patch Detail
Show a patch.
GET /api/patches/396/?format=api
{ "id": 396, "url": "https://patchwork.libcamera.org/api/patches/396/?format=api", "web_url": "https://patchwork.libcamera.org/patch/396/", "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": "<20190125212154.26950-3-niklas.soderlund@ragnatech.se>", "date": "2019-01-25T21:21:54", "name": "[libcamera-devel,RFC,2/2] cam: make the --format option take arguments", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "db6871586c0ccef98f8b8fe50e665195428beaed", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": { "id": 16, "url": "https://patchwork.libcamera.org/api/users/16/?format=api", "username": "neg", "first_name": "Niklas", "last_name": "Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "mbox": "https://patchwork.libcamera.org/patch/396/mbox/", "series": [ { "id": 135, "url": "https://patchwork.libcamera.org/api/series/135/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=135", "date": "2019-01-25T21:21:52", "name": "cam: make the --format option take arguments", "version": 1, "mbox": "https://patchwork.libcamera.org/series/135/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/396/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/396/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 6C4E660C7F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jan 2019 22:22:13 +0100 (CET)", "from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 44a80b3b-20e7-11e9-9adf-005056917a89;\n\tFri, 25 Jan 2019 22:22:07 +0100 (CET)" ], "X-Halon-ID": "44a80b3b-20e7-11e9-9adf-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, 25 Jan 2019 22:21:54 +0100", "Message-Id": "<20190125212154.26950-3-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190125212154.26950-1-niklas.soderlund@ragnatech.se>", "References": "<20190125212154.26950-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC 2/2] cam: make the --format option take\n\targuments", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "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, 25 Jan 2019 21:22:13 -0000" }, "content": "Instead of configuring a static frame dimension of 640x480 make the\nformat option take a list of arguments and parse the width, height and\npixel format from that list.\n\nThe pixel format is still specified as a integer which should correspond\nto the kernels FOURCC identifiers. Going forward this should be turned\ninto a string representation and the cam parser should translate between\nthe two.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/cam/main.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++------\n 1 file changed, 63 insertions(+), 8 deletions(-)", "diff": "diff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex b8c05d9079be3cb3..9fee77d6ddec31bc 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -41,7 +41,15 @@ static int parseOptions(int argc, char *argv[])\n \tparser.addOption(OptCamera, \"Specify which camera to operate on\",\n \t\t\t \"camera\", OptionsParser::ArgumentRequired,\n \t\t\t \"camera\");\n-\tparser.addOption(OptFormat, \"Configure the first stream to 640x480\", \"format\");\n+\tparser.addOption(OptFormat,\n+\t\t\t \"Set format of the cameras first stream\\n\"\n+\t\t\t \"\\tformatdesc is a string of key=value pairs joined by a commas\\n\\n\"\n+\t\t\t \"\\twidth=<w> Specify the width (int)\\n\"\n+\t\t\t \"\\theight=<w> Specify the height (int)\\n\"\n+\t\t\t \"\\tpixelformat=<pf> Specify the pixelformat (int)\\n\"\n+\t\t\t \"\\n\\tAny combination of options are valid, example: --format width=800,height=600\",\n+\t\t\t \"format\", OptionsParser::ArgumentRequired,\n+\t\t\t \"formatdesc\");\n \tparser.addOption(OptHelp, \"Display this help message\", \"help\");\n \tparser.addOption(OptList, \"List all cameras\", \"list\");\n \n@@ -57,6 +65,57 @@ static int parseOptions(int argc, char *argv[])\n \treturn 0;\n }\n \n+int str2uint(std::string str, unsigned int *dest)\n+{\n+\tunsigned long tmp = stoul(str);\n+\t*dest = tmp;\n+\tif (*dest != tmp)\n+\t\treturn -EINVAL;;\n+\treturn 0;\n+}\n+\n+bool configureStreams(Camera *camera, const std::string &arg)\n+{\n+\tSubOptionsParser parser;\n+\tparser.addToken(\"width\");\n+\tparser.addToken(\"height\");\n+\tparser.addToken(\"pixelformat\");\n+\tSubOptionsParser::Options format = parser.parse(arg.c_str());\n+\n+\tif (!format.valid())\n+\t\treturn false;\n+\n+\tstd::vector<Stream> streams = camera->streams();\n+\tStreamConfiguration config = StreamConfiguration(streams.front());\n+\n+\tif (format.isSet(\"width\") && format.isSet(\"height\")) {\n+\t\tunsigned int width, height;\n+\n+\t\tif (str2uint(format[\"width\"], &width) || str2uint(format[\"height\"], &height))\n+\t\t\treturn false;\n+\n+\t\tconfig.setDimension(width, height);\n+\t}\n+\n+\tif (format.isSet(\"pixelformat\")) {\n+\t\tunsigned int pixelformat;\n+\n+\t\t/* TODO: Translate 4CC string to ID. */\n+\t\tif (str2uint(format[\"pixelformat\"], &pixelformat))\n+\t\t\treturn false;\n+\n+\t\tconfig.setPixelFormat(pixelformat);\n+\t}\n+\n+\tstd::vector<StreamConfiguration *> configs;\n+\tconfigs.push_back(&config);\n+\n+\tif (camera->configure(configs))\n+\t\treturn false;\n+\n+\treturn true;\n+}\n+\n int main(int argc, char **argv)\n {\n \tint ret;\n@@ -117,14 +176,10 @@ int main(int argc, char **argv)\n \t\t\tgoto out_camera;\n \t\t}\n \n-\t\tStreamConfiguration config = StreamConfiguration(streams.front());\n-\t\tconfig.setDimension(640, 480);\n-\n-\t\tstd::vector<StreamConfiguration *> configs;\n-\t\tconfigs.push_back(&config);\n-\n-\t\tif (camera->configure(configs))\n+\t\tif (!configureStreams(camera.get(), options[OptFormat])) {\n \t\t\tstd::cout << \"Failed to configure camera\" << std::endl;\n+\t\t\tgoto out_camera;\n+\t\t}\n \t}\n \n \tret = loop->exec();\n", "prefixes": [ "libcamera-devel", "RFC", "2/2" ] }