~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/userspace-api/media/v4l/selection-api-examples.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/userspace-api/media/v4l/selection-api-examples.rst (Version linux-6.12-rc7) and /Documentation/userspace-api/media/v4l/selection-api-examples.rst (Version linux-5.8.18)


  1 .. SPDX-License-Identifier: GFDL-1.1-no-invari !!   1 .. Permission is granted to copy, distribute and/or modify this
                                                   >>   2 .. document under the terms of the GNU Free Documentation License,
                                                   >>   3 .. Version 1.1 or any later version published by the Free Software
                                                   >>   4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
                                                   >>   5 .. and no Back-Cover Texts. A copy of the license is included at
                                                   >>   6 .. Documentation/userspace-api/media/fdl-appendix.rst.
                                                   >>   7 ..
                                                   >>   8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
  2                                                     9 
  3 ********                                           10 ********
  4 Examples                                           11 Examples
  5 ********                                           12 ********
  6                                                    13 
  7 (A video capture device is assumed; change         14 (A video capture device is assumed; change
  8 ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` for other devi     15 ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` for other devices; change target to
  9 ``V4L2_SEL_TGT_COMPOSE_*`` family to configure     16 ``V4L2_SEL_TGT_COMPOSE_*`` family to configure composing area)
 10                                                    17 
 11 Example: Resetting the cropping parameters         18 Example: Resetting the cropping parameters
 12 ==========================================         19 ==========================================
 13                                                    20 
 14 .. code-block:: c                                  21 .. code-block:: c
 15                                                    22 
 16         struct v4l2_selection sel = {              23         struct v4l2_selection sel = {
 17             .type = V4L2_BUF_TYPE_VIDEO_CAPTUR     24             .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
 18             .target = V4L2_SEL_TGT_CROP_DEFAUL     25             .target = V4L2_SEL_TGT_CROP_DEFAULT,
 19         };                                         26         };
 20         ret = ioctl(fd, VIDIOC_G_SELECTION, &s     27         ret = ioctl(fd, VIDIOC_G_SELECTION, &sel);
 21         if (ret)                                   28         if (ret)
 22             exit(-1);                              29             exit(-1);
 23         sel.target = V4L2_SEL_TGT_CROP;            30         sel.target = V4L2_SEL_TGT_CROP;
 24         ret = ioctl(fd, VIDIOC_S_SELECTION, &s     31         ret = ioctl(fd, VIDIOC_S_SELECTION, &sel);
 25         if (ret)                                   32         if (ret)
 26             exit(-1);                              33             exit(-1);
 27                                                    34 
 28 Setting a composing area on output of size of      35 Setting a composing area on output of size of *at most* half of limit
 29 placed at a center of a display.                   36 placed at a center of a display.
 30                                                    37 
 31 Example: Simple downscaling                        38 Example: Simple downscaling
 32 ===========================                        39 ===========================
 33                                                    40 
 34 .. code-block:: c                                  41 .. code-block:: c
 35                                                    42 
 36         struct v4l2_selection sel = {              43         struct v4l2_selection sel = {
 37             .type = V4L2_BUF_TYPE_VIDEO_OUTPUT     44             .type = V4L2_BUF_TYPE_VIDEO_OUTPUT,
 38             .target = V4L2_SEL_TGT_COMPOSE_BOU     45             .target = V4L2_SEL_TGT_COMPOSE_BOUNDS,
 39         };                                         46         };
 40         struct v4l2_rect r;                        47         struct v4l2_rect r;
 41                                                    48 
 42         ret = ioctl(fd, VIDIOC_G_SELECTION, &s     49         ret = ioctl(fd, VIDIOC_G_SELECTION, &sel);
 43         if (ret)                                   50         if (ret)
 44             exit(-1);                              51             exit(-1);
 45         /* setting smaller compose rectangle *     52         /* setting smaller compose rectangle */
 46         r.width = sel.r.width / 2;                 53         r.width = sel.r.width / 2;
 47         r.height = sel.r.height / 2;               54         r.height = sel.r.height / 2;
 48         r.left = sel.r.width / 4;                  55         r.left = sel.r.width / 4;
 49         r.top = sel.r.height / 4;                  56         r.top = sel.r.height / 4;
 50         sel.r = r;                                 57         sel.r = r;
 51         sel.target = V4L2_SEL_TGT_COMPOSE;         58         sel.target = V4L2_SEL_TGT_COMPOSE;
 52         sel.flags = V4L2_SEL_FLAG_LE;              59         sel.flags = V4L2_SEL_FLAG_LE;
 53         ret = ioctl(fd, VIDIOC_S_SELECTION, &s     60         ret = ioctl(fd, VIDIOC_S_SELECTION, &sel);
 54         if (ret)                                   61         if (ret)
 55             exit(-1);                              62             exit(-1);
 56                                                    63 
 57 A video output device is assumed; change ``V4L     64 A video output device is assumed; change ``V4L2_BUF_TYPE_VIDEO_OUTPUT``
 58 for other devices                                  65 for other devices
 59                                                    66 
 60 Example: Querying for scaling factors              67 Example: Querying for scaling factors
 61 =====================================              68 =====================================
 62                                                    69 
 63 .. code-block:: c                                  70 .. code-block:: c
 64                                                    71 
 65         struct v4l2_selection compose = {          72         struct v4l2_selection compose = {
 66             .type = V4L2_BUF_TYPE_VIDEO_OUTPUT     73             .type = V4L2_BUF_TYPE_VIDEO_OUTPUT,
 67             .target = V4L2_SEL_TGT_COMPOSE,        74             .target = V4L2_SEL_TGT_COMPOSE,
 68         };                                         75         };
 69         struct v4l2_selection crop = {             76         struct v4l2_selection crop = {
 70             .type = V4L2_BUF_TYPE_VIDEO_OUTPUT     77             .type = V4L2_BUF_TYPE_VIDEO_OUTPUT,
 71             .target = V4L2_SEL_TGT_CROP,           78             .target = V4L2_SEL_TGT_CROP,
 72         };                                         79         };
 73         double hscale, vscale;                     80         double hscale, vscale;
 74                                                    81 
 75         ret = ioctl(fd, VIDIOC_G_SELECTION, &c     82         ret = ioctl(fd, VIDIOC_G_SELECTION, &compose);
 76         if (ret)                                   83         if (ret)
 77             exit(-1);                              84             exit(-1);
 78         ret = ioctl(fd, VIDIOC_G_SELECTION, &c     85         ret = ioctl(fd, VIDIOC_G_SELECTION, &crop);
 79         if (ret)                                   86         if (ret)
 80             exit(-1);                              87             exit(-1);
 81                                                    88 
 82         /* computing scaling factors */            89         /* computing scaling factors */
 83         hscale = (double)compose.r.width / cro     90         hscale = (double)compose.r.width / crop.r.width;
 84         vscale = (double)compose.r.height / cr     91         vscale = (double)compose.r.height / crop.r.height;
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php