[{"id":125,"web_url":"https://patchwork.libcamera.org/comment/125/","msgid":"<20181230100427.yvaimsj4qalizehs@uno.localdomain>","date":"2018-12-30T10:04:27","subject":"Re: [libcamera-devel] [PATCH v2 04/12] libcamera:\n\tdevice_enumerator: add DeviceMatch class","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\nOn Sat, Dec 29, 2018 at 04:28:47AM +0100, Niklas Söderlund wrote:\n> Provide a DeviceMatch class which represents all properties of a media\n> device a pipeline hander can specify when searching for a device to use\n> in its pipeline.\n>\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nThanks\n  j\n\n> ---\n> * Changes since v1\n> - Remove unneeded std::string(entity) in DeviceMatch::add().\n> - Inline matchInfo() and matchEntities() into the only caller,\n>   DeviceMatch::match.\n> ---\n>  src/libcamera/device_enumerator.cpp       | 36 +++++++++++++++++++++++\n>  src/libcamera/include/device_enumerator.h | 14 +++++++++\n>  2 files changed, 50 insertions(+)\n>\n> diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n> index 83dcda9403526010..61b32bb921581f49 100644\n> --- a/src/libcamera/device_enumerator.cpp\n> +++ b/src/libcamera/device_enumerator.cpp\n> @@ -75,4 +75,40 @@ int DeviceInfo::lookup(const std::string &name, std::string &devnode) const\n>  \treturn 0;\n>  }\n>\n> +/* -----------------------------------------------------------------------------\n> + * DeviceMatch\n> + */\n> +\n> +DeviceMatch::DeviceMatch(const std::string &driver)\n> +\t: driver_(driver)\n> +{\n> +}\n> +\n> +void DeviceMatch::add(const std::string &entity)\n> +{\n> +\tentities_.push_back(entity);\n> +}\n> +\n> +bool DeviceMatch::match(const DeviceInfo *info) const\n> +{\n> +\tif (driver_ != info->info().driver)\n> +\t\treturn false;\n> +\n> +\tfor (const std::string &name : entities_) {\n> +\t\tbool found = false;\n> +\n> +\t\tfor (const std::string &entity : info->entities()) {\n> +\t\t\tif (name == entity) {\n> +\t\t\t\tfound = true;\n> +\t\t\t\tbreak;\n> +\t\t\t}\n> +\t\t}\n> +\n> +\t\tif (!found)\n> +\t\t\treturn false;\n> +\t}\n> +\n> +\treturn true;\n> +}\n> +\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h\n> index ac40bafc5169c7c7..ed1e986ff45f95f5 100644\n> --- a/src/libcamera/include/device_enumerator.h\n> +++ b/src/libcamera/include/device_enumerator.h\n> @@ -39,6 +39,20 @@ private:\n>  \tstd::map<std::string, std::string> entities_;\n>  };\n>\n> +class DeviceMatch\n> +{\n> +public:\n> +\tDeviceMatch(const std::string &driver);\n> +\n> +\tvoid add(const std::string &entity);\n> +\n> +\tbool match(const DeviceInfo *info) const;\n> +\n> +private:\n> +\tstd::string driver_;\n> +\tstd::vector<std::string> entities_;\n> +};\n> +\n>  } /* namespace libcamera */\n>\n>  #endif\t/* __LIBCAMERA_DEVICE_ENUMERATOR_H__ */\n> --\n> 2.20.1\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9844E60B31\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 30 Dec 2018 11:04:25 +0100 (CET)","from uno.localdomain (unknown [37.176.180.32])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id 0B16E200002;\n\tSun, 30 Dec 2018 10:04:24 +0000 (UTC)"],"Date":"Sun, 30 Dec 2018 11:04:27 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20181230100427.yvaimsj4qalizehs@uno.localdomain>","References":"<20181229032855.26249-1-niklas.soderlund@ragnatech.se>\n\t<20181229032855.26249-5-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"msoajptf52oiuj3c\"","Content-Disposition":"inline","In-Reply-To":"<20181229032855.26249-5-niklas.soderlund@ragnatech.se>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v2 04/12] libcamera:\n\tdevice_enumerator: add DeviceMatch class","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":"Sun, 30 Dec 2018 10:04:25 -0000"}},{"id":132,"web_url":"https://patchwork.libcamera.org/comment/132/","msgid":"<36817627.HfMAxRiORs@avalon>","date":"2018-12-30T20:11:02","subject":"Re: [libcamera-devel] [PATCH v2 04/12] libcamera:\n\tdevice_enumerator: add DeviceMatch class","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Saturday, 29 December 2018 05:28:47 EET Niklas Söderlund wrote:\n> Provide a DeviceMatch class which represents all properties of a media\n> device a pipeline hander can specify when searching for a device to use\n> in its pipeline.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n> * Changes since v1\n> - Remove unneeded std::string(entity) in DeviceMatch::add().\n> - Inline matchInfo() and matchEntities() into the only caller,\n>   DeviceMatch::match.\n> ---\n>  src/libcamera/device_enumerator.cpp       | 36 +++++++++++++++++++++++\n>  src/libcamera/include/device_enumerator.h | 14 +++++++++\n>  2 files changed, 50 insertions(+)\n> \n> diff --git a/src/libcamera/device_enumerator.cpp\n> b/src/libcamera/device_enumerator.cpp index\n> 83dcda9403526010..61b32bb921581f49 100644\n> --- a/src/libcamera/device_enumerator.cpp\n> +++ b/src/libcamera/device_enumerator.cpp\n> @@ -75,4 +75,40 @@ int DeviceInfo::lookup(const std::string &name,\n> std::string &devnode) const return 0;\n>  }\n> \n> +/*\n> ---------------------------------------------------------------------------\n> -- + * DeviceMatch\n> + */\n> +\n> +DeviceMatch::DeviceMatch(const std::string &driver)\n> +\t: driver_(driver)\n> +{\n> +}\n> +\n> +void DeviceMatch::add(const std::string &entity)\n> +{\n> +\tentities_.push_back(entity);\n> +}\n> +\n> +bool DeviceMatch::match(const DeviceInfo *info) const\n> +{\n> +\tif (driver_ != info->info().driver)\n> +\t\treturn false;\n> +\n> +\tfor (const std::string &name : entities_) {\n> +\t\tbool found = false;\n> +\n> +\t\tfor (const std::string &entity : info->entities()) {\n> +\t\t\tif (name == entity) {\n> +\t\t\t\tfound = true;\n> +\t\t\t\tbreak;\n> +\t\t\t}\n> +\t\t}\n> +\n> +\t\tif (!found)\n> +\t\t\treturn false;\n> +\t}\n> +\n> +\treturn true;\n> +}\n> +\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/include/device_enumerator.h\n> b/src/libcamera/include/device_enumerator.h index\n> ac40bafc5169c7c7..ed1e986ff45f95f5 100644\n> --- a/src/libcamera/include/device_enumerator.h\n> +++ b/src/libcamera/include/device_enumerator.h\n> @@ -39,6 +39,20 @@ private:\n>  \tstd::map<std::string, std::string> entities_;\n>  };\n> \n> +class DeviceMatch\n> +{\n> +public:\n> +\tDeviceMatch(const std::string &driver);\n> +\n> +\tvoid add(const std::string &entity);\n> +\n> +\tbool match(const DeviceInfo *info) const;\n> +\n> +private:\n> +\tstd::string driver_;\n> +\tstd::vector<std::string> entities_;\n> +};\n> +\n>  } /* namespace libcamera */\n> \n>  #endif\t/* __LIBCAMERA_DEVICE_ENUMERATOR_H__ */","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 89F5D600CC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 30 Dec 2018 21:10:06 +0100 (CET)","from avalon.localnet (unknown\n\t[IPv6:2a02:a03f:3ad5:900:7d1d:858b:75d5:534d])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1FF6750A;\n\tSun, 30 Dec 2018 21:10:05 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1546200605;\n\tbh=ylVxww6cjBDOM7srrYYUXRN00AjgFVqupx3212rwKm0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=TRCLM6+/3oGIcC1LN97iz6pg9TUWDJqsy/p3vG+TnZmaLpkUyHP/TEGM5zLLxFNnP\n\tRvXQcJbJIYqlLuXpStB/QQbbouR9ZzwhMoeJFZ5vBi9l8mJ+iUlgHukTCy8one5dzq\n\tkAvwz5OjbJ59ZWHMn3vOlvGvtKsPrGU2sFremH+Q=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sun, 30 Dec 2018 22:11:02 +0200","Message-ID":"<36817627.HfMAxRiORs@avalon>","Organization":"Ideas on Board Oy","In-Reply-To":"<20181229032855.26249-5-niklas.soderlund@ragnatech.se>","References":"<20181229032855.26249-1-niklas.soderlund@ragnatech.se>\n\t<20181229032855.26249-5-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","Content-Type":"text/plain; charset=\"iso-8859-1\"","Subject":"Re: [libcamera-devel] [PATCH v2 04/12] libcamera:\n\tdevice_enumerator: add DeviceMatch class","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":"Sun, 30 Dec 2018 20:10:06 -0000"}}]