All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Alexandre Courbot <acourbot@chromium.org>,
	Sakari Ailus <sakari.ailus@iki.fi>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Pawel Osciak <pawel@osciak.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Tomasz Figa <tfiga@chromium.org>,
	Gustavo Padovan <gustavo.padovan@collabora.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 0/9] V4L2 Jobs API WIP
Date: Thu, 26 Oct 2017 02:06:31 +0300	[thread overview]
Message-ID: <18194285.JDWGGIrcDz@avalon> (raw)
In-Reply-To: <9546e2fa-3f6e-ccc2-58e6-785eb9361901@xs4all.nl>

Hi Hans,

On Wednesday, 25 October 2017 19:19:27 EEST Hans Verkuil wrote:
> On 10/25/2017 05:48 PM, Laurent Pinchart wrote:
> > Hello,
> > 
> > On Monday, 23 October 2017 11:45:01 EEST Alexandre Courbot wrote:
> >> On Thu, Oct 19, 2017 at 11:43 PM, Sakari Ailus <sakari.ailus@iki.fi> 
wrote:
> >>> On Thu, Sep 28, 2017 at 06:50:18PM +0900, Alexandre Courbot wrote:
> >>>> Hi everyone,
> >>>> 
> >>>> Here is a new attempt at the "request" (which I propose to rename
> >>>> "jobs")
> >>>> API for V4L2, hopefully in a manner that can converge to something that
> >>>> will be merged. The core ideas should be easy to grasp for those
> >>>> familiar with the previous attemps, yet there are a few important
> >>>> differences.
> >>>> 
> >>>> Most notably, user-space does not need to explicitly allocate and
> >>>> manage
> >>>> requests/jobs (but still can if this makes sense). We noticed that only
> >>>> specific use-cases require such an explicit management, and opted for a
> >>>> jobs queue that controls the flow of work over a set of opened devices.
> >>>> This should simplify user-space code quite a bit, while still retaining
> >>>> the ability to manage states explicitly like the previous request API
> >>>> proposals allowed to do.
> >>>> 
> >>>> The jobs API defines a few new concepts that user-space can use to
> >>>> control the workflow on a set of opened V4L2 devices:
> >>>> 
> >>>> A JOB QUEUE can be created from a set of opened FDs that are part of a
> >>>> pipeline and need to cooperate (be it capture, m2m, or media controller
> >>>> devices).
> >>>> 
> >>>> A JOB can then be set up with regular (if slightly modified) V4L2
> >>>> ioctls,
> >>>> and then submitted to the job queue. Once the job queue schedules the
> >>>> job, its parameters (controls, etc) are applied to the devices of the
> >>>> queue, and itsd buffers are processed. Immediately after a job is
> >>>> submitted, the next job is ready to be set up without further user
> >>>> action.
> >>>> 
> >>>> Once a job completes, it must be dequeued and user-space can then read
> >>>> back its properties (notably controls) at completion time.
> >>>> 
> >>>> Internally, the state of jobs is managed through STATE HANDLERS. Each
> >>>> driver supporting the jobs API needs to specify an implementation of a
> >>>> state handler. Fortunately, most drivers can rely on the generic state
> >>>> handler implementation that simply records and replays a job's
> >>>> parameter
> >>>> using standard V4L2 functions. Thanks to this, adding jobs API support
> >>>> to a driver relying on the control framework and vb2 only requires a
> >>>> dozen lines of codes.
> >>>> 
> >>>> Drivers with specific needs or opportunities for optimization can
> >>>> however
> >>>> provide their own implementation of a state handler. This may in
> >>>> particular be beneficial for hardware that supports configuration or
> >>>> command buffers (thinking about VSP1 here).
> >>>> 
> >>>> This is still very early work, and focus has been on the following
> >>>> points:
> >>>> 
> >>>> * Provide something that anybody can test (currently using vim2m and
> >>>> vivid),
> >>>> * Reuse the current V4L2 APIs as much as possible,
> >>>> * Remain flexible enough to accomodate the inevitable changes that will
> >>>> be requested,
> >>>> * Keep line count low, even if functionality is missing at the moment.
> >>>> 
> >>>> Please keep this in mind while going through the patches. In
> >>>> particular,
> >>>> at the moment the parameters of a job are limited to integer controls.
> >>>> I
> >>>> know that much more is expected, but V4L2 has quite a learning curve
> >>>> and
> >>>> I preferred to focus on the general concepts for now. More is coming
> >>>> though! :)
> >>>> 
> >>>> I have written two small example programs that demonstrate the use of
> >>>> this API:
> >>>> 
> >>>> - With a codec device (vim2m):
> >>>> https://gist.github.com/Gnurou/34c35f1f8e278dad454b51578d239a42
> >>>> 
> >>>> - With a capture device (vivid):
> >>>> https://gist.github.com/Gnurou/5052e6ab41e7c55164b75d2970bc5a04
> >>>> 
> >>>> Considering the history with the request API, I don't expect everything
> >>>> proposed here to be welcome or understood immediately. In particular I
> >>>> apologize for not reusing any of the previous attempts - I was just
> >>>> more
> >>>> comfortable laying down my ideas from scratch.
> >>>> 
> >>>> If this proposal is not dismissed as complete garbage I will also be
> >>>> happy to discuss it in-person at the mini-summit in Prague. :)
> >>> 
> >>> Thank you for the initiative and the patchset.
> >>> 
> >>> While reviewing this patchset, I'm concentrating primarily on the
> >>> approach
> >>> taken and the design, not so much in the actual implementation which I
> >>> don't think matters much at this moment.
> >> 
> >> Thanks, that is exactly how I hoped things would go for the moment.
> >> 
> >>> It's difficult to avoid seeing many similarities with the Request API
> >>> patches posted earlier on. And not only that, rather you have to start
> >>> looking for the differences in what I could call details, while
> >>> important
> >>> design decisions could sometimes be only visible in what appear details
> >>> at
> >>> this point.
> >> 
> >> I was not quite sure whether I should base this work on one of the
> >> existing patchsets (and in this case, which one) or start from
> >> scratch. This being my first contribution to a new area of the kernel
> >> for me, I decided to start from scratch as it would yield more
> >> educative value.
> > 
> > What bothers me here is that we had a full day face to face meeting in
> > Tokyo back in June about this, where you presented this idea of how the
> > userspace API could look like. We went through the proposal point by
> > point to discuss potential issues, and for most points I recall agreeing
> > that the changes proposed compared to the previous request API RFC were
> > introducing problems that couldn't be easily solved. I walked out of the
> > meeting understanding we had an agreement to go back to an API quite
> > similar to the previous RFC, in particular with explicit request object
> > management from userspace, and I now see several months later an RFC that
> > ignores all the conclusions of our meeting.
> 
> Laurent, can you give a link to that RFC? Just so we all refer to the same
> request API RFC. That will help with the discussion tomorrow.

Sure, it's available at https://www.spinics.net/lists/linux-sh/msg48289.html. 
Sakari has posted two newer versions based on that original series.

> Two notes: my hope is that by the end of Friday we have a public API that is
> good enough for the codec use case and can be extended for the more generic
> use case. We have codec drivers waiting to be mainlined for years now that
> are blocked because of this. It's getting ridiculous. That also means that
> I don't care all that much about the kernel API: ideally it will be
> suitable or extensible for the generic use case, but if it isn't and needs
> to be reworked substantially for the generic use case, then so be it.
> Obviously this is something I hope we can avoid, but it would be much worse
> if the codec vendors would move away from V4L2 and start using other
> suboptimal solutions just because we can't reach an agreement.
> 
> As I said in the beginning: we don't have that option for the public API:
> that does need some careful thought as we cannot change that later, we can
> only extend it.

I agree with your overall, we need to move forward on this. Focussing on the 
userspace API first is the way to go according to me as well. I wouldn't say 
that I don't care about the kernel API, but that's indeed easier to change. 
I'd like to share your optimism about what we will achieve by the end of 
Friday, and I would certainly love to be proven wrong when I'm pessimistic :) 
Let's try our best.

> Second note (just to throw it in the discussion): I've always thought that
> controls are a good way to store state, including things like formats.
> 
> Having a single framework taking care of that would simplify things
> substantially. With VIDIOC_S_EXT_CTRLS you can already set a large number
> of controls in one ioctl.

To some extent I agree with you, but I don't think we should base the API on 
VIDIOC_S_EXT_CTRLS, nor the implementation on the control framework as it 
exists today. That's a topic to be discussed tomorrow :-)

> This does require some (or a lot?) refactoring of the control framework as
> you rightly mentioned in your email, but I'm willing to do that work.

Thank you.

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2017-10-25 23:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28  9:50 [RFC PATCH 0/9] V4L2 Jobs API WIP Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 1/9] [media] v4l2-core: add v4l2_is_v4l2_file function Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 2/9] [media] v4l2-core: add core jobs API support Alexandre Courbot
2017-10-16 10:01   ` Hans Verkuil
2017-10-23  8:35     ` Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 3/9] [media] videobuf2: add support for jobs API Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 4/9] [media] v4l2-ctrls: " Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 5/9] [media] v4l2-job: add generic jobs ops Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 6/9] [media] m2m: add generic support for jobs API Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 7/9] [media] vim2m: add jobs API support Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 8/9] [media] vivid: add jobs API support for capture device Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 9/9] [media] document jobs API Alexandre Courbot
2017-10-16 11:06 ` [RFC PATCH 0/9] V4L2 Jobs API WIP Hans Verkuil
2017-10-23  8:36   ` Alexandre Courbot
2017-10-23 19:03   ` Gustavo Padovan
2017-10-19 14:43 ` Sakari Ailus
2017-10-23  8:45   ` Alexandre Courbot
2017-10-25 15:48     ` Laurent Pinchart
2017-10-25 16:19       ` Hans Verkuil
2017-10-25 23:06         ` Laurent Pinchart [this message]
2017-10-26  3:08       ` Tomasz Figa
2017-10-26  3:08         ` Tomasz Figa
2017-10-26  2:49   ` Tomasz Figa

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=18194285.JDWGGIrcDz@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=acourbot@chromium.org \
    --cc=gustavo.padovan@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@kernel.org \
    --cc=pawel@osciak.com \
    --cc=sakari.ailus@iki.fi \
    --cc=tfiga@chromium.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.