From patchwork Thu Nov 24 12:12:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 17886 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 32FC4BDE6B for ; Thu, 24 Nov 2022 12:12:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C95396331A; Thu, 24 Nov 2022 13:12:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669291947; bh=UohL0RuGjd6bRHTP3N1W2zN400T6UIjDLjNrGlJWAC4=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=4VKC0AtUdmGs/V//WwJGYzXVR85elCnrsjzG5TUyDKVFIQXXk5gZmafFYwPfVsS6Z wAtwbTmEe3ZhDk47hgn0Qci7Rz2PMXQmx/DZ+zwDEh57lCv4FciH8v5sclbeJhZrSf n5JMywHrcHqxS3BzRUZzWGCPrVanCGgf81o/P7pk8K7RAGwHuG5PBSnHAoGPFIFheA hJb0SxTg5yMnEZktgeBltH3EJZMGBNCLc8/zZvtSQBI+1BIkC4JO8wGpfDsSxvgFxW nJzfab34F/wpUD36XV+YbjOjelzzFuYfmpFt8TzHnLyiZGuJqaGEB+3w0Wd5fArEHC 3jRQKlmnj2czg== Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 61079632EA for ; Thu, 24 Nov 2022 13:12:26 +0100 (CET) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 5861440003; Thu, 24 Nov 2022 12:12:25 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 13:12:11 +0100 Message-Id: <20221124121220.47000-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 0/9] libcamera: camera_sensor: Centralize flips handling 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" Hello, this series takes in two patches from David and on top of them plumbs flips handling in the CameraSensor class. The discussion on how to handle flip reset/defaut configuration on David's patches highlighted the need to centrlize their handling as the only two platforms that support rotation do so by applying flips on the sensor, and the code was copied from RPi pipeline handler to IPU3. As the RkISP1 platform needs to support Transform as well, it is desirable to collect all the boilerplate code in a central location in the CameraSensor class. The series start with the two patches from David, on top of which the CameraSensor class is extended to 1) Validate Transform: The same logic as implemented in the IPU3/RPi PH is moved in the CameraSensor class. The requested Transform is adjusted against the sensor's rotation and the sensor's capabilities. In example, if a sensor is 180 degrees rotated (as reported by V4L2_CID_ROTATION) and the Identity transform is requested, the resulting combined Transform is Rot180, to automatically correct the image rotation. 2) Apply flips at CameraSensor::setFormat() time Before applying a format, flips are operated according to the requested Transform. Applying flips before setting a format is crucial to obtain an up to data Bayer pattern order. In order to simplify setting a Transform on the camera sensor, a new "transform" member is added to V4L2SubdeviceFormat. On top, after a few minor patches, Transform support is added to the RkISP1 pipeline handler. Tested on i.MX8MP with a sensor that - does not support flips - support flips - no V4L2_CID_ROTATION - support flips with V4L2_CID_ROTATION Only compile tested on IPU3 and RPi. Thanks j David Plowman (2): libcamera: bayer_format: Add toMbusCode method libcamera: camera_sensor: Do not clear camera flips when listing formats Jacopo Mondi (7): libcamera: bayer_format: Expand documentation libcamera: camera_sensor: Verify flips support libcamera: camera_sensor: Validate Transform libcamera: camera_sensor: Apply flips at setFormat() libcamera: rkisp1: Re-sort includes libcamera: rkisp1: Add support for Transform documentation: sensor_drivers: Document H/V flip Documentation/sensor_driver_requirements.rst | 13 ++ include/libcamera/internal/bayer_format.h | 1 + include/libcamera/internal/camera_sensor.h | 5 + include/libcamera/internal/v4l2_subdevice.h | 2 + src/libcamera/bayer_format.cpp | 31 +++- src/libcamera/camera_sensor.cpp | 149 ++++++++++++++++-- src/libcamera/pipeline/ipu3/cio2.cpp | 6 +- src/libcamera/pipeline/ipu3/cio2.h | 4 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 73 +-------- .../pipeline/raspberrypi/raspberrypi.cpp | 86 ++-------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 19 ++- src/libcamera/v4l2_subdevice.cpp | 10 ++ 12 files changed, 235 insertions(+), 164 deletions(-) --- 2.38.1