xref: /OK3568_Linux_fs/kernel/Documentation/userspace-api/media/v4l/app-pri.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun.. _app-pri:
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun********************
6*4882a593SmuzhiyunApplication Priority
7*4882a593Smuzhiyun********************
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunWhen multiple applications share a device it may be desirable to assign
10*4882a593Smuzhiyunthem different priorities. Contrary to the traditional "rm -rf /" school
11*4882a593Smuzhiyunof thought, a video recording application could for example block other
12*4882a593Smuzhiyunapplications from changing video controls or switching the current TV
13*4882a593Smuzhiyunchannel. Another objective is to permit low priority applications
14*4882a593Smuzhiyunworking in background, which can be preempted by user controlled
15*4882a593Smuzhiyunapplications and automatically regain control of the device at a later
16*4882a593Smuzhiyuntime.
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunSince these features cannot be implemented entirely in user space V4L2
19*4882a593Smuzhiyundefines the :ref:`VIDIOC_G_PRIORITY <VIDIOC_G_PRIORITY>` and
20*4882a593Smuzhiyun:ref:`VIDIOC_S_PRIORITY <VIDIOC_G_PRIORITY>` ioctls to request and
21*4882a593Smuzhiyunquery the access priority associate with a file descriptor. Opening a
22*4882a593Smuzhiyundevice assigns a medium priority, compatible with earlier versions of
23*4882a593SmuzhiyunV4L2 and drivers not supporting these ioctls. Applications requiring a
24*4882a593Smuzhiyundifferent priority will usually call :ref:`VIDIOC_S_PRIORITY
25*4882a593Smuzhiyun<VIDIOC_G_PRIORITY>` after verifying the device with the
26*4882a593Smuzhiyun:ref:`VIDIOC_QUERYCAP` ioctl.
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunIoctls changing driver properties, such as
29*4882a593Smuzhiyun:ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>`, return an ``EBUSY`` error code
30*4882a593Smuzhiyunafter another application obtained higher priority.
31