media: v4l2-subdev: Refactor events
PATCH v2 1/1 media: v4l2-subdev: Refactor events
Controls can be exposed to userspace via a v4l-subdevX device, and userspace has to be able to subscribe to control events so that it is notified when the control changes value.
If a control handler is set for the subdev then set the HAS_EVENTS flag automatically into v4l2_subdev_init_finalize() and use v4l2_ctrl_subdev_subscribe_event() and v4l2_event_subdev_unsubscribe() as default if subdev don't have .(un)subscribe control operations.
---
Changes since v1:
- Aligned event subscription with unsubscription as suggested by LPinchart, SAilus
drivers/media/v4l2-core/v4l2-subdev.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-subdev.c +20 -2
@@ -691,10 +691,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,return v4l2_event_dequeue (vfh, arg, file->f_flags &O_NONBLOCK );case VIDIOC_SUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, subscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, subscribe_event)) +return v4l2_subdev_call (sd, core, subscribe_event, + vfh, arg); + +if ((sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) && + vfh->ctrl_handler) +return v4l2_ctrl_subdev_subscribe_event (sd, vfh, arg); + +return -ENOIOCTLCMD ;case VIDIOC_UNSUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, unsubscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, unsubscribe_event)) +return v4l2_subdev_call (sd, core, unsubscribe_event, + vfh, arg); + +if (sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) +return v4l2_event_subdev_unsubscribe (sd, vfh, arg); + +return -ENOIOCTLCMD ;#ifdef CONFIG_VIDEO_ADV_DEBUG case VIDIOC_DBG_G_REGISTER :
@@ -1641,6 +1656,9 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, } } +if (sd->ctrl_handler) + sd->flags |=V4L2_SUBDEV_FL_HAS_EVENTS ; + state =__v4l2_subdev_state_alloc (sd, name, key);if (IS_ERR (state))return PTR_ERR (state);
Signature · 1 line
2.34.1
Hi Tommaso,
Thank you for the patch.
Quoted 7 lines · Tommaso Merciai
Controls can be exposed to userspace via a v4l-subdevX device, and userspace has to be able to subscribe to control events so that it is notified when the control changes value.
If a control handler is set for the subdev then set theHAS_EVENTSflag automatically intov4l2_subdev_init_finalize()and usev4l2_ctrl_subdev_subscribe_event()andv4l2_event_subdev_unsubscribe()as default if subdev don't have .(un)subscribe control operations.
I would add here
This simplifies subdev drivers by avoiding the need to set the V4L2_SUBDEV_FL_HAS_EVENTS flag and plug the event handlers, and ensures consistency of the API exposed to userspace.
And you can also add
Quoted 1 line
Signed-off-by Tommaso Merciai <[email protected]>
Now, can we simplify sensor drivers to drop the event handlers and the flag ? :-)
Quoted 50 lines
---
Changes since v1:
- Aligned event subscription with unsubscription as suggested by LPinchart, SAilusdrivers/media/v4l2-core/v4l2-subdev.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)drivers/media/v4l2-core/v4l2-subdev.c +20
-2@@ -691,10 +691,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,return v4l2_event_dequeue (vfh, arg, file->f_flags &O_NONBLOCK );case VIDIOC_SUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, subscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, subscribe_event)) +return v4l2_subdev_call (sd, core, subscribe_event, + vfh, arg); + +if ((sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) && + vfh->ctrl_handler) +return v4l2_ctrl_subdev_subscribe_event (sd, vfh, arg); + +return -ENOIOCTLCMD ;case VIDIOC_UNSUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, unsubscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, unsubscribe_event)) +return v4l2_subdev_call (sd, core, unsubscribe_event, + vfh, arg); + +if (sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) +return v4l2_event_subdev_unsubscribe (sd, vfh, arg); + +return -ENOIOCTLCMD ;#ifdef CONFIG_VIDEO_ADV_DEBUG case VIDIOC_DBG_G_REGISTER :@@ -1641,6 +1656,9 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, } } +if (sd->ctrl_handler) + sd->flags |=V4L2_SUBDEV_FL_HAS_EVENTS ; + state =__v4l2_subdev_state_alloc (sd, name, key);if (IS_ERR (state))return PTR_ERR (state);
Signature · 3 lines
Regards, Laurent Pinchart
Hi Laurent,
Thanks for your review.
Quoted 19 lines · Laurent Pinchart
Hi Tommaso,
Thank you for the patch.
Quoted 7 lines · Tommaso Merciai
Controls can be exposed to userspace via a v4l-subdevX device, and userspace has to be able to subscribe to control events so that it is notified when the control changes value.
If a control handler is set for the subdev then set theHAS_EVENTSflag automatically intov4l2_subdev_init_finalize()and usev4l2_ctrl_subdev_subscribe_event()andv4l2_event_subdev_unsubscribe()as default if subdev don't have .(un)subscribe control operations.I would add here
This simplifies subdev drivers by avoiding the need to set the
V4L2_SUBDEV_FL_HAS_EVENTSflag and plug the event handlers, and ensures consistency of the API exposed to userspace.
Quoted 7 lines
And you can also add
Suggested-by Laurent Pinchart <[email protected]>Quoted 1 line
Signed-off-by Tommaso Merciai <[email protected]>Reviewed-by Laurent Pinchart <[email protected]>
Oks, Thanks again.
Quoted 3 lines
Now, can we simplify sensor drivers to drop the event handlers and the flag ? :-)
Yep, plan is add all to support v4l2_subdev_init_finalize() Removing:
.subscribe_event = v4l2_ctrl_subdev_subscribe_event, .unsubscribe_event = v4l2_event_subdev_unsubscribe,
if are used. And ofc V4L2_SUBDEV_FL_HAS_EVENTS.
Meanwhile I think I will send v3 with your
suggestions. :)
Thanks & Regards,
Tommaso
Quoted 56 lines
Quoted 51 lines
---
Changes since v1:
- Aligned event subscription with unsubscription as suggested by LPinchart, SAilusdrivers/media/v4l2-core/v4l2-subdev.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)drivers/media/v4l2-core/v4l2-subdev.c +20
-2@@ -691,10 +691,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,return v4l2_event_dequeue (vfh, arg, file->f_flags &O_NONBLOCK );case VIDIOC_SUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, subscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, subscribe_event)) +return v4l2_subdev_call (sd, core, subscribe_event, + vfh, arg); + +if ((sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) && + vfh->ctrl_handler) +return v4l2_ctrl_subdev_subscribe_event (sd, vfh, arg); + +return -ENOIOCTLCMD ;case VIDIOC_UNSUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, unsubscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, unsubscribe_event)) +return v4l2_subdev_call (sd, core, unsubscribe_event, + vfh, arg); + +if (sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) +return v4l2_event_subdev_unsubscribe (sd, vfh, arg); + +return -ENOIOCTLCMD ;#ifdef CONFIG_VIDEO_ADV_DEBUG case VIDIOC_DBG_G_REGISTER :@@ -1641,6 +1656,9 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, } } +if (sd->ctrl_handler) + sd->flags |=V4L2_SUBDEV_FL_HAS_EVENTS ; + state =__v4l2_subdev_state_alloc (sd, name, key);if (IS_ERR (state))return PTR_ERR (state);Signature · 3 lines
Regards, Laurent Pinchart
Quoted 36 lines · Tommaso Merciai
Hi Laurent,
Thanks for your review.Quoted 19 lines · Laurent Pinchart
Hi Tommaso,
Thank you for the patch.
Quoted 7 lines · Tommaso Merciai
Controls can be exposed to userspace via a v4l-subdevX device, and userspace has to be able to subscribe to control events so that it is notified when the control changes value.
If a control handler is set for the subdev then set theHAS_EVENTSflag automatically intov4l2_subdev_init_finalize()and usev4l2_ctrl_subdev_subscribe_event()andv4l2_event_subdev_unsubscribe()as default if subdev don't have .(un)subscribe control operations.I would add here
This simplifies subdev drivers by avoiding the need to set the
V4L2_SUBDEV_FL_HAS_EVENTSflag and plug the event handlers, and ensures consistency of the API exposed to userspace.Quoted 7 lines
And you can also add
Suggested-by Laurent Pinchart <[email protected]>Quoted 1 line
Signed-off-by Tommaso Merciai <[email protected]>Reviewed-by Laurent Pinchart <[email protected]>Oks, Thanks again.
Quoted 2 lines
Now, can we simplify sensor drivers to drop the event handlers and the flag ? :-)
Quoted 7 lines
Yep, plan is add all to support
v4l2_subdev_init_finalize()Removing:.subscribe_event =
v4l2_ctrl_subdev_subscribe_event, .unsubscribe_event =v4l2_event_subdev_unsubscribe,if are used. And ofc
V4L2_SUBDEV_FL_HAS_EVENTS.
What I meant is looking at the I2C sensor drivers that currently
- call v4l2_subdev_init_finalize()
- set V4L2_SUBDEV_FL_HAS_EVENTS
- set the .subscribe_event() and .unsubscribe_event() handlers
and dropping the flag and handlers from them. Is that what you plan to work on ?
Quoted 53 lines
Meanwhile I think I will send v3 with your
suggestions. :)Quoted 50 lines
Quoted 50 lines
---
Changes since v1:
- Aligned event subscription with unsubscription as suggested by LPinchart, SAilusdrivers/media/v4l2-core/v4l2-subdev.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)drivers/media/v4l2-core/v4l2-subdev.c +20
-2@@ -691,10 +691,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,return v4l2_event_dequeue (vfh, arg, file->f_flags &O_NONBLOCK );case VIDIOC_SUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, subscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, subscribe_event)) +return v4l2_subdev_call (sd, core, subscribe_event, + vfh, arg); + +if ((sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) && + vfh->ctrl_handler) +return v4l2_ctrl_subdev_subscribe_event (sd, vfh, arg); + +return -ENOIOCTLCMD ;case VIDIOC_UNSUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, unsubscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, unsubscribe_event)) +return v4l2_subdev_call (sd, core, unsubscribe_event, + vfh, arg); + +if (sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) +return v4l2_event_subdev_unsubscribe (sd, vfh, arg); + +return -ENOIOCTLCMD ;#ifdef CONFIG_VIDEO_ADV_DEBUG case VIDIOC_DBG_G_REGISTER :@@ -1641,6 +1656,9 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, } } +if (sd->ctrl_handler) + sd->flags |=V4L2_SUBDEV_FL_HAS_EVENTS ; + state =__v4l2_subdev_state_alloc (sd, name, key);if (IS_ERR (state))return PTR_ERR (state);
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 45 lines · Laurent Pinchart
Quoted 36 lines · Tommaso Merciai
Hi Laurent,
Thanks for your review.Quoted 19 lines · Laurent Pinchart
Hi Tommaso,
Thank you for the patch.
Quoted 7 lines · Tommaso Merciai
Controls can be exposed to userspace via a v4l-subdevX device, and userspace has to be able to subscribe to control events so that it is notified when the control changes value.
If a control handler is set for the subdev then set theHAS_EVENTSflag automatically intov4l2_subdev_init_finalize()and usev4l2_ctrl_subdev_subscribe_event()andv4l2_event_subdev_unsubscribe()as default if subdev don't have .(un)subscribe control operations.I would add here
This simplifies subdev drivers by avoiding the need to set the
V4L2_SUBDEV_FL_HAS_EVENTSflag and plug the event handlers, and ensures consistency of the API exposed to userspace.Quoted 7 lines
And you can also add
Suggested-by Laurent Pinchart <[email protected]>Quoted 1 line
Signed-off-by Tommaso Merciai <[email protected]>Reviewed-by Laurent Pinchart <[email protected]>Oks, Thanks again.
Quoted 2 lines
Now, can we simplify sensor drivers to drop the event handlers and the flag ? :-)
Quoted 7 lines
Yep, plan is add all to support
v4l2_subdev_init_finalize()Removing:.subscribe_event =
v4l2_ctrl_subdev_subscribe_event, .unsubscribe_event =v4l2_event_subdev_unsubscribe,if are used. And ofc
V4L2_SUBDEV_FL_HAS_EVENTS.
Quoted 8 lines
What I meant is looking at the I2C sensor drivers that currently
- call
v4l2_subdev_init_finalize()
- setV4L2_SUBDEV_FL_HAS_EVENTS
- set the .subscribe_event() and .unsubscribe_event() handlersand dropping the flag and handlers from them. Is that what you plan to work on ?
Yep, I will take a look on that. :)
Thanks & Regards,
Tommaso
Quoted 59 lines
Quoted 54 lines
Meanwhile I think I will send v3 with your
suggestions. :)Quoted 50 lines
Quoted 50 lines
---
Changes since v1:
- Aligned event subscription with unsubscription as suggested by LPinchart, SAilusdrivers/media/v4l2-core/v4l2-subdev.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)drivers/media/v4l2-core/v4l2-subdev.c +20
-2@@ -691,10 +691,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,return v4l2_event_dequeue (vfh, arg, file->f_flags &O_NONBLOCK );case VIDIOC_SUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, subscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, subscribe_event)) +return v4l2_subdev_call (sd, core, subscribe_event, + vfh, arg); + +if ((sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) && + vfh->ctrl_handler) +return v4l2_ctrl_subdev_subscribe_event (sd, vfh, arg); + +return -ENOIOCTLCMD ;case VIDIOC_UNSUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, unsubscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, unsubscribe_event)) +return v4l2_subdev_call (sd, core, unsubscribe_event, + vfh, arg); + +if (sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) +return v4l2_event_subdev_unsubscribe (sd, vfh, arg); + +return -ENOIOCTLCMD ;#ifdef CONFIG_VIDEO_ADV_DEBUG case VIDIOC_DBG_G_REGISTER :@@ -1641,6 +1656,9 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, } } +if (sd->ctrl_handler) + sd->flags |=V4L2_SUBDEV_FL_HAS_EVENTS ; + state =__v4l2_subdev_state_alloc (sd, name, key);if (IS_ERR (state))return PTR_ERR (state);Signature · 3 lines
Regards, Laurent Pinchart
Hi Laurent, Sakari,
Sorry for the delay.
Back on this topic.
Quoted 45 lines · Laurent Pinchart
Quoted 36 lines · Tommaso Merciai
Hi Laurent,
Thanks for your review.Quoted 19 lines · Laurent Pinchart
Hi Tommaso,
Thank you for the patch.
Quoted 7 lines · Tommaso Merciai
Controls can be exposed to userspace via a v4l-subdevX device, and userspace has to be able to subscribe to control events so that it is notified when the control changes value.
If a control handler is set for the subdev then set theHAS_EVENTSflag automatically intov4l2_subdev_init_finalize()and usev4l2_ctrl_subdev_subscribe_event()andv4l2_event_subdev_unsubscribe()as default if subdev don't have .(un)subscribe control operations.I would add here
This simplifies subdev drivers by avoiding the need to set the
V4L2_SUBDEV_FL_HAS_EVENTSflag and plug the event handlers, and ensures consistency of the API exposed to userspace.Quoted 7 lines
And you can also add
Suggested-by Laurent Pinchart <[email protected]>Quoted 1 line
Signed-off-by Tommaso Merciai <[email protected]>Reviewed-by Laurent Pinchart <[email protected]>Oks, Thanks again.
Quoted 2 lines
Now, can we simplify sensor drivers to drop the event handlers and the flag ? :-)
Quoted 7 lines
Yep, plan is add all to support
v4l2_subdev_init_finalize()Removing:.subscribe_event =
v4l2_ctrl_subdev_subscribe_event, .unsubscribe_event =v4l2_event_subdev_unsubscribe,if are used. And ofc
V4L2_SUBDEV_FL_HAS_EVENTS.
Quoted 8 lines
What I meant is looking at the I2C sensor drivers that currently
- call
v4l2_subdev_init_finalize()
- setV4L2_SUBDEV_FL_HAS_EVENTS
- set the .subscribe_event() and .unsubscribe_event() handlersand dropping the flag and handlers from them. Is that what you plan to work on ?
It's ok for you per/driver patch or you prefer a big single patch?
Meanwhile I've prepared something here:
Let me know if you prefer (un)squashed version.
Thanks in advance. :)
Thanks & Regards,
Tommaso
Quoted 59 lines
Quoted 54 lines
Meanwhile I think I will send v3 with your
suggestions. :)Quoted 50 lines
Quoted 50 lines
---
Changes since v1:
- Aligned event subscription with unsubscription as suggested by LPinchart, SAilusdrivers/media/v4l2-core/v4l2-subdev.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)drivers/media/v4l2-core/v4l2-subdev.c +20
-2@@ -691,10 +691,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,return v4l2_event_dequeue (vfh, arg, file->f_flags &O_NONBLOCK );case VIDIOC_SUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, subscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, subscribe_event)) +return v4l2_subdev_call (sd, core, subscribe_event, + vfh, arg); + +if ((sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) && + vfh->ctrl_handler) +return v4l2_ctrl_subdev_subscribe_event (sd, vfh, arg); + +return -ENOIOCTLCMD ;case VIDIOC_UNSUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, unsubscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, unsubscribe_event)) +return v4l2_subdev_call (sd, core, unsubscribe_event, + vfh, arg); + +if (sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) +return v4l2_event_subdev_unsubscribe (sd, vfh, arg); + +return -ENOIOCTLCMD ;#ifdef CONFIG_VIDEO_ADV_DEBUG case VIDIOC_DBG_G_REGISTER :@@ -1641,6 +1656,9 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, } } +if (sd->ctrl_handler) + sd->flags |=V4L2_SUBDEV_FL_HAS_EVENTS ; + state =__v4l2_subdev_state_alloc (sd, name, key);if (IS_ERR (state))return PTR_ERR (state);Signature · 3 lines
Regards, Laurent Pinchart
Hi Tommaso,
Quoted 41 lines · Tommaso Merciai
Quoted 40 lines · Laurent Pinchart
Quoted 29 lines · Tommaso Merciai
Quoted 15 lines · Laurent Pinchart
Quoted 7 lines · Tommaso Merciai
Controls can be exposed to userspace via a v4l-subdevX device, and userspace has to be able to subscribe to control events so that it is notified when the control changes value.
If a control handler is set for the subdev then set theHAS_EVENTSflag automatically intov4l2_subdev_init_finalize()and usev4l2_ctrl_subdev_subscribe_event()andv4l2_event_subdev_unsubscribe()as default if subdev don't have .(un)subscribe control operations.I would add here
This simplifies subdev drivers by avoiding the need to set the
V4L2_SUBDEV_FL_HAS_EVENTSflag and plug the event handlers, and ensures consistency of the API exposed to userspace.Quoted 7 lines
And you can also add
Suggested-by Laurent Pinchart <[email protected]>Quoted 1 line
Signed-off-by Tommaso Merciai <[email protected]>Reviewed-by Laurent Pinchart <[email protected]>Oks, Thanks again.
Quoted 2 lines
Now, can we simplify sensor drivers to drop the event handlers and the flag ? :-)
Quoted 7 lines
Yep, plan is add all to support
v4l2_subdev_init_finalize()Removing:.subscribe_event =
v4l2_ctrl_subdev_subscribe_event, .unsubscribe_event =v4l2_event_subdev_unsubscribe,if are used. And ofc
V4L2_SUBDEV_FL_HAS_EVENTS.What I meant is looking at the I2C sensor drivers that currently
Quoted 8 lines
Quoted 6 lines
- call
v4l2_subdev_init_finalize()
- setV4L2_SUBDEV_FL_HAS_EVENTS
- set the .subscribe_event() and .unsubscribe_event() handlersand dropping the flag and handlers from them. Is that what you plan to work on ?
It's ok for you per/driver patch or you prefer a big single patch?
I'm fine either way. Maybe one large patch to address all the drivers where the flag and handlers are simply dropped, and then one patch per driver where changes are larger (such as adding calls to v4l2_subdev_init_finalize()) ?
Quoted 64 lines
Meanwhile I've prepared something here:
Let me know if you prefer (un)squashed version.
Thanks in advance. :)Thanks & Regards,
TommasoQuoted 54 lines
Quoted 54 lines
Meanwhile I think I will send v3 with your
suggestions. :)Quoted 50 lines
Quoted 50 lines
---
Changes since v1:
- Aligned event subscription with unsubscription as suggested by LPinchart, SAilusdrivers/media/v4l2-core/v4l2-subdev.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)drivers/media/v4l2-core/v4l2-subdev.c +20
-2@@ -691,10 +691,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,return v4l2_event_dequeue (vfh, arg, file->f_flags &O_NONBLOCK );case VIDIOC_SUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, subscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, subscribe_event)) +return v4l2_subdev_call (sd, core, subscribe_event, + vfh, arg); + +if ((sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) && + vfh->ctrl_handler) +return v4l2_ctrl_subdev_subscribe_event (sd, vfh, arg); + +return -ENOIOCTLCMD ;case VIDIOC_UNSUBSCRIBE_EVENT : -return v4l2_subdev_call (sd, core, unsubscribe_event, vfh, arg); +if (v4l2_subdev_has_op (sd, core, unsubscribe_event)) +return v4l2_subdev_call (sd, core, unsubscribe_event, + vfh, arg); + +if (sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS ) +return v4l2_event_subdev_unsubscribe (sd, vfh, arg); + +return -ENOIOCTLCMD ;#ifdef CONFIG_VIDEO_ADV_DEBUG case VIDIOC_DBG_G_REGISTER :@@ -1641,6 +1656,9 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, } } +if (sd->ctrl_handler) + sd->flags |=V4L2_SUBDEV_FL_HAS_EVENTS ; + state =__v4l2_subdev_state_alloc (sd, name, key);if (IS_ERR (state))return PTR_ERR (state);
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 9 lines · Laurent Pinchart
Quoted 9 lines
Quoted 8 lines
What I meant is looking at the I2C sensor drivers that currently
- call
v4l2_subdev_init_finalize()
- setV4L2_SUBDEV_FL_HAS_EVENTS
- set the .subscribe_event() and .unsubscribe_event() handlersand dropping the flag and handlers from them. Is that what you plan to work on ?
Quoted 6 lines
Quoted 1 line
It's ok for you per/driver patch or you prefer a big single patch?
I'm fine either way. Maybe one large patch to address all the drivers where the flag and handlers are simply dropped, and then one patch per driver where changes are larger (such as adding calls to
v4l2_subdev_init_finalize()) ?
Sounds good to me.
Signature · 1 line
Sakari Ailus
Sakari Ailus
AppliedHi Laurent, Tommaso,
Quoted 19 lines · Laurent Pinchart
Hi Tommaso,
Thank you for the patch.
Quoted 7 lines · Tommaso Merciai
Controls can be exposed to userspace via a v4l-subdevX device, and userspace has to be able to subscribe to control events so that it is notified when the control changes value.
If a control handler is set for the subdev then set theHAS_EVENTSflag automatically intov4l2_subdev_init_finalize()and usev4l2_ctrl_subdev_subscribe_event()andv4l2_event_subdev_unsubscribe()as default if subdev don't have .(un)subscribe control operations.I would add here
This simplifies subdev drivers by avoiding the need to set the
V4L2_SUBDEV_FL_HAS_EVENTSflag and plug the event handlers, and ensures consistency of the API exposed to userspace.
Quoted 7 lines
And you can also add
Suggested-by Laurent Pinchart <[email protected]>Quoted 1 line
Signed-off-by Tommaso Merciai <[email protected]>Reviewed-by Laurent Pinchart <[email protected]>
Thanks!
I've picked this to my tree.
Please try to properly wrap the commit message the next time, most editors can do that automatically.
Signature · 1 line
Sakari Ailus
Hi Sakari,
Quoted 28 lines · Sakari Ailus
Hi Laurent, Tommaso,
Quoted 25 lines · Laurent Pinchart
Hi Tommaso,
Thank you for the patch.
Quoted 7 lines · Tommaso Merciai
Controls can be exposed to userspace via a v4l-subdevX device, and userspace has to be able to subscribe to control events so that it is notified when the control changes value.
If a control handler is set for the subdev then set theHAS_EVENTSflag automatically intov4l2_subdev_init_finalize()and usev4l2_ctrl_subdev_subscribe_event()andv4l2_event_subdev_unsubscribe()as default if subdev don't have .(un)subscribe control operations.I would add here
This simplifies subdev drivers by avoiding the need to set the
V4L2_SUBDEV_FL_HAS_EVENTSflag and plug the event handlers, and ensures consistency of the API exposed to userspace.And you can also add
Suggested-by Laurent Pinchart <[email protected]>Quoted 1 line
Signed-off-by Tommaso Merciai <[email protected]>
Quoted 8 lines
Quoted 1 line
Reviewed-by Laurent Pinchart <[email protected]>Thanks!
I've picked this to my tree.
Please try to properly wrap the commit message the next time, most editors can do that automatically.
Mmm..
In theory I have this cfg for my vim:
filetype plugin indent on
syntax on
set title
set tabstop=8
set softtabstop=8
set shiftwidth=8
set noexpandtab
set number
set hidden
Thanks & Regards,
Tommaso
Quoted 3 lines
Signature · 2 lines
-- Sakari Ailus