From: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Hans Verkuil <hans.verkuil@cisco.com>, linux-media@vger.kernel.org
Subject: Re: [RFCv1 PATCH 4/9] v4l2-ctrls: add per-control events.
Date: Sat, 16 Apr 2011 11:51:27 +0300 [thread overview]
Message-ID: <4DA9588F.6030103@maxwell.research.nokia.com> (raw)
In-Reply-To: <7db9a20f6d656cee512dd4a9d3f53061.squirrel@webmail.xs4all.nl>
Hi Hans,
Thanks for the reply.
Hans Verkuil wrote:
>> Hi Hans,
>>
>> I have some more comments below. :-)
>>
>> Hans Verkuil wrote:
>>> Whenever a control changes value an event is sent to anyone that
>>> subscribed
>>> to it.
>>>
>>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
>>> ---
>>> drivers/media/video/v4l2-ctrls.c | 59 ++++++++++++++++++
>>> drivers/media/video/v4l2-event.c | 126
>>> +++++++++++++++++++++++++++-----------
>>> drivers/media/video/v4l2-fh.c | 4 +-
>>> include/linux/videodev2.h | 17 +++++-
>>> include/media/v4l2-ctrls.h | 9 +++
>>> include/media/v4l2-event.h | 2 +
>>> 6 files changed, 177 insertions(+), 40 deletions(-)
>>>
>>> diff --git a/drivers/media/video/v4l2-ctrls.c
>>> b/drivers/media/video/v4l2-ctrls.c
>>> index f75a1d4..163f412 100644
>>> --- a/drivers/media/video/v4l2-ctrls.c
>>> +++ b/drivers/media/video/v4l2-ctrls.c
>>> @@ -23,6 +23,7 @@
>>> #include <media/v4l2-ioctl.h>
>>> #include <media/v4l2-device.h>
>>> #include <media/v4l2-ctrls.h>
>>> +#include <media/v4l2-event.h>
>>> #include <media/v4l2-dev.h>
>>>
>>> /* Internal temporary helper struct, one for each v4l2_ext_control */
>>> @@ -537,6 +538,16 @@ static bool type_is_int(const struct v4l2_ctrl
>>> *ctrl)
>>> }
>>> }
>>>
>>> +static void send_event(struct v4l2_ctrl *ctrl, struct v4l2_event *ev)
>>> +{
>>> + struct v4l2_ctrl_fh *pos;
>>> +
>>> + ev->id = ctrl->id;
>>> + list_for_each_entry(pos, &ctrl->fhs, node) {
>>> + v4l2_event_queue_fh(pos->fh, ev);
>>> + }
>>
>> Shouldn't we do v4l2_ctrl_lock(ctrl) here? Or does something prevent
>> changes to the file handle list while we loop over it?
>
> This function is always called with the lock taken.
Yes, you're right.
>> v4l2_ctrl_lock() locks a mutex. Events often arrive from interrupt
>> context, which would mean the drivers would need to create a work queue
>> to tell about changes to control values.
>
> I will have to check whether it is possible to make a function that can be
> called from interrupt context. I have my doubts though whether it is 1)
> possible and 2) desirable. At least in the area of HDMI
> receivers/transmitters you will want to have a workqueue anyway.
I wonder if there could be a more generic mechanism than to implement
this in a driver itself. In some cases it may also be harmful that
events are lost, and if there's just a single event for the workqueue,
it happens too easily in my opinion.
What do you think; could/should there be a queue for control events that
arrive from interrupt context, or should that be implemented in the
drivers themselves?
Another issue with this is that workqueues require to be scheduled so
sending the event to user space gets delayed by that. One of the
important aspects of events is latency and it would be nice to be able
to minimise that --- that's one reason why events use a spinlock rather
than a mutex, the other being that they can be easily sent from
interrupt context where they mostly arrive from.
It would be nice to have the same properties for control events.
There are use cases where a user space control process would run on a
real time priority to avoid scheduling latencies caused by other
processes, and such control process receiving control events would be
affected by the low priority of the work queues.
I agree with all your responses below on locking.
Thanks.
Regards,
--
Sakari Ailus
sakari.ailus@maxwell.research.nokia.com
next prev parent reply other threads:[~2011-04-16 8:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-04 11:51 [RFCv1 PATCH 0/9] Control Events Hans Verkuil
2011-04-04 11:51 ` [RFCv1 PATCH 1/9] v4l2-ctrls: add new bitmask control type Hans Verkuil
2011-04-04 11:51 ` [RFCv1 PATCH 2/9] vivi: add bitmask test control Hans Verkuil
2011-04-04 11:51 ` [RFCv1 PATCH 3/9] v4l2-ioctl: add ctrl_handler to v4l2_fh Hans Verkuil
2011-04-08 15:10 ` Laurent Pinchart
2011-04-08 15:39 ` Hans Verkuil
2011-04-11 14:54 ` Laurent Pinchart
2011-04-04 11:51 ` [RFCv1 PATCH 4/9] v4l2-ctrls: add per-control events Hans Verkuil
2011-04-11 7:29 ` Sakari Ailus
2011-04-11 14:57 ` Hans Verkuil
2011-04-12 8:12 ` Sakari Ailus
2011-04-12 13:40 ` Hans Verkuil
2011-04-15 10:51 ` Sakari Ailus
2011-04-15 16:25 ` Hans Verkuil
2011-04-16 8:51 ` Sakari Ailus [this message]
2011-04-19 12:19 ` Laurent Pinchart
2011-04-21 11:41 ` Sakari Ailus
2011-04-21 12:16 ` Hans Verkuil
2011-04-04 11:51 ` [RFCv1 PATCH 5/9] vb2_poll: don't start DMA, leave that to the first read() Hans Verkuil
2011-04-08 7:00 ` Marek Szyprowski
2011-04-08 8:07 ` Hans Verkuil
2011-04-08 8:13 ` Marek Szyprowski
2011-04-04 11:51 ` [RFCv1 PATCH 6/9] vivi: add support for control events Hans Verkuil
2011-04-08 15:19 ` Laurent Pinchart
2011-04-08 15:43 ` Hans Verkuil
2011-04-04 11:51 ` [RFCv1 PATCH 7/9] v4l2-ctrls: add new V4L2_EVENT_CTRL_CH_STATE event Hans Verkuil
2011-04-04 11:51 ` [RFCv1 PATCH 8/9] vivi: add support for CTRL_CH_STATE events Hans Verkuil
2011-04-08 15:13 ` Laurent Pinchart
2011-04-04 11:51 ` [RFCv1 PATCH 9/9] v4l2-ctrls: add new SEND_INITIAL flag to force an initial event Hans Verkuil
2011-04-08 15:08 ` [RFCv1 PATCH 1/9] v4l2-ctrls: add new bitmask control type Laurent Pinchart
Reply instructions:
You may reply publicly 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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DA9588F.6030103@maxwell.research.nokia.com \
--to=sakari.ailus@maxwell.research.nokia.com \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox