History

media: uapi: Convert RkISP1 to V4L2 extensible params

With the introduction of common types for extensible parameters format, convert the rkisp1-config.h header to use the new types. Factor out the documentation that is now part of the common header and only keep the driver-specific on in place. The conversion to use common types doesn't impact userspace as the new types are either identical to the ones already existing in the RkISP1 uAPI or are 1-to-1 type convertible.

Jacopo Mondi committed 1 year ago

Commit 1e8152d1 parent e36dbd11 file · +24 −83Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/rkisp1-config.h+24−83
@@ -7,8 +7,13 @@ · 6 unmodified lines
77 #ifndef _UAPI_RKISP1_CONFIG_H
88 #define _UAPI_RKISP1_CONFIG_H
99
10+#ifdef __KERNEL__
11+#include <linux/build_bug.h>
12+#endif /* __KERNEL__ */
1013 #include <linux/types.h>
1114
15+#include <linux/media/v4l2-isp.h>
16+
1217 /* Defect Pixel Cluster Detection */
1318 #define RKISP1_CIF_ISP_MODULE_DPCC (1U << 0)
1419 /* Black Level Subtraction */
@@ -1158,79 +1163,26 @@ enum rkisp1_ext_params_block_type { · 1143 unmodified lines
11581163 RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR,
11591164 };
11601165
1161−#define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE (1U << 0)
1162−#define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE (1U << 1)
1166+/* For backward compatibility */
1167+#define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE V4L2_ISP_PARAMS_FL_BLOCK_DISABLE
1168+#define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE V4L2_ISP_PARAMS_FL_BLOCK_ENABLE
11631169
11641170 /* A bitmask of parameters blocks supported on the current hardware. */
11651171 #define RKISP1_CID_SUPPORTED_PARAMS_BLOCKS (V4L2_CID_USER_RKISP1_BASE + 0x01)
11661172
11671173 /**
1168− * struct rkisp1_ext_params_block_header - RkISP1 extensible parameters block
1169− * header
1174+ * rkisp1_ext_params_block_header - RkISP1 extensible parameters block header
11701175 *
11711176 * This structure represents the common part of all the ISP configuration
1172− * blocks. Each parameters block shall embed an instance of this structure type
1173− * as its first member, followed by the block-specific configuration data. The
1174− * driver inspects this common header to discern the block type and its size and
1175− * properly handle the block content by casting it to the correct block-specific
1176− * type.
1177+ * blocks and is identical to :c:type:`v4l2_isp_params_block_header`.
11771178 *
1178− * The @type field is one of the values enumerated by
1179+ * The type field is one of the values enumerated by
11791180 * :c:type:`rkisp1_ext_params_block_type` and specifies how the data should be
1180− * interpreted by the driver. The @size field specifies the size of the
1181− * parameters block and is used by the driver for validation purposes.
1182− *
1183− * The @flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*.
1184− *
1185− * When userspace wants to configure and enable an ISP block it shall fully
1186− * populate the block configuration and set the
1187− * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE bit in the @flags field.
1188− *
1189− * When userspace simply wants to disable an ISP block the
1190− * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bit should be set in @flags field. The
1191− * driver ignores the rest of the block configuration structure in this case.
1192− *
1193− * If a new configuration of an ISP block has to be applied userspace shall
1194− * fully populate the ISP block configuration and omit setting the
1195− * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits
1196− * in the @flags field.
1197− *
1198− * Setting both the RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and
1199− * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits in the @flags field is not allowed
1200− * and not accepted by the driver.
1201− *
1202− * Userspace is responsible for correctly populating the parameters block header
1203− * fields (@type, @flags and @size) and the block-specific parameters.
1204− *
1205− * For example:
1181+ * interpreted by the driver.
12061182 *
1207− * .. code-block:: c
1208− *
1209− * void populate_bls(struct rkisp1_ext_params_block_header *block) {
1210− * struct rkisp1_ext_params_bls_config *bls =
1211− * (struct rkisp1_ext_params_bls_config *)block;
1212− *
1213− * bls->header.type = RKISP1_EXT_PARAMS_BLOCK_ID_BLS;
1214− * bls->header.flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE;
1215− * bls->header.size = sizeof(*bls);
1216− *
1217− * bls->config.enable_auto = 0;
1218− * bls->config.fixed_val.r = blackLevelRed_;
1219− * bls->config.fixed_val.gr = blackLevelGreenR_;
1220− * bls->config.fixed_val.gb = blackLevelGreenB_;
1221− * bls->config.fixed_val.b = blackLevelBlue_;
1222− * }
1223− *
1224− * @type: The parameters block type, see
1225− * :c:type:`rkisp1_ext_params_block_type`
1226− * @flags: A bitmask of block flags
1227− * @size: Size (in bytes) of the parameters block, including this header
1183+ * The flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*.
12281184 */
1229−struct rkisp1_ext_params_block_header {
1230− __u16 type;
1231− __u16 flags;
1232− __u32 size;
1233−};
1185+#define rkisp1_ext_params_block_header v4l2_isp_params_block_header
12341186
12351187 /**
12361188 * struct rkisp1_ext_params_bls_config - RkISP1 extensible params BLS config
@@ -1588,27 +1540,14 @@ struct rkisp1_ext_params_wdr_config { · 351 unmodified lines
15881540 * @RKISP1_EXT_PARAM_BUFFER_V1: First version of RkISP1 extensible parameters
15891541 */
15901542 enum rksip1_ext_param_buffer_version {
1591− RKISP1_EXT_PARAM_BUFFER_V1 = 1,
1543+ RKISP1_EXT_PARAM_BUFFER_V1 = V4L2_ISP_PARAMS_VERSION_V1,
15921544 };
15931545
15941546 /**
15951547 * struct rkisp1_ext_params_cfg - RkISP1 extensible parameters configuration
15961548 *
1597− * This struct contains the configuration parameters of the RkISP1 ISP
1598− * algorithms, serialized by userspace into a data buffer. Each configuration
1599− * parameter block is represented by a block-specific structure which contains a
1600− * :c:type:`rkisp1_ext_params_block_header` entry as first member. Userspace
1601− * populates the @data buffer with configuration parameters for the blocks that
1602− * it intends to configure. As a consequence, the data buffer effective size
1603− * changes according to the number of ISP blocks that userspace intends to
1604− * configure and is set by userspace in the @data_size field.
1605− *
1606− * The parameters buffer is versioned by the @version field to allow modifying
1607− * and extending its definition. Userspace shall populate the @version field to
1608− * inform the driver about the version it intends to use. The driver will parse
1609− * and handle the @data buffer according to the data layout specific to the
1610− * indicated version and return an error if the desired version is not
1611− * supported.
1549+ * This is the driver-specific implementation of
1550+ * :c:type:`v4l2_isp_params_buffer`.
16121551 *
16131552 * Currently the single RKISP1_EXT_PARAM_BUFFER_V1 version is supported.
16141553 * When a new format version will be added, a mechanism for userspace to query
@@ -1624,11 +1563,6 @@ enum rksip1_ext_param_buffer_version { · 9 unmodified lines
16241563 * the maximum value represents the blocks supported by the kernel driver,
16251564 * independently of the device instance.
16261565 *
1627− * For each ISP block that userspace wants to configure, a block-specific
1628− * structure is appended to the @data buffer, one after the other without gaps
1629− * in between nor overlaps. Userspace shall populate the @data_size field with
1630− * the effective size, in bytes, of the @data buffer.
1631− *
16321566 * The expected memory layout of the parameters buffer is::
16331567 *
16341568 * +-------------------- struct rkisp1_ext_params_cfg -------------------+
@@ -1678,4 +1612,11 @@ struct rkisp1_ext_params_cfg { · 43 unmodified lines
16781612 __u8 data[RKISP1_EXT_PARAMS_MAX_SIZE];
16791613 };
16801614
1615+#ifdef __KERNEL__
1616+/* Make sure the header is type-convertible to the generic v4l2 params one */
1617+static_assert((sizeof(struct rkisp1_ext_params_cfg) -
1618+ RKISP1_EXT_PARAMS_MAX_SIZE) ==
1619+ sizeof(struct v4l2_isp_params_buffer));
1620+#endif /* __KERNEL__ */
1621+
16811622 #endif /* _UAPI_RKISP1_CONFIG_H */