Last edited one month ago

Media-ctl

Applicable for STM32MP13x lines, STM32MP21x lines, STM32MP23x lines, STM32MP25x lines


1. Overview[edit | edit source]

media-ctl is a V4L2 utility[1] used to set up and configure the camera subsystem subdevices. It is based on the media controller Linux kernel interface[2].

2. Usage[edit | edit source]

media-ctl --help
media-ctl [options]
-d, --device dev        Media device name (default: /dev/media0)
                        If <dev> starts with a digit, then /dev/media<dev> is used.
                        If <dev> doesn't exist, then find a media device that
                        reports a bus info string equal to <dev>.
-e, --entity name       Print the device name associated with the given entity
-V, --set-v4l2 v4l2     Comma-separated list of formats to setup
    --get-v4l2 pad      Print the active format on a given pad
    --get-dv pad        Print detected and current DV timings on a given pad
    --set-dv pad        Configure DV timings on a given pad
-R, --set-routes routes Configure routes on a given subdev entity
-h, --help              Show verbose help and exit
-i, --interactive       Modify links interactively
-l, --links links       Comma-separated list of link descriptors to setup
    --known-mbus-fmts   List known media bus formats and their numeric values
-p, --print-topology    Print the device topology. If an entity
                        is specified through the -e option, print
                        information for that entity only.
    --print-dot         Print the device topology as a dot graph
-r, --reset             Reset all links to inactive
-v, --verbose           Be verbose
    --version           Show version information

Links and formats are defined as
        links           = link { ',' link } ;
        link            = pad '->' pad '[' flags ']' ;
        pad             = entity ':' pad-number { '/' stream-number } ;
        entity          = entity-number | ( '"' entity-name '"' ) ;

        v4l2            = pad '[' v4l2-properties ']' ;
        v4l2-properties = v4l2-property { ',' v4l2-property } ;
        v4l2-property   = v4l2-mbusfmt | v4l2-crop | v4l2-interval
                        | v4l2-compose | v4l2-interval ;
        v4l2-mbusfmt    = 'fmt:' fcc '/' size ; { 'field:' v4l2-field ; } { 'colorspace:' v4l2-colorspace ; }
                           { 'xfer:' v4l2-xfer-func ; } { 'ycbcr:' v4l2-ycbcr-enc ; }
                           { 'quantization:' v4l2-quant ; }
        v4l2-crop       = 'crop:' rectangle ;
        v4l2-compose    = 'compose:' rectangle ;
        v4l2-interval   = '@' numerator '/' denominator ;

        rectangle       = '(' left ',' top, ')' '/' size ;
        size            = width 'x' height ;

        routes          = entity '[' route { ',' route } ']' ;
        route           = pad-number '/' stream-number '->' pad-number '/' stream-number '[' route-flags ']' ;

where the fields are
        entity-number   Entity numeric identifier
        entity-name     Entity name (string) 
        pad-number      Pad numeric identifier
        stream-number   Stream numeric identifier
        flags           Link flags (0: inactive, 1: active)
        route-flags     Route flags (bitmask of route flags: active - 0x1)
        fcc             Format FourCC
        width           Image width in pixels
        height          Image height in pixels
        numerator       Frame interval numerator
        denominator     Frame interval denominator
        v4l2-field      One of the following:
                        any
                        none
                        top
                        bottom
                        interlaced
                        seq-tb
                        seq-bt
                        alternate
                        interlaced-tb
                        interlaced-bt
        v4l2-colorspace One of the following:
                        default
                        smpte170m
                        smpte240m
                        rec709
                        unknown
                        470m
                        470bg
                        jpeg
                        srgb
                        oprgb
                        bt2020
                        raw
                        dcip3
        v4l2-xfer-func  One of the following:
                        default
                        709
                        srgb
                        oprgb
                        smpte240m
                        none
                        dcip3
                        smpte2084
        v4l2-quant      One of the following:
                        default
                        full-range
                        lim-range
        v4l2-ycbcr-enc  One of the following:
                        default
                        601
                        709
                        xv601
                        xv709
                        unknown
                        bt2020
                        bt2020c
                        smpte240m

3. Examples[edit | edit source]

Refer to V4L2 camera subsystem setup for examples of usage.

4. References[edit | edit source]