From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: hverkuil@xs4all.nl, acourbot@chromium.org
Subject: [RFC v2 00/10] Preparing the request API
Date: Fri, 23 Mar 2018 23:17:34 +0200 [thread overview]
Message-ID: <1521839864-10146-1-git-send-email-sakari.ailus@linux.intel.com> (raw)
Hi folks,
This preliminary RFC patchset prepares for the request API. What's new
here is support for binding arbitrary configuration or resources to
requests.
There are a few new concepts here:
Class --- a type of configuration or resource a driver (or e.g. the V4L2
framework) can attach to a resource. E.g. a video buffer queue would be a
class.
Object --- an instance of the class. This may be either configuration (in
which case the setting will stay until changed, e.g. V4L2 format on a
video node) or a resource (such as a video buffer).
Reference --- a reference to an object. If a configuration is not changed
in a request, instead of allocating a new object, a reference to an
existing object is used. This saves time and memory.
I expect Laurent to comment on aligning the concept names between the
request API and DRM. As far as I understand, the respective DRM names for
"class" and "object" used in this set would be "object" and "state".
The drivers will need to interact with the requests in three ways:
- Allocate new configurations or resources. Drivers are free to store
their own data into request objects as well. These callbacks are
specific to classes.
- Validate and queue callbacks. These callbacks are used to try requests
(validate only) as well as queue them (validate and queue). These
callbacks are media device wide, at least for now.
The lifetime of the objects related to requests is based on refcounting
both requests and request objects. This fits well for existing use cases
whether or not based on refcounting; what still needs most of the
attention is likely that the number of gets and puts matches once the
object is no longer needed.
Configuration can be bound to the request the usual way (V4L2 IOCTLs with
the request_fd field set to the request). Once queued, request completion
is signalled through polling the request file handle (POLLPRI).
I'm posting this as an RFC because it's not complete yet. The code
compiles but no testing has been done yet.
Todo list:
- Testing! (And fixing the bugs.)
- Request support in a few drivers as well as the control framework.
- Request support for V4L2 formats?
In the future, support for changing e.g. Media controller link state or
V4L2 sub-device formats will need to be added. Those should receive more
attention when the core is in a good shape and the more simple use cases
are already functional.
Comments and questions are welcome.
since v1:
- Provide an iterator helper for request objects in a request.
- Remove the request lists in the media device (they were not used)
- Move request queing to request fd and add reinit (Alexandre's patchset);
this roughly corresponds to Request API RFC v2 from Hans.
(MEDIA_IOC_REQUEST_ALLOC argument is a struct pointer instead of an
__s32 pointer.)
- Provide a way to unbind request objects from an unqueued request
(reinit, closing request fd).
- v4l2-mem2mem + vivid implementation without control support.
- More states for requests. In order to take a spinlock (or a mutex) for
an extended period of time, add a "QUEUEING" and "REINIT" states.
- Move non-IOCTL code to media-request.c, remove extra filp argument that
was added in v1.
- SPDX license header, other small changes.
Open questions:
- How to tell at complete time whether a request failed? Return error code
on release? What's the behaviour with reinit then --- fail on error? Add
another IOCTL to ask for completion status?
Alexandre Courbot (1):
videodev2.h: add request_fd field to v4l2_ext_controls
Hans Verkuil (1):
videodev2.h: Add request_fd field to v4l2_buffer
Laurent Pinchart (1):
media: Add request API
Sakari Ailus (7):
media: Support variable size IOCTL arguments
staging: media: atomisp: Remove v4l2_buffer.reserved2 field hack
vb2: Add support for requests
v4l: m2m: Simplify exiting the function in v4l2_m2m_try_schedule
v4l: m2m: Support requests with video buffers
vim2m: Register V4L2 video device after V4L2 mem2mem init
vim2m: Request support
drivers/media/Makefile | 3 +-
drivers/media/common/videobuf2/videobuf2-core.c | 43 +-
drivers/media/common/videobuf2/videobuf2-v4l2.c | 40 +-
drivers/media/media-device.c | 80 ++-
drivers/media/media-request.c | 650 +++++++++++++++++++++
drivers/media/platform/vim2m.c | 76 ++-
drivers/media/usb/cpia2/cpia2_v4l.c | 2 +-
drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 16 +-
drivers/media/v4l2-core/v4l2-ioctl.c | 6 +-
drivers/media/v4l2-core/v4l2-mem2mem.c | 131 ++++-
.../media/atomisp/pci/atomisp2/atomisp_ioctl.c | 17 +-
include/media/media-device.h | 19 +-
include/media/media-request.h | 301 ++++++++++
include/media/v4l2-mem2mem.h | 28 +
include/media/videobuf2-core.h | 19 +
include/media/videobuf2-v4l2.h | 28 +
include/uapi/linux/media.h | 8 +
include/uapi/linux/videodev2.h | 6 +-
18 files changed, 1408 insertions(+), 65 deletions(-)
create mode 100644 drivers/media/media-request.c
create mode 100644 include/media/media-request.h
--
2.7.4
next reply other threads:[~2018-03-23 21:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-23 21:17 Sakari Ailus [this message]
2018-03-23 21:17 ` [RFC v2 01/10] media: Support variable size IOCTL arguments Sakari Ailus
2018-03-26 10:47 ` Mauro Carvalho Chehab
2018-03-26 11:34 ` Sakari Ailus
2018-03-26 13:23 ` [RFC v2.1 1/1] " Sakari Ailus
2018-03-26 17:28 ` Mauro Carvalho Chehab
2018-03-26 20:00 ` Sakari Ailus
2018-03-26 20:37 ` Mauro Carvalho Chehab
2018-03-23 21:17 ` [RFC v2 02/10] media: Add request API Sakari Ailus
2018-03-23 21:17 ` [RFC v2 03/10] videodev2.h: Add request_fd field to v4l2_buffer Sakari Ailus
2018-03-23 21:17 ` [RFC v2 04/10] videodev2.h: add request_fd field to v4l2_ext_controls Sakari Ailus
2018-03-23 21:17 ` [RFC v2 05/10] staging: media: atomisp: Remove v4l2_buffer.reserved2 field hack Sakari Ailus
2018-03-23 21:17 ` [RFC v2 06/10] vb2: Add support for requests Sakari Ailus
2018-03-26 6:02 ` Tomasz Figa
2018-03-26 9:31 ` Sakari Ailus
2018-03-23 21:17 ` [RFC v2 07/10] v4l: m2m: Simplify exiting the function in v4l2_m2m_try_schedule Sakari Ailus
2018-03-23 21:17 ` [RFC v2 08/10] v4l: m2m: Support requests with video buffers Sakari Ailus
2018-03-23 21:17 ` [RFC v2 09/10] vim2m: Register V4L2 video device after V4L2 mem2mem init Sakari Ailus
2018-03-23 21:17 ` [RFC v2 10/10] vim2m: Request support Sakari Ailus
2018-03-25 15:12 ` [RFC v2 00/10] Preparing the request API Hans Verkuil
2018-03-25 16:17 ` Hans Verkuil
2018-03-26 7:58 ` Sakari Ailus
2018-03-26 8:31 ` Hans Verkuil
2018-03-26 9:17 ` Sakari Ailus
2018-03-26 15:35 ` Hans Verkuil
2018-03-27 15:00 ` Hans Verkuil
2018-03-26 3:30 ` Alexandre Courbot
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=1521839864-10146-1-git-send-email-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=acourbot@chromium.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox