From: Hans de Goede <hdegoede@redhat.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
hverkuil@xs4all.nl
Subject: Re: [PATCH 5/6] v4l2-event: Add v4l2_subscribed_event_ops
Date: Fri, 28 Oct 2011 10:37:19 +0200 [thread overview]
Message-ID: <4EAA69BF.8060702@redhat.com> (raw)
In-Reply-To: <201110271430.25044.laurent.pinchart@ideasonboard.com>
Hi,
On 10/27/2011 02:30 PM, Laurent Pinchart wrote:
> Hi Hans,
>
> On Thursday 27 October 2011 13:18:02 Hans de Goede wrote:
>> Just like with ctrl events, drivers may want to get called back on
>> listener add / remove for other event types too. Rather then special
>> casing all of this in subscribe / unsubscribe event it is better to
>> use ops for this.
>>
>> Signed-off-by: Hans de Goede<hdegoede@redhat.com>
>> ---
>> drivers/media/video/ivtv/ivtv-ioctl.c | 2 +-
>> drivers/media/video/omap3isp/ispccdc.c | 2 +-
>> drivers/media/video/omap3isp/ispstat.c | 2 +-
>> drivers/media/video/pwc/pwc-v4l.c | 2 +-
>> drivers/media/video/v4l2-event.c | 42 ++++++++++++++++++++++-------
>> drivers/media/video/vivi.c | 2 +-
>> include/media/v4l2-event.h | 24 +++++++++++++-----
>
> Haven't you forgotten to update Documentation/video4linux/v4l2-framework.txt ?
>
I think I have, I'll go and do another revision fixing this.
>> 7 files changed, 54 insertions(+), 22 deletions(-)
>
> [snip]
>
>> diff --git a/drivers/media/video/v4l2-event.c
>> b/drivers/media/video/v4l2-event.c index 3d27300..2dd9252 100644
>> --- a/drivers/media/video/v4l2-event.c
>> +++ b/drivers/media/video/v4l2-event.c
>> @@ -131,14 +131,14 @@ static void __v4l2_event_queue_fh(struct v4l2_fh *fh,
>> const struct v4l2_event *e sev->first = sev_pos(sev, 1);
>> fh->navailable--;
>> if (sev->elems == 1) {
>> - if (sev->replace) {
>> - sev->replace(&kev->event, ev);
>> + if (sev->ops&& sev->ops->replace) {
>> + sev->ops->replace(&kev->event, ev);
>> copy_payload = false;
>> }
>> - } else if (sev->merge) {
>> + } else if (sev->ops&& sev->ops->merge) {
>> struct v4l2_kevent *second_oldest =
>> sev->events + sev_pos(sev, 0);
>> - sev->merge(&kev->event,&second_oldest->event);
>> + sev->ops->merge(&kev->event,&second_oldest->event);
>> }
>> }
>>
>> @@ -207,8 +207,14 @@ static void ctrls_merge(const struct v4l2_event *old,
>> struct v4l2_event *new) new->u.ctrl.changes |= old->u.ctrl.changes;
>> }
>>
>> +const struct v4l2_subscribed_event_ops ctrl_ops = {
>
> Shouldn't this be static const ?
>
You're right I will fix this in the next iteration.
>> + .replace = ctrls_replace,
>> + .merge = ctrls_merge,
>> +};
>> +
>> int v4l2_event_subscribe(struct v4l2_fh *fh,
>> - struct v4l2_event_subscription *sub, unsigned elems)
>> + struct v4l2_event_subscription *sub, unsigned elems,
>> + const struct v4l2_subscribed_event_ops *ops)
>> {
>> struct v4l2_subscribed_event *sev, *found_ev;
>> struct v4l2_ctrl *ctrl = NULL;
>> @@ -236,9 +242,9 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
>> sev->flags = sub->flags;
>> sev->fh = fh;
>> sev->elems = elems;
>> + sev->ops = ops;
>> if (ctrl) {
>> - sev->replace = ctrls_replace;
>> - sev->merge = ctrls_merge;
>> + sev->ops =&ctrl_ops;
>> }
>
> You can remove the brackets here.
>
I was aiming for minimal diff size here, since this bit will go away in the
next patch in the series anyways.
>>
>> spin_lock_irqsave(&fh->vdev->fh_lock, flags);
>> @@ -247,10 +253,22 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
>> list_add(&sev->list,&fh->subscribed);
>> spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
>>
>> - /* v4l2_ctrl_add_event uses a mutex, so do this outside the spin lock */
>> - if (found_ev)
>> + if (found_ev) {
>> kfree(sev);
>> - else if (ctrl)
>> + return 0; /* Already listening */
>> + }
>> +
>> + if (sev->ops&& sev->ops->add) {
>> + int ret = sev->ops->add(sev);
>> + if (ret) {
>> + sev->ops = NULL;
>> + v4l2_event_unsubscribe(fh, sub);
>> + return ret;
>> + }
>> + }
>> +
>> + /* v4l2_ctrl_add_event uses a mutex, so do this outside the spin lock */
>> + if (ctrl)
>> v4l2_ctrl_add_event(ctrl, sev);
>>
>> return 0;
>> @@ -307,6 +325,10 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
>> }
>>
>> spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
>> +
>> + if (sev&& sev->ops&& sev->ops->del)
>> + sev->ops->del(sev);
>> +
>> if (sev&& sev->type == V4L2_EVENT_CTRL) {
>> struct v4l2_ctrl *ctrl = v4l2_ctrl_find(fh->ctrl_handler, sev->id);
>>
>
Regards,
Hans
next prev parent reply other threads:[~2011-10-28 8:37 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-27 11:17 Various ctrl and event frame work patches Hans de Goede
2011-10-27 11:17 ` [PATCH 1/6] v4l2-ctrl: Send change events to all fh for auto cluster slave controls Hans de Goede
2011-10-30 10:16 ` Hans Verkuil
2011-10-27 11:17 ` [PATCH 2/6] v4l2-event: Deny subscribing with a type of V4L2_EVENT_ALL Hans de Goede
2011-10-27 12:04 ` Laurent Pinchart
2011-10-30 10:17 ` Hans Verkuil
2011-10-27 11:18 ` [PATCH 3/6] v4l2-event: Remove pending events from fh event queue when unsubscribing Hans de Goede
2011-10-27 12:07 ` Laurent Pinchart
2011-10-30 10:24 ` Hans Verkuil
2011-10-27 11:18 ` [PATCH 4/6] v4l2-event: Don't set sev->fh to NULL on unsubcribe Hans de Goede
2011-10-27 12:20 ` Laurent Pinchart
2011-10-28 8:35 ` Hans de Goede
2011-10-28 11:48 ` Laurent Pinchart
2011-10-30 10:30 ` Hans Verkuil
2011-10-27 11:18 ` [PATCH 5/6] v4l2-event: Add v4l2_subscribed_event_ops Hans de Goede
2011-10-27 12:30 ` Laurent Pinchart
2011-10-28 8:37 ` Hans de Goede [this message]
2011-10-30 11:17 ` Hans Verkuil
2011-10-30 11:37 ` Hans Verkuil
2011-10-27 11:18 ` [PATCH 6/6] v4l2-ctrls: Use v4l2_subscribed_event_ops Hans de Goede
2011-10-30 11:24 ` Hans Verkuil
-- strict thread matches above, loose matches on Subject: below --
2011-10-31 15:16 Various ctrl and event frame work patches (version 2) Hans de Goede
2011-10-31 15:16 ` [PATCH 5/6] v4l2-event: Add v4l2_subscribed_event_ops Hans de Goede
2011-11-02 10:04 Hans de Goede
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=4EAA69BF.8060702@redhat.com \
--to=hdegoede@redhat.com \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.