xref: /OK3568_Linux_fs/kernel/Documentation/userspace-api/media/v4l/vidioc-subdev-g-frame-interval.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*4882a593Smuzhiyun.. c:namespace:: V4L
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun.. _VIDIOC_SUBDEV_G_FRAME_INTERVAL:
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun********************************************************************
7*4882a593Smuzhiyunioctl VIDIOC_SUBDEV_G_FRAME_INTERVAL, VIDIOC_SUBDEV_S_FRAME_INTERVAL
8*4882a593Smuzhiyun********************************************************************
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunName
11*4882a593Smuzhiyun====
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunVIDIOC_SUBDEV_G_FRAME_INTERVAL - VIDIOC_SUBDEV_S_FRAME_INTERVAL - Get or set the frame interval on a subdev pad
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunSynopsis
16*4882a593Smuzhiyun========
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun.. c:macro:: VIDIOC_SUBDEV_G_FRAME_INTERVAL
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun``int ioctl(int fd, VIDIOC_SUBDEV_G_FRAME_INTERVAL, struct v4l2_subdev_frame_interval *argp)``
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun.. c:macro:: VIDIOC_SUBDEV_S_FRAME_INTERVAL
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun``int ioctl(int fd, VIDIOC_SUBDEV_S_FRAME_INTERVAL, struct v4l2_subdev_frame_interval *argp)``
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunArguments
27*4882a593Smuzhiyun=========
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun``fd``
30*4882a593Smuzhiyun    File descriptor returned by :c:func:`open()`.
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun``argp``
33*4882a593Smuzhiyun    Pointer to struct :c:type:`v4l2_subdev_frame_interval`.
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunDescription
36*4882a593Smuzhiyun===========
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunThese ioctls are used to get and set the frame interval at specific
39*4882a593Smuzhiyunsubdev pads in the image pipeline. The frame interval only makes sense
40*4882a593Smuzhiyunfor sub-devices that can control the frame period on their own. This
41*4882a593Smuzhiyunincludes, for instance, image sensors and TV tuners. Sub-devices that
42*4882a593Smuzhiyundon't support frame intervals must not implement these ioctls.
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunTo retrieve the current frame interval applications set the ``pad``
45*4882a593Smuzhiyunfield of a struct
46*4882a593Smuzhiyun:c:type:`v4l2_subdev_frame_interval` to
47*4882a593Smuzhiyunthe desired pad number as reported by the media controller API. When
48*4882a593Smuzhiyunthey call the ``VIDIOC_SUBDEV_G_FRAME_INTERVAL`` ioctl with a pointer to
49*4882a593Smuzhiyunthis structure the driver fills the members of the ``interval`` field.
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunTo change the current frame interval applications set both the ``pad``
52*4882a593Smuzhiyunfield and all members of the ``interval`` field. When they call the
53*4882a593Smuzhiyun``VIDIOC_SUBDEV_S_FRAME_INTERVAL`` ioctl with a pointer to this
54*4882a593Smuzhiyunstructure the driver verifies the requested interval, adjusts it based
55*4882a593Smuzhiyunon the hardware capabilities and configures the device. Upon return the
56*4882a593Smuzhiyunstruct
57*4882a593Smuzhiyun:c:type:`v4l2_subdev_frame_interval`
58*4882a593Smuzhiyuncontains the current frame interval as would be returned by a
59*4882a593Smuzhiyun``VIDIOC_SUBDEV_G_FRAME_INTERVAL`` call.
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunCalling ``VIDIOC_SUBDEV_S_FRAME_INTERVAL`` on a subdev device node that has been
62*4882a593Smuzhiyunregistered in read-only mode is not allowed. An error is returned and the errno
63*4882a593Smuzhiyunvariable is set to ``-EPERM``.
64*4882a593Smuzhiyun
65*4882a593SmuzhiyunDrivers must not return an error solely because the requested interval
66*4882a593Smuzhiyundoesn't match the device capabilities. They must instead modify the
67*4882a593Smuzhiyuninterval to match what the hardware can provide. The modified interval
68*4882a593Smuzhiyunshould be as close as possible to the original request.
69*4882a593Smuzhiyun
70*4882a593SmuzhiyunChanging the frame interval shall never change the format. Changing the
71*4882a593Smuzhiyunformat, on the other hand, may change the frame interval.
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunSub-devices that support the frame interval ioctls should implement them
74*4882a593Smuzhiyunon a single pad only. Their behaviour when supported on multiple pads of
75*4882a593Smuzhiyunthe same sub-device is not defined.
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun.. c:type:: v4l2_subdev_frame_interval
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun.. flat-table:: struct v4l2_subdev_frame_interval
82*4882a593Smuzhiyun    :header-rows:  0
83*4882a593Smuzhiyun    :stub-columns: 0
84*4882a593Smuzhiyun    :widths:       1 1 2
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun    * - __u32
87*4882a593Smuzhiyun      - ``pad``
88*4882a593Smuzhiyun      - Pad number as reported by the media controller API.
89*4882a593Smuzhiyun    * - struct :c:type:`v4l2_fract`
90*4882a593Smuzhiyun      - ``interval``
91*4882a593Smuzhiyun      - Period, in seconds, between consecutive video frames.
92*4882a593Smuzhiyun    * - __u32
93*4882a593Smuzhiyun      - ``reserved``\ [9]
94*4882a593Smuzhiyun      - Reserved for future extensions. Applications and drivers must set
95*4882a593Smuzhiyun	the array to zero.
96*4882a593Smuzhiyun
97*4882a593SmuzhiyunReturn Value
98*4882a593Smuzhiyun============
99*4882a593Smuzhiyun
100*4882a593SmuzhiyunOn success 0 is returned, on error -1 and the ``errno`` variable is set
101*4882a593Smuzhiyunappropriately. The generic error codes are described at the
102*4882a593Smuzhiyun:ref:`Generic Error Codes <gen-errors>` chapter.
103*4882a593Smuzhiyun
104*4882a593SmuzhiyunEBUSY
105*4882a593Smuzhiyun    The frame interval can't be changed because the pad is currently
106*4882a593Smuzhiyun    busy. This can be caused, for instance, by an active video stream on
107*4882a593Smuzhiyun    the pad. The ioctl must not be retried without performing another
108*4882a593Smuzhiyun    action to fix the problem first. Only returned by
109*4882a593Smuzhiyun    ``VIDIOC_SUBDEV_S_FRAME_INTERVAL``
110*4882a593Smuzhiyun
111*4882a593SmuzhiyunEINVAL
112*4882a593Smuzhiyun    The struct
113*4882a593Smuzhiyun    :c:type:`v4l2_subdev_frame_interval`
114*4882a593Smuzhiyun    ``pad`` references a non-existing pad, or the pad doesn't support
115*4882a593Smuzhiyun    frame intervals.
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunEPERM
118*4882a593Smuzhiyun    The ``VIDIOC_SUBDEV_S_FRAME_INTERVAL`` ioctl has been called on a read-only
119*4882a593Smuzhiyun    subdevice.
120