Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: uapi: Convert Amlogic C3 to V4L2 extensible params

With the introduction of common types for extensible parameters
format, convert the c3-isp-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
C3 ISP uAPI or are 1-to-1 type convertible.

Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Keke Li <keke.li@amlogic.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Jacopo Mondi and committed by
Hans Verkuil
45662082 1e8152db

+23 -67
+23 -67
include/uapi/linux/media/amlogic/c3-isp-config.h
··· 6 6 #ifndef _UAPI_C3_ISP_CONFIG_H_ 7 7 #define _UAPI_C3_ISP_CONFIG_H_ 8 8 9 + #ifdef __KERNEL__ 10 + #include <linux/build_bug.h> 11 + #endif /* __KERNEL__ */ 9 12 #include <linux/types.h> 13 + 14 + #include <linux/media/v4l2-isp.h> 10 15 11 16 /* 12 17 * Frames are split into zones of almost equal width and height - a zone is a ··· 146 141 * @C3_ISP_PARAMS_BUFFER_V0: First version of C3 ISP parameters block 147 142 */ 148 143 enum c3_isp_params_buffer_version { 149 - C3_ISP_PARAMS_BUFFER_V0, 144 + C3_ISP_PARAMS_BUFFER_V0 = V4L2_ISP_PARAMS_VERSION_V0, 150 145 }; 151 146 152 147 /** ··· 181 176 C3_ISP_PARAMS_BLOCK_SENTINEL 182 177 }; 183 178 184 - #define C3_ISP_PARAMS_BLOCK_FL_DISABLE (1U << 0) 185 - #define C3_ISP_PARAMS_BLOCK_FL_ENABLE (1U << 1) 179 + /* For backward compatibility */ 180 + #define C3_ISP_PARAMS_BLOCK_FL_DISABLE V4L2_ISP_PARAMS_FL_BLOCK_DISABLE 181 + #define C3_ISP_PARAMS_BLOCK_FL_ENABLE V4L2_ISP_PARAMS_FL_BLOCK_ENABLE 186 182 187 183 /** 188 184 * struct c3_isp_params_block_header - C3 ISP parameter block header 189 185 * 190 186 * This structure represents the common part of all the ISP configuration 191 - * blocks. Each parameters block shall embed an instance of this structure type 192 - * as its first member, followed by the block-specific configuration data. The 193 - * driver inspects this common header to discern the block type and its size and 194 - * properly handle the block content by casting it to the correct block-specific 195 - * type. 187 + * blocks and is identical to :c:type:`v4l2_isp_params_block_header`. 196 188 * 197 - * The @type field is one of the values enumerated by 189 + * The type field is one of the values enumerated by 198 190 * :c:type:`c3_isp_params_block_type` and specifies how the data should be 199 - * interpreted by the driver. The @size field specifies the size of the 200 - * parameters block and is used by the driver for validation purposes. The 201 - * @flags field is a bitmask of per-block flags C3_ISP_PARAMS_FL*. 191 + * interpreted by the driver. 202 192 * 203 - * When userspace wants to disable an ISP block the 204 - * C3_ISP_PARAMS_BLOCK_FL_DISABLED bit should be set in the @flags field. In 205 - * this case userspace may optionally omit the remainder of the configuration 206 - * block, which will be ignored by the driver. 207 - * 208 - * When a new configuration of an ISP block needs to be applied userspace 209 - * shall fully populate the ISP block and omit setting the 210 - * C3_ISP_PARAMS_BLOCK_FL_DISABLED bit in the @flags field. 211 - * 212 - * Userspace is responsible for correctly populating the parameters block header 213 - * fields (@type, @flags and @size) and the block-specific parameters. 214 - * 215 - * For example: 216 - * 217 - * .. code-block:: c 218 - * 219 - * void populate_pst_gamma(struct c3_isp_params_block_header *block) { 220 - * struct c3_isp_params_pst_gamma *gamma = 221 - * (struct c3_isp_params_pst_gamma *)block; 222 - * 223 - * gamma->header.type = C3_ISP_PARAMS_BLOCK_PST_GAMMA; 224 - * gamma->header.flags = C3_ISP_PARAMS_BLOCK_FL_ENABLE; 225 - * gamma->header.size = sizeof(*gamma); 226 - * 227 - * for (unsigned int i = 0; i < 129; i++) 228 - * gamma->pst_gamma_lut[i] = i; 229 - * } 230 - * 231 - * @type: The parameters block type from :c:type:`c3_isp_params_block_type` 232 - * @flags: A bitmask of block flags 233 - * @size: Size (in bytes) of the parameters block, including this header 193 + * The flags field is a bitmask of per-block flags C3_ISP_PARAMS_FL_*. 234 194 */ 235 - struct c3_isp_params_block_header { 236 - __u16 type; 237 - __u16 flags; 238 - __u32 size; 239 - }; 195 + #define c3_isp_params_block_header v4l2_isp_params_block_header 240 196 241 197 /** 242 198 * struct c3_isp_params_awb_gains - Gains for auto-white balance ··· 464 498 /** 465 499 * struct c3_isp_params_cfg - C3 ISP configuration parameters 466 500 * 467 - * This struct contains the configuration parameters of the C3 ISP 468 - * algorithms, serialized by userspace into an opaque data buffer. Each 469 - * configuration parameter block is represented by a block-specific structure 470 - * which contains a :c:type:`c3_isp_param_block_header` entry as first 471 - * member. Userspace populates the @data buffer with configuration parameters 472 - * for the blocks that it intends to configure. As a consequence, the data 473 - * buffer effective size changes according to the number of ISP blocks that 474 - * userspace intends to configure. 501 + * This is the driver-specific implementation of 502 + * :c:type:`v4l2_isp_params_buffer`. 475 503 * 476 - * The parameters buffer is versioned by the @version field to allow modifying 477 - * and extending its definition. Userspace should populate the @version field to 478 - * inform the driver about the version it intends to use. The driver will parse 479 - * and handle the @data buffer according to the data layout specific to the 480 - * indicated revision and return an error if the desired revision is not 481 - * supported. 482 - * 483 - * For each ISP block that userspace wants to configure, a block-specific 484 - * structure is appended to the @data buffer, one after the other without gaps 485 - * in between nor overlaps. Userspace shall populate the @total_size field with 486 - * the effective size, in bytes, of the @data buffer. 504 + * Currently only C3_ISP_PARAM_BUFFER_V0 is supported. 487 505 * 488 506 * The expected memory layout of the parameters buffer is:: 489 507 * ··· 510 560 __u32 data_size; 511 561 __u8 data[C3_ISP_PARAMS_MAX_SIZE]; 512 562 }; 563 + 564 + #ifdef __KERNEL__ 565 + /* Make sure the header is type-convertible to the generic v4l2 params one */ 566 + static_assert((sizeof(struct c3_isp_params_cfg) - C3_ISP_PARAMS_MAX_SIZE) == 567 + sizeof(struct v4l2_isp_params_buffer)); 568 + #endif /* __KERNEL__ */ 513 569 514 570 #endif