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.