Linux-Media Archive on
 help / color / Atom feed
From: Hans Verkuil <>
To: Ricardo Ribalda Delgado <>
Cc: Linux Media Mailing List <>
Subject: Proposal for a v4l2_ctrl_new_std_compound() function
Date: Thu, 12 Sep 2019 15:35:45 +0200
Message-ID: <> (raw)

Hi Ricardo,

As per our irc discussion, here is a proposal how I think it can be done.
The core problem is that for compound types we want to provide a default
value that can be used in std_init_compound() without having to provide
our own type ops. The new v4l2_ctrl_new_std_compound would pass a const
pointer to the struct with the default value, and std_init_compound
should use that if p_def != NULL.

I think this is beneficial for the various codec compound types as well.

Implementing this in v4l2-ctrls.c is left as an exercise for the reader
(i.e., you!).



Signed-off-by: Hans Verkuil <>
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 570ff4b0205a..7fdbf3abe49b 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -254,6 +254,7 @@ struct v4l2_ctrl {
 		s32 val;
 	} cur;

+	const union v4l2_ctrl_ptr p_def;
 	union v4l2_ctrl_ptr p_new;
 	union v4l2_ctrl_ptr p_cur;
@@ -667,6 +668,27 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
 					 u32 id, u8 max, u8 def,
 					 const s64 *qmenu_int);

+ * v4l2_ctrl_new_std_compound() - Allocate and initialize a new standard V4L2
+ *	compound control.
+ *
+ * @hdl:	The control handler.
+ * @ops:	The control ops.
+ * @id:		The control ID.
+ * @min:	The control's minimum value.
+ * @max:	The control's maximum value.
+ * @step:	The control's step value
+ * @p_def:	The control's default value.
+ *
+ * If the &v4l2_ctrl struct could not be allocated, or the control
+ * ID is not known, then NULL is returned and @hdl->error is set to the
+ * appropriate error code (if it wasn't set already).
+ */
+struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl,
+					     const struct v4l2_ctrl_ops *ops,
+					     u32 id, s64 min, s64 max, u64 step,
+					     const union v4l2_ctrl_ptr p_def);
  * typedef v4l2_ctrl_filter - Typedef to define the filter function to be
  *	used when adding a control handler.

             reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-12 13:35 Hans Verkuil [this message]
2019-09-13 16:08 ` kbuild test robot
2019-09-17 16:19 ` [PATCH] RFC: v4l2-ctrls: Inmplement v4l2_ctrl_new_std_compound() Ricardo Ribalda Delgado
2019-09-17 16:21   ` Ricardo Ribalda Delgado
2019-09-20 10:06     ` Hans Verkuil
2019-09-20 10:33       ` Ricardo Ribalda Delgado
2019-09-20 10:38         ` Hans Verkuil

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Media Archive on

Archives are clonable:
	git clone --mirror linux-media/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-media linux-media/ \
	public-inbox-index linux-media

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox