{"id":11782,"url":"https://patchwork.libcamera.org/api/patches/11782/?format=json","web_url":"https://patchwork.libcamera.org/patch/11782/","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":"<20210330052521.381550-3-hiroh@chromium.org>","date":"2021-03-30T05:25:19","name":"[libcamera-devel,v3,2/4] android: CameraDevice: Validate crop_rotate_scale_degrees in configuration","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"9e315d19f88bf342583d56b6518a7de109755819","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11782/mbox/","series":[{"id":1866,"url":"https://patchwork.libcamera.org/api/series/1866/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1866","date":"2021-03-30T05:25:17","name":"Regard crop_rotate_scale_degrees in configuration","version":3,"mbox":"https://patchwork.libcamera.org/series/1866/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11782/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11782/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 073A0C32F0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Mar 2021 05:25:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 94B816878E;\n\tTue, 30 Mar 2021 07:25:35 +0200 (CEST)","from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com\n\t[IPv6:2607:f8b0:4864:20::1036])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8AF4E68782\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Mar 2021 07:25:32 +0200 (CEST)","by mail-pj1-x1036.google.com with SMTP id\n\tcl21-20020a17090af695b02900c61ac0f0e9so708752pjb.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Mar 2021 22:25:32 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:c112:2822:484f:486])\n\tby smtp.gmail.com with ESMTPSA id\n\tu79sm19726006pfc.207.2021.03.29.22.25.28\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 29 Mar 2021 22:25:29 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"mAx3cCd5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=/7+uGJ7HhmqCSqVDyOBu+HTkMdRR7c4qWTGEw3kJnmc=;\n\tb=mAx3cCd5Fw7JuZ7ITVEULrfZ1qFYrwrkDB6KtHlCNNYRppcggYK6g/2cUCgX8szm2G\n\tdQ/KLequWSrRqF6wcAsThG1BLHk9P+Y7UOLc+t+FpgabKpLGC6l90qnCwUNYD//1QKf+\n\tEiuwxLfZm4U6ynsZMgtTYnLRAmSnmoaTdzD9U=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=/7+uGJ7HhmqCSqVDyOBu+HTkMdRR7c4qWTGEw3kJnmc=;\n\tb=ofXRAgITXLeusUyoc+SJPCpiRKdxAyjCXzf1AJABxLEMV71KmFXEHodoYseF8kEsZ0\n\tvU7vYfUGHU5wi8pVgB6cksi6w16Vg3GmJ8qOLgNqhz1JI1C2AzSvS/NyL3au2eVsPVSC\n\tvMTWjFqF1SscDi8CHAVri7xF9wzRRD9VjsfYxTK2mqiNEjRrrN6iUhG7AudfuKji0ZpN\n\tX0i7q4uthvJ969PDHKtV937ZAdl31WGsUJ89y/4VrYGVYXjhkGx4bfxl129Snn7CIOSV\n\trA670z1TVN8sXC0x/E3CimEvhn5C6pL2HySz/umbiNdvKLWaLZnMUnuUJZf1OEiyYVIL\n\t56wQ==","X-Gm-Message-State":"AOAM530Vgq3DrzSGK0+ue8PVKHIfH5d8vCc84DIAyzpkaCeOMO07PrwD\n\tiint9v1gjO9mFXoccoPhOHFnT6tyQ6fYiw==","X-Google-Smtp-Source":"ABdhPJyQt747CqcMiHA8cTi0rZwnJ7l4yM2CXYYQyI6om36kVcxNVfAXsIeSOuWVpALX222TuPau3g==","X-Received":"by 2002:a17:902:7d8d:b029:e6:4061:b767 with SMTP id\n\ta13-20020a1709027d8db02900e64061b767mr31834299plm.32.1617081930142; \n\tMon, 29 Mar 2021 22:25:30 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 30 Mar 2021 14:25:19 +0900","Message-Id":"<20210330052521.381550-3-hiroh@chromium.org>","X-Mailer":"git-send-email 2.31.0.291.g576ba9dcdaf-goog","In-Reply-To":"<20210330052521.381550-1-hiroh@chromium.org>","References":"<20210330052521.381550-1-hiroh@chromium.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 2/4] android: CameraDevice: Validate\n\tcrop_rotate_scale_degrees in configuration","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>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Libcamera doesn't handle |crop_rotate_scale_degrees| in\ncamera3_stream at all. This adds the validation of the requested\n|crop_rotate_scale_degrees| in configuration, but still not\nhandle the specified values.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/camera_device.cpp | 46 +++++++++++++++++++++++++++++++++++\n 1 file changed, 46 insertions(+)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex ae693664..f88e94bc 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -256,6 +256,44 @@ void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,\n \tunsortedConfigs = sortedConfigs;\n }\n \n+#if defined(CHROMEOS)\n+/*\n+ * Check whether the crop_rotate_scale_degrees values for all streams in\n+ * the list are valid according to the Chrome OS camera HAL API.\n+ */\n+bool validateCropRotate(const camera3_stream_configuration_t &streamList)\n+{\n+\tASSERT(streamList.num_streams > 0);\n+\tconst int cropRotateScaleDegrees =\n+\t\tstreamList.streams[0]->crop_rotate_scale_degrees;\n+\tfor (unsigned int i = 0; i < streamList.num_streams; ++i) {\n+\t\tconst camera3_stream_t &stream = *streamList.streams[i];\n+\n+\t\tswitch (stream.crop_rotate_scale_degrees) {\n+\t\tcase CAMERA3_STREAM_ROTATION_0:\n+\t\tcase CAMERA3_STREAM_ROTATION_90:\n+\t\tcase CAMERA3_STREAM_ROTATION_270:\n+\t\t\tbreak;\n+\n+\t\t/* 180° rotation is specified by Chrome OS as invalid. */\n+\t\tcase CAMERA3_STREAM_ROTATION_180:\n+\t\tdefault:\n+\t\t\tLOG(HAL, Error) << \"Invalid crop_rotate_scale_degrees: \"\n+\t\t\t\t\t<< stream.crop_rotate_scale_degrees;\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tif (cropRotateScaleDegrees != stream.crop_rotate_scale_degrees) {\n+\t\t\tLOG(HAL, Error) << \"crop_rotate_scale_degrees in all \"\n+\t\t\t\t\t<< \"streams are not identical\";\n+\t\t\treturn false;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+#endif\n+\n } /* namespace */\n \n /*\n@@ -1552,6 +1590,14 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\trunning_ = false;\n \t}\n \n+\tif (stream_list->num_streams == 0)\n+\t\treturn -EINVAL;\n+\n+#if defined(CHROMEOS)\n+\tif (!validateCropRotate(*stream_list))\n+\t\treturn -EINVAL;\n+#endif\n+\n \t/*\n \t * Generate an empty configuration, and construct a StreamConfiguration\n \t * for each camera3_stream to add to it.\n","prefixes":["libcamera-devel","v3","2/4"]}