Peios Learn
Documentation

Peios

Peios Peios Kernel Universal Directory Project

Developer Tools

Trail Acta Provium clackatoo CAF GCSL Pekit

Applications

Framewright

Standards and Conventions

Standards and Conventions Peios Specifications
Peios Kernel

Digital television (DVB)

Single-page view · as markdown

Digital TV CA close()

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

Digital TV CA close()

Synopsis #

int close(int fd)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

Description #

This system call closes a previously opened CA device.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

Digital TV CA open()

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

Digital TV CA open()

Synopsis #

int open(const char *name, int flags)

Arguments #

  • name

    Name of specific Digital TV CA device.

  • flags

    A bit-wise OR of the following flags:

O_RDONLY

read-only access

O_RDWR

read/write access

O_NONBLOCK

open in non-blocking mode (blocking mode is the default)

Description #

This system call opens a named ca device (e.g. /dev/dvb/adapter?/ca?) for subsequent use.

When an open() call has succeeded, the device will be ready for use. The significance of blocking or non-blocking mode is described in the documentation for functions where there is a difference. It does not affect the semantics of the open() call itself. A device opened in blocking mode can later be put into non-blocking mode (and vice versa) using the F_SETFL command of the fcntl system call. This is a standard system call, documented in the Linux manual page for fcntl. Only one user can open the CA Device in O_RDWR mode. All other attempts to open the device in this mode will fail, and an error code will be returned.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

CA_GET_CAP

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

CA_GET_CAP

Synopsis #

CA_GET_CAP

int ioctl(fd, CA_GET_CAP, struct ca_caps *caps)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

  • caps

    Pointer to struct ca_caps.

Description #

Queries the Kernel for information about the available CA and descrambler slots, and their types.

Return Value #

On success 0 is returned and ca_caps is filled.

On error, -1 is returned and the errno variable is set appropriately.

The generic error codes are described at the Generic Error Codes chapter.

CA_GET_DESCR_INFO

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

CA_GET_DESCR_INFO

Synopsis #

CA_GET_DESCR_INFO

int ioctl(fd, CA_GET_DESCR_INFO, struct ca_descr_info *desc)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

  • desc

    Pointer to struct ca_descr_info.

Description #

Returns information about all descrambler slots.

Return Value #

On success 0 is returned, and ca_descr_info is filled.

On error -1 is returned, and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

CA_GET_MSG

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

CA_GET_MSG

Synopsis #

CA_GET_MSG

int ioctl(fd, CA_GET_MSG, struct ca_msg *msg)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

  • msg

    Pointer to struct ca_msg.

Description #

Receives a message via a CI CA module.

Note

Please notice that, on most drivers, this is done by reading from the /dev/adapter?/ca? device node.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

CA_GET_SLOT_INFO

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

CA_GET_SLOT_INFO

Synopsis #

CA_GET_SLOT_INFO

int ioctl(fd, CA_GET_SLOT_INFO, struct ca_slot_info *info)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

  • info

    Pointer to struct ca_slot_info.

Description #

Returns information about a CA slot identified by ca_slot_info.slot_num.

Return Value #

On success 0 is returned, and ca_slot_info is filled.

On error -1 is returned, and the errno variable is set appropriately.

ENODEV

the slot is not available.

The generic error codes are described at the Generic Error Codes chapter.

CA_RESET

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

CA_RESET

Synopsis #

CA_RESET

int ioctl(fd, CA_RESET)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

Description #

Puts the Conditional Access hardware on its initial state. It should be called before start using the CA hardware.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

CA_SEND_MSG

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

CA_SEND_MSG

Synopsis #

CA_SEND_MSG

int ioctl(fd, CA_SEND_MSG, struct ca_msg *msg)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

  • msg

    Pointer to struct ca_msg.

Description #

Sends a message via a CI CA module.

Note

Please notice that, on most drivers, this is done by writing to the /dev/adapter?/ca? device node.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

CA_SET_DESCR

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

CA_SET_DESCR

Synopsis #

CA_SET_DESCR

int ioctl(fd, CA_SET_DESCR, struct ca_descr *desc)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

  • msg

    Pointer to struct ca_descr.

Description #

CA_SET_DESCR is used for feeding descrambler CA slots with descrambling keys (referred as control words).

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

Digital TV CA Device

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

The Digital TV CA device controls the conditional access hardware. It can be accessed through /dev/dvb/adapter?/ca?. Data types and ioctl definitions can be accessed by including linux/dvb/ca.h in your application.

Note

There are three ioctls at this API that aren't documented: CA_GET_MSG, CA_SEND_MSG and CA_SET_DESCR. Documentation for them are welcome.

  • CA Data Types
  • CA Function Calls
  • The High level CI API

CA Data Types

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

struct ca_slot_info #

CA slot interface types and info.

Definition

struct ca_slot_info {
        int num;
        int type;
    #define CA_CI            1;
    #define CA_CI_LINK       2;
    #define CA_CI_PHYS       4;
    #define CA_DESCR         8;
    #define CA_SC          128;
        unsigned int flags;
    #define CA_CI_MODULE_PRESENT 1;
    #define CA_CI_MODULE_READY   2;
};

Members

  • num: slot number.
  • type: slot type.
  • flags: flags applicable to the slot.

Description

This struct stores the CA slot information.

type can be:

  • CA_CI - CI high level interface;
  • CA_CI_LINK - CI link layer level interface;
  • CA_CI_PHYS - CI physical layer level interface;
  • CA_DESCR - built-in descrambler;
  • CA_SC -simple smart card interface.

flags can be:

  • CA_CI_MODULE_PRESENT - module (or card) inserted;
  • CA_CI_MODULE_READY - module is ready for usage.

struct ca_descr_info #

descrambler types and info.

Definition

struct ca_descr_info {
        unsigned int num;
        unsigned int type;
    #define CA_ECD           1;
    #define CA_NDS           2;
    #define CA_DSS           4;
};

Members

  • num: number of available descramblers (keys).
  • type: type of supported scrambling system.

Description

Identifies the number of descramblers and their type.

type can be:

  • CA_ECD - European Common Descrambler (ECD) hardware;
  • CA_NDS - Videoguard (NDS) hardware;
  • CA_DSS - Distributed Sample Scrambling (DSS) hardware.

struct ca_caps #

CA slot interface capabilities.

Definition

struct ca_caps {
    unsigned int slot_num;
    unsigned int slot_type;
    unsigned int descr_num;
    unsigned int descr_type;
};

Members

  • slot_num: total number of CA card and module slots.
  • slot_type: bitmap with all supported types as defined at struct ca_slot_info (e. g. CA_CI, CA_CI_LINK, etc).
  • descr_num: total number of descrambler slots (keys)
  • descr_type: bitmap with all supported types as defined at struct ca_descr_info (e. g. CA_ECD, CA_NDS, etc).

struct ca_msg #

a message to/from a CI-CAM

Definition

struct ca_msg {
    unsigned int index;
    unsigned int type;
    unsigned int length;
    unsigned char msg[256];
};

Members

  • index: unused
  • type: unused
  • length: length of the message
  • msg: message

Description

This struct carries a message to be send/received from a CI CA module.

struct ca_descr #

CA descrambler control words info

Definition

struct ca_descr {
    unsigned int index;
    unsigned int parity;
    unsigned char cw[8];
};

Members

  • index: CA Descrambler slot
  • parity: control words parity, where 0 means even and 1 means odd
  • cw: CA Descrambler control words

CA Function Calls

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

  • Digital TV CA open()
  • Digital TV CA close()
  • CA_RESET
  • CA_GET_CAP
  • CA_GET_SLOT_INFO
  • CA_GET_DESCR_INFO
  • CA_GET_MSG
  • CA_SEND_MSG
  • CA_SET_DESCR

The High level CI API

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Note

This documentation is outdated.

This document describes the high level CI API as in accordance to the Linux DVB API.

With the High Level CI approach any new card with almost any random architecture can be implemented with this style, the definitions inside the switch statement can be easily adapted for any card, thereby eliminating the need for any additional ioctls.

The disadvantage is that the driver/hardware has to manage the rest. For the application programmer it would be as simple as sending/receiving an array to/from the CI ioctls as defined in the Linux DVB API. No changes have been made in the API to accommodate this feature.

Why the need for another CI interface? #

This is one of the most commonly asked question. Well a nice question. Strictly speaking this is not a new interface.

The CI interface is defined in the DVB API in ca.h as:

typedef struct ca_slot_info {
        int num;               /* slot number */

        int type;              /* CA interface this slot supports */
#define CA_CI            1     /* CI high level interface */
#define CA_CI_LINK       2     /* CI link layer level interface */
#define CA_CI_PHYS       4     /* CI physical layer level interface */
#define CA_DESCR         8     /* built-in descrambler */
#define CA_SC          128     /* simple smart card interface */

        unsigned int flags;
#define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */
#define CA_CI_MODULE_READY   2
} ca_slot_info_t;

This CI interface follows the CI high level interface, which is not implemented by most applications. Hence this area is revisited.

This CI interface is quite different in the case that it tries to accommodate all other CI based devices, that fall into the other categories.

This means that this CI interface handles the EN50221 style tags in the Application layer only and no session management is taken care of by the application. The driver/hardware will take care of all that.

This interface is purely an EN50221 interface exchanging APDU's. This means that no session management, link layer or a transport layer do exist in this case in the application to driver communication. It is as simple as that. The driver/hardware has to take care of that.

With this High Level CI interface, the interface can be defined with the regular ioctls.

All these ioctls are also valid for the High level CI interface

#define CA_RESET _IO('o', 128) #define CA_GET_CAP _IOR('o', 129, ca_caps_t) #define CA_GET_SLOT_INFO _IOR('o', 130, ca_slot_info_t) #define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t) #define CA_GET_MSG _IOR('o', 132, ca_msg_t) #define CA_SEND_MSG _IOW('o', 133, ca_msg_t) #define CA_SET_DESCR _IOW('o', 134, ca_descr_t)

On querying the device, the device yields information thus:

CA_GET_SLOT_INFO
----------------------------
Command = [info]
APP: Number=[1]
APP: Type=[1]
APP: flags=[1]
APP: CI High level interface
APP: CA/CI Module Present

CA_GET_CAP
----------------------------
Command = [caps]
APP: Slots=[1]
APP: Type=[1]
APP: Descrambler keys=[16]
APP: Type=[1]

CA_SEND_MSG
----------------------------
Descriptors(Program Level)=[ 09 06 06 04 05 50 ff f1]
Found CA descriptor @ program level

(20) ES type=[2] ES pid=[201]  ES length =[0 (0x0)]
(25) ES type=[4] ES pid=[301]  ES length =[0 (0x0)]
ca_message length is 25 (0x19) bytes
EN50221 CA MSG=[ 9f 80 32 19 03 01 2d d1 f0 08 01 09 06 06 04 05 50 ff f1 02 e0 c9 00 00 04 e1 2d 00 00]

Not all ioctl's are implemented in the driver from the API, the other features of the hardware that cannot be implemented by the API are achieved using the CA_GET_MSG and CA_SEND_MSG ioctls. An EN50221 style wrapper is used to exchange the data to maintain compatibility with other hardware.

/* a message to/from a CI-CAM */
typedef struct ca_msg {
        unsigned int index;
        unsigned int type;
        unsigned int length;
        unsigned char msg[256];
} ca_msg_t;

The flow of data can be described thus,

     App (User)
     -----
     parse
       |
       |
       v
     en50221 APDU (package)
--------------------------------------
|      |                             | High Level CI driver
|      |                             |
|      v                             |
|    en50221 APDU (unpackage)        |
|      |                             |
|      |                             |
|      v                             |
|    sanity checks                   |
|      |                             |
|      |                             |
|      v                             |
|    do (H/W dep)                    |
--------------------------------------
       |    Hardware
       |
       v

The High Level CI interface uses the EN50221 DVB standard, following a standard ensures futureproofness.

Digital TV Demux Device

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

The Digital TV demux device controls the MPEG-TS filters for the digital TV. If the driver and hardware supports, those filters are implemented at the hardware. Otherwise, the Kernel provides a software emulation.

It can be accessed through /dev/adapter?/demux?. Data types and ioctl definitions can be accessed by including linux/dvb/dmx.h in your application.

  • Demux Data Types
  • Demux Function Calls

DMX_ADD_PID

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_ADD_PID

Synopsis #

DMX_ADD_PID

int ioctl(fd, DMX_ADD_PID, __u16 *pid)

Arguments #

  • fd

    File descriptor returned by open().

  • pid

    PID number to be filtered.

Description #

This ioctl call allows to add multiple PIDs to a transport stream filter previously set up with DMX_SET_PES_FILTER and output equal to DMX_OUT_TSDEMUX_TAP <dmx_output>.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

ioctl DMX_EXPBUF

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_EXPBUF - Export a buffer as a DMABUF file descriptor.

Warning

this API is still experimental

Synopsis #

DMX_EXPBUF

int ioctl(int fd, DMX_EXPBUF, struct dmx_exportbuffer *argp)

Arguments #

  • fd

    File descriptor returned by open().

  • argp

    Pointer to struct dmx_exportbuffer.

Description #

This ioctl is an extension to the memory mapping I/O method. It can be used to export a buffer as a DMABUF file at any time after buffers have been allocated with the ioctl DMX_REQBUFS ioctl.

To export a buffer, applications fill struct dmx_exportbuffer. Applications must set the index field. Valid index numbers range from zero to the number of buffers allocated with ioctl DMX_REQBUFS (struct dmx_requestbuffers count) minus one. Additional flags may be posted in the flags field. Refer to a manual for open() for details. Currently only O_CLOEXEC, O_RDONLY, O_WRONLY, and O_RDWR are supported. All other fields must be set to zero. In the case of multi-planar API, every plane is exported separately using multiple ioctl DMX_EXPBUF calls.

After calling ioctl DMX_EXPBUF the fd field will be set by a driver, on success. This is a DMABUF file descriptor. The application may pass it to other DMABUF-aware devices. It is recommended to close a DMABUF file when it is no longer used to allow the associated memory to be reclaimed.

Examples #

int buffer_export(int v4lfd, enum dmx_buf_type bt, int index, int *dmafd)
{
    struct dmx_exportbuffer expbuf;

    memset(&expbuf, 0, sizeof(expbuf));
    expbuf.type = bt;
    expbuf.index = index;
    if (ioctl(v4lfd, DMX_EXPBUF, &expbuf) == -1) {
        perror("DMX_EXPBUF");
        return -1;
    }

    *dmafd = expbuf.fd;

    return 0;
}

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

  • EINVAL

    A queue is not in MMAP mode or DMABUF exporting is not supported or flags or index fields are invalid.

Digital TV demux close()

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

Digital TV demux close()

Synopsis #

int close(int fd)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

Description #

This system call deactivates and deallocates a filter that was previously allocated via the open() call.

Return Value #

On success 0 is returned.

On error, -1 is returned and the errno variable is set appropriately.

The generic error codes are described at the Generic Error Codes chapter.

Digital TV demux open()

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

Digital TV demux open()

Synopsis #

int open(const char *deviceName, int flags)

Arguments #

  • name

    Name of specific Digital TV demux device.

  • flags

    A bit-wise OR of the following flags:

O_RDONLY

read-only access

O_RDWR

read/write access

O_NONBLOCK

open in non-blocking mode (blocking mode is the default)

Description #

This system call, used with a device name of /dev/dvb/adapter?/demux?, allocates a new filter and returns a handle which can be used for subsequent control of that filter. This call has to be made for each filter to be used, i.e. every returned file descriptor is a reference to a single filter. /dev/dvb/adapter?/dvr? is a logical device to be used for retrieving Transport Streams for digital video recording. When reading from this device a transport stream containing the packets from all PES filters set in the corresponding demux device (/dev/dvb/adapter?/demux?) having the output set to DMX_OUT_TS_TAP. A recorded Transport Stream is replayed by writing to this device.

The significance of blocking or non-blocking mode is described in the documentation for functions where there is a difference. It does not affect the semantics of the open() call itself. A device opened in blocking mode can later be put into non-blocking mode (and vice versa) using the F_SETFL command of the fcntl system call.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

EMFILE

"Too many open files", i.e. no more filters available.

The generic error codes are described at the Generic Error Codes chapter.

Digital TV demux read()

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

Digital TV demux read()

Synopsis #

size_t read(int fd, void *buf, size_t count)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

    • buf

      Buffer to be filled

  • count

    Max number of bytes to read

Description #

This system call returns filtered data, which might be section or Packetized Elementary Stream (PES) data. The filtered data is transferred from the driver's internal circular buffer to buf. The maximum amount of data to be transferred is implied by count.

Note

if a section filter created with DMX_CHECK_CRC <dmx_sct_filter_params> flag set, data that fails on CRC check will be silently ignored.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

EWOULDBLOCK

No data to return and O_NONBLOCK was specified.

EOVERFLOW

The filtered data was not read from the buffer in due time, resulting in non-read data being lost. The buffer is flushed.

ETIMEDOUT

The section was not loaded within the stated timeout period. See ioctl DMX_SET_FILTER for how to set a timeout.

EFAULT

The driver failed to write to the callers buffer due to an invalid *buf pointer.

The generic error codes are described at the Generic Error Codes chapter.

Digital TV demux write()

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

Digital TV demux write()

Synopsis #

ssize_t write(int fd, const void *buf, size_t count)

Arguments #

  • fd

    File descriptor returned by a previous call to open().

  • buf

    Buffer with data to be written

  • count

    Number of bytes at the buffer

Description #

This system call is only provided by the logical device /dev/dvb/adapter?/dvr?, associated with the physical demux device that provides the actual DVR functionality. It is used for replay of a digitally recorded Transport Stream. Matching filters have to be defined in the corresponding physical demux device, /dev/dvb/adapter?/demux?. The amount of data to be transferred is implied by count.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

EWOULDBLOCK

No data was written. This might happen if O_NONBLOCK was specified and there is no more buffer space available (if O_NONBLOCK is not specified the function will block until buffer space is available).

EBUSY

This error code indicates that there are conflicting requests. The corresponding demux device is setup to receive data from the front- end. Make sure that these filters are stopped and that the filters with input set to DMX_IN_DVR are started.

The generic error codes are described at the Generic Error Codes chapter.

DMX_GET_PES_PIDS

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_GET_PES_PIDS

Synopsis #

DMX_GET_PES_PIDS

int ioctl(fd, DMX_GET_PES_PIDS, __u16 pids[5])

Arguments #

  • fd

    File descriptor returned by open().

  • pids

    Array used to store 5 Program IDs.

Description #

This ioctl allows to query a DVB device to return the first PID used by audio, video, textext, subtitle and PCR programs on a given service. They're stored as:

PID element

position

content

pids[DMX_PES_AUDIO]

0

first audio PID

pids[DMX_PES_VIDEO]

1

first video PID

pids[DMX_PES_TELETEXT]

2

first teletext PID

pids[DMX_PES_SUBTITLE]

3

first subtitle PID

pids[DMX_PES_PCR]

4

first Program Clock Reference PID

Note

A value equal to 0xffff means that the PID was not filled by the Kernel.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

The generic error codes are described at the Generic Error Codes chapter.

DMX_GET_STC

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_GET_STC

Synopsis #

DMX_GET_STC

int ioctl(int fd, DMX_GET_STC, struct dmx_stc *stc)

Arguments #

  • fd

    File descriptor returned by open().

  • stc

    Pointer to dmx_stc where the stc data is to be stored.

Description #

This ioctl call returns the current value of the system time counter (which is driven by a PES filter of type DMX_PES_PCR <dmx_ts_pes>). Some hardware supports more than one STC, so you must specify which one by setting the num <dmx_stc> field of stc before the ioctl (range 0...n). The result is returned in form of a ratio with a 64 bit numerator and a 32 bit denominator, so the real 90kHz STC value is stc->stc / stc->base.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

EINVAL

Invalid stc number.

The generic error codes are described at the Generic Error Codes chapter.

Digital TV mmap()

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

dmx-mmap - Map device memory into application address space

Warning

this API is still experimental

Synopsis #

#include <unistd.h>
#include <sys/mman.h>

void *mmap( void *start, size_t length, int prot, int flags, int fd, off_t offset )

Arguments #

  • start

    Map the buffer to this address in the application's address space. When the MAP_FIXED flag is specified, start must be a multiple of the pagesize and mmap will fail when the specified address cannot be used. Use of this option is discouraged; applications should just specify a NULL pointer here.

  • length

    Length of the memory area to map. This must be a multiple of the DVB packet length (188, on most drivers).

  • prot

    The prot argument describes the desired memory protection. Regardless of the device type and the direction of data exchange it should be set to PROT_READ | PROT_WRITE, permitting read and write access to image buffers. Drivers should support at least this combination of flags.

  • flags

    The flags parameter specifies the type of the mapped object, mapping options and whether modifications made to the mapped copy of the page are private to the process or are to be shared with other references.

    MAP_FIXED requests that the driver selects no other address than the one specified. If the specified address cannot be used, mmap() will fail. If MAP_FIXED is specified, start must be a multiple of the pagesize. Use of this option is discouraged.

    One of the MAP_SHARED or MAP_PRIVATE flags must be set. MAP_SHARED allows applications to share the mapped memory with other (e. g. child-) processes.

    Note

    The Linux Digital TV applications should not set the MAP_PRIVATE, MAP_DENYWRITE, MAP_EXECUTABLE or MAP_ANON flags.

  • fd

    File descriptor returned by open().

  • offset

    Offset of the buffer in device memory, as returned by ioctl DMX_QUERYBUF ioctl.

Description #

The mmap() function asks to map length bytes starting at offset in the memory of the device specified by fd into the application address space, preferably at address start. This latter address is a hint only, and is usually specified as 0.

Suitable length and offset parameters are queried with the ioctl DMX_QUERYBUF ioctl. Buffers must be allocated with the ioctl DMX_REQBUFS ioctl before they can be queried.

To unmap buffers the munmap() function is used.

Return Value #

On success mmap() returns a pointer to the mapped buffer. On error MAP_FAILED (-1) is returned, and the errno variable is set appropriately. Possible error codes are:

  • EBADF

    fd is not a valid file descriptor.

  • EACCES

    fd is not open for reading and writing.

  • EINVAL

    The start or length or offset are not suitable. (E. g. they are too large, or not aligned on a PAGESIZE boundary.)

    The flags or prot value is not supported.

    No buffers have been allocated with the ioctl DMX_REQBUFS ioctl.

  • ENOMEM

    Not enough physical or virtual memory was available to complete the request.

DVB munmap()

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

dmx-munmap - Unmap device memory

Warning

This API is still experimental.

Synopsis #

#include <unistd.h>
#include <sys/mman.h>

int munmap( void *start, size_t length )

Arguments #

  • start

    Address of the mapped buffer as returned by the mmap() function.

  • length

    Length of the mapped buffer. This must be the same value as given to mmap().

Description #

Unmaps a previously with the mmap() function mapped buffer and frees it, if possible.

Return Value #

On success munmap() returns 0, on failure -1 and the errno variable is set appropriately:

  • EINVAL

    The start or length is incorrect, or no buffers have been mapped yet.

ioctl DMX_QBUF, DMX_DQBUF

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_QBUF - DMX_DQBUF - Exchange a buffer with the driver

Warning

this API is still experimental

Synopsis #

DMX_QBUF

int ioctl(int fd, DMX_QBUF, struct dmx_buffer *argp)

DMX_DQBUF

int ioctl(int fd, DMX_DQBUF, struct dmx_buffer *argp)

Arguments #

  • fd

    File descriptor returned by open().

  • argp

    Pointer to struct dmx_buffer.

Description #

Applications call the DMX_QBUF ioctl to enqueue an empty (capturing) or filled (output) buffer in the driver's incoming queue. The semantics depend on the selected I/O method.

To enqueue a buffer applications set the index field. Valid index numbers range from zero to the number of buffers allocated with ioctl DMX_REQBUFS (struct dmx_requestbuffers count) minus one. The contents of the struct dmx_buffer returned by a ioctl DMX_QUERYBUF ioctl will do as well.

When DMX_QBUF is called with a pointer to this structure, it locks the memory pages of the buffer in physical memory, so they cannot be swapped out to disk. Buffers remain locked until dequeued, until the device is closed.

Applications call the DMX_DQBUF ioctl to dequeue a filled (capturing) buffer from the driver's outgoing queue. They just set the index field with the buffer ID to be queued. When DMX_DQBUF is called with a pointer to struct dmx_buffer, the driver fills the remaining fields or returns an error code.

By default DMX_DQBUF blocks when no buffer is in the outgoing queue. When the O_NONBLOCK flag was given to the open() function, DMX_DQBUF returns immediately with an EAGAIN error code when no buffer is available.

The struct dmx_buffer structure is specified in buffer.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

  • EAGAIN

    Non-blocking I/O has been selected using O_NONBLOCK and no buffer was in the outgoing queue.

  • EINVAL

    The index is out of bounds, or no buffers have been allocated yet.

  • EIO

    DMX_DQBUF failed due to an internal error. Can also indicate temporary problems like signal loss or CRC errors.

ioctl DMX_QUERYBUF

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_QUERYBUF - Query the status of a buffer

Warning

this API is still experimental

Synopsis #

DMX_QUERYBUF

int ioctl(int fd, DMX_QUERYBUF, struct dvb_buffer *argp)

Arguments #

  • fd

    File descriptor returned by open().

  • argp

    Pointer to struct dvb_buffer.

Description #

This ioctl is part of the mmap streaming I/O method. It can be used to query the status of a buffer at any time after buffers have been allocated with the ioctl DMX_REQBUFS ioctl.

Applications set the index field. Valid index numbers range from zero to the number of buffers allocated with ioctl DMX_REQBUFS (struct dvb_requestbuffers count) minus one.

After calling ioctl DMX_QUERYBUF with a pointer to this structure, drivers return an error code or fill the rest of the structure.

On success, the offset will contain the offset of the buffer from the start of the device memory, the length field its size, and the bytesused the number of bytes occupied by data in the buffer (payload).

Return Value #

On success 0 is returned, the offset will contain the offset of the buffer from the start of the device memory, the length field its size, and the bytesused the number of bytes occupied by data in the buffer (payload).

On error it returns -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

  • EINVAL

    The index is out of bounds.

DMX_REMOVE_PID

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_REMOVE_PID

Synopsis #

DMX_REMOVE_PID

int ioctl(fd, DMX_REMOVE_PID, __u16 *pid)

Arguments #

  • fd

    File descriptor returned by open().

  • pid

    PID of the PES filter to be removed.

Description #

This ioctl call allows to remove a PID when multiple PIDs are set on a transport stream filter, e. g. a filter previously set up with output equal to DMX_OUT_TSDEMUX_TAP <dmx_output>, created via either DMX_SET_PES_FILTER or DMX_ADD_PID.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

The generic error codes are described at the Generic Error Codes chapter.

ioctl DMX_REQBUFS

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_REQBUFS - Initiate Memory Mapping and/or DMA buffer I/O

Warning

this API is still experimental

Synopsis #

DMX_REQBUFS

int ioctl(int fd, DMX_REQBUFS, struct dmx_requestbuffers *argp)

Arguments #

  • fd

    File descriptor returned by open().

  • argp

    Pointer to struct dmx_requestbuffers.

Description #

This ioctl is used to initiate a memory mapped or DMABUF based demux I/O.

Memory mapped buffers are located in device memory and must be allocated with this ioctl before they can be mapped into the application's address space. User buffers are allocated by applications themselves, and this ioctl is merely used to switch the driver into user pointer I/O mode and to setup some internal structures. Similarly, DMABUF buffers are allocated by applications through a device driver, and this ioctl only configures the driver into DMABUF I/O mode without performing any direct allocation.

To allocate device buffers applications initialize all fields of the struct dmx_requestbuffers structure. They set the count field to the desired number of buffers, and size to the size of each buffer.

When the ioctl is called with a pointer to this structure, the driver will attempt to allocate the requested number of buffers and it stores the actual number allocated in the count field. The count can be smaller than the number requested, even zero, when the driver runs out of free memory. A larger number is also possible when the driver requires more buffers to function correctly. The actual allocated buffer size can is returned at size, and can be smaller than what's requested.

When this I/O method is not supported, the ioctl returns an EOPNOTSUPP error code.

Applications can call ioctl DMX_REQBUFS again to change the number of buffers, however this cannot succeed when any buffers are still mapped. A count value of zero frees all buffers, after aborting or finishing any DMA in progress.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

  • EOPNOTSUPP

    The the requested I/O method is not supported.

DMX_SET_BUFFER_SIZE

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_SET_BUFFER_SIZE

Synopsis #

DMX_SET_BUFFER_SIZE

int ioctl(int fd, DMX_SET_BUFFER_SIZE, unsigned long size)

Arguments #

  • fd

    File descriptor returned by open().

  • size

    Unsigned long size

Description #

This ioctl call is used to set the size of the circular buffer used for filtered data. The default size is two maximum sized sections, i.e. if this function is not called a buffer size of 2 * 4096 bytes will be used.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

The generic error codes are described at the Generic Error Codes chapter.

DMX_SET_FILTER

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_SET_FILTER

Synopsis #

DMX_SET_FILTER

int ioctl(int fd, DMX_SET_FILTER, struct dmx_sct_filter_params *params)

Arguments #

  • fd

    File descriptor returned by open().

params

Pointer to structure containing filter parameters.

Description #

This ioctl call sets up a filter according to the filter and mask parameters provided. A timeout may be defined stating number of seconds to wait for a section to be loaded. A value of 0 means that no timeout should be applied. Finally there is a flag field where it is possible to state whether a section should be CRC-checked, whether the filter should be a "one-shot" filter, i.e. if the filtering operation should be stopped after the first section is received, and whether the filtering operation should be started immediately (without waiting for a DMX_START ioctl call). If a filter was previously set-up, this filter will be canceled, and the receive buffer will be flushed.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

The generic error codes are described at the Generic Error Codes chapter.

DMX_SET_PES_FILTER

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_SET_PES_FILTER

Synopsis #

DMX_SET_PES_FILTER

int ioctl(int fd, DMX_SET_PES_FILTER, struct dmx_pes_filter_params *params)

Arguments #

  • fd

    File descriptor returned by open().

  • params

    Pointer to structure containing filter parameters.

Description #

This ioctl call sets up a PES filter according to the parameters provided. By a PES filter is meant a filter that is based just on the packet identifier (PID), i.e. no PES header or payload filtering capability is supported.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

EBUSY

This error code indicates that there are conflicting requests. There are active filters filtering data from another input source. Make sure that these filters are stopped before starting this filter.

The generic error codes are described at the Generic Error Codes chapter.

DMX_START

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_START

Synopsis #

DMX_START

int ioctl(int fd, DMX_START)

Arguments #

  • fd

    File descriptor returned by open().

Description #

This ioctl call is used to start the actual filtering operation defined via the ioctl calls DMX_SET_FILTER or DMX_SET_PES_FILTER.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

EINVAL

Invalid argument, i.e. no filtering parameters provided via the DMX_SET_FILTER or DMX_SET_PES_FILTER ioctls.

EBUSY

This error code indicates that there are conflicting requests. There are active filters filtering data from another input source. Make sure that these filters are stopped before starting this filter.

The generic error codes are described at the Generic Error Codes chapter.

DMX_STOP

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

DMX_STOP

Synopsis #

DMX_STOP

int ioctl(int fd, DMX_STOP)

Arguments #

  • fd

    File descriptor returned by open().

Description #

This ioctl call is used to stop the actual filtering operation defined via the ioctl calls DMX_SET_FILTER or DMX_SET_PES_FILTER and started via the DMX_START command.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

The generic error codes are described at the Generic Error Codes chapter.

Demux Function Calls

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

  • Digital TV demux open()
  • Digital TV demux close()
  • Digital TV demux read()
  • Digital TV demux write()
  • Digital TV mmap()
  • DVB munmap()
  • DMX_START
  • DMX_STOP
  • DMX_SET_FILTER
  • DMX_SET_PES_FILTER
  • DMX_SET_BUFFER_SIZE
  • DMX_GET_STC
  • DMX_GET_PES_PIDS
  • DMX_ADD_PID
  • DMX_REMOVE_PID
  • ioctl DMX_REQBUFS
  • ioctl DMX_QUERYBUF
  • ioctl DMX_EXPBUF
  • ioctl DMX_QBUF, DMX_DQBUF

Demux Data Types

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

enum dmx_output #

Output for the demux.

Constants

  • DMX_OUT_DECODER: Streaming directly to decoder.
  • DMX_OUT_TAP: Output going to a memory buffer (to be retrieved via the read command). Delivers the stream output to the demux device on which the ioctl is called.
  • DMX_OUT_TS_TAP: Output multiplexed into a new TS (to be retrieved by reading from the logical DVR device). Routes output to the logical DVR device /dev/dvb/adapter?/dvr?, which delivers a TS multiplexed from all filters for which DMX_OUT_TS_TAP was specified.
  • DMX_OUT_TSDEMUX_TAP: Like DMX_OUT_TS_TAP but retrieved from the DMX device.

enum dmx_input #

Input from the demux.

Constants

  • DMX_IN_FRONTEND: Input from a front-end device.
  • DMX_IN_DVR: Input from the logical DVR device.

enum dmx_ts_pes #

type of the PES filter.

Constants

  • DMX_PES_AUDIO0: first audio PID. Also referred as DMX_PES_AUDIO.
  • DMX_PES_VIDEO0: first video PID. Also referred as DMX_PES_VIDEO.
  • DMX_PES_TELETEXT0: first teletext PID. Also referred as DMX_PES_TELETEXT.
  • DMX_PES_SUBTITLE0: first subtitle PID. Also referred as DMX_PES_SUBTITLE.
  • DMX_PES_PCR0: first Program Clock Reference PID. Also referred as DMX_PES_PCR.
  • DMX_PES_AUDIO1: second audio PID.
  • DMX_PES_VIDEO1: second video PID.
  • DMX_PES_TELETEXT1: second teletext PID.
  • DMX_PES_SUBTITLE1: second subtitle PID.
  • DMX_PES_PCR1: second Program Clock Reference PID.
  • DMX_PES_AUDIO2: third audio PID.
  • DMX_PES_VIDEO2: third video PID.
  • DMX_PES_TELETEXT2: third teletext PID.
  • DMX_PES_SUBTITLE2: third subtitle PID.
  • DMX_PES_PCR2: third Program Clock Reference PID.
  • DMX_PES_AUDIO3: fourth audio PID.
  • DMX_PES_VIDEO3: fourth video PID.
  • DMX_PES_TELETEXT3: fourth teletext PID.
  • DMX_PES_SUBTITLE3: fourth subtitle PID.
  • DMX_PES_PCR3: fourth Program Clock Reference PID.
  • DMX_PES_OTHER: any other PID.

struct dmx_filter #

Specifies a section header filter.

Definition

struct dmx_filter {
    __u8 filter[DMX_FILTER_SIZE];
    __u8 mask[DMX_FILTER_SIZE];
    __u8 mode[DMX_FILTER_SIZE];
};

Members

  • filter: bit array with bits to be matched at the section header.
  • mask: bits that are valid at the filter bit array.
  • mode: mode of match: if bit is zero, it will match if equal (positive match); if bit is one, it will match if the bit is negated.

Note

All arrays in this struct have a size of DMX_FILTER_SIZE (16 bytes).

struct dmx_sct_filter_params #

Specifies a section filter.

Definition

struct dmx_sct_filter_params {
        __u16 pid;
        struct dmx_filter filter;
        __u32 timeout;
        __u32 flags;
    #define DMX_CHECK_CRC       1;
    #define DMX_ONESHOT         2;
    #define DMX_IMMEDIATE_START 4;
};

Members

  • pid: PID to be filtered.
  • filter: section header filter, as defined by struct dmx_filter.
  • timeout: maximum time to filter, in milliseconds.
  • flags: extra flags for the section filter.

Description

Carries the configuration for a MPEG-TS section filter.

The flags can be:

  • DMX_CHECK_CRC - only deliver sections where the CRC check succeeded;
  • DMX_ONESHOT - disable the section filter after one section has been delivered;
  • DMX_IMMEDIATE_START - Start filter immediately without requiring a DMX_START.

struct dmx_pes_filter_params #

Specifies Packetized Elementary Stream (PES) filter parameters.

Definition

struct dmx_pes_filter_params {
    __u16 pid;
    enum dmx_input  input;
    enum dmx_output output;
    enum dmx_ts_pes pes_type;
    __u32 flags;
};

Members

  • pid: PID to be filtered.
  • input: Demux input, as specified by enum dmx_input.
  • output: Demux output, as specified by enum dmx_output.
  • pes_type: Type of the pes filter, as specified by enum dmx_pes_type.
  • flags: Demux PES flags.

struct dmx_stc #

Stores System Time Counter (STC) information.

Definition

struct dmx_stc {
    unsigned int num;
    unsigned int base;
    __u64 stc;
};

Members

  • num: input data: number of the STC, from 0 to N.
  • base: output: divisor for STC to get 90 kHz clock.
  • stc: output: stc in base * 90 kHz units.

enum dmx_buffer_flags #

DMX memory-mapped buffer flags

Constants

  • DMX_BUFFER_FLAG_HAD_CRC32_DISCARD: Indicates that the Kernel discarded one or more frames due to wrong CRC32 checksum.
  • DMX_BUFFER_FLAG_TEI: Indicates that the Kernel has detected a Transport Error indicator (TEI) on a filtered pid.
  • DMX_BUFFER_PKT_COUNTER_MISMATCH: Indicates that the Kernel has detected a packet counter mismatch on a filtered pid.
  • DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED: Indicates that the Kernel has detected one or more frame discontinuity.
  • DMX_BUFFER_FLAG_DISCONTINUITY_INDICATOR: Received at least one packet with a frame discontinuity indicator.

struct dmx_buffer #

dmx buffer info

Definition

struct dmx_buffer {
    __u32 index;
    __u32 bytesused;
    __u32 offset;
    __u32 length;
    __u32 flags;
    __u32 count;
};

Members

  • index: id number of the buffer
  • bytesused: number of bytes occupied by data in the buffer (payload);
  • offset: for buffers with memory == DMX_MEMORY_MMAP; offset from the start of the device memory for this plane, (or a "cookie" that should be passed to mmap() as offset)
  • length: size in bytes of the buffer
  • flags: bit array of buffer flags as defined by enum dmx_buffer_flags. Filled only at DMX_DQBUF.
  • count: monotonic counter for filled buffers. Helps to identify data stream loses. Filled only at DMX_DQBUF.

Description

Contains data exchanged by application and driver using one of the streaming I/O methods.

Please notice that, for DMX_QBUF, only index should be filled. On DMX_DQBUF calls, all fields will be filled by the Kernel.

struct dmx_requestbuffers #

request dmx buffer information

Definition

struct dmx_requestbuffers {
    __u32 count;
    __u32 size;
};

Members

  • count: number of requested buffers,
  • size: size in bytes of the requested buffer

Description

Contains data used for requesting a dmx buffer. All reserved fields must be set to zero.

struct dmx_exportbuffer #

export of dmx buffer as DMABUF file descriptor

Definition

struct dmx_exportbuffer {
    __u32 index;
    __u32 flags;
    __s32 fd;
};

Members

  • index: id number of the buffer
  • flags: flags for newly created file, currently only O_CLOEXEC is supported, refer to manual of open syscall for more details
  • fd: file descriptor associated with DMABUF (set by driver)

Description

Contains data used for exporting a dmx buffer as DMABUF file descriptor. The buffer is identified by a 'cookie' returned by DMX_QUERYBUF (identical to the cookie used to mmap() the buffer to userspace). All reserved fields must be set to zero. The field reserved0 is expected to become a structure 'type' allowing an alternative layout of the structure content. Therefore this field should not be used for any other extensions.

Querying frontend status and statistics

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Once FE_SET_PROPERTY is called, the frontend will run a kernel thread that will periodically check for the tuner lock status and provide statistics about the quality of the signal.

The information about the frontend tuner locking status can be queried using ioctl FE_READ_STATUS.

Signal statistics are provided via ioctl FE_SET_PROPERTY, FE_GET_PROPERTY.

Note

Most statistics require the demodulator to be fully locked (e. g. with FE_HAS_LOCK <fe_status> bit set). See Frontend statistics indicators for more details.

frontend events

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

dvb_frontend_event

frontend events #

struct dvb_frontend_event {
    fe_status_t status;
    struct dvb_frontend_parameters parameters;
};

frontend parameters

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

dvb_frontend_parameters

frontend parameters #

The kind of parameters passed to the frontend device for tuning depend on the kind of hardware you are using.

The struct dvb_frontend_parameters uses a union with specific per-system parameters. However, as newer delivery systems required more data, the structure size weren't enough to fit, and just extending its size would break the existing applications. So, those parameters were replaced by the usage of FE_GET_PROPERTY/FE_SET_PROPERTY ioctl's. The new API is flexible enough to add new parameters to existing delivery systems, and to add newer delivery systems.

So, newer applications should use FE_GET_PROPERTY/FE_SET_PROPERTY instead, in order to be able to support the newer System Delivery like DVB-S2, DVB-T2, DVB-C2, ISDB, etc.

All kinds of parameters are combined as a union in the dvb_frontend_parameters structure:

struct dvb_frontend_parameters {
    uint32_t frequency;     /* (absolute) frequency in Hz for QAM/OFDM */
                /* intermediate frequency in kHz for QPSK */
    fe_spectral_inversion_t inversion;
    union {
        struct dvb_qpsk_parameters qpsk;
        struct dvb_qam_parameters  qam;
        struct dvb_ofdm_parameters ofdm;
        struct dvb_vsb_parameters  vsb;
    } u;
};

In the case of QPSK frontends the frequency field specifies the intermediate frequency, i.e. the offset which is effectively added to the local oscillator frequency (LOF) of the LNB. The intermediate frequency has to be specified in units of kHz. For QAM and OFDM frontends the frequency specifies the absolute frequency and is given in Hz.

dvb_qpsk_parameters

QPSK parameters #

For satellite QPSK frontends you have to use the dvb_qpsk_parameters structure:

struct dvb_qpsk_parameters {
    uint32_t        symbol_rate;  /* symbol rate in Symbols per second */
    fe_code_rate_t  fec_inner;    /* forward error correction (see above) */
};

dvb_qam_parameters

QAM parameters #

for cable QAM frontend you use the dvb_qam_parameters structure:

struct dvb_qam_parameters {
    uint32_t         symbol_rate; /* symbol rate in Symbols per second */
    fe_code_rate_t   fec_inner;   /* forward error correction (see above) */
    fe_modulation_t  modulation;  /* modulation type (see above) */
};

dvb_vsb_parameters

VSB parameters #

ATSC frontends are supported by the dvb_vsb_parameters structure:

struct dvb_vsb_parameters {
    fe_modulation_t modulation; /* modulation type (see above) */
};

dvb_ofdm_parameters

OFDM parameters #

DVB-T frontends are supported by the dvb_ofdm_parameters structure:

struct dvb_ofdm_parameters {
    fe_bandwidth_t      bandwidth;
    fe_code_rate_t      code_rate_HP;  /* high priority stream code rate */
    fe_code_rate_t      code_rate_LP;  /* low priority stream code rate */
    fe_modulation_t     constellation; /* modulation type (see above) */
    fe_transmit_mode_t  transmission_mode;
    fe_guard_interval_t guard_interval;
    fe_hierarchy_t      hierarchy_information;
};

Part II - Digital TV API

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Note

This API is also known as Linux DVB API.

It it was originally written to support the European digital TV standard (DVB), and later extended to support all digital TV standards.

In order to avoid confusion, within this document, it was opted to refer to it, and to associated hardware as Digital TV.

The word DVB is reserved to be used for:

  • the Digital TV API version (e. g. DVB API version 3 or DVB API version 5);

  • digital TV data types (enums, structs, defines, etc);

  • digital TV device nodes (/dev/dvb/...);

  • the European DVB standard.

Version 5.10

Table of Contents

  1. Introduction
  2. Digital TV Frontend API
  3. Digital TV Demux Device
  4. Digital TV CA Device
  5. Digital TV Network API
  6. Digital TV Deprecated APIs
  7. Examples
  8. headers

Revision and Copyright #

Authors:

    • J. - K. Metzler, Ralph <rjkm@metzlerbros.de>
  • Original author of the Digital TV API documentation.
    • O. - C. Metzler, Marcus <rjkm@metzlerbros.de>
  • Original author of the Digital TV API documentation.
  • Carvalho Chehab, Mauro <mchehab+samsung@kernel.org>
  • Ported document to Docbook XML, addition of DVBv5 API, documentation gaps fix.

Copyright © 2002-2003 : Convergence GmbH

Copyright © 2009-2017 : Mauro Carvalho Chehab

Revision History #

revision: 2.2.0 / 2017-09-01 (mcc)

Most gaps between the uAPI document and the Kernel implementation got fixed for the non-legacy API.

revision: 2.1.0 / 2015-05-29 (mcc)

DocBook improvements and cleanups, in order to document the system calls on a more standard way and provide more description about the current Digital TV API.

revision: 2.0.4 / 2011-05-06 (mcc)

Add more information about DVBv5 API, better describing the frontend GET/SET props ioctl's.

revision: 2.0.3 / 2010-07-03 (mcc)

Add some frontend capabilities flags, present on kernel, but missing at the specs.

revision: 2.0.2 / 2009-10-25 (mcc)

documents FE_SET_FRONTEND_TUNE_MODE and FE_DISHETWORK_SEND_LEGACY_CMD ioctls.

revision: 2.0.1 / 2009-09-16 (mcc)

Added ISDB-T test originally written by Patrick Boettcher

revision: 2.0.0 / 2009-09-06 (mcc)

Conversion from LaTex to DocBook XML. The contents is the same as the original LaTex version.

revision: 1.0.0 / 2003-07-24 (rjkm)

Initial revision on LaTEX.

Property types

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Tuning into a Digital TV physical channel and starting decoding it requires changing a set of parameters, in order to control the tuner, the demodulator, the Linear Low-noise Amplifier (LNA) and to set the antenna subsystem via Satellite Equipment Control - SEC (on satellite systems). The actual parameters are specific to each particular digital TV standards, and may change as the digital TV specs evolves.

In the past (up to DVB API version 3 - DVBv3), the strategy used was to have a union with the parameters needed to tune for DVB-S, DVB-C, DVB-T and ATSC delivery systems grouped there. The problem is that, as the second generation standards appeared, the size of such union was not big enough to group the structs that would be required for those new standards. Also, extending it would break userspace.

So, the legacy union/struct based approach was deprecated, in favor of a properties set approach. On such approach, FE_GET_PROPERTY and FE_SET_PROPERTY are used to setup the frontend and read its status.

The actual action is determined by a set of dtv_property cmd/data pairs. With one single ioctl, is possible to get/set up to 64 properties.

This section describes the new and recommended way to set the frontend, with supports all digital TV delivery systems.

Note

  1. On Linux DVB API version 3, setting a frontend was done via struct dvb_frontend_parameters.

  2. Don't use DVB API version 3 calls on hardware with supports newer standards. Such API provides no support or a very limited support to new standards and/or new hardware.

  3. Nowadays, most frontends support multiple delivery systems. Only with DVB API version 5 calls it is possible to switch between the multiple delivery systems supported by a frontend.

  4. DVB API version 5 is also called S2API, as the first new standard added to it was DVB-S2.

Example: in order to set the hardware to tune into a DVB-C channel at 651 kHz, modulated with 256-QAM, FEC 3/4 and symbol rate of 5.217 Mbauds, those properties should be sent to FE_SET_PROPERTY ioctl:

DTV_DELIVERY_SYSTEM = SYS_DVBC_ANNEX_A

DTV_FREQUENCY = 651000000

DTV_MODULATION = QAM_256

DTV_INVERSION = INVERSION_AUTO

DTV_SYMBOL_RATE = 5217000

DTV_INNER_FEC = FEC_3_4

DTV_TUNE

The code that would that would do the above is show in dtv-prop-example.

Example: Setting digital TV frontend properties

#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/dvb/frontend.h>

static struct dtv_property props[] = {
    { .cmd = DTV_DELIVERY_SYSTEM, .u.data = SYS_DVBC_ANNEX_A },
    { .cmd = DTV_FREQUENCY,       .u.data = 651000000 },
    { .cmd = DTV_MODULATION,      .u.data = QAM_256 },
    { .cmd = DTV_INVERSION,       .u.data = INVERSION_AUTO },
    { .cmd = DTV_SYMBOL_RATE,     .u.data = 5217000 },
    { .cmd = DTV_INNER_FEC,       .u.data = FEC_3_4 },
    { .cmd = DTV_TUNE }
};

static struct dtv_properties dtv_prop = {
    .num = 6, .props = props
};

int main(void)
{
    int fd = open("/dev/dvb/adapter0/frontend0", O_RDWR);

    if (!fd) {
        perror ("open");
        return -1;
    }
    if (ioctl(fd, FE_SET_PROPERTY, &dtv_prop) == -1) {
        perror("ioctl");
        return -1;
    }
    printf("Frontend set\\n");
    return 0;
}

Note

While it is possible to directly call the Kernel code like the above example, it is strongly recommended to use libdvbv5, as it provides abstraction to work with the supported digital TV standards and provides methods for usual operations like program scanning and to read/write channel descriptor files.

  • Digital TV property parameters
  • Frontend statistics indicators
  • Properties used on terrestrial delivery systems
  • Properties used on cable delivery systems
  • Properties used on satellite delivery systems
  • Frontend uAPI data types

Examples

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

In the past, we used to have a set of examples here. However, those examples got out of date and doesn't even compile nowadays.

Also, nowadays, the best is to use the libdvbv5 DVB API nowadays, with is fully documented.

Please refer to the libdvbv5 for updated/recommended examples.

Frontend bandwidth

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

fe_bandwidth
enum fe_bandwidth

ID

Description

BANDWIDTH_AUTO

Autodetect bandwidth (if supported)

BANDWIDTH_1_712_MHZ

1.712 MHz

BANDWIDTH_5_MHZ

5 MHz

BANDWIDTH_6_MHZ

6 MHz

BANDWIDTH_7_MHZ

7 MHz

BANDWIDTH_8_MHZ

8 MHz

BANDWIDTH_10_MHZ

10 MHz

ioctl FE_DISEQC_RECV_SLAVE_REPLY

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_DISEQC_RECV_SLAVE_REPLY - Receives reply from a DiSEqC 2.0 command

Synopsis #

FE_DISEQC_RECV_SLAVE_REPLY

int ioctl(int fd, FE_DISEQC_RECV_SLAVE_REPLY, struct dvb_diseqc_slave_reply *argp)

Arguments #

  • fd

    File descriptor returned by open().

  • argp

    pointer to struct dvb_diseqc_slave_reply.

Description #

Receives reply from a DiSEqC 2.0 command.

The received message is stored at the buffer pointed by argp.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

ioctl FE_DISEQC_RESET_OVERLOAD

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_DISEQC_RESET_OVERLOAD - Restores the power to the antenna subsystem, if it was powered off due - to power overload.

Synopsis #

FE_DISEQC_RESET_OVERLOAD

int ioctl(int fd, FE_DISEQC_RESET_OVERLOAD, NULL)

Arguments #

  • fd

    File descriptor returned by open().

Description #

If the bus has been automatically powered off due to power overload, this ioctl call restores the power to the bus. The call requires read/write access to the device. This call has no effect if the device is manually powered off. Not all Digital TV adapters support this ioctl.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

ioctl FE_DISEQC_SEND_BURST

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_DISEQC_SEND_BURST - Sends a 22KHz tone burst for 2x1 mini DiSEqC satellite selection.

Synopsis #

FE_DISEQC_SEND_BURST

int ioctl(int fd, FE_DISEQC_SEND_BURST, enum fe_sec_mini_cmd tone)

Arguments #

  • fd

    File descriptor returned by open().

  • tone

    An integer enumerated value described at fe_sec_mini_cmd.

Description #

This ioctl is used to set the generation of a 22kHz tone burst for mini DiSEqC satellite selection for 2x1 switches. This call requires read/write permissions.

It provides support for what's specified at Digital Satellite Equipment Control (DiSEqC) - Simple "ToneBurst" Detection Circuit specification.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

ioctl FE_DISEQC_SEND_MASTER_CMD

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_DISEQC_SEND_MASTER_CMD - Sends a DiSEqC command

Synopsis #

FE_DISEQC_SEND_MASTER_CMD

int ioctl(int fd, FE_DISEQC_SEND_MASTER_CMD, struct dvb_diseqc_master_cmd *argp)

Arguments #

  • fd

    File descriptor returned by open().

  • argp

    pointer to struct dvb_diseqc_master_cmd

Description #

Sends the DiSEqC command pointed by dvb_diseqc_master_cmd to the antenna subsystem.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

FE_DISHNETWORK_SEND_LEGACY_CMD

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_DISHNETWORK_SEND_LEGACY_CMD

Synopsis #

FE_DISHNETWORK_SEND_LEGACY_CMD

int ioctl(int fd, FE_DISHNETWORK_SEND_LEGACY_CMD, unsigned long cmd)

Arguments #

  • fd

    File descriptor returned by open().

  • cmd

    Sends the specified raw cmd to the dish via DISEqC.

Description #

Warning

This is a very obscure legacy command, used only at stv0299 driver. Should not be used on newer drivers.

It provides a non-standard method for selecting Diseqc voltage on the frontend, for Dish Network legacy switches.

As support for this ioctl were added in 2004, this means that such dishes were already legacy in 2004.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

ioctl FE_ENABLE_HIGH_LNB_VOLTAGE

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_ENABLE_HIGH_LNB_VOLTAGE - Select output DC level between normal LNBf voltages or higher LNBf - voltages.

Synopsis #

FE_ENABLE_HIGH_LNB_VOLTAGE

int ioctl(int fd, FE_ENABLE_HIGH_LNB_VOLTAGE, unsigned int high)

Arguments #

  • fd

    File descriptor returned by open().

  • high

    Valid flags:

    • 0 - normal 13V and 18V.

    • >0 - enables slightly higher voltages instead of 13/18V, in order to compensate for long antenna cables.

Description #

Select output DC level between normal LNBf voltages or higher LNBf voltages between 0 (normal) or a value grater than 0 for higher voltages.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

FE_GET_EVENT

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_GET_EVENT

Note

This ioctl is deprecated.

Synopsis #

FE_GET_EVENT

int ioctl(int fd, FE_GET_EVENT, struct dvb_frontend_event *ev)

Arguments #

  • fd

    File descriptor returned by open().

  • ev

    Points to the location where the event, if any, is to be stored.

Description #

This ioctl call returns a frontend event if available. If an event is not available, the behavior depends on whether the device is in blocking or non-blocking mode. In the latter case, the call fails immediately with errno set to EWOULDBLOCK. In the former case, the call blocks until an event becomes available.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

EWOULDBLOCK

There is no event pending, and the device is in non-blocking mode.

EOVERFLOW

Overflow in event queue - one or more events were lost.

Generic error codes are described at the Generic Error Codes chapter.

FE_GET_FRONTEND

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_GET_FRONTEND

Note

This ioctl is deprecated.

Synopsis #

FE_GET_FRONTEND

int ioctl(int fd, FE_GET_FRONTEND, struct dvb_frontend_parameters *p)

Arguments #

  • fd

    File descriptor returned by open().

  • p

    Points to parameters for tuning operation.

Description #

This ioctl call queries the currently effective frontend parameters. For this command, read-only access to the device is sufficient.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

EINVAL

Maximum supported symbol rate reached.

Generic error codes are described at the Generic Error Codes chapter.

ioctl FE_GET_INFO

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_GET_INFO - Query Digital TV frontend capabilities and returns information about the - front-end. This call only requires read-only access to the device.

Synopsis #

FE_GET_INFO

int ioctl(int fd, FE_GET_INFO, struct dvb_frontend_info *argp)

Arguments #

  • fd

    File descriptor returned by open().

  • argp

    pointer to struct dvb_frontend_info

Description #

All Digital TV frontend devices support the ioctl FE_GET_INFO ioctl. It is used to identify kernel devices compatible with this specification and to obtain information about driver and hardware capabilities. The ioctl takes a pointer to dvb_frontend_info which is filled by the driver. When the driver is not compatible with this specification the ioctl returns an error.

frontend capabilities #

Capabilities describe what a frontend can do. Some capabilities are supported only on some specific frontend types.

The frontend capabilities are described at fe_caps.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

ioctl FE_SET_PROPERTY, FE_GET_PROPERTY

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_SET_PROPERTY - FE_GET_PROPERTY - FE_SET_PROPERTY sets one or more frontend properties. - FE_GET_PROPERTY returns one or more frontend properties.

Synopsis #

FE_GET_PROPERTY

int ioctl(int fd, FE_GET_PROPERTY, struct dtv_properties *argp)

FE_SET_PROPERTY

int ioctl(int fd, FE_SET_PROPERTY, struct dtv_properties *argp)

Arguments #

  • fd

    File descriptor returned by open().

  • argp

    Pointer to struct dtv_properties.

Description #

All Digital TV frontend devices support the FE_SET_PROPERTY and FE_GET_PROPERTY ioctls. The supported properties and statistics depends on the delivery system and on the device:

  • FE_SET_PROPERTY:

    • This ioctl is used to set one or more frontend properties.

    • This is the basic command to request the frontend to tune into some frequency and to start decoding the digital TV signal.

    • This call requires read/write access to the device.

Note

At return, the values aren't updated to reflect the actual parameters used. If the actual parameters are needed, an explicit call to FE_GET_PROPERTY is needed.

  • FE_GET_PROPERTY:

    • This ioctl is used to get properties and statistics from the frontend.

    • No properties are changed, and statistics aren't reset.

    • This call only requires read-only access to the device.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

FE_READ_BER

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_READ_BER

Note

This ioctl is deprecated.

Synopsis #

FE_READ_BER

int ioctl(int fd, FE_READ_BER, uint32_t *ber)

Arguments #

  • fd

    File descriptor returned by open().

  • ber

    The bit error rate is stored into *ber.

Description #

This ioctl call returns the bit error rate for the signal currently received/demodulated by the front-end. For this command, read-only access to the device is sufficient.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

FE_READ_SIGNAL_STRENGTH

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_READ_SIGNAL_STRENGTH

Note

This ioctl is deprecated.

Synopsis #

FE_READ_SIGNAL_STRENGTH

int ioctl(int fd, FE_READ_SIGNAL_STRENGTH, uint16_t *strength)

Arguments #

  • fd

    File descriptor returned by open().

  • strength

    The signal strength value is stored into *strength.

Description #

This ioctl call returns the signal strength value for the signal currently received by the front-end. For this command, read-only access to the device is sufficient.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

FE_READ_SNR

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_READ_SNR

Note

This ioctl is deprecated.

Synopsis #

FE_READ_SNR

int ioctl(int fd, FE_READ_SNR, int16_t *snr)

Arguments #

  • fd

    File descriptor returned by open().

  • snr

    The signal-to-noise ratio is stored into *snr.

Description #

This ioctl call returns the signal-to-noise ratio for the signal currently received by the front-end. For this command, read-only access to the device is sufficient.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

ioctl FE_READ_STATUS

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_READ_STATUS - Returns status information about the front-end. This call only requires - read-only access to the device

Synopsis #

FE_READ_STATUS

int ioctl(int fd, FE_READ_STATUS, unsigned int *status)

Arguments #

  • fd

    File descriptor returned by open().

  • status

    pointer to a bitmask integer filled with the values defined by enum fe_status.

Description #

All Digital TV frontend devices support the FE_READ_STATUS ioctl. It is used to check about the locking status of the frontend after being tuned. The ioctl takes a pointer to an integer where the status will be written.

Note

The size of status is actually sizeof(enum fe_status), with varies according with the architecture. This needs to be fixed in the future.

int fe_status #

The fe_status parameter is used to indicate the current state and/or state changes of the frontend hardware. It is produced using the enum fe_status values on a bitmask

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

FE_READ_UNCORRECTED_BLOCKS

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_READ_UNCORRECTED_BLOCKS

Note

This ioctl is deprecated.

Synopsis #

FE_READ_UNCORRECTED_BLOCKS

int ioctl(int fd, FE_READ_UNCORRECTED_BLOCKS, uint32_t *ublocks)

Arguments #

  • fd

    File descriptor returned by open().

  • ublocks

    The total number of uncorrected blocks seen by the driver so far.

Description #

This ioctl call returns the number of uncorrected blocks detected by the device driver during its lifetime. For meaningful measurements, the increment in block count during a specific time interval should be calculated. For this command, read-only access to the device is sufficient.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

ioctl FE_SET_FRONTEND_TUNE_MODE

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_SET_FRONTEND_TUNE_MODE - Allow setting tuner mode flags to the frontend.

Synopsis #

FE_SET_FRONTEND_TUNE_MODE

int ioctl(int fd, FE_SET_FRONTEND_TUNE_MODE, unsigned int flags)

Arguments #

  • fd

    File descriptor returned by open().

  • flags

    Valid flags:

    • 0 - normal tune mode

    • FE_TUNE_MODE_ONESHOT - When set, this flag will disable any zigzagging or other "normal" tuning behaviour. Additionally, there will be no automatic monitoring of the lock status, and hence no frontend events will be generated. If a frontend device is closed, this flag will be automatically turned off when the device is reopened read-write.

Description #

Allow setting tuner mode flags to the frontend, between 0 (normal) or FE_TUNE_MODE_ONESHOT mode

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

FE_SET_FRONTEND

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Note

This ioctl is deprecated.

Name #

FE_SET_FRONTEND

Synopsis #

FE_SET_FRONTEND

int ioctl(int fd, FE_SET_FRONTEND, struct dvb_frontend_parameters *p)

Arguments #

  • fd

    File descriptor returned by open().

  • p

    Points to parameters for tuning operation.

Description #

This ioctl call starts a tuning operation using specified parameters. The result of this call will be successful if the parameters were valid and the tuning could be initiated. The result of the tuning operation in itself, however, will arrive asynchronously as an event (see documentation for FE_GET_EVENT and FrontendEvent.) If a new FE_SET_FRONTEND operation is initiated before the previous one was completed, the previous operation will be aborted in favor of the new one. This command requires read/write access to the device.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

EINVAL

Maximum supported symbol rate reached.

Generic error codes are described at the Generic Error Codes chapter.

ioctl FE_SET_TONE

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_SET_TONE - Sets/resets the generation of the continuous 22kHz tone.

Synopsis #

FE_SET_TONE

int ioctl(int fd, FE_SET_TONE, enum fe_sec_tone_mode tone)

Arguments #

  • fd

    File descriptor returned by open().

  • tone

    An integer enumerated value described at fe_sec_tone_mode

Description #

This ioctl is used to set the generation of the continuous 22kHz tone. This call requires read/write permissions.

Usually, satellite antenna subsystems require that the digital TV device to send a 22kHz tone in order to select between high/low band on some dual-band LNBf. It is also used to send signals to DiSEqC equipment, but this is done using the DiSEqC ioctls.

Note

If more than one device is connected to the same antenna, setting a tone may interfere on other devices, as they may lose the capability of selecting the band. So, it is recommended that applications would change to SEC_TONE_OFF when the device is not used.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

ioctl FE_SET_VOLTAGE

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

FE_SET_VOLTAGE - Allow setting the DC level sent to the antenna subsystem.

Synopsis #

FE_SET_VOLTAGE

int ioctl(int fd, FE_SET_VOLTAGE, enum fe_sec_voltage voltage)

Arguments #

  • fd

    File descriptor returned by open().

  • voltage

    An integer enumerated value described at fe_sec_voltage

Description #

This ioctl allows to set the DC voltage level sent through the antenna cable to 13V, 18V or off.

Usually, a satellite antenna subsystems require that the digital TV device to send a DC voltage to feed power to the LNBf. Depending on the LNBf type, the polarization or the intermediate frequency (IF) of the LNBf can controlled by the voltage level. Other devices (for example, the ones that implement DISEqC and multipoint LNBf's don't need to control the voltage level, provided that either 13V or 18V is sent to power up the LNBf.

Note

if more than one device is connected to the same antenna, setting a voltage level may interfere on other devices, as they may lose the capability of setting polarization or IF. So, on those cases, setting the voltage to SEC_VOLTAGE_OFF while the device is not is used is recommended.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

Frontend type

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

For historical reasons, frontend types are named by the type of modulation used in transmission. The fontend types are given by fe_type_t type, defined as:

fe_type
Frontend types

fe_type

Description

DTV_DELIVERY_SYSTEM equivalent type

FE_QPSK

For DVB-S standard

SYS_DVBS

FE_QAM

For DVB-C annex A standard

SYS_DVBC_ANNEX_A

FE_OFDM

For DVB-T standard

SYS_DVBT

FE_ATSC

For ATSC standard (terrestrial) or for DVB-C Annex B (cable) used in US.

SYS_ATSC (terrestrial) or SYS_DVBC_ANNEX_B (cable)

Newer formats like DVB-S2, ISDB-T, ISDB-S and DVB-T2 are not described at the above, as they're supported via the new FE_GET_PROPERTY/FE_GET_SET_PROPERTY ioctl's, using the DTV_DELIVERY_SYSTEM parameter.

In the old days, struct dvb_frontend_info used to contain fe_type_t field to indicate the delivery systems, filled with either FE_QPSK, FE_QAM, FE_OFDM or FE_ATSC. While this is still filled to keep backward compatibility, the usage of this field is deprecated, as it can report just one delivery system, but some devices support multiple delivery systems. Please use DTV_ENUM_DELSYS instead.

On devices that support multiple delivery systems, struct dvb_frontend_info::fe_type_t is filled with the currently standard, as selected by the last call to FE_SET_PROPERTY using the DTV_DELIVERY_SYSTEM property.

Digital TV property parameters

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

There are several different Digital TV parameters that can be used by FE_SET_PROPERTY and FE_GET_PROPERTY ioctls. This section describes each of them. Please notice, however, that only a subset of them are needed to setup a frontend.

DTV_UNDEFINED #

Used internally. A GET/SET operation for it won't change or return anything.

DTV_TUNE #

Interpret the cache of data, build either a traditional frontend tunerequest so we can pass validation in the FE_SET_FRONTEND ioctl.

DTV_CLEAR #

Reset a cache of data specific to the frontend here. This does not effect hardware.

DTV_FREQUENCY #

Frequency of the digital TV transponder/channel.

Note

  1. For satellite delivery systems, the frequency is in kHz.

  2. For cable and terrestrial delivery systems, the frequency is in Hz.

  3. On most delivery systems, the frequency is the center frequency of the transponder/channel. The exception is for ISDB-T, where the main carrier has a 1/7 offset from the center.

  4. For ISDB-T, the channels are usually transmitted with an offset of about 143kHz. E.g. a valid frequency could be 474,143 kHz. The stepping is bound to the bandwidth of the channel which is typically 6MHz.

  5. In ISDB-Tsb, the channel consists of only one or three segments the frequency step is 429kHz, 3*429 respectively.

DTV_MODULATION #

Specifies the frontend modulation type for delivery systems that support multiple modulations.

The modulation can be one of the types defined by enum fe_modulation.

Most of the digital TV standards offer more than one possible modulation type.

The table below presents a summary of the types of modulation types supported by each delivery system, as currently defined by specs.

Standard

Modulation types

ATSC (version 1)

8-VSB and 16-VSB.

DMTB

4-QAM, 16-QAM, 32-QAM, 64-QAM and 4-QAM-NR.

DVB-C Annex A/C

16-QAM, 32-QAM, 64-QAM and 256-QAM.

DVB-C Annex B

64-QAM.

DVB-C2

QPSK, 16-QAM, 64-QAM, 256-QAM, 1024-QAM and 4096-QAM.

DVB-T

QPSK, 16-QAM and 64-QAM.

DVB-T2

QPSK, 16-QAM, 64-QAM and 256-QAM.

DVB-S

No need to set. It supports only QPSK.

DVB-S2

QPSK, 8-PSK, 16-APSK and 32-APSK.

DVB-S2X

8-APSK-L, 16-APSK-L, 32-APSK-L, 64-APSK and 64-APSK-L.

ISDB-T

QPSK, DQPSK, 16-QAM and 64-QAM.

ISDB-S

8-PSK, QPSK and BPSK.

Note

As DVB-S2X specifies extensions to the DVB-S2 standard, the same delivery system enum value is used (SYS_DVBS2).

Please notice that some of the above modulation types may not be defined currently at the Kernel. The reason is simple: no driver needed such definition yet.

DTV_BANDWIDTH_HZ #

Bandwidth for the channel, in HZ.

Should be set only for terrestrial delivery systems.

Possible values: 1712000, 5000000, 6000000, 7000000, 8000000, 10000000.

Terrestrial Standard

Possible values for bandwidth

ATSC (version 1)

No need to set. It is always 6MHz.

DMTB

No need to set. It is always 8MHz.

DVB-T

6MHz, 7MHz and 8MHz.

DVB-T2

1.172 MHz, 5MHz, 6MHz, 7MHz, 8MHz and 10MHz

ISDB-T

5MHz, 6MHz, 7MHz and 8MHz, although most places use 6MHz.

Note

  1. For ISDB-Tsb, the bandwidth can vary depending on the number of connected segments.

    It can be easily derived from other parameters (DTV_ISDBT_SB_SEGMENT_IDX, DTV_ISDBT_SB_SEGMENT_COUNT).

  2. On Satellite and Cable delivery systems, the bandwidth depends on the symbol rate. The kernel will silently ignore any DTV_BANDWIDTH_HZ setting and overwrites it with bandwidth estimation.

    Such bandwidth estimation takes into account the symbol rate set with DTV_SYMBOL_RATE, and the rolloff factor, with is fixed for DVB-C and DVB-S.

    For DVB-S2, the rolloff should also be set via DTV_ROLLOFF.

DTV_INVERSION #

Specifies if the frontend should do spectral inversion or not.

The acceptable values are defined by fe_spectral_inversion.

DTV_DISEQC_MASTER #

Currently not implemented.

DTV_SYMBOL_RATE #

Used on cable and satellite delivery systems.

Digital TV symbol rate, in bauds (symbols/second).

DTV_INNER_FEC #

Used on cable and satellite delivery systems.

The acceptable values are defined by fe_code_rate.

DTV_VOLTAGE #

Used on satellite delivery systems.

The voltage is usually used with non-DiSEqC capable LNBs to switch the polarization (horizontal/vertical). When using DiSEqC equipment this voltage has to be switched consistently to the DiSEqC commands as described in the DiSEqC spec.

The acceptable values are defined by fe_sec_voltage.

DTV_TONE #

Currently not used.

DTV_PILOT #

Used on DVB-S2.

Sets DVB-S2 pilot.

The acceptable values are defined by fe_pilot.

DTV_ROLLOFF #

Used on DVB-S2.

Sets DVB-S2 rolloff.

The acceptable values are defined by fe_rolloff.

DTV_DISEQC_SLAVE_REPLY #

Currently not implemented.

DTV_FE_CAPABILITY_COUNT #

Currently not implemented.

DTV_FE_CAPABILITY #

Currently not implemented.

DTV_DELIVERY_SYSTEM #

Specifies the type of the delivery system.

The acceptable values are defined by fe_delivery_system.

DTV_ISDBT_PARTIAL_RECEPTION #

Used only on ISDB.

If DTV_ISDBT_SOUND_BROADCASTING is '0' this bit field represents whether the channel is in partial reception mode or not.

If '1' DTV_ISDBT_LAYERA_* values are assigned to the center segment and DTV_ISDBT_LAYERA_SEGMENT_COUNT has to be '1'.

If in addition DTV_ISDBT_SOUND_BROADCASTING is '1' DTV_ISDBT_PARTIAL_RECEPTION represents whether this ISDB-Tsb channel is consisting of one segment and layer or three segments and two layers.

Possible values: 0, 1, -1 (AUTO)

DTV_ISDBT_SOUND_BROADCASTING #

Used only on ISDB.

This field represents whether the other DTV_ISDBT_*-parameters are referring to an ISDB-T and an ISDB-Tsb channel. (See also DTV_ISDBT_PARTIAL_RECEPTION).

Possible values: 0, 1, -1 (AUTO)

DTV_ISDBT_SB_SUBCHANNEL_ID #

Used only on ISDB.

This field only applies if DTV_ISDBT_SOUND_BROADCASTING is '1'.

(Note of the author: This might not be the correct description of the SUBCHANNEL-ID in all details, but it is my understanding of the technical background needed to program a device)

An ISDB-Tsb channel (1 or 3 segments) can be broadcasted alone or in a set of connected ISDB-Tsb channels. In this set of channels every channel can be received independently. The number of connected ISDB-Tsb segment can vary, e.g. depending on the frequency spectrum bandwidth available.

Example: Assume 8 ISDB-Tsb connected segments are broadcasted. The broadcaster has several possibilities to put those channels in the air: Assuming a normal 13-segment ISDB-T spectrum he can align the 8 segments from position 1-8 to 5-13 or anything in between.

The underlying layer of segments are sub-channels: each segment is consisting of several sub-channels with a predefined IDs. A sub-channel is used to help the demodulator to synchronize on the channel.

An ISDB-T channel is always centered over all sub-channels. As for the example above, in ISDB-Tsb it is no longer as simple as that.

The DTV_ISDBT_SB_SUBCHANNEL_ID parameter is used to give the sub-channel ID of the segment to be demodulated.

Possible values: 0 .. 41, -1 (AUTO)

DTV_ISDBT_SB_SEGMENT_IDX #

Used only on ISDB.

This field only applies if DTV_ISDBT_SOUND_BROADCASTING is '1'.

DTV_ISDBT_SB_SEGMENT_IDX gives the index of the segment to be demodulated for an ISDB-Tsb channel where several of them are transmitted in the connected manner.

Possible values: 0 .. DTV_ISDBT_SB_SEGMENT_COUNT - 1

Note: This value cannot be determined by an automatic channel search.

DTV_ISDBT_SB_SEGMENT_COUNT #

Used only on ISDB.

This field only applies if DTV_ISDBT_SOUND_BROADCASTING is '1'.

DTV_ISDBT_SB_SEGMENT_COUNT gives the total count of connected ISDB-Tsb channels.

Possible values: 1 .. 13

Note: This value cannot be determined by an automatic channel search.

DTV-ISDBT-LAYER[A-C] parameters #

Used only on ISDB.

ISDB-T channels can be coded hierarchically. As opposed to DVB-T in ISDB-T hierarchical layers can be decoded simultaneously. For that reason a ISDB-T demodulator has 3 Viterbi and 3 Reed-Solomon decoders.

ISDB-T has 3 hierarchical layers which each can use a part of the available segments. The total number of segments over all layers has to 13 in ISDB-T.

There are 3 parameter sets, for Layers A, B and C.

DTV_ISDBT_LAYER_ENABLED #

Used only on ISDB.

Hierarchical reception in ISDB-T is achieved by enabling or disabling layers in the decoding process. Setting all bits of DTV_ISDBT_LAYER_ENABLED to '1' forces all layers (if applicable) to be demodulated. This is the default.

If the channel is in the partial reception mode (DTV_ISDBT_PARTIAL_RECEPTION = 1) the central segment can be decoded independently of the other 12 segments. In that mode layer A has to have a SEGMENT_COUNT of 1.

In ISDB-Tsb only layer A is used, it can be 1 or 3 in ISDB-Tsb according to DTV_ISDBT_PARTIAL_RECEPTION. SEGMENT_COUNT must be filled accordingly.

Only the values of the first 3 bits are used. Other bits will be silently ignored:

DTV_ISDBT_LAYER_ENABLED bit 0: layer A enabled

DTV_ISDBT_LAYER_ENABLED bit 1: layer B enabled

DTV_ISDBT_LAYER_ENABLED bit 2: layer C enabled

DTV_ISDBT_LAYER_ENABLED bits 3-31: unused

DTV_ISDBT_LAYER[A-C]_FEC #

Used only on ISDB.

The Forward Error Correction mechanism used by a given ISDB Layer, as defined by fe_code_rate.

Possible values are: FEC_AUTO, FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_7_8

DTV_ISDBT_LAYER[A-C]_MODULATION #

Used only on ISDB.

The modulation used by a given ISDB Layer, as defined by fe_modulation.

Possible values are: QAM_AUTO, QPSK, QAM_16, QAM_64, DQPSK

Note

  1. If layer C is DQPSK, then layer B has to be DQPSK.

  2. If layer B is DQPSK and DTV_ISDBT_PARTIAL_RECEPTION= 0, then layer has to be DQPSK.

DTV_ISDBT_LAYER[A-C]_SEGMENT_COUNT #

Used only on ISDB.

Possible values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1 (AUTO)

Note: Truth table for DTV_ISDBT_SOUND_BROADCASTING and DTV_ISDBT_PARTIAL_RECEPTION and LAYER[A-C]_SEGMENT_COUNT

Truth table for ISDB-T Sound Broadcasting

Partial Reception

Sound Broadcasting

Layer A width

Layer B width

Layer C width

total width

0

0

1 .. 13

1 .. 13

1 .. 13

13

1

0

1

1 .. 13

1 .. 13

13

0

1

1

0

0

1

1

1

1

2

0

13

DTV_ISDBT_LAYER[A-C]_TIME_INTERLEAVING #

Used only on ISDB.

Valid values: 0, 1, 2, 4, -1 (AUTO)

when DTV_ISDBT_SOUND_BROADCASTING is active, value 8 is also valid.

Note: The real time interleaving length depends on the mode (fft-size). The values here are referring to what can be found in the TMCC-structure, as shown in the table below.

isdbt_layer_interleaving_table
ISDB-T time interleaving modes

DTV_ISDBT_LAYER[A-C]_TIME_INTERLEAVING

Mode 1 (2K FFT)

Mode 2 (4K FFT)

Mode 3 (8K FFT)

0

0

0

0

1

4

2

1

2

8

4

2

4

16

8

4

DTV_ATSCMH_FIC_VER #

Used only on ATSC-MH.

Version number of the FIC (Fast Information Channel) signaling data.

FIC is used for relaying information to allow rapid service acquisition by the receiver.

Possible values: 0, 1, 2, 3, ..., 30, 31

DTV_ATSCMH_PARADE_ID #

Used only on ATSC-MH.

Parade identification number

A parade is a collection of up to eight MH groups, conveying one or two ensembles.

Possible values: 0, 1, 2, 3, ..., 126, 127

DTV_ATSCMH_NOG #

Used only on ATSC-MH.

Number of MH groups per MH subframe for a designated parade.

Possible values: 1, 2, 3, 4, 5, 6, 7, 8

DTV_ATSCMH_TNOG #

Used only on ATSC-MH.

Total number of MH groups including all MH groups belonging to all MH parades in one MH subframe.

Possible values: 0, 1, 2, 3, ..., 30, 31

DTV_ATSCMH_SGN #

Used only on ATSC-MH.

Start group number.

Possible values: 0, 1, 2, 3, ..., 14, 15

DTV_ATSCMH_PRC #

Used only on ATSC-MH.

Parade repetition cycle.

Possible values: 1, 2, 3, 4, 5, 6, 7, 8

DTV_ATSCMH_RS_FRAME_MODE #

Used only on ATSC-MH.

Reed Solomon (RS) frame mode.

The acceptable values are defined by atscmh_rs_frame_mode.

DTV_ATSCMH_RS_FRAME_ENSEMBLE #

Used only on ATSC-MH.

Reed Solomon (RS) frame ensemble.

The acceptable values are defined by atscmh_rs_frame_ensemble.

DTV_ATSCMH_RS_CODE_MODE_PRI #

Used only on ATSC-MH.

Reed Solomon (RS) code mode (primary).

The acceptable values are defined by atscmh_rs_code_mode.

DTV_ATSCMH_RS_CODE_MODE_SEC #

Used only on ATSC-MH.

Reed Solomon (RS) code mode (secondary).

The acceptable values are defined by atscmh_rs_code_mode.

DTV_ATSCMH_SCCC_BLOCK_MODE #

Used only on ATSC-MH.

Series Concatenated Convolutional Code Block Mode.

The acceptable values are defined by atscmh_sccc_block_mode.

DTV_ATSCMH_SCCC_CODE_MODE_A #

Used only on ATSC-MH.

Series Concatenated Convolutional Code Rate.

The acceptable values are defined by atscmh_sccc_code_mode.

DTV_ATSCMH_SCCC_CODE_MODE_B #

Used only on ATSC-MH.

Series Concatenated Convolutional Code Rate.

Possible values are the same as documented on enum atscmh_sccc_code_mode.

DTV_ATSCMH_SCCC_CODE_MODE_C #

Used only on ATSC-MH.

Series Concatenated Convolutional Code Rate.

Possible values are the same as documented on enum atscmh_sccc_code_mode.

DTV_ATSCMH_SCCC_CODE_MODE_D #

Used only on ATSC-MH.

Series Concatenated Convolutional Code Rate.

Possible values are the same as documented on enum atscmh_sccc_code_mode.

DTV_API_VERSION #

Returns the major/minor version of the Digital TV API

DTV_CODE_RATE_HP #

Used on terrestrial transmissions.

The acceptable values are defined by fe_transmit_mode.

DTV_CODE_RATE_LP #

Used on terrestrial transmissions.

The acceptable values are defined by fe_transmit_mode.

DTV_GUARD_INTERVAL #

The acceptable values are defined by fe_guard_interval.

Note

  1. If DTV_GUARD_INTERVAL is set the GUARD_INTERVAL_AUTO the hardware will try to find the correct guard interval (if capable) and will use TMCC to fill in the missing parameters.

  2. Interval GUARD_INTERVAL_1_64 is used only for DVB-C2.

  3. Interval GUARD_INTERVAL_1_128 is used for both DVB-C2 and DVB_T2.

  4. Intervals GUARD_INTERVAL_19_128 and GUARD_INTERVAL_19_256 are used only for DVB-T2.

  5. Intervals GUARD_INTERVAL_PN420, GUARD_INTERVAL_PN595 and GUARD_INTERVAL_PN945 are used only for DMTB at the present. On such standard, only those intervals and GUARD_INTERVAL_AUTO are valid.

DTV_TRANSMISSION_MODE #

Used only on OFTM-based standards, e. g. DVB-T/T2, ISDB-T, DTMB.

Specifies the FFT size (with corresponds to the approximate number of carriers) used by the standard.

The acceptable values are defined by fe_transmit_mode.

Note

  1. ISDB-T supports three carrier/symbol-size: 8K, 4K, 2K. It is called mode on such standard, and are numbered from 1 to 3:

    Mode

    FFT size

    Transmission mode

    1

    2K

    TRANSMISSION_MODE_2K

    2

    4K

    TRANSMISSION_MODE_4K

    3

    8K

    TRANSMISSION_MODE_8K

  2. If DTV_TRANSMISSION_MODE is set the TRANSMISSION_MODE_AUTO the hardware will try to find the correct FFT-size (if capable) and will use TMCC to fill in the missing parameters.

  3. DVB-T specifies 2K and 8K as valid sizes.

  4. DVB-T2 specifies 1K, 2K, 4K, 8K, 16K and 32K.

  5. DTMB specifies C1 and C3780.

DTV_HIERARCHY #

Used only on DVB-T and DVB-T2.

Frontend hierarchy.

The acceptable values are defined by fe_hierarchy.

DTV_STREAM_ID #

Used on DVB-C2, DVB-S2, DVB-T2 and ISDB-S.

DVB-C2, DVB-S2, DVB-T2 and ISDB-S support the transmission of several streams on a single transport stream. This property enables the digital TV driver to handle substream filtering, when supported by the hardware. By default, substream filtering is disabled.

For DVB-C2, DVB-S2 and DVB-T2, the valid substream id range is from 0 to 255.

For ISDB, the valid substream id range is from 1 to 65535.

To disable it, you should use the special macro NO_STREAM_ID_FILTER.

Note: any value outside the id range also disables filtering.

DTV_DVBT2_PLP_ID_LEGACY #

Obsolete, replaced with DTV_STREAM_ID.

DTV_ENUM_DELSYS #

A Multi standard frontend needs to advertise the delivery systems provided. Applications need to enumerate the provided delivery systems, before using any other operation with the frontend. Prior to its introduction, FE_GET_INFO was used to determine a frontend type. A frontend which provides more than a single delivery system, FE_GET_INFO doesn't help much. Applications which intends to use a multistandard frontend must enumerate the delivery systems associated with it, rather than trying to use FE_GET_INFO. In the case of a legacy frontend, the result is just the same as with FE_GET_INFO, but in a more structured format.

The acceptable values are defined by fe_delivery_system.

DTV_INTERLEAVING #

Time interleaving to be used.

The acceptable values are defined by fe_interleaving.

DTV_LNA #

Low-noise amplifier.

Hardware might offer controllable LNA which can be set manually using that parameter. Usually LNA could be found only from terrestrial devices if at all.

Possible values: 0, 1, LNA_AUTO

0, LNA off

1, LNA on

use the special macro LNA_AUTO to set LNA auto

DTV_SCRAMBLING_SEQUENCE_INDEX #

Used on DVB-S2.

This 18 bit field, when present, carries the index of the DVB-S2 physical layer scrambling sequence as defined in clause 5.5.4 of EN 302 307. There is no explicit signalling method to convey scrambling sequence index to the receiver. If S2 satellite delivery system descriptor is available it can be used to read the scrambling sequence index (EN 300 468 table 41).

By default, gold scrambling sequence index 0 is used.

The valid scrambling sequence index range is from 0 to 262142.

Frontend uAPI data types

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

enum fe_caps #

Frontend capabilities

Constants

  • FE_IS_STUPID: There's something wrong at the frontend, and it can't report its capabilities.
  • FE_CAN_INVERSION_AUTO: Can auto-detect frequency spectral band inversion
  • FE_CAN_FEC_1_2: Supports FEC 1/2
  • FE_CAN_FEC_2_3: Supports FEC 2/3
  • FE_CAN_FEC_3_4: Supports FEC 3/4
  • FE_CAN_FEC_4_5: Supports FEC 4/5
  • FE_CAN_FEC_5_6: Supports FEC 5/6
  • FE_CAN_FEC_6_7: Supports FEC 6/7
  • FE_CAN_FEC_7_8: Supports FEC 7/8
  • FE_CAN_FEC_8_9: Supports FEC 8/9
  • FE_CAN_FEC_AUTO: Can auto-detect FEC
  • FE_CAN_QPSK: Supports QPSK modulation
  • FE_CAN_QAM_16: Supports 16-QAM modulation
  • FE_CAN_QAM_32: Supports 32-QAM modulation
  • FE_CAN_QAM_64: Supports 64-QAM modulation
  • FE_CAN_QAM_128: Supports 128-QAM modulation
  • FE_CAN_QAM_256: Supports 256-QAM modulation
  • FE_CAN_QAM_AUTO: Can auto-detect QAM modulation
  • FE_CAN_TRANSMISSION_MODE_AUTO: Can auto-detect transmission mode
  • FE_CAN_BANDWIDTH_AUTO: Can auto-detect bandwidth
  • FE_CAN_GUARD_INTERVAL_AUTO: Can auto-detect guard interval
  • FE_CAN_HIERARCHY_AUTO: Can auto-detect hierarchy
  • FE_CAN_8VSB: Supports 8-VSB modulation
  • FE_CAN_16VSB: Supporta 16-VSB modulation
  • FE_HAS_EXTENDED_CAPS: Unused
  • FE_CAN_MULTISTREAM: Supports multistream filtering
  • FE_CAN_TURBO_FEC: Supports "turbo FEC" modulation
  • FE_CAN_2G_MODULATION: Supports "2nd generation" modulation, e. g. DVB-S2, DVB-T2, DVB-C2
  • FE_NEEDS_BENDING: Unused
  • FE_CAN_RECOVER: Can recover from a cable unplug automatically
  • FE_CAN_MUTE_TS: Can stop spurious TS data output

struct dvb_frontend_info #

Frontend properties and capabilities

Definition

struct dvb_frontend_info {
    char name[128];
    enum fe_type type;
    __u32 frequency_min;
    __u32 frequency_max;
    __u32 frequency_stepsize;
    __u32 frequency_tolerance;
    __u32 symbol_rate_min;
    __u32 symbol_rate_max;
    __u32 symbol_rate_tolerance;
    __u32 notifier_delay;
    enum fe_caps caps;
};

Members

  • name: Name of the frontend

  • type:

    DEPRECATED. Should not be used on modern programs, as a frontend may have more than one type. In order to get the support types of a given frontend, use DTV_ENUM_DELSYS instead.

  • frequency_min: Minimal frequency supported by the frontend.

  • frequency_max: Minimal frequency supported by the frontend.

  • frequency_stepsize: All frequencies are multiple of this value.

  • frequency_tolerance: Frequency tolerance.

  • symbol_rate_min: Minimal symbol rate, in bauds (for Cable/Satellite systems).

  • symbol_rate_max: Maximal symbol rate, in bauds (for Cable/Satellite systems).

  • symbol_rate_tolerance: Maximal symbol rate tolerance, in ppm (for Cable/Satellite systems).

  • notifier_delay:

    DEPRECATED. Not used by any driver.

  • caps: Capabilities supported by the frontend, as specified in enum fe_caps.

Description

struct dvb_diseqc_master_cmd #

DiSEqC master command

Definition

struct dvb_diseqc_master_cmd {
    __u8 msg[6];
    __u8 msg_len;
};

Members

  • msg: DiSEqC message to be sent. It contains a 3 bytes header with: framing + address + command, and an optional argument of up to 3 bytes of data.
  • msg_len: Length of the DiSEqC message. Valid values are 3 to 6.

Description

Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for the possible messages that can be used.

struct dvb_diseqc_slave_reply #

DiSEqC received data

Definition

struct dvb_diseqc_slave_reply {
    __u8 msg[4];
    __u8 msg_len;
    int timeout;
};

Members

  • msg: DiSEqC message buffer to store a message received via DiSEqC. It contains one byte header with: framing and an optional argument of up to 3 bytes of data.
  • msg_len: Length of the DiSEqC message. Valid values are 0 to 4, where 0 means no message.
  • timeout: Return from ioctl after timeout ms with errorcode when no message was received.

Description

Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for the possible messages that can be used.

enum fe_sec_voltage #

DC Voltage used to feed the LNBf

Constants

  • SEC_VOLTAGE_13: Output 13V to the LNBf
  • SEC_VOLTAGE_18: Output 18V to the LNBf
  • SEC_VOLTAGE_OFF: Don't feed the LNBf with a DC voltage

enum fe_sec_tone_mode #

Type of tone to be send to the LNBf.

Constants

  • SEC_TONE_ON: Sends a 22kHz tone burst to the antenna.
  • SEC_TONE_OFF: Don't send a 22kHz tone to the antenna (except if the FE_DISEQC_* ioctls are called).

enum fe_sec_mini_cmd #

Type of mini burst to be sent

Constants

  • SEC_MINI_A: Sends a mini-DiSEqC 22kHz '0' Tone Burst to select satellite-A
  • SEC_MINI_B: Sends a mini-DiSEqC 22kHz '1' Data Burst to select satellite-B

enum fe_status #

Enumerates the possible frontend status.

Constants

  • FE_NONE: The frontend doesn't have any kind of lock. That's the initial frontend status
  • FE_HAS_SIGNAL: Has found something above the noise level.
  • FE_HAS_CARRIER: Has found a signal.
  • FE_HAS_VITERBI: FEC inner coding (Viterbi, LDPC or other inner code). is stable.
  • FE_HAS_SYNC: Synchronization bytes was found.
  • FE_HAS_LOCK: Digital TV were locked and everything is working.
  • FE_TIMEDOUT: Fo lock within the last about 2 seconds.
  • FE_REINIT: Frontend was reinitialized, application is recommended to reset DiSEqC, tone and parameters.

enum fe_spectral_inversion #

Type of inversion band

Constants

  • INVERSION_OFF: Don't do spectral band inversion.
  • INVERSION_ON: Do spectral band inversion.
  • INVERSION_AUTO: Autodetect spectral band inversion.

Description

This parameter indicates if spectral inversion should be presumed or not. In the automatic setting (INVERSION_AUTO) the hardware will try to figure out the correct setting by itself. If the hardware doesn't support, the dvb_frontend will try to lock at the carrier first with inversion off. If it fails, it will try to enable inversion.

enum fe_code_rate #

Type of Forward Error Correction (FEC)

Constants

  • FEC_NONE: No Forward Error Correction Code
  • FEC_1_2: Forward Error Correction Code 1/2
  • FEC_2_3: Forward Error Correction Code 2/3
  • FEC_3_4: Forward Error Correction Code 3/4
  • FEC_4_5: Forward Error Correction Code 4/5
  • FEC_5_6: Forward Error Correction Code 5/6
  • FEC_6_7: Forward Error Correction Code 6/7
  • FEC_7_8: Forward Error Correction Code 7/8
  • FEC_8_9: Forward Error Correction Code 8/9
  • FEC_AUTO: Autodetect Error Correction Code
  • FEC_3_5: Forward Error Correction Code 3/5
  • FEC_9_10: Forward Error Correction Code 9/10
  • FEC_2_5: Forward Error Correction Code 2/5
  • FEC_1_3: Forward Error Correction Code 1/3
  • FEC_1_4: Forward Error Correction Code 1/4
  • FEC_5_9: Forward Error Correction Code 5/9
  • FEC_7_9: Forward Error Correction Code 7/9
  • FEC_8_15: Forward Error Correction Code 8/15
  • FEC_11_15: Forward Error Correction Code 11/15
  • FEC_13_18: Forward Error Correction Code 13/18
  • FEC_9_20: Forward Error Correction Code 9/20
  • FEC_11_20: Forward Error Correction Code 11/20
  • FEC_23_36: Forward Error Correction Code 23/36
  • FEC_25_36: Forward Error Correction Code 25/36
  • FEC_13_45: Forward Error Correction Code 13/45
  • FEC_26_45: Forward Error Correction Code 26/45
  • FEC_28_45: Forward Error Correction Code 28/45
  • FEC_32_45: Forward Error Correction Code 32/45
  • FEC_77_90: Forward Error Correction Code 77/90
  • FEC_11_45: Forward Error Correction Code 11/45
  • FEC_4_15: Forward Error Correction Code 4/15
  • FEC_14_45: Forward Error Correction Code 14/45
  • FEC_7_15: Forward Error Correction Code 7/15

Description

Please note that not all FEC types are supported by a given standard.

enum fe_modulation #

Type of modulation/constellation

Constants

  • QPSK: QPSK modulation
  • QAM_16: 16-QAM modulation
  • QAM_32: 32-QAM modulation
  • QAM_64: 64-QAM modulation
  • QAM_128: 128-QAM modulation
  • QAM_256: 256-QAM modulation
  • QAM_AUTO: Autodetect QAM modulation
  • VSB_8: 8-VSB modulation
  • VSB_16: 16-VSB modulation
  • PSK_8: 8-PSK modulation
  • APSK_16: 16-APSK modulation
  • APSK_32: 32-APSK modulation
  • DQPSK: DQPSK modulation
  • QAM_4_NR: 4-QAM-NR modulation
  • QAM_1024: 1024-QAM modulation
  • QAM_4096: 4096-QAM modulation
  • APSK_8_L: 8APSK-L modulation
  • APSK_16_L: 16APSK-L modulation
  • APSK_32_L: 32APSK-L modulation
  • APSK_64: 64APSK modulation
  • APSK_64_L: 64APSK-L modulation

Description

Please note that not all modulations are supported by a given standard.

enum fe_transmit_mode #

Transmission mode

Constants

  • TRANSMISSION_MODE_2K: Transmission mode 2K
  • TRANSMISSION_MODE_8K: Transmission mode 8K
  • TRANSMISSION_MODE_AUTO: Autodetect transmission mode. The hardware will try to find the correct FFT-size (if capable) to fill in the missing parameters.
  • TRANSMISSION_MODE_4K: Transmission mode 4K
  • TRANSMISSION_MODE_1K: Transmission mode 1K
  • TRANSMISSION_MODE_16K: Transmission mode 16K
  • TRANSMISSION_MODE_32K: Transmission mode 32K
  • TRANSMISSION_MODE_C1: Single Carrier (C=1) transmission mode (DTMB only)
  • TRANSMISSION_MODE_C3780: Multi Carrier (C=3780) transmission mode (DTMB only)

Description

Please note that not all transmission modes are supported by a given standard.

enum fe_guard_interval #

Guard interval

Constants

  • GUARD_INTERVAL_1_32: Guard interval 1/32
  • GUARD_INTERVAL_1_16: Guard interval 1/16
  • GUARD_INTERVAL_1_8: Guard interval 1/8
  • GUARD_INTERVAL_1_4: Guard interval 1/4
  • GUARD_INTERVAL_AUTO: Autodetect the guard interval
  • GUARD_INTERVAL_1_128: Guard interval 1/128
  • GUARD_INTERVAL_19_128: Guard interval 19/128
  • GUARD_INTERVAL_19_256: Guard interval 19/256
  • GUARD_INTERVAL_PN420: PN length 420 (1/4)
  • GUARD_INTERVAL_PN595: PN length 595 (1/6)
  • GUARD_INTERVAL_PN945: PN length 945 (1/9)
  • GUARD_INTERVAL_1_64: Guard interval 1/64

Description

Please note that not all guard intervals are supported by a given standard.

enum fe_hierarchy #

Hierarchy

Constants

  • HIERARCHY_NONE: No hierarchy
  • HIERARCHY_1: Hierarchy 1
  • HIERARCHY_2: Hierarchy 2
  • HIERARCHY_4: Hierarchy 4
  • HIERARCHY_AUTO: Autodetect hierarchy (if supported)

Description

Please note that not all hierarchy types are supported by a given standard.

enum fe_interleaving #

Interleaving

Constants

  • INTERLEAVING_NONE: No interleaving.
  • INTERLEAVING_AUTO: Auto-detect interleaving.
  • INTERLEAVING_240: Interleaving of 240 symbols.
  • INTERLEAVING_720: Interleaving of 720 symbols.

Description

Please note that, currently, only DTMB uses it.

enum fe_pilot #

Type of pilot tone

Constants

  • PILOT_ON: Pilot tones enabled
  • PILOT_OFF: Pilot tones disabled
  • PILOT_AUTO: Autodetect pilot tones

enum fe_rolloff #

Rolloff factor

Constants

  • ROLLOFF_35: Roloff factor: α=35%
  • ROLLOFF_20: Roloff factor: α=20%
  • ROLLOFF_25: Roloff factor: α=25%
  • ROLLOFF_AUTO: Auto-detect the roloff factor.
  • ROLLOFF_15: Rolloff factor: α=15%
  • ROLLOFF_10: Rolloff factor: α=10%
  • ROLLOFF_5: Rolloff factor: α=5%

Description

enum fe_delivery_system #

Type of the delivery system

Constants

  • SYS_UNDEFINED: Undefined standard. Generally, indicates an error
  • SYS_DVBC_ANNEX_A: Cable TV: DVB-C following ITU-T J.83 Annex A spec
  • SYS_DVBC_ANNEX_B: Cable TV: DVB-C following ITU-T J.83 Annex B spec (ClearQAM)
  • SYS_DVBT: Terrestrial TV: DVB-T
  • SYS_DSS: Satellite TV: DSS (not fully supported)
  • SYS_DVBS: Satellite TV: DVB-S
  • SYS_DVBS2: Satellite TV: DVB-S2 and DVB-S2X
  • SYS_DVBH: Terrestrial TV (mobile): DVB-H (standard deprecated)
  • SYS_ISDBT: Terrestrial TV: ISDB-T
  • SYS_ISDBS: Satellite TV: ISDB-S
  • SYS_ISDBC: Cable TV: ISDB-C (no drivers yet)
  • SYS_ATSC: Terrestrial TV: ATSC
  • SYS_ATSCMH: Terrestrial TV (mobile): ATSC-M/H
  • SYS_DTMB: Terrestrial TV: DTMB
  • SYS_CMMB: Terrestrial TV (mobile): CMMB (not fully supported)
  • SYS_DAB: Digital audio: DAB (not fully supported)
  • SYS_DVBT2: Terrestrial TV: DVB-T2
  • SYS_TURBO: Satellite TV: DVB-S Turbo
  • SYS_DVBC_ANNEX_C: Cable TV: DVB-C following ITU-T J.83 Annex C spec
  • SYS_DVBC2: Cable TV: DVB-C2

enum atscmh_sccc_block_mode #

Type of Series Concatenated Convolutional Code Block Mode.

Constants

  • ATSCMH_SCCC_BLK_SEP: Separate SCCC: the SCCC outer code mode shall be set independently for each Group Region (A, B, C, D)
  • ATSCMH_SCCC_BLK_COMB: Combined SCCC: all four Regions shall have the same SCCC outer code mode.
  • ATSCMH_SCCC_BLK_RES: Reserved. Shouldn't be used.

enum atscmh_sccc_code_mode #

Type of Series Concatenated Convolutional Code Rate.

Constants

  • ATSCMH_SCCC_CODE_HLF: The outer code rate of a SCCC Block is 1/2 rate.
  • ATSCMH_SCCC_CODE_QTR: The outer code rate of a SCCC Block is 1/4 rate.
  • ATSCMH_SCCC_CODE_RES: Reserved. Should not be used.

enum atscmh_rs_frame_ensemble #

Reed Solomon(RS) frame ensemble.

Constants

  • ATSCMH_RSFRAME_ENS_PRI: Primary Ensemble.
  • ATSCMH_RSFRAME_ENS_SEC: Secondary Ensemble.

enum atscmh_rs_frame_mode #

Reed Solomon (RS) frame mode.

Constants

  • ATSCMH_RSFRAME_PRI_ONLY: Single Frame: There is only a primary RS Frame for all Group Regions.
  • ATSCMH_RSFRAME_PRI_SEC: Dual Frame: There are two separate RS Frames: Primary RS Frame for Group Region A and B and Secondary RS Frame for Group Region C and D.
  • ATSCMH_RSFRAME_RES: Reserved. Shouldn't be used.

enum atscmh_rs_code_mode #

ATSC-M/H Reed Solomon modes

Constants

  • ATSCMH_RSCODE_211_187: Reed Solomon code (211,187).
  • ATSCMH_RSCODE_223_187: Reed Solomon code (223,187).
  • ATSCMH_RSCODE_235_187: Reed Solomon code (235,187).
  • ATSCMH_RSCODE_RES: Reserved. Shouldn't be used.

enum fecap_scale_params #

scale types for the quality parameters.

Constants

  • FE_SCALE_NOT_AVAILABLE: That QoS measure is not available. That could indicate a temporary or a permanent condition.
  • FE_SCALE_DECIBEL: The scale is measured in 0.001 dB steps, typically used on signal measures.
  • FE_SCALE_RELATIVE: The scale is a relative percentual measure, ranging from 0 (0%) to 0xffff (100%).
  • FE_SCALE_COUNTER: The scale counts the occurrence of an event, like bit error, block error, lapsed time.

struct dtv_stats #

Used for reading a DTV status property

Definition

struct dtv_stats {
    __u8 scale;
    union {
        __u64 uvalue;
        __s64 svalue;
    };
};

Members

  • scale: Filled with enum fecap_scale_params - the scale in usage for that parameter
  • {unnamed_union}: anonymous
  • uvalue: unsigned integer value of the measure, used when scale is either FE_SCALE_RELATIVE or FE_SCALE_COUNTER.
  • svalue: integer value of the measure, for FE_SCALE_DECIBEL, used for dB measures. The unit is 0.001 dB.

Description

For most delivery systems, this will return a single value for each parameter.

It should be noticed, however, that new OFDM delivery systems like ISDB can use different modulation types for each group of carriers. On such standards, up to 8 groups of statistics can be provided, one for each carrier group (called "layer" on ISDB).

In order to be consistent with other delivery systems, the first value refers to the entire set of carriers ("global").

scale should use the value FE_SCALE_NOT_AVAILABLE when the value for the entire group of carriers or from one specific layer is not provided by the hardware.

len should be filled with the latest filled status + 1.

In other words, for ISDB, those values should be filled like:

u.st.stat.svalue[0] = global statistics;
u.st.stat.scale[0] = FE_SCALE_DECIBEL;
u.st.stat.value[1] = layer A statistics;
u.st.stat.scale[1] = FE_SCALE_NOT_AVAILABLE (if not available);
u.st.stat.svalue[2] = layer B statistics;
u.st.stat.scale[2] = FE_SCALE_DECIBEL;
u.st.stat.svalue[3] = layer C statistics;
u.st.stat.scale[3] = FE_SCALE_DECIBEL;
u.st.len = 4;

struct dtv_fe_stats #

store Digital TV frontend statistics

Definition

struct dtv_fe_stats {
    __u8 len;
    struct dtv_stats stat[MAX_DTV_STATS];
};

Members

  • len: length of the statistics - if zero, stats is disabled.
  • stat: array with digital TV statistics.

Description

On most standards, len can either be 0 or 1. However, for ISDB, each layer is modulated in separate. So, each layer may have its own set of statistics. If so, stat[0] carries on a global value for the property. Indexes 1 to 3 means layer A to B.

struct dtv_property #

store one of frontend command and its value

Definition

struct dtv_property {
    __u32 cmd;
    __u32 reserved[3];
    union {
        __u32 data;
        struct dtv_fe_stats st;
        struct {
            __u8 data[32];
            __u32 len;
            __u32 reserved1[3];
            void *reserved2;
        } buffer;
    } u;
    int result;
};

Members

  • cmd: Digital TV command.
  • reserved: Not used.
  • u: Union with the values for the command.
  • u.data: A unsigned 32 bits integer with command value.
  • u.st: a struct dtv_fe_stats array of statistics.
  • u.buffer: Struct to store bigger properties. Currently unused.
  • u.buffer.data: an unsigned 32-bits array.
  • u.buffer.len: number of elements of the buffer.
  • u.buffer.reserved1: Reserved.
  • u.buffer.reserved2: Reserved.
  • result: Currently unused.

struct dtv_properties #

a set of command/value pairs.

Definition

struct dtv_properties {
    __u32 num;
    struct dtv_property *props;
};

Members

  • num: amount of commands stored at the struct.
  • props: a pointer to struct dtv_property.

Properties used on cable delivery systems

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

DVB-C delivery system #

The DVB-C Annex-A is the widely used cable standard. Transmission uses QAM modulation.

The DVB-C Annex-C is optimized for 6MHz, and is used in Japan. It supports a subset of the Annex A modulation types, and a roll-off of 0.13, instead of 0.15

The following parameters are valid for DVB-C Annex A/C:

  • DTV_API_VERSION

  • DTV_DELIVERY_SYSTEM

  • DTV_TUNE

  • DTV_CLEAR

  • DTV_FREQUENCY

  • DTV_MODULATION

  • DTV_INVERSION

  • DTV_SYMBOL_RATE

  • DTV_INNER_FEC

  • DTV_LNA

In addition, the DTV QoS statistics are also valid.

DVB-C Annex B delivery system #

The DVB-C Annex-B is only used on a few Countries like the United States.

The following parameters are valid for DVB-C Annex B:

  • DTV_API_VERSION

  • DTV_DELIVERY_SYSTEM

  • DTV_TUNE

  • DTV_CLEAR

  • DTV_FREQUENCY

  • DTV_MODULATION

  • DTV_INVERSION

  • DTV_LNA

In addition, the DTV QoS statistics are also valid.

Properties used on satellite delivery systems

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

DVB-S delivery system #

The following parameters are valid for DVB-S:

  • DTV_API_VERSION

  • DTV_DELIVERY_SYSTEM

  • DTV_TUNE

  • DTV_CLEAR

  • DTV_FREQUENCY

  • DTV_INVERSION

  • DTV_SYMBOL_RATE

  • DTV_INNER_FEC

  • DTV_VOLTAGE

  • DTV_TONE

In addition, the DTV QoS statistics are also valid.

Future implementations might add those two missing parameters:

  • DTV_DISEQC_MASTER

  • DTV_DISEQC_SLAVE_REPLY

DVB-S2 delivery system #

In addition to all parameters valid for DVB-S, DVB-S2 supports the following parameters:

  • DTV_MODULATION

  • DTV_PILOT

  • DTV_ROLLOFF

  • DTV_STREAM_ID

  • DTV_SCRAMBLING_SEQUENCE_INDEX

In addition, the DTV QoS statistics are also valid.

Turbo code delivery system #

In addition to all parameters valid for DVB-S, turbo code supports the following parameters:

  • DTV_MODULATION

ISDB-S delivery system #

The following parameters are valid for ISDB-S:

  • DTV_API_VERSION

  • DTV_DELIVERY_SYSTEM

  • DTV_TUNE

  • DTV_CLEAR

  • DTV_FREQUENCY

  • DTV_INVERSION

  • DTV_SYMBOL_RATE

  • DTV_INNER_FEC

  • DTV_VOLTAGE

  • DTV_STREAM_ID

Properties used on terrestrial delivery systems

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

DVB-T delivery system #

The following parameters are valid for DVB-T:

  • DTV_API_VERSION

  • DTV_DELIVERY_SYSTEM

  • DTV_TUNE

  • DTV_CLEAR

  • DTV_FREQUENCY

  • DTV_MODULATION

  • DTV_BANDWIDTH_HZ

  • DTV_INVERSION

  • DTV_CODE_RATE_HP

  • DTV_CODE_RATE_LP

  • DTV_GUARD_INTERVAL

  • DTV_TRANSMISSION_MODE

  • DTV_HIERARCHY

  • DTV_LNA

In addition, the DTV QoS statistics are also valid.

DVB-T2 delivery system #

DVB-T2 support is currently in the early stages of development, so expect that this section may grow and become more detailed with time.

The following parameters are valid for DVB-T2:

  • DTV_API_VERSION

  • DTV_DELIVERY_SYSTEM

  • DTV_TUNE

  • DTV_CLEAR

  • DTV_FREQUENCY

  • DTV_MODULATION

  • DTV_BANDWIDTH_HZ

  • DTV_INVERSION

  • DTV_CODE_RATE_HP

  • DTV_CODE_RATE_LP

  • DTV_GUARD_INTERVAL

  • DTV_TRANSMISSION_MODE

  • DTV_HIERARCHY

  • DTV_STREAM_ID

  • DTV_LNA

In addition, the DTV QoS statistics are also valid.

ISDB-T delivery system #

This ISDB-T/ISDB-Tsb API extension should reflect all information needed to tune any ISDB-T/ISDB-Tsb hardware. Of course it is possible that some very sophisticated devices won't need certain parameters to tune.

The information given here should help application writers to know how to handle ISDB-T and ISDB-Tsb hardware using the Linux Digital TV API.

The details given here about ISDB-T and ISDB-Tsb are just enough to basically show the dependencies between the needed parameter values, but surely some information is left out. For more detailed information see the following documents:

ARIB STD-B31 - "Transmission System for Digital Terrestrial Television Broadcasting" and

ARIB TR-B14 - "Operational Guidelines for Digital Terrestrial Television Broadcasting".

In order to understand the ISDB specific parameters, one has to have some knowledge the channel structure in ISDB-T and ISDB-Tsb. I.e. it has to be known to the reader that an ISDB-T channel consists of 13 segments, that it can have up to 3 layer sharing those segments, and things like that.

The following parameters are valid for ISDB-T:

  • DTV_API_VERSION

  • DTV_DELIVERY_SYSTEM

  • DTV_TUNE

  • DTV_CLEAR

  • DTV_FREQUENCY

  • DTV_BANDWIDTH_HZ

  • DTV_INVERSION

  • DTV_GUARD_INTERVAL

  • DTV_TRANSMISSION_MODE

  • DTV_ISDBT_LAYER_ENABLED

  • DTV_ISDBT_PARTIAL_RECEPTION

  • DTV_ISDBT_SOUND_BROADCASTING

  • DTV_ISDBT_SB_SUBCHANNEL_ID

  • DTV_ISDBT_SB_SEGMENT_IDX

  • DTV_ISDBT_SB_SEGMENT_COUNT

  • DTV_ISDBT_LAYERA_FEC

  • DTV_ISDBT_LAYERA_MODULATION

  • DTV_ISDBT_LAYERA_SEGMENT_COUNT

  • DTV_ISDBT_LAYERA_TIME_INTERLEAVING

  • DTV_ISDBT_LAYERB_FEC

  • DTV_ISDBT_LAYERB_MODULATION

  • DTV_ISDBT_LAYERB_SEGMENT_COUNT

  • DTV_ISDBT_LAYERB_TIME_INTERLEAVING

  • DTV_ISDBT_LAYERC_FEC

  • DTV_ISDBT_LAYERC_MODULATION

  • DTV_ISDBT_LAYERC_SEGMENT_COUNT

  • DTV_ISDBT_LAYERC_TIME_INTERLEAVING

In addition, the DTV QoS statistics are also valid.

ATSC delivery system #

The following parameters are valid for ATSC:

  • DTV_API_VERSION

  • DTV_DELIVERY_SYSTEM

  • DTV_TUNE

  • DTV_CLEAR

  • DTV_FREQUENCY

  • DTV_MODULATION

  • DTV_BANDWIDTH_HZ

In addition, the DTV QoS statistics are also valid.

ATSC-MH delivery system #

The following parameters are valid for ATSC-MH:

  • DTV_API_VERSION

  • DTV_DELIVERY_SYSTEM

  • DTV_TUNE

  • DTV_CLEAR

  • DTV_FREQUENCY

  • DTV_BANDWIDTH_HZ

  • DTV_ATSCMH_FIC_VER

  • DTV_ATSCMH_PARADE_ID

  • DTV_ATSCMH_NOG

  • DTV_ATSCMH_TNOG

  • DTV_ATSCMH_SGN

  • DTV_ATSCMH_PRC

  • DTV_ATSCMH_RS_FRAME_MODE

  • DTV_ATSCMH_RS_FRAME_ENSEMBLE

  • DTV_ATSCMH_RS_CODE_MODE_PRI

  • DTV_ATSCMH_RS_CODE_MODE_SEC

  • DTV_ATSCMH_SCCC_BLOCK_MODE

  • DTV_ATSCMH_SCCC_CODE_MODE_A

  • DTV_ATSCMH_SCCC_CODE_MODE_B

  • DTV_ATSCMH_SCCC_CODE_MODE_C

  • DTV_ATSCMH_SCCC_CODE_MODE_D

In addition, the DTV QoS statistics are also valid.

DTMB delivery system #

The following parameters are valid for DTMB:

  • DTV_API_VERSION

  • DTV_DELIVERY_SYSTEM

  • DTV_TUNE

  • DTV_CLEAR

  • DTV_FREQUENCY

  • DTV_MODULATION

  • DTV_BANDWIDTH_HZ

  • DTV_INVERSION

  • DTV_INNER_FEC

  • DTV_GUARD_INTERVAL

  • DTV_TRANSMISSION_MODE

  • DTV_INTERLEAVING

  • DTV_LNA

In addition, the DTV QoS statistics are also valid.

Frontend statistics indicators

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

The values are returned via dtv_property.stat. If the property is supported, dtv_property.stat.len is bigger than zero.

For most delivery systems, dtv_property.stat.len will be 1 if the stats is supported, and the properties will return a single value for each parameter.

It should be noted, however, that new OFDM delivery systems like ISDB can use different modulation types for each group of carriers. On such standards, up to 3 groups of statistics can be provided, and dtv_property.stat.len is updated to reflect the "global" metrics, plus one metric per each carrier group (called "layer" on ISDB).

So, in order to be consistent with other delivery systems, the first value at dtv_property.stat.dtv_stats <dtv_stats> array refers to the global metric. The other elements of the array represent each layer, starting from layer A(index 1), layer B (index 2) and so on.

The number of filled elements are stored at dtv_property.stat.len.

Each element of the dtv_property.stat.dtv_stats array consists on two elements:

  • svalue or uvalue, where svalue is for signed values of the measure (dB measures) and uvalue is for unsigned values (counters, relative scale)

  • scale - Scale for the value. It can be:

    • FE_SCALE_NOT_AVAILABLE - The parameter is supported by the frontend, but it was not possible to collect it (could be a transitory or permanent condition)

    • FE_SCALE_DECIBEL - parameter is a signed value, measured in 1/1000 dB

    • FE_SCALE_RELATIVE - parameter is a unsigned value, where 0 means 0% and 65535 means 100%.

    • FE_SCALE_COUNTER - parameter is a unsigned value that counts the occurrence of an event, like bit error, block error, or lapsed time.

DTV_STAT_SIGNAL_STRENGTH #

Indicates the signal strength level at the analog part of the tuner or of the demod.

Possible scales for this metric are:

  • FE_SCALE_NOT_AVAILABLE - it failed to measure it, or the measurement was not complete yet.

  • FE_SCALE_DECIBEL - signal strength is in 0.001 dBm units, power measured in miliwatts. This value is generally negative.

  • FE_SCALE_RELATIVE - The frontend provides a 0% to 100% measurement for power (actually, 0 to 65535).

DTV_STAT_CNR #

Indicates the Signal to Noise ratio for the main carrier.

Possible scales for this metric are:

  • FE_SCALE_NOT_AVAILABLE - it failed to measure it, or the measurement was not complete yet.

  • FE_SCALE_DECIBEL - Signal/Noise ratio is in 0.001 dB units.

  • FE_SCALE_RELATIVE - The frontend provides a 0% to 100% measurement for Signal/Noise (actually, 0 to 65535).

DTV_STAT_PRE_ERROR_BIT_COUNT #

Measures the number of bit errors before the forward error correction (FEC) on the inner coding block (before Viterbi, LDPC or other inner code).

This measure is taken during the same interval as DTV_STAT_PRE_TOTAL_BIT_COUNT.

In order to get the BER (Bit Error Rate) measurement, it should be divided by DTV_STAT_PRE_TOTAL_BIT_COUNT.

This measurement is monotonically increased, as the frontend gets more bit count measurements. The frontend may reset it when a channel/transponder is tuned.

Possible scales for this metric are:

  • FE_SCALE_NOT_AVAILABLE - it failed to measure it, or the measurement was not complete yet.

  • FE_SCALE_COUNTER - Number of error bits counted before the inner coding.

DTV_STAT_PRE_TOTAL_BIT_COUNT #

Measures the amount of bits received before the inner code block, during the same period as DTV_STAT_PRE_ERROR_BIT_COUNT measurement was taken.

It should be noted that this measurement can be smaller than the total amount of bits on the transport stream, as the frontend may need to manually restart the measurement, losing some data between each measurement interval.

This measurement is monotonically increased, as the frontend gets more bit count measurements. The frontend may reset it when a channel/transponder is tuned.

Possible scales for this metric are:

  • FE_SCALE_NOT_AVAILABLE - it failed to measure it, or the measurement was not complete yet.

  • FE_SCALE_COUNTER - Number of bits counted while measuring DTV_STAT_PRE_ERROR_BIT_COUNT.

DTV_STAT_POST_ERROR_BIT_COUNT #

Measures the number of bit errors after the forward error correction (FEC) done by inner code block (after Viterbi, LDPC or other inner code).

This measure is taken during the same interval as DTV_STAT_POST_TOTAL_BIT_COUNT.

In order to get the BER (Bit Error Rate) measurement, it should be divided by DTV_STAT_POST_TOTAL_BIT_COUNT.

This measurement is monotonically increased, as the frontend gets more bit count measurements. The frontend may reset it when a channel/transponder is tuned.

Possible scales for this metric are:

  • FE_SCALE_NOT_AVAILABLE - it failed to measure it, or the measurement was not complete yet.

  • FE_SCALE_COUNTER - Number of error bits counted after the inner coding.

DTV_STAT_POST_TOTAL_BIT_COUNT #

Measures the amount of bits received after the inner coding, during the same period as DTV_STAT_POST_ERROR_BIT_COUNT measurement was taken.

It should be noted that this measurement can be smaller than the total amount of bits on the transport stream, as the frontend may need to manually restart the measurement, losing some data between each measurement interval.

This measurement is monotonically increased, as the frontend gets more bit count measurements. The frontend may reset it when a channel/transponder is tuned.

Possible scales for this metric are:

  • FE_SCALE_NOT_AVAILABLE - it failed to measure it, or the measurement was not complete yet.

  • FE_SCALE_COUNTER - Number of bits counted while measuring DTV_STAT_POST_ERROR_BIT_COUNT.

DTV_STAT_ERROR_BLOCK_COUNT #

Measures the number of block errors after the outer forward error correction coding (after Reed-Solomon or other outer code).

This measurement is monotonically increased, as the frontend gets more bit count measurements. The frontend may reset it when a channel/transponder is tuned.

Possible scales for this metric are:

  • FE_SCALE_NOT_AVAILABLE - it failed to measure it, or the measurement was not complete yet.

  • FE_SCALE_COUNTER - Number of error blocks counted after the outer coding.

DTV-STAT_TOTAL_BLOCK_COUNT #

Measures the total number of blocks received during the same period as DTV_STAT_ERROR_BLOCK_COUNT measurement was taken.

It can be used to calculate the PER indicator, by dividing DTV_STAT_ERROR_BLOCK_COUNT by DTV-STAT_TOTAL_BLOCK_COUNT.

Possible scales for this metric are:

  • FE_SCALE_NOT_AVAILABLE - it failed to measure it, or the measurement was not complete yet.

  • FE_SCALE_COUNTER - Number of blocks counted while measuring DTV_STAT_ERROR_BLOCK_COUNT.

Digital TV Frontend API

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

The Digital TV frontend API was designed to support three groups of delivery systems: Terrestrial, cable and Satellite. Currently, the following delivery systems are supported:

  • Terrestrial systems: DVB-T, DVB-T2, ATSC, ATSC M/H, ISDB-T, DVB-H, DTMB, CMMB

  • Cable systems: DVB-C Annex A/C, ClearQAM (DVB-C Annex B)

  • Satellite systems: DVB-S, DVB-S2, DVB Turbo, ISDB-S, DSS

The Digital TV frontend controls several sub-devices including:

  • Tuner

  • Digital TV demodulator

  • Low noise amplifier (LNA)

  • Satellite Equipment Control (SEC) 1.

The frontend can be accessed through /dev/dvb/adapter?/frontend?. Data types and ioctl definitions can be accessed by including linux/dvb/frontend.h in your application.

Note

Transmission via the internet (DVB-IP) and MMT (MPEG Media Transport) is not yet handled by this API but a future extension is possible.

[1] On Satellite systems, the API support for the Satellite Equipment Control (SEC) allows to power control and to send/receive signals to control the antenna subsystem, selecting the polarization and choosing the Intermediate Frequency IF) of the Low Noise Block Converter Feed Horn (LNBf). It supports the DiSEqC and V-SEC protocols. The DiSEqC (digital SEC) specification is available at Eutelsat.

  • Querying frontend information
  • Querying frontend status and statistics
  • dvbproperty
  • Frontend Function Calls

Digital TV frontend close()

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

fe-close - Close a frontend device

Synopsis #

#include <unistd.h>

int close( int fd )

Arguments #

  • fd

    File descriptor returned by open().

Description #

This system call closes a previously opened front-end device. After closing a front-end device, its corresponding hardware might be powered down automatically.

Return Value #

On success 0 is returned.

On error -1 is returned, and the errno variable is set appropriately.

Generic error codes are described at the Generic Error Codes chapter.

Digital TV frontend open()

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

fe-open - Open a frontend device

Synopsis #

#include <fcntl.h>

int open( const char *device_name, int flags )

Arguments #

  • device_name

    Device to be opened.

  • flags

    Open flags. Access can either be O_RDWR or O_RDONLY.

    Multiple opens are allowed with O_RDONLY. In this mode, only query and read ioctls are allowed.

    Only one open is allowed in O_RDWR. In this mode, all ioctls are allowed.

    When the O_NONBLOCK flag is given, the system calls may return EAGAIN error code when no data is available or when the device driver is temporarily busy.

    Other flags have no effect.

Description #

This system call opens a named frontend device (/dev/dvb/adapter?/frontend?) for subsequent use. Usually the first thing to do after a successful open is to find out the frontend type with ioctl FE_GET_INFO.

The device can be opened in read-only mode, which only allows monitoring of device status and statistics, or read/write mode, which allows any kind of use (e.g. performing tuning operations.)

In a system with multiple front-ends, it is usually the case that multiple devices cannot be open in read/write mode simultaneously. As long as a front-end device is opened in read/write mode, other open() calls in read/write mode will either fail or block, depending on whether non-blocking or blocking mode was specified. A front-end device opened in blocking mode can later be put into non-blocking mode (and vice versa) using the F_SETFL command of the fcntl system call. This is a standard system call, documented in the Linux manual page for fcntl. When an open() call has succeeded, the device will be ready for use in the specified mode. This implies that the corresponding hardware is powered up, and that other front-ends may have been powered down to make that possible.

Return Value #

On success open() returns the new file descriptor. On error, -1 is returned, and the errno variable is set appropriately.

Possible error codes are:

On success 0 is returned, and ca_slot_info is filled.

On error -1 is returned, and the errno variable is set appropriately.

EPERM

The caller has no permission to access the device.

EBUSY

The device driver is already in use.

EMFILE

The process already has the maximum number of files open.

ENFILE

The limit on the total number of files open on the system has been reached.

The generic error codes are described at the Generic Error Codes chapter.

Frontend Function Calls

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

  • Digital TV frontend open()
  • Digital TV frontend close()
  • ioctl FE_GET_INFO
  • ioctl FE_READ_STATUS
  • ioctl FE_SET_PROPERTY, FE_GET_PROPERTY
  • ioctl FE_DISEQC_RESET_OVERLOAD
  • ioctl FE_DISEQC_SEND_MASTER_CMD
  • ioctl FE_DISEQC_RECV_SLAVE_REPLY
  • ioctl FE_DISEQC_SEND_BURST
  • ioctl FE_SET_TONE
  • ioctl FE_SET_VOLTAGE
  • ioctl FE_ENABLE_HIGH_LNB_VOLTAGE
  • ioctl FE_SET_FRONTEND_TUNE_MODE

Frontend Legacy Data Types

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Frontend Legacy Data Types #

  • Frontend type
  • Frontend bandwidth
  • frontend parameters
  • frontend events

Frontend Legacy Function Calls #

Those functions are defined at DVB version 3. The support is kept in the kernel due to compatibility issues only. Their usage is strongly not recommended

  • FE_READ_BER
  • FE_READ_SNR
  • FE_READ_SIGNAL_STRENGTH
  • FE_READ_UNCORRECTED_BLOCKS
  • FE_SET_FRONTEND
  • FE_GET_FRONTEND
  • FE_GET_EVENT
  • FE_DISHNETWORK_SEND_LEGACY_CMD

Digital TV Frontend legacy API (a. k. a. DVBv3)

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

The usage of this API is deprecated, as it doesn't support all digital TV standards, doesn't provide good statistics measurements and provides incomplete information. This is kept only to support legacy applications.

  • Frontend Legacy Data Types

Digital TV uAPI symbols

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Frontend #

Enumeration values #

  • BANDWIDTH_10_MHZ: include/uapi/linux/dvb/frontend.h, line 987
  • BANDWIDTH_1_712_MHZ: include/uapi/linux/dvb/frontend.h, line 988
  • BANDWIDTH_5_MHZ: include/uapi/linux/dvb/frontend.h, line 986
  • BANDWIDTH_6_MHZ: include/uapi/linux/dvb/frontend.h, line 984
  • BANDWIDTH_7_MHZ: include/uapi/linux/dvb/frontend.h, line 983
  • BANDWIDTH_8_MHZ: include/uapi/linux/dvb/frontend.h, line 982
  • BANDWIDTH_AUTO: include/uapi/linux/dvb/frontend.h, line 985
  • FE_ATSC: include/uapi/linux/dvb/frontend.h, line 98
  • FE_OFDM: include/uapi/linux/dvb/frontend.h, line 97
  • FE_QAM: include/uapi/linux/dvb/frontend.h, line 96
  • FE_QPSK: include/uapi/linux/dvb/frontend.h, line 95

Enumerations #

  • atscmh_rs_code_mode: include/uapi/linux/dvb/frontend.h, line 778
  • atscmh_rs_frame_ensemble: include/uapi/linux/dvb/frontend.h, line 747
  • atscmh_rs_frame_mode: include/uapi/linux/dvb/frontend.h, line 765
  • atscmh_sccc_block_mode: include/uapi/linux/dvb/frontend.h, line 718
  • atscmh_sccc_code_mode: include/uapi/linux/dvb/frontend.h, line 735
  • fe_bandwidth: include/uapi/linux/dvb/frontend.h, line 981
  • fe_caps: include/uapi/linux/dvb/frontend.h, line 57
  • fe_code_rate: include/uapi/linux/dvb/frontend.h, line 306
  • fe_delivery_system: include/uapi/linux/dvb/frontend.h, line 676
  • fe_guard_interval: include/uapi/linux/dvb/frontend.h, line 449
  • fe_hierarchy: include/uapi/linux/dvb/frontend.h, line 474
  • fe_interleaving: include/uapi/linux/dvb/frontend.h, line 491
  • fe_modulation: include/uapi/linux/dvb/frontend.h, line 369
  • fe_pilot: include/uapi/linux/dvb/frontend.h, line 602
  • fe_rolloff: include/uapi/linux/dvb/frontend.h, line 622
  • fe_sec_mini_cmd: include/uapi/linux/dvb/frontend.h, line 218
  • fe_sec_tone_mode: include/uapi/linux/dvb/frontend.h, line 205
  • fe_sec_voltage: include/uapi/linux/dvb/frontend.h, line 193
  • fe_spectral_inversion: include/uapi/linux/dvb/frontend.h, line 261
  • fe_status: include/uapi/linux/dvb/frontend.h, line 237
  • fe_transmit_mode: include/uapi/linux/dvb/frontend.h, line 419
  • fe_type: include/uapi/linux/dvb/frontend.h, line 94
  • fecap_scale_params: include/uapi/linux/dvb/frontend.h, line 801

IOCTL Commands #

  • FE_DISEQC_RECV_SLAVE_REPLY: include/uapi/linux/dvb/frontend.h, line 941
  • FE_DISEQC_RESET_OVERLOAD: include/uapi/linux/dvb/frontend.h, line 939
  • FE_DISEQC_SEND_BURST: include/uapi/linux/dvb/frontend.h, line 942
  • FE_DISEQC_SEND_MASTER_CMD: include/uapi/linux/dvb/frontend.h, line 940
  • FE_DISHNETWORK_SEND_LEGACY_CMD: include/uapi/linux/dvb/frontend.h, line 957
  • FE_ENABLE_HIGH_LNB_VOLTAGE: include/uapi/linux/dvb/frontend.h, line 946
  • FE_GET_EVENT: include/uapi/linux/dvb/frontend.h, line 955
  • FE_GET_FRONTEND: include/uapi/linux/dvb/frontend.h, line 1056
  • FE_GET_INFO: include/uapi/linux/dvb/frontend.h, line 937
  • FE_GET_PROPERTY: include/uapi/linux/dvb/frontend.h, line 960
  • FE_READ_BER: include/uapi/linux/dvb/frontend.h, line 949
  • FE_READ_SIGNAL_STRENGTH: include/uapi/linux/dvb/frontend.h, line 950
  • FE_READ_SNR: include/uapi/linux/dvb/frontend.h, line 951
  • FE_READ_STATUS: include/uapi/linux/dvb/frontend.h, line 948
  • FE_READ_UNCORRECTED_BLOCKS: include/uapi/linux/dvb/frontend.h, line 952
  • FE_SET_FRONTEND: include/uapi/linux/dvb/frontend.h, line 1055
  • FE_SET_FRONTEND_TUNE_MODE: include/uapi/linux/dvb/frontend.h, line 954
  • FE_SET_PROPERTY: include/uapi/linux/dvb/frontend.h, line 959
  • FE_SET_TONE: include/uapi/linux/dvb/frontend.h, line 944
  • FE_SET_VOLTAGE: include/uapi/linux/dvb/frontend.h, line 945

Macros and Definitions #

  • DTV_API_VERSION: include/uapi/linux/dvb/frontend.h, line 544
  • DTV_ATSCMH_FIC_VER: include/uapi/linux/dvb/frontend.h, line 561
  • DTV_ATSCMH_NOG: include/uapi/linux/dvb/frontend.h, line 563
  • DTV_ATSCMH_PARADE_ID: include/uapi/linux/dvb/frontend.h, line 562
  • DTV_ATSCMH_PRC: include/uapi/linux/dvb/frontend.h, line 566
  • DTV_ATSCMH_RS_CODE_MODE_PRI: include/uapi/linux/dvb/frontend.h, line 569
  • DTV_ATSCMH_RS_CODE_MODE_SEC: include/uapi/linux/dvb/frontend.h, line 570
  • DTV_ATSCMH_RS_FRAME_ENSEMBLE: include/uapi/linux/dvb/frontend.h, line 568
  • DTV_ATSCMH_RS_FRAME_MODE: include/uapi/linux/dvb/frontend.h, line 567
  • DTV_ATSCMH_SCCC_BLOCK_MODE: include/uapi/linux/dvb/frontend.h, line 571
  • DTV_ATSCMH_SCCC_CODE_MODE_A: include/uapi/linux/dvb/frontend.h, line 572
  • DTV_ATSCMH_SCCC_CODE_MODE_B: include/uapi/linux/dvb/frontend.h, line 573
  • DTV_ATSCMH_SCCC_CODE_MODE_C: include/uapi/linux/dvb/frontend.h, line 574
  • DTV_ATSCMH_SCCC_CODE_MODE_D: include/uapi/linux/dvb/frontend.h, line 575
  • DTV_ATSCMH_SGN: include/uapi/linux/dvb/frontend.h, line 565
  • DTV_ATSCMH_TNOG: include/uapi/linux/dvb/frontend.h, line 564
  • DTV_BANDWIDTH_HZ: include/uapi/linux/dvb/frontend.h, line 505
  • DTV_CLEAR: include/uapi/linux/dvb/frontend.h, line 502
  • DTV_CODE_RATE_HP: include/uapi/linux/dvb/frontend.h, line 546
  • DTV_CODE_RATE_LP: include/uapi/linux/dvb/frontend.h, line 547
  • DTV_DELIVERY_SYSTEM: include/uapi/linux/dvb/frontend.h, line 519
  • DTV_DISEQC_MASTER: include/uapi/linux/dvb/frontend.h, line 507
  • DTV_DISEQC_SLAVE_REPLY: include/uapi/linux/dvb/frontend.h, line 514
  • DTV_DVBT2_PLP_ID_LEGACY: include/uapi/linux/dvb/frontend.h, line 556
  • DTV_ENUM_DELSYS: include/uapi/linux/dvb/frontend.h, line 558
  • DTV_FE_CAPABILITY: include/uapi/linux/dvb/frontend.h, line 518
  • DTV_FE_CAPABILITY_COUNT: include/uapi/linux/dvb/frontend.h, line 517
  • DTV_FREQUENCY: include/uapi/linux/dvb/frontend.h, line 503
  • DTV_GUARD_INTERVAL: include/uapi/linux/dvb/frontend.h, line 548
  • DTV_HIERARCHY: include/uapi/linux/dvb/frontend.h, line 550
  • DTV_INNER_FEC: include/uapi/linux/dvb/frontend.h, line 509
  • DTV_INTERLEAVING: include/uapi/linux/dvb/frontend.h, line 577
  • DTV_INVERSION: include/uapi/linux/dvb/frontend.h, line 506
  • DTV_ISDBT_LAYERA_FEC: include/uapi/linux/dvb/frontend.h, line 529
  • DTV_ISDBT_LAYERA_MODULATION: include/uapi/linux/dvb/frontend.h, line 530
  • DTV_ISDBT_LAYERA_SEGMENT_COUNT: include/uapi/linux/dvb/frontend.h, line 531
  • DTV_ISDBT_LAYERA_TIME_INTERLEAVING: include/uapi/linux/dvb/frontend.h, line 532
  • DTV_ISDBT_LAYERB_FEC: include/uapi/linux/dvb/frontend.h, line 534
  • DTV_ISDBT_LAYERB_MODULATION: include/uapi/linux/dvb/frontend.h, line 535
  • DTV_ISDBT_LAYERB_SEGMENT_COUNT: include/uapi/linux/dvb/frontend.h, line 536
  • DTV_ISDBT_LAYERB_TIME_INTERLEAVING: include/uapi/linux/dvb/frontend.h, line 537
  • DTV_ISDBT_LAYERC_FEC: include/uapi/linux/dvb/frontend.h, line 539
  • DTV_ISDBT_LAYERC_MODULATION: include/uapi/linux/dvb/frontend.h, line 540
  • DTV_ISDBT_LAYERC_SEGMENT_COUNT: include/uapi/linux/dvb/frontend.h, line 541
  • DTV_ISDBT_LAYERC_TIME_INTERLEAVING: include/uapi/linux/dvb/frontend.h, line 542
  • DTV_ISDBT_LAYER_ENABLED: include/uapi/linux/dvb/frontend.h, line 552
  • DTV_ISDBT_PARTIAL_RECEPTION: include/uapi/linux/dvb/frontend.h, line 522
  • DTV_ISDBT_SB_SEGMENT_COUNT: include/uapi/linux/dvb/frontend.h, line 527
  • DTV_ISDBT_SB_SEGMENT_IDX: include/uapi/linux/dvb/frontend.h, line 526
  • DTV_ISDBT_SB_SUBCHANNEL_ID: include/uapi/linux/dvb/frontend.h, line 525
  • DTV_ISDBT_SOUND_BROADCASTING: include/uapi/linux/dvb/frontend.h, line 523
  • DTV_LNA: include/uapi/linux/dvb/frontend.h, line 578
  • DTV_MODULATION: include/uapi/linux/dvb/frontend.h, line 504
  • DTV_PILOT: include/uapi/linux/dvb/frontend.h, line 512
  • DTV_ROLLOFF: include/uapi/linux/dvb/frontend.h, line 513
  • DTV_SCRAMBLING_SEQUENCE_INDEX: include/uapi/linux/dvb/frontend.h, line 591
  • DTV_STAT_CNR: include/uapi/linux/dvb/frontend.h, line 582
  • DTV_STAT_ERROR_BLOCK_COUNT: include/uapi/linux/dvb/frontend.h, line 587
  • DTV_STAT_POST_ERROR_BIT_COUNT: include/uapi/linux/dvb/frontend.h, line 585
  • DTV_STAT_POST_TOTAL_BIT_COUNT: include/uapi/linux/dvb/frontend.h, line 586
  • DTV_STAT_PRE_ERROR_BIT_COUNT: include/uapi/linux/dvb/frontend.h, line 583
  • DTV_STAT_PRE_TOTAL_BIT_COUNT: include/uapi/linux/dvb/frontend.h, line 584
  • DTV_STAT_SIGNAL_STRENGTH: include/uapi/linux/dvb/frontend.h, line 581
  • DTV_STAT_TOTAL_BLOCK_COUNT: include/uapi/linux/dvb/frontend.h, line 588
  • DTV_STREAM_ID: include/uapi/linux/dvb/frontend.h, line 554
  • DTV_SYMBOL_RATE: include/uapi/linux/dvb/frontend.h, line 508
  • DTV_TONE: include/uapi/linux/dvb/frontend.h, line 511
  • DTV_TRANSMISSION_MODE: include/uapi/linux/dvb/frontend.h, line 549
  • DTV_TUNE: include/uapi/linux/dvb/frontend.h, line 501
  • DTV_UNDEFINED: include/uapi/linux/dvb/frontend.h, line 500
  • DTV_VOLTAGE: include/uapi/linux/dvb/frontend.h, line 510
  • FE_TUNE_MODE_ONESHOT: include/uapi/linux/dvb/frontend.h, line 933
  • LNA_AUTO: include/uapi/linux/dvb/frontend.h, line 786
  • NO_STREAM_ID_FILTER: include/uapi/linux/dvb/frontend.h, line 785

Structures #

  • dtv_fe_stats: include/uapi/linux/dvb/frontend.h, line 874
  • dtv_properties: include/uapi/linux/dvb/frontend.h, line 921
  • dtv_property: include/uapi/linux/dvb/frontend.h, line 896
  • dtv_stats: include/uapi/linux/dvb/frontend.h, line 852
  • dvb_diseqc_master_cmd: include/uapi/linux/dvb/frontend.h, line 158
  • dvb_diseqc_slave_reply: include/uapi/linux/dvb/frontend.h, line 180
  • dvb_frontend_event: include/uapi/linux/dvb/frontend.h, line 1048
  • dvb_frontend_info: include/uapi/linux/dvb/frontend.h, line 131
  • dvb_frontend_parameters: include/uapi/linux/dvb/frontend.h, line 1036
  • dvb_ofdm_parameters: include/uapi/linux/dvb/frontend.h, line 1026
  • dvb_qam_parameters: include/uapi/linux/dvb/frontend.h, line 1016
  • dvb_qpsk_parameters: include/uapi/linux/dvb/frontend.h, line 1011
  • dvb_vsb_parameters: include/uapi/linux/dvb/frontend.h, line 1022

Type Definitions #

  • fe_bandwidth_t: include/uapi/linux/dvb/frontend.h, line 1002
  • fe_caps_t: include/uapi/linux/dvb/frontend.h, line 993
  • fe_code_rate_t: include/uapi/linux/dvb/frontend.h, line 999
  • fe_delivery_system_t: include/uapi/linux/dvb/frontend.h, line 1007
  • fe_guard_interval_t: include/uapi/linux/dvb/frontend.h, line 1003
  • fe_hierarchy_t: include/uapi/linux/dvb/frontend.h, line 1004
  • fe_modulation_t: include/uapi/linux/dvb/frontend.h, line 1000
  • fe_pilot_t: include/uapi/linux/dvb/frontend.h, line 1005
  • fe_rolloff_t: include/uapi/linux/dvb/frontend.h, line 1006
  • fe_sec_mini_cmd_t: include/uapi/linux/dvb/frontend.h, line 996
  • fe_sec_tone_mode_t: include/uapi/linux/dvb/frontend.h, line 995
  • fe_sec_voltage_t: include/uapi/linux/dvb/frontend.h, line 992
  • fe_spectral_inversion_t: include/uapi/linux/dvb/frontend.h, line 998
  • fe_status_t: include/uapi/linux/dvb/frontend.h, line 997
  • fe_transmit_mode_t: include/uapi/linux/dvb/frontend.h, line 1001
  • fe_type_t: include/uapi/linux/dvb/frontend.h, line 994

Demux #

Enumeration values #

  • DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED: include/uapi/linux/dvb/dmx.h, line 221
  • DMX_BUFFER_FLAG_DISCONTINUITY_INDICATOR: include/uapi/linux/dvb/dmx.h, line 222
  • DMX_BUFFER_FLAG_HAD_CRC32_DISCARD: include/uapi/linux/dvb/dmx.h, line 218
  • DMX_BUFFER_FLAG_TEI: include/uapi/linux/dvb/dmx.h, line 219
  • DMX_BUFFER_PKT_COUNTER_MISMATCH: include/uapi/linux/dvb/dmx.h, line 220
  • DMX_IN_DVR: include/uapi/linux/dvb/dmx.h, line 54
  • DMX_IN_FRONTEND: include/uapi/linux/dvb/dmx.h, line 53
  • DMX_OUT_DECODER: include/uapi/linux/dvb/dmx.h, line 39
  • DMX_OUT_TAP: include/uapi/linux/dvb/dmx.h, line 40
  • DMX_OUT_TSDEMUX_TAP: include/uapi/linux/dvb/dmx.h, line 42
  • DMX_OUT_TS_TAP: include/uapi/linux/dvb/dmx.h, line 41
  • DMX_PES_AUDIO0: include/uapi/linux/dvb/dmx.h, line 89
  • DMX_PES_AUDIO1: include/uapi/linux/dvb/dmx.h, line 95
  • DMX_PES_AUDIO2: include/uapi/linux/dvb/dmx.h, line 101
  • DMX_PES_AUDIO3: include/uapi/linux/dvb/dmx.h, line 107
  • DMX_PES_OTHER: include/uapi/linux/dvb/dmx.h, line 113
  • DMX_PES_PCR0: include/uapi/linux/dvb/dmx.h, line 93
  • DMX_PES_PCR1: include/uapi/linux/dvb/dmx.h, line 99
  • DMX_PES_PCR2: include/uapi/linux/dvb/dmx.h, line 105
  • DMX_PES_PCR3: include/uapi/linux/dvb/dmx.h, line 111
  • DMX_PES_SUBTITLE0: include/uapi/linux/dvb/dmx.h, line 92
  • DMX_PES_SUBTITLE1: include/uapi/linux/dvb/dmx.h, line 98
  • DMX_PES_SUBTITLE2: include/uapi/linux/dvb/dmx.h, line 104
  • DMX_PES_SUBTITLE3: include/uapi/linux/dvb/dmx.h, line 110
  • DMX_PES_TELETEXT0: include/uapi/linux/dvb/dmx.h, line 91
  • DMX_PES_TELETEXT1: include/uapi/linux/dvb/dmx.h, line 97
  • DMX_PES_TELETEXT2: include/uapi/linux/dvb/dmx.h, line 103
  • DMX_PES_TELETEXT3: include/uapi/linux/dvb/dmx.h, line 109
  • DMX_PES_VIDEO0: include/uapi/linux/dvb/dmx.h, line 90
  • DMX_PES_VIDEO1: include/uapi/linux/dvb/dmx.h, line 96
  • DMX_PES_VIDEO2: include/uapi/linux/dvb/dmx.h, line 102
  • DMX_PES_VIDEO3: include/uapi/linux/dvb/dmx.h, line 108

Enumerations #

  • dmx_buffer_flags: include/uapi/linux/dvb/dmx.h, line 217
  • dmx_input: include/uapi/linux/dvb/dmx.h, line 52
  • dmx_output: include/uapi/linux/dvb/dmx.h, line 38
  • dmx_ts_pes: include/uapi/linux/dvb/dmx.h, line 88

IOCTL Commands #

  • DMX_ADD_PID: include/uapi/linux/dvb/dmx.h, line 296
  • DMX_DQBUF: include/uapi/linux/dvb/dmx.h, line 313
  • DMX_EXPBUF: include/uapi/linux/dvb/dmx.h, line 311
  • DMX_GET_PES_PIDS: include/uapi/linux/dvb/dmx.h, line 294
  • DMX_GET_STC: include/uapi/linux/dvb/dmx.h, line 295
  • DMX_QBUF: include/uapi/linux/dvb/dmx.h, line 312
  • DMX_QUERYBUF: include/uapi/linux/dvb/dmx.h, line 310
  • DMX_REMOVE_PID: include/uapi/linux/dvb/dmx.h, line 297
  • DMX_REQBUFS: include/uapi/linux/dvb/dmx.h, line 309
  • DMX_SET_BUFFER_SIZE: include/uapi/linux/dvb/dmx.h, line 293
  • DMX_SET_FILTER: include/uapi/linux/dvb/dmx.h, line 291
  • DMX_SET_PES_FILTER: include/uapi/linux/dvb/dmx.h, line 292
  • DMX_START: include/uapi/linux/dvb/dmx.h, line 289
  • DMX_STOP: include/uapi/linux/dvb/dmx.h, line 290

Macros and Definitions #

  • DMX_CHECK_CRC: include/uapi/linux/dvb/dmx.h, line 163
  • DMX_IMMEDIATE_START: include/uapi/linux/dvb/dmx.h, line 165
  • DMX_ONESHOT: include/uapi/linux/dvb/dmx.h, line 164

Structures #

  • dmx_buffer: include/uapi/linux/dvb/dmx.h, line 245
  • dmx_exportbuffer: include/uapi/linux/dvb/dmx.h, line 283
  • dmx_filter: include/uapi/linux/dvb/dmx.h, line 134
  • dmx_pes_filter_params: include/uapi/linux/dvb/dmx.h, line 178
  • dmx_requestbuffers: include/uapi/linux/dvb/dmx.h, line 263
  • dmx_sct_filter_params: include/uapi/linux/dvb/dmx.h, line 158
  • dmx_stc: include/uapi/linux/dvb/dmx.h, line 193

Type Definitions #

  • dmx_filter_t: include/uapi/linux/dvb/dmx.h, line 305
  • dmx_input_t: include/uapi/linux/dvb/dmx.h, line 303
  • dmx_output_t: include/uapi/linux/dvb/dmx.h, line 302
  • dmx_pes_type_t: include/uapi/linux/dvb/dmx.h, line 304

Conditional Access #

IOCTL Commands #

  • CA_GET_CAP: include/uapi/linux/dvb/ca.h, line 121
  • CA_GET_DESCR_INFO: include/uapi/linux/dvb/ca.h, line 123
  • CA_GET_MSG: include/uapi/linux/dvb/ca.h, line 124
  • CA_GET_SLOT_INFO: include/uapi/linux/dvb/ca.h, line 122
  • CA_RESET: include/uapi/linux/dvb/ca.h, line 120
  • CA_SEND_MSG: include/uapi/linux/dvb/ca.h, line 125
  • CA_SET_DESCR: include/uapi/linux/dvb/ca.h, line 126

Macros and Definitions #

  • CA_CI: include/uapi/linux/dvb/ca.h, line 39
  • CA_CI_LINK: include/uapi/linux/dvb/ca.h, line 40
  • CA_CI_MODULE_PRESENT: include/uapi/linux/dvb/ca.h, line 46
  • CA_CI_MODULE_READY: include/uapi/linux/dvb/ca.h, line 47
  • CA_CI_PHYS: include/uapi/linux/dvb/ca.h, line 41
  • CA_DESCR: include/uapi/linux/dvb/ca.h, line 42
  • CA_DSS: include/uapi/linux/dvb/ca.h, line 70
  • CA_ECD: include/uapi/linux/dvb/ca.h, line 68
  • CA_NDS: include/uapi/linux/dvb/ca.h, line 69
  • CA_SC: include/uapi/linux/dvb/ca.h, line 43

Structures #

  • ca_caps: include/uapi/linux/dvb/ca.h, line 83
  • ca_descr: include/uapi/linux/dvb/ca.h, line 114
  • ca_descr_info: include/uapi/linux/dvb/ca.h, line 65
  • ca_msg: include/uapi/linux/dvb/ca.h, line 100
  • ca_slot_info: include/uapi/linux/dvb/ca.h, line 36

Type Definitions #

  • ca_caps_t: include/uapi/linux/dvb/ca.h, line 133
  • ca_descr_info_t: include/uapi/linux/dvb/ca.h, line 132
  • ca_descr_t: include/uapi/linux/dvb/ca.h, line 135
  • ca_msg_t: include/uapi/linux/dvb/ca.h, line 134
  • ca_slot_info_t: include/uapi/linux/dvb/ca.h, line 131

Network #

IOCTL Commands #

  • NET_ADD_IF: include/uapi/linux/dvb/net.h, line 39
  • NET_GET_IF: include/uapi/linux/dvb/net.h, line 41
  • NET_REMOVE_IF: include/uapi/linux/dvb/net.h, line 40

Macros and Definitions #

  • DVB_NET_FEEDTYPE_MPE: include/uapi/linux/dvb/net.h, line 34
  • DVB_NET_FEEDTYPE_ULE: include/uapi/linux/dvb/net.h, line 35

Structures #

  • dvb_net_if: include/uapi/linux/dvb/net.h, line 30

Introduction

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

What you need to know #

The reader of this document is required to have some knowledge in the area of digital video broadcasting (Digital TV) and should be familiar with part I of the MPEG2 specification ISO/IEC 13818 (aka ITU-T H.222), i.e you should know what a program/transport stream (PS/TS) is and what is meant by a packetized elementary stream (PES) or an I-frame.

Various Digital TV standards documents are available for download at:

  • European standards (DVB): http://www.dvb.org and/or http://www.etsi.org.

  • American standards (ATSC): https://www.atsc.org/standards/

  • Japanese standards (ISDB): http://www.dibeg.org/

It is also necessary to know how to access Linux devices and how to use ioctl calls. This also includes the knowledge of C or C++.

History #

The first API for Digital TV cards we used at Convergence in late 1999 was an extension of the Video4Linux API which was primarily developed for frame grabber cards. As such it was not really well suited to be used for Digital TV cards and their new features like recording MPEG streams and filtering several section and PES data streams at the same time.

In early 2000, Convergence was approached by Nokia with a proposal for a new standard Linux Digital TV API. As a commitment to the development of terminals based on open standards, Nokia and Convergence made it available to all Linux developers and published it on https://linuxtv.org in September 2000. With the Linux driver for the Siemens/Hauppauge DVB PCI card, Convergence provided a first implementation of the Linux Digital TV API. Convergence was the maintainer of the Linux Digital TV API in the early days.

Now, the API is maintained by the LinuxTV community (i.e. you, the reader of this document). The Linux Digital TV API is constantly reviewed and improved together with the improvements at the subsystem's core at the Kernel.

Overview #

dvbstb.svg

Components of a Digital TV card/STB

A Digital TV card or set-top-box (STB) usually consists of the following main hardware components:

  • Frontend consisting of tuner and digital TV demodulator

    Here the raw signal reaches the digital TV hardware from a satellite dish or antenna or directly from cable. The frontend down-converts and demodulates this signal into an MPEG transport stream (TS). In case of a satellite frontend, this includes a facility for satellite equipment control (SEC), which allows control of LNB polarization, multi feed switches or dish rotors.

  • Conditional Access (CA) hardware like CI adapters and smartcard slots

    The complete TS is passed through the CA hardware. Programs to which the user has access (controlled by the smart card) are decoded in real time and re-inserted into the TS.

    Note

    Not every digital TV hardware provides conditional access hardware.

  • Demultiplexer which filters the incoming Digital TV MPEG-TS stream

    The demultiplexer splits the TS into its components like audio and video streams. Besides usually several of such audio and video streams it also contains data streams with information about the programs offered in this or other streams of the same provider.

  • Audio and video decoder

    The main targets of the demultiplexer are audio and video decoders. After decoding, they pass on the uncompressed audio and video to the computer screen or to a TV set.

    Note

    Modern hardware usually doesn't have a separate decoder hardware, as such functionality can be provided by the main CPU, by the graphics adapter of the system or by a signal processing hardware embedded on a Systems on a Chip (SoC) integrated circuit.

    It may also not be needed for certain usages (e.g. for data-only uses like "internet over satellite").

stb_components shows a crude schematic of the control and data flow between those components.

Linux Digital TV Devices #

The Linux Digital TV API lets you control these hardware components through currently six Unix-style character devices for video, audio, frontend, demux, CA and IP-over-DVB networking. The video and audio devices control the MPEG2 decoder hardware, the frontend device the tuner and the Digital TV demodulator. The demux device gives you control over the PES and section filters of the hardware. If the hardware does not support filtering, these filters can be implemented in software. Finally, the CA device controls all the conditional access capabilities of the hardware. It can depend on the individual security requirements of the platform, if and how many of the CA functions are made available to the application through this device.

All devices can be found in the /dev tree under /dev/dvb. The individual devices are called:

  • /dev/dvb/adapterN/audioM,

  • /dev/dvb/adapterN/videoM,

  • /dev/dvb/adapterN/frontendM,

  • /dev/dvb/adapterN/netM,

  • /dev/dvb/adapterN/demuxM,

  • /dev/dvb/adapterN/dvrM,

  • /dev/dvb/adapterN/caM,

where N enumerates the Digital TV cards in a system starting from 0, and M enumerates the devices of each type within each adapter, starting from 0, too. We will omit the "/dev/dvb/adapterN/" in the further discussion of these devices.

More details about the data structures and function calls of all the devices are described in the following chapters.

API include files #

For each of the Digital TV devices a corresponding include file exists. The Digital TV API include files should be included in application sources with a partial path like:

#include <linux/dvb/ca.h>

#include <linux/dvb/dmx.h>

#include <linux/dvb/frontend.h>

#include <linux/dvb/net.h>

To enable applications to support different API version, an additional include file linux/dvb/version.h exists, which defines the constant DVB_API_VERSION. This document describes DVB_API_VERSION 5.10.

Digital TV Deprecated APIs

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

The APIs described here should not be used on new drivers or applications.

The DVBv3 frontend API has issues with new delivery systems, including DVB-S2, DVB-T2, ISDB, etc.

Note

The APIs described here doesn't necessarily reflect the current code implementation, as this section of the document was written for DVB version 1, while the code reflects DVB version 3 implementation.

  • Digital TV Frontend legacy API (a. k. a. DVBv3)
  • Legacy DVB MPEG Decoder APIs

DVB Audio Device

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Note

Do not use in new drivers! See: General Notes

The DVB audio device controls the MPEG2 audio decoder of the DVB hardware. It can be accessed through /dev/dvb/adapter?/audio?. Data types and ioctl definitions can be accessed by including linux/dvb/audio.h in your application.

Please note that most DVB cards don’t have their own MPEG decoder, which results in the omission of the audio and video device.

These ioctls were also used by V4L2 to control MPEG decoders implemented in V4L2. The use of these ioctls for that purpose has been made obsolete and proper V4L2 ioctls or controls have been created to replace that functionality. Use V4L2 ioctls for new drivers!

Audio Data Types #

This section describes the structures, data types and defines used when talking to the audio device.


audio_stream_source_t #

Synopsis #

audio_stream_source_t
typedef enum {
AUDIO_SOURCE_DEMUX,
AUDIO_SOURCE_MEMORY
} audio_stream_source_t;

Constants #

AUDIO_SOURCE_DEMUX

Selects the demultiplexer (fed either by the frontend or the DVR device) as the source of the video stream.

AUDIO_SOURCE_MEMORY

Selects the stream from the application that comes through the write() system call.

Description #

The audio stream source is set through the AUDIO_SELECT_SOURCE call and can take the following values, depending on whether we are replaying from an internal (demux) or external (user write) source.

The data fed to the decoder is also controlled by the PID-filter. Output selection: dmx_output DMX_OUT_DECODER.


audio_play_state_t #

Synopsis #

audio_play_state_t
typedef enum {
    AUDIO_STOPPED,
    AUDIO_PLAYING,
    AUDIO_PAUSED
} audio_play_state_t;

Constants #

AUDIO_STOPPED

Audio is stopped.

AUDIO_PLAYING

Audio is currently playing.

AUDIO_PAUSE

Audio is frozen.

Description #

This values can be returned by the AUDIO_GET_STATUS call representing the state of audio playback.


audio_channel_select_t #

Synopsis #

audio_channel_select_t
typedef enum {
    AUDIO_STEREO,
    AUDIO_MONO_LEFT,
    AUDIO_MONO_RIGHT,
    AUDIO_MONO,
    AUDIO_STEREO_SWAPPED
} audio_channel_select_t;

Constants #

AUDIO_STEREO

Stereo.

AUDIO_MONO_LEFT

Mono, select left stereo channel as source.

AUDIO_MONO_RIGHT

Mono, select right stereo channel as source.

AUDIO_MONO

Mono source only.

AUDIO_STEREO_SWAPPED

Stereo, swap L & R.

Description #

The audio channel selected via AUDIO_CHANNEL_SELECT is determined by this value.


audio_mixer_t #

Synopsis #

audio_mixer
typedef struct audio_mixer {
    unsigned int volume_left;
    unsigned int volume_right;
} audio_mixer_t;

Variables #

unsigned int volume_left

Volume left channel. Valid range: 0 ... 255

unsigned int volume_right

Volume right channel. Valid range: 0 ... 255

Description #

This structure is used by the AUDIO_SET_MIXER call to set the audio volume.


audio_status #

Synopsis #

audio_status
typedef struct audio_status {
    int AV_sync_state;
    int mute_state;
    audio_play_state_t play_state;
    audio_stream_source_t stream_source;
    audio_channel_select_t channel_select;
    int bypass_mode;
    audio_mixer_t mixer_state;
} audio_status_t;

Variables #

int AV_sync_state

Shows if A/V synchronization is ON or OFF.

TRUE ( != 0 )

AV-sync ON.

FALSE ( == 0 )

AV-sync OFF.

int mute_state

Indicates if audio is muted or not.

TRUE ( != 0 )

mute audio

FALSE ( == 0 )

unmute audio

audio_play_state_t play_state

Current playback state.

audio_stream_source_t stream_source

Current source of the data.

int bypass_mode

Is the decoding of the current Audio stream in the DVB subsystem enabled or disabled.

TRUE ( != 0 )

Bypass disabled.

FALSE ( == 0 )

Bypass enabled.

audio_mixer_t mixer_state

Current volume settings.

Description #

The AUDIO_GET_STATUS call returns this structure as information about various states of the playback operation.


audio encodings #

Synopsis #

#define AUDIO_CAP_DTS    1
#define AUDIO_CAP_LPCM   2
#define AUDIO_CAP_MP1    4
#define AUDIO_CAP_MP2    8
#define AUDIO_CAP_MP3   16
#define AUDIO_CAP_AAC   32
#define AUDIO_CAP_OGG   64
#define AUDIO_CAP_SDDS 128
#define AUDIO_CAP_AC3  256

Constants #

AUDIO_CAP_DTS

The hardware accepts DTS audio tracks.

AUDIO_CAP_LPCM

The hardware accepts uncompressed audio with Linear Pulse-Code Modulation (LPCM)

AUDIO_CAP_MP1

The hardware accepts MPEG-1 Audio Layer 1.

AUDIO_CAP_MP2

The hardware accepts MPEG-1 Audio Layer 2. Also known as MUSICAM.

AUDIO_CAP_MP3

The hardware accepts MPEG-1 Audio Layer III. Commonly known as .mp3.

AUDIO_CAP_AAC

The hardware accepts AAC (Advanced Audio Coding).

AUDIO_CAP_OGG

The hardware accepts Vorbis audio tracks.

AUDIO_CAP_SDDS

The hardware accepts Sony Dynamic Digital Sound (SDDS).

AUDIO_CAP_AC3

The hardware accepts Dolby Digital ATSC A/52 audio. Also known as AC-3.

Description #

A call to AUDIO_GET_CAPABILITIES returns an unsigned integer with the following bits set according to the hardwares capabilities.


Audio Function Calls #

AUDIO_STOP #

Synopsis #

AUDIO_STOP
int ioctl(int fd, int request = AUDIO_STOP)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_STOP for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Audio Device to stop playing the current stream.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_PLAY #

Synopsis #

AUDIO_PLAY
int  ioctl(int fd, int request = AUDIO_PLAY)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_PLAY for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Audio Device to start playing an audio stream from the selected source.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_PAUSE #

Synopsis #

AUDIO_PAUSE
int  ioctl(int fd, int request = AUDIO_PAUSE)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_PAUSE for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call suspends the audio stream being played. Decoding and playing are paused. It is then possible to restart again decoding and playing process of the audio stream using AUDIO_CONTINUE command.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_CONTINUE #

Synopsis #

AUDIO_CONTINUE
int  ioctl(int fd, int request = AUDIO_CONTINUE)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_CONTINUE for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl restarts the decoding and playing process previously paused with AUDIO_PAUSE command.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_SELECT_SOURCE #

Synopsis #

AUDIO_SELECT_SOURCE
int ioctl(int fd, int request = AUDIO_SELECT_SOURCE,
audio_stream_source_t source)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SELECT_SOURCE for this command.

audio_stream_source_t source

Indicates the source that shall be used for the Audio stream.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call informs the audio device which source shall be used for the input data. The possible sources are demux or memory. If AUDIO_SOURCE_MEMORY is selected, the data is fed to the Audio Device through the write command. If AUDIO_SOURCE_DEMUX is selected, the data is directly transferred from the onboard demux-device to the decoder. Note: This only supports DVB-devices with one demux and one decoder so far.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_SET_MUTE #

Synopsis #

AUDIO_SET_MUTE
int  ioctl(int fd, int request = AUDIO_SET_MUTE, int state)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_MUTE for this command.

int state

Indicates if audio device shall mute or not.

TRUE ( != 0 )

mute audio

FALSE ( == 0 )

unmute audio

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl is for DVB devices only. To control a V4L2 decoder use the V4L2 ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD with the V4L2_DEC_CMD_START_MUTE_AUDIO flag instead.

This ioctl call asks the audio device to mute the stream that is currently being played.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_SET_AV_SYNC #

Synopsis #

AUDIO_SET_AV_SYNC
int  ioctl(int fd, int request = AUDIO_SET_AV_SYNC, int state)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_AV_SYNC for this command.

int state

Tells the DVB subsystem if A/V synchronization shall be ON or OFF.

TRUE ( != 0 )

AV-sync ON.

FALSE ( == 0 )

AV-sync OFF.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Audio Device to turn ON or OFF A/V synchronization.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_SET_BYPASS_MODE #

Synopsis #

AUDIO_SET_BYPASS_MODE
int ioctl(int fd, int request = AUDIO_SET_BYPASS_MODE, int mode)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_BYPASS_MODE for this command.

int mode

Enables or disables the decoding of the current Audio stream in the DVB subsystem.

TRUE ( != 0 )

Disable bypass

FALSE ( == 0 )

Enable bypass

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Audio Device to bypass the Audio decoder and forward the stream without decoding. This mode shall be used if streams that can’t be handled by the DVB system shall be decoded. Dolby DigitalTM streams are automatically forwarded by the DVB subsystem if the hardware can handle it.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_CHANNEL_SELECT #

Synopsis #

AUDIO_CHANNEL_SELECT
int ioctl(int fd, int request = AUDIO_CHANNEL_SELECT,
audio_channel_select_t)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_CHANNEL_SELECT for this command.

audio_channel_select_t ch

Select the output format of the audio (mono left/right, stereo).

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl is for DVB devices only. To control a V4L2 decoder use the V4L2 V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK control instead.

This ioctl call asks the Audio Device to select the requested channel if possible.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_GET_STATUS #

Synopsis #

AUDIO_GET_STATUS
int ioctl(int fd, int request = AUDIO_GET_STATUS,
struct audio_status *status)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_GET_STATUS for this command.

struct audio_status *status

Returns the current state of Audio Device.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Audio Device to return the current state of the Audio Device.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_GET_CAPABILITIES #

Synopsis #

AUDIO_GET_CAPABILITIES
int ioctl(int fd, int request = AUDIO_GET_CAPABILITIES,
unsigned int *cap)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_GET_CAPABILITIES for this command.

unsigned int *cap

Returns a bit array of supported sound formats. Bits are defined in audio encodings.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Audio Device to tell us about the decoding capabilities of the audio hardware.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_CLEAR_BUFFER #

Synopsis #

AUDIO_CLEAR_BUFFER
int  ioctl(int fd, int request = AUDIO_CLEAR_BUFFER)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_CLEAR_BUFFER for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Audio Device to clear all software and hardware buffers of the audio decoder device.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_SET_ID #

Synopsis #

AUDIO_SET_ID
int  ioctl(int fd, int request = AUDIO_SET_ID, int id)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_ID for this command.

int id

Audio sub-stream id.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl selects which sub-stream is to be decoded if a program or system stream is sent to the video device.

If no audio stream type is set the id has to be in range [0xC0,0xDF] for MPEG sound, in [0x80,0x87] for AC3 and in [0xA0,0xA7] for LPCM. See ITU-T H.222.0 | ISO/IEC 13818-1 for further description.

If the stream type is set with AUDIO_SET_STREAMTYPE, specifies the id just the sub-stream id of the audio stream and only the first 5 bits (& 0x1F) are recognized.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_SET_MIXER #

Synopsis #

AUDIO_SET_MIXER
int ioctl(int fd, int request = AUDIO_SET_MIXER, audio_mixer_t *mix)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_MIXER for this command.

audio_mixer_t *mix

Mixer settings.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl lets you adjust the mixer settings of the audio decoder.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


AUDIO_SET_STREAMTYPE #

Synopsis #

AUDIO_SET_STREAMTYPE
int  ioctl(fd, int request = AUDIO_SET_STREAMTYPE, int type)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_SET_STREAMTYPE for this command.

int type

Stream type.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl tells the driver which kind of audio stream to expect. This is useful if the stream offers several audio sub-streams like LPCM and AC3.

Stream types defined in ITU-T H.222.0 | ISO/IEC 13818-1 are used.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

EINVAL

Type is not a valid or supported stream type.


AUDIO_BILINGUAL_CHANNEL_SELECT #

Synopsis #

AUDIO_BILINGUAL_CHANNEL_SELECT
int ioctl(int fd, int request = AUDIO_BILINGUAL_CHANNEL_SELECT,
audio_channel_select_t)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals AUDIO_BILINGUAL_CHANNEL_SELECT for this command.

audio_channel_select_t ch

Select the output format of the audio (mono left/right, stereo).

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl has been replaced by the V4L2 V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK control for MPEG decoders controlled through V4L2.

This ioctl call asks the Audio Device to select the requested channel for bilingual streams if possible.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


open() #

Synopsis #

#include <fcntl.h>

int  open(const char *deviceName, int flags)

Arguments #

const char *deviceName

Name of specific audio device.

int flags

A bit-wise OR of the following flags:

O_RDONLY

read-only access

O_RDWR

read/write access

O_NONBLOCK

Open in non-blocking mode
(blocking mode is the default)

Description #

This system call opens a named audio device (e.g. /dev/dvb/adapter0/audio0) for subsequent use. When an open() call has succeeded, the device will be ready for use. The significance of blocking or non-blocking mode is described in the documentation for functions where there is a difference. It does not affect the semantics of the open() call itself. A device opened in blocking mode can later be put into non-blocking mode (and vice versa) using the F_SETFL command of the fcntl system call. This is a standard system call, documented in the Linux manual page for fcntl. Only one user can open the Audio Device in O_RDWR mode. All other attempts to open the device in this mode will fail, and an error code will be returned. If the Audio Device is opened in O_RDONLY mode, the only ioctl call that can be used is AUDIO_GET_STATUS. All other call will return with an error code.

Return Value #

ENODEV

Device driver not loaded/available.

EBUSY

Device or resource busy.

EINVAL

Invalid argument.


close() #

Synopsis #

int close(int fd)

Arguments #

int fd

File descriptor returned by a previous call to open().

Description #

This system call closes a previously opened audio device.

Return Value #

EBADF

Fd is not a valid open file descriptor.


write() #

Synopsis #

size_t write(int fd, const void *buf, size_t count)

Arguments #

int fd

File descriptor returned by a previous call to open().

void *buf

Pointer to the buffer containing the PES data.

size_t count

Size of buf.

Description #

This system call can only be used if AUDIO_SOURCE_MEMORY is selected in the ioctl call AUDIO_SELECT_SOURCE. The data provided shall be in PES format. If O_NONBLOCK is not specified the function will block until buffer space is available. The amount of data to be transferred is implied by count.

Return Value #

EPERM

Mode AUDIO_SOURCE_MEMORY not selected.

ENOMEM

Attempted to write more data than the internal buffer can hold.

EBADF

Fd is not a valid open file descriptor.

Legacy DVB MPEG Decoder APIs

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

General Notes #

This API has originally been designed for DVB only and is therefore limited to the Data Formats used in such digital TV-broadcastsystems.

To circumvent this limitations the more versatile V4L2 API has been designed. Which replaces this part of the DVB API.

Nevertheless there have been projects build around this API. To ensure compatibility this API is kept as it is.

Note

Do not use this API in new drivers!

For audio and video use the V4L2 and ALSA APIs.

Pipelines should be set up using the Media Controller API.

Practically the decoders seem to be treated differently. The application typically knows which decoder is in use or it is specially written for one decoder type. Querying capabilities are rarely used because they are already known.

Data Formats #

The API has been designed for DVB and compatible broadcastsystems. Because of that fact the only supported data formats are ISO/IEC 13818-1 compatible MPEG streams. The supported payloads may vary depending on the used decoder.

Timestamps are always MPEG PTS as defined in ITU T-REC-H.222.0 / ISO/IEC 13818-1, if not otherwise noted.

For storing recordings typically TS streams are used, in lesser extent PES. Both variants are commonly accepted for playback, but it may be driver dependent.

Table of Contents #

  • DVB Video Device
  • DVB Audio Device
  • DVB OSD Device

DVB OSD Device

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Note

Do not use in new drivers! See: General Notes

The DVB OSD device controls the OnScreen-Display of the AV7110 based DVB-cards with hardware MPEG2 decoder. It can be accessed through /dev/dvb/adapter?/osd0. Data types and ioctl definitions can be accessed by including linux/dvb/osd.h in your application.

The OSD is not a frame-buffer like on many other cards. It is a kind of canvas one can draw on. The color-depth is limited depending on the memory size installed. An appropriate palette of colors has to be set up. The installed memory size can be identified with the OSD_GET_CAPABILITY ioctl.

OSD Data Types #

OSD_Command #

Synopsis #

typedef enum {
    /* All functions return -2 on "not open" */
    OSD_Close = 1,
    OSD_Open,
    OSD_Show,
    OSD_Hide,
    OSD_Clear,
    OSD_Fill,
    OSD_SetColor,
    OSD_SetPalette,
    OSD_SetTrans,
    OSD_SetPixel,
    OSD_GetPixel,
    OSD_SetRow,
    OSD_SetBlock,
    OSD_FillRow,
    OSD_FillBlock,
    OSD_Line,
    OSD_Query,
    OSD_Test,
    OSD_Text,
    OSD_SetWindow,
    OSD_MoveWindow,
    OSD_OpenRaw,
} OSD_Command;

Commands #

Note

All functions return -2 on "not open"

Command

Used variables of struct osd_cmd_t.
Usage{variable} if alternative use.

Description

OSD_Close

Disables OSD and releases the buffers.
Returns 0 on success.

OSD_Open

x0,y0,x1,y1,
BitPerPixel[2/4/8]{color&0x0F},
mix[0..15]{color&0xF0}

Opens OSD with this size and bit depth
Returns 0 on success,
-1 on DRAM allocation error,
-2 on "already open".

OSD_Show

Enables OSD mode.
Returns 0 on success.

OSD_Hide

Disables OSD mode.
Returns 0 on success.

OSD_Clear

Sets all pixel to color 0.
Returns 0 on success.

OSD_Fill

color

Sets all pixel to color <color>.
Returns 0 on success.

OSD_SetColor

color,
R{x0},G{y0},B{x1},
opacity{y1}

Set palette entry <num> to <r,g,b>, <mix> and <trans> apply
R,G,B: 0..255
R=Red, G=Green, B=Blue
opacity=0: pixel opacity 0% (only video pixel shows)
opacity=1..254: pixel opacity as specified in header
opacity=255: pixel opacity 100% (only OSD pixel shows)
Returns 0 on success, -1 on error.

OSD_SetPalette

firstcolor{color},
lastcolor{x0},data

Set a number of entries in the palette.
Sets the entries "firstcolor" through "lastcolor" from the array "data".
Data has 4 byte for each color:
R,G,B, and a opacity value: 0->transparent, 1..254->mix, 255->pixel

OSD_SetTrans

transparency{color}

Sets transparency of mixed pixel (0..15).
Returns 0 on success.

OSD_SetPixel

x0,y0,color

Sets pixel <x>,<y> to color number <color>.
Returns 0 on success, -1 on error.

OSD_GetPixel

x0,y0

Returns color number of pixel <x>,<y>, or -1.
Command currently not supported by the AV7110!

OSD_SetRow

x0,y0,x1,data

Fills pixels x0,y through x1,y with the content of data[].
Returns 0 on success, -1 on clipping all pixel (no pixel drawn).

OSD_SetBlock

x0,y0,x1,y1,
increment{color},
data

Fills pixels x0,y0 through x1,y1 with the content of data[].
Inc contains the width of one line in the data block,
inc<=0 uses block width as line width.
Returns 0 on success, -1 on clipping all pixel.

OSD_FillRow

x0,y0,x1,color

Fills pixels x0,y through x1,y with the color <color>.
Returns 0 on success, -1 on clipping all pixel.

OSD_FillBlock

x0,y0,x1,y1,color

Fills pixels x0,y0 through x1,y1 with the color <color>.
Returns 0 on success, -1 on clipping all pixel.

OSD_Line

x0,y0,x1,y1,color

Draw a line from x0,y0 to x1,y1 with the color <color>.
Returns 0 on success.

OSD_Query

x0,y0,x1,y1,
xasp{color}; yasp=11

Fills parameters with the picture dimensions and the pixel aspect ratio.
Returns 0 on success.
Command currently not supported by the AV7110!

OSD_Test

Draws a test picture.
For debugging purposes only.
Returns 0 on success.

OSD_Text

x0,y0,size,color,text

Draws a text at position x0,y0 with the color <color>.

OSD_SetWindow

x0

Set window with number 0<x0<8 as current.

OSD_MoveWindow

x0,y0

Move current window to (x0, y0).

OSD_OpenRaw

x0,y0,x1,y1,
osd_raw_window_t {color}

Open other types of OSD windows.

Description #

The OSD_Command data type is used with the OSD_SEND_CMD ioctl to tell the driver which OSD_Command to execute.


osd_cmd_t #

Synopsis #

typedef struct osd_cmd_s {
    OSD_Command cmd;
    int x0;
    int y0;
    int x1;
    int y1;
    int color;
    void __user *data;
} osd_cmd_t;

Variables #

OSD_Command cmd

OSD_Command to be executed.

int x0

First horizontal position.

int y0

First vertical position.

int x1

Second horizontal position.

int y1

Second vertical position.

int color

Number of the color in the palette.

void __user *data

Command specific Data.

Description #

The osd_cmd_t data type is used with the OSD_SEND_CMD ioctl. It contains the data for the OSD_Command and the OSD_Command itself. The structure has to be passed to the driver and the components may be modified by it.


osd_raw_window_t #

Synopsis #

typedef enum {
    OSD_BITMAP1,
    OSD_BITMAP2,
    OSD_BITMAP4,
    OSD_BITMAP8,
    OSD_BITMAP1HR,
    OSD_BITMAP2HR,
    OSD_BITMAP4HR,
    OSD_BITMAP8HR,
    OSD_YCRCB422,
    OSD_YCRCB444,
    OSD_YCRCB444HR,
    OSD_VIDEOTSIZE,
    OSD_VIDEOHSIZE,
    OSD_VIDEOQSIZE,
    OSD_VIDEODSIZE,
    OSD_VIDEOTHSIZE,
    OSD_VIDEOTQSIZE,
    OSD_VIDEOTDSIZE,
    OSD_VIDEONSIZE,
    OSD_CURSOR
} osd_raw_window_t;

Constants #

OSD_BITMAP1

1 bit bitmap

OSD_BITMAP2

2 bit bitmap

OSD_BITMAP4

4 bit bitmap

OSD_BITMAP8

8 bit bitmap

OSD_BITMAP1HR

1 Bit bitmap half resolution

OSD_BITMAP2HR

2 Bit bitmap half resolution

OSD_BITMAP4HR

4 Bit bitmap half resolution

OSD_BITMAP8HR

8 Bit bitmap half resolution

OSD_YCRCB422

4:2:2 YCRCB Graphic Display

OSD_YCRCB444

4:4:4 YCRCB Graphic Display

OSD_YCRCB444HR

4:4:4 YCRCB graphic half resolution

OSD_VIDEOTSIZE

True Size Normal MPEG Video Display

OSD_VIDEOHSIZE

MPEG Video Display Half Resolution

OSD_VIDEOQSIZE

MPEG Video Display Quarter Resolution

OSD_VIDEODSIZE

MPEG Video Display Double Resolution

OSD_VIDEOTHSIZE

True Size MPEG Video Display Half Resolution

OSD_VIDEOTQSIZE

True Size MPEG Video Display Quarter Resolution

OSD_VIDEOTDSIZE

True Size MPEG Video Display Double Resolution

OSD_VIDEONSIZE

Full Size MPEG Video Display

OSD_CURSOR

Cursor

Description #

The osd_raw_window_t data type is used with the OSD_Command OSD_OpenRaw to tell the driver which type of OSD to open.


osd_cap_t #

Synopsis #

typedef struct osd_cap_s {
    int  cmd;
#define OSD_CAP_MEMSIZE         1
    long val;
} osd_cap_t;

Variables #

int cmd

Capability to query.

long val

Used to store the Data.

Supported capabilities #

OSD_CAP_MEMSIZE

Memory size installed on the card.

Description #

This structure of data used with the OSD_GET_CAPABILITY call.


OSD Function Calls #

OSD_SEND_CMD #

Synopsis #

OSD_SEND_CMD
int ioctl(int fd, int request = OSD_SEND_CMD, enum osd_cmd_t *cmd)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Pointer to the location of the structure osd_cmd_t for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl sends the OSD_Command to the card.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

EINVAL

Command is out of range.


OSD_GET_CAPABILITY #

Synopsis #

OSD_GET_CAPABILITY
int ioctl(int fd, int request = OSD_GET_CAPABILITY,
struct osd_cap_t *cap)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals OSD_GET_CAPABILITY for this command.

unsigned int *cap

Pointer to the location of the structure osd_cap_t for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl is used to get the capabilities of the OSD of the AV7110 based DVB-decoder-card in use.

Note

The structure osd_cap_t has to be setup by the user and passed to the driver.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

EINVAL

Unsupported capability.


open() #

Synopsis #

#include <fcntl.h>

int open(const char *deviceName, int flags)

Arguments #

const char *deviceName

Name of specific OSD device.

int flags

A bit-wise OR of the following flags:

O_RDONLY

read-only access

O_RDWR

read/write access

O_NONBLOCK

Open in non-blocking mode
(blocking mode is the default)

Description #

This system call opens a named OSD device (e.g. /dev/dvb/adapter?/osd0) for subsequent use.

Return Value #

ENODEV

Device driver not loaded/available.

EINTERNAL

Internal error.

EBUSY

Device or resource busy.

EINVAL

Invalid argument.


close() #

Synopsis #

int close(int fd)

Arguments #

int fd

File descriptor returned by a previous call to open() .

Description #

This system call closes a previously opened OSD device.

Return Value #

EBADF

fd is not a valid open file descriptor.

DVB Video Device

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Note

Do not use in new drivers! See: General Notes

The DVB video device controls the MPEG2 video decoder of the DVB hardware. It can be accessed through /dev/dvb/adapter0/video0. Data types and ioctl definitions can be accessed by including linux/dvb/video.h in your application.

Note that the DVB video device only controls decoding of the MPEG video stream, not its presentation on the TV or computer screen. On PCs this is typically handled by an associated video4linux device, e.g. /dev/video, which allows scaling and defining output windows.

Most DVB cards don’t have their own MPEG decoder, which results in the omission of the audio and video device as well as the video4linux device.

These ioctls were also used by V4L2 to control MPEG decoders implemented in V4L2. The use of these ioctls for that purpose has been made obsolete and proper V4L2 ioctls or controls have been created to replace that functionality. Use V4L2 ioctls for new drivers!

Video Data Types #

video_format_t #

Synopsis #

typedef enum {
    VIDEO_FORMAT_4_3,
    VIDEO_FORMAT_16_9,
    VIDEO_FORMAT_221_1
} video_format_t;

Constants #

VIDEO_FORMAT_4_3

Select 4:3 format.

VIDEO_FORMAT_16_9

Select 16:9 format.

VIDEO_FORMAT_221_1

Select 2.21:1 format.

Description #

The video_format_t data type is used in the VIDEO_SET_FORMAT function to tell the driver which aspect ratio the output hardware (e.g. TV) has. It is also used in the data structures video_status returned by VIDEO_GET_STATUS and video_event returned by VIDEO_GET_EVENT which report about the display format of the current video stream.


video_displayformat_t #

Synopsis #

typedef enum {
    VIDEO_PAN_SCAN,
    VIDEO_LETTER_BOX,
    VIDEO_CENTER_CUT_OUT
} video_displayformat_t;

Constants #

VIDEO_PAN_SCAN

Use pan and scan format.

VIDEO_LETTER_BOX

Use letterbox format.

VIDEO_CENTER_CUT_OUT

Use center cut out format.

Description #

In case the display format of the video stream and of the display hardware differ the application has to specify how to handle the cropping of the picture. This can be done using the VIDEO_SET_DISPLAY_FORMAT call which accepts this enum as argument.


video_size_t #

Synopsis #

typedef struct {
    int w;
    int h;
    video_format_t aspect_ratio;
} video_size_t;

Variables #

int w

Video width in pixels.

int h

Video height in pixels.

video_format_t aspect_ratio

Aspect ratio.

Description #

Used in the struct video_event. It stores the resolution and aspect ratio of the video.


video_stream_source_t #

Synopsis #

typedef enum {
    VIDEO_SOURCE_DEMUX,
    VIDEO_SOURCE_MEMORY
} video_stream_source_t;

Constants #

VIDEO_SOURCE_DEMUX

Select the demux as the main source.

VIDEO_SOURCE_MEMORY

If this source is selected, the stream comes from the user through the write system call.

Description #

The video stream source is set through the VIDEO_SELECT_SOURCE call and can take the following values, depending on whether we are replaying from an internal (demuxer) or external (user write) source. VIDEO_SOURCE_DEMUX selects the demultiplexer (fed either by the frontend or the DVR device) as the source of the video stream. If VIDEO_SOURCE_MEMORY is selected the stream comes from the application through the write() system call.


video_play_state_t #

Synopsis #

typedef enum {
    VIDEO_STOPPED,
    VIDEO_PLAYING,
    VIDEO_FREEZED
} video_play_state_t;

Constants #

VIDEO_STOPPED

Video is stopped.

VIDEO_PLAYING

Video is currently playing.

VIDEO_FREEZED

Video is frozen.

Description #

This values can be returned by the VIDEO_GET_STATUS call representing the state of video playback.


struct video_command #

Synopsis #

struct video_command {
    __u32 cmd;
    __u32 flags;
    union {
        struct {
            __u64 pts;
        } stop;

        struct {
            __s32 speed;
            __u32 format;
        } play;

        struct {
            __u32 data[16];
        } raw;
    };
};

Variables #

__u32 cmd

Decoder command

__u32 flags

Flags for the Decoder command.

struct stop

__u64 pts

MPEG PTS

stuct play

__s32 speed

0 or 1000 specifies normal speed,

1: specifies forward single stepping,

-1: specifies backward single stepping,

>1: playback at speed / 1000 of the normal speed

<-1: reverse playback at ( -speed / 1000 ) of the normal speed.

__u32 format

Play input formats

__u32 data[16]

Reserved

Description #

The structure must be zeroed before use by the application. This ensures it can be extended safely in the future.


Predefined decoder commands and flags #

Synopsis #

#define VIDEO_CMD_PLAY                      (0)
#define VIDEO_CMD_STOP                      (1)
#define VIDEO_CMD_FREEZE                    (2)
#define VIDEO_CMD_CONTINUE                  (3)

#define VIDEO_CMD_FREEZE_TO_BLACK      (1 << 0)

#define VIDEO_CMD_STOP_TO_BLACK        (1 << 0)
#define VIDEO_CMD_STOP_IMMEDIATELY     (1 << 1)

#define VIDEO_PLAY_FMT_NONE                 (0)
#define VIDEO_PLAY_FMT_GOP                  (1)

#define VIDEO_VSYNC_FIELD_UNKNOWN           (0)
#define VIDEO_VSYNC_FIELD_ODD               (1)
#define VIDEO_VSYNC_FIELD_EVEN              (2)
#define VIDEO_VSYNC_FIELD_PROGRESSIVE       (3)

Constants #

VIDEO_CMD_PLAY

Start playback.

VIDEO_CMD_STOP

Stop playback.

VIDEO_CMD_FREEZE

Freeze playback.

VIDEO_CMD_CONTINUE

Continue playback after freeze.

Flags for VIDEO_CMD_FREEZE

VIDEO_CMD_FREEZE_TO_BLACK

Show black picture on freeze.

Flags for VIDEO_CMD_STOP

VIDEO_CMD_STOP_TO_BLACK

Show black picture on stop.

VIDEO_CMD_STOP_IMMEDIATELY

Stop immediately, without emptying buffers.

VIDEO_PLAY_FMT_NONE

The decoder has no special format requirements

VIDEO_PLAY_FMT_GOP

The decoder requires full GOPs

Field order

VIDEO_VSYNC_FIELD_UNKNOWN

FIELD_UNKNOWN can be used if the hardware does not know whether the Vsync is for an odd, even or progressive (i.e. non-interlaced) field.

VIDEO_VSYNC_FIELD_ODD

Vsync is for an odd field.

VIDEO_VSYNC_FIELD_EVEN

Vsync is for an even field.

VIDEO_VSYNC_FIELD_PROGRESSIVE

progressive (i.e. non-interlaced)


video_event #

Synopsis #

struct video_event {
    __s32 type;
#define VIDEO_EVENT_SIZE_CHANGED        1
#define VIDEO_EVENT_FRAME_RATE_CHANGED  2
#define VIDEO_EVENT_DECODER_STOPPED     3
#define VIDEO_EVENT_VSYNC               4
    long timestamp;
    union {
        video_size_t size;
        unsigned int frame_rate;
        unsigned char vsync_field;
    } u;
};

Variables #

__s32 type

Event type.

VIDEO_EVENT_SIZE_CHANGED

Size changed.

VIDEO_EVENT_FRAME_RATE_CHANGED

Framerate changed.

VIDEO_EVENT_DECODER_STOPPED

Decoder stopped.

VIDEO_EVENT_VSYNC

Vsync occurred.

long timestamp

MPEG PTS at occurrence.

union u

video_size_t size

Resolution and aspect ratio of the video.

unsigned int frame_rate

in frames per 1000sec

unsigned char vsync_field

unknown / odd / even / progressive
See: Predefined decoder commands and flags

Description #

This is the structure of a video event as it is returned by the VIDEO_GET_EVENT call. See there for more details.


video_status #

Synopsis #

The VIDEO_GET_STATUS call returns the following structure informing about various states of the playback operation.

struct video_status {
    int                    video_blank;
    video_play_state_t     play_state;
    video_stream_source_t  stream_source;
    video_format_t         video_format;
    video_displayformat_t  display_format;
};

Variables #

int video_blank

Show blank video on freeze?

TRUE ( != 0 )

Blank screen when freeze.

FALSE ( == 0 )

Show last decoded frame.

video_play_state_t play_state

Current state of playback.

video_stream_source_t stream_source

Current source (demux/memory).

video_format_t video_format

Current aspect ratio of stream.

video_displayformat_t display_format

Applied cropping mode.

Description #

If video_blank is set TRUE video will be blanked out if the channel is changed or if playback is stopped. Otherwise, the last picture will be displayed. play_state indicates if the video is currently frozen, stopped, or being played back. The stream_source corresponds to the selected source for the video stream. It can come either from the demultiplexer or from memory. The video_format indicates the aspect ratio (one of 4:3 or 16:9) of the currently played video stream. Finally, display_format corresponds to the applied cropping mode in case the source video format is not the same as the format of the output device.


video_still_picture #

Synopsis #

struct video_still_picture {
char *iFrame;
int32_t size;
};

Variables #

char *iFrame

Pointer to a single iframe in memory.

int32_t size

Size of the iframe.

Description #

An I-frame displayed via the VIDEO_STILLPICTURE call is passed on within this structure.


video capabilities #

Synopsis #

#define VIDEO_CAP_MPEG1   1
#define VIDEO_CAP_MPEG2   2
#define VIDEO_CAP_SYS     4
#define VIDEO_CAP_PROG    8

Constants #

Bit definitions for capabilities:

VIDEO_CAP_MPEG1

The hardware can decode MPEG1.

VIDEO_CAP_MPEG2

The hardware can decode MPEG2.

VIDEO_CAP_SYS

The video device accepts system stream.

You still have to open the video and the audio device but only send the stream to the video device.

VIDEO_CAP_PROG

The video device accepts program stream.

You still have to open the video and the audio device but only send the stream to the video device.

Description #

A call to VIDEO_GET_CAPABILITIES returns an unsigned integer with the following bits set according to the hardware's capabilities.


Video Function Calls #

VIDEO_STOP #

Synopsis #

VIDEO_STOP
int ioctl(fd, VIDEO_STOP, int mode)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_STOP for this command.

int mode

Indicates how the screen shall be handled.

TRUE ( != 0 )

Blank screen when stop.

FALSE ( == 0 )

Show last decoded frame.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl is for Digital TV devices only. To control a V4L2 decoder use the V4L2 ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD instead.

This ioctl call asks the Video Device to stop playing the current stream. Depending on the input parameter, the screen can be blanked out or displaying the last decoded frame.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_PLAY #

Synopsis #

VIDEO_PLAY
int ioctl(fd, VIDEO_PLAY)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_PLAY for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl is for Digital TV devices only. To control a V4L2 decoder use the V4L2 ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD instead.

This ioctl call asks the Video Device to start playing a video stream from the selected source.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_FREEZE #

Synopsis #

VIDEO_FREEZE
int ioctl(fd, VIDEO_FREEZE)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_FREEZE for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl is for Digital TV devices only. To control a V4L2 decoder use the V4L2 ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD instead.

This ioctl call suspends the live video stream being played, if VIDEO_SOURCE_DEMUX is selected. Decoding and playing are frozen. It is then possible to restart the decoding and playing process of the video stream using the VIDEO_CONTINUE command. If VIDEO_SOURCE_MEMORY is selected in the ioctl call VIDEO_SELECT_SOURCE, the Digital TV subsystem will not decode any more data until the ioctl call VIDEO_CONTINUE or VIDEO_PLAY is performed.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_CONTINUE #

Synopsis #

VIDEO_CONTINUE
int ioctl(fd, VIDEO_CONTINUE)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_CONTINUE for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl is for Digital TV devices only. To control a V4L2 decoder use the V4L2 ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD instead.

This ioctl call restarts decoding and playing processes of the video stream which was played before a call to VIDEO_FREEZE was made.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_SELECT_SOURCE #

Synopsis #

VIDEO_SELECT_SOURCE
int ioctl(fd, VIDEO_SELECT_SOURCE, video_stream_source_t source)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_SELECT_SOURCE for this command.

video_stream_source_t source

Indicates which source shall be used for the Video stream.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl is for Digital TV devices only. This ioctl was also supported by the V4L2 ivtv driver, but that has been replaced by the ivtv-specific IVTV_IOC_PASSTHROUGH_MODE ioctl.

This ioctl call informs the video device which source shall be used for the input data. The possible sources are demux or memory. If memory is selected, the data is fed to the video device through the write command using the struct video_stream_source_t. If demux is selected, the data is directly transferred from the onboard demux-device to the decoder.

The data fed to the decoder is also controlled by the PID-filter. Output selection: dmx_output DMX_OUT_DECODER.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_SET_BLANK #

Synopsis #

VIDEO_SET_BLANK
int ioctl(fd, VIDEO_SET_BLANK, int mode)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_SET_BLANK for this command.

int mode

Indicates if the screen shall be blanked.

TRUE ( != 0 )

Blank screen when stop.

FALSE ( == 0 )

Show last decoded frame.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Video Device to blank out the picture.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_GET_STATUS #

Synopsis #

VIDEO_GET_STATUS
int ioctl(fd, int request = VIDEO_GET_STATUS,
struct video_status *status)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_GET_STATUS for this command.

struct video_status *status

Returns the current status of the Video Device.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Video Device to return the current status of the device.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_GET_EVENT #

Synopsis #

VIDEO_GET_EVENT
int ioctl(fd, int request = VIDEO_GET_EVENT,
struct video_event *ev)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_GET_EVENT for this command.

struct video_event *ev

Points to the location where the event, if any, is to be stored.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl is for DVB devices only. To get events from a V4L2 decoder use the V4L2 ioctl VIDIOC_DQEVENT ioctl instead.

This ioctl call returns an event of type video_event if available. A certain number of the latest events will be cued and returned in order of occurrence. Older events may be discarded if not fetched in time. If an event is not available, the behavior depends on whether the device is in blocking or non-blocking mode. In the latter case, the call fails immediately with errno set to EWOULDBLOCK. In the former case, the call blocks until an event becomes available. The standard Linux poll() and/or select() system calls can be used with the device file descriptor to watch for new events. For select(), the file descriptor should be included in the exceptfds argument, and for poll(), POLLPRI should be specified as the wake-up condition. Read-only permissions are sufficient for this ioctl call.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

EWOULDBLOCK

There is no event pending, and the device is in non-blocking mode.

EOVERFLOW

Overflow in event queue - one or more events were lost.


VIDEO_SET_DISPLAY_FORMAT #

Synopsis #

VIDEO_SET_DISPLAY_FORMAT
int ioctl(fd, int request = VIDEO_SET_DISPLAY_FORMAT,
video_display_format_t format)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_SET_DISPLAY_FORMAT for this command.

video_displayformat_t format

Selects the video format to be used.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Video Device to select the video format to be applied by the MPEG chip on the video.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_STILLPICTURE #

Synopsis #

VIDEO_STILLPICTURE
int ioctl(fd, int request = VIDEO_STILLPICTURE,
struct video_still_picture *sp)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_STILLPICTURE for this command.

struct video_still_picture *sp

Pointer to the location where the struct with the I-frame and size is stored.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Video Device to display a still picture (I-frame). The input data shall be the section of an elementary video stream containing an I-frame. Typically this section is extracted from a TS or PES recording. Resolution and codec (see video capabilities) must be supported by the device. If the pointer is NULL, then the current displayed still picture is blanked.

e.g. The AV7110 supports MPEG1 and MPEG2 with the common PAL-SD resolutions.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_FAST_FORWARD #

Synopsis #

VIDEO_FAST_FORWARD
int ioctl(fd, int request = VIDEO_FAST_FORWARD, int nFrames)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_FAST_FORWARD for this command.

int nFrames

The number of frames to skip.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the Video Device to skip decoding of N number of I-frames. This call can only be used if VIDEO_SOURCE_MEMORY is selected.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

EPERM

Mode VIDEO_SOURCE_MEMORY not selected.


VIDEO_SLOWMOTION #

Synopsis #

VIDEO_SLOWMOTION
int ioctl(fd, int request = VIDEO_SLOWMOTION, int nFrames)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_SLOWMOTION for this command.

int nFrames

The number of times to repeat each frame.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the video device to repeat decoding frames N number of times. This call can only be used if VIDEO_SOURCE_MEMORY is selected.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.

EPERM

Mode VIDEO_SOURCE_MEMORY not selected.


VIDEO_GET_CAPABILITIES #

Synopsis #

VIDEO_GET_CAPABILITIES
int ioctl(fd, int request = VIDEO_GET_CAPABILITIES, unsigned int *cap)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_GET_CAPABILITIES for this command.

unsigned int *cap

Pointer to a location where to store the capability information.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call asks the video device about its decoding capabilities. On success it returns an integer which has bits set according to the defines in video capabilities.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_CLEAR_BUFFER #

Synopsis #

VIDEO_CLEAR_BUFFER
int ioctl(fd, int request = VIDEO_CLEAR_BUFFER)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_CLEAR_BUFFER for this command.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl call clears all video buffers in the driver and in the decoder hardware.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_SET_STREAMTYPE #

Synopsis #

VIDEO_SET_STREAMTYPE
int ioctl(fd, int request = VIDEO_SET_STREAMTYPE, int type)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_SET_STREAMTYPE for this command.

int type

Stream type.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl tells the driver which kind of stream to expect being written to it. Intelligent decoder might also not support or ignore (like the AV7110) this call and determine the stream type themselves.

Currently used stream types:

Codec

Stream type

MPEG2

0

MPEG4 h.264

1

VC1

3

MPEG4 Part2

4

VC1 SM

5

MPEG1

6

HEVC h.265

7
DREAMBOX: 22

AVS

16

AVS2

40

Not every decoder supports all stream types.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_SET_FORMAT #

Synopsis #

VIDEO_SET_FORMAT
int ioctl(fd, int request = VIDEO_SET_FORMAT, video_format_t format)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_SET_FORMAT for this command.

video_format_t format

Video format of TV as defined in section video_format_t.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl sets the screen format (aspect ratio) of the connected output device (TV) so that the output of the decoder can be adjusted accordingly.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_GET_SIZE #

Synopsis #

VIDEO_GET_SIZE
int ioctl(int fd, int request = VIDEO_GET_SIZE, video_size_t *size)

Arguments #

int fd

File descriptor returned by a previous call, to open().

int request

Equals VIDEO_GET_SIZE for this command.

video_size_t *size

Returns the size and aspect ratio.

Description #

Note

Do not use in new drivers! See: General Notes

This ioctl returns the size and aspect ratio.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_GET_PTS #

Synopsis #

VIDEO_GET_PTS
int ioctl(int fd, int request = VIDEO_GET_PTS, __u64 *pts)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_GET_PTS for this command.

__u64 *pts

Returns the 33-bit timestamp as defined in ITU T-REC-H.222.0 / ISO/IEC 13818-1.

The PTS should belong to the currently played frame if possible, but may also be a value close to it like the PTS of the last decoded frame or the last PTS extracted by the PES parser.

Description #

Note

Do not use in new drivers! See: General Notes

For V4L2 decoders this ioctl has been replaced by the V4L2_CID_MPEG_VIDEO_DEC_PTS control.

This ioctl call asks the Video Device to return the current PTS timestamp.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_GET_FRAME_COUNT #

Synopsis #

VIDEO_GET_FRAME_COUNT
int ioctl(int fd, VIDEO_GET_FRAME_COUNT, __u64 *pts)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_GET_FRAME_COUNT for this command.

__u64 *pts

Returns the number of frames displayed since the decoder was started.

Description #

Note

Do not use in new drivers! See: General Notes

For V4L2 decoders this ioctl has been replaced by the V4L2_CID_MPEG_VIDEO_DEC_FRAME control.

This ioctl call asks the Video Device to return the number of displayed frames since the decoder was started.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_COMMAND #

Synopsis #

VIDEO_COMMAND
int ioctl(int fd, int request = VIDEO_COMMAND,
struct video_command *cmd)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_COMMAND for this command.

struct video_command *cmd

Commands the decoder.

Description #

Note

Do not use in new drivers! See: General Notes

For V4L2 decoders this ioctl has been replaced by the ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD ioctl.

This ioctl commands the decoder. The struct video_command is a subset of the v4l2_decoder_cmd struct, so refer to the ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD documentation for more information.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


VIDEO_TRY_COMMAND #

Synopsis #

VIDEO_TRY_COMMAND
int ioctl(int fd, int request = VIDEO_TRY_COMMAND,
struct video_command *cmd)

Arguments #

int fd

File descriptor returned by a previous call to open().

int request

Equals VIDEO_TRY_COMMAND for this command.

struct video_command *cmd

Try a decoder command.

Description #

Note

Do not use in new drivers! See: General Notes

For V4L2 decoders this ioctl has been replaced by the VIDIOC_TRY_DECODER_CMD ioctl.

This ioctl tries a decoder command. The struct video_command is a subset of the v4l2_decoder_cmd struct, so refer to the VIDIOC_TRY_DECODER_CMD documentation for more information.

Return Value #

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


open() #

Synopsis #

#include <fcntl.h>

int open(const char *deviceName, int flags)

Arguments #

const char *deviceName

Name of specific video device.

int flags

A bit-wise OR of the following flags:

O_RDONLY

read-only access

O_RDWR

read/write access

O_NONBLOCK

Open in non-blocking mode
(blocking mode is the default)

Description #

This system call opens a named video device (e.g. /dev/dvb/adapter?/video?) for subsequent use.

When an open() call has succeeded, the device will be ready for use. The significance of blocking or non-blocking mode is described in the documentation for functions where there is a difference. It does not affect the semantics of the open() call itself. A device opened in blocking mode can later be put into non-blocking mode (and vice versa) using the F_SETFL command of the fcntl system call. This is a standard system call, documented in the Linux manual page for fcntl. Only one user can open the Video Device in O_RDWR mode. All other attempts to open the device in this mode will fail, and an error-code will be returned. If the Video Device is opened in O_RDONLY mode, the only ioctl call that can be used is VIDEO_GET_STATUS. All other call will return an error code.

Return Value #

ENODEV

Device driver not loaded/available.

EINTERNAL

Internal error.

EBUSY

Device or resource busy.

EINVAL

Invalid argument.


close() #

Synopsis #

int close(int fd)

Arguments #

int fd

File descriptor returned by a previous call to open().

Description #

This system call closes a previously opened video device.

Return Value #

EBADF

fd is not a valid open file descriptor.


write() #

Synopsis #

size_t write(int fd, const void *buf, size_t count)

Arguments #

int fd

File descriptor returned by a previous call to open().

void *buf

Pointer to the buffer containing the PES data.

size_t count

Size of buf.

Description #

This system call can only be used if VIDEO_SOURCE_MEMORY is selected in the ioctl call VIDEO_SELECT_SOURCE. The data provided shall be in PES format, unless the capability allows other formats. TS is the most common format for storing DVB-data, it is usually supported too. If O_NONBLOCK is not specified the function will block until buffer space is available. The amount of data to be transferred is implied by count.

Note

See: DVB Data Formats

Return Value #

EPERM

Mode VIDEO_SOURCE_MEMORY not selected.

ENOMEM

Attempted to write more data than the internal buffer can hold.

EBADF

fd is not a valid open file descriptor.

ioctl NET_ADD_IF

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

NET_ADD_IF - Creates a new network interface for a given Packet ID.

Synopsis #

NET_ADD_IF

int ioctl(int fd, NET_ADD_IF, struct dvb_net_if *net_if)

Arguments #

  • fd

    File descriptor returned by open().

  • net_if

    pointer to struct dvb_net_if

Description #

The NET_ADD_IF ioctl system call selects the Packet ID (PID) that contains a TCP/IP traffic, the type of encapsulation to be used (MPE or ULE) and the interface number for the new interface to be created. When the system call successfully returns, a new virtual network interface is created.

The struct dvb_net_if::ifnum field will be filled with the number of the created interface.

Return Value #

On success 0 is returned, and ca_slot_info is filled.

On error -1 is returned, and the errno variable is set appropriately.

The generic error codes are described at the Generic Error Codes chapter.

ioctl NET_GET_IF

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

NET_GET_IF - Read the configuration data of an interface created via - NET_ADD_IF.

Synopsis #

NET_GET_IF

int ioctl(int fd, NET_GET_IF, struct dvb_net_if *net_if)

Arguments #

  • fd

    File descriptor returned by open().

  • net_if

    pointer to struct dvb_net_if

Description #

The NET_GET_IF ioctl uses the interface number given by the struct dvb_net_if::ifnum field and fills the content of struct dvb_net_if with the packet ID and encapsulation type used on such interface. If the interface was not created yet with NET_ADD_IF, it will return -1 and fill the errno with EINVAL error code.

Return Value #

On success 0 is returned, and ca_slot_info is filled.

On error -1 is returned, and the errno variable is set appropriately.

The generic error codes are described at the Generic Error Codes chapter.

ioctl NET_REMOVE_IF

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Name #

NET_REMOVE_IF - Removes a network interface.

Synopsis #

NET_REMOVE_IF

int ioctl(int fd, NET_REMOVE_IF, int ifnum)

Arguments #

  • fd

    File descriptor returned by open().

  • net_if

    number of the interface to be removed

Description #

The NET_REMOVE_IF ioctl deletes an interface previously created via NET_ADD_IF.

Return Value #

On success 0 is returned, and ca_slot_info is filled.

On error -1 is returned, and the errno variable is set appropriately.

The generic error codes are described at the Generic Error Codes chapter.

Net Data Types

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

struct dvb_net_if #

describes a DVB network interface

Definition

struct dvb_net_if {
        __u16 pid;
        __u16 if_num;
        __u8 feedtype;
    #define DVB_NET_FEEDTYPE_MPE 0;
    #define DVB_NET_FEEDTYPE_ULE 1;
};

Members

  • pid: Packet ID (PID) of the MPEG-TS that contains data
  • if_num: number of the Digital TV interface.
  • feedtype: Encapsulation type of the feed.

Description

A MPEG-TS stream may contain packet IDs with IP packages on it. This struct describes it, and the type of encoding.

feedtype can be:

  • DVB_NET_FEEDTYPE_MPE for MPE encoding
  • DVB_NET_FEEDTYPE_ULE for ULE encoding.

Digital TV Network API

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

The Digital TV net device controls the mapping of data packages that are part of a transport stream to be mapped into a virtual network interface, visible through the standard Linux network protocol stack.

Currently, two encapsulations are supported:

  • Multi Protocol Encapsulation (MPE)

  • Ultra Lightweight Encapsulation (ULE)

In order to create the Linux virtual network interfaces, an application needs to tell to the Kernel what are the PIDs and the encapsulation types that are present on the transport stream. This is done through /dev/dvb/adapter?/net? device node. The data will be available via virtual dvb?_? network interfaces, and will be controlled/routed via the standard ip tools (like ip, route, netstat, ifconfig, etc).

Data types and ioctl definitions are defined via linux/dvb/net.h header.

Digital TV net Function Calls #

  • Net Data Types
  • ioctl NET_ADD_IF
  • ioctl NET_REMOVE_IF
  • ioctl NET_GET_IF

Querying frontend information

Peios Kernel / Userspace interfaces / System and device interfaces / Digital television (DVB)

Usually, the first thing to do when the frontend is opened is to check the frontend capabilities. This is done using ioctl FE_GET_INFO. This ioctl will enumerate the Digital TV API version and other characteristics about the frontend, and can be opened either in read only or read/write mode.

Peios Learn — documentation for Peios software.

Built with Trail.