Patch Detail
Show a patch.
GET /api/1.1/patches/17288/?format=api
{ "id": 17288, "url": "https://patchwork.libcamera.org/api/1.1/patches/17288/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17288/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20220903181037.1406-2-laurent.pinchart@ideasonboard.com>", "date": "2022-09-03T18:10:35", "name": "[libcamera-devel,1/3] pipeline: uvcvideo: Move camera ID generation to UVCCameraData class", "commit_ref": "52660f2b13dd9f1032de5e50c416845def66a838", "pull_url": null, "state": "accepted", "archived": false, "hash": "444ab91ce218e6b75fcbb11565d56701039b59f1", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17288/mbox/", "series": [ { "id": 3466, "url": "https://patchwork.libcamera.org/api/1.1/series/3466/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3466", "date": "2022-09-03T18:10:34", "name": "libcamera: Fix crash with UVC cameras that expose no supported format", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3466/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17288/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17288/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6A74EC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 3 Sep 2022 18:10:54 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 375B76203C;\n\tSat, 3 Sep 2022 20:10:54 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C9C9D6203C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 3 Sep 2022 20:10:51 +0200 (CEST)", "from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4F3024A8;\n\tSat, 3 Sep 2022 20:10:51 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662228654;\n\tbh=eMGSi/27H+OU236Wr8sTP2VnIhK3fDLlkmTXN6wvgBM=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=K8rWVZiq6NVPiOB3zVsTZ+fwADIKvdEFMmKpi35XKVqj5WQrvHBwvqc4HvKiMWJgP\n\txKswp/eaSwqTB1QBz9be77Yy92Lqwe6w8DrJvsLyz9R2Sb3gQgtEZsI+OkXBdynL3R\n\tkfISr4Np/z/kHM2hsxa9ZsyTfPlFA2kcvk7fDYlgX7XBuH1Kzr5aGb3vUIRzIQuU3s\n\tym6UDtXGM5RCqCv08mAQ2gYreA6M1adIUsAm2IN0ow5XstQAPf164SW6bMcOsud0sI\n\tw6wRhR1N1GLZVrfGsipRS6G9MActFMG0b54yFJHF31PTQqwN5Mat2meISQe0KV30hL\n\tx+XxlQevUkM8Q==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662228651;\n\tbh=eMGSi/27H+OU236Wr8sTP2VnIhK3fDLlkmTXN6wvgBM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=JMo2tXtXP44PwLB9vpwsQmYpWbIA6If/anQjfeoMNNmhDqgUEb3HPvOP2e9I7bGEl\n\tYtkONLsNvUgAdfET6+wuNU3i74vO34DHH3BTPOIQ4WsRGp6kEv8zWmBP+BoGmIrOku\n\tVjco/pEiM+SbaHDvrN0xbWGZ91I+3k4bqrLhaRDI=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"JMo2tXtX\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 3 Sep 2022 21:10:35 +0300", "Message-Id": "<20220903181037.1406-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20220903181037.1406-1-laurent.pinchart@ideasonboard.com>", "References": "<20220903181037.1406-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 1/3] pipeline: uvcvideo: Move camera ID\n\tgeneration to UVCCameraData class", "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>", "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Move the camera ID generation to UVCCameraData, and cache the ID in that\nclass. This will be useful to access the ID in multiple locations, such\nas when printing error messages.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 149 ++++++++++---------\n 1 file changed, 78 insertions(+), 71 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 2ae640a31f68..22b67faf309e 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -46,8 +46,15 @@ public:\n \t\t\tControlInfoMap::Map *ctrls);\n \tvoid bufferReady(FrameBuffer *buffer);\n \n+\tconst std::string &id() const { return id_; }\n+\n \tstd::unique_ptr<V4L2VideoDevice> video_;\n \tStream stream_;\n+\n+private:\n+\tbool generateId();\n+\n+\tstd::string id_;\n };\n \n class UVCCameraConfiguration : public CameraConfiguration\n@@ -81,8 +88,6 @@ public:\n \tbool match(DeviceEnumerator *enumerator) override;\n \n private:\n-\tstd::string generateId(const UVCCameraData *data);\n-\n \tint processControl(ControlList *controls, unsigned int id,\n \t\t\t const ControlValue &value);\n \tint processControls(UVCCameraData *data, Request *request);\n@@ -384,69 +389,6 @@ int PipelineHandlerUVC::queueRequestDevice(Camera *camera, Request *request)\n \treturn 0;\n }\n \n-std::string PipelineHandlerUVC::generateId(const UVCCameraData *data)\n-{\n-\tconst std::string path = data->video_->devicePath();\n-\n-\t/* Create a controller ID from first device described in firmware. */\n-\tstd::string controllerId;\n-\tstd::string searchPath = path;\n-\twhile (true) {\n-\t\tstd::string::size_type pos = searchPath.rfind('/');\n-\t\tif (pos <= 1) {\n-\t\t\tLOG(UVC, Error) << \"Can not find controller ID\";\n-\t\t\treturn {};\n-\t\t}\n-\n-\t\tsearchPath = searchPath.substr(0, pos);\n-\n-\t\tcontrollerId = sysfs::firmwareNodePath(searchPath);\n-\t\tif (!controllerId.empty())\n-\t\t\tbreak;\n-\t}\n-\n-\t/*\n-\t * Create a USB ID from the device path which has the known format:\n-\t *\n-\t *\tpath = bus, \"-\", ports, \":\", config, \".\", interface ;\n-\t *\tbus = number ;\n-\t *\tports = port, [ \".\", ports ] ;\n-\t *\tport = number ;\n-\t *\tconfig = number ;\n-\t *\tinterface = number ;\n-\t *\n-\t * Example: 3-2.4:1.0\n-\t *\n-\t * The bus is not guaranteed to be stable and needs to be stripped from\n-\t * the USB ID. The final USB ID is built up of the ports, config and\n-\t * interface properties.\n-\t *\n-\t * Example 2.4:1.0.\n-\t */\n-\tstd::string usbId = utils::basename(path.c_str());\n-\tusbId = usbId.substr(usbId.find('-') + 1);\n-\n-\t/* Creata a device ID from the USB devices vendor and product ID. */\n-\tstd::string deviceId;\n-\tfor (const char *name : { \"idVendor\", \"idProduct\" }) {\n-\t\tstd::ifstream file(path + \"/../\" + name);\n-\n-\t\tif (!file.is_open())\n-\t\t\treturn {};\n-\n-\t\tstd::string value;\n-\t\tstd::getline(file, value);\n-\t\tfile.close();\n-\n-\t\tif (!deviceId.empty())\n-\t\t\tdeviceId += \":\";\n-\n-\t\tdeviceId += value;\n-\t}\n-\n-\treturn controllerId + \"-\" + usbId + \"-\" + deviceId;\n-}\n-\n bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n {\n \tMediaDevice *media;\n@@ -462,12 +404,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \n \t/* Create and register the camera. */\n-\tstd::string id = generateId(data.get());\n-\tif (id.empty()) {\n-\t\tLOG(UVC, Error) << \"Failed to generate camera ID\";\n-\t\treturn false;\n-\t}\n-\n+\tstd::string id = data->id();\n \tstd::set<Stream *> streams{ &data->stream_ };\n \tstd::shared_ptr<Camera> camera =\n \t\tCamera::create(std::move(data), id, streams);\n@@ -502,6 +439,12 @@ int UVCCameraData::init(MediaDevice *media)\n \n \tvideo_->bufferReady.connect(this, &UVCCameraData::bufferReady);\n \n+\t/* Generate the camera ID. */\n+\tif (!generateId()) {\n+\t\tLOG(UVC, Error) << \"Failed to generate camera ID\";\n+\t\treturn -EINVAL;\n+\t}\n+\n \tproperties_.set(properties::Model, utils::toAscii(media->model()));\n \n \t/*\n@@ -563,6 +506,70 @@ int UVCCameraData::init(MediaDevice *media)\n \treturn 0;\n }\n \n+bool UVCCameraData::generateId()\n+{\n+\tconst std::string path = video_->devicePath();\n+\n+\t/* Create a controller ID from first device described in firmware. */\n+\tstd::string controllerId;\n+\tstd::string searchPath = path;\n+\twhile (true) {\n+\t\tstd::string::size_type pos = searchPath.rfind('/');\n+\t\tif (pos <= 1) {\n+\t\t\tLOG(UVC, Error) << \"Can not find controller ID\";\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tsearchPath = searchPath.substr(0, pos);\n+\n+\t\tcontrollerId = sysfs::firmwareNodePath(searchPath);\n+\t\tif (!controllerId.empty())\n+\t\t\tbreak;\n+\t}\n+\n+\t/*\n+\t * Create a USB ID from the device path which has the known format:\n+\t *\n+\t *\tpath = bus, \"-\", ports, \":\", config, \".\", interface ;\n+\t *\tbus = number ;\n+\t *\tports = port, [ \".\", ports ] ;\n+\t *\tport = number ;\n+\t *\tconfig = number ;\n+\t *\tinterface = number ;\n+\t *\n+\t * Example: 3-2.4:1.0\n+\t *\n+\t * The bus is not guaranteed to be stable and needs to be stripped from\n+\t * the USB ID. The final USB ID is built up of the ports, config and\n+\t * interface properties.\n+\t *\n+\t * Example 2.4:1.0.\n+\t */\n+\tstd::string usbId = utils::basename(path.c_str());\n+\tusbId = usbId.substr(usbId.find('-') + 1);\n+\n+\t/* Creata a device ID from the USB devices vendor and product ID. */\n+\tstd::string deviceId;\n+\tfor (const char *name : { \"idVendor\", \"idProduct\" }) {\n+\t\tstd::ifstream file(path + \"/../\" + name);\n+\n+\t\tif (!file.is_open())\n+\t\t\treturn false;\n+\n+\t\tstd::string value;\n+\t\tstd::getline(file, value);\n+\t\tfile.close();\n+\n+\t\tif (!deviceId.empty())\n+\t\t\tdeviceId += \":\";\n+\n+\t\tdeviceId += value;\n+\t}\n+\n+\tid_ = controllerId + \"-\" + usbId + \"-\" + deviceId;\n+\treturn true;\n+}\n+\n void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info,\n \t\t\t ControlInfoMap::Map *ctrls)\n {\n", "prefixes": [ "libcamera-devel", "1/3" ] }