public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Nathaniel Kim <dongsoo.kim@gmail.com>,
	linux-media@vger.kernel.org,
	Laurent Pinchart <laurent.pinchart@skynet.be>
Subject: Re: Media controller: sysfs vs ioctl
Date: Mon, 21 Sep 2009 20:23:54 +0300	[thread overview]
Message-ID: <4AB7B6AA.3070404@maxwell.research.nokia.com> (raw)
In-Reply-To: <200909131103.20202.hverkuil@xs4all.nl>

Hans Verkuil wrote:
> On Sunday 13 September 2009 08:13:04 Nathaniel Kim wrote:
>> 2009. 9. 12., 오전 7:21, Hans Verkuil 작성:
>>
>> Hans,
>>
>> First of all I'm very sorry that I had not enough time to go through  
>> your new RFC. I'll checkout right after posting this mail.
>>
>> I think this is a good approach and I also had in my mind that sysfs  
>> might be a good method if we could control and monitor through this.  
>> Recalling memory when we had a talk in San Francisco, I was frustrated  
>> that there is no way to catch events from sort of sub-devices like  
>> lens actuator (I mean pizeo motors in camera module). As you know lens  
>> actuator is an extremely slow device in comparison with common v4l2  
>> devices we are using and we need to know whether it has succeeded or  
>> not in moving to expected position.
>> So I considered sysfs and udev as candidates for catching events from  
>> sub-devices. events like success/failure of lens movement, change of  
>> status of subdevices.
>> Does anybody experiencing same issue? I think I've seen a lens  
>> controller driver in omap3 kernel from TI but not sure how did they  
>> control that.
>>
>> My point is that we need a kind of framework to give and event to user  
>> space and catching them properly just like udev does.
> 
> When I was talking to Laurent Pinchart and Sakari and his team at Nokia
> we discussed just such a framework. It actually exists already, although
> it is poorly implemented.
> 
> Look at include/linux/dvb/video.h, struct video_event and ioctl VIDEO_GET_EVENT.
> It is used in ivtv (ivtv-ioctl.c, look for VIDEO_GET_EVENT).
> 
> The idea is that you can either call VIDEO_GET_EVENT to wait for an event
> or use select() and wait for an exception to arrive, and then call
> VIDEO_GET_EVENT to find which event it was.
> 
> This is ideal for streaming-related events. In ivtv it is used to report
> VSYNCs and to report when the MPEG decoder stopped (there is a delay between
> stopping sending new data to the decoder and when it actually processed all
> its internal buffers).
> 
> Laurent is going to look into this to clean it up and present it as a new
> proper official V4L2 event mechanism.
> 
> For events completely specific to a subdev I wonder whether it wouldn't be
> a good idea to use the media controller device for that. I like the select()
> mechanism since in an application you can just select() on a whole bunch of
> filehandles. If you can't use select() then you are forced to do awkward coding
> (e.g. make a separate thread just to handle that other event mechanism).

Agree. There's no reasonable way to use video devices here since the 
events may be connected to non-video related issues --- like the statistics.

One possible approach could be allocating a device node for each subdev 
and use them and leave the media controller device with just the media 
controller specific ioctls. Then there would be no need to set current 
subdev nor bind the subdev to file handle either.

Just an idea.

> So with the media controller we can easily let sub-devices notify the media
> controller when an event is ready and the media controller can then generate
> an exception. An application can just select() on the mc filehandle.
> 
> There are two ways of implementing this. One is that the media controller
> keeps a global queue of pending events and subdevices just queue events to
> that when they arrive (with some queue size limit to prevent run-away events).

With the above arrangement, the events could be easily subdev specific. 
The mechanism should be generic still, though.

> So when you call some GET_EVENT type ioctl it should return the ID of the
> subdevice (aka entity) as well. What makes me slightly uncomfortable is that
> you still want to use that same ioctl on a normal video node. And the subdev
> ID has really no meaning there. But making two different ioctls doesn't sit
> well with me either.
> 
> The alternative implementation is that the mc will only wait for events from
> the currently selected sub-device. So if you want to wait on events from
> different sub-devices, then you have to open the mc multiple times, once for
> each subdev that you want to receive events from.
> 
> I think I would probably go for the second implementation because it is
> consistent with the way ioctls are passed to sub-devices. I like the idea that
> you can just pass regular V4L2 ioctls to sub-devices. Not all ioctls make
> sense, obviously (e.g. any of the streaming I/O ioctls), but a surprisingly
> large number of ioctls can be used in that way.

I agree with this. There are just a few ioctls that probably don't make 
sense (e.g. the steaming related ones).

IMO even the format setting ioctls could be nice since the possible 
input and output formats of the subdevs should be enumerable, too.

ENUM_FRAMESIZES and ENUM_FRAMEINTERVALS are missing the v4l2_buf_type, 
but there are reserved fields...

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


  reply	other threads:[~2009-09-22 18:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-11 22:21 Media controller: sysfs vs ioctl Hans Verkuil
2009-09-11 23:01 ` Andy Walls
2009-09-12  1:37   ` hermann pitton
2009-09-12 13:31 ` Mauro Carvalho Chehab
2009-09-12 13:41   ` Devin Heitmueller
2009-09-12 14:45     ` Mauro Carvalho Chehab
2009-09-12 15:12       ` Hans Verkuil
2009-09-12 15:54         ` Mauro Carvalho Chehab
2009-09-12 18:48           ` Andy Walls
2009-09-13  1:33             ` Mauro Carvalho Chehab
     [not found]           ` <434302664.20090915195043@ntlworld.com>
2009-09-15 19:00             ` [linux-dvb] " Devin Heitmueller
2009-09-13  6:13 ` Nathaniel Kim
2009-09-13  9:03   ` Hans Verkuil
2009-09-21 17:23     ` Sakari Ailus [this message]
2009-10-11 22:46       ` Laurent Pinchart
2009-09-13 13:27   ` Mauro Carvalho Chehab
2009-09-13 13:43     ` Hans Verkuil
2009-09-13 14:00       ` Mauro Carvalho Chehab
2009-09-15 14:33         ` Laurent Pinchart
2009-09-13 15:54 ` wk
2009-09-13 16:07   ` Hans Verkuil
2009-09-13 23:31   ` Mauro Carvalho Chehab
2009-09-14 11:49     ` Karicheri, Muralidharan
2009-09-15 14:10 ` Laurent Pinchart
2009-09-15 15:07   ` Hans Verkuil

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=4AB7B6AA.3070404@maxwell.research.nokia.com \
    --to=sakari.ailus@maxwell.research.nokia.com \
    --cc=dongsoo.kim@gmail.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@skynet.be \
    --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