Skip to contentSkip to conversation

New V4L2 control V4L2_CID_NOTIFY_GAINS

PATCH In review David Plowman 3 participants 7 messages Aug 16, 2021 – Oct 6, 2021 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

v6 cover New V4L2 control V4L2_CID_NOTIFY_GAINS

Hi again everyone

Thanks for last round of feedback, leading to this v6 pair of patches. I've made the documentation improvements that were suggested, and accordingly added Laurent's "Reviewed-by" tags.

Thanks and best regards

David

David Plowman (2):
media: v4l2-ctrls: Add V4L2_CID_NOTIFY_GAINS control
media: v4l2-ctrls: Document V4L2_CID_NOTIFY_GAINS control

 .../media/v4l/ext-ctrls-image-source.rst      | 20 +++++++++++++++++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c     |  1 +
 include/uapi/linux/v4l2-controls.h            |  1 +
 3 files changed, 22 insertions(+)
Signature · 1 line
2.30.2
#1 lore raw

PATCH v6 1/2 media: v4l2-ctrls: Add V4L2_CID_NOTIFY_GAINS control

We add a new control V4L2_CID_NOTIFY_GAINS which allows the sensor to be notified what gains will be applied to the different colour channels by subsequent processing (such as by an ISP), even though the sensor will not apply any of these gains itself.

For Bayer sensors this will be an array control taking 4 values which are the 4 gains arranged in the fixed order B, Gb, Gr and R, irrespective of the exact Bayer order of the sensor itself. The use of an array makes it straightforward to extend this control to non-Bayer sensors (for example, sensors with an RGBW pattern) in future.

The units are in all cases linear with the default value indicating a gain of exactly 1.0. For example, if the default value were reported as 128 then the value 192 would represent a gain of exactly 1.5.

---
 drivers/media/v4l2-core/v4l2-ctrls-defs.c | 1 +
 include/uapi/linux/v4l2-controls.h        | 1 +
 2 files changed, 2 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls-defs.c +1 -0
index 421300e13a41..f87053c83249 100644
@@ -1107,6 +1107,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_TEST_PATTERN_GREENR:	return "Green (Red) Pixel Value";
 	case V4L2_CID_TEST_PATTERN_BLUE:	return "Blue Pixel Value";
 	case V4L2_CID_TEST_PATTERN_GREENB:	return "Green (Blue) Pixel Value";
+	case V4L2_CID_NOTIFY_GAINS:		return "Notify Gains";
 
 	/* Image processing controls */
 	/* Keep the order of the 'case's the same as in v4l2-controls.h! */
include/uapi/linux/v4l2-controls.h +1 -0
index 5532b5f68493..133e20444939 100644
@@ -1118,6 +1118,7 @@ enum v4l2_jpeg_chroma_subsampling {
 #define V4L2_CID_TEST_PATTERN_BLUE		(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 6)
 #define V4L2_CID_TEST_PATTERN_GREENB		(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 7)
 #define V4L2_CID_UNIT_CELL_SIZE			(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 8)
+#define V4L2_CID_NOTIFY_GAINS			(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 9)
 
 
 /* Image processing controls */
Signature · 1 line
2.30.2
#2 lore raw

PATCH v6 2/2 media: v4l2-ctrls: Document V4L2_CID_NOTIFY_GAINS control

In reply to David Plowman

Add documentation for the V4L2_CID_NOTIFY_GAINS control.

This control is required by sensors that need to know what colour gains will be applied to pixels by downstream processing (such as by an ISP), though the sensor does not apply these gains itself.

---
 .../media/v4l/ext-ctrls-image-source.rst      | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst +20 -0
index de43f5c8486d..71f23f131f97 100644
@@ -72,3 +72,23 @@ Image Source Control IDs
     * - __u32
       - ``height``
       - Height of the area.
+
+``V4L2_CID_NOTIFY_GAINS (integer array)``
+    The sensor is notified what gains will be applied to the different
+    colour channels by subsequent processing (such as by an ISP). The
+    sensor is merely informed of these values in case it performs
+    processing that requires them, but it does not apply them itself to
+    the output pixels.
+
+    Currently it is defined only for Bayer sensors, and is an array
+    control taking 4 gain values, being the gains for each of the
+    Bayer channels. The gains are always in the order B, Gb, Gr and R,
+    irrespective of the exact Bayer order of the sensor itself.
+
+    The use of an array allows this control to be extended to sensors
+    with, for example, non-Bayer CFAs (colour filter arrays).
+
+    The units for the gain values are linear, with the default value
+    representing a gain of exactly 1.0. For example, if this default value
+    is reported as being (say) 128, then a value of 192 would represent
+    a gain of exactly 1.5.
Signature · 1 line
2.30.2
#3 lore raw
In reply to David Plowman

Hello,

I've reviewed this series and it looks good to me. Sakari, would you like to have a look, or should I send a pull request ?

Quoted 18 lines · David Plowman

Hi again everyone

Thanks for last round of feedback, leading to this v6 pair of patches. I've made the documentation improvements that were suggested, and accordingly added Laurent's "Reviewed-by" tags.

Thanks and best regards

David

David Plowman (2):
media: v4l2-ctrls: Add V4L2_CID_NOTIFY_GAINS control
media: v4l2-ctrls: Document V4L2_CID_NOTIFY_GAINS control

 .../media/v4l/ext-ctrls-image-source.rst      | 20 +++++++++++++++++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c     |  1 +
 include/uapi/linux/v4l2-controls.h            |  1 +
 3 files changed, 22 insertions(+)
Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw

Hi Laurent, Sakari, everyone

I was wondering whether I might give this another little nudge just so that it doesn't get lost.

Thanks again and best regards

David

Quoted 30 lines · Laurent Pinchart

Hello,

I've reviewed this series and it looks good to me. Sakari, would you like to have a look, or should I send a pull request ?

Quoted 10 lines · David Plowman

Hi again everyone

Thanks for last round of feedback, leading to this v6 pair of patches. I've made the documentation improvements that were suggested, and accordingly added Laurent's "Reviewed-by" tags.

Thanks and best regards

David

Quoted 8 lines

David Plowman (2):
media: v4l2-ctrls: Add V4L2_CID_NOTIFY_GAINS control
media: v4l2-ctrls: Document V4L2_CID_NOTIFY_GAINS control

 .../media/v4l/ext-ctrls-image-source.rst      | 20 +++++++++++++++++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c     |  1 +
 include/uapi/linux/v4l2-controls.h            |  1 +
 3 files changed, 22 insertions(+)

--
Regards,

Laurent Pinchart

#5 lore raw

Hi David,

Quoted 4 lines · David Plowman

Hi Laurent, Sakari, everyone

I was wondering whether I might give this another little nudge just so that it doesn't get lost.

I've already reviewed it, I can only join you to nicely ask Sakari if he could have a look :-) I know he has lots of patches on his plate at the moment though.

Hans, would you like to share your opinion on this series ?

Quoted 26 lines · Laurent Pinchart
Quoted 25 lines

Hello,

I've reviewed this series and it looks good to me. Sakari, would you like to have a look, or should I send a pull request ?

Quoted 18 lines · David Plowman

Hi again everyone

Thanks for last round of feedback, leading to this v6 pair of patches. I've made the documentation improvements that were suggested, and accordingly added Laurent's "Reviewed-by" tags.

Thanks and best regards

David

David Plowman (2):
media: v4l2-ctrls: Add V4L2_CID_NOTIFY_GAINS control
media: v4l2-ctrls: Document V4L2_CID_NOTIFY_GAINS control

 .../media/v4l/ext-ctrls-image-source.rst      | 20 +++++++++++++++++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c     |  1 +
 include/uapi/linux/v4l2-controls.h            |  1 +
 3 files changed, 22 insertions(+)
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by Laurent Pinchart Reviewed-by Laurent Pinchart
#6 lore raw

Hi David, Laurent,

Quoted 5 lines · Laurent Pinchart

Hi David,

Quoted 2 lines · David Plowman

Hi Laurent, Sakari, everyone

Quoted 8 lines
Quoted 2 lines

I was wondering whether I might give this another little nudge just so that it doesn't get lost.

I've already reviewed it, I can only join you to nicely ask Sakari if he could have a look :-) I know he has lots of patches on his plate at the moment though.

Hans, would you like to share your opinion on this series ?

The patches have been merged some time ago to the media tree master branch:

commit 311a839a1ad255ebcb7291fb4e0d2ec2f32312a7

Author: David Plowman <[email protected]>
Date:   Mon Aug 16 13:39:09 2021 +0200

media: v4l2-ctrls: Document V4L2_CID_NOTIFY_GAINS control

Add documentation for the V4L2_CID_NOTIFY_GAINS control.

This control is required by sensors that need to know what colour gains will be applied to pixels by downstream processing (such as by an ISP), though the sensor does not apply these gains itself.

commit a9c80593ff80ddb7c6496624e5384e1ea3460a72

Author: David Plowman <[email protected]>
Date:   Mon Aug 16 13:39:08 2021 +0200

media: v4l2-ctrls: Add V4L2_CID_NOTIFY_GAINS control

We add a new control V4L2_CID_NOTIFY_GAINS which allows the sensor to be notified what gains will be applied to the different colour channels by subsequent processing (such as by an ISP), even though the sensor will not apply any of these gains itself.

For Bayer sensors this will be an array control taking 4 values which are the 4 gains arranged in the fixed order B, Gb, Gr and R, irrespective of the exact Bayer order of the sensor itself. The use of an array makes it straightforward to extend this control to non-Bayer sensors (for example, sensors with an RGBW pattern) in future.

The units are in all cases linear with the default value indicating a gain of exactly 1.0. For example, if the default value were reported as 128 then the value 192 would represent a gain of exactly 1.5.

Signature · 3 lines
Kind regards,

Sakari Ailus