{"id":1272,"url":"https://patchwork.libcamera.org/api/patches/1272/?format=json","web_url":"https://patchwork.libcamera.org/patch/1272/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190523135900.24029-4-kieran.bingham@ideasonboard.com>","date":"2019-05-23T13:59:00","name":"[libcamera-devel,v2,3/3] libcamera: pipeline: uvc: Use the device to validate formats","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"0e3cae16797c64f8179ea9164cf2555fbc71fb77","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":{"id":11,"url":"https://patchwork.libcamera.org/api/users/11/?format=json","username":"kbingham","first_name":"Kieran","last_name":"Bingham","email":"kieran.bingham@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/1272/mbox/","series":[{"id":322,"url":"https://patchwork.libcamera.org/api/series/322/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=322","date":"2019-05-23T13:58:57","name":"V4L2Device Try format support","version":2,"mbox":"https://patchwork.libcamera.org/series/322/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1272/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1272/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["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 2DB5960E4C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 May 2019 15:59:06 +0200 (CEST)","from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BD9BDB93;\n\tThu, 23 May 2019 15:59:05 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1558619945;\n\tbh=ngTtArm6h9Ki5s6nJfol2JanyMaJy0woc7tnpLqFMmU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=VvTFYP7msVRyoxCgkJIcNS4TMYRu2F1WosbXpE+s6PvwLDFRVgrCZqOl4lHBRSjrv\n\t9Gs0Z7TNRXX64bUZGWFLYL3r6gkjrZlg1Nl6coleiunpxqBYkeBn9UYE5IBMYVBivo\n\tMO2n1aVsoS7GzeAKj39iZuEhOTSY+AbEKHSjk9tk=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Thu, 23 May 2019 14:59:00 +0100","Message-Id":"<20190523135900.24029-4-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190523135900.24029-1-kieran.bingham@ideasonboard.com>","References":"<20190523135900.24029-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 3/3] libcamera: pipeline: uvc: Use the\n\tdevice to validate formats","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":"Thu, 23 May 2019 13:59:06 -0000"},"content":"UVC pipelines are highly variable, and we can not define their\nconfiguration restrictions within the UVC pipeline handler directly.\n\nUpdate the UVCCameraConfiguration to store the UVCCameraData (storing\na reference to the camera as a means of borrowing a reference to the\ncamera data).\n\nWe then validate the configuration by the tryFormat() operation on the\nUVC V4L2Device.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/pipeline/uvcvideo.cpp | 36 +++++++++++++++++++++--------\n 1 file changed, 26 insertions(+), 10 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 45260f34c8f5..df321c6e64a6 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -42,9 +42,18 @@ public:\n class UVCCameraConfiguration : public CameraConfiguration\n {\n public:\n-\tUVCCameraConfiguration();\n+\tUVCCameraConfiguration(Camera *camera, UVCCameraData *data);\n \n \tStatus validate() override;\n+\n+private:\n+\t/*\n+\t * The UVCCameraConfiguration instance is guaranteed to be valid as long\n+\t * as the corresponding Camera instance is valid. In order to borrow a\n+\t * reference to the camera data, store a new reference to the camera.\n+\t */\n+\tstd::shared_ptr<Camera> camera_;\n+\tconst UVCCameraData *data_;\n };\n \n class PipelineHandlerUVC : public PipelineHandler\n@@ -76,9 +85,12 @@ private:\n \t}\n };\n \n-UVCCameraConfiguration::UVCCameraConfiguration()\n+UVCCameraConfiguration::UVCCameraConfiguration(Camera *camera,\n+\t\t\t\t\t       UVCCameraData *data)\n \t: CameraConfiguration()\n {\n+\tcamera_ = camera->shared_from_this();\n+\tdata_ = data;\n }\n \n CameraConfiguration::Status UVCCameraConfiguration::validate()\n@@ -96,17 +108,20 @@ CameraConfiguration::Status UVCCameraConfiguration::validate()\n \n \tStreamConfiguration &cfg = config_[0];\n \n-\t/* \\todo: Validate the configuration against the device capabilities. */\n-\tconst unsigned int pixelFormat = cfg.pixelFormat;\n-\tconst Size size = cfg.size;\n+\tV4L2DeviceFormat format;\n+\tformat.fourcc = cfg.pixelFormat;\n+\tformat.size = cfg.size;\n \n-\tcfg.pixelFormat = V4L2_PIX_FMT_YUYV;\n-\tcfg.size = { 640, 480 };\n+\t/* Validate the format on the device. */\n+\tdata_->video_->tryFormat(&format);\n \n-\tif (cfg.pixelFormat != pixelFormat || cfg.size != size) {\n+\tif (cfg.pixelFormat != format.fourcc || cfg.size != format.size) {\n \t\tLOG(UVC, Debug)\n \t\t\t<< \"Adjusting configuration from \" << cfg.toString()\n-\t\t\t<< \" to \" << cfg.size.toString() << \"-YUYV\";\n+\t\t\t<< \" to \" << format.toString();\n+\n+\t\tcfg.pixelFormat = format.fourcc;\n+\t\tcfg.size = format.size;\n \t\tstatus = Adjusted;\n \t}\n \n@@ -123,7 +138,8 @@ PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager)\n CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera,\n \tconst StreamRoles &roles)\n {\n-\tCameraConfiguration *config = new UVCCameraConfiguration();\n+\tUVCCameraData *data = cameraData(camera);\n+\tCameraConfiguration *config = new UVCCameraConfiguration(camera, data);\n \n \tif (roles.empty())\n \t\treturn config;\n","prefixes":["libcamera-devel","v2","3/3"]}