media/v4l2-ctrls: volatiles should not generate CH_VALUE
PATCH v2 1/5 media/v4l2-ctrls: volatiles should not generate CH_VALUE
Volatile controls should not generate CH_VALUE events.
Set has_changed to false to prevent this happening.
---
v2: By Sakari Ailus <[email protected]>
Fix CodeStyle (sorry :S)
drivers/media/v4l2-core/v4l2-ctrls.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls.c +9 -0
@@ -1609,6 +1609,15 @@ static int cluster_changed(struct v4l2_ctrl *master)if (ctrl ==NULL )continue ; +/* +* Set has_changed to false to avoid generating +* the event V4L2_EVENT_CTRL_CH_VALUE +*/ +if (ctrl->flags &V4L2_CTRL_FLAG_VOLATILE ) { + ctrl->has_changed = false; +continue ; + } +for (idx =0 ; !ctrl_changed && idx < ctrl->elems; idx++) ctrl_changed = !ctrl->type_ops->equal (ctrl, idx, ctrl->p_cur, ctrl->p_new);
Signature · 1 line
2.1.4
PATCH v2 4/5 media/v4l2-ctrls: Always execute EXECUTE_ON_WRITE ctrls
Any control with V4L2_CTRL_FLAG_EXECUTE_ON_WRITE set should return changed == true in cluster_changed.
This forces the value to be passed to the driver even if it has not changed.
---
v2: By Sakari Ailus <[email protected]>
Fix CodeStyle (sorry :S)
drivers/media/v4l2-core/v4l2-ctrls.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls.c +4 -0
@@ -1611,6 +1611,10 @@ static int cluster_changed(struct v4l2_ctrl *master)if (ctrl ==NULL )continue ; + +if (ctrl->flags &V4L2_CTRL_FLAG_EXECUTE_ON_WRITE ) + changed = true; +/* * Set has_changed to false to avoid generating * the event V4L2_EVENT_CTRL_CH_VALUE
Signature · 1 line
2.1.4
Hi Ricardo,
Thank you for the patch, and sorry for the late review (so late that the patch has already been merged).
Quoted 1 line · On Friday 20 March 2015 14:30:46 Ricardo Ribalda Delgado wrote:
Volatile controls should not generate
CH_VALUEevents.
What's the rationale for that ? I would actually expect the value change events to be more useful for volatile controls than non-volatile controls. Volatile controls can have their value changed by the hardware without software intervention, and it makes sense to me to report that to userspace.
Quoted 30 lines
Set
has_changedto false to prevent this happening.Signed-off-by Ricardo Ribalda Delgado <[email protected]>---
v2: By Sakari Ailus <[email protected]>Fix CodeStyle (sorry :S)
drivers/media/v4l2-core/v4l2-ctrls.c | 9 +++++++++ 1 file changed, 9 insertions(+)(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-ctrls.cindex 45c5b47..2ebc33e 100644drivers/media/v4l2-core/v4l2-ctrls.c +9
-0@@ -1609,6 +1609,15 @@ static int cluster_changed(struct v4l2_ctrl *master)if (ctrl ==NULL )continue ; +/* +* Set has_changed to false to avoid generating +* the event V4L2_EVENT_CTRL_CH_VALUE +*/ +if (ctrl->flags &V4L2_CTRL_FLAG_VOLATILE ) { + ctrl->has_changed = false; +continue ; + } +for (idx =0 ; !ctrl_changed && idx < ctrl->elems; idx++) ctrl_changed = !ctrl->type_ops->equal (ctrl, idx, ctrl->p_cur, ctrl->p_new);
Signature · 3 lines
Regards, Laurent Pinchart
Hello Laurent
Quoted 4 lines · Laurent Pinchart
Hi Ricardo,
Thank you for the patch, and sorry for the late review (so late that the patch has already been merged).
No worries.
Quoted 8 lines · On Friday 20 March 2015 14:30:46 Ricardo Ribalda Delgado wrote:
Quoted 1 line
Volatile controls should not generate
CH_VALUEevents.What's the rationale for that ? I would actually expect the value change events to be more useful for volatile controls than non-volatile controls. Volatile controls can have their value changed by the hardware without software intervention, and it makes sense to me to report that to userspace.
Imagine a temperature register on the sensor. It is changing constantly, resolution 10 milidegrees:
Do you want to get an event for every change? Who will poll the temperature? The driver? The hardware will irq the driver....?
So I guess the less wrong solution is not throwing the ch_value event.
This is just my two cents, probably Hans has a much better global view :)
Regards.