From patchwork Tue Mar 30 05:25:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11782 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 073A0C32F0 for ; Tue, 30 Mar 2021 05:25:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 94B816878E; Tue, 30 Mar 2021 07:25:35 +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="mAx3cCd5"; dkim-atps=neutral Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8AF4E68782 for ; Tue, 30 Mar 2021 07:25:32 +0200 (CEST) Received: by mail-pj1-x1036.google.com with SMTP id cl21-20020a17090af695b02900c61ac0f0e9so708752pjb.1 for ; Mon, 29 Mar 2021 22:25:32 -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=/7+uGJ7HhmqCSqVDyOBu+HTkMdRR7c4qWTGEw3kJnmc=; b=mAx3cCd5Fw7JuZ7ITVEULrfZ1qFYrwrkDB6KtHlCNNYRppcggYK6g/2cUCgX8szm2G dQ/KLequWSrRqF6wcAsThG1BLHk9P+Y7UOLc+t+FpgabKpLGC6l90qnCwUNYD//1QKf+ EiuwxLfZm4U6ynsZMgtTYnLRAmSnmoaTdzD9U= 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=/7+uGJ7HhmqCSqVDyOBu+HTkMdRR7c4qWTGEw3kJnmc=; b=ofXRAgITXLeusUyoc+SJPCpiRKdxAyjCXzf1AJABxLEMV71KmFXEHodoYseF8kEsZ0 vU7vYfUGHU5wi8pVgB6cksi6w16Vg3GmJ8qOLgNqhz1JI1C2AzSvS/NyL3au2eVsPVSC vMTWjFqF1SscDi8CHAVri7xF9wzRRD9VjsfYxTK2mqiNEjRrrN6iUhG7AudfuKji0ZpN X0i7q4uthvJ969PDHKtV937ZAdl31WGsUJ89y/4VrYGVYXjhkGx4bfxl129Snn7CIOSV rA670z1TVN8sXC0x/E3CimEvhn5C6pL2HySz/umbiNdvKLWaLZnMUnuUJZf1OEiyYVIL 56wQ== X-Gm-Message-State: AOAM530Vgq3DrzSGK0+ue8PVKHIfH5d8vCc84DIAyzpkaCeOMO07PrwD iint9v1gjO9mFXoccoPhOHFnT6tyQ6fYiw== X-Google-Smtp-Source: ABdhPJyQt747CqcMiHA8cTi0rZwnJ7l4yM2CXYYQyI6om36kVcxNVfAXsIeSOuWVpALX222TuPau3g== X-Received: by 2002:a17:902:7d8d:b029:e6:4061:b767 with SMTP id a13-20020a1709027d8db02900e64061b767mr31834299plm.32.1617081930142; Mon, 29 Mar 2021 22:25:30 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:c112:2822:484f:486]) by smtp.gmail.com with ESMTPSA id u79sm19726006pfc.207.2021.03.29.22.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 22:25:29 -0700 (PDT) From: Hirokazu Honda 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 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 Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ae693664..f88e94bc 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -256,6 +256,44 @@ void sortCamera3StreamConfigs(std::vector &unsortedConfigs, unsortedConfigs = sortedConfigs; } +#if defined(CHROMEOS) +/* + * Check whether the crop_rotate_scale_degrees values for all streams in + * the list are valid according to the Chrome OS camera HAL API. + */ +bool validateCropRotate(const camera3_stream_configuration_t &streamList) +{ + ASSERT(streamList.num_streams > 0); + const int cropRotateScaleDegrees = + streamList.streams[0]->crop_rotate_scale_degrees; + for (unsigned int i = 0; i < streamList.num_streams; ++i) { + const camera3_stream_t &stream = *streamList.streams[i]; + + switch (stream.crop_rotate_scale_degrees) { + case CAMERA3_STREAM_ROTATION_0: + case CAMERA3_STREAM_ROTATION_90: + case CAMERA3_STREAM_ROTATION_270: + break; + + /* 180° rotation is specified by Chrome OS as invalid. */ + case CAMERA3_STREAM_ROTATION_180: + default: + LOG(HAL, Error) << "Invalid crop_rotate_scale_degrees: " + << stream.crop_rotate_scale_degrees; + 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; +} +#endif + } /* namespace */ /* @@ -1552,6 +1590,14 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) running_ = false; } + if (stream_list->num_streams == 0) + return -EINVAL; + +#if defined(CHROMEOS) + if (!validateCropRotate(*stream_list)) + return -EINVAL; +#endif + /* * Generate an empty configuration, and construct a StreamConfiguration * for each camera3_stream to add to it. From patchwork Tue Mar 30 05:25:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11783 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 A6FBAC32F0 for ; Tue, 30 Mar 2021 05:25:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5155568787; Tue, 30 Mar 2021 07:25:36 +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="LK5P1HNp"; dkim-atps=neutral Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 99C696877F for ; Tue, 30 Mar 2021 07:25:33 +0200 (CEST) Received: by mail-pg1-x52d.google.com with SMTP id k8so1726694pgf.4 for ; Mon, 29 Mar 2021 22:25:33 -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=uzJ5NBH/VKVvgZ8hs4XPVTW2Cjo7mcmmi+r7ZDRXFN0=; b=LK5P1HNpip8OSedLYC0P9HDPjNUtzP0fvriZvlC5DHFYws8MATbiAARkQAlNF/arMp mcGSdaLF+V4RUNu5GaPid533toK7Wu3bmskrG4w/bRJYfOHYD0vvZ6s/Dx6lBhsV31pm Wb/tjsCuHIe8cInYmYw3gsc0fIG9aOq2N6lQM= 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=uzJ5NBH/VKVvgZ8hs4XPVTW2Cjo7mcmmi+r7ZDRXFN0=; b=eVdzpDoEQMhJEsh39KGJBkd1HywnJE3U8UbC4ej/qSjGdcqOLgurnoVtNBYRPt0BEl CBQufjVAr6VGWDqGsxtEtW8i0SZGWNfkY5JDlXpUb1K7xmadI9dBwhrKrCZaCVWB04lr Ppxy9tSEvo3q0Y2nKurv28CvAE1a13/vADLJeQeucysWE3a0NYHt/SOiF7budplRuNph eISHYKEji9aff7u1TSSxibV3xTtp5YeBsyb/xzfWsMZpSvUc2YRi5FM61f76WOLhzOXx dPMDWJKxZx0+l7GGXb0/lZzH+nyqRm1Y+apO+EXiwORHHCCrb2K2/JVTZBFpuPDGZOae NUUQ== X-Gm-Message-State: AOAM531Q4AMJGiVfSNl37mGgpxLYxJ32YKs0dO/PAvzQr3ZQeMdOcgDj mgjrc7cpdqnpy0dWBfT7vxtPfrFChu+ekQ== X-Google-Smtp-Source: ABdhPJzppM1fI2BVHtW1BNXp8kbW+OYbgSE3d2NDSmKxquGWYv7tqSFUvBOE2kqbmSy3j1YgNJuW+g== X-Received: by 2002:a63:d449:: with SMTP id i9mr26133523pgj.227.1617081932056; Mon, 29 Mar 2021 22:25:32 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:c112:2822:484f:486]) by smtp.gmail.com with ESMTPSA id u79sm19726006pfc.207.2021.03.29.22.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 22:25:31 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 30 Mar 2021 14:25:20 +0900 Message-Id: <20210330052521.381550-4-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 3/4] 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 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index f88e94bc..e0eaa3b5 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -256,6 +256,21 @@ void sortCamera3StreamConfigs(std::vector &unsortedConfigs, unsortedConfigs = sortedConfigs; } +const char *rotationToString(int rotation) +{ + switch (rotation) { + case CAMERA3_STREAM_ROTATION_0: + return "0"; + case CAMERA3_STREAM_ROTATION_90: + return "90"; + case CAMERA3_STREAM_ROTATION_180: + return "180"; + case CAMERA3_STREAM_ROTATION_270: + return "270"; + } + return "INVALID"; +} + #if defined(CHROMEOS) /* * Check whether the crop_rotate_scale_degrees values for all streams in @@ -1632,6 +1647,11 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) << ", width: " << stream->width << ", height: " << stream->height << ", format: " << utils::hex(stream->format) + << ", rotation: " << rotationToString(stream->rotation) +#if defined(CHROMEOS) + << ", crop_rotate_scale_degrees: " + << rotationToString(stream->crop_rotate_scale_degrees) +#endif << " (" << format.toString() << ")"; if (!format.isValid()) From patchwork Tue Mar 30 05:25:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11784 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 752DBC32F0 for ; Tue, 30 Mar 2021 05:25:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2F3C36878D; Tue, 30 Mar 2021 07:25:38 +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="YPRBJECO"; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4EEEF602D7 for ; Tue, 30 Mar 2021 07:25:35 +0200 (CEST) Received: by mail-pf1-x430.google.com with SMTP id v10so6013036pfn.5 for ; Mon, 29 Mar 2021 22:25:35 -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=gVOz5jVRMv2He7b+Ik480Ku/8IyMwqhHk6RVu2nSBAE=; b=YPRBJECOgk6oBmnYpt6bCjtCtrD7CeDx6bJhBkYt/47hS2xce/YTqGTJhlOChlV++I hPwY3xmLfBJoM7l8yvUOHQITsY1H6cfKOlKvfkBzezoA8OLJ5JPIVFPlSP4RQPxSXRy8 7JUZHxdw1hBRRDo7GiY1xKhQExhobcW9pCZjM= 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=gVOz5jVRMv2He7b+Ik480Ku/8IyMwqhHk6RVu2nSBAE=; b=c8OQglgnpK5XYY60FFT3AOsRguI8lewdrZTIXz0RJX/XVTKsNCDDxeRdusvXFmabzi ZvhQtX5jCjtqLEajjvK3v3wrIN67AVetoyIvS4/OBs/KqFeKuGVB4fCbPCX78q7cSKQv B8ge84p33x+09/6qGmbVykHXOulSq+K2QVEqTQaqTEzeOMMY066rnk5/kKTrJd3PoXWN dHVdSzrVTeIWHBsw8XMvGFmn/YBtOvvFUoJ7AGRTawNn0gQa+acYTiTMEDk+DZ9uedcU g/uJZnHarNsEEIbkNXmSvHTjzixHXlMmBNJ/hxjrhr3st8Twyxv04Us5ta6utzW3pklm Xe1w== X-Gm-Message-State: AOAM532vbXEL7eUaGpXzADPz5WGK1yEelXvRTonpYz7Xwrg/AUj1htEo PQX4LK6mca9Cxm1WGW/yBqLv4H+Y0t699A== X-Google-Smtp-Source: ABdhPJzKF862Pl+SD7yCMeO6d5McPzeIbSfo6++Ptd1kDJg2IOnRn1Kx5lKXkejmGoXZPHcJKn/1jg== X-Received: by 2002:a62:6883:0:b029:220:4426:449c with SMTP id d125-20020a6268830000b02902204426449cmr25257365pfc.14.1617081933782; Mon, 29 Mar 2021 22:25:33 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:c112:2822:484f:486]) by smtp.gmail.com with ESMTPSA id u79sm19726006pfc.207.2021.03.29.22.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 22:25:33 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 30 Mar 2021 14:25:21 +0900 Message-Id: <20210330052521.381550-5-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 4/4] 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index e0eaa3b5..344522ba 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1657,6 +1657,18 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) if (!format.isValid()) return -EINVAL; + /* \todo Support rotation. */ + if (stream->rotation != CAMERA3_STREAM_ROTATION_0) { + LOG(HAL, Error) << "Rotation is not supported"; + return -EINVAL; + } +#if defined(CHROMEOS) + if (stream->crop_rotate_scale_degrees != CAMERA3_STREAM_ROTATION_0) { + LOG(HAL, Error) << "Rotation is not supported"; + return -EINVAL; + } +#endif + /* Defer handling of MJPEG streams until all others are known. */ if (stream->format == HAL_PIXEL_FORMAT_BLOB) { if (jpegStream) {