Frontend Function Calls

open()
close()
FE_READ_STATUS
FE_READ_BER
FE_READ_SNR
FE_READ_SIGNAL_STRENGTH
FE_READ_UNCORRECTED_BLOCKS
FE_SET_FRONTEND
FE_GET_FRONTEND
FE_GET_EVENT
FE_GET_INFO
FE_DISEQC_RESET_OVERLOAD
FE_DISEQC_SEND_MASTER_CMD
FE_DISEQC_RECV_SLAVE_REPLY
FE_DISEQC_SEND_BURST
FE_SET_TONE
FE_SET_VOLTAGE
FE_ENABLE_HIGH_LNB_VOLTAGE
FE_SET_FRONTEND_TUNE_MODE
FE_DISHNETWORK_SEND_LEGACY_CMD

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)

RETURN VALUE

ENODEV

Device driver not loaded/available.

EINTERNAL

Internal error.

EBUSY

Device or resource busy.

EINVAL

Invalid argument.

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().

RETURN VALUE

EBADF

fd is not a valid open file descriptor.

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.

RETURN VALUE

EBADF

fd is not a valid open file descriptor.

EFAULT

status points to invalid address.

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.

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.

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, uint16_t ⋆snr);

PARAMETERS

int fd

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

int request

Equals FE_READ_SNR for this command.

uint16_t *snr

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

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.

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, uint16_t ⋆strength);

PARAMETERS

int fd

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

int request

Equals FE_READ_SIGNAL_STRENGTH for this command.

uint16_t *strength

The signal strength value is stored into *strength.

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.

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.

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.

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.

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

Maximum supported symbol rate reached.

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.

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

Maximum supported symbol rate reached.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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).

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.

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.

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.

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.

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.

FE_SET_FRONTEND_TUNE_MODE

DESCRIPTION

Allow setting tuner mode flags to the frontend.

SYNOPSIS

int ioctl(int fd, int request = FE_SET_FRONTEND_TUNE_MODE, unsigned int flags);

PARAMETERS

unsigned int flags

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.

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.

FE_DISHNETWORK_SEND_LEGACY_CMD

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.

SYNOPSIS

int ioctl(int fd, int request = FE_DISHNETWORK_SEND_LEGACY_CMD, unsigned long cmd);

PARAMETERS

unsigned long cmd

sends the specified raw cmd to the dish via DISEqC.

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.