2.2. Frontend Function Calls

2.2.1. open()

DESCRIPTION

This system call opens a named frontend device (/dev/dvb/adapter0/frontend0) for subsequent use. Usually the first thing to do after a successful open is to find out the frontend type with 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.

SYNOPSIS

int open(const char ⋆deviceName, int flags);

PARAMETERS

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)

ERRORS

ENODEV

Device driver not loaded/available.

EINTERNAL

Internal error.

EBUSY

Device or resource busy.

EINVAL

Invalid argument.

2.2.2. close()

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.

SYNOPSIS

int close(int fd);

PARAMETERS

int fd

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

ERRORS

EBADF

fd is not a valid open file descriptor.

2.2.3. FE_READ_STATUS

DESCRIPTION

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

SYNOPSIS

int ioctl(int fd, int request = FE_READ_STATUS, fe_status_t ⋆status);

PARAMETERS

int fd

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

int request

Equals FE_READ_STATUS for this command.

struct fe_status_t *status

Points to the location where the front-end status word is to be stored.

ERRORS

EBADF

fd is not a valid open file descriptor.

EFAULT

status points to invalid address.

2.2.4. FE_READ_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.

SYNOPSIS

int ioctl(int fd, int request = FE_READ_BER, uint32_t ⋆ber);

PARAMETERS

int fd

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

int request

Equals FE_READ_BER for this command.

uint32_t *ber

The bit error rate is stored into *ber.

ERRORS

EBADF

fd is not a valid open file descriptor.

EFAULT

ber points to invalid address.

ENOSIGNAL

There is no signal, thus no meaningful bit error rate. Also returned if the front-end is not turned on.

ENOSYS

Function not available for this device.

2.2.5. FE_READ_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.

SYNOPSIS

int ioctl(int fd, int request = FE_READ_SNR, int16_t ⋆snr);

PARAMETERS

int fd

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

int request

Equals FE_READ_SNR for this command.

int16_t *snr

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

ERRORS

EBADF

fd is not a valid open file descriptor.

EFAULT

snr points to invalid address.

ENOSIGNAL

There is no signal, thus no meaningful signal strength value. Also returned if front-end is not turned on.

ENOSYS

Function not available for this device.

2.2.6. FE_READ_SIGNAL_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.

SYNOPSIS

int ioctl( int fd, int request = FE_READ_SIGNAL_STRENGTH, int16_t ⋆strength);

PARAMETERS

int fd

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

int request

Equals FE_READ_SIGNAL_STRENGTH for this command.

int16_t *strength

The signal strength value is stored into *strength.

ERRORS

EBADF

fd is not a valid open file descriptor.

EFAULT

status points to invalid address.

ENOSIGNAL

There is no signal, thus no meaningful signal strength value. Also returned if front-end is not turned on.

ENOSYS

Function not available for this device.

2.2.7. FE_READ_UNCORRECTED_BLOCKS

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.

Note that the counter will wrap to zero after its maximum count has been reached.

SYNOPSIS

int ioctl( int fd, int request = FE_READ_UNCORRECTED_BLOCKS, uint32_t ⋆ublocks);

PARAMETERS

int fd

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

int request

Equals FE_READ_UNCORRECTED_BLOCKS for this command.

uint32_t *ublocks

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

ERRORS

EBADF

fd is not a valid open file descriptor.

EFAULT

ublocks points to invalid address.

ENOSYS

Function not available for this device.

2.2.8. FE_SET_FRONTEND

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.

SYNOPSIS

int ioctl(int fd, int request = FE_SET_FRONTEND, struct dvb_frontend_parameters ⋆p);

PARAMETERS

int fd

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

int request

Equals FE_SET_FRONTEND for this command.

struct dvb_frontend_parameters *p

Points to parameters for tuning operation.

ERRORS

EBADF

fd is not a valid open file descriptor.

EFAULT

p points to invalid address.

EINVAL

Maximum supported symbol rate reached.

2.2.9. FE_GET_FRONTEND

DESCRIPTION

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

SYNOPSIS

int ioctl(int fd, int request = FE_GET_FRONTEND, struct dvb_frontend_parameters ⋆p);

PARAMETERS

int fd

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

int request

Equals FE_SET_FRONTEND for this command.

struct dvb_frontend_parameters *p

Points to parameters for tuning operation.

ERRORS

EBADF

fd is not a valid open file descriptor.

EFAULT

p points to invalid address.

EINVAL

Maximum supported symbol rate reached.

2.2.10. FE_GET_EVENT

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.

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. Since the event queue allocated is rather small (room for 8 events), the queue must be serviced regularly to avoid overflow. If an overflow happens, the oldest event is discarded from the queue, and an error (EOVERFLOW) occurs the next time the queue is read. After reporting the error condition in this fashion, subsequent FE_GET_EVENT calls will return events from the queue as usual.

For the sake of implementation simplicity, this command requires read/write access to the device.

SYNOPSIS

int ioctl(int fd, int request = QPSK_GET_EVENT, struct dvb_frontend_event ⋆ev);

PARAMETERS

int fd

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

int request

Equals FE_GET_EVENT for this command.

struct dvb_frontend_event *ev

Points to the location where the event,

if any, is to be stored.

ERRORS

EBADF

fd is not a valid open file descriptor.

EFAULT

ev points to invalid address.

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.

2.2.11. FE_GET_INFO

DESCRIPTION

This ioctl call returns information about the front-end. This call only requires read-only access to the device.

SYNOPSIS

int ioctl(int fd, int request = FE_GET_INFO, struct dvb_frontend_info ⋆info);

PARAMETERS

int fd

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

int request

Equals FE_GET_INFO for this command.

struct dvb_frontend_info *info

Points to the location where the front-end information is to be stored.

ERRORS

EBADF

fd is not a valid open file descriptor.

EFAULT

info points to invalid address.

2.2.12. FE_DISEQC_RESET_OVERLOAD

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 DVB adapters support this ioctl.

SYNOPSIS

int ioctl(int fd, int request = FE_DISEQC_RESET_OVERLOAD);

PARAMETERS

int fd

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

int request

Equals FE_DISEQC_RESET_OVERLOAD for this command.

ERRORS

EBADF

fd is not a valid file descriptor.

EPERM

Permission denied (needs read/write access).

EINTERNAL

Internal error in the device driver.

2.2.13. FE_DISEQC_SEND_MASTER_CMD

DESCRIPTION

This ioctl call is used to send a a DiSEqC command.

SYNOPSIS

int ioctl(int fd, int request = FE_DISEQC_SEND_MASTER_CMD, struct dvb_diseqc_master_cmd ⋆cmd);

PARAMETERS

int fd

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

int request

Equals FE_DISEQC_SEND_MASTER_CMD for this command.

struct dvb_diseqc_master_cmd *cmd

Pointer to the command to be transmitted.

ERRORS

EBADF

fd is not a valid file descriptor.

EFAULT

Seq points to an invalid address.

EINVAL

The data structure referred to by seq is invalid in some way.

EPERM

Permission denied (needs read/write access).

EINTERNAL

Internal error in the device driver.

2.2.14. FE_DISEQC_RECV_SLAVE_REPLY

DESCRIPTION

This ioctl call is used to receive reply to a DiSEqC 2.0 command.

SYNOPSIS

int ioctl(int fd, int request = FE_DISEQC_RECV_SLAVE_REPLY, struct dvb_diseqc_slave_reply ⋆reply);

PARAMETERS

int fd

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

int request

Equals FE_DISEQC_RECV_SLAVE_REPLY for this command.

struct dvb_diseqc_slave_reply *reply

Pointer to the command to be received.

ERRORS

EBADF

fd is not a valid file descriptor.

EFAULT

Seq points to an invalid address.

EINVAL

The data structure referred to by seq is invalid in some way.

EPERM

Permission denied (needs read/write access).

EINTERNAL

Internal error in the device driver.

2.2.15. FE_DISEQC_SEND_BURST

DESCRIPTION

This ioctl call is used to send a 22KHz tone burst.

SYNOPSIS

int ioctl(int fd, int request = FE_DISEQC_SEND_BURST, fe_sec_mini_cmd_t burst);

PARAMETERS

int fd

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

int request

Equals FE_DISEQC_SEND_BURST for this command.

fe_sec_mini_cmd_t burst

burst A or B.

ERRORS

EBADF

fd is not a valid file descriptor.

EFAULT

Seq points to an invalid address.

EINVAL

The data structure referred to by seq is invalid in some way.

EPERM

Permission denied (needs read/write access).

EINTERNAL

Internal error in the device driver.

2.2.16. FE_SET_TONE

DESCRIPTION

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

SYNOPSIS

int ioctl(int fd, int request = FE_SET_TONE, fe_sec_tone_mode_t tone);

PARAMETERS

int fd

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

int request

Equals FE_SET_TONE for this command.

fe_sec_tone_mode_t tone

The requested tone generation mode (on/off).

ERRORS

ENODEV

Device driver not loaded/available.

EBUSY

Device or resource busy.

EINVAL

Invalid argument.

EPERM

File not opened with read permissions.

EINTERNAL

Internal error in the device driver.

2.2.17. FE_SET_VOLTAGE

DESCRIPTION

This call is used to set the bus voltage. This call requires read/write permissions.

SYNOPSIS

int ioctl(int fd, int request = FE_SET_VOLTAGE, fe_sec_voltage_t voltage);

PARAMETERS

int fd

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

int request

Equals FE_SET_VOLTAGE for this command.

fe_sec_voltage_t voltage

The requested bus voltage.

ERRORS

ENODEV

Device driver not loaded/available.

EBUSY

Device or resource busy.

EINVAL

Invalid argument.

EPERM

File not opened with read permissions.

EINTERNAL

Internal error in the device driver.

2.2.18. FE_ENABLE_HIGH_LNB_VOLTAGE

DESCRIPTION

If high != 0 enables slightly higher voltages instead of 13/18V (to compensate for long cables). This call requires read/write permissions. Not all DVB adapters support this ioctl.

SYNOPSIS

int ioctl(int fd, int request = FE_ENABLE_HIGH_LNB_VOLTAGE, int high);

PARAMETERS

int fd

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

int request

Equals FE_SET_VOLTAGE for this command.

int high

The requested bus voltage.

ERRORS

ENODEV

Device driver not loaded/available.

EBUSY

Device or resource busy.

EINVAL

Invalid argument.

EPERM

File not opened with read permissions.

EINTERNAL

Internal error in the device driver.