162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci.. _app-pri:
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci********************
662306a36Sopenharmony_ciApplication Priority
762306a36Sopenharmony_ci********************
862306a36Sopenharmony_ci
962306a36Sopenharmony_ciWhen multiple applications share a device it may be desirable to assign
1062306a36Sopenharmony_cithem different priorities. Contrary to the traditional "rm -rf /" school
1162306a36Sopenharmony_ciof thought, a video recording application could for example block other
1262306a36Sopenharmony_ciapplications from changing video controls or switching the current TV
1362306a36Sopenharmony_cichannel. Another objective is to permit low priority applications
1462306a36Sopenharmony_ciworking in background, which can be preempted by user controlled
1562306a36Sopenharmony_ciapplications and automatically regain control of the device at a later
1662306a36Sopenharmony_citime.
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ciSince these features cannot be implemented entirely in user space V4L2
1962306a36Sopenharmony_cidefines the :ref:`VIDIOC_G_PRIORITY <VIDIOC_G_PRIORITY>` and
2062306a36Sopenharmony_ci:ref:`VIDIOC_S_PRIORITY <VIDIOC_G_PRIORITY>` ioctls to request and
2162306a36Sopenharmony_ciquery the access priority associate with a file descriptor. Opening a
2262306a36Sopenharmony_cidevice assigns a medium priority, compatible with earlier versions of
2362306a36Sopenharmony_ciV4L2 and drivers not supporting these ioctls. Applications requiring a
2462306a36Sopenharmony_cidifferent priority will usually call :ref:`VIDIOC_S_PRIORITY
2562306a36Sopenharmony_ci<VIDIOC_G_PRIORITY>` after verifying the device with the
2662306a36Sopenharmony_ci:ref:`VIDIOC_QUERYCAP` ioctl.
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ciIoctls changing driver properties, such as
2962306a36Sopenharmony_ci:ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>`, return an ``EBUSY`` error code
3062306a36Sopenharmony_ciafter another application obtained higher priority.
31