[2/3] include: uapi: Drop controls for VC4 ISP params
diff mbox series

Message ID 20260210-pi4-upstream-v1-2-279841c15fba@ideasonboard.com
State New
Headers show
Series
  • Raspberry Pi: Update VC4 pipeline for upstream
Related show

Commit Message

Jai Luthra Feb. 10, 2026, 8:25 a.m. UTC
Update the BCM2835 ISP kernel header to replace custom V4L2 controls
with an extensible parameter buffer interface, aligning with the
approach used by other upstream ISP drivers (rkisp1, mali-c55).

Add new bcm2835_isp_awb_gains and bcm2835_isp_digital_gain structures
for AWB and digital gain, which were previously configured through
standard V4L2 controls (V4L2_CID_RED_BALANCE, V4L2_CID_BLUE_BALANCE,
V4L2_CID_DIGITAL_GAIN) and now need dedicated parameter blocks.

Register V4L2_META_FMT_BCM2835_ISP_PARAMS as the fourcc for the new
metadata format in videodev2.h, and drop the control ID base from the
v4l2-controls.h.

Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
 include/linux/bcm2835-isp.h   | 276 +++++++++++++++++++++++++++++++++++-------
 include/linux/v4l2-controls.h |   3 -
 include/linux/videodev2.h     |   3 +-
 3 files changed, 232 insertions(+), 50 deletions(-)

Patch
diff mbox series

diff --git a/include/linux/bcm2835-isp.h b/include/linux/bcm2835-isp.h
index 5f0f78e3e93f994487a1123263d2b26e7ce5b947..0f3c1b4dbb06313ce661c492cbd023e93f005d54 100644
--- a/include/linux/bcm2835-isp.h
+++ b/include/linux/bcm2835-isp.h
@@ -13,26 +13,8 @@ 
 #ifndef __BCM2835_ISP_H_
 #define __BCM2835_ISP_H_
 
-#include <linux/v4l2-controls.h>
-
-#define V4L2_CID_USER_BCM2835_ISP_CC_MATRIX	\
-				(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0001)
-#define V4L2_CID_USER_BCM2835_ISP_LENS_SHADING	\
-				(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0002)
-#define V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL	\
-				(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0003)
-#define V4L2_CID_USER_BCM2835_ISP_GEQ		\
-				(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0004)
-#define V4L2_CID_USER_BCM2835_ISP_GAMMA		\
-				(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0005)
-#define V4L2_CID_USER_BCM2835_ISP_DENOISE	\
-				(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0006)
-#define V4L2_CID_USER_BCM2835_ISP_SHARPEN	\
-				(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0007)
-#define V4L2_CID_USER_BCM2835_ISP_DPC		\
-				(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0008)
-#define V4L2_CID_USER_BCM2835_ISP_CDN \
-				(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0009)
+#include <linux/media/v4l2-isp.h>
+
 /*
  * All structs below are directly mapped onto the equivalent structs in
  * drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h
@@ -62,8 +44,7 @@  struct bcm2835_isp_ccm {
 };
 
 /**
- * struct bcm2835_isp_custom_ccm - Custom CCM applied with the
- *				   V4L2_CID_USER_BCM2835_ISP_CC_MATRIX ctrl.
+ * struct bcm2835_isp_custom_ccm - Custom CCM configuration.
  *
  * @enabled:	Enable custom CCM.
  * @ccm:	Custom CCM coefficients and offsets.
@@ -75,8 +56,7 @@  struct bcm2835_isp_custom_ccm {
 
 /**
  * enum bcm2835_isp_gain_format - format of the gains in the lens shading
- *				  tables used with the
- *				  V4L2_CID_USER_BCM2835_ISP_LENS_SHADING ctrl.
+ *				  tables.
  *
  * @GAIN_FORMAT_U0P8_1:		Gains are u0.8 format, starting at 1.0
  * @GAIN_FORMAT_U1P7_0:		Gains are u1.7 format, starting at 0.0
@@ -99,9 +79,7 @@  enum bcm2835_isp_gain_format {
 };
 
 /**
- * struct bcm2835_isp_lens_shading - Lens shading tables supplied with the
- *				     V4L2_CID_USER_BCM2835_ISP_LENS_SHADING
- *				     ctrl.
+ * struct bcm2835_isp_lens_shading - Lens shading tables.
  *
  * @enabled:		Enable lens shading.
  * @grid_cell_size:	Size of grid cells in samples (16, 32, 64, 128 or 256).
@@ -128,13 +106,13 @@  struct bcm2835_isp_lens_shading {
 };
 
 /**
- * struct bcm2835_isp_black_level - Sensor black level set with the
- *				    V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL ctrl.
+ * struct bcm2835_isp_black_level - Sensor black level configuration.
  *
  * @enabled:		Enable black level.
  * @black_level_r:	Black level for red channel.
  * @black_level_g:	Black level for green channels.
  * @black_level_b:	Black level for blue channel.
+ * @padding:		Unused padding.
  */
 struct bcm2835_isp_black_level {
 	__u32 enabled;
@@ -145,8 +123,7 @@  struct bcm2835_isp_black_level {
 };
 
 /**
- * struct bcm2835_isp_geq - Green equalisation parameters set with the
- *			    V4L2_CID_USER_BCM2835_ISP_GEQ ctrl.
+ * struct bcm2835_isp_geq - Green equalisation parameters.
  *
  * @enabled:	Enable green equalisation.
  * @offset:	Fixed offset of the green equalisation threshold.
@@ -161,13 +138,12 @@  struct bcm2835_isp_geq {
 #define BCM2835_NUM_GAMMA_PTS 33
 
 /**
- * struct bcm2835_isp_gamma - Gamma parameters set with the
- *			      V4L2_CID_USER_BCM2835_ISP_GAMMA ctrl.
+ * struct bcm2835_isp_gamma - Gamma parameters.
  *
  * @enabled:	Enable gamma adjustment.
- * @X:		X values of the points defining the gamma curve.
+ * @x:		X values of the points defining the gamma curve.
  *		Values should be scaled to 16 bits.
- * @Y:		Y values of the points defining the gamma curve.
+ * @y:		Y values of the points defining the gamma curve.
  *		Values should be scaled to 16 bits.
  */
 struct bcm2835_isp_gamma {
@@ -179,9 +155,9 @@  struct bcm2835_isp_gamma {
 /**
  * enum bcm2835_isp_cdn_mode - Mode of operation for colour denoise.
  *
-  * @CDN_MODE_FAST:		Fast (but lower quality) colour denoise
+ * @CDN_MODE_FAST:		Fast (but lower quality) colour denoise
  *				algorithm, typically used for video recording.
- * @CDN_HIGH_QUALITY:		High quality (but slower) colour denoise
+ * @CDN_MODE_HIGH_QUALITY:	High quality (but slower) colour denoise
  *				algorithm, typically used for stills capture.
  */
 enum bcm2835_isp_cdn_mode {
@@ -190,11 +166,10 @@  enum bcm2835_isp_cdn_mode {
 };
 
 /**
- * struct bcm2835_isp_cdn - Colour denoise parameters set with the
- *			    V4L2_CID_USER_BCM2835_ISP_CDN ctrl.
+ * struct bcm2835_isp_cdn - Colour denoise parameters.
  *
  * @enabled:	Enable colour denoise.
- * @cdn_mode:	Colour denoise operating mode (see enum &bcm2835_isp_cdn_mode)
+ * @mode:	Colour denoise operating mode (see enum &bcm2835_isp_cdn_mode)
  */
 struct bcm2835_isp_cdn {
 	__u32 enabled;
@@ -202,8 +177,7 @@  struct bcm2835_isp_cdn {
 };
 
 /**
- * struct bcm2835_isp_denoise - Denoise parameters set with the
- *				V4L2_CID_USER_BCM2835_ISP_DENOISE ctrl.
+ * struct bcm2835_isp_denoise - Denoise parameters.
  *
  * @enabled:	Enable denoise.
  * @constant:	Fixed offset of the noise threshold.
@@ -218,8 +192,7 @@  struct bcm2835_isp_denoise {
 };
 
 /**
- * struct bcm2835_isp_sharpen - Sharpen parameters set with the
- *				V4L2_CID_USER_BCM2835_ISP_SHARPEN ctrl.
+ * struct bcm2835_isp_sharpen - Sharpen parameters.
  *
  * @enabled:	Enable sharpening.
  * @threshold:	Threshold at which to start sharpening pixels.
@@ -247,8 +220,7 @@  enum bcm2835_isp_dpc_mode {
 };
 
 /**
- * struct bcm2835_isp_dpc - Defective pixel correction (DPC) parameters set
- *			    with the V4L2_CID_USER_BCM2835_ISP_DPC ctrl.
+ * struct bcm2835_isp_dpc - Defective pixel correction (DPC) parameters.
  *
  * @enabled:	Enable DPC.
  * @strength:	DPC strength (see enum &bcm2835_isp_dpc_mode).
@@ -258,6 +230,218 @@  struct bcm2835_isp_dpc {
 	__u32 strength;
 };
 
+/**
+ * struct bcm2835_isp_awb_gains - AWB gains configuration.
+ *
+ * @r_gain:	Red channel AWB gain.
+ * @b_gain:	Blue channel AWB gain.
+ */
+struct bcm2835_isp_awb_gains {
+	struct bcm2835_isp_rational r_gain;
+	struct bcm2835_isp_rational b_gain;
+};
+
+/**
+ * struct bcm2835_isp_digital_gain - Digital gain configuration.
+ *
+ * @gain:	Digital gain value.
+ */
+struct bcm2835_isp_digital_gain {
+	struct bcm2835_isp_rational gain;
+};
+
+/*
+ * BCM2835 ISP extensible parameters buffer definitions.
+ *
+ * The extensible parameters mechanism allows userspace to submit ISP
+ * configuration parameters as a buffer containing a series of tagged
+ * blocks rather than individual V4L2 controls. This enables atomic
+ * application of multiple parameters in a single operation.
+ */
+
+/**
+ * enum bcm2835_isp_param_buffer_version - BCM2835 ISP parameters buffer version
+ *
+ * @BCM2835_ISP_PARAM_BUFFER_V1: First version of parameters buffer format
+ */
+enum bcm2835_isp_param_buffer_version {
+	BCM2835_ISP_PARAM_BUFFER_V1 = V4L2_ISP_PARAMS_VERSION_V1,
+};
+
+/**
+ * enum bcm2835_isp_param_block_type - BCM2835 ISP parameter block types
+ *
+ * This enumeration defines the types of parameters blocks that can be
+ * included in the extensible parameters buffer. Each block type corresponds
+ * to a specific ISP processing block configuration.
+ *
+ * @BCM2835_ISP_PARAM_BLOCK_BLACK_LEVEL: Black level configuration
+ * @BCM2835_ISP_PARAM_BLOCK_GEQ: Green equalisation configuration
+ * @BCM2835_ISP_PARAM_BLOCK_GAMMA: Gamma curve configuration
+ * @BCM2835_ISP_PARAM_BLOCK_DENOISE: Denoise configuration
+ * @BCM2835_ISP_PARAM_BLOCK_SHARPEN: Sharpening configuration
+ * @BCM2835_ISP_PARAM_BLOCK_DPC: Defective pixel correction configuration
+ * @BCM2835_ISP_PARAM_BLOCK_CDN: Colour denoise configuration
+ * @BCM2835_ISP_PARAM_BLOCK_CC_MATRIX: Colour correction matrix configuration
+ * @BCM2835_ISP_PARAM_BLOCK_LENS_SHADING: Lens shading table configuration
+ * @BCM2835_ISP_PARAM_BLOCK_AWB_GAINS: AWB gains configuration
+ * @BCM2835_ISP_PARAM_BLOCK_DIGITAL_GAIN: Digital gain configuration
+ */
+enum bcm2835_isp_param_block_type {
+	BCM2835_ISP_PARAM_BLOCK_BLACK_LEVEL,
+	BCM2835_ISP_PARAM_BLOCK_GEQ,
+	BCM2835_ISP_PARAM_BLOCK_GAMMA,
+	BCM2835_ISP_PARAM_BLOCK_DENOISE,
+	BCM2835_ISP_PARAM_BLOCK_SHARPEN,
+	BCM2835_ISP_PARAM_BLOCK_DPC,
+	BCM2835_ISP_PARAM_BLOCK_CDN,
+	BCM2835_ISP_PARAM_BLOCK_CC_MATRIX,
+	BCM2835_ISP_PARAM_BLOCK_LENS_SHADING,
+	BCM2835_ISP_PARAM_BLOCK_AWB_GAINS,
+	BCM2835_ISP_PARAM_BLOCK_DIGITAL_GAIN,
+};
+
+/**
+ * struct bcm2835_isp_params_black_level - Black level parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_BLACK_LEVEL)
+ * @black_level: Black level configuration
+ */
+struct bcm2835_isp_params_black_level {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_black_level black_level;
+} __attribute__((aligned(8)));
+
+/**
+ * struct bcm2835_isp_params_geq - Green equalisation parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_GEQ)
+ * @geq: Green equalisation configuration
+ */
+struct bcm2835_isp_params_geq {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_geq geq;
+} __attribute__((aligned(8)));
+
+/**
+ * struct bcm2835_isp_params_gamma - Gamma parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_GAMMA)
+ * @gamma: Gamma curve configuration
+ */
+struct bcm2835_isp_params_gamma {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_gamma gamma;
+} __attribute__((aligned(8)));
+
+/**
+ * struct bcm2835_isp_params_denoise - Denoise parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_DENOISE)
+ * @denoise: Denoise configuration
+ */
+struct bcm2835_isp_params_denoise {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_denoise denoise;
+} __attribute__((aligned(8)));
+
+/**
+ * struct bcm2835_isp_params_sharpen - Sharpen parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_SHARPEN)
+ * @sharpen: Sharpening configuration
+ */
+struct bcm2835_isp_params_sharpen {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_sharpen sharpen;
+} __attribute__((aligned(8)));
+
+/**
+ * struct bcm2835_isp_params_dpc - Defective pixel correction parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_DPC)
+ * @dpc: DPC configuration
+ */
+struct bcm2835_isp_params_dpc {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_dpc dpc;
+} __attribute__((aligned(8)));
+
+/**
+ * struct bcm2835_isp_params_cdn - Colour denoise parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_CDN)
+ * @cdn: Colour denoise configuration
+ */
+struct bcm2835_isp_params_cdn {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_cdn cdn;
+} __attribute__((aligned(8)));
+
+/**
+ * struct bcm2835_isp_params_cc_matrix - Colour correction matrix parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_CC_MATRIX)
+ * @ccm: Colour correction matrix configuration
+ */
+struct bcm2835_isp_params_cc_matrix {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_custom_ccm ccm;
+} __attribute__((aligned(8)));
+
+/**
+ * struct bcm2835_isp_params_lens_shading - Lens shading parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_LENS_SHADING)
+ * @ls: Lens shading configuration (includes dmabuf fd for table data)
+ */
+struct bcm2835_isp_params_lens_shading {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_lens_shading ls;
+} __attribute__((aligned(8)));
+
+/**
+ * struct bcm2835_isp_params_awb_gains - AWB gains parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_AWB_GAINS)
+ * @awb_gains: AWB gains configuration
+ */
+struct bcm2835_isp_params_awb_gains {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_awb_gains awb_gains;
+} __attribute__((aligned(8)));
+
+/**
+ * struct bcm2835_isp_params_digital_gain - Digital gain parameters block
+ *
+ * @header: Block header (type = BCM2835_ISP_PARAM_BLOCK_DIGITAL_GAIN)
+ * @digital_gain: Digital gain configuration
+ */
+struct bcm2835_isp_params_digital_gain {
+	struct v4l2_isp_params_block_header header;
+	struct bcm2835_isp_digital_gain digital_gain;
+} __attribute__((aligned(8)));
+
+/**
+ * define BCM2835_ISP_PARAMS_MAX_SIZE - Maximum size of all ISP parameters
+ *
+ * This defines the maximum size needed to accommodate all possible parameter
+ * blocks in a single buffer. Drivers use this to allocate appropriately
+ * sized buffers.
+ */
+#define BCM2835_ISP_PARAMS_MAX_SIZE					\
+	(sizeof(struct bcm2835_isp_params_black_level) +		\
+	 sizeof(struct bcm2835_isp_params_geq) +			\
+	 sizeof(struct bcm2835_isp_params_gamma) +			\
+	 sizeof(struct bcm2835_isp_params_denoise) +			\
+	 sizeof(struct bcm2835_isp_params_sharpen) +			\
+	 sizeof(struct bcm2835_isp_params_dpc) +			\
+	 sizeof(struct bcm2835_isp_params_cdn) +			\
+	 sizeof(struct bcm2835_isp_params_cc_matrix) +			\
+	 sizeof(struct bcm2835_isp_params_lens_shading) +		\
+	 sizeof(struct bcm2835_isp_params_awb_gains) +			\
+	 sizeof(struct bcm2835_isp_params_digital_gain))
+
 /*
  * ISP statistics structures.
  *
diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
index 25914de2cd7a39a168f59cd80ed331b4b339659f..0400a68b02d481f4bd5dffcd474a7f413c6bd278 100644
--- a/include/linux/v4l2-controls.h
+++ b/include/linux/v4l2-controls.h
@@ -178,9 +178,6 @@  enum v4l2_colorfx {
  */
 #define V4L2_CID_USER_CCS_BASE			(V4L2_CID_USER_BASE + 0x10f0)
 
-/* The base for the bcm2835-isp driver controls.
- * We reserve 16 controls for this driver. */
-#define V4L2_CID_USER_BCM2835_ISP_BASE		(V4L2_CID_USER_BASE + 0x10e0)
 /*
  * The base for Allegro driver controls.
  * We reserve 16 controls for this driver.
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index b40b43d72196cee5f677f96dddb8452600cd296c..5f38e786496be83600e3924abd9c9aeff81d1ca9 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -843,7 +843,8 @@  struct v4l2_pix_format {
 #define V4L2_META_FMT_UVC_MSXU_1_5  v4l2_fourcc('U', 'V', 'C', 'M') /* UVC MSXU metadata */
 #define V4L2_META_FMT_VIVID	  v4l2_fourcc('V', 'I', 'V', 'D') /* Vivid Metadata */
 #define V4L2_META_FMT_SENSOR_DATA v4l2_fourcc('S', 'E', 'N', 'S') /* Sensor Ancillary metadata */
-#define V4L2_META_FMT_BCM2835_ISP_STATS v4l2_fourcc('B', 'S', 'T', 'A') /* BCM2835 ISP image statistics output */
+#define V4L2_META_FMT_BCM2835_ISP_STATS v4l2_fourcc('B', 'S', 'T', 'A') /* BCM2835 ISP stats */
+#define V4L2_META_FMT_BCM2835_ISP_PARAMS v4l2_fourcc('B', 'C', 'M', 'P') /* BCM2835 ISP params */
 
 /* Vendor specific - used for RK_ISP1 camera sub-system */
 #define V4L2_META_FMT_RK_ISP1_PARAMS	v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */