All of lore.kernel.org
 help / color / mirror / Atom feed
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: Tue, 12 Apr 2011 11:12:25 +0300	[thread overview]
Message-ID: <4DA40969.0@maxwell.research.nokia.com> (raw)
In-Reply-To: <de36e47085bf38f0b4e95740ab43b85f.squirrel@webmail.xs4all.nl>

Hi Hans,

Hans Verkuil wrote:
[clip]
>>> diff --git a/drivers/media/video/v4l2-fh.c
>>> b/drivers/media/video/v4l2-fh.c
>>> index 8635011..c6aef84 100644
>>> --- a/drivers/media/video/v4l2-fh.c
>>> +++ b/drivers/media/video/v4l2-fh.c
>>> @@ -93,10 +93,8 @@ void v4l2_fh_exit(struct v4l2_fh *fh)
>>>  {
>>>  	if (fh->vdev == NULL)
>>>  		return;
>>> -
>>> -	fh->vdev = NULL;
>>> -
>>>  	v4l2_event_free(fh);
>>> +	fh->vdev = NULL;
>>
>> This looks like a bugfix.
> 
> But it isn't :-)
> 
> v4l2_event_free didn't use fh->vdev in the past, but now it does so the
> order had to be swapped.

Ok.

>>
>>>  }
>>>  EXPORT_SYMBOL_GPL(v4l2_fh_exit);
>>>
>>> diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
>>> index 92d2fdd..f7238c1 100644
>>> --- a/include/linux/videodev2.h
>>> +++ b/include/linux/videodev2.h
>>> @@ -1787,6 +1787,7 @@ struct v4l2_streamparm {
>>>  #define V4L2_EVENT_ALL				0
>>>  #define V4L2_EVENT_VSYNC			1
>>>  #define V4L2_EVENT_EOS				2
>>> +#define V4L2_EVENT_CTRL_CH_VALUE		3
>>>  #define V4L2_EVENT_PRIVATE_START		0x08000000
>>>
>>>  /* Payload for V4L2_EVENT_VSYNC */
>>> @@ -1795,21 +1796,33 @@ struct v4l2_event_vsync {
>>>  	__u8 field;
>>>  } __attribute__ ((packed));
>>>
>>> +/* Payload for V4L2_EVENT_CTRL_CH_VALUE */
>>> +struct v4l2_event_ctrl_ch_value {
>>> +	__u32 type;
>>
>> type is enum v4l2_ctrl_type in struct v4l2_ctrl and struct v4l2_queryctrl.
> 
> Yes, but enum's are frowned upon these days in the public API.

Agreed.

>>
>>> +	union {
>>> +		__s32 value;
>>> +		__s64 value64;
>>> +	};
>>> +} __attribute__ ((packed));
>>> +
>>>  struct v4l2_event {
>>>  	__u32				type;
>>>  	union {
>>>  		struct v4l2_event_vsync vsync;
>>> +		struct v4l2_event_ctrl_ch_value ctrl_ch_value;
>>>  		__u8			data[64];
>>>  	} u;
>>>  	__u32				pending;
>>>  	__u32				sequence;
>>>  	struct timespec			timestamp;
>>> -	__u32				reserved[9];
>>> +	__u32				id;
>>
>> id is valid only for control related events. Shouldn't it be part of the
>> control related structures instead, or another union for control related
>> event types? E.g.
>>
>> struct {
>> 	enum v4l2_ctrl_type	id;
>> 	union {
>> 		struct v4l2_event_ctrl_ch_value ch_value;
>> 	};
>> } ctrl;
> 
> The problem with making this dependent of the type is that the core event
> code would have to have a switch on the event type when it comes to
> matching identifiers. By making it a core field it doesn't have to do
> this. Also, this makes it available for use by private events as well.
> 
> It is important to keep the send-event core code as fast as possible since
> it can be called from interrupt context.
> 
> So this is by design.

I understand your point, and agree with it. There would be a few places
in the v4l2-event.c that one would have to know if the event is
control-related or not.

As the id field is handled in the v4l2-event.c the way it is, it must be
zero when the event is not a control-related one. This makes it
impossible to use it for other purposes, at least for now.

What about renaming the field to ctrl_id? Or do you think we could have
other use for the field outside the scope of the control-related events?

The benefit of the current name is still that it does not suggest
anything on the implementation.

Cheers,

-- 
Sakari Ailus
sakari.ailus@maxwell.research.nokia.com

  reply	other threads:[~2011-04-12  8:09 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 [this message]
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
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=4DA40969.0@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 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.