From patchwork Wed Sep 2 10:44:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9443 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 A06A7BF019 for ; Wed, 2 Sep 2020 10:44:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6DD41629A3; Wed, 2 Sep 2020 12:44:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="g/hScoOE"; dkim-atps=neutral Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 819D4628EE for ; Wed, 2 Sep 2020 12:44:16 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id c18so4688501wrm.9 for ; Wed, 02 Sep 2020 03:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q668yEp4JKcNCeXSdxOZyYE0+wNdHoGwDTyfQND9EYQ=; b=g/hScoOERsjG6M4fvd64dc0jd2RxmX4LYoYRG5L3sbwU7K+8A4fmA/VoBo3QB4T8Fn jBHEcEpykBsxuF6WJtn+6NpcAnqv/tTxuyp321hEDckTvrm+7HndXOT5A+23370hzciA SyjAX39I94i6xEk44XwfIjqznTh5QmTta2l31bm1K92s6YPD7LMpjJIli/LF5aJCP6mG m0MbdRixJnEwjqb7zYUnyavUEYOtzOKoIJttUhX3GA0v4kXaT4wvmEyK4PE+qIUBBJXC DLYu7XDAs/4d6etwzopUHZODn+IwHzBR1tikeAsb7c/oYwMiSX3Xr7AVcaYgwIHU7XoN 9THg== 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=Q668yEp4JKcNCeXSdxOZyYE0+wNdHoGwDTyfQND9EYQ=; b=GPZOXOTpT4XQWCRvcuQ0zaVH0HsyMkz/f/tVDRk+oGVhj1fnCOnewxgIIF4nGPpsOZ 9YALDjc83Bqk4v+k0q3P/fmqID9gE/GULhwp16HFtizq/kItHq5kM/sZq9iT3N8TtZUG 1c8P5SyCYotVdPl35dTNXXTfj4NBU/j668gKq+S/kpBfqIOGj5FUIuSECB1XAP8Sdw85 ++h3D1l7CNP9TjMeTC+uuEQ4yTcDUUI/cdZH+AEm1yRTIoiU+5Z7Jhd6BFFtrLO4wmCK SZwc3NhMCiI3lruLpsSWvnzSND0g5Kqe30zFo2wbEDDon9zp8NoQD7ptLmtZs0mSO8J+ bXxg== X-Gm-Message-State: AOAM532ryE6qOegkMTsyhYLS9ER13+gVhmYvVFIDB5WwO5j0Kbrh3UbL 7VRwtVLFWaF6y2lFZS/aCrRfzUHfQ4AHQw== X-Google-Smtp-Source: ABdhPJyqyw6VKuF83W4WlfrKnGWdsnOweSWh/EU23ufqlu9KykmuisqK9ThsnJ6JT2Tb0lNp8A/pkA== X-Received: by 2002:a05:6000:11c5:: with SMTP id i5mr6720722wrx.18.1599043455726; Wed, 02 Sep 2020 03:44:15 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id m3sm5583062wmb.26.2020.09.02.03.44.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2020 03:44:15 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Wed, 2 Sep 2020 11:44:02 +0100 Message-Id: <20200902104410.7569-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 0/8] 2D transforms 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" Hi everyone Another version of 2D transforms! There's actually been a bit more churn than I wanted because I liked the suggestion that was made of storing the "native" Bayer order (with no transforms) at startup, and then applying transforms to that. Unfortunately I found the various pixel formats rather difficult to work with (as the Bayer information is opaque in the encoding) so I decided to add a BayerFormat class to make everything explicit. So there's a bit of a hit converting to the BayerFormat and back out again, but once you're there it's easy to transform them without having to worry about the bit depth or packing. With this change, the original method of transforming Bayer V4L2PixelFormats is redundant, so I've dropped it. Anyway, see what you think. This leaves the following commits: 1. Revert the same commit as before. Unchanged. 2. Rename the queryCtrl() method to controlInfo(). I've made it a const function too, but otherwise this commit unchanged. 3. Add Transform enum. Unchanged apart from adding operator~. 4. This commit replaces the previous V4L2PixelFormat one and adds a BayerFormat type instead. 5. Add user Transform to CameraConfiguration. Unchanged. 6. Set flips correctly in RPi pipeline handler. Apart from the new class in commit #4, the other significant changes are here. I guess I have a bit of a question about how you find the "native" Bayer order - is there any circumstance where a sensor might return different Bayer orders in different modes (even when the transform doesn't change)? 7 and 8. Unchanged. Thanks and best regards David David Plowman (8): libcamera: pipeline: raspberrypi: Revert "Set sensor default orientation before configure()" libcamera: Allow access to v4l2_query_ext_ctrl structure for a V4L2 control libcamera: Add Transform enum to represent 2D plane transforms. libcamera: Add BayerFormat type libcamera: Add user Transform to CameraConfiguration libcamera: raspberrypi: Set camera flips correctly from user transform libcamera: raspberrypi: Plumb user transform through to IPA libcamera: ipa: raspberrypi: ALSC: Handle user transform include/libcamera/camera.h | 3 + include/libcamera/internal/bayer_format.h | 63 ++++ include/libcamera/internal/v4l2_device.h | 2 + include/libcamera/meson.build | 1 + include/libcamera/transform.h | 78 +++++ src/ipa/raspberrypi/controller/camera_mode.h | 4 + src/ipa/raspberrypi/controller/rpi/alsc.cpp | 13 +- src/ipa/raspberrypi/raspberrypi.cpp | 48 +-- src/libcamera/bayer_format.cpp | 223 ++++++++++++ src/libcamera/camera.cpp | 16 +- src/libcamera/meson.build | 2 + src/libcamera/pipeline/ipu3/ipu3.cpp | 5 + .../pipeline/raspberrypi/raspberrypi.cpp | 152 ++++++++- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 5 + src/libcamera/pipeline/simple/simple.cpp | 5 + src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 5 + src/libcamera/pipeline/vimc/vimc.cpp | 5 + src/libcamera/transform.cpp | 322 ++++++++++++++++++ src/libcamera/v4l2_device.cpp | 15 + 19 files changed, 933 insertions(+), 34 deletions(-) create mode 100644 include/libcamera/internal/bayer_format.h create mode 100644 include/libcamera/transform.h create mode 100644 src/libcamera/bayer_format.cpp create mode 100644 src/libcamera/transform.cpp