linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: hverkuil <hverkuil@xs4all.nl>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>,
	Aviv Greenberg <avivgr@gmail.com>,
	linux-media-owner@vger.kernel.org
Subject: Re: per-frame camera metadata (again)
Date: Thu, 24 Dec 2015 13:29:07 +0200	[thread overview]
Message-ID: <4268557.IA99RCLRfS@avalon> (raw)
In-Reply-To: <7eb32a870441220fc4f6738d03a96a36@xs4all.nl>

Hi Hans,

On Thursday 24 December 2015 12:17:48 hverkuil wrote:
> On 2015-12-24 11:46, Laurent Pinchart wrote:
> > On Wednesday 23 December 2015 10:47:57 Guennadi Liakhovetski wrote:
> >> >>> 2. Separate buffer queues. Pros: (a) no need to extend multiplanar
> >> >>> buffer implementation. Cons: (a) more difficult synchronisation with
> >> >>> image frames, (b) still need to work out a way to specify the
> >> >>> metadata version.
> >> > 
> >> > Do you think you have different versions of metadata from a sensor, for
> >> > instance? Based on what I've seen these tend to be sensor specific, or
> >> > SMIA which defines a metadata type for each bit depth for compliant
> >> > sensors.
> >> > 
> >> > Each metadata format should have a 4cc code, SMIA bit depth specific or
> >> > sensor specific where metadata is sensor specific.
> >> > 
> >> > Other kind of metadata than what you get from sensors is not covered by
> >> > the thoughts above.
> >> > 
> >> > <URL:http://www.retiisi.org.uk/v4l2/foil/v4l2-multi-format.pdf>
> >> > 
> >> > I think I'd still favour separate buffer queues.
> >> 
> >> And separate video nodes then.
> >> 
> >> >>> Any further options? Of the above my choice would go with (1) but
> >> >>> with a dedicated metadata plane in struct vb2_buffer.
> >> >> 
> >> >> 3. Use the request framework and return the metadata as control(s).
> >> >> Since controls can be associated with events when they change you can
> >> >> subscribe to such events. Note: currently I haven't implemented such
> >> >> events for request controls since I am not certainly how it would be
> >> >> used, but this would be a good test case.
> >> >> 
> >> >> Pros: (a) no need to extend multiplanar buffer implementation, (b)
> >> >> syncing up with the image frames should be easy (both use the same
> >> >> request ID), (c) a lot of freedom on how to export the metadata. Cons:
> >> >> (a) request framework is still work in progress (currently worked on
> >> >> by Laurent), (b) probably too slow for really large amounts of
> >> >> metadata, you'll need proper DMA handling for that in which case I
> >> >> would go for 2.
> >> > 
> >> > Agreed. You could consider it as a drawback that the number of new
> >> > controls required for this could be large as well, but then already for
> >> > other reasons the best implementation would rather be the second option
> >> > mentioned.
> >> 
> >> But wouldn't a single extended control with all metadata-transferred
> >> controls solve the performance issue?
> > 
> > You would still have to update the value of the controls in the kernel
> > based on meta-data parsing, we've never measured the cost of such an
> > operation when the number of controls is large.
> 
> Before discounting this option we need to measure the cost first. I suspect
> that if there are just a handful (let's say <= 10) of controls, then the
> cost is limited.

I certainly don't want to disregard the option before having tried it, my only 
point is that we need to measure performances before making a decision. I plan 
to do so but without an ETA at this point.

> > An interesting side issue is that the control framework currently doesn't
> > support updating controls from interrupt context as all controls are
> > protected by a mutex. The cost of locking, once it will be reworked, also
> > needs to be taken into account.
> 
> I think the cost of locking can be limited (and I am not even sure if
> locking is needed if we restrict the type of control where this can be
> done). I have some ideas about that.

Well, we'll need to do something, and a lockless algorithm would certainly be 
good :-)

> >>>>> In either of the above options we also need a way to tell the user
> >>>>> what is in the metadata buffer, its format. We could create new
> >>>>> FOURCC codes for them, perhaps as V4L2_META_FMT_... or the user space
> >>>>> could identify the metadata format based on the camera model and an
> >>>>> opaque type (metadata version code) value. Since metadata formats
> >>>>> seem to be extremely camera-specific, I'd go with the latter option.
> >>> 
> >>> I think I'd use separate 4cc codes for the metadata formats when they
> >>> really are different. There are plenty of possible 4cc codes we can
> >>> use.
> >>> 
> >>> :-)
> >>> 
> >>> Documenting the formats might be painful though.
> >> 
> >> The advantage of this approach together with a separate video node /
> >> buffer queue is, that no changes to the core would be required.
> >> 
> >> At the moment I think, that using (extended) controls would be the
> >> most "correct" way to implement that metadata, but you can associate such
> >> control values with frames only when the request API is there. Yet
> >> another caveat is, that we define V4L2_CTRL_ID2CLASS() as ((id) &
> >> 0x0fff0000UL) and V4L2_CID_PRIVATE_BASE as 0x08000000, so that drivers
> >> cannot define private controls to belong to existing classes. Was this
> >> intensional?
> 
> PRIVATE_BASE is deprecated and cannot be used with the control framework
> (it was a very bad design). The control framework provides backwards compat
> code to handle old apps that still use PRIVATE_BASE.
> 
> Control classes are not deprecated, only the use of the control_class
> field in struct v4l2_ext_controls to limit the controls in the list to a
> single control class is deprecated. That old limitation was from pre-
> control-framework times to simplify driver design. With the creation of the
> control framework that limitation is no longer needed.

Doesn't that effectively deprecated control classes ? We can certainly group 
controls in categories for documentation purposes, but the control class as an 
API concept is quite useless nowadays.

> Per-control class private controls are perfectly possible: such controls
> start at control class base ID + 0x1000.
> 
> > Control classes are a deprecated concept, so I don't think this matters
> > much.
> 
> As described above, this statement is not correct.

-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2015-12-24 11:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-16  9:37 per-frame camera metadata (again) Guennadi Liakhovetski
2015-12-16 10:02 ` Hans Verkuil
2015-12-16 11:25   ` Guennadi Liakhovetski
2015-12-21  3:41     ` Laurent Pinchart
2015-12-22 11:16       ` Guennadi Liakhovetski
2015-12-22 13:30         ` karthik poduval
2015-12-24 10:54           ` Laurent Pinchart
2015-12-23 17:40         ` Laurent Pinchart
2015-12-24 10:42           ` Guennadi Liakhovetski
2015-12-26 23:47             ` Laurent Pinchart
2016-01-01 15:43               ` Guennadi Liakhovetski
2016-01-05 11:31                 ` Guennadi Liakhovetski
2016-01-25 11:14                   ` Guennadi Liakhovetski
2016-01-25 19:53                     ` Laurent Pinchart
2016-01-26 12:49                       ` Guennadi Liakhovetski
2016-01-29 10:08                         ` Guennadi Liakhovetski
2015-12-19  0:06   ` Sakari Ailus
2015-12-23  9:47     ` Guennadi Liakhovetski
2015-12-24 10:46       ` Laurent Pinchart
2015-12-24 11:17         ` hverkuil
2015-12-24 11:29           ` Laurent Pinchart [this message]
2015-12-24 12:54             ` hverkuil
2015-12-24 17:33               ` 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=4268557.IA99RCLRfS@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=avivgr@gmail.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media-owner@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=sakari.ailus@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).