xref: /linux/Documentation/userspace-api/media/mediactl/media-ioc-request-alloc.rst (revision cbecf716ca618fd44feda6bd9a64a8179d031fc5)
184d33341SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
2*937e6805SMauro Carvalho Chehab.. c:namespace:: MC
354f38fcaSMauro Carvalho Chehab
454f38fcaSMauro Carvalho Chehab.. _media_ioc_request_alloc:
554f38fcaSMauro Carvalho Chehab
654f38fcaSMauro Carvalho Chehab*****************************
754f38fcaSMauro Carvalho Chehabioctl MEDIA_IOC_REQUEST_ALLOC
854f38fcaSMauro Carvalho Chehab*****************************
954f38fcaSMauro Carvalho Chehab
1054f38fcaSMauro Carvalho ChehabName
1154f38fcaSMauro Carvalho Chehab====
1254f38fcaSMauro Carvalho Chehab
1354f38fcaSMauro Carvalho ChehabMEDIA_IOC_REQUEST_ALLOC - Allocate a request
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho ChehabSynopsis
1654f38fcaSMauro Carvalho Chehab========
1754f38fcaSMauro Carvalho Chehab
18*937e6805SMauro Carvalho Chehab.. c:macro:: MEDIA_IOC_REQUEST_ALLOC
1954f38fcaSMauro Carvalho Chehab
20*937e6805SMauro Carvalho Chehab``int ioctl(int fd, MEDIA_IOC_REQUEST_ALLOC, int *argp)``
2154f38fcaSMauro Carvalho Chehab
2254f38fcaSMauro Carvalho ChehabArguments
2354f38fcaSMauro Carvalho Chehab=========
2454f38fcaSMauro Carvalho Chehab
2554f38fcaSMauro Carvalho Chehab``fd``
26*937e6805SMauro Carvalho Chehab    File descriptor returned by :c:func:`open()`.
2754f38fcaSMauro Carvalho Chehab
2854f38fcaSMauro Carvalho Chehab``argp``
2954f38fcaSMauro Carvalho Chehab    Pointer to an integer.
3054f38fcaSMauro Carvalho Chehab
3154f38fcaSMauro Carvalho ChehabDescription
3254f38fcaSMauro Carvalho Chehab===========
3354f38fcaSMauro Carvalho Chehab
3454f38fcaSMauro Carvalho ChehabIf the media device supports :ref:`requests <media-request-api>`, then
3554f38fcaSMauro Carvalho Chehabthis ioctl can be used to allocate a request. If it is not supported, then
3654f38fcaSMauro Carvalho Chehab``errno`` is set to ``ENOTTY``. A request is accessed through a file descriptor
3754f38fcaSMauro Carvalho Chehabthat is returned in ``*argp``.
3854f38fcaSMauro Carvalho Chehab
3954f38fcaSMauro Carvalho ChehabIf the request was successfully allocated, then the request file descriptor
4054f38fcaSMauro Carvalho Chehabcan be passed to the :ref:`VIDIOC_QBUF <VIDIOC_QBUF>`,
4154f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`,
4254f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` and
4354f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` ioctls.
4454f38fcaSMauro Carvalho Chehab
4554f38fcaSMauro Carvalho ChehabIn addition, the request can be queued by calling
4654f38fcaSMauro Carvalho Chehab:ref:`MEDIA_REQUEST_IOC_QUEUE` and re-initialized by calling
4754f38fcaSMauro Carvalho Chehab:ref:`MEDIA_REQUEST_IOC_REINIT`.
4854f38fcaSMauro Carvalho Chehab
4954f38fcaSMauro Carvalho ChehabFinally, the file descriptor can be :ref:`polled <request-func-poll>` to wait
5054f38fcaSMauro Carvalho Chehabfor the request to complete.
5154f38fcaSMauro Carvalho Chehab
5254f38fcaSMauro Carvalho ChehabThe request will remain allocated until all the file descriptors associated
53*937e6805SMauro Carvalho Chehabwith it are closed by :c:func:`close()` and the driver no
5454f38fcaSMauro Carvalho Chehablonger uses the request internally. See also
5554f38fcaSMauro Carvalho Chehab:ref:`here <media-request-life-time>` for more information.
5654f38fcaSMauro Carvalho Chehab
5754f38fcaSMauro Carvalho ChehabReturn Value
5854f38fcaSMauro Carvalho Chehab============
5954f38fcaSMauro Carvalho Chehab
6054f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set
6154f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
6254f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
6354f38fcaSMauro Carvalho Chehab
6454f38fcaSMauro Carvalho ChehabENOTTY
6554f38fcaSMauro Carvalho Chehab    The driver has no support for requests.
66