···114114to dynamically modify values such as black level, cross talk corrections115115and others.116116117117-The buffer format is defined by struct :c:type:`rkisp1_params_cfg`, and118118-userspace should set117117+The ISP driver supports two different parameters configuration methods, the118118+`fixed parameters format` or the `extensible parameters format`.119119+120120+When using the `fixed parameters` method the buffer format is defined by struct121121+:c:type:`rkisp1_params_cfg`, and userspace should set119122:ref:`V4L2_META_FMT_RK_ISP1_PARAMS <v4l2-meta-fmt-rk-isp1-params>` as the120123dataformat.121124125125+When using the `extensible parameters` method the buffer format is defined by126126+struct :c:type:`rkisp1_ext_params_cfg`, and userspace should set127127+:ref:`V4L2_META_FMT_RK_ISP1_EXT_PARAMS <v4l2-meta-fmt-rk-isp1-ext-params>` as128128+the dataformat.122129123130Capturing Video Frames Example124131==============================
···11.. SPDX-License-Identifier: GPL-2.02233-.. _v4l2-meta-fmt-rk-isp1-params:44-53.. _v4l2-meta-fmt-rk-isp1-stat-3a:6477-*****************************************************************************88-V4L2_META_FMT_RK_ISP1_PARAMS ('rk1p'), V4L2_META_FMT_RK_ISP1_STAT_3A ('rk1s')99-*****************************************************************************55+************************************************************************************************************************66+V4L2_META_FMT_RK_ISP1_PARAMS ('rk1p'), V4L2_META_FMT_RK_ISP1_STAT_3A ('rk1s'), V4L2_META_FMT_RK_ISP1_EXT_PARAMS ('rk1e')77+************************************************************************************************************************10899+========================1110Configuration parameters1211========================13121414-The configuration parameters are passed to the1313+The configuration of the RkISP1 ISP is performed by userspace by providing1414+parameters for the ISP to the driver using the :c:type:`v4l2_meta_format`1515+interface.1616+1717+There are two methods that allow to configure the ISP, the `fixed parameters`1818+configuration format and the `extensible parameters` configuration1919+format.2020+2121+.. _v4l2-meta-fmt-rk-isp1-params:2222+2323+Fixed parameters configuration format2424+=====================================2525+2626+When using the fixed configuration format, parameters are passed to the1527:ref:`rkisp1_params <rkisp1_params>` metadata output video node, using1616-the :c:type:`v4l2_meta_format` interface. The buffer contains1717-a single instance of the C structure :c:type:`rkisp1_params_cfg` defined in1818-``rkisp1-config.h``. So the structure can be obtained from the buffer by:2828+the `V4L2_META_FMT_RK_ISP1_PARAMS` meta format.2929+3030+The buffer contains a single instance of the C structure3131+:c:type:`rkisp1_params_cfg` defined in ``rkisp1-config.h``. So the structure can3232+be obtained from the buffer by:19332034.. code-block:: c21352236 struct rkisp1_params_cfg *params = (struct rkisp1_params_cfg*) buffer;23373838+This method supports a subset of the ISP features only, new applications should3939+use the extensible parameters method.4040+4141+.. _v4l2-meta-fmt-rk-isp1-ext-params:4242+4343+Extensible parameters configuration format4444+==========================================4545+4646+When using the extensible configuration format, parameters are passed to the4747+:ref:`rkisp1_params <rkisp1_params>` metadata output video node, using4848+the `V4L2_META_FMT_RK_ISP1_EXT_PARAMS` meta format.4949+5050+The buffer contains a single instance of the C structure5151+:c:type:`rkisp1_ext_params_cfg` defined in ``rkisp1-config.h``. The5252+:c:type:`rkisp1_ext_params_cfg` structure is designed to allow userspace to5353+populate the data buffer with only the configuration data for the ISP blocks it5454+intends to configure. The extensible parameters format design allows developers5555+to define new block types to support new configuration parameters, and defines a5656+versioning scheme so that it can be extended and versioned without breaking5757+compatibility with existing applications.5858+5959+For these reasons, this configuration method is preferred over the `fixed6060+parameters` format alternative.6161+2462.. rkisp1_stat_buffer25636464+===========================26653A and histogram statistics2766===========================2867
···3333#define RKISP1_ISP_SD_SRC BIT(0)3434#define RKISP1_ISP_SD_SINK BIT(1)35353636-/* min and max values for the widths and heights of the entities */3737-#define RKISP1_ISP_MAX_WIDTH 40323838-#define RKISP1_ISP_MAX_HEIGHT 30243636+/*3737+ * Minimum values for the width and height of entities. The maximum values are3838+ * model-specific and stored in the rkisp1_info structure.3939+ */3940#define RKISP1_ISP_MIN_WIDTH 324041#define RKISP1_ISP_MIN_HEIGHT 324142···116115 * @RKISP1_FEATURE_SELF_PATH: The ISP has a self path117116 * @RKISP1_FEATURE_DUAL_CROP: The ISP has the dual crop block at the resizer input118117 * @RKISP1_FEATURE_DMA_34BIT: The ISP uses 34-bit DMA addresses118118+ * @RKISP1_FEATURE_BLS: The ISP has a dedicated BLS block119119+ * @RKISP1_FEATURE_COMPAND: The ISP has a companding block119120 *120121 * The ISP features are stored in a bitmask in &rkisp1_info.features and allow121122 * the driver to implement support for features present in some ISP versions···129126 RKISP1_FEATURE_SELF_PATH = BIT(2),130127 RKISP1_FEATURE_DUAL_CROP = BIT(3),131128 RKISP1_FEATURE_DMA_34BIT = BIT(4),129129+ RKISP1_FEATURE_BLS = BIT(5),130130+ RKISP1_FEATURE_COMPAND = BIT(6),132131};133132134133#define rkisp1_has_feature(rkisp1, feature) \···145140 * @isr_size: number of entries in the @isrs array146141 * @isp_ver: ISP version147142 * @features: bitmask of rkisp1_feature features implemented by the ISP143143+ * @max_width: maximum input frame width144144+ * @max_height: maximum input frame height148145 *149146 * This structure contains information about the ISP specific to a particular150147 * ISP model, version, or integration in a particular SoC.···158151 unsigned int isr_size;159152 enum rkisp1_cif_isp_version isp_ver;160153 unsigned int features;154154+ unsigned int max_width;155155+ unsigned int max_height;161156};162157163158/*···241232242233/*243234 * struct rkisp1_buffer - A container for the vb2 buffers used by the video devices:244244- * params, stats, mainpath, selfpath235235+ * stats, mainpath, selfpath245236 *246237 * @vb: vb2 buffer247238 * @queue: entry of the buffer in the queue···252243 struct list_head queue;253244 dma_addr_t buff_addr[VIDEO_MAX_PLANES];254245};246246+247247+/*248248+ * struct rkisp1_params_buffer - A container for the vb2 buffers used by the249249+ * params video device250250+ *251251+ * @vb: vb2 buffer252252+ * @queue: entry of the buffer in the queue253253+ * @cfg: scratch buffer used for caching the ISP configuration parameters254254+ */255255+struct rkisp1_params_buffer {256256+ struct vb2_v4l2_buffer vb;257257+ struct list_head queue;258258+ void *cfg;259259+};260260+261261+static inline struct rkisp1_params_buffer *262262+to_rkisp1_params_buffer(struct vb2_v4l2_buffer *vbuf)263263+{264264+ return container_of(vbuf, struct rkisp1_params_buffer, vb);265265+}255266256267/*257268 * struct rkisp1_dummy_buffer - A buffer to write the next frame to in case···401372 * @ops: pointer to the variant-specific operations402373 * @config_lock: locks the buffer list 'params'403374 * @params: queue of rkisp1_buffer404404- * @vdev_fmt: v4l2_format of the metadata format375375+ * @metafmt the currently enabled metadata format405376 * @quantization: the quantization configured on the isp's src pad377377+ * @ycbcr_encoding the YCbCr encoding406378 * @raw_type: the bayer pattern on the isp video sink pad379379+ * @enabled_blocks: bitmask of enabled ISP blocks407380 */408381struct rkisp1_params {409382 struct rkisp1_vdev_node vnode;···414383415384 spinlock_t config_lock; /* locks the buffers list 'params' */416385 struct list_head params;417417- struct v4l2_format vdev_fmt;386386+387387+ const struct v4l2_meta_format *metafmt;418388419389 enum v4l2_quantization quantization;420390 enum v4l2_ycbcr_encoding ycbcr_encoding;421391 enum rkisp1_fmt_raw_pat_type raw_type;392392+393393+ u32 enabled_blocks;422394};423395424396/*···606572 */607573void rkisp1_sd_adjust_crop(struct v4l2_rect *crop,608574 const struct v4l2_mbus_framefmt *bounds);575575+576576+void rkisp1_bls_swap_regs(enum rkisp1_fmt_raw_pat_type pattern,577577+ const u32 input[4], u32 output[4]);609578610579/*611580 * rkisp1_mbus_info_get_by_code - get the isp info of the media bus code
···494494495495 sink_fmt->width = clamp_t(u32, format->width,496496 RKISP1_ISP_MIN_WIDTH,497497- RKISP1_ISP_MAX_WIDTH);497497+ rsz->rkisp1->info->max_width);498498 sink_fmt->height = clamp_t(u32, format->height,499499 RKISP1_ISP_MIN_HEIGHT,500500- RKISP1_ISP_MAX_HEIGHT);500500+ rsz->rkisp1->info->max_height);501501502502 /*503503 * Adjust the color space fields. Accept any color primaries and