Path: blob/master/drivers/media/dvb/dvb-core/dvb_frontend.h
15112 views
/*1* dvb_frontend.h2*3* Copyright (C) 2001 convergence integrated media GmbH4* Copyright (C) 2004 convergence GmbH5*6* Written by Ralph Metzler7* Overhauled by Holger Waechtler8* Kernel I2C stuff by Michael Hunold <[email protected]>9*10* This program is free software; you can redistribute it and/or11* modify it under the terms of the GNU Lesser General Public License12* as published by the Free Software Foundation; either version 2.113* of the License, or (at your option) any later version.14*15* This program is distributed in the hope that it will be useful,16* but WITHOUT ANY WARRANTY; without even the implied warranty of17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the18* GNU General Public License for more details.19*2021* You should have received a copy of the GNU Lesser General Public License22* along with this program; if not, write to the Free Software23* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.24*25*/2627#ifndef _DVB_FRONTEND_H_28#define _DVB_FRONTEND_H_2930#include <linux/types.h>31#include <linux/sched.h>32#include <linux/ioctl.h>33#include <linux/i2c.h>34#include <linux/module.h>35#include <linux/errno.h>36#include <linux/delay.h>37#include <linux/mutex.h>38#include <linux/slab.h>3940#include <linux/dvb/frontend.h>4142#include "dvbdev.h"4344struct dvb_frontend_tune_settings {45int min_delay_ms;46int step_size;47int max_drift;48struct dvb_frontend_parameters parameters;49};5051struct dvb_frontend;5253struct dvb_tuner_info {54char name[128];5556u32 frequency_min;57u32 frequency_max;58u32 frequency_step;5960u32 bandwidth_min;61u32 bandwidth_max;62u32 bandwidth_step;63};6465struct analog_parameters {66unsigned int frequency;67unsigned int mode;68unsigned int audmode;69u64 std;70};7172enum dvbfe_modcod {73DVBFE_MODCOD_DUMMY_PLFRAME = 0,74DVBFE_MODCOD_QPSK_1_4,75DVBFE_MODCOD_QPSK_1_3,76DVBFE_MODCOD_QPSK_2_5,77DVBFE_MODCOD_QPSK_1_2,78DVBFE_MODCOD_QPSK_3_5,79DVBFE_MODCOD_QPSK_2_3,80DVBFE_MODCOD_QPSK_3_4,81DVBFE_MODCOD_QPSK_4_5,82DVBFE_MODCOD_QPSK_5_6,83DVBFE_MODCOD_QPSK_8_9,84DVBFE_MODCOD_QPSK_9_10,85DVBFE_MODCOD_8PSK_3_5,86DVBFE_MODCOD_8PSK_2_3,87DVBFE_MODCOD_8PSK_3_4,88DVBFE_MODCOD_8PSK_5_6,89DVBFE_MODCOD_8PSK_8_9,90DVBFE_MODCOD_8PSK_9_10,91DVBFE_MODCOD_16APSK_2_3,92DVBFE_MODCOD_16APSK_3_4,93DVBFE_MODCOD_16APSK_4_5,94DVBFE_MODCOD_16APSK_5_6,95DVBFE_MODCOD_16APSK_8_9,96DVBFE_MODCOD_16APSK_9_10,97DVBFE_MODCOD_32APSK_3_4,98DVBFE_MODCOD_32APSK_4_5,99DVBFE_MODCOD_32APSK_5_6,100DVBFE_MODCOD_32APSK_8_9,101DVBFE_MODCOD_32APSK_9_10,102DVBFE_MODCOD_RESERVED_1,103DVBFE_MODCOD_BPSK_1_3,104DVBFE_MODCOD_BPSK_1_4,105DVBFE_MODCOD_RESERVED_2106};107108enum tuner_param {109DVBFE_TUNER_FREQUENCY = (1 << 0),110DVBFE_TUNER_TUNERSTEP = (1 << 1),111DVBFE_TUNER_IFFREQ = (1 << 2),112DVBFE_TUNER_BANDWIDTH = (1 << 3),113DVBFE_TUNER_REFCLOCK = (1 << 4),114DVBFE_TUNER_IQSENSE = (1 << 5),115DVBFE_TUNER_DUMMY = (1 << 31)116};117118/*119* ALGO_HW: (Hardware Algorithm)120* ----------------------------------------------------------------121* Devices that support this algorithm do everything in hardware122* and no software support is needed to handle them.123* Requesting these devices to LOCK is the only thing required,124* device is supposed to do everything in the hardware.125*126* ALGO_SW: (Software Algorithm)127* ----------------------------------------------------------------128* These are dumb devices, that require software to do everything129*130* ALGO_CUSTOM: (Customizable Agorithm)131* ----------------------------------------------------------------132* Devices having this algorithm can be customized to have specific133* algorithms in the frontend driver, rather than simply doing a134* software zig-zag. In this case the zigzag maybe hardware assisted135* or it maybe completely done in hardware. In all cases, usage of136* this algorithm, in conjunction with the search and track137* callbacks, utilizes the driver specific algorithm.138*139* ALGO_RECOVERY: (Recovery Algorithm)140* ----------------------------------------------------------------141* These devices have AUTO recovery capabilities from LOCK failure142*/143enum dvbfe_algo {144DVBFE_ALGO_HW = (1 << 0),145DVBFE_ALGO_SW = (1 << 1),146DVBFE_ALGO_CUSTOM = (1 << 2),147DVBFE_ALGO_RECOVERY = (1 << 31)148};149150struct tuner_state {151u32 frequency;152u32 tunerstep;153u32 ifreq;154u32 bandwidth;155u32 iqsense;156u32 refclock;157};158159/*160* search callback possible return status161*162* DVBFE_ALGO_SEARCH_SUCCESS163* The frontend search algorithm completed and returned successfully164*165* DVBFE_ALGO_SEARCH_ASLEEP166* The frontend search algorithm is sleeping167*168* DVBFE_ALGO_SEARCH_FAILED169* The frontend search for a signal failed170*171* DVBFE_ALGO_SEARCH_INVALID172* The frontend search algorith was probably supplied with invalid173* parameters and the search is an invalid one174*175* DVBFE_ALGO_SEARCH_ERROR176* The frontend search algorithm failed due to some error177*178* DVBFE_ALGO_SEARCH_AGAIN179* The frontend search algorithm was requested to search again180*/181enum dvbfe_search {182DVBFE_ALGO_SEARCH_SUCCESS = (1 << 0),183DVBFE_ALGO_SEARCH_ASLEEP = (1 << 1),184DVBFE_ALGO_SEARCH_FAILED = (1 << 2),185DVBFE_ALGO_SEARCH_INVALID = (1 << 3),186DVBFE_ALGO_SEARCH_AGAIN = (1 << 4),187DVBFE_ALGO_SEARCH_ERROR = (1 << 31),188};189190191struct dvb_tuner_ops {192193struct dvb_tuner_info info;194195int (*release)(struct dvb_frontend *fe);196int (*init)(struct dvb_frontend *fe);197int (*sleep)(struct dvb_frontend *fe);198199/** This is for simple PLLs - set all parameters in one go. */200int (*set_params)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);201int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);202203/** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */204int (*calc_regs)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len);205206/** This is to allow setting tuner-specific configs */207int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);208209int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);210int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);211212#define TUNER_STATUS_LOCKED 1213#define TUNER_STATUS_STEREO 2214int (*get_status)(struct dvb_frontend *fe, u32 *status);215int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);216217/** These are provided separately from set_params in order to facilitate silicon218* tuners which require sophisticated tuning loops, controlling each parameter separately. */219int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);220int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);221222/*223* These are provided separately from set_params in order to facilitate silicon224* tuners which require sophisticated tuning loops, controlling each parameter separately.225*/226int (*set_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);227int (*get_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);228};229230struct analog_demod_info {231char *name;232};233234struct analog_demod_ops {235236struct analog_demod_info info;237238void (*set_params)(struct dvb_frontend *fe,239struct analog_parameters *params);240int (*has_signal)(struct dvb_frontend *fe);241int (*get_afc)(struct dvb_frontend *fe);242void (*tuner_status)(struct dvb_frontend *fe);243void (*standby)(struct dvb_frontend *fe);244void (*release)(struct dvb_frontend *fe);245int (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);246247/** This is to allow setting tuner-specific configuration */248int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);249};250251struct dvb_frontend_ops {252253struct dvb_frontend_info info;254255void (*release)(struct dvb_frontend* fe);256void (*release_sec)(struct dvb_frontend* fe);257258int (*init)(struct dvb_frontend* fe);259int (*sleep)(struct dvb_frontend* fe);260261int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);262263/* if this is set, it overrides the default swzigzag */264int (*tune)(struct dvb_frontend* fe,265struct dvb_frontend_parameters* params,266unsigned int mode_flags,267unsigned int *delay,268fe_status_t *status);269/* get frontend tuning algorithm from the module */270enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);271272/* these two are only used for the swzigzag code */273int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);274int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);275276int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);277278int (*read_status)(struct dvb_frontend* fe, fe_status_t* status);279int (*read_ber)(struct dvb_frontend* fe, u32* ber);280int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);281int (*read_snr)(struct dvb_frontend* fe, u16* snr);282int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);283284int (*diseqc_reset_overload)(struct dvb_frontend* fe);285int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);286int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);287int (*diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);288int (*set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);289int (*set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);290int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);291int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);292int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);293int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);294295/* These callbacks are for devices that implement their own296* tuning algorithms, rather than a simple swzigzag297*/298enum dvbfe_search (*search)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);299int (*track)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);300301struct dvb_tuner_ops tuner_ops;302struct analog_demod_ops analog_ops;303304int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);305int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);306};307308#define MAX_EVENT 8309310struct dvb_fe_events {311struct dvb_frontend_event events[MAX_EVENT];312int eventw;313int eventr;314int overflow;315wait_queue_head_t wait_queue;316struct mutex mtx;317};318319struct dtv_frontend_properties {320321/* Cache State */322u32 state;323324u32 frequency;325fe_modulation_t modulation;326327fe_sec_voltage_t voltage;328fe_sec_tone_mode_t sectone;329fe_spectral_inversion_t inversion;330fe_code_rate_t fec_inner;331fe_transmit_mode_t transmission_mode;332u32 bandwidth_hz; /* 0 = AUTO */333fe_guard_interval_t guard_interval;334fe_hierarchy_t hierarchy;335u32 symbol_rate;336fe_code_rate_t code_rate_HP;337fe_code_rate_t code_rate_LP;338339fe_pilot_t pilot;340fe_rolloff_t rolloff;341342fe_delivery_system_t delivery_system;343344/* ISDB-T specifics */345u8 isdbt_partial_reception;346u8 isdbt_sb_mode;347u8 isdbt_sb_subchannel;348u32 isdbt_sb_segment_idx;349u32 isdbt_sb_segment_count;350u8 isdbt_layer_enabled;351struct {352u8 segment_count;353fe_code_rate_t fec;354fe_modulation_t modulation;355u8 interleaving;356} layer[3];357358/* ISDB-T specifics */359u32 isdbs_ts_id;360361/* DVB-T2 specifics */362u32 dvbt2_plp_id;363};364365struct dvb_frontend {366struct dvb_frontend_ops ops;367struct dvb_adapter *dvb;368void *demodulator_priv;369void *tuner_priv;370void *frontend_priv;371void *sec_priv;372void *analog_demod_priv;373struct dtv_frontend_properties dtv_property_cache;374#define DVB_FRONTEND_COMPONENT_TUNER 0375int (*callback)(void *adapter_priv, int component, int cmd, int arg);376int id;377};378379extern int dvb_register_frontend(struct dvb_adapter *dvb,380struct dvb_frontend *fe);381382extern int dvb_unregister_frontend(struct dvb_frontend *fe);383384extern void dvb_frontend_detach(struct dvb_frontend *fe);385386extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);387388extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec);389extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime);390391#endif392393394