From patchwork Sun Mar 28 22:45:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11747 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 5B2DBC32EA for ; Sun, 28 Mar 2021 22:45:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19DC068788; Mon, 29 Mar 2021 00:45:39 +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="QpaszsmQ"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C7776877C for ; Mon, 29 Mar 2021 00:45:37 +0200 (CEST) Received: by mail-pj1-x102f.google.com with SMTP id f2-20020a17090a4a82b02900c67bf8dc69so6808554pjh.1 for ; Sun, 28 Mar 2021 15:45:37 -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=zk4sjHPGuv7zXqT8sfjgx4K+iKxGU2Nrb0XJoo3SUQ8=; b=QpaszsmQntqgX0/oW8ppqsfnW8qkUkYzC2xz7uQqZKXL9GCmeqUxHYF3E5Xe67fMLS TN/1pU9WgRum0PQCz6KKKTajZ+khXyqxgcNHiFOgUGqrNB11GdeST3+8O7aEIcWCoJqj g5tdyYyfMb7HHKwVCq8tIUrGA+kXs3tHxT338= 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=zk4sjHPGuv7zXqT8sfjgx4K+iKxGU2Nrb0XJoo3SUQ8=; b=hTdIno1SbFMrl6X0b/gpiYZ04ogN3H4kcR0s12xWIV8nZA9N2ZpJnGKkJTa/suDI/m Hqg7IVd5M0X3zXWDh5WLAMqOUgIWS1GejRvF7bJqXmL4k2B8LShSV6baEEvzroCo7udh nKrKM7NrWzW/4+mw5NdKvyZ4UsoCFAwSoBjapEmgzDz9WkL86/6RDfzwpHaqSwuysr17 23DF+OEUIjm8D5lUdtFJMSVzK6J22QmuDFhNo5vLrPmkYoRQndK1yUj/b2eq+/OUY1sv bTQ5ysdV0otBzwVcg88eyde83ECWkKkCC9ztZGObyz9MOOGZ1QNuHJ0im/06+ziRHpbX 5R/Q== X-Gm-Message-State: AOAM532ubP+cmArSGSDLLzu6QHyCxtVCSvDAUJnpM+xATbZHcml1LVkh JnlEGX7HVoRa96ornwGSZKLm02gah/yblQ== X-Google-Smtp-Source: ABdhPJyakDNRg1ggJxTUl2N8uJ7GBk8LHpb8B9qEwjp0P7tJeX/L+tq3BivPgYbpR5Y7hUWxGQx2RA== X-Received: by 2002:a17:90a:7a8b:: with SMTP id q11mr24043699pjf.215.1616971535869; Sun, 28 Mar 2021 15:45:35 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:1db7:ae60:9288:b906]) by smtp.gmail.com with ESMTPSA id q25sm14814244pff.104.2021.03.28.15.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 15:45:35 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Mar 2021 07:45:26 +0900 Message-Id: <20210328224528.55468-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210328224528.55468-1-hiroh@chromium.org> References: <20210328224528.55468-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) -- 2.31.0.291.g576ba9dcdaf-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ae693664..c5e55a18 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -256,6 +256,39 @@ void sortCamera3StreamConfigs(std::vector &unsortedConfigs, unsortedConfigs = sortedConfigs; } +/* + * Returns where crop_rotate_scale_degrees in all camera3_stream in stream_list + * are valid. + */ +bool validateCropRotate(const camera3_stream_configuration_t &stream_list) +{ + ASSERT(stream_list.num_streams > 0); + + const int cropRotateScaleDegrees = + 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 (cropRotateScaleDegrees != stream.crop_rotate_scale_degrees) { + LOG(HAL, Error) << "crop_rotate_scale_degrees in all " + << "streams are not identical"; + return false; + } + } + + return true; +} + } /* namespace */ /* @@ -1552,6 +1585,12 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) running_ = false; } + if (stream_list->num_streams == 0) + return -EINVAL; + + if (!validateCropRotate(*stream_list)) + return -EINVAL; + /* * Generate an empty configuration, and construct a StreamConfiguration * for each camera3_stream to add to it.