Patch Detail
Show a patch.
GET /api/1.1/patches/21735/?format=api
{ "id": 21735, "url": "https://patchwork.libcamera.org/api/1.1/patches/21735/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21735/", "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": "<20241022102448.229381-1-stanislaw.gruszka@linux.intel.com>", "date": "2024-10-22T10:24:48", "name": "[v3] qcam: Automatically select the camera if only one is available", "commit_ref": "80a7ccd3add45eb56fda6f1fb445017ac01fea7a", "pull_url": null, "state": "accepted", "archived": false, "hash": "14ecc16b627faf4d04f233f78e8c7854639dbef0", "submitter": { "id": 211, "url": "https://patchwork.libcamera.org/api/1.1/people/211/?format=api", "name": "Stanislaw Gruszka", "email": "stanislaw.gruszka@linux.intel.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/21735/mbox/", "series": [ { "id": 4735, "url": "https://patchwork.libcamera.org/api/1.1/series/4735/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4735", "date": "2024-10-22T10:24:48", "name": "[v3] qcam: Automatically select the camera if only one is available", "version": 3, "mbox": "https://patchwork.libcamera.org/series/4735/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21735/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21735/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 49F6EC3274\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Oct 2024 10:24:56 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2BF3165395;\n\tTue, 22 Oct 2024 12:24:55 +0200 (CEST)", "from mgamail.intel.com (mgamail.intel.com [198.175.65.17])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D8368633C8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Oct 2024 12:24:52 +0200 (CEST)", "from orviesa010.jf.intel.com ([10.64.159.150])\n\tby orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n\t22 Oct 2024 03:24:51 -0700", "from sgruszka-mobl.ger.corp.intel.com (HELO localhost)\n\t([10.245.97.183]) by orviesa010-auth.jf.intel.com with\n\tESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 03:24:50 -0700" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=intel.com header.i=@intel.com\n\theader.b=\"Rhddeevs\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n\td=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n\tt=1729592693; x=1761128693;\n\th=from:to:subject:date:message-id:mime-version:\n\tcontent-transfer-encoding;\n\tbh=N0KmeFd/c0JG2UcTnQx/jooqGI3qzlGqZFTWQdNB7nc=;\n\tb=RhddeevsiWNprIkcavdG/x8t7r954IHZ9q/4zSrFtMtEyprBD4UmmTCC\n\tmZGndhrdfe2k6TSzdxR6IemTU6utT5NkoNswihe2mYJ1Mlf9IFizk5c4L\n\tyfUeiSttgzWleBjXH7TBRwrFWDyJZTy3tqdQ+xZBbXpxo/O1qB0U9UDp9\n\thoKxXOYv4qn1AzuQQe+mtpe/AE2nmACtLBtdVqVG0dmAQVuYAzLku+dWh\n\t9Z2R0SCFhgZMMAEdAMSKlck6UEch82rbMa/Ybhljafs+oed7NWUnwb8n4\n\tweKP05Iph1+kmJsUs4Hh8v38IVg7TO76qFijHBsLLh6G14gPUbWqQmKTU A==;", "X-CSE-ConnectionGUID": [ "P+WyvlgbSj27xb7McJ3QiQ==", "yRc7MSNdQ6qIe16rAQm2ig==" ], "X-CSE-MsgGUID": [ "SWlBIiXWQbKutjis2O8iSA==", "nD1UBkz9Q/6aksrMzFymeQ==" ], "X-IronPort-AV": [ "E=McAfee;i=\"6700,10204,11232\"; a=\"29220511\"", "E=Sophos;i=\"6.11,222,1725346800\"; d=\"scan'208\";a=\"29220511\"", "E=Sophos;i=\"6.11,222,1725346800\"; d=\"scan'208\";a=\"79765308\"" ], "X-ExtLoop1": "1", "From": "Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v3] qcam: Automatically select the camera if only one is\n\tavailable", "Date": "Tue, 22 Oct 2024 12:24:48 +0200", "Message-Id": "<20241022102448.229381-1-stanislaw.gruszka@linux.intel.com>", "X-Mailer": "git-send-email 2.34.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "When only a single camera is available, showing the camera selection\ndialog is unnecessary. It's better to automatically select the available\ncamera without prompting the user for input.\n\nCo-developed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>\n---\nv2:\n- Avoid cm_->cameras().size() vs cm_->cameras()[0] race condition\n using custom loop.\n- Update in code comment\nv3: \n- Avoid TOCTOU race using shared_ptr vector copy\n- Use Laurent comment wording\n\n src/apps/qcam/main_window.cpp | 16 +++++++++++-----\n 1 file changed, 11 insertions(+), 5 deletions(-)", "diff": "diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp\nindex 5144c6b3..de487672 100644\n--- a/src/apps/qcam/main_window.cpp\n+++ b/src/apps/qcam/main_window.cpp\n@@ -298,13 +298,19 @@ int MainWindow::openCamera()\n \tstd::string cameraName;\n \n \t/*\n-\t * Use the camera specified on the command line, if any, or display the\n-\t * camera selection dialog box otherwise.\n+\t * If a camera is specified on the command line, get it. Otherwise, if\n+\t * only one camera is available, pick it automatically, else, display\n+\t * the selector dialog box.\n \t */\n-\tif (options_.isSet(OptCamera))\n+\tif (options_.isSet(OptCamera)) {\n \t\tcameraName = static_cast<std::string>(options_[OptCamera]);\n-\telse\n-\t\tcameraName = chooseCamera();\n+\t} else {\n+\t\tstd::vector<std::shared_ptr<Camera>> cameras = cm_->cameras();\n+\t\tif (cameras.size() == 1)\n+\t\t\tcameraName = cameras[0]->id();\n+\t\telse\n+\t\t\tcameraName = chooseCamera();\n+\t}\n \n \tif (cameraName == \"\")\n \t\treturn -EINVAL;\n", "prefixes": [ "v3" ] }