From patchwork Sat Apr 3 13:10:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11826 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 E66F7C0DA3 for ; Sat, 3 Apr 2021 13:10:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A22EC6877E; Sat, 3 Apr 2021 15:10:25 +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="ePrKsf3T"; dkim-atps=neutral Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CAC39602CF for ; Sat, 3 Apr 2021 15:10:23 +0200 (CEST) Received: by mail-pl1-x62e.google.com with SMTP id t20so3635720plr.13 for ; Sat, 03 Apr 2021 06:10:23 -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=O9gdRyPR1TApuPAMGULeLbUsGyF31phekVniyKsKgAU=; b=ePrKsf3T7cpjLgJWCqmLkFAqKmHZAf/C0RKf+KO5Cw2w2ItkqvfYOJEtDID2oWL3oL 4Zpfx51qBldXSO0o5GKqXJ8A/SmipO4kGn0b0BIPhOjwgUa8ZpZ1JGZdwcB58biSExuk cHMKqq4G67+1ch3jxYNJf4/o1glqK/uCchhVU= 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=O9gdRyPR1TApuPAMGULeLbUsGyF31phekVniyKsKgAU=; b=eXWnv+UKCeVAnuIH8utiijIk24dp/wnbGILhWkLWuCvFHc0URp7ydMnkp5XL5Z/QBd FnZJyD2yhuSGmTDznr/doIgV67q6aTwnQ3mdOCRZwhjCuMtF1XUXBB7w5NKUcsfvk7hd O9YjLQ2z8Nu3BxemYb/QB/tqe8Mgua8iXlDwcJ2hF8rdZvbxIJDAgUNDIrNqr9ZMlvMr TeTsvlR/G2ArZ35GqGRxe73K1h10JZoZLt2IijOhaqGfEJSkcI8xuCRcD9a2TEcMJMNi CBzoou/E1OoXrX6AdFZdCrRgDoNGcXEe3dtUr07LFXIJ8zx7BSyoRcxjpm4jiofzqhtt 63yA== X-Gm-Message-State: AOAM531Rc+97tTA9XpukNHWjl9zl2LwfrZdRDT9v7586LHpULbqePUa6 AVaLdRN96Vy5Weha8XpWThkyhRUEJIN8Ww== X-Google-Smtp-Source: ABdhPJwUxCFeYbTU9/2ga+8LX1XGjlcNh0c48SUUF72SxifG4vJ4vU79cXAcKwPVTiAdNr61YKGLQg== X-Received: by 2002:a17:90b:100a:: with SMTP id gm10mr18166568pjb.0.1617455422240; Sat, 03 Apr 2021 06:10:22 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:d1f5:1b96:f027:f646]) by smtp.gmail.com with ESMTPSA id h6sm11303271pfb.157.2021.04.03.06.10.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Apr 2021 06:10:21 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Sat, 3 Apr 2021 22:10:13 +0900 Message-Id: <20210403131015.1590399-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog In-Reply-To: <20210403131015.1590399-1-hiroh@chromium.org> References: <20210403131015.1590399-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index eb327978..3f7cce8e 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(OS_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 */ /* @@ -1554,6 +1592,11 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) running_ = false; } +#if defined(OS_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 Sat Apr 3 13:10:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11827 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 4C76FC0DA3 for ; Sat, 3 Apr 2021 13:10:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B9CA68796; Sat, 3 Apr 2021 15:10:28 +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="RcPuCn85"; dkim-atps=neutral Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2A5CA602E6 for ; Sat, 3 Apr 2021 15:10:26 +0200 (CEST) Received: by mail-pg1-x52f.google.com with SMTP id d10so351864pgf.12 for ; Sat, 03 Apr 2021 06:10:26 -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=LU/wNcYg4zQL4s3IItBj4TUxdrY1GMeo1gXZ+FUj6lY=; b=RcPuCn85wYth2s7Syu5BHSLBJTpmJ6RtIIVZNud09lqDISklJg0fB8IHxOuSjnR/Fc 4aniNadtBqe9nFmtPoe5ck3C6Wz1DV7OLd1KQWfSyyXrXxk8J40O1C34mLmxrFnSfxpg xr6EbL0xihz1KFFIvqhrwr1E99AG868C4G4hM= 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=LU/wNcYg4zQL4s3IItBj4TUxdrY1GMeo1gXZ+FUj6lY=; b=lWt/iPBbIIwVs0ggOClB2lPuEK2K1PJd8OCowjL8K21xCeXVtJxyR62MNxLwm3stba PTeqNXrVYiH/vzDMxDrxzOEAzziMgrOY+sku9TU6k1cNZyjBHg1emk//br/sHxU95E92 Y0Ow1BjtOtCJW2Wdhk4e5T5IIgcXfPLrW3WzlwyBzLwx88G9vPt2XpZjV3hQKT0R51hD dgktVjr21nr4Ak7jgvw9xIj8+tNPFAxACwuFnA2eSjmOArVdW2z8T6HfoWXJ7I5nwl0O DSv1fHZxOMZ/bWjmA1UEaEpSL7ShvGGYZGp/EQ5ldBreIrX2KzLY2R12yVFpFK7xNajJ rOCw== X-Gm-Message-State: AOAM5321Bj4H21nZtwP2rkIJZd7I/CmqmU0jcH0GDB9Hs7adTEeZ/3XC QNen2M9+5SMjqkFlODVLuPZwFOtUoZ3lAA== X-Google-Smtp-Source: ABdhPJwvXNBGgZ1LNDnWN5y4Wz6L44yYXzVC3OMwOBOqrzNJl1k4oPrsTXeQ+7rUEupQbHNpiLEpCA== X-Received: by 2002:aa7:9f08:0:b029:20c:9997:aeea with SMTP id g8-20020aa79f080000b029020c9997aeeamr16241277pfr.18.1617455424015; Sat, 03 Apr 2021 06:10:24 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:d1f5:1b96:f027:f646]) by smtp.gmail.com with ESMTPSA id h6sm11303271pfb.157.2021.04.03.06.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Apr 2021 06:10:23 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Sat, 3 Apr 2021 22:10:14 +0900 Message-Id: <20210403131015.1590399-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog In-Reply-To: <20210403131015.1590399-1-hiroh@chromium.org> References: <20210403131015.1590399-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 3f7cce8e..ddac56da 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(OS_CHROMEOS) /* * Check whether the crop_rotate_scale_degrees values for all streams in @@ -1631,6 +1646,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(OS_CHROMEOS) + << ", crop_rotate_scale_degrees: " + << rotationToString(stream->crop_rotate_scale_degrees) +#endif << " (" << format.toString() << ")"; if (!format.isValid()) From patchwork Sat Apr 3 13:10:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11828 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 0AA88C0DA3 for ; Sat, 3 Apr 2021 13:10:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B28F268798; Sat, 3 Apr 2021 15:10:28 +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="FzOruzt3"; dkim-atps=neutral Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 59B7168791 for ; Sat, 3 Apr 2021 15:10:27 +0200 (CEST) Received: by mail-pl1-x636.google.com with SMTP id t5so1698701plg.9 for ; Sat, 03 Apr 2021 06:10:27 -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=mNIc070cnoO6de/trc4kKmm+W/FgPNJRZXCbAsx3nNY=; b=FzOruzt3IJzWrPxDbawKMbqjoYD7W4jfc+0EaVqwNO3OFTMNpX8U3qP5vfsWfhxV88 h5ykwqPkT/q20nzj+3b2sW/PfZiMM+/pbA/f+QHkrkgBZgRSGiZCrLpHzZyGzmWHrWwZ WiTE46GSkgPN3WsHpWRTDvHtDoxa/+LuvyGEU= 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=mNIc070cnoO6de/trc4kKmm+W/FgPNJRZXCbAsx3nNY=; b=gR/qCrLzErKXikASQ3B7ldifbYjb2laSI2fnXFlrmBu86Z3p/OZpLYe0+V3AijMeN4 K+68hPhYjQD6ouq06sxXMa1amsCx3vtoclS22AFHAbyj9G2C8IVlbXqtfnjNKpDejgTR qO0CXqQZYgYrxUMc9BfeaKkqUL+FtglrkrBe2QLnpZmEve6cJzUJeLhTeLmRPrZQtWVR ckNs11NDazRLzth29UUiDCvQyHt7x1ous2diLF0waHdrGXkYDAc9qqKebipsksMUZw9I UbNyXpYjWzzZNImDyt9D/dYy4loDOQiWTf2w7s53jlzp9ndXdus6YZE7caLyi62nRvOh F5/w== X-Gm-Message-State: AOAM530R6mWYPhApGJuDPVMHaHM1K/q08EdhcxZ2aDOnkD035JcYZhXE GeAZ5h7VZTWuVmRaTJDpTSHUJ3cxCSfNvA== X-Google-Smtp-Source: ABdhPJwd0x6mqoSZuqsnXiNkDRQCNIgVlTJ51SM5Q9mJMKn4D56wpWaaFpLBy9Jfkjh8w0AjF/coJw== X-Received: by 2002:a17:903:22d1:b029:e7:1052:a979 with SMTP id y17-20020a17090322d1b02900e71052a979mr16729357plg.16.1617455425772; Sat, 03 Apr 2021 06:10:25 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:d1f5:1b96:f027:f646]) by smtp.gmail.com with ESMTPSA id h6sm11303271pfb.157.2021.04.03.06.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Apr 2021 06:10:25 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Sat, 3 Apr 2021 22:10:15 +0900 Message-Id: <20210403131015.1590399-4-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog In-Reply-To: <20210403131015.1590399-1-hiroh@chromium.org> References: <20210403131015.1590399-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 ddac56da..2c8f76e7 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1656,6 +1656,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(OS_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) {