From patchwork Sat Aug 29 11:54:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9426 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 06074BF019 for ; Sat, 29 Aug 2020 11:54:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3ACE66291E; Sat, 29 Aug 2020 13:54:36 +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="dsSzwafQ"; dkim-atps=neutral Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AF09B6037D for ; Sat, 29 Aug 2020 13:54:34 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id b79so1411217wmb.4 for ; Sat, 29 Aug 2020 04:54:34 -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=qiIWPkAx0NYImiTCgW4Wdl46j3TJq2a5xgBl8YF1ES8=; b=dsSzwafQCdX7fSsm5hGdFGdFzE+D0Hrrbiyp1LvWqTqnrCYAnquTfPJKaXkIrrym2H svBWMQy1QIRPb6I1R7FSFtKfO816uJztu3T9sIBfgfonTRk0rU6SMyqlQOiqUd3tFQjN U12TSyN9hgesp4yvDXDGKfOEfVPbVrr3oS+b4pYBZP6FFYGNCfizL46Iv1D7qYKhGvdn 0hv3Af2+MUSs1caJ6r9ZXCN8tdp5cAok8/WWRhKD4V47rhd30AeMcte/4w8EyCBzhPej LQ95tF33VDF+/ak/905SHdcjDlTfQbr4yff4LYqLSUi0rsFuPFiweEpv36x/4k3QciPL xauw== 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=qiIWPkAx0NYImiTCgW4Wdl46j3TJq2a5xgBl8YF1ES8=; b=jDz8g7c33pmZw2B4YVfH7rNAj3h4WEeb9NC6dv+333zmsu8QGwn38Gd1Dr796kuCmB RUZdlDpFvAMulzjJ6Fg/w1dArR7JklCh3WMzmVAS8QQUwcNRZFJyMuzx6N4ugZoTPZlX yW+QxCeGXbKJJjhGWtO4kheUlEIJv7R+1a0k8Tu5kRx25qXZuNJlmWdq2p1s1RVqNrg6 m71qHlUnA/MW8ub7jgVvhF7mpFr0VCH3zpndBdkqn5dUnvZqwyRWU+6iP1JUZfB8CScA mX8Ofc1woWY7eWtKPoCgEplJ0r2EmnNBx5BVOySfKWJlpwib9BUqFvYMcC25gN94lubs gI5A== X-Gm-Message-State: AOAM533eItaNn3zgD0EvOvZaIkfYE/PgIvDnInOSN2Mv/2pnRFCirBWC 1lq7A5n2XMPMH1CoI/XzpM8hPGB3mrKu/Q== X-Google-Smtp-Source: ABdhPJx2xg98aHBt0yrlC05IvwVSbiYU8uxxdYpEFNG83lW3YHgV5Ob7sVuTws20RxCxRcU6nSxnXQ== X-Received: by 2002:a7b:c084:: with SMTP id r4mr2915147wmh.20.1598702073975; Sat, 29 Aug 2020 04:54:33 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id v16sm3071523wmj.14.2020.08.29.04.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Aug 2020 04:54:33 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Sat, 29 Aug 2020 12:54:21 +0100 Message-Id: <20200829115429.30010-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Here's another version of 2D transforms, after the previous version slightly set the cat among the pigeons! Of course, the basic way in which transforms work is unchanged, but we now avoid touching the sensor until the configure() method. The number of separate commits has gone up to eight, let me walk through them: 1. This reverts that same patch as we did previously. (Note that there was previously a commit here that moved the sensor H/VFLIP manipulation into validate(), but this one has been dropped, leaving it in configure().) 2. This is a new commit that gives pipeline handlers access to the v4l2_query_ext_ctrl structure for a V4L2 control. The V4L2Device has already retrieved this information, but doesn't make it publicly available. I went with a simple extra queryCtrl function as it seemed simplest and touches least stuff, but I did wonder about other ways of doing it. Perhaps the flags could be stored also in the V4L2ControlInfo structure and made available from there? But currently the V4L2Device appears to give out ControlInfos, not V4L2ControlInfos... anyway, there's perhaps a bit of a discussion to have here. 3. The third commit adds the transform enum and is unchanged. 4. This is also a new commit, and adds a transform method to the V4L2PixelFormat class that operates only on Bayer formats. I thought it was worth adding this function in a place where it would be helpful to other pipeline handlers, rather than burying it in the RPi one. I'm afraid I don't have a more elegant implementation of it other than by using tables. 5. Adds the transform field to the CameraConfiguration. Unchanged. 6. This is where we handle the transforms properly in the RPi pipeline handler. validate() now works out what the Bayer order of any raw streams _will_ be, given the transform. The actual updating of the flip bits in the sensor is still in configure(), as it was a couple of versions ago! 7 and 8. Both unchanged. I think that's everything. 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: Allow Bayer pixel formats to be transformed 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/v4l2_device.h | 2 + include/libcamera/internal/v4l2_pixelformat.h | 3 + include/libcamera/meson.build | 1 + include/libcamera/transform.h | 73 ++++ src/ipa/raspberrypi/controller/camera_mode.h | 4 + src/ipa/raspberrypi/controller/rpi/alsc.cpp | 13 +- src/ipa/raspberrypi/raspberrypi.cpp | 48 +-- src/libcamera/camera.cpp | 16 +- src/libcamera/meson.build | 1 + src/libcamera/pipeline/ipu3/ipu3.cpp | 5 + .../pipeline/raspberrypi/raspberrypi.cpp | 96 +++++- 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 | 312 ++++++++++++++++++ src/libcamera/v4l2_device.cpp | 15 + src/libcamera/v4l2_pixelformat.cpp | 94 +++++- 19 files changed, 668 insertions(+), 38 deletions(-) create mode 100644 include/libcamera/transform.h create mode 100644 src/libcamera/transform.cpp