From patchwork Thu Nov 24 12:12:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 17890 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 5FB2BBDE6B for ; Thu, 24 Nov 2022 12:12:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0388463313; Thu, 24 Nov 2022 13:12:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669291954; bh=r+f33DwLy79JD2IOnj7rEgDwXTCozTBwrDQB5q1rtjU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=iKOnmtrMTzz0CKb8dI8vm8NSYatWKA4frzPHsxqzhOu+CZ3gn3v7pM/fXEEnUd0TY sdYdK04FaW/Xx02aJApPrGgq+xGTRFFmGR2ci/Vhu0tASE4bJTj0PH4mVCE7pMUqw9 BH/c+O+/fCTstRpEqcxgtX43IZqIB/HTb95b33BWELX6WPZkr3ZAbRrPdbehOMMOL+ YUvBZuimJQvig7moo7oOMNAQKAargqo3vr3Olu2r/tWUcMz8jWW/s9d4go5pttJEq2 d4szTC18T9+a2m+W1qWCThh/t/FNqoQ19Kn9smZGa1mqOfBKptJ9iGKvOmHLriwDMk gUm20YVWEwWsQ== Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BB58863319 for ; Thu, 24 Nov 2022 13:12:30 +0100 (CET) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id C3C2940002; Thu, 24 Nov 2022 12:12:29 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 13:12:15 +0100 Message-Id: <20221124121220.47000-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221124121220.47000-1-jacopo@jmondi.org> References: <20221124121220.47000-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/9] libcamera: camera_sensor: Verify flips support 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" During the camera sensor driver validation, verify if the sensor supports horizontal and vertical flips and store a flag as CameraSensor::supportFlips_ class member. The flag will be later inspected when applying flips. Signed-off-by: Jacopo Mondi Reviewed-by: David Plowman --- include/libcamera/internal/camera_sensor.h | 1 + src/libcamera/camera_sensor.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index b9f4d7867854..878f3c28a3c9 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -101,6 +101,7 @@ private: Size pixelArraySize_; Rectangle activeArea_; const BayerFormat *bayerFormat_; + bool supportFlips_; ControlList properties_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index cbac9e7801ae..3afcbc482095 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -57,7 +57,8 @@ LOG_DEFINE_CATEGORY(CameraSensor) */ CameraSensor::CameraSensor(const MediaEntity *entity) : entity_(entity), pad_(UINT_MAX), staticProps_(nullptr), - bayerFormat_(nullptr), properties_(properties::properties) + bayerFormat_(nullptr), supportFlips_(false), + properties_(properties::properties) { } @@ -271,6 +272,18 @@ int CameraSensor::validateSensorDriver() } } + /* Verify if sensor supports horizontal/vertical flips. */ + const struct v4l2_query_ext_ctrl *hflipInfo = subdev_->controlInfo(V4L2_CID_HFLIP); + const struct v4l2_query_ext_ctrl *vflipInfo = subdev_->controlInfo(V4L2_CID_VFLIP); + if (hflipInfo && vflipInfo && + !(hflipInfo->flags & V4L2_CTRL_FLAG_READ_ONLY) && + !(vflipInfo->flags & V4L2_CTRL_FLAG_READ_ONLY)) + supportFlips_ = true; + + if (!supportFlips_) + LOG(CameraSensor, Warning) + << "Camera sensor does not support horizontal/vertical flip"; + /* * Make sure the required selection targets are supported. *