2.26.Tuner functions and data structures

enumtuner_mode

Mode of the tuner

Constants

T_RADIO

Tuner core will work in radio mode

T_ANALOG_TV

Tuner core will work in analog TV mode

Description

Older boards only had a single tuner device, but some devices have aseparate tuner for radio. In any case, the tuner-core needs to know ifthe tuner chip(s) will be used in radio mode or analog TV mode, as, onradio mode, frequencies are specified on a different range than on TVmode. Thisenumis used by the tuner core in order to work with theproper tuner range and eventually use a different tuner chip while inradio mode.

structtuner_setup

setup the tuner chipsets

Definition:

struct tuner_setup {    unsigned short  addr;    unsigned int    type;    unsigned int    mode_mask;    void *config;    int (*tuner_callback)(void *dev, int component, int cmd, int arg);};

Members

addr

I2C address used to control the tuner device/chipset

type

Type of the tuner, as defined at the TUNER_* macros.Each different tuner model should have an uniqueidentifier.

mode_mask

Mask with the allowed tuner modes: V4L2_TUNER_RADIO,V4L2_TUNER_ANALOG_TV and/or V4L2_TUNER_DIGITAL_TV,describing if the tuner should be used to supportRadio, analog TV and/or digital TV.

config

Used to send tuner-specific configuration for complextuners that require extra parameters to be set.Only a very few tuners require it and its usage onnewer tuners should be avoided.

tuner_callback

Some tuners require to call back the bridge driver,in order to do some tasks like rising a GPIO at thebridge chipset, in order to do things like resettingthe device.

Description

Older boards only had a single tuner device. Nowadays multiple tunerdevices may be present on a single board. Using TUNER_SET_TYPE_ADDRto pass the tuner_setup structure it is possible to setup each tunerdevice in turn.

Since multiple devices may be present it is no longer sufficient tosend a command to a single i2c device. Instead you should broadcastthe command to all i2c devices.

By setting the mode_mask correctly you can select which commands areaccepted by a specific tuner device. For example, set mode_mask toT_RADIO if the device is a radio-only tuner. That specific tuner willonly accept commands when the tuner is in radio mode and ignore themwhen the tuner is set to TV mode.

enumparam_type

type of the tuner pameters

Constants

TUNER_PARAM_TYPE_RADIO

Tuner params are for FM and/or AM radio

TUNER_PARAM_TYPE_PAL

Tuner params are for PAL color TV standard

TUNER_PARAM_TYPE_SECAM

Tuner params are for SECAM color TV standard

TUNER_PARAM_TYPE_NTSC

Tuner params are for NTSC color TV standard

TUNER_PARAM_TYPE_DIGITAL

Tuner params are for digital TV

structtuner_range

define the frequencies supported by the tuner

Definition:

struct tuner_range {    unsigned short limit;    unsigned char config;    unsigned char cb;};

Members

limit

Max frequency supported by that range, in 62.5 kHz(TV) or 62.5 Hz (Radio), as defined byV4L2_TUNER_CAP_LOW.

config

Value of the band switch byte (BB) to setup this mode.

cb

Value of the CB byte to setup this mode.

Description

Please notice that digital tuners like xc3028/xc4000/xc5000 don’t usethose ranges, as they’re defined inside the driver. This is used byanalog tuners that are compatible with the “Philips way” to setup thetuners. On those devices, the tuner set is done via 4 bytes:

  1. divider byte1 (DB1)

  2. divider byte 2 (DB2)

  3. Control byte (CB)

  4. band switch byte (BB)

Some tuners also have an additional optional Auxiliary byte (AB).

structtuner_params

Parameters to be used to setup the tuner. Those are used by drivers/media/tuners/tuner-types.c in order to specify the tuner properties. Most of the parameters are for tuners based on tda9887 IF-PLL multi-standard analog TV/Radio demodulator, with is very common on legacy analog tuners.

Definition:

struct tuner_params {    enum param_type type;    unsigned int cb_first_if_lower_freq:1;    unsigned int has_tda9887:1;    unsigned int port1_fm_high_sensitivity:1;    unsigned int port2_fm_high_sensitivity:1;    unsigned int fm_gain_normal:1;    unsigned int intercarrier_mode:1;    unsigned int port1_active:1;    unsigned int port2_active:1;    unsigned int port1_invert_for_secam_lc:1;    unsigned int port2_invert_for_secam_lc:1;    unsigned int port1_set_for_fm_mono:1;    unsigned int default_pll_gating_18:1;    unsigned int radio_if:2;    signed int default_top_low:5;    signed int default_top_mid:5;    signed int default_top_high:5;    signed int default_top_secam_low:5;    signed int default_top_secam_mid:5;    signed int default_top_secam_high:5;    u16 iffreq;    unsigned int count;    const struct tuner_range *ranges;};

Members

type

Type of the tuner parameters, as defined atenumparam_type. If the tuner supports multiplestandards, an array should be used, with onerow per different standard.

cb_first_if_lower_freq

Many Philips-based tuners have a comment intheir datasheet like“For channel selection involving bandswitching, and to ensure smooth tuning to thedesired channel without causing unnecessarycharge pump action, it is recommended toconsider the difference between wanted channelfrequency and the current channel frequency.Unnecessary charge pump action will resultin very low tuning voltage which may drive theoscillator to extreme conditions”.Set cb_first_if_lower_freq to 1, if this checkis required for this tuner. I tested this forPAL by first setting the TV frequency to203 MHz and then switching to 96.6 MHz FMradio. The result was static unless thecontrol byte was sent first.

has_tda9887

Set to 1 if this tuner uses a tda9887

port1_fm_high_sensitivity

Many Philips tuners use tda9887 PORT1 to selectthe FM radio sensitivity. If this setting is 1,then set PORT1 to 1 to get proper FM reception.

port2_fm_high_sensitivity

Some Philips tuners use tda9887 PORT2 to selectthe FM radio sensitivity. If this setting is 1,then set PORT2 to 1 to get proper FM reception.

fm_gain_normal

Some Philips tuners use tda9887 cGainNormal toselect the FM radio sensitivity. If thissetting is 1, e register will use cGainNormalinstead of cGainLow.

intercarrier_mode

Most tuners with a tda9887 use QSS mode.Some (cheaper) tuners use Intercarrier mode.If this setting is 1, then the tuner needs tobe set to intercarrier mode.

port1_active

This setting sets the default value for PORT1.0 means inactive, 1 means active. Note: theactual bit value written to the tda9887 isinverted. So a 0 here means a 1 in the B6 bit.

port2_active

This setting sets the default value for PORT2.0 means inactive, 1 means active. Note: theactual bit value written to the tda9887 isinverted. So a 0 here means a 1 in the B7 bit.

port1_invert_for_secam_lc

Sometimes PORT1 is inverted when the SECAM-L’standard is selected. Set this bit to 1 if thisis needed.

port2_invert_for_secam_lc

Sometimes PORT2 is inverted when the SECAM-L’standard is selected. Set this bit to 1 if thisis needed.

port1_set_for_fm_mono

Some cards require PORT1 to be 1 for mono RadioFM and 0 for stereo.

default_pll_gating_18

Select 18% (or according to datasheet 0%)L standard PLL gating, vs the driver defaultof 36%.

radio_if

IF to use in radio mode. Tuners with aseparate radio IF filter seem to use 10.7,while those without use 33.3 for PAL/SECAMtuners and 41.3 for NTSC tuners.0 = 10.7, 1 = 33.3, 2 = 41.3

default_top_low

Default tda9887 TOP value in dB for the lowband. Default is 0. Range: -16:+15

default_top_mid

Default tda9887 TOP value in dB for the midband. Default is 0. Range: -16:+15

default_top_high

Default tda9887 TOP value in dB for the highband. Default is 0. Range: -16:+15

default_top_secam_low

Default tda9887 TOP value in dB for SECAM-L/L’for the low band. Default is 0. Several tunersrequire a different TOP value for theSECAM-L/L’ standards. Range: -16:+15

default_top_secam_mid

Default tda9887 TOP value in dB for SECAM-L/L’for the mid band. Default is 0. Several tunersrequire a different TOP value for theSECAM-L/L’ standards. Range: -16:+15

default_top_secam_high

Default tda9887 TOP value in dB for SECAM-L/L’for the high band. Default is 0. Several tunersrequire a different TOP value for theSECAM-L/L’ standards. Range: -16:+15

iffreq

Intermediate frequency (IF) used by the tuneron digital mode.

count

Size of the ranges array.

ranges

Array with the frequency ranges supported bythe tuner.

structtunertype

describes the known tuners.

Definition:

struct tunertype {    char *name;    unsigned int count;    const struct tuner_params *params;    u16 min;    u16 max;    u32 stepsize;    u8 *initdata;    u8 *sleepdata;};

Members

name

string with the tuner’s name.

count

size ofstructtuner_params array.

params

pointer tostructtuner_params array.

min

minimal tuner frequency, in 62.5 kHz step.should be multiplied to 16 to convert to MHz.

max

minimal tuner frequency, in 62.5 kHz step.Should be multiplied to 16 to convert to MHz.

stepsize

frequency step, in Hz.

initdata

optional byte sequence to initialize the tuner.

sleepdata

optional byte sequence to power down the tuner.