linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls
@ 2015-02-17 14:41 Ricardo Ribalda Delgado
  2015-02-17 14:41 ` [PATCH 2/2] media/Documentation: Volatile writable Ricardo Ribalda Delgado
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ricardo Ribalda Delgado @ 2015-02-17 14:41 UTC (permalink / raw)
  To: Hans Verkuil, Mauro Carvalho Chehab, Jonathan Corbet,
	Arun Kumar K, Sylwester Nawrocki, Sakari Ailus, Antti Palosaari,
	linux-media, linux-doc, linux-kernel
  Cc: Ricardo Ribalda Delgado

Volatile controls can change their value outside the v4l-ctrl framework.
We should ignore the cached written value of the ctrl when evaluating if
we should run s_ctrl.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 45c5b47..693a473 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1609,6 +1609,12 @@ static int cluster_changed(struct v4l2_ctrl *master)
 
 		if (ctrl == NULL)
 			continue;
+
+		if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) {
+			changed = true;
+			continue;
+		}
+
 		for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++)
 			ctrl_changed = !ctrl->type_ops->equal(ctrl, idx,
 				ctrl->p_cur, ctrl->p_new);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] media/Documentation: Volatile writable
  2015-02-17 14:41 [PATCH 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls Ricardo Ribalda Delgado
@ 2015-02-17 14:41 ` Ricardo Ribalda Delgado
  2015-02-17 14:52   ` Hans Verkuil
  2015-02-17 14:46 ` [PATCH 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls Ricardo Ribalda Delgado
  2015-02-17 14:48 ` Hans Verkuil
  2 siblings, 1 reply; 5+ messages in thread
From: Ricardo Ribalda Delgado @ 2015-02-17 14:41 UTC (permalink / raw)
  To: Hans Verkuil, Mauro Carvalho Chehab, Jonathan Corbet,
	Arun Kumar K, Sylwester Nawrocki, Sakari Ailus, Antti Palosaari,
	linux-media, linux-doc, linux-kernel
  Cc: Ricardo Ribalda Delgado

Volatile variables are also writable now. Update the documentation
accordingly.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 Documentation/DocBook/media/v4l/vidioc-dqevent.xml   | 7 ++++---
 Documentation/DocBook/media/v4l/vidioc-queryctrl.xml | 6 ++++--
 Documentation/video4linux/v4l2-controls.txt          | 4 +++-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
index b036f89..38d907e 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
@@ -318,9 +318,10 @@
 	    <entry><constant>V4L2_EVENT_CTRL_CH_VALUE</constant></entry>
 	    <entry>0x0001</entry>
 	    <entry>This control event was triggered because the value of the control
-		changed. Special case: if a button control is pressed, then this
-		event is sent as well, even though there is not explicit value
-		associated with a button control.</entry>
+		changed. Special cases: Volatile controls do no generate this event;
+		If a button control is pressed, then this event is sent as well,
+		even though there is not explicit value associated with a button
+		control.</entry>
 	  </row>
 	  <row>
 	    <entry><constant>V4L2_EVENT_CTRL_CH_FLAGS</constant></entry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml b/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
index 2bd98fd..6e1e98d 100644
--- a/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
@@ -599,8 +599,10 @@ writing a value will cause the device to carry out a given action
 	    <entry>This control is volatile, which means that the value of the control
 changes continuously. A typical example would be the current gain value if the device
 is in auto-gain mode. In such a case the hardware calculates the gain value based on
-the lighting conditions which can change over time. Note that setting a new value for
-a volatile control will have no effect. The new value will just be ignored.</entry>
+the lighting conditions which can change over time. Another example would be an error
+flag (missed trigger, invalid voltage on the sensor). In those situations the user
+could write to the control to acknowledge the error, but that write will never
+generate a <constant>V4L2_EVENT_CTRL_CH_VALUE</constant> event.<entry>
 	  </row>
 	  <row>
 	    <entry><constant>V4L2_CTRL_FLAG_HAS_PAYLOAD</constant></entry>
diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt
index 0f84ce8..5517db6 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -344,7 +344,9 @@ implement g_volatile_ctrl like this:
 	}
 
 Note that you use the 'new value' union as well in g_volatile_ctrl. In general
-controls that need to implement g_volatile_ctrl are read-only controls.
+controls that need to implement g_volatile_ctrl are read-only controls. If they
+are not, a V4L2_EVENT_CTRL_CH_VALUE will not be generated when the control
+changes.
 
 To mark a control as volatile you have to set V4L2_CTRL_FLAG_VOLATILE:
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls
  2015-02-17 14:41 [PATCH 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls Ricardo Ribalda Delgado
  2015-02-17 14:41 ` [PATCH 2/2] media/Documentation: Volatile writable Ricardo Ribalda Delgado
@ 2015-02-17 14:46 ` Ricardo Ribalda Delgado
  2015-02-17 14:48 ` Hans Verkuil
  2 siblings, 0 replies; 5+ messages in thread
From: Ricardo Ribalda Delgado @ 2015-02-17 14:46 UTC (permalink / raw)
  To: Hans Verkuil, Mauro Carvalho Chehab, Jonathan Corbet,
	Arun Kumar K, Sylwester Nawrocki, Sakari Ailus, Antti Palosaari,
	linux-media, linux-doc, LKML
  Cc: Ricardo Ribalda Delgado

This is v3 of the patch.

I forgot to add it to the subject. I have marked v1 and v2 as
Superseded on patchwork

Thanks

On Tue, Feb 17, 2015 at 3:41 PM, Ricardo Ribalda Delgado
<ricardo.ribalda@gmail.com> wrote:
> Volatile controls can change their value outside the v4l-ctrl framework.
> We should ignore the cached written value of the ctrl when evaluating if
> we should run s_ctrl.
>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
>  drivers/media/v4l2-core/v4l2-ctrls.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> index 45c5b47..693a473 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -1609,6 +1609,12 @@ static int cluster_changed(struct v4l2_ctrl *master)
>
>                 if (ctrl == NULL)
>                         continue;
> +
> +               if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) {
> +                       changed = true;
> +                       continue;
> +               }
> +
>                 for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++)
>                         ctrl_changed = !ctrl->type_ops->equal(ctrl, idx,
>                                 ctrl->p_cur, ctrl->p_new);
> --
> 2.1.4
>



-- 
Ricardo Ribalda

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls
  2015-02-17 14:41 [PATCH 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls Ricardo Ribalda Delgado
  2015-02-17 14:41 ` [PATCH 2/2] media/Documentation: Volatile writable Ricardo Ribalda Delgado
  2015-02-17 14:46 ` [PATCH 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls Ricardo Ribalda Delgado
@ 2015-02-17 14:48 ` Hans Verkuil
  2 siblings, 0 replies; 5+ messages in thread
From: Hans Verkuil @ 2015-02-17 14:48 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado, Hans Verkuil, Mauro Carvalho Chehab,
	Jonathan Corbet, Arun Kumar K, Sylwester Nawrocki, Sakari Ailus,
	Antti Palosaari, linux-media, linux-doc, linux-kernel

On 02/17/2015 03:41 PM, Ricardo Ribalda Delgado wrote:
> Volatile controls can change their value outside the v4l-ctrl framework.
> We should ignore the cached written value of the ctrl when evaluating if
> we should run s_ctrl.
> 
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
>  drivers/media/v4l2-core/v4l2-ctrls.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> index 45c5b47..693a473 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -1609,6 +1609,12 @@ static int cluster_changed(struct v4l2_ctrl *master)
>  
>  		if (ctrl == NULL)
>  			continue;
> +
> +		if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) {
> +			changed = true;

You need to explicitly set 'ctrl->has_changed = false;' here.

And a comment why it is set to false (to prevent sending the event) is
needed as well since it would look a bit weird otherwise.

Regards,

	Hans

> +			continue;
> +		}
> +
>  		for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++)
>  			ctrl_changed = !ctrl->type_ops->equal(ctrl, idx,
>  				ctrl->p_cur, ctrl->p_new);
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] media/Documentation: Volatile writable
  2015-02-17 14:41 ` [PATCH 2/2] media/Documentation: Volatile writable Ricardo Ribalda Delgado
@ 2015-02-17 14:52   ` Hans Verkuil
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Verkuil @ 2015-02-17 14:52 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado, Hans Verkuil, Mauro Carvalho Chehab,
	Jonathan Corbet, Arun Kumar K, Sylwester Nawrocki, Sakari Ailus,
	Antti Palosaari, linux-media, linux-doc, linux-kernel

On 02/17/2015 03:41 PM, Ricardo Ribalda Delgado wrote:
> Volatile variables are also writable now. Update the documentation
> accordingly.
> 
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
>  Documentation/DocBook/media/v4l/vidioc-dqevent.xml   | 7 ++++---
>  Documentation/DocBook/media/v4l/vidioc-queryctrl.xml | 6 ++++--
>  Documentation/video4linux/v4l2-controls.txt          | 4 +++-
>  3 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
> index b036f89..38d907e 100644
> --- a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
> +++ b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
> @@ -318,9 +318,10 @@
>  	    <entry><constant>V4L2_EVENT_CTRL_CH_VALUE</constant></entry>
>  	    <entry>0x0001</entry>
>  	    <entry>This control event was triggered because the value of the control
> -		changed. Special case: if a button control is pressed, then this
> -		event is sent as well, even though there is not explicit value
> -		associated with a button control.</entry>
> +		changed. Special cases: Volatile controls do no generate this event;

Volatile -> volatile
no -> not
event; -> event.

> +		If a button control is pressed, then this event is sent as well,
> +		even though there is not explicit value associated with a button

Hmm: not -> no

:-)

> +		control.</entry>
>  	  </row>
>  	  <row>
>  	    <entry><constant>V4L2_EVENT_CTRL_CH_FLAGS</constant></entry>
> diff --git a/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml b/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
> index 2bd98fd..6e1e98d 100644
> --- a/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
> +++ b/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
> @@ -599,8 +599,10 @@ writing a value will cause the device to carry out a given action
>  	    <entry>This control is volatile, which means that the value of the control
>  changes continuously. A typical example would be the current gain value if the device
>  is in auto-gain mode. In such a case the hardware calculates the gain value based on
> -the lighting conditions which can change over time. Note that setting a new value for
> -a volatile control will have no effect. The new value will just be ignored.</entry>
> +the lighting conditions which can change over time. Another example would be an error
> +flag (missed trigger, invalid voltage on the sensor). In those situations the user
> +could write to the control to acknowledge the error, but that write will never
> +generate a <constant>V4L2_EVENT_CTRL_CH_VALUE</constant> event.<entry>
>  	  </row>
>  	  <row>
>  	    <entry><constant>V4L2_CTRL_FLAG_HAS_PAYLOAD</constant></entry>
> diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt
> index 0f84ce8..5517db6 100644
> --- a/Documentation/video4linux/v4l2-controls.txt
> +++ b/Documentation/video4linux/v4l2-controls.txt
> @@ -344,7 +344,9 @@ implement g_volatile_ctrl like this:
>  	}
>  
>  Note that you use the 'new value' union as well in g_volatile_ctrl. In general
> -controls that need to implement g_volatile_ctrl are read-only controls.
> +controls that need to implement g_volatile_ctrl are read-only controls. If they
> +are not, a V4L2_EVENT_CTRL_CH_VALUE will not be generated when the control
> +changes.
>  
>  To mark a control as volatile you have to set V4L2_CTRL_FLAG_VOLATILE:
>  
> 

With those typo fixes:

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Thanks!

	Hans

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-17 14:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-17 14:41 [PATCH 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls Ricardo Ribalda Delgado
2015-02-17 14:41 ` [PATCH 2/2] media/Documentation: Volatile writable Ricardo Ribalda Delgado
2015-02-17 14:52   ` Hans Verkuil
2015-02-17 14:46 ` [PATCH 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls Ricardo Ribalda Delgado
2015-02-17 14:48 ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).