From patchwork Wed Aug 7 08:03:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 20812 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 1F76BC324E for ; Wed, 7 Aug 2024 08:03:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7E510633B4; Wed, 7 Aug 2024 10:03:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Unb7Z4BP"; dkim-atps=neutral Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B3CD1633AC for ; Wed, 7 Aug 2024 10:03:43 +0200 (CEST) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2f15e48f35bso14610181fa.0 for ; Wed, 07 Aug 2024 01:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1723017823; x=1723622623; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zNjKDE4OTLVxsHwtowMOBpxID0k5Y/yIVUCRhbZyvEg=; b=Unb7Z4BPFPwmAHqoclbd86qfCTfUs0/93TvgppHQ0xIzseq/d3TqFGsR7bwoI5JJ0U de6dqc8B3XNr/LKIG+NzSQrbBzM3Lqc22sdJajiD8vsutfFf97AxXfR9DstN0XHzye8w POdIclcBIqYx00bRj8qJI97YahNZnwk2v0biiO1wOpn4IyfQ3d9kGKGERE/igSDEc9bS U38rVsGun1EOEbn4d8W1zCq19b/a3XbWNX9nFbVqZTLijsM7VzENaaBJQNZEcPFCVdlc SZC4MxBVE5iHTIWslnMH/vmwgTEoQBUopHBCR/yzaK91RQYUIo2dYl7ZhQhleP8Basjh g4Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723017823; x=1723622623; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zNjKDE4OTLVxsHwtowMOBpxID0k5Y/yIVUCRhbZyvEg=; b=T0R9L/TWLcBqwBLxza++xreatm3NzsWmSau4cp+m5XIHDbl8DdsIUqnNkcfj+DHkMZ RAd08Ps97LT8gzdlKkD9hf6aw7q6/htCTfrWdyWJ1VSSPy3LCFq+QCbq5xmsCpUVXPu9 6ZZU5Mr+RZVqJhXxvPT2EIHlOPcfzibjcb5gq6MVQ8imNDxxgzICuiiASp0EeXEV+Uu+ FTD3OAPqEaLM7N4pejGFyGqii8ePAtCTAWqxFM/A47Ct3kxMxdMVJlqIqtJVTsUtGcU+ zWq26r4wm1MdtPeUkYtY92VTKzJTb+pl+zJeZHSkrYPcLu4cu0uG2DFEF9D0MfDdGfMe jNtQ== X-Gm-Message-State: AOJu0YzpWZgAXtgrFRbnRZmjvp7y3btV0RyFC/oHu5Gh9wKv84JUkNGE njWNftMeIc150SZY9MUkixTUGARaepeF3Sf1sGvRB5I0UqDlbcSaTbIinRttVcK8NnCKEEej/gx L X-Google-Smtp-Source: AGHT+IEjGtNELAuPc2fkByIbZi2VkUkxa2mnCbJrZwM4fKUjZQqHb9hh+mh6k1FbJG7TFOGB8+QrSg== X-Received: by 2002:a2e:91d0:0:b0:2ef:1c0f:d490 with SMTP id 38308e7fff4ca-2f15ab0c2a1mr125068651fa.39.1723017822051; Wed, 07 Aug 2024 01:03:42 -0700 (PDT) Received: from naush-laptop.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42905961e9dsm16403005e9.8.2024.08.07.01.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 01:03:41 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: will whang , Naushir Patuck Subject: [PATCH v1 2/2] ipa: rpi: Adding IMX585 + IMX585-mono support Date: Wed, 7 Aug 2024 09:03:44 +0100 Message-Id: <20240807080344.12780-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240807080344.12780-1-naush@raspberrypi.com> References: <20240807080344.12780-1-naush@raspberrypi.com> MIME-Version: 1.0 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" From: will whang Add support for the IMX585 sensor - both colour and mono variants. Signed-off-by: will whang Signed-off-by: Naushir Patuck Reviewed-by: Naushir Patuck --- src/ipa/rpi/cam_helper/cam_helper_imx585.cpp | 75 +++++ src/ipa/rpi/cam_helper/meson.build | 1 + src/ipa/rpi/vc4/data/imx585.json | 315 ++++++++++++++++++ src/ipa/rpi/vc4/data/imx585_mono.json | 180 ++++++++++ src/ipa/rpi/vc4/data/meson.build | 2 + .../sensor/camera_sensor_properties.cpp | 4 + 6 files changed, 577 insertions(+) create mode 100644 src/ipa/rpi/cam_helper/cam_helper_imx585.cpp create mode 100644 src/ipa/rpi/vc4/data/imx585.json create mode 100644 src/ipa/rpi/vc4/data/imx585_mono.json diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx585.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx585.cpp new file mode 100644 index 000000000000..8efdb504c75b --- /dev/null +++ b/src/ipa/rpi/cam_helper/cam_helper_imx585.cpp @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2024, Raspberry Pi Ltd + * + * cam_helper_Imx585.cpp - camera information for Imx585 sensor + */ + +#include +#include + +#include "cam_helper.h" + +using namespace RPiController; + +class CamHelperImx585 : public CamHelper +{ +public: + CamHelperImx585(); + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay, int &hblankDelay) const override; + unsigned int hideFramesModeSwitch() const override; + +private: + /* + * Smallest difference between the frame length and integration time, + * in units of lines. + */ + static constexpr int frameIntegrationDiff = 4; +}; + +/* + * Imx585 doesn't output metadata, so we have to use delayed controls which + * works by counting frames. + */ + +CamHelperImx585::CamHelperImx585() + : CamHelper({}, frameIntegrationDiff) +{ +} + +uint32_t CamHelperImx585::gainCode(double gain) const +{ + int code = 66.6667 * log10(gain); + return std::max(0, std::min(code, 0xf0)); +} + +double CamHelperImx585::gain(uint32_t gainCode) const +{ + return pow(10, 0.015 * gainCode); +} + +void CamHelperImx585::getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay, int &hblankDelay) const +{ + /* The driver appears to behave as follows: */ + exposureDelay = 2; + gainDelay = 2; + vblankDelay = 2; + hblankDelay = 2; +} + +unsigned int CamHelperImx585::hideFramesModeSwitch() const +{ + /* After a mode switch, we seem to get 1 bad frame. */ + return 1; +} + +static CamHelper *create() +{ + return new CamHelperImx585(); +} + +static RegisterCamHelper reg("imx585", &create); diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build index 7262505742f3..369669397d46 100644 --- a/src/ipa/rpi/cam_helper/meson.build +++ b/src/ipa/rpi/cam_helper/meson.build @@ -8,6 +8,7 @@ rpi_ipa_cam_helper_sources = files([ 'cam_helper_imx296.cpp', 'cam_helper_imx477.cpp', 'cam_helper_imx519.cpp', + 'cam_helper_imx585.cpp', 'cam_helper_imx708.cpp', 'cam_helper_ov64a40.cpp', 'cam_helper_ov9281.cpp', diff --git a/src/ipa/rpi/vc4/data/imx585.json b/src/ipa/rpi/vc4/data/imx585.json new file mode 100644 index 000000000000..be101389f699 --- /dev/null +++ b/src/ipa/rpi/vc4/data/imx585.json @@ -0,0 +1,315 @@ +{ + "version": 2.0, + "target": "bcm2835", + "algorithms": [ + { + "rpi.black_level": + { + "black_level": 3200 + } + }, + { + "rpi.dpc": { } + }, + { + "rpi.lux": + { + "reference_shutter_speed": 6384, + "reference_gain": 1.0, + "reference_aperture": 1.0, + "reference_lux": 935, + "reference_Y": 11637 + } + }, + { + "rpi.noise": + { + "reference_constant": 12, + "reference_slope": 3.568 + } + }, + { + "rpi.geq": + { + "offset": 192, + "slope": 0.00812 + } + }, + { + "rpi.sdn": { } + }, + { + "rpi.awb": + { + "priors": [ + { + "lux": 0, + "prior": + [ + 2000, 1.0, + 3000, 0.0, + 13000, 0.0 + ] + }, + { + "lux": 800, + "prior": + [ + 2000, 0.0, + 6000, 2.0, + 13000, 2.0 + ] + }, + { + "lux": 1500, + "prior": + [ + 2000, 0.0, + 4000, 1.0, + 6000, 6.0, + 6500, 7.0, + 7000, 1.0, + 13000, 1.0 + ] + } + ], + "modes": + { + "auto": + { + "lo": 2500, + "hi": 8000 + }, + "incandescent": + { + "lo": 2500, + "hi": 3000 + }, + "tungsten": + { + "lo": 3000, + "hi": 3500 + }, + "fluorescent": + { + "lo": 4000, + "hi": 4700 + }, + "indoor": + { + "lo": 3000, + "hi": 5000 + }, + "daylight": + { + "lo": 5500, + "hi": 6500 + } + }, + "bayes": 1, + "ct_curve": + [ + 2187.0, 1.1114, 0.1026, + 2258.0, 1.1063, 0.1147, + 5225.0, 0.6631, 0.5507, + 5289.0, 0.5769, 0.5731, + 6532.0, 0.5259, 0.5801 + ], + "sensitivity_r": 1.0, + "sensitivity_b": 1.0, + "transverse_pos": 0.13694, + "transverse_neg": 0.08426 + } + }, + { + "rpi.agc": + { + "metering_modes": + { + "centre-weighted": + { + "weights": + [ + 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0 + ] + }, + "spot": + { + "weights": + [ + 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ] + }, + "matrix": + { + "weights": + [ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + ] + } + }, + "exposure_modes": + { + "normal": + { + "shutter": [ 100, 10000, 30000, 60000, 120000 ], + "gain": [ 1.0, 2.0, 4.0, 6.0, 6.0 ] + }, + "short": + { + "shutter": [ 100, 5000, 10000, 20000, 120000 ], + "gain": [ 1.0, 2.0, 4.0, 6.0, 6.0 ] + } + }, + "constraint_modes": + { + "normal": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.5, + 1000, 0.5 + ] + } + ], + "highlight": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.5, + 1000, 0.5 + ] + }, + { + "bound": "UPPER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.8, + 1000, 0.8 + ] + } + ] + }, + "y_target": + [ + 0, 0.16, + 1000, 0.165, + 10000, 0.17 + ] + } + }, + { + "rpi.alsc": + { + "omega": 1.3, + "n_iter": 100, + "luminance_strength": 0.7 + } + }, + { + "rpi.contrast": + { + "ce_enable": 1, + "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 + ] + } + }, + { + "rpi.ccm": + { + "ccms": [ + { + "ct": 2187, + "ccm": + [ + 1.91049, -0.78523, -0.12525, + -0.69541, 1.68995, 0.00546, + -0.47685, 0.89308, 0.58376 + ] + }, + { + "ct": 2258, + "ccm": + [ + 1.78809, -0.66968, -0.11841, + -0.67083, 1.69256, -0.02173, + -0.53371, 1.05827, 0.47545 + ] + }, + { + "ct": 5225, + "ccm": + [ + 1.41687, -0.26811, -0.14877, + -0.37784, 1.28381, 0.09403, + 0.04629, -0.42973, 1.38344 + ] + }, + { + "ct": 5289, + "ccm": + [ + 1.42939, -0.40792, -0.02147, + -0.27719, 1.46177, -0.18458, + 0.08958, -0.63362, 1.54404 + ] + }, + { + "ct": 6532, + "ccm": + [ + 1.46551, -0.24251, -0.22301, + -0.42242, 1.64605, -0.22363, + 0.02631, -0.42478, 1.39847 + ] + } + ] + } + }, + { + "rpi.sharpen": { } + } + ] +} \ No newline at end of file diff --git a/src/ipa/rpi/vc4/data/imx585_mono.json b/src/ipa/rpi/vc4/data/imx585_mono.json new file mode 100644 index 000000000000..956b4aeb390d --- /dev/null +++ b/src/ipa/rpi/vc4/data/imx585_mono.json @@ -0,0 +1,180 @@ +{ + "version": 2.0, + "target": "bcm2835", + "algorithms": [ + { + "rpi.black_level": + { + "black_level": 3200 + } + }, + { + "rpi.dpc": { } + }, + { + "rpi.lux": + { + "reference_shutter_speed": 6384, + "reference_gain": 1.0, + "reference_aperture": 1.0, + "reference_lux": 935, + "reference_Y": 11637 + } + }, + { + "rpi.noise": + { + "reference_constant": 12, + "reference_slope": 3.568 + } + }, + { + "rpi.geq": + { + "offset": 192, + "slope": 0.00812 + } + }, + { + "rpi.sdn": { } + }, + { + "rpi.agc": + { + "metering_modes": + { + "centre-weighted": + { + "weights": + [ + 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0 + ] + }, + "spot": + { + "weights": + [ + 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ] + }, + "matrix": + { + "weights": + [ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + ] + } + }, + "exposure_modes": + { + "normal": + { + "shutter": [ 100, 10000, 30000, 60000, 120000 ], + "gain": [ 1.0, 2.0, 4.0, 6.0, 6.0 ] + }, + "short": + { + "shutter": [ 100, 5000, 10000, 20000, 120000 ], + "gain": [ 1.0, 2.0, 4.0, 6.0, 6.0 ] + } + }, + "constraint_modes": + { + "normal": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.5, + 1000, 0.5 + ] + } + ], + "highlight": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.5, + 1000, 0.5 + ] + }, + { + "bound": "UPPER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.8, + 1000, 0.8 + ] + } + ] + }, + "y_target": + [ + 0, 0.16, + 1000, 0.165, + 10000, 0.17 + ] + } + }, + { + "rpi.alsc": + { + "omega": 1.3, + "n_iter": 100, + "luminance_strength": 0.7 + } + }, + { + "rpi.contrast": + { + "ce_enable": 1, + "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 + ] + } + }, + { + "rpi.sharpen": { } + } + ] +} diff --git a/src/ipa/rpi/vc4/data/meson.build b/src/ipa/rpi/vc4/data/meson.build index afbf875a113a..a3198b57c141 100644 --- a/src/ipa/rpi/vc4/data/meson.build +++ b/src/ipa/rpi/vc4/data/meson.build @@ -11,6 +11,8 @@ conf_files = files([ 'imx477_noir.json', 'imx477_scientific.json', 'imx519.json', + 'imx585.json', + 'imx585_mono.json', 'imx708.json', 'imx708_noir.json', 'imx708_wide.json', diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp index 4e5217ab51ef..86c8576e319c 100644 --- a/src/libcamera/sensor/camera_sensor_properties.cpp +++ b/src/libcamera/sensor/camera_sensor_properties.cpp @@ -148,6 +148,10 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen */ }, } }, + { "imx585", { + .unitCellSize = { 2900, 2900 }, + .testPatternModes = {}, + } }, { "imx708", { .unitCellSize = { 1400, 1400 }, .testPatternModes = {