From patchwork Thu Mar 25 05:19:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11703 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 7BA8AC32E9 for ; Thu, 25 Mar 2021 05:19:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9358968D5E; Thu, 25 Mar 2021 06:19:44 +0100 (CET) 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="BtD4JuMg"; dkim-atps=neutral Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6ACE5602D7 for ; Thu, 25 Mar 2021 06:19:43 +0100 (CET) Received: by mail-pg1-x536.google.com with SMTP id f10so632594pgl.9 for ; Wed, 24 Mar 2021 22:19:43 -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=JA45d1nxGZzoAYuR5Vt+C+TDUKQUzaepsHQRv/+izzg=; b=BtD4JuMgtsQs4PxjDhvViefJQykULHpbkwkhIXOVmjMYR7d+m4sb6JS6Xgqu6H4BXJ 2s3mqsSZUIR8rpaEvf9rWjCE8Fq6PdSU3AlqaY4AEcEU8OafXSQ0Pr3osa/EB6vsguC8 OCLFhW838vPbXWrLKYDHQO2qDiWBjO4nHnsbs= 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=JA45d1nxGZzoAYuR5Vt+C+TDUKQUzaepsHQRv/+izzg=; b=p5Rquw6MOOKqUrFRc8SnD9oE8iwh1Pj+iH+9yAK8/lnXvju65bGR4ZTLqAUWTfxgIG 4wbyGjc0ynnlRIaZ6gUw1mvx1KWCNocuzSTcme/E8xG78wd4LwzDFM6eXJE01sxXKSL4 yrYLQGTe8LES9ywHNwgTYMFkBb5qnhGFTsAHBviJP3RNOlKsJdFcMz0A4cBCf8Ux3PS4 NQWHY+trFAWGzD+RKYFAsKfYxgtH4gFk/wX6AKSxDQG+WurURfCBxcz1BDqotIK1q8No QJHarDB6rmNmiLfHRHOjRZ/u6fG+dQD8nxxV650PqbmgeD4ahN2fkstIFADeKaFXA/U/ 1L+w== X-Gm-Message-State: AOAM533bh3qevda0cZIhmotM3P8uowkrgWiK1zTlFM4aUtg7ipc2M/f9 GhQTVmBRIxy99snxtnKlftaKl7ZJWChu3w== X-Google-Smtp-Source: ABdhPJz7iSjwGheOrL/IuxrDEUqLs7DExuL6rrEGnD8myKqbCvX76ToO6B2H+YVvDi/CqFbiJ1wWew== X-Received: by 2002:a17:902:e54c:b029:e6:42ee:18ae with SMTP id n12-20020a170902e54cb02900e642ee18aemr7401856plf.68.1616649581653; Wed, 24 Mar 2021 22:19:41 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7c07:24cd:c637:7fab]) by smtp.gmail.com with ESMTPSA id fs9sm3999250pjb.40.2021.03.24.22.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 22:19:41 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Mar 2021 14:19:29 +0900 Message-Id: <20210325051931.3748204-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210325051931.3748204-1-hiroh@chromium.org> References: <20210325051931.3748204-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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 | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.31.0.291.g576ba9dcdaf-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 72a89258..1414bfef 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -256,6 +256,38 @@ void sortCamera3StreamConfigs(std::vector &unsortedConfigs, unsortedConfigs = sortedConfigs; } +/* + * verifyCropRotateScaleDegrees returns where |crop_rotate_scale_degrees| in + * all camera3_stream in stream_list are valid. + */ +bool verifyCropRotateScaleDegrees(const camera3_stream_configuration_t &stream_list) +{ + if (stream_list.num_streams == 0) + return true; + const int crop_rotate_scale_degrees = + 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 (crop_rotate_scale_degrees != stream.crop_rotate_scale_degrees) { + LOG(HAL, Error) << "crop_rotate_scale_degrees in all " + << "streams are not identical"; + return false; + } + } + return true; +} + } /* namespace */ /* @@ -1566,6 +1598,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) running_ = false; } + if (!verifyCropRotateScaleDegrees(*stream_list)) + return -EINVAL; + /* * Generate an empty configuration, and construct a StreamConfiguration * for each camera3_stream to add to it. From patchwork Thu Mar 25 05:19:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11704 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 2EBEDC32E9 for ; Thu, 25 Mar 2021 05:19:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E1ABA68D6C; Thu, 25 Mar 2021 06:19:46 +0100 (CET) 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="R//9ZwEF"; dkim-atps=neutral Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8DCF1602D7 for ; Thu, 25 Mar 2021 06:19:44 +0100 (CET) Received: by mail-pj1-x1034.google.com with SMTP id il9-20020a17090b1649b0290114bcb0d6c2so2247319pjb.0 for ; Wed, 24 Mar 2021 22:19:44 -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=PZPYhm58v8yg1n+/LPY7yqvGtfUspXKfM7MF2dvZ+yk=; b=R//9ZwEFacpRU+rzkMKmGzfu3nLag7hsqnA60s651fI7jZ2RdmWDQrSirg3jSp1oIv mSiP9pqDqrl1HdcLLcBhBOwzAPeSVHcqW/UlTxnv6ub5JTkAkGewOZXzokjqxUB6mQeY 4qSI2NVaCfQ+nd9EVtoZ7nbq4jacNFArC5+T8= 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=PZPYhm58v8yg1n+/LPY7yqvGtfUspXKfM7MF2dvZ+yk=; b=QwQ4rpia80g5dgyJ+Shf/P3uSYcvmey+FjXYe4lyZuuY2ENJsfgTRt39UyP6Tlm2XX NQrtPzGHxIXqRqA0gbsnBnJufD0zQsDfNsQuHhop9MGa2K+7E/+6A/RaIxM1rdF6jypd ZJqpAtAgnVzDL8sz9IeTEDV19rdqstvb8TRVgr+zXZGznDeeYkpwriRYBZ7ejSx+Fvnr rRB2mB0CW+L36iWRBXTlt2qhGHd4VCMHekGWVpdsvasDZZl8IiNj0WBhvyIQL15D0x8V 8wgcLk9fVSp/1VzwYIl/EGqbfmJSgHBEQR60tayEdOCT+0UIpQhDcBoLQrsmCG89kxWJ saqA== X-Gm-Message-State: AOAM532LZZWFH6P8J0Z4dj+FgG8pmtLGfr1JsJND8MWx1Q59KejxI2vD Z9IodNIw+uH4cuzqPaHjym0pKQF+dNOuow== X-Google-Smtp-Source: ABdhPJxhlLUn+Lhn8U1zCPA/tvd9E5ghVDK8MOSIKtDQjJVYocLCSLGpVzu+WDEZeA83dVZS1FxwZA== X-Received: by 2002:a17:90b:38f:: with SMTP id ga15mr6993422pjb.149.1616649583035; Wed, 24 Mar 2021 22:19:43 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7c07:24cd:c637:7fab]) by smtp.gmail.com with ESMTPSA id fs9sm3999250pjb.40.2021.03.24.22.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 22:19:42 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Mar 2021 14:19:30 +0900 Message-Id: <20210325051931.3748204-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210325051931.3748204-1-hiroh@chromium.org> References: <20210325051931.3748204-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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 --- 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 1414bfef..d24b0b23 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"; +} /* * verifyCropRotateScaleDegrees returns where |crop_rotate_scale_degrees| in * all camera3_stream in stream_list are valid. @@ -1635,6 +1649,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 Thu Mar 25 05:19:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11705 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 BC930C32E9 for ; Thu, 25 Mar 2021 05:19:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5A1A068D68; Thu, 25 Mar 2021 06:19:47 +0100 (CET) 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="LCJpynPX"; dkim-atps=neutral Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E16B268D68 for ; Thu, 25 Mar 2021 06:19:45 +0100 (CET) Received: by mail-pf1-x431.google.com with SMTP id h3so808613pfr.12 for ; Wed, 24 Mar 2021 22:19:45 -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=PjpQr3Vz3Da91peYZt+5pvwi3qlCZ3U2n1oIkOsHbBI=; b=LCJpynPX2ka49HcUuHNewW5sjGEvTq5WPZJPJrnIpKQIs2dlDtq+DVdNVO3UoNOhWy xeISIQJ3WKg8o2oWt8gMD9nRd2eV/waeXmpSPdCSJGHrM5mFxZSIpweTyGQ4QPiaU6O+ K4qqnjQgX4MQy8o/a7mG23UbUM8WwuvhFjeTc= 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=PjpQr3Vz3Da91peYZt+5pvwi3qlCZ3U2n1oIkOsHbBI=; b=LVkwB3xNNJdO78KS8fTh3NrrfS7rV11RhmkjUaNwTvHXHqijjPqLLQ322BbiLTPIKW L3E0rU3KutOnbX3T0ddlEkskpNaywba0VGw6Kz+SrnfkErKgPXpjwNlLpb3r9Ta9ux9e eKSp6jkbztJRLgV3SCVoG1nzVgYKz8P2PfCCW5OyrhyR9Bxft27SDzLfid0tJ/CAwILb aGLQMUICX3ldTDwj4h3McuiJ2dE441edBGjOYKBjVniq20UvxLbdtOGB5DN/15xWUsae p1SKgay6gdsPYkwLOE5DOoP7nlLXyNlBOTF5lNrXdcQzUJSS036bPJtWu/D0h+T8vkej 5kcA== X-Gm-Message-State: AOAM531zjGlz+Ts5FN740VRmWrZH7KXaxN0TpzEmMTEg+2omtYKeq9wP vgrtCKKZ/ygv2+ZoZjrDWf7hLjp/m5jqWQ== X-Google-Smtp-Source: ABdhPJwlTh/lFHZTyKrXcQCfz/rPvfI5ZfoGhHp2ZLh0CfhitiOXkAC3N3Q/v2iCTgrQ6NO8O0ainA== X-Received: by 2002:a05:6a00:14cc:b029:200:5f06:2ded with SMTP id w12-20020a056a0014ccb02902005f062dedmr6337028pfu.65.1616649584406; Wed, 24 Mar 2021 22:19:44 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7c07:24cd:c637:7fab]) by smtp.gmail.com with ESMTPSA id fs9sm3999250pjb.40.2021.03.24.22.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 22:19:44 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Mar 2021 14:19:31 +0900 Message-Id: <20210325051931.3748204-4-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210325051931.3748204-1-hiroh@chromium.org> References: <20210325051931.3748204-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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 --- 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 d24b0b23..3aab643d 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1657,6 +1657,13 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) if (!format.isValid()) return -EINVAL; + /* \todo Support crop_rotate_scale_degrees. */ + if (stream->crop_rotate_scale_degrees != CAMERA3_STREAM_ROTATION_0) { + LOG(HAL, Error) + << "crop_rotate_scale_degrees is not supported"; + return -EINVAL; + } + /* Defer handling of MJPEG streams until all others are known. */ if (stream->format == HAL_PIXEL_FORMAT_BLOB) { if (jpegStream) {