[{"id":15189,"web_url":"https://patchwork.libcamera.org/comment/15189/","msgid":"<20210217084909.GC1786@pyrite.rasen.tech>","date":"2021-02-17T08:49:09","subject":"Re: [libcamera-devel] [PATCH 3/3] ipa: rkisp1: update the uapi to\n\tthe latest kernel version","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Dafna,\n\nOn Tue, Feb 16, 2021 at 01:26:24PM +0100, Dafna Hirschfeld wrote:\n> In kernel 5.11 the rkisp1 uapi had changed to support\n> different hardware versions. This patch updates the\n> uapi header and adds support to hardware version 10 only.\n> In the future, support to other version will be added.\n\ns/to/for\n\n> \n> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>\n> ---\n>  include/libcamera/ipa/rkisp1.mojom       |  2 +-\n>  include/linux/rkisp1-config.h            | 88 +++++++++++++++++++++---\n>  src/ipa/rkisp1/rkisp1.cpp                | 16 +++--\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp |  3 +-\n>  4 files changed, 92 insertions(+), 17 deletions(-)\n> \n> diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom\n> index 95fa0d93..b097fc8f 100644\n> --- a/include/libcamera/ipa/rkisp1.mojom\n> +++ b/include/libcamera/ipa/rkisp1.mojom\n> @@ -29,7 +29,7 @@ interface IPARkISP1Interface {\n>  \tstart() => (int32 ret);\n>  \tstop();\n>  \n> -\tconfigure(CameraSensorInfo sensorInfo,\n> +\tconfigure(uint32 hwRevision, CameraSensorInfo sensorInfo,\n>  \t\t  map<uint32, IPAStream> streamConfig,\n>  \t\t  map<uint32, ControlInfoMap> entityControls) => (int32 ret);\n>  \n> diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h\n> index 9c24867d..3bccccbc 100644\n> --- a/include/linux/rkisp1-config.h\n> +++ b/include/linux/rkisp1-config.h\n> @@ -1,4 +1,4 @@\n> -/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */\n> +/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR MIT) */\n>  /*\n>   * Rockchip ISP1 userspace API\n>   * Copyright (C) 2017 Rockchip Electronics Co., Ltd.\n> @@ -53,8 +53,14 @@\n>  #define RKISP1_CIF_ISP_CTK_COEFF_MAX            0x100\n>  #define RKISP1_CIF_ISP_CTK_OFFSET_MAX           0x800\n>  \n> -#define RKISP1_CIF_ISP_AE_MEAN_MAX              25\n> -#define RKISP1_CIF_ISP_HIST_BIN_N_MAX           16\n> +#define RKISP1_CIF_ISP_AE_MEAN_MAX_V10\t\t25\n> +#define RKISP1_CIF_ISP_AE_MEAN_MAX_V12\t\t81\n> +#define RKISP1_CIF_ISP_AE_MEAN_MAX\t\tRKISP1_CIF_ISP_AE_MEAN_MAX_V12\n> +\n> +#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10\t16\n> +#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12\t32\n> +#define RKISP1_CIF_ISP_HIST_BIN_N_MAX\t\tRKISP1_CIF_ISP_HIST_BIN_N_MAX_V12\n> +\n>  #define RKISP1_CIF_ISP_AFM_MAX_WINDOWS          3\n>  #define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE       17\n>  \n> @@ -90,7 +96,9 @@\n>   * Gamma out\n>   */\n>  /* Maximum number of color samples supported */\n> -#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       17\n> +#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10   17\n> +#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12   34\n> +#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12\n>  \n>  /*\n>   * Lens shade correction\n> @@ -106,8 +114,9 @@\n>  /*\n>   * Histogram calculation\n>   */\n> -/* Last 3 values unused. */\n> -#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 28\n> +#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 25\n> +#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81\n> +#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE     RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12\n>  \n>  /*\n>   * Defect Pixel Cluster Correction\n> @@ -128,6 +137,21 @@\n>  #define RKISP1_CIF_ISP_STAT_AFM           (1U << 2)\n>  #define RKISP1_CIF_ISP_STAT_HIST          (1U << 3)\n>  \n> +/**\n> + * enum rkisp1_cif_isp_version - ISP variants\n> + *\n> + * @RKISP1_V10: used at least in rk3288 and rk3399\n> + * @RKISP1_V11: declared in the original vendor code, but not used\n> + * @RKISP1_V12: used at least in rk3326 and px30\n> + * @RKISP1_V13: used at least in rk1808\n> + */\n> +enum rkisp1_cif_isp_version {\n> +\tRKISP1_V10 = 10,\n> +\tRKISP1_V11,\n> +\tRKISP1_V12,\n> +\tRKISP1_V13,\n> +};\n> +\n>  enum rkisp1_cif_isp_histogram_mode {\n>  \tRKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,\n>  \tRKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,\n> @@ -514,6 +538,15 @@ enum rkisp1_cif_isp_goc_mode {\n>   *\n>   * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode)\n>   * @gamma_y: gamma out curve y-axis for all color components\n> + *\n> + * The number of entries of @gamma_y depends on the hardware revision\n> + * as is reported by the hw_revision field of the struct media_device_info\n> + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.\n> + *\n> + * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10\n> + * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12\n> + * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum\n> + * of the two.\n>   */\n>  struct rkisp1_cif_isp_goc_config {\n>  \t__u32 mode;\n> @@ -528,6 +561,15 @@ struct rkisp1_cif_isp_goc_config {\n>   *\t\t\t  skipped\n>   * @meas_window: coordinates of the measure window\n>   * @hist_weight: weighting factor for sub-windows\n> + *\n> + * The number of entries of @hist_weight depends on the hardware revision\n> + * as is reported by the hw_revision field of the struct media_device_info\n> + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.\n> + *\n> + * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10\n> + * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12\n> + * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum\n> + * of the two.\n>   */\n>  struct rkisp1_cif_isp_hst_config {\n>  \t__u32 mode;\n> @@ -815,7 +857,15 @@ struct rkisp1_cif_isp_bls_meas_val {\n>   * @exp_mean: Mean luminance value of block xx\n>   * @bls_val:  BLS measured values\n>   *\n> - * Image is divided into 5x5 blocks.\n> + * The number of entries of @exp_mean depends on the hardware revision\n> + * as is reported by the hw_revision field of the struct media_device_info\n> + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.\n> + *\n> + * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,\n> + * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.\n> + * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.\n> + *\n> + * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.\n>   */\n>  struct rkisp1_cif_isp_ae_stat {\n>  \t__u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX];\n> @@ -848,13 +898,29 @@ struct rkisp1_cif_isp_af_stat {\n>  /**\n>   * struct rkisp1_cif_isp_hist_stat - statistics histogram data\n>   *\n> - * @hist_bins: measured bin counters\n> + * @hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point\n> + *\t       type. Bits 0-4 are the fractional part and bits 5-19 are the\n> + *\t       integer part.\n> + *\n> + * The window of the measurements area is divided to 5x5 sub-windows for\n> + * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for\n> + * each sub-window independently and the final result is a weighted average of\n> + * the histogram measurements on all sub-windows. The window of the\n> + * measurements area and the weight of each sub-window are configurable using\n> + * struct @rkisp1_cif_isp_hst_config.\n> + *\n> + * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.\n> + *\n> + * The number of entries of @hist_bins depends on the hardware revision\n> + * as is reported by the hw_revision field of the struct media_device_info\n> + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.\n>   *\n> - * Measurement window divided into 25 sub-windows, set\n> - * with ISP_HIST_XXX\n> + * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,\n> + * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.\n> + * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.\n>   */\n>  struct rkisp1_cif_isp_hist_stat {\n> -\t__u16 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];\n> +\t__u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];\n>  };\n>  \n>  /**\n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index b0641faf..a3ba3dcd 100644\n> --- a/src/ipa/rkisp1/rkisp1.cpp\n> +++ b/src/ipa/rkisp1/rkisp1.cpp\n> @@ -38,7 +38,7 @@ public:\n>  \tint start() override { return 0; }\n>  \tvoid stop() override {}\n>  \n> -\tint configure(const CameraSensorInfo &info,\n> +\tint configure(uint32_t hwRevision, const CameraSensorInfo &info,\n>  \t\t       const std::map<uint32_t, IPAStream> &streamConfig,\n>  \t\t       const std::map<uint32_t, ControlInfoMap> &entityControls) override;\n>  \tvoid mapBuffers(const std::vector<IPABuffer> &buffers) override;\n> @@ -75,10 +75,17 @@ private:\n>   * assemble one. Make sure the reported sensor information are relevant\n>   * before accessing them.\n>   */\n> -int IPARkISP1::configure([[maybe_unused]] const CameraSensorInfo &info,\n> +int IPARkISP1::configure(uint32_t hwRevision, [[maybe_unused]] const CameraSensorInfo &info,\n>  \t\t\t  [[maybe_unused]] const std::map<uint32_t, IPAStream> &streamConfig,\n>  \t\t\t  const std::map<uint32_t, ControlInfoMap> &entityControls)\n>  {\n> +\t/* \\todo add support to other revisions */\n\ns/to/for\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> +\tif (hwRevision != RKISP1_V10) {\n> +\t\tLOG(IPARkISP1, Error) << \"Hardware version \" << hwRevision << \" is currently\"\n> +\t\t\t\t      << \" not supported\";\n> +\t\treturn -1;\n> +\t}\n> +\n>  \tif (entityControls.empty())\n>  \t\treturn -1;\n>  \n> @@ -107,7 +114,8 @@ int IPARkISP1::configure([[maybe_unused]] const CameraSensorInfo &info,\n>  \tgain_ = minGain_;\n>  \n>  \tLOG(IPARkISP1, Info)\n> -\t\t<< \"Exposure: \" << minExposure_ << \"-\" << maxExposure_\n> +\t\t<< \"Hw Revision: \" hwRevision <<\n> +\t\t<< \" Exposure: \" << minExposure_ << \"-\" << maxExposure_\n>  \t\t<< \" Gain: \" << minGain_ << \"-\" << maxGain_;\n>  \n>  \tsetControls(0);\n> @@ -217,7 +225,7 @@ void IPARkISP1::updateStatistics(unsigned int frame,\n>  \n>  \t\tunsigned int value = 0;\n>  \t\tunsigned int num = 0;\n> -\t\tfor (int i = 0; i < RKISP1_CIF_ISP_AE_MEAN_MAX; i++) {\n> +\t\tfor (int i = 0; i < RKISP1_CIF_ISP_AE_MEAN_MAX_V10; i++) {\n>  \t\t\tif (ae->exp_mean[i] <= 15)\n>  \t\t\t\tcontinue;\n>  \n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index dad8e5d4..32158519 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -653,7 +653,8 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n>  \tstd::map<uint32_t, ControlInfoMap> entityControls;\n>  \tentityControls.emplace(0, data->sensor_->controls());\n>  \n> -\tret = data->ipa_->configure(sensorInfo, streamConfig, entityControls);\n> +\tret = data->ipa_->configure(media_->hwRevision(), sensorInfo,\n> +\t\t\t\t    streamConfig, entityControls);\n>  \tif (ret) {\n>  \t\tLOG(RkISP1, Error) << \"failed configuring IPA (\" << ret << \")\";\n>  \t\treturn ret;\n> -- \n> 2.17.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 95D0FBD1F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 17 Feb 2021 08:49:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 276E6637F8;\n\tWed, 17 Feb 2021 09:49:20 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F94D637F2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Feb 2021 09:49:18 +0100 (CET)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0258B8C4;\n\tWed, 17 Feb 2021 09:49:14 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"sp3PCcTT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1613551758;\n\tbh=z5Q/Q6EXZo7dHh9fOQeWy70F85tdKE93tjZ0qvAQpI8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=sp3PCcTTGccQxzCj39B2u8aSwIqs8da1Ll59bpy6J9C4gBtWpGJ104h5Vce59qObB\n\tsMb4pTF/ff0g3PVO4Tq60iPvAfEGOPH/Si0A7LVsxAjDAQAeBjR/nvtc3xHRNziq4I\n\tecdkxTijhMvZFNzU9n91md4On5ZPcEzqxGL4vaAg=","Date":"Wed, 17 Feb 2021 17:49:09 +0900","From":"paul.elder@ideasonboard.com","To":"Dafna Hirschfeld <dafna.hirschfeld@collabora.com>","Message-ID":"<20210217084909.GC1786@pyrite.rasen.tech>","References":"<20210216122624.27940-1-dafna.hirschfeld@collabora.com>\n\t<20210216122624.27940-4-dafna.hirschfeld@collabora.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210216122624.27940-4-dafna.hirschfeld@collabora.com>","Subject":"Re: [libcamera-devel] [PATCH 3/3] ipa: rkisp1: update the uapi to\n\tthe latest kernel version","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org, kernel@collabora.com","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15208,"web_url":"https://patchwork.libcamera.org/comment/15208/","msgid":"<ac90773c-7285-6f2e-554a-5ac04696e865@collabora.com>","date":"2021-02-17T18:13:28","subject":"Re: [libcamera-devel] [PATCH 3/3] ipa: rkisp1: update the uapi to\n\tthe latest kernel version","submitter":{"id":46,"url":"https://patchwork.libcamera.org/api/people/46/","name":"Dafna Hirschfeld","email":"dafna.hirschfeld@collabora.com"},"content":"On 17.02.21 09:49, paul.elder@ideasonboard.com wrote:\n> Hi Dafna,\n> \n> On Tue, Feb 16, 2021 at 01:26:24PM +0100, Dafna Hirschfeld wrote:\n>> In kernel 5.11 the rkisp1 uapi had changed to support\n>> different hardware versions. This patch updates the\n>> uapi header and adds support to hardware version 10 only.\n>> In the future, support to other version will be added.\n> \n> s/to/for\n> \n>>\n>> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>\n>> ---\n>>   include/libcamera/ipa/rkisp1.mojom       |  2 +-\n>>   include/linux/rkisp1-config.h            | 88 +++++++++++++++++++++---\n>>   src/ipa/rkisp1/rkisp1.cpp                | 16 +++--\n>>   src/libcamera/pipeline/rkisp1/rkisp1.cpp |  3 +-\n>>   4 files changed, 92 insertions(+), 17 deletions(-)\n>>\n>> diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom\n>> index 95fa0d93..b097fc8f 100644\n>> --- a/include/libcamera/ipa/rkisp1.mojom\n>> +++ b/include/libcamera/ipa/rkisp1.mojom\n>> @@ -29,7 +29,7 @@ interface IPARkISP1Interface {\n>>   \tstart() => (int32 ret);\n>>   \tstop();\n>>   \n>> -\tconfigure(CameraSensorInfo sensorInfo,\n>> +\tconfigure(uint32 hwRevision, CameraSensorInfo sensorInfo,\n>>   \t\t  map<uint32, IPAStream> streamConfig,\n>>   \t\t  map<uint32, ControlInfoMap> entityControls) => (int32 ret);\n>>   \n>> diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h\n>> index 9c24867d..3bccccbc 100644\n>> --- a/include/linux/rkisp1-config.h\n>> +++ b/include/linux/rkisp1-config.h\n>> @@ -1,4 +1,4 @@\n>> -/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */\n>> +/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR MIT) */\n>>   /*\n>>    * Rockchip ISP1 userspace API\n>>    * Copyright (C) 2017 Rockchip Electronics Co., Ltd.\n>> @@ -53,8 +53,14 @@\n>>   #define RKISP1_CIF_ISP_CTK_COEFF_MAX            0x100\n>>   #define RKISP1_CIF_ISP_CTK_OFFSET_MAX           0x800\n>>   \n>> -#define RKISP1_CIF_ISP_AE_MEAN_MAX              25\n>> -#define RKISP1_CIF_ISP_HIST_BIN_N_MAX           16\n>> +#define RKISP1_CIF_ISP_AE_MEAN_MAX_V10\t\t25\n>> +#define RKISP1_CIF_ISP_AE_MEAN_MAX_V12\t\t81\n>> +#define RKISP1_CIF_ISP_AE_MEAN_MAX\t\tRKISP1_CIF_ISP_AE_MEAN_MAX_V12\n>> +\n>> +#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10\t16\n>> +#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12\t32\n>> +#define RKISP1_CIF_ISP_HIST_BIN_N_MAX\t\tRKISP1_CIF_ISP_HIST_BIN_N_MAX_V12\n>> +\n>>   #define RKISP1_CIF_ISP_AFM_MAX_WINDOWS          3\n>>   #define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE       17\n>>   \n>> @@ -90,7 +96,9 @@\n>>    * Gamma out\n>>    */\n>>   /* Maximum number of color samples supported */\n>> -#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       17\n>> +#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10   17\n>> +#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12   34\n>> +#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12\n>>   \n>>   /*\n>>    * Lens shade correction\n>> @@ -106,8 +114,9 @@\n>>   /*\n>>    * Histogram calculation\n>>    */\n>> -/* Last 3 values unused. */\n>> -#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 28\n>> +#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 25\n>> +#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81\n>> +#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE     RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12\n>>   \n>>   /*\n>>    * Defect Pixel Cluster Correction\n>> @@ -128,6 +137,21 @@\n>>   #define RKISP1_CIF_ISP_STAT_AFM           (1U << 2)\n>>   #define RKISP1_CIF_ISP_STAT_HIST          (1U << 3)\n>>   \n>> +/**\n>> + * enum rkisp1_cif_isp_version - ISP variants\n>> + *\n>> + * @RKISP1_V10: used at least in rk3288 and rk3399\n>> + * @RKISP1_V11: declared in the original vendor code, but not used\n>> + * @RKISP1_V12: used at least in rk3326 and px30\n>> + * @RKISP1_V13: used at least in rk1808\n>> + */\n>> +enum rkisp1_cif_isp_version {\n>> +\tRKISP1_V10 = 10,\n>> +\tRKISP1_V11,\n>> +\tRKISP1_V12,\n>> +\tRKISP1_V13,\n>> +};\n>> +\n>>   enum rkisp1_cif_isp_histogram_mode {\n>>   \tRKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,\n>>   \tRKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,\n>> @@ -514,6 +538,15 @@ enum rkisp1_cif_isp_goc_mode {\n>>    *\n>>    * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode)\n>>    * @gamma_y: gamma out curve y-axis for all color components\n>> + *\n>> + * The number of entries of @gamma_y depends on the hardware revision\n>> + * as is reported by the hw_revision field of the struct media_device_info\n>> + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.\n>> + *\n>> + * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10\n>> + * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12\n>> + * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum\n>> + * of the two.\n>>    */\n>>   struct rkisp1_cif_isp_goc_config {\n>>   \t__u32 mode;\n>> @@ -528,6 +561,15 @@ struct rkisp1_cif_isp_goc_config {\n>>    *\t\t\t  skipped\n>>    * @meas_window: coordinates of the measure window\n>>    * @hist_weight: weighting factor for sub-windows\n>> + *\n>> + * The number of entries of @hist_weight depends on the hardware revision\n>> + * as is reported by the hw_revision field of the struct media_device_info\n>> + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.\n>> + *\n>> + * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10\n>> + * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12\n>> + * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum\n>> + * of the two.\n>>    */\n>>   struct rkisp1_cif_isp_hst_config {\n>>   \t__u32 mode;\n>> @@ -815,7 +857,15 @@ struct rkisp1_cif_isp_bls_meas_val {\n>>    * @exp_mean: Mean luminance value of block xx\n>>    * @bls_val:  BLS measured values\n>>    *\n>> - * Image is divided into 5x5 blocks.\n>> + * The number of entries of @exp_mean depends on the hardware revision\n>> + * as is reported by the hw_revision field of the struct media_device_info\n>> + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.\n>> + *\n>> + * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,\n>> + * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.\n>> + * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.\n>> + *\n>> + * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.\n>>    */\n>>   struct rkisp1_cif_isp_ae_stat {\n>>   \t__u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX];\n>> @@ -848,13 +898,29 @@ struct rkisp1_cif_isp_af_stat {\n>>   /**\n>>    * struct rkisp1_cif_isp_hist_stat - statistics histogram data\n>>    *\n>> - * @hist_bins: measured bin counters\n>> + * @hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point\n>> + *\t       type. Bits 0-4 are the fractional part and bits 5-19 are the\n>> + *\t       integer part.\n>> + *\n>> + * The window of the measurements area is divided to 5x5 sub-windows for\n>> + * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for\n>> + * each sub-window independently and the final result is a weighted average of\n>> + * the histogram measurements on all sub-windows. The window of the\n>> + * measurements area and the weight of each sub-window are configurable using\n>> + * struct @rkisp1_cif_isp_hst_config.\n>> + *\n>> + * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.\n>> + *\n>> + * The number of entries of @hist_bins depends on the hardware revision\n>> + * as is reported by the hw_revision field of the struct media_device_info\n>> + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.\n>>    *\n>> - * Measurement window divided into 25 sub-windows, set\n>> - * with ISP_HIST_XXX\n>> + * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,\n>> + * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.\n>> + * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.\n>>    */\n>>   struct rkisp1_cif_isp_hist_stat {\n>> -\t__u16 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];\n>> +\t__u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];\n>>   };\n>>   \n>>   /**\n>> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n>> index b0641faf..a3ba3dcd 100644\n>> --- a/src/ipa/rkisp1/rkisp1.cpp\n>> +++ b/src/ipa/rkisp1/rkisp1.cpp\n>> @@ -38,7 +38,7 @@ public:\n>>   \tint start() override { return 0; }\n>>   \tvoid stop() override {}\n>>   \n>> -\tint configure(const CameraSensorInfo &info,\n>> +\tint configure(uint32_t hwRevision, const CameraSensorInfo &info,\n>>   \t\t       const std::map<uint32_t, IPAStream> &streamConfig,\n>>   \t\t       const std::map<uint32_t, ControlInfoMap> &entityControls) override;\n>>   \tvoid mapBuffers(const std::vector<IPABuffer> &buffers) override;\n>> @@ -75,10 +75,17 @@ private:\n>>    * assemble one. Make sure the reported sensor information are relevant\n>>    * before accessing them.\n>>    */\n>> -int IPARkISP1::configure([[maybe_unused]] const CameraSensorInfo &info,\n>> +int IPARkISP1::configure(uint32_t hwRevision, [[maybe_unused]] const CameraSensorInfo &info,\n>>   \t\t\t  [[maybe_unused]] const std::map<uint32_t, IPAStream> &streamConfig,\n>>   \t\t\t  const std::map<uint32_t, ControlInfoMap> &entityControls)\n>>   {\n>> +\t/* \\todo add support to other revisions */\n> \n> s/to/for\n> \n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n>> +\tif (hwRevision != RKISP1_V10) {\n>> +\t\tLOG(IPARkISP1, Error) << \"Hardware version \" << hwRevision << \" is currently\"\n>> +\t\t\t\t      << \" not supported\";\n>> +\t\treturn -1;\n>> +\t}\n>> +\n>>   \tif (entityControls.empty())\n>>   \t\treturn -1;\n>>   \n>> @@ -107,7 +114,8 @@ int IPARkISP1::configure([[maybe_unused]] const CameraSensorInfo &info,\n>>   \tgain_ = minGain_;\n>>   \n>>   \tLOG(IPARkISP1, Info)\n>> -\t\t<< \"Exposure: \" << minExposure_ << \"-\" << maxExposure_\n>> +\t\t<< \"Hw Revision: \" hwRevision <<\n\noops, this does not compile (missing a '<<'),  it should be replaced with:\n\t\t<< \"Hw Revision: \" << hwRevision <<\n\nThanks,\nDafna\n\n\n>> +\t\t<< \" Exposure: \" << minExposure_ << \"-\" << maxExposure_\n>>   \t\t<< \" Gain: \" << minGain_ << \"-\" << maxGain_;\n>>   \n>>   \tsetControls(0);\n>> @@ -217,7 +225,7 @@ void IPARkISP1::updateStatistics(unsigned int frame,\n>>   \n>>   \t\tunsigned int value = 0;\n>>   \t\tunsigned int num = 0;\n>> -\t\tfor (int i = 0; i < RKISP1_CIF_ISP_AE_MEAN_MAX; i++) {\n>> +\t\tfor (int i = 0; i < RKISP1_CIF_ISP_AE_MEAN_MAX_V10; i++) {\n>>   \t\t\tif (ae->exp_mean[i] <= 15)\n>>   \t\t\t\tcontinue;\n>>   \n>> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n>> index dad8e5d4..32158519 100644\n>> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n>> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n>> @@ -653,7 +653,8 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n>>   \tstd::map<uint32_t, ControlInfoMap> entityControls;\n>>   \tentityControls.emplace(0, data->sensor_->controls());\n>>   \n>> -\tret = data->ipa_->configure(sensorInfo, streamConfig, entityControls);\n>> +\tret = data->ipa_->configure(media_->hwRevision(), sensorInfo,\n>> +\t\t\t\t    streamConfig, entityControls);\n>>   \tif (ret) {\n>>   \t\tLOG(RkISP1, Error) << \"failed configuring IPA (\" << ret << \")\";\n>>   \t\treturn ret;\n>> -- \n>> 2.17.1\n>>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 31C53BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 17 Feb 2021 18:13:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7E4FC6381E;\n\tWed, 17 Feb 2021 19:13:32 +0100 (CET)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 548D1637FF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Feb 2021 19:13:31 +0100 (CET)","from [IPv6:2003:c7:cf1c:ce00:4dda:edd1:21fe:7506]\n\t(p200300c7cf1cce004ddaedd121fe7506.dip0.t-ipconnect.de\n\t[IPv6:2003:c7:cf1c:ce00:4dda:edd1:21fe:7506])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits))\n\t(No client certificate requested) (Authenticated sender: dafna)\n\tby bhuna.collabora.co.uk (Postfix) with ESMTPSA id C5C451F45514;\n\tWed, 17 Feb 2021 18:13:30 +0000 (GMT)"],"To":"paul.elder@ideasonboard.com","References":"<20210216122624.27940-1-dafna.hirschfeld@collabora.com>\n\t<20210216122624.27940-4-dafna.hirschfeld@collabora.com>\n\t<20210217084909.GC1786@pyrite.rasen.tech>","From":"Dafna Hirschfeld <dafna.hirschfeld@collabora.com>","Message-ID":"<ac90773c-7285-6f2e-554a-5ac04696e865@collabora.com>","Date":"Wed, 17 Feb 2021 19:13:28 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<20210217084909.GC1786@pyrite.rasen.tech>","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH 3/3] ipa: rkisp1: update the uapi to\n\tthe latest kernel version","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org, kernel@collabora.com","Content-Transfer-Encoding":"7bit","Content-Type":"text/plain; charset=\"us-ascii\"; Format=\"flowed\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]