Appendix B. Common definitions for V4L2 and V4L2 subdev interfaces

Table of Contents

Common selection definitions
Selection targets
Selection flags

Common selection definitions

While the V4L2 selection API and V4L2 subdev selection APIs are very similar, there's one fundamental difference between the two. On sub-device API, the selection rectangle refers to the media bus format, and is bound to a sub-device's pad. On the V4L2 interface the selection rectangles refer to the in-memory pixel format.

This section defines the common definitions of the selection interfaces on the two APIs.

Selection targets

The precise meaning of the selection targets may be dependent on which of the two interfaces they are used.

Table B.1. Selection target definitions

Target nameidDefinitionValid for V4L2Valid for V4L2 subdev
V4L2_SEL_TGT_CROP0x0000Crop rectangle. Defines the cropped area.YesYes
V4L2_SEL_TGT_CROP_DEFAULT0x0001Suggested cropping rectangle that covers the "whole picture".YesNo
V4L2_SEL_TGT_CROP_BOUNDS0x0002Bounds of the crop rectangle. All valid crop rectangles fit inside the crop bounds rectangle. YesYes
V4L2_SEL_TGT_NATIVE_SIZE0x0003The native size of the device, e.g. a sensor's pixel array. left and top fields are zero for this target. Setting the native size will generally only make sense for memory to memory devices where the software can create a canvas of a given size in which for example a video frame can be composed. In that case V4L2_SEL_TGT_NATIVE_SIZE can be used to configure the size of that canvas. YesYes
V4L2_SEL_TGT_COMPOSE0x0100Compose rectangle. Used to configure scaling and composition.YesYes
V4L2_SEL_TGT_COMPOSE_DEFAULT0x0101Suggested composition rectangle that covers the "whole picture".YesNo
V4L2_SEL_TGT_COMPOSE_BOUNDS0x0102Bounds of the compose rectangle. All valid compose rectangles fit inside the compose bounds rectangle.YesYes
V4L2_SEL_TGT_COMPOSE_PADDED0x0103The active area and all padding pixels that are inserted or modified by hardware.YesNo

Selection flags

Table B.2. Selection flag definitions

Flag nameidDefinitionValid for V4L2Valid for V4L2 subdev
V4L2_SEL_FLAG_GE(1 << 0)Suggest the driver it should choose greater or equal rectangle (in size) than was requested. Albeit the driver may choose a lesser size, it will only do so due to hardware limitations. Without this flag (and V4L2_SEL_FLAG_LE) the behaviour is to choose the closest possible rectangle.YesYes
V4L2_SEL_FLAG_LE(1 << 1)Suggest the driver it should choose lesser or equal rectangle (in size) than was requested. Albeit the driver may choose a greater size, it will only do so due to hardware limitations.YesYes
V4L2_SEL_FLAG_KEEP_CONFIG(1 << 2)The configuration must not be propagated to any further processing steps. If this flag is not given, the configuration is propagated inside the subdevice to all further processing steps.NoYes