From patchwork Thu Sep 16 13:20:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 13861 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 816C2BF01C for ; Thu, 16 Sep 2021 13:20:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EB1CA6918A; Thu, 16 Sep 2021 15:20:23 +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="WZ2L3Byq"; dkim-atps=neutral Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 445376916F for ; Thu, 16 Sep 2021 15:20:22 +0200 (CEST) Received: by mail-wm1-x32a.google.com with SMTP id z184-20020a1c7ec1000000b003065f0bc631so7388862wmc.0 for ; Thu, 16 Sep 2021 06:20:22 -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=iG+z2XG3WoRA+Vl2v1qQhE3PcV4Q/c8s1XmMCSzIzgQ=; b=WZ2L3ByqcA1H7TQLibc4AfpbYrRxYUuiA0piF1gJX2GanSOqVEbgihpcTH2u51jTW3 f0lhf88d2WICYmb+omq90uiGMqUC5aW9uEu1ZIkYJZAJTaE6BKYQLc2hryrLr8v2vw0H nYOdqfrxUMm2Dn/hrcvUw9LR0P7fmtAdhc3Nng39vy6qkc2WNiG7eKSS9di8TqyWw84k tIs+bvOGQydenVo5LpcHYNAukMohfiW2hU7Q07g6Hk+btoW6ciEFbcjl5KjnMKLl6qcN FBP+HfIoZMOOYE5WvEhYr83duvIIsoSce/iHyQv0TjFK70zAxi/2R20AEBK2jFUUk/JO BUDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iG+z2XG3WoRA+Vl2v1qQhE3PcV4Q/c8s1XmMCSzIzgQ=; b=Dn8stDqbrts/VOvqc4aULyluE4Qrfenm+rtA5GdoDZ3cUEf/Cdio7KotBbTfjiz+wd uXw6NcUkafnyI8nDj2r3bNYmSSkcTC8rAaN9gMs9HhLjUujj8CsHgIEFXBz9zapSwdN1 9C8bgUcIeyH7xxFu+ZS6wnRPp22VQhAf7oJN6Ie1nwkOUexdUs/tSXVSOga8vZJEgH1X MrkDDutBRQpC/eUYGkh1HZ1frPUrdDR0rYoo8cBXCJPBBAWQkHNCMebxzqYBKWnEBCuz Klqj6AEd2Lv0Un4+/l35nynqrr8o2pWNSpuQPDgcy+y08Pz69d9h1Fu2loIlO5H20vwI /cBQ== X-Gm-Message-State: AOAM533oi7AMb04ZSzrBna1hbEsg0WBOXp0NTM/IDn1yal7SUTminoEp Sv9Qq7ofu4+0YkzWtI6YAiEDlNpyaXUNCotK X-Google-Smtp-Source: ABdhPJyvsubYjYFXvERuY/xPhSAUMxH++LSy2lCut4ZStG594I4Xz7TEzo5e/enf829TQoboG8teFg== X-Received: by 2002:a1c:28b:: with SMTP id 133mr5045710wmc.14.1631798421575; Thu, 16 Sep 2021 06:20:21 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id f3sm3233425wmj.28.2021.09.16.06.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 06:20:21 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Sep 2021 14:20:13 +0100 Message-Id: <20210916132015.1790-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 0/2] Sensor mode hints 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 a first attempt at functionality that allows applications to provide "hints" as to what kind of camera mode they want. 1. Bit Depths and Sizes So far I'm allowing hints about bit depth and the image sizes that can be read out of a sensor, and I've gathered these together into something I've call a SensorMode. I've added a SensorMode field to the CameraConfiguration so that applications can optionally put in there what they think they want, and also a CameraSensor::getSensorModes function that returns a list of the supported modes (raw formats only...). There are various ways an application could use this: * It might not care and would ignore the new field altogether. The pipeline handler will stick to its current behaviour. * It might have some notion of what it wants, perhaps a larger bit depth, and/or a range of sizes. It can fill some or all of those into the SensorMode and the pipeline handler should respect it. * Or it could query the CameraSensor for its list of SensorModes and then sift through them looking for the one that it likes best. 2. Field of View and Framerates The SensorMode should probably include FoV and framerate information so that applications can make intelligent choices automatically. However, this is a bit trickier for various reasons so I've left it out. There could be a later phase of work that adds these. Even without this, however, the implementation gets us out of our rather critical hole where we simply can't get 10-bit modes. It also provides a better alternative to the current nasty practice of requesting a raw stream specifically to bodge the camera mode selection, even when the raw stream is not actually wanted! 3. There are 2 commits here The first adds the SensorMode class, puts it into the CameraConfiguration, and allows the supported modes to be listed from the CameraSensor. (All the non-Pi stuff.) The second commit updates our mode selection code to select according to the hinted SensorMode (figuring out defaults if it was empty). But it essentially works just the same, if in a slightly more generic way. The code here is fully functional and seems to work fine. Would other pipeline handlers be able to adapt to the idea of a "hinted SensorMode" as easily? As always, I'm looking forward to people's thoughts! Thanks David David Plowman (2): libcamera: Add SensorMode class libcamera: pipeline_handler: raspberrypi: Handle the new SensorMode hint include/libcamera/camera.h | 3 + include/libcamera/internal/camera_sensor.h | 4 + include/libcamera/meson.build | 1 + include/libcamera/sensor_mode.h | 50 +++++++++ src/libcamera/camera_sensor.cpp | 15 +++ src/libcamera/meson.build | 1 + .../pipeline/raspberrypi/raspberrypi.cpp | 105 +++++++++++++----- src/libcamera/sensor_mode.cpp | 60 ++++++++++ 8 files changed, 212 insertions(+), 27 deletions(-) create mode 100644 include/libcamera/sensor_mode.h create mode 100644 src/libcamera/sensor_mode.cpp