From patchwork Sun Mar 28 22:45:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11747 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5B2DBC32EA for ; Sun, 28 Mar 2021 22:45:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19DC068788; Mon, 29 Mar 2021 00:45:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="QpaszsmQ"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C7776877C for ; Mon, 29 Mar 2021 00:45:37 +0200 (CEST) Received: by mail-pj1-x102f.google.com with SMTP id f2-20020a17090a4a82b02900c67bf8dc69so6808554pjh.1 for ; Sun, 28 Mar 2021 15:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zk4sjHPGuv7zXqT8sfjgx4K+iKxGU2Nrb0XJoo3SUQ8=; b=QpaszsmQntqgX0/oW8ppqsfnW8qkUkYzC2xz7uQqZKXL9GCmeqUxHYF3E5Xe67fMLS TN/1pU9WgRum0PQCz6KKKTajZ+khXyqxgcNHiFOgUGqrNB11GdeST3+8O7aEIcWCoJqj g5tdyYyfMb7HHKwVCq8tIUrGA+kXs3tHxT338= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zk4sjHPGuv7zXqT8sfjgx4K+iKxGU2Nrb0XJoo3SUQ8=; b=hTdIno1SbFMrl6X0b/gpiYZ04ogN3H4kcR0s12xWIV8nZA9N2ZpJnGKkJTa/suDI/m Hqg7IVd5M0X3zXWDh5WLAMqOUgIWS1GejRvF7bJqXmL4k2B8LShSV6baEEvzroCo7udh nKrKM7NrWzW/4+mw5NdKvyZ4UsoCFAwSoBjapEmgzDz9WkL86/6RDfzwpHaqSwuysr17 23DF+OEUIjm8D5lUdtFJMSVzK6J22QmuDFhNo5vLrPmkYoRQndK1yUj/b2eq+/OUY1sv bTQ5ysdV0otBzwVcg88eyde83ECWkKkCC9ztZGObyz9MOOGZ1QNuHJ0im/06+ziRHpbX 5R/Q== X-Gm-Message-State: AOAM532ubP+cmArSGSDLLzu6QHyCxtVCSvDAUJnpM+xATbZHcml1LVkh JnlEGX7HVoRa96ornwGSZKLm02gah/yblQ== X-Google-Smtp-Source: ABdhPJyakDNRg1ggJxTUl2N8uJ7GBk8LHpb8B9qEwjp0P7tJeX/L+tq3BivPgYbpR5Y7hUWxGQx2RA== X-Received: by 2002:a17:90a:7a8b:: with SMTP id q11mr24043699pjf.215.1616971535869; Sun, 28 Mar 2021 15:45:35 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:1db7:ae60:9288:b906]) by smtp.gmail.com with ESMTPSA id q25sm14814244pff.104.2021.03.28.15.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 15:45:35 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Mar 2021 07:45:26 +0900 Message-Id: <20210328224528.55468-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210328224528.55468-1-hiroh@chromium.org> References: <20210328224528.55468-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] android: CameraDevice: Validate crop_rotate_scale_degrees in configuration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Libcamera doesn't handle |crop_rotate_scale_degrees| in camera3_stream at all. This adds the validation of the requested |crop_rotate_scale_degrees| in configuration, but still not handle the specified values. Signed-off-by: Hirokazu Honda --- src/android/camera_device.cpp | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) -- 2.31.0.291.g576ba9dcdaf-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ae693664..c5e55a18 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -256,6 +256,39 @@ void sortCamera3StreamConfigs(std::vector &unsortedConfigs, unsortedConfigs = sortedConfigs; } +/* + * Returns where crop_rotate_scale_degrees in all camera3_stream in stream_list + * are valid. + */ +bool validateCropRotate(const camera3_stream_configuration_t &stream_list) +{ + ASSERT(stream_list.num_streams > 0); + + const int cropRotateScaleDegrees = + stream_list.streams[0]->crop_rotate_scale_degrees; + for (unsigned int i = 0; i < stream_list.num_streams; ++i) { + const camera3_stream_t &stream = *stream_list.streams[i]; + if (CAMERA3_STREAM_ROTATION_0 > stream.crop_rotate_scale_degrees || + CAMERA3_STREAM_ROTATION_270 < stream.crop_rotate_scale_degrees) { + LOG(HAL, Error) << "Invalid crop_rotate_scale_degrees: " + << stream.crop_rotate_scale_degrees; + return false; + } + if (stream.crop_rotate_scale_degrees == CAMERA3_STREAM_ROTATION_180) { + LOG(HAL, Error) << "crop_rotate_scale_degrees should " + << "not be CAMERA3_STREAM_ROTATION_180"; + return false; + } + if (cropRotateScaleDegrees != stream.crop_rotate_scale_degrees) { + LOG(HAL, Error) << "crop_rotate_scale_degrees in all " + << "streams are not identical"; + return false; + } + } + + return true; +} + } /* namespace */ /* @@ -1552,6 +1585,12 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) running_ = false; } + if (stream_list->num_streams == 0) + return -EINVAL; + + if (!validateCropRotate(*stream_list)) + return -EINVAL; + /* * Generate an empty configuration, and construct a StreamConfiguration * for each camera3_stream to add to it. From patchwork Sun Mar 28 22:45:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11748 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DBBE9C32EA for ; Sun, 28 Mar 2021 22:45:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C3876878B; Mon, 29 Mar 2021 00:45:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Aas611ZP"; dkim-atps=neutral Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 87F316878B for ; Mon, 29 Mar 2021 00:45:39 +0200 (CEST) Received: by mail-pl1-x635.google.com with SMTP id d8so3499400plh.11 for ; Sun, 28 Mar 2021 15:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MYBHAvX6Lsm9+kuGa3isuRmZ/leiSfywV2SdpD6yFD8=; b=Aas611ZPdVOv+DIAHBhSXxu2mp3pca7v3RLfZ58KVaeXlO75kIurNOvzs1PwYIkoEW TPhHMLOjxocXNVGHl1ruHVWxkWcauezRWYQGaJc3KnbxMVyQVTnsvQnNH9YdbbzNvbvE n96k9c0O2tlUd+3f2rgjNJZZIyKkI14rHinBg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MYBHAvX6Lsm9+kuGa3isuRmZ/leiSfywV2SdpD6yFD8=; b=Q7F/Hy2O8D2fOrOUIRarEXQ6qwh7O/3JwnZSycG6Nj64zHiSWc/rPLuHn7RHwIntXR VKfa0d8qq0qyVOyDbPdv8WaVkMaP+fr68ce4G10rlq4MZacZRalHmviosSGTnsCKeegP CENa7r8WVRDj2gvU4aY/NzDNC8VQgt0sDAEKKcmHhzWSXiE/ZA3IiCoR4bYQFmI5b9fP y1jasTbo48LQoyYlUcwuMzP96jPbK45+a4Lkgq/XkVlJenmRBcPYzdjkrrhqtY3PBeuz aMHyOBOcNFmH0oFBbkvfE0Z/hzV2zcjAg2qbDcw847z1wT4VCcney9wA/oD/+rkMNgDY DPIg== X-Gm-Message-State: AOAM530N3Y5Ie2r5Ra8u8eYEjKvD+4j/Ivx+tfYtkSsCw2Rr1VAzXZwC L4b2ZqfQBi5v0ZKwPR611ecidL8J8NkxZg== X-Google-Smtp-Source: ABdhPJxRjgzHWkrHSn2BUoyfAs3QiUB3zPeukH5lqEq1kwjjSajFcX9XBgVj55emouaSi4K1hiUcig== X-Received: by 2002:a17:90a:c7d5:: with SMTP id gf21mr22980802pjb.165.1616971537402; Sun, 28 Mar 2021 15:45:37 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:1db7:ae60:9288:b906]) by smtp.gmail.com with ESMTPSA id q25sm14814244pff.104.2021.03.28.15.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 15:45:37 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Mar 2021 07:45:27 +0900 Message-Id: <20210328224528.55468-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210328224528.55468-1-hiroh@chromium.org> References: <20210328224528.55468-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] android: CameraDevice: Log rotation variables in camera3_stream X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" |rotation| and |crop_rotate_scale_degrees| are important info of a configuration. They should be logged. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- 2.31.0.291.g576ba9dcdaf-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index c5e55a18..d3368b19 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -256,6 +256,20 @@ void sortCamera3StreamConfigs(std::vector &unsortedConfigs, unsortedConfigs = sortedConfigs; } +const char *rotationToString(int rotation) +{ + switch (rotation) { + case CAMERA3_STREAM_ROTATION_0: + return "ROTATION_0"; + case CAMERA3_STREAM_ROTATION_90: + return "ROTATION_90"; + case CAMERA3_STREAM_ROTATION_180: + return "ROTATION_180"; + case CAMERA3_STREAM_ROTATION_270: + return "ROTATION_270"; + } + return "ROTATION_INVALID"; +} /* * Returns where crop_rotate_scale_degrees in all camera3_stream in stream_list * are valid. @@ -1625,6 +1639,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) << ", width: " << stream->width << ", height: " << stream->height << ", format: " << utils::hex(stream->format) + << ", rotation: " << rotationToString(stream->rotation) + << ", crop_rotate_scale_degrees: " + << rotationToString(stream->crop_rotate_scale_degrees) << " (" << format.toString() << ")"; if (!format.isValid()) From patchwork Sun Mar 28 22:45:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11749 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 44588C32EA for ; Sun, 28 Mar 2021 22:45:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 073E268788; Mon, 29 Mar 2021 00:45:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="S0wUsJah"; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 668BB6877C for ; Mon, 29 Mar 2021 00:45:40 +0200 (CEST) Received: by mail-pj1-x1033.google.com with SMTP id il9-20020a17090b1649b0290114bcb0d6c2so6823520pjb.0 for ; Sun, 28 Mar 2021 15:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3XFw66zLJldvVab3br52TbLvk9ogclQY85vQlEPbt3k=; b=S0wUsJahy2O3TKZENIF0sc2jNLgm394tokG2JLG6aUf73yWoZncONvRO/BqagEfwoS f6Pfq2YuveMWASbgpk/EDdvKEeUBvvXQVZ2VUAgZ//Ca0mpVrvj2mX7mE5YtCTEcwsR7 2w7+PDiSGC0mgXaM7duTwhe9J7Rfisc00Ij2Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3XFw66zLJldvVab3br52TbLvk9ogclQY85vQlEPbt3k=; b=dNmC8yMtePm4cNTBEmxxTD+ggX4UdNbgHJebNcsJLAMJl4PhVUeFYnTYSPIs4hy7GZ 1JGtxwtRImmqHMxSNgq6B+W2rf/8GLIN23ze5X6ADwj4tZs5x8UR1PdgXDooZLGeEWKs qmnAA3D/UUm9x5P0SjkOpdNRpkn9Ufu+SLTgK28Bk3/LH2ZeiYH6+3PxhJvvjX8MnCni z10PHj75ILIkutpOp0mOIEwqs1js7XoYTLYZQAEHRDnORZso5pXI4mR4hya0uPClLr4A 5Yjtqle9T7sGrqUiFt3mksG51/1Kbmht8ukNyzBjXf/GkII0elMP8dTrYZSzPps8sF5T FO/w== X-Gm-Message-State: AOAM530w1SjGxdEG61HUlXmJE1oj61ahUm7zHeH2FT4TdWwgXBZKACTd x/me/gKkxdfNg7QLzqqd9qW2PcTnSdfpoA== X-Google-Smtp-Source: ABdhPJyL8fzkXFv/ZuZ4KrNYpQlRCeoCKiFNn6SZmSDUiHWyzenP1RmNgQuj9T9b7TyExwPVZ1stIg== X-Received: by 2002:a17:903:188:b029:e6:52f4:1b2d with SMTP id z8-20020a1709030188b02900e652f41b2dmr26407183plg.58.1616971538798; Sun, 28 Mar 2021 15:45:38 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:1db7:ae60:9288:b906]) by smtp.gmail.com with ESMTPSA id q25sm14814244pff.104.2021.03.28.15.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 15:45:38 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Mar 2021 07:45:28 +0900 Message-Id: <20210328224528.55468-4-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210328224528.55468-1-hiroh@chromium.org> References: <20210328224528.55468-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] android: CameraDevice: Deny non ROTATION_0 stream configuration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Libcamera doesn't handle crop_rotate_scale_degrees. Therefore, if it is requested, that is, crop_rotate_scale_degrees is not CAMERA3_STREAM_ROTATION_0, the configuration should fail. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.31.0.291.g576ba9dcdaf-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index d3368b19..11c0f35a 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1647,6 +1647,13 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) if (!format.isValid()) return -EINVAL; + /* \todo Support rotation. */ + if (stream->rotation != CAMERA3_STREAM_ROTATION_0 || + stream->crop_rotate_scale_degrees != CAMERA3_STREAM_ROTATION_0) { + LOG(HAL, Error) << "Rotation is not supported"; + return -EINVAL; + } + /* Defer handling of MJPEG streams until all others are known. */ if (stream->format == HAL_PIXEL_FORMAT_BLOB) { if (jpegStream) {