[{"id":3228,"web_url":"https://patchwork.libcamera.org/comment/3228/","msgid":"<20191209174931.GD27340@bigcity.dyn.berto.se>","date":"2019-12-09T17:49:31","subject":"Re: [libcamera-devel] [PATCH v3 10/10] cam: Add option to list\n\tcamera properties","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your patch.\n\nOn 2019-12-09 17:34:46 +0100, Jacopo Mondi wrote:\n> Add the '-p'|'--list-properties' option to the cam application to list\n> the properties of a camera.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/cam/main.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++\n>  src/cam/main.h   |  1 +\n>  2 files changed, 51 insertions(+)\n> \n> diff --git a/src/cam/main.cpp b/src/cam/main.cpp\n> index a38cca959aca..41aedea3ab17 100644\n> --- a/src/cam/main.cpp\n> +++ b/src/cam/main.cpp\n> @@ -11,6 +11,7 @@\n>  #include <string.h>\n>  \n>  #include <libcamera/libcamera.h>\n> +#include <libcamera/property_ids.h>\n>  \n>  #include \"capture.h\"\n>  #include \"event_loop.h\"\n> @@ -36,6 +37,7 @@ public:\n>  private:\n>  \tint parseOptions(int argc, char *argv[]);\n>  \tint prepareConfig();\n> +\tint listProperties();\n>  \tint infoConfiguration();\n>  \tint run();\n>  \n> @@ -180,6 +182,7 @@ int CamApp::parseOptions(int argc, char *argv[])\n>  \tparser.addOption(OptInfo, OptionNone,\n>  \t\t\t \"Display information about stream(s)\", \"info\");\n>  \tparser.addOption(OptList, OptionNone, \"List all cameras\", \"list\");\n> +\tparser.addOption(OptProps, OptionNone, \"List cameras properties\", \"list-properties\");\n>  \n>  \toptions_ = parser.parse(argc, argv);\n>  \tif (!options_.valid())\n> @@ -268,6 +271,47 @@ int CamApp::prepareConfig()\n>  \treturn 0;\n>  }\n>  \n> +int CamApp::listProperties()\n> +{\n> +\tif (!camera_) {\n> +\t\tstd::cout << \"Cannot list properties without a camera\"\n> +\t\t\t  << std::endl;\n> +\t\treturn -EINVAL;\n> +\t}\n> +\n> +\tconst ControlList &properties = camera_->properties();\n> +\tfor (const auto &prop : properties) {\n> +\t\tunsigned int id = prop.first;\n> +\t\tconst auto &ctrlId = properties::properties.find(id);\n> +\t\tconst ControlId *ctrl = ctrlId->second;\n> +\t\tconst ControlValue &value = prop.second;\n> +\n> +\t\tstd::cout << \"Property: \" << ctrl->name() << \" = \";\n> +\n> +\t\tswitch (ctrl->type()) {\n> +\t\tcase ControlTypeBool: {\n> +\t\t\tbool val = value.get<bool>();\n> +\t\t\tstd::cout << (val ? \"True\" : \"False\") << std::endl;\n> +\t\t\tbreak;\n> +\t\t}\n> +\t\tcase ControlTypeInteger32: {\n> +\t\t\tint32_t val = value.get<int32_t>();\n> +\t\t\tstd::cout << val << std::endl;\n> +\t\t\tbreak;\n> +\t\t}\n> +\t\tcase ControlTypeInteger64: {\n> +\t\t\tint64_t val = value.get<int64_t>();\n> +\t\t\tstd::cout << val << std::endl;\n> +\t\t\tbreak;\n> +\t\t}\n> +\t\tdefault:\n> +\t\t\tbreak;\n> +\t\t}\n> +\t}\n> +\n> +\treturn 0;\n> +}\n> +\n>  int CamApp::infoConfiguration()\n>  {\n>  \tif (!config_) {\n> @@ -312,6 +356,12 @@ int CamApp::run()\n>  \t\t}\n>  \t}\n>  \n> +\tif (options_.isSet(OptProps)) {\n> +\t\tret = listProperties();\n> +\t\tif (ret)\n> +\t\t\treturn ret;\n> +\t}\n> +\n>  \tif (options_.isSet(OptInfo)) {\n>  \t\tret = infoConfiguration();\n>  \t\tif (ret)\n> diff --git a/src/cam/main.h b/src/cam/main.h\n> index 0997476bb335..afcad4353b7d 100644\n> --- a/src/cam/main.h\n> +++ b/src/cam/main.h\n> @@ -14,6 +14,7 @@ enum {\n>  \tOptHelp = 'h',\n>  \tOptInfo = 'I',\n>  \tOptList = 'l',\n> +\tOptProps = 'p',\n>  \tOptStream = 's',\n>  };\n>  \n> -- \n> 2.24.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x229.google.com (mail-lj1-x229.google.com\n\t[IPv6:2a00:1450:4864:20::229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 814E060BDB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  9 Dec 2019 18:49:33 +0100 (CET)","by mail-lj1-x229.google.com with SMTP id m6so16682188ljc.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 09 Dec 2019 09:49:33 -0800 (PST)","from localhost (h-93-159.A463.priv.bahnhof.se. [46.59.93.159])\n\tby smtp.gmail.com with ESMTPSA id l7sm53745lfc.80.2019.12.09.09.49.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 09 Dec 2019 09:49:32 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=K9OAT/R/wXcue0UeFMmcY3ukbdpjPfpfmy7XW1XoD+Q=;\n\tb=p6GCDkG71oElC1fhzxkIZo//MwD/9BqZ0ojzTJIsM9c8rqG6ukt0EeYClZoE7vdyE1\n\tog6uwGxKQ10mHK33OKkLGUSEPJ0tqb5GUBiPGoxP3tJzJwWQRP3tmtbVCAkVhVdY/tdG\n\tD/R/xigFAu8mqcDr7eE41VXJBVS/2Rm4rQE1+dSejuLocapKscK8ngaukTIYRurW5vWf\n\tNtDa1JDFrB86UwuVeYKVW1qehB28RKiIcfoZwxGm5pTy855WSeXKXGTt+b4F+mZpCtT7\n\tbBc3DLf5wWpRRctpuD5prh8usL+tGjgTuR1Dlg0meGEHCBbqFjkazvcg4Cawr06f3AmH\n\tYtvA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=K9OAT/R/wXcue0UeFMmcY3ukbdpjPfpfmy7XW1XoD+Q=;\n\tb=GIvz62sqV07m4NMgWfJZweoxra+RHjBqGqG0nLFjTCT8CZ4TMl59PMNBIdYOiMfmhv\n\tLAskDv8PzxT+s0lhgLOjMOvFVuDuGH57ZPxABg8O/eJVvqjRSuLe1cEKu8QWubWkZtoT\n\tLQb6Fsf/yAYUYOIgCcH9nD8vcy+XvAsJM63KXg58g3tE0Nk49zqNHidWDAW3QuKrAjOs\n\tGgcuqqXYVH6q0iO58nU4tVbgYHKLE3zqm32W9UhUbvq4goHV9Ajmi9mkJobh1bMlDt0F\n\t/NVbxe0AiGLtn1+wJiQm40jMsoYKxS89hrfbZ4VmDpjcAgpFK6bhkTUqh5TG5dF7WSsq\n\tQNFQ==","X-Gm-Message-State":"APjAAAWyuXGtvTaMQGYmJuOlwzwWZA4V2MfdiJLQX7Vk23yQsP2FpQc1\n\tAjUysaqPGKKDkfwuo93XVKclLw==","X-Google-Smtp-Source":"APXvYqwXf90kYSg8WHQKKb72qh6N13miLZDk4shjCs8/Fj/OmdpmeSA4jLbJ+QcEZn4TAyo0sZ8QEA==","X-Received":"by 2002:a2e:2e14:: with SMTP id\n\tu20mr3976540lju.120.1575913772877; \n\tMon, 09 Dec 2019 09:49:32 -0800 (PST)","Date":"Mon, 9 Dec 2019 18:49:31 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191209174931.GD27340@bigcity.dyn.berto.se>","References":"<20191209163446.32381-1-jacopo@jmondi.org>\n\t<20191209163446.32381-11-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20191209163446.32381-11-jacopo@jmondi.org>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH v3 10/10] cam: Add option to list\n\tcamera properties","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":"Mon, 09 Dec 2019 17:49:33 -0000"}}]