From patchwork Mon Aug 1 00:05:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16883 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 82997C3276 for ; Mon, 1 Aug 2022 00:05:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 33E1C63326; Mon, 1 Aug 2022 02:05:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659312359; bh=8nqh/5MSopczm2EoKmlXdolNruINeHQ6JnZdDcm1F2c=; 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=uMUJcsqyiuwfiK1yVGqQ4/HmmFOxT3rvICoivST+OvWp0hGor0AmOtHJC+vnMD/61 YNaAPhdI9CMG69U9bTkD5teq+2yQfD5fMssZh3JL0buOUSwdgt/OnJko9CdsVmxH5r IpnFxlajPrqqie36fWglcOf8DNuiKFJJC6myo/vqj5Gavo1uQAYAxjH8HbOfZNBTBV RI+/tP1I5Qd0za/c9dfVGGaHNfm8QmUIHfjdnpCFNWrrR6HInF244Z6YyEsjCnY9dV ruhfvDGCpG5g/D4AjkgxVHL7N099IWq+WfXkROAGWV36zhTD9VVvigBhMCVy9jKNoB u4mSpWY+EEODg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CAE3863312 for ; Mon, 1 Aug 2022 02:05:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cYfNQZuf"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5630230B; Mon, 1 Aug 2022 02:05:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659312357; bh=8nqh/5MSopczm2EoKmlXdolNruINeHQ6JnZdDcm1F2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cYfNQZufdgM1zJnITtVNXfaRoug/R2HFb18Css2HuDXHQMNWYlv/Kd7slINMNzciZ 8N1CwNlALu5chNvmPnyIUuXVKaWkbDLQFqr9pjJUeZhvFxrCKu/3wni6if/tYdH7kr kbl7w0qzdSzvr4M32lFpkJelt3Ogb12427RyC7RI= To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Aug 2022 03:05:36 +0300 Message-Id: <20220801000543.3501-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220801000543.3501-1-laurent.pinchart@ideasonboard.com> References: <20220801000543.3501-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 06/13] libcamera: v4l2_subdevice: Change V4L2Subdevice::Whence 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Jacopo Mondi The V4L2Subdevice::Whence enumerations defines two values that should correspond to the V4L2_SUBDEV_FORMAT_ACTIVE and V4L2_SUBDEV_FORMAT_TRY definitions. The V4L2 symbols are defined as: V4L2_SUBDEV_FORMAT_TRY = 0, V4L2_SUBDEV_FORMAT_ACTIVE = 1, While the libcamera defined enumeration is: enum Whence { ActiveFormat, TryFormat, } As V4L2Subdevice::Whence values are used to populate data types defined in v4l2-subdev.h used as arguments to VIDIOC_SUBDEV_* ioctls, the V4L2Subdevice class is required to adjust their value as: subdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE : V4L2_SUBDEV_FORMAT_TRY; Drop the adjustment by defining : Whence::TryFormat = V4L2_SUBDEV_FORMAT_TRY; Whence::ActiveFormat = V4L2_SUBDEV_FORMAT_ACTIVE; Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/internal/v4l2_subdevice.h | 6 ++++-- src/libcamera/v4l2_subdevice.cpp | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index 6fda52ada41b..2db392d5e37a 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -13,6 +13,8 @@ #include #include +#include + #include #include @@ -44,8 +46,8 @@ public: using Formats = std::map>; enum Whence { - ActiveFormat, - TryFormat, + TryFormat = V4L2_SUBDEV_FORMAT_TRY, + ActiveFormat = V4L2_SUBDEV_FORMAT_ACTIVE, }; explicit V4L2Subdevice(const MediaEntity *entity); diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 98a3911aa7df..37960b76a044 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -416,8 +416,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence) { struct v4l2_subdev_format subdevFmt = {}; - subdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE - : V4L2_SUBDEV_FORMAT_TRY; + subdevFmt.which = whence; subdevFmt.pad = pad; int ret = ioctl(VIDIOC_SUBDEV_G_FMT, &subdevFmt); @@ -452,8 +451,7 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence) { struct v4l2_subdev_format subdevFmt = {}; - subdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE - : V4L2_SUBDEV_FORMAT_TRY; + subdevFmt.which = whence; subdevFmt.pad = pad; subdevFmt.format.width = format->size.width; subdevFmt.format.height = format->size.height;