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.