From patchwork Tue Jun 15 10:51:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12597 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 EDB8BBD78E for ; Tue, 15 Jun 2021 10:51:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 67E966029A; Tue, 15 Jun 2021 12:51:44 +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="T6bUvqAn"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D4D66029D for ; Tue, 15 Jun 2021 12:51:43 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id m3so8634022wms.4 for ; Tue, 15 Jun 2021 03:51:43 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=dX7vDkJOH13e4PMs9zqtfbDImO7crkG0/86wTonUNiI=; b=T6bUvqAn9xdjqppS+0rudUm4aO6nBQ3DvEw1HwhFPkPwNQ76rn4jiml9nGDV5Reoot 7BZKINudAGDb3FXfVk9y47QRykid5f/0R/xIQO+zW4Gwp7DeqoHjH2EXBzKrWTFiBzho 6If9eBObUBj9lXtJvj7qcmcP3ePyuNhjr4DUe+mJwCcxYfBH5OnwSdahbfSHIBPwHi2R T4NHr525VDGXzxgBYjDze8I6vZnx8eH1gq1j3ewwWRmmDMSZGz0DiWN1OzWZ6voXK09H OB1peQqpa/5SWtdRzYMTH4Op26VhDO155f40rhZBS4jlDvmaL1pA0RfGb3XaZAxpIMC9 JyoQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=dX7vDkJOH13e4PMs9zqtfbDImO7crkG0/86wTonUNiI=; b=AtUDu81N0afHCKNGJX2YQg0QrP+gUUbGiYsRYVWok8BWgmYmcqKtMZG2R7aDUvgrwy SsDyea4fxXpwrD3t38vQC7Babyms3hj/d0uL5zdB0rFrpMB4kX6h/qukHgpCJ9N9AfwI hk1bPcDolOAzlJJByASPwSCMUnL/xyu/E+zmvs/ALomi04ke0VRNZ15P208+2tBH3DxS xciobtr+uypkek/skgy+lHLGdkzb711csHu/Clh9fkgdxCQKFNX7Napfit/kyotKq8LW gJwhE9dd9vvw4eOry5fso9NrCnbBO0zjuBmZt91gukKb/RKfG257dVHmUgNonJhh/AsD HtvQ== X-Gm-Message-State: AOAM531V3f7c/1sJ0nNii9v1qFCOt2WZ3Ol+/UzaeS8zWUymKFrU49O7 2fG/ST+QvmQtF7vW/stdXFPDNTAUUCiPLOFp X-Google-Smtp-Source: ABdhPJwI5t5EOqQeTgxGTtyZdtzBHxcZsRuF2/xtALJpMVNmDyaAER6i/oEY0IQqBvLrRu8dRDg90Q== X-Received: by 2002:a05:600c:3397:: with SMTP id o23mr22178712wmp.10.1623754302597; Tue, 15 Jun 2021 03:51:42 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id u15sm1796300wmq.48.2021.06.15.03.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 03:51:42 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 15 Jun 2021 11:51:37 +0100 Message-Id: <20210615105139.16171-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210615105139.16171-1-david.plowman@raspberrypi.com> References: <20210615105139.16171-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] libcamera: Add support for monochrome sensors 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" This commit adds support for monochrome (greyscale) raw sensors. These are sensors that have no colour filter array, so all pixels are the same and there are no distinct colour channels. These sensors still require many of an ISP's processing stages, such as denoise, tone mapping, but not those that involve colours (such as demosaic, or colour matrices). Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- include/libcamera/internal/bayer_format.h | 3 ++- src/libcamera/bayer_format.cpp | 14 ++++++++++++-- src/libcamera/camera_sensor.cpp | 3 +++ src/libcamera/property_ids.yaml | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 5b8c1dc9..723382d4 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -23,7 +23,8 @@ public: BGGR = 0, GBRG = 1, GRBG = 2, - RGGB = 3 + RGGB = 3, + MONO = 4 }; enum Packing : uint16_t { diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index ed61202c..11355f14 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -45,6 +45,8 @@ namespace libcamera { * \brief G then R on the first row, B then G on the second row. * \var BayerFormat::RGGB * \brief R then G on the first row, G then B on the second row. + * \var BayerFormat::MONO + * \brief Monochrome image data, there is no colour filter array. */ /** @@ -111,6 +113,8 @@ const std::map bayerToV4l2{ { { BayerFormat::GBRG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) }, { { BayerFormat::GRBG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) }, { { BayerFormat::RGGB, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) }, + { { BayerFormat::MONO, 8, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_GREY) }, + { { BayerFormat::MONO, 10, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) }, }; const std::unordered_map mbusCodeToBayer{ @@ -146,6 +150,8 @@ const std::unordered_map mbusCodeToBayer{ { MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::None } }, { MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::None } }, { MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::None } }, + { MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::None } }, + { MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10, BayerFormat::None } }, }; } /* namespace */ @@ -198,9 +204,10 @@ std::string BayerFormat::toString() const "BGGR", "GBRG", "GRBG", - "RGGB" + "RGGB", + "MONO" }; - if (isValid() && order <= RGGB) + if (isValid() && order <= MONO) result = orderStrings[order]; else return "INVALID"; @@ -280,6 +287,9 @@ BayerFormat BayerFormat::transform(Transform t) const { BayerFormat result = *this; + if (order == MONO) + return result; + /* * Observe that flipping bit 0 of the Order enum performs a horizontal * mirror on the Bayer pattern (e.g. RGGB goes to GRBG). Similarly, diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 3e135353..fb67c15a 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -427,6 +427,9 @@ int CameraSensor::initProperties() case BayerFormat::RGGB: cfa = properties::draft::RGGB; break; + case BayerFormat::MONO: + cfa = properties::draft::MONO; + break; } properties_.set(properties::draft::ColorFilterArrangement, cfa); diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 104e9aaf..87be68f7 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -706,5 +706,9 @@ controls: description: | Sensor is not Bayer; output has 3 16-bit values for each pixel, instead of just 1 16-bit value per pixel. + - name: MONO + value: 5 + description: | + Sensor is not Bayer; output consits of a single colour channel. ... From patchwork Tue Jun 15 10:51:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12598 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 CFDD0BD78E for ; Tue, 15 Jun 2021 10:51:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 915DD68948; Tue, 15 Jun 2021 12:51:47 +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="jSG9JzmL"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CDEFF68949 for ; Tue, 15 Jun 2021 12:51:43 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id h11-20020a05600c350bb02901b59c28e8b4so1456370wmq.1 for ; Tue, 15 Jun 2021 03:51:43 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=QVArBmBrjrypsLGJa1m5fvTRw+qpuCABtPTcmqBl12A=; b=jSG9JzmL7FH1Ntj7dKStsCVZYENy1MFtP3z1IqyYGNFYNJPhdRAwBAO2V6kJqvd4Mb mJAUPJ75mpuXT78PGfs6U9HYx+WFg5Rbob6EXmDULigaUwJPCu6LbIZCMgA6hLmL6oAA m2/dEuiLuaO1vrjIThbINBrnfb1UR3e5pDYM/95+j1KIztbzh1NuDnD6wCGLZi4CRY6l fCAZMjhRukR5E72ROTCPzoSfF5/lpsROlVEbSO3cVbGe4toK3NneM7yHbzyQrrEfaXjG 3hvWHcUFTIH52sq8QHtA3hI4je8IgEkQPy+3vHHbT6e7IN9doFqniGwLluSJlq4yIZKu 4BIA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=QVArBmBrjrypsLGJa1m5fvTRw+qpuCABtPTcmqBl12A=; b=mGyhr2i0mab9DiGz40b/906OhZKUiUF7/8GXwcSL4IY29JfNd9OJr5l2dJraq2EWNF RsfNQLKN7iGH3+TL6UkZDjS2b/L8alWCDoc7ZfGw/nyHCT6tCMhf1nvAdORYN8QDqcCl TbgtWt+8B887/iuBTHrnfq7iWd4Aio0Wp1ohXzJ3zOhrTyZdkhb1LmCIHSDsYPm74PTA iaTZPKRopFqTbxgZ0veC54rC/im0ouDJp3IuOPZXTtuqKs1uSw9hRetaY4nTi5WNZryV VApQMAbJ8eNoeOQDqw5vxv9hXgjf0g5RfhYwPPEnrVOZ/POhnjiN0ScD01oFZ+85DWMT 5img== X-Gm-Message-State: AOAM530nQWVrJVpdAH6P0b2KpDtcsKcrwZ8dgD405tfTB55NBOAB/w4d 4GHWICWZ66kN6JPLG+SoC5O75APN0paD8eua X-Google-Smtp-Source: ABdhPJyvwVCV5Sbtgc8uc0CKRofwOsC6O2KnQQ2jMwVcp/bUxmso9B1VZ0sdZUN873twgpjF9tLxpA== X-Received: by 2002:a05:600c:4f47:: with SMTP id m7mr4300541wmq.8.1623754303415; Tue, 15 Jun 2021 03:51:43 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id u15sm1796300wmq.48.2021.06.15.03.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 03:51:42 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 15 Jun 2021 11:51:38 +0100 Message-Id: <20210615105139.16171-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210615105139.16171-1-david.plowman@raspberrypi.com> References: <20210615105139.16171-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] libcamera: ipa: raspberrypi: Demote warnings about lack of AWB results 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" Warnings about the lack of AWB status results are demoted to being just "Debug". With monochrome sensors becoming more common this would otherwise overwhelm the console output, and in practice nothing is really lost as it is normally very evident if AWB is failing to run. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 55e80ac7..2c95f287 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -481,7 +481,7 @@ void Agc::fetchAwbStatus(Metadata *image_metadata) awb_.gain_g = 1.0; awb_.gain_b = 1.0; if (image_metadata->Get("awb.status", awb_) != 0) - LOG(RPiAgc, Warning) << "Agc: no AWB status found"; + LOG(RPiAgc, Debug) << "Agc: no AWB status found"; } static double compute_initial_Y(bcm2835_isp_stats *stats, AwbStatus const &awb, diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index b0d24aa2..c58ef7d0 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -267,7 +267,7 @@ double get_ct(Metadata *metadata, double default_ct) AwbStatus awb_status; awb_status.temperature_K = default_ct; // in case nothing found if (metadata->Get("awb.status", awb_status) != 0) - LOG(RPiAlsc, Warning) << "no AWB results found, using " + LOG(RPiAlsc, Debug) << "no AWB results found, using " << awb_status.temperature_K; else LOG(RPiAlsc, Debug) << "AWB results found, using " From patchwork Tue Jun 15 10:51:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12599 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 44905C3219 for ; Tue, 15 Jun 2021 10:51:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E731C6894E; Tue, 15 Jun 2021 12:51:47 +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="Hl8wpvfS"; dkim-atps=neutral Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DBF96894C for ; Tue, 15 Jun 2021 12:51:44 +0200 (CEST) Received: by mail-wr1-x42e.google.com with SMTP id c5so17774053wrq.9 for ; Tue, 15 Jun 2021 03:51:44 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=y6CY5ccg+5koDNETxXS+nXi+jxkMEVLU06/K/QWwFSc=; b=Hl8wpvfSU1Q6OS/L3nMhgy1bh6eUGgrdWDwRNXyaerSOMEF4mW+IsJmjwCH/xGS7uC ZHEmOky3TXJrT7UPzphDn7bovh4AfQ3C/Lik3tPRg1wS2wUCN3v1c9qF5aHC5D0uaD+n zyGCPzAxE/4OT1MmjvvoHju1pNfz6hqJf2fpAKoF1KGZlLWiy07/rvD7E5ld2ALiq9M7 qOye4aJmpeO9LDyiIlioM/tHfh+BTtEth6lCIKIQfQl12o/mnHui8xo5pLWxhu2VJxAe mHA94PpHdOciA63qCAHAVjqOsoBeh+9QgFLzHf4rDoODAi4B5osnrvXFcVsqC+ft2tKH iDaA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=y6CY5ccg+5koDNETxXS+nXi+jxkMEVLU06/K/QWwFSc=; b=iD62OwRTc/jsuuiA171hJlc3gxHyeCv6YbQ2+eK5+s1wbbFf2kHLbLXQ3P7g5ZaXhF cBuNJceMh3dKWQnllETIOrrIhpxGMXTXEw3FVp/ZLgyk9ivuYXOsOmvnLsIv0R7gwuDa 4ijzJbs4N4HCgH3a7+I6cx1GKQdiPxLBr1ssS3mOdSjdirPEZMsxP8CaVjsN+HyyiiQ+ VhEIFWuyDr/F4VyoFRK7owx3dIfepCV7Ph/ppDRzU+4FXX8YiHvdZl+bn5LS1imrYipE 0QvJpKwIn3FNCqUg3KqxMIbV7KMlKnMGEuEm+oupB2ZVuThOp1a0W+WMpDaldGj0ApWg K1+w== X-Gm-Message-State: AOAM533DGT64Z9PzZ+IqESnQ+JiDxIbEgOtRcsQHp6wwquQ60/JX9yBI 6dk+qwQ7DHk/gy8yDJIp0gSFGhdahKXgcXOe X-Google-Smtp-Source: ABdhPJynCD6MwZ6vvzH5q9T3HhW257EWkGUHLLel7QaYSdpWeJOzgZpPqyXi0tdeG5AB3IcIy9AU1Q== X-Received: by 2002:adf:d1ec:: with SMTP id g12mr24717392wrd.204.1623754303966; Tue, 15 Jun 2021 03:51:43 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id u15sm1796300wmq.48.2021.06.15.03.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 03:51:43 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 15 Jun 2021 11:51:39 +0100 Message-Id: <20210615105139.16171-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210615105139.16171-1-david.plowman@raspberrypi.com> References: <20210615105139.16171-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] libcamera: ipa: raspberrypi: Add support for ov9281 sensor 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" The necessary tuning file and CamHelper is added for the ov9281 sensor (which the driver names as the "mov9281"). The ov9281 is a 1280x800 monochrome global shutter sensor. To enable it, please add dtoverlay=ov9281 to the /boot/config.txt file and reboot the Pi. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/cam_helper_mov9281.cpp | 108 +++++++++++++++++++++ src/ipa/raspberrypi/data/meson.build | 1 + src/ipa/raspberrypi/data/mov9281.json | 92 ++++++++++++++++++ src/ipa/raspberrypi/meson.build | 1 + 4 files changed, 202 insertions(+) create mode 100644 src/ipa/raspberrypi/cam_helper_mov9281.cpp create mode 100644 src/ipa/raspberrypi/data/mov9281.json diff --git a/src/ipa/raspberrypi/cam_helper_mov9281.cpp b/src/ipa/raspberrypi/cam_helper_mov9281.cpp new file mode 100644 index 00000000..5645c73a --- /dev/null +++ b/src/ipa/raspberrypi/cam_helper_mov9281.cpp @@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * + * cam_helper_mov9281.cpp - camera information for ov9281 sensor + */ + +#include + +#include "cam_helper.hpp" + +using namespace RPiController; + +class CamHelperOv9281 : public CamHelper +{ +public: + CamHelperOv9281(); + uint32_t GainCode(double gain) const override; + double Gain(uint32_t gain_code) const override; + void GetDelays(int &exposure_delay, int &gain_delay, + int &vblank_delay) const override; + unsigned int HideFramesStartup() const override; + unsigned int HideFramesModeSwitch() const override; + unsigned int MistrustFramesStartup() const override; + unsigned int MistrustFramesModeSwitch() const override; + +private: + /* + * Smallest difference between the frame length and integration time, + * in units of lines. + */ + static constexpr int frameIntegrationDiff = 4; +}; + +/* + * OV9281 doesn't output metadata, so we have to use the "unicam parser" which + * works by counting frames. + */ + +CamHelperOv9281::CamHelperOv9281() + : CamHelper(nullptr, frameIntegrationDiff) +{ +} + +uint32_t CamHelperOv9281::GainCode(double gain) const +{ + return static_cast(gain * 16.0); +} + +double CamHelperOv9281::Gain(uint32_t gain_code) const +{ + return static_cast(gain_code) / 16.0; +} + +void CamHelperOv9281::GetDelays(int &exposure_delay, int &gain_delay, + int &vblank_delay) const +{ + /* + * We run this sensor in a mode where the gain delay is bumped up to + * 2. It seems to be the only way to make the delays "predictable". + */ + exposure_delay = 2; + gain_delay = 2; + vblank_delay = 2; +} + +unsigned int CamHelperOv9281::HideFramesStartup() const +{ + /* + * On startup, we get a couple of under-exposed frames which + * we don't want shown. + */ + return 2; +} + +unsigned int CamHelperOv9281::HideFramesModeSwitch() const +{ + /* + * After a mode switch, we get a couple of under-exposed frames which + * we don't want shown. + */ + return 2; +} + +unsigned int CamHelperOv9281::MistrustFramesStartup() const +{ + /* + * First couple of frames are under-exposed and are no good for control + * algos. + */ + return 2; +} + +unsigned int CamHelperOv9281::MistrustFramesModeSwitch() const +{ + /* + * First couple of frames are under-exposed even after a simple + * mode switch, and are no good for control algos. + */ + return 2; +} + +static CamHelper *Create() +{ + return new CamHelperOv9281(); +} + +static RegisterCamHelper reg("mov9281", &Create); diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build index 92ad3272..f8baab6d 100644 --- a/src/ipa/raspberrypi/data/meson.build +++ b/src/ipa/raspberrypi/data/meson.build @@ -4,6 +4,7 @@ conf_files = files([ 'imx219.json', 'imx290.json', 'imx477.json', + 'mov9281.json', 'ov5647.json', 'se327m12.json', 'uncalibrated.json', diff --git a/src/ipa/raspberrypi/data/mov9281.json b/src/ipa/raspberrypi/data/mov9281.json new file mode 100644 index 00000000..ecd262be --- /dev/null +++ b/src/ipa/raspberrypi/data/mov9281.json @@ -0,0 +1,92 @@ +{ + "rpi.black_level": + { + "black_level": 4096 + }, + "rpi.lux": + { + "reference_shutter_speed": 2000, + "reference_gain": 1.0, + "reference_aperture": 1.0, + "reference_lux": 800, + "reference_Y": 20000 + }, + "rpi.noise": + { + "reference_constant": 0, + "reference_slope": 2.5 + }, + "rpi.sdn": + { + }, + "rpi.agc": + { + "metering_modes": + { + "centre-weighted": { + "weights": [4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0] + } + }, + "exposure_modes": + { + "normal": + { + "shutter": [ 100, 15000, 30000, 60000, 120000 ], + "gain": [ 1.0, 2.0, 3.0, 4.0, 6.0 ] + } + }, + "constraint_modes": + { + "normal": + [ + { "bound": "LOWER", "q_lo": 0.98, "q_hi": 1.0, "y_target": [ 0, 0.4, 1000, 0.4 ] } + ] + }, + "y_target": [ 0, 0.16, 1000, 0.165, 10000, 0.17 ] + }, + "rpi.alsc": + { + "n_iter": 0, + "luminance_strength": 1.0, + "corner_strength": 1.5 + }, + "rpi.contrast": + { + "ce_enable": 0, + "gamma_curve": [ + 0, 0, + 1024, 5040, + 2048, 9338, + 3072, 12356, + 4096, 15312, + 5120, 18051, + 6144, 20790, + 7168, 23193, + 8192, 25744, + 9216, 27942, + 10240, 30035, + 11264, 32005, + 12288, 33975, + 13312, 35815, + 14336, 37600, + 15360, 39168, + 16384, 40642, + 18432, 43379, + 20480, 45749, + 22528, 47753, + 24576, 49621, + 26624, 51253, + 28672, 52698, + 30720, 53796, + 32768, 54876, + 36864, 57012, + 40960, 58656, + 45056, 59954, + 49152, 61183, + 53248, 62355, + 57344, 63419, + 61440, 64476, + 65535, 65535 + ] + } +} diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build index d1397a32..e384c7ce 100644 --- a/src/ipa/raspberrypi/meson.build +++ b/src/ipa/raspberrypi/meson.build @@ -22,6 +22,7 @@ rpi_ipa_sources = files([ 'cam_helper_imx219.cpp', 'cam_helper_imx290.cpp', 'cam_helper_imx477.cpp', + 'cam_helper_mov9281.cpp', 'controller/controller.cpp', 'controller/histogram.cpp', 'controller/algorithm.cpp',