media: remove text encoding from rst files
[sfrench/cifs-2.6.git] / Documentation / media / uapi / v4l / selection-api-vs-crop-api.rst
1 .. _selection-vs-crop:
2
3 ********************************
4 Comparison with old cropping API
5 ********************************
6
7 The selection API was introduced to cope with deficiencies of the
8 older :ref:`CROP API <crop>`, that was designed to control simple
9 capture devices. Later the cropping API was adopted by video output
10 drivers. The ioctls are used to select a part of the display were the
11 video signal is inserted. It should be considered as an API abuse
12 because the described operation is actually the composing. The
13 selection API makes a clear distinction between composing and cropping
14 operations by setting the appropriate targets.
15
16 The CROP API lacks any support for composing to and cropping from an
17 image inside a memory buffer. The application could configure a
18 capture device to fill only a part of an image by abusing V4L2
19 API. Cropping a smaller image from a larger one is achieved by setting
20 the field ``bytesperline`` at struct :c:type:`v4l2_pix_format`.
21 Introducing an image offsets could be done by modifying field
22 ``m_userptr`` at struct :c:type:`v4l2_buffer` before calling
23 :ref:`VIDIOC_QBUF <VIDIOC_QBUF>`. Those operations should be avoided
24 because they are not portable (endianness), and do not work for
25 macroblock and Bayer formats and mmap buffers.
26
27 The selection API deals with configuration of buffer
28 cropping/composing in a clear, intuitive and portable way. Next, with
29 the selection API the concepts of the padded target and constraints
30 flags are introduced. Finally, struct :c:type:`v4l2_crop` and struct
31 :c:type:`v4l2_cropcap` have no reserved fields. Therefore there is no
32 way to extend their functionality. The new struct
33 :c:type:`v4l2_selection` provides a lot of place for future
34 extensions.
35
36 Driver developers are encouraged to implement only selection API. The
37 former cropping API would be simulated using the new one.