From patchwork Mon Jun 28 16:36:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12731 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 83349C321F for ; Mon, 28 Jun 2021 16:36:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EEEEF60508; Mon, 28 Jun 2021 18:36:52 +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="F5MWyS3d"; dkim-atps=neutral Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BBAD6028C for ; Mon, 28 Jun 2021 18:36:51 +0200 (CEST) Received: by mail-pg1-x52e.google.com with SMTP id y17so3634283pgf.12 for ; Mon, 28 Jun 2021 09:36:51 -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:mime-version :content-transfer-encoding; bh=gka1u8kial3MrfS6NwTFMO4cJ/KoSi5j0u/D3BLc7sc=; b=F5MWyS3dm1xPQeOF9sh275r0zYs1bYs5GomqzoTHEeRDB0/sgt4vK1x5U/UBsUIrvS 1xja/nbJmjmfg/I6HFBCH7RRKknof9Lpk1MFpwbHe0XvGSxQUqqaH3RJPe5lvh3ANNrB dD5cqp241meorzI9ggYZasvl8GAgo/Q+IuPv4= 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:mime-version :content-transfer-encoding; bh=gka1u8kial3MrfS6NwTFMO4cJ/KoSi5j0u/D3BLc7sc=; b=UczTr7EkPV0MZSZuJTB91fGaQl49LBlJaX77wNV+By9LHZI1wE9eTU3D2ND/C4KNu7 NZ3TZs1YXiHIrL1REk9l4gGTisAVmvholm+Ua+liJbBi99mXYSaO+2CUNSghRzekjfqy pWjk5zJPIGCBKxh5GHzqtX9OlMINL6P9QgTMcARP1UVS9ORmGOQPURD2bjQKLv9fTsgE zqFGtT34EPw3QGNNd3oROuu18j+HarESzqWV9ACUZq0xre8qIAz/KDaiI/wUgmF3k7/m bJwl/miKDlbQUqye1GCpUhAc03Hw2asQ3x7arnYLq2mwQVKCrIOgFTLpXLQAFcJXylT+ 2n8Q== X-Gm-Message-State: AOAM530gCr684bZiJkZJa4aA0hyr9pcVaKeR8TJ4UzelVCaZ/X7z2TBa cM3IzHbHFP3+C9JIDB1LEihGn0j7du8geg== X-Google-Smtp-Source: ABdhPJw8kueB8qBs8hLfSnzKjNPhzlcM8h7hY5WXM/4mBpwijaurodzoe6ZDFtcyPrpZBb3rsJY0OA== X-Received: by 2002:a63:d301:: with SMTP id b1mr24455113pgg.423.1624898209420; Mon, 28 Jun 2021 09:36:49 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:a147:1cb:e226:4ed9]) by smtp.gmail.com with ESMTPSA id r92sm22302pja.6.2021.06.28.09.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 09:36:48 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Jun 2021 01:36:44 +0900 Message-Id: <20210628163644.3195189-1-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] android: camera_device: Propagate the requested test pattern mode 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" Propagate the requested test pattern mode to libcamera::Camera through libcamera::Request and also set the android metadata to the test pattern mode contained by the complete Request. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 47 ++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 678cde23..bce3fe48 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -768,16 +768,54 @@ int CameraDevice::processControls(Camera3RequestDescriptor *descriptor) return 0; /* Translate the Android request settings to libcamera controls. */ + ControlList &controls = descriptor->request_->controls(); camera_metadata_ro_entry_t entry; if (settings.getEntry(ANDROID_SCALER_CROP_REGION, &entry)) { const int32_t *data = entry.data.i32; Rectangle cropRegion{ data[0], data[1], static_cast(data[2]), static_cast(data[3]) }; - ControlList &controls = descriptor->request_->controls(); controls.set(controls::ScalerCrop, cropRegion); } + if (settings.getEntry(ANDROID_SENSOR_TEST_PATTERN_MODE, &entry)) { + const int32_t data = *entry.data.i32; + int32_t testPatternMode = controls::draft::TestPatternModeOff; + switch (data) { + case ANDROID_SENSOR_TEST_PATTERN_MODE_OFF: + testPatternMode = controls::draft::TestPatternModeOff; + break; + + case ANDROID_SENSOR_TEST_PATTERN_MODE_SOLID_COLOR: + testPatternMode = controls::draft::TestPatternModeSolidColor; + break; + + case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS: + testPatternMode = controls::draft::TestPatternModeColorBars; + break; + + case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY: + testPatternMode = controls::draft::TestPatternModeColorBarsFadeToGray; + break; + + case ANDROID_SENSOR_TEST_PATTERN_MODE_PN9: + testPatternMode = controls::draft::TestPatternModePn9; + break; + + case ANDROID_SENSOR_TEST_PATTERN_MODE_CUSTOM1: + testPatternMode = controls::draft::TestPatternModeCustom1; + break; + + default: + LOG(HAL, Error) + << "Unknown test pattern mode: " << data; + + return -EINVAL; + } + + controls.set(controls::draft::TestPatternMode, testPatternMode); + } + return 0; } @@ -1329,6 +1367,13 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons resultMetadata->addEntry(ANDROID_SCALER_CROP_REGION, cropRect); } + if (metadata.contains(controls::draft::TestPatternMode)) { + const int32_t testPatternMode = + metadata.get(controls::draft::TestPatternMode); + resultMetadata->addEntry(ANDROID_SENSOR_TEST_PATTERN_MODE, + testPatternMode); + } + /* * Return the result metadata pack even is not valid: get() will return * nullptr.