1*54f38fcaSMauro Carvalho Chehab.. Permission is granted to copy, distribute and/or modify this 2*54f38fcaSMauro Carvalho Chehab.. document under the terms of the GNU Free Documentation License, 3*54f38fcaSMauro Carvalho Chehab.. Version 1.1 or any later version published by the Free Software 4*54f38fcaSMauro Carvalho Chehab.. Foundation, with no Invariant Sections, no Front-Cover Texts 5*54f38fcaSMauro Carvalho Chehab.. and no Back-Cover Texts. A copy of the license is included at 6*54f38fcaSMauro Carvalho Chehab.. Documentation/userspace-api/media/fdl-appendix.rst. 7*54f38fcaSMauro Carvalho Chehab.. 8*54f38fcaSMauro Carvalho Chehab.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections 9*54f38fcaSMauro Carvalho Chehab 10*54f38fcaSMauro Carvalho Chehab************* 11*54f38fcaSMauro Carvalho ChehabConfiguration 12*54f38fcaSMauro Carvalho Chehab************* 13*54f38fcaSMauro Carvalho Chehab 14*54f38fcaSMauro Carvalho ChehabApplications can use the :ref:`selection API <VIDIOC_G_SELECTION>` to 15*54f38fcaSMauro Carvalho Chehabselect an area in a video signal or a buffer, and to query for default 16*54f38fcaSMauro Carvalho Chehabsettings and hardware limits. 17*54f38fcaSMauro Carvalho Chehab 18*54f38fcaSMauro Carvalho ChehabVideo hardware can have various cropping, composing and scaling 19*54f38fcaSMauro Carvalho Chehablimitations. It may only scale up or down, support only discrete scaling 20*54f38fcaSMauro Carvalho Chehabfactors, or have different scaling abilities in the horizontal and 21*54f38fcaSMauro Carvalho Chehabvertical directions. Also it may not support scaling at all. At the same 22*54f38fcaSMauro Carvalho Chehabtime the cropping/composing rectangles may have to be aligned, and both 23*54f38fcaSMauro Carvalho Chehabthe source and the sink may have arbitrary upper and lower size limits. 24*54f38fcaSMauro Carvalho ChehabTherefore, as usual, drivers are expected to adjust the requested 25*54f38fcaSMauro Carvalho Chehabparameters and return the actual values selected. An application can 26*54f38fcaSMauro Carvalho Chehabcontrol the rounding behaviour using 27*54f38fcaSMauro Carvalho Chehab:ref:`constraint flags <v4l2-selection-flags>`. 28*54f38fcaSMauro Carvalho Chehab 29*54f38fcaSMauro Carvalho Chehab 30*54f38fcaSMauro Carvalho ChehabConfiguration of video capture 31*54f38fcaSMauro Carvalho Chehab============================== 32*54f38fcaSMauro Carvalho Chehab 33*54f38fcaSMauro Carvalho ChehabSee figure :ref:`sel-targets-capture` for examples of the selection 34*54f38fcaSMauro Carvalho Chehabtargets available for a video capture device. It is recommended to 35*54f38fcaSMauro Carvalho Chehabconfigure the cropping targets before to the composing targets. 36*54f38fcaSMauro Carvalho Chehab 37*54f38fcaSMauro Carvalho ChehabThe range of coordinates of the top left corner, width and height of 38*54f38fcaSMauro Carvalho Chehabareas that can be sampled is given by the ``V4L2_SEL_TGT_CROP_BOUNDS`` 39*54f38fcaSMauro Carvalho Chehabtarget. It is recommended for the driver developers to put the top/left 40*54f38fcaSMauro Carvalho Chehabcorner at position ``(0,0)``. The rectangle's coordinates are expressed 41*54f38fcaSMauro Carvalho Chehabin pixels. 42*54f38fcaSMauro Carvalho Chehab 43*54f38fcaSMauro Carvalho ChehabThe top left corner, width and height of the source rectangle, that is 44*54f38fcaSMauro Carvalho Chehabthe area actually sampled, is given by the ``V4L2_SEL_TGT_CROP`` target. 45*54f38fcaSMauro Carvalho ChehabIt uses the same coordinate system as ``V4L2_SEL_TGT_CROP_BOUNDS``. The 46*54f38fcaSMauro Carvalho Chehabactive cropping area must lie completely inside the capture boundaries. 47*54f38fcaSMauro Carvalho ChehabThe driver may further adjust the requested size and/or position 48*54f38fcaSMauro Carvalho Chehabaccording to hardware limitations. 49*54f38fcaSMauro Carvalho Chehab 50*54f38fcaSMauro Carvalho ChehabEach capture device has a default source rectangle, given by the 51*54f38fcaSMauro Carvalho Chehab``V4L2_SEL_TGT_CROP_DEFAULT`` target. This rectangle shall cover what the 52*54f38fcaSMauro Carvalho Chehabdriver writer considers the complete picture. Drivers shall set the 53*54f38fcaSMauro Carvalho Chehabactive crop rectangle to the default when the driver is first loaded, 54*54f38fcaSMauro Carvalho Chehabbut not later. 55*54f38fcaSMauro Carvalho Chehab 56*54f38fcaSMauro Carvalho ChehabThe composing targets refer to a memory buffer. The limits of composing 57*54f38fcaSMauro Carvalho Chehabcoordinates are obtained using ``V4L2_SEL_TGT_COMPOSE_BOUNDS``. All 58*54f38fcaSMauro Carvalho Chehabcoordinates are expressed in pixels. The rectangle's top/left corner 59*54f38fcaSMauro Carvalho Chehabmust be located at position ``(0,0)``. The width and height are equal to 60*54f38fcaSMauro Carvalho Chehabthe image size set by :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`. 61*54f38fcaSMauro Carvalho Chehab 62*54f38fcaSMauro Carvalho ChehabThe part of a buffer into which the image is inserted by the hardware is 63*54f38fcaSMauro Carvalho Chehabcontrolled by the ``V4L2_SEL_TGT_COMPOSE`` target. The rectangle's 64*54f38fcaSMauro Carvalho Chehabcoordinates are also expressed in the same coordinate system as the 65*54f38fcaSMauro Carvalho Chehabbounds rectangle. The composing rectangle must lie completely inside 66*54f38fcaSMauro Carvalho Chehabbounds rectangle. The driver must adjust the composing rectangle to fit 67*54f38fcaSMauro Carvalho Chehabto the bounding limits. Moreover, the driver can perform other 68*54f38fcaSMauro Carvalho Chehabadjustments according to hardware limitations. The application can 69*54f38fcaSMauro Carvalho Chehabcontrol rounding behaviour using 70*54f38fcaSMauro Carvalho Chehab:ref:`constraint flags <v4l2-selection-flags>`. 71*54f38fcaSMauro Carvalho Chehab 72*54f38fcaSMauro Carvalho ChehabFor capture devices the default composing rectangle is queried using 73*54f38fcaSMauro Carvalho Chehab``V4L2_SEL_TGT_COMPOSE_DEFAULT``. It is usually equal to the bounding 74*54f38fcaSMauro Carvalho Chehabrectangle. 75*54f38fcaSMauro Carvalho Chehab 76*54f38fcaSMauro Carvalho ChehabThe part of a buffer that is modified by the hardware is given by 77*54f38fcaSMauro Carvalho Chehab``V4L2_SEL_TGT_COMPOSE_PADDED``. It contains all pixels defined using 78*54f38fcaSMauro Carvalho Chehab``V4L2_SEL_TGT_COMPOSE`` plus all padding data modified by hardware 79*54f38fcaSMauro Carvalho Chehabduring insertion process. All pixels outside this rectangle *must not* 80*54f38fcaSMauro Carvalho Chehabbe changed by the hardware. The content of pixels that lie inside the 81*54f38fcaSMauro Carvalho Chehabpadded area but outside active area is undefined. The application can 82*54f38fcaSMauro Carvalho Chehabuse the padded and active rectangles to detect where the rubbish pixels 83*54f38fcaSMauro Carvalho Chehabare located and remove them if needed. 84*54f38fcaSMauro Carvalho Chehab 85*54f38fcaSMauro Carvalho Chehab 86*54f38fcaSMauro Carvalho ChehabConfiguration of video output 87*54f38fcaSMauro Carvalho Chehab============================= 88*54f38fcaSMauro Carvalho Chehab 89*54f38fcaSMauro Carvalho ChehabFor output devices targets and ioctls are used similarly to the video 90*54f38fcaSMauro Carvalho Chehabcapture case. The *composing* rectangle refers to the insertion of an 91*54f38fcaSMauro Carvalho Chehabimage into a video signal. The cropping rectangles refer to a memory 92*54f38fcaSMauro Carvalho Chehabbuffer. It is recommended to configure the composing targets before to 93*54f38fcaSMauro Carvalho Chehabthe cropping targets. 94*54f38fcaSMauro Carvalho Chehab 95*54f38fcaSMauro Carvalho ChehabThe cropping targets refer to the memory buffer that contains an image 96*54f38fcaSMauro Carvalho Chehabto be inserted into a video signal or graphical screen. The limits of 97*54f38fcaSMauro Carvalho Chehabcropping coordinates are obtained using ``V4L2_SEL_TGT_CROP_BOUNDS``. 98*54f38fcaSMauro Carvalho ChehabAll coordinates are expressed in pixels. The top/left corner is always 99*54f38fcaSMauro Carvalho Chehabpoint ``(0,0)``. The width and height is equal to the image size 100*54f38fcaSMauro Carvalho Chehabspecified using :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl. 101*54f38fcaSMauro Carvalho Chehab 102*54f38fcaSMauro Carvalho ChehabThe top left corner, width and height of the source rectangle, that is 103*54f38fcaSMauro Carvalho Chehabthe area from which image date are processed by the hardware, is given 104*54f38fcaSMauro Carvalho Chehabby the ``V4L2_SEL_TGT_CROP``. Its coordinates are expressed in in the 105*54f38fcaSMauro Carvalho Chehabsame coordinate system as the bounds rectangle. The active cropping area 106*54f38fcaSMauro Carvalho Chehabmust lie completely inside the crop boundaries and the driver may 107*54f38fcaSMauro Carvalho Chehabfurther adjust the requested size and/or position according to hardware 108*54f38fcaSMauro Carvalho Chehablimitations. 109*54f38fcaSMauro Carvalho Chehab 110*54f38fcaSMauro Carvalho ChehabFor output devices the default cropping rectangle is queried using 111*54f38fcaSMauro Carvalho Chehab``V4L2_SEL_TGT_CROP_DEFAULT``. It is usually equal to the bounding 112*54f38fcaSMauro Carvalho Chehabrectangle. 113*54f38fcaSMauro Carvalho Chehab 114*54f38fcaSMauro Carvalho ChehabThe part of a video signal or graphics display where the image is 115*54f38fcaSMauro Carvalho Chehabinserted by the hardware is controlled by ``V4L2_SEL_TGT_COMPOSE`` 116*54f38fcaSMauro Carvalho Chehabtarget. The rectangle's coordinates are expressed in pixels. The 117*54f38fcaSMauro Carvalho Chehabcomposing rectangle must lie completely inside the bounds rectangle. The 118*54f38fcaSMauro Carvalho Chehabdriver must adjust the area to fit to the bounding limits. Moreover, the 119*54f38fcaSMauro Carvalho Chehabdriver can perform other adjustments according to hardware limitations. 120*54f38fcaSMauro Carvalho Chehab 121*54f38fcaSMauro Carvalho ChehabThe device has a default composing rectangle, given by the 122*54f38fcaSMauro Carvalho Chehab``V4L2_SEL_TGT_COMPOSE_DEFAULT`` target. This rectangle shall cover what 123*54f38fcaSMauro Carvalho Chehabthe driver writer considers the complete picture. It is recommended for 124*54f38fcaSMauro Carvalho Chehabthe driver developers to put the top/left corner at position ``(0,0)``. 125*54f38fcaSMauro Carvalho ChehabDrivers shall set the active composing rectangle to the default one when 126*54f38fcaSMauro Carvalho Chehabthe driver is first loaded. 127*54f38fcaSMauro Carvalho Chehab 128*54f38fcaSMauro Carvalho ChehabThe devices may introduce additional content to video signal other than 129*54f38fcaSMauro Carvalho Chehaban image from memory buffers. It includes borders around an image. 130*54f38fcaSMauro Carvalho ChehabHowever, such a padded area is driver-dependent feature not covered by 131*54f38fcaSMauro Carvalho Chehabthis document. Driver developers are encouraged to keep padded rectangle 132*54f38fcaSMauro Carvalho Chehabequal to active one. The padded target is accessed by the 133*54f38fcaSMauro Carvalho Chehab``V4L2_SEL_TGT_COMPOSE_PADDED`` identifier. It must contain all pixels 134*54f38fcaSMauro Carvalho Chehabfrom the ``V4L2_SEL_TGT_COMPOSE`` target. 135*54f38fcaSMauro Carvalho Chehab 136*54f38fcaSMauro Carvalho Chehab 137*54f38fcaSMauro Carvalho ChehabScaling control 138*54f38fcaSMauro Carvalho Chehab=============== 139*54f38fcaSMauro Carvalho Chehab 140*54f38fcaSMauro Carvalho ChehabAn application can detect if scaling is performed by comparing the width 141*54f38fcaSMauro Carvalho Chehaband the height of rectangles obtained using ``V4L2_SEL_TGT_CROP`` and 142*54f38fcaSMauro Carvalho Chehab``V4L2_SEL_TGT_COMPOSE`` targets. If these are not equal then the 143*54f38fcaSMauro Carvalho Chehabscaling is applied. The application can compute the scaling ratios using 144*54f38fcaSMauro Carvalho Chehabthese values. 145