834 lines · 30.4 KB · C
RawDownload
/* * dvb_frontend.h * * The Digital TV Frontend kABI defines a driver-internal interface for * registering low-level, hardware specific driver to a hardware independent * frontend layer. * * Copyright (C) 2001 convergence integrated media GmbH * Copyright (C) 2004 convergence GmbH * * Written by Ralph Metzler * Overhauled by Holger Waechtler * Kernel I2C stuff by Michael Hunold <hunold@convergence.de> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * */ #ifndef _DVB_FRONTEND_H_#define _DVB_FRONTEND_H_ #include <linux/types.h>#include <linux/sched.h>#include <linux/ioctl.h>#include <linux/i2c.h>#include <linux/module.h>#include <linux/errno.h>#include <linux/delay.h>#include <linux/mutex.h>#include <linux/slab.h>#include <linux/bitops.h> #include <linux/dvb/frontend.h> #include <media/dvbdev.h> /* * Maximum number of Delivery systems per frontend. It * should be smaller or equal to 32 */#define MAX_DELSYS	8 /* Helper definitions to be used at frontend drivers */#define kHz 1000UL#define MHz 1000000UL /** * struct dvb_frontend_tune_settings - parameters to adjust frontend tuning * * @min_delay_ms:	minimum delay for tuning, in ms * @step_size:		step size between two consecutive frequencies * @max_drift:		maximum drift * * NOTE: step_size is in Hz, for terrestrial/cable or kHz for satellite */struct dvb_frontend_tune_settings {	int min_delay_ms;	int step_size;	int max_drift;}; struct dvb_frontend; /** * struct dvb_tuner_info - Frontend name and min/max ranges/bandwidths * * @name:		name of the Frontend * @frequency_min_hz:	minimal frequency supported in Hz * @frequency_max_hz:	maximum frequency supported in Hz * @frequency_step_hz:	frequency step in Hz * @bandwidth_min:	minimal frontend bandwidth supported * @bandwidth_max:	maximum frontend bandwidth supported * @bandwidth_step:	frontend bandwidth step */struct dvb_tuner_info {	char name[128]; 	u32 frequency_min_hz;	u32 frequency_max_hz;	u32 frequency_step_hz; 	u32 bandwidth_min;	u32 bandwidth_max;	u32 bandwidth_step;}; /** * struct analog_parameters - Parameters to tune into an analog/radio channel * * @frequency:	Frequency used by analog TV tuner (either in 62.5 kHz step, *		for TV, or 62.5 Hz for radio) * @mode:	Tuner mode, as defined on enum v4l2_tuner_type * @audmode:	Audio mode as defined for the rxsubchans field at videodev2.h, *		e. g. V4L2_TUNER_MODE_* * @std:	TV standard bitmap as defined at videodev2.h, e. g. V4L2_STD_* * * Hybrid tuners should be supported by both V4L2 and DVB APIs. This * struct contains the data that are used by the V4L2 side. To avoid * dependencies from V4L2 headers, all enums here are declared as integers. */struct analog_parameters {	unsigned int frequency;	unsigned int mode;	unsigned int audmode;	u64 std;}; /** * enum dvbfe_algo - defines the algorithm used to tune into a channel * * @DVBFE_ALGO_HW: Hardware Algorithm - *	Devices that support this algorithm do everything in hardware *	and no software support is needed to handle them. *	Requesting these devices to LOCK is the only thing required, *	device is supposed to do everything in the hardware. * * @DVBFE_ALGO_SW: Software Algorithm - * These are dumb devices, that require software to do everything * * @DVBFE_ALGO_CUSTOM: Customizable Agorithm - *	Devices having this algorithm can be customized to have specific *	algorithms in the frontend driver, rather than simply doing a *	software zig-zag. In this case the zigzag maybe hardware assisted *	or it maybe completely done in hardware. In all cases, usage of *	this algorithm, in conjunction with the search and track *	callbacks, utilizes the driver specific algorithm. * * @DVBFE_ALGO_RECOVERY: Recovery Algorithm - *	These devices have AUTO recovery capabilities from LOCK failure */enum dvbfe_algo {	DVBFE_ALGO_HW			= BIT(0),	DVBFE_ALGO_SW			= BIT(1),	DVBFE_ALGO_CUSTOM		= BIT(2),	DVBFE_ALGO_RECOVERY		= BIT(31),}; /** * enum dvbfe_search - search callback possible return status * * @DVBFE_ALGO_SEARCH_SUCCESS: *	The frontend search algorithm completed and returned successfully * * @DVBFE_ALGO_SEARCH_ASLEEP: *	The frontend search algorithm is sleeping * * @DVBFE_ALGO_SEARCH_FAILED: *	The frontend search for a signal failed * * @DVBFE_ALGO_SEARCH_INVALID: *	The frontend search algorithm was probably supplied with invalid *	parameters and the search is an invalid one * * @DVBFE_ALGO_SEARCH_ERROR: *	The frontend search algorithm failed due to some error * * @DVBFE_ALGO_SEARCH_AGAIN: *	The frontend search algorithm was requested to search again */enum dvbfe_search {	DVBFE_ALGO_SEARCH_SUCCESS	= BIT(0),	DVBFE_ALGO_SEARCH_ASLEEP	= BIT(1),	DVBFE_ALGO_SEARCH_FAILED	= BIT(2),	DVBFE_ALGO_SEARCH_INVALID	= BIT(3),	DVBFE_ALGO_SEARCH_AGAIN		= BIT(4),	DVBFE_ALGO_SEARCH_ERROR		= BIT(31),}; /** * struct dvb_tuner_ops - Tuner information and callbacks * * @info:		embedded &struct dvb_tuner_info with tuner properties * @release:		callback function called when frontend is detached. *			drivers should free any allocated memory. * @init:		callback function used to initialize the tuner device. * @sleep:		callback function used to put the tuner to sleep. * @suspend:		callback function used to inform that the Kernel will *			suspend. * @resume:		callback function used to inform that the Kernel is *			resuming from suspend. * @set_params:		callback function used to inform the tuner to tune *			into a digital TV channel. The properties to be used *			are stored at &struct dvb_frontend.dtv_property_cache. *			The tuner demod can change the parameters to reflect *			the changes needed for the channel to be tuned, and *			update statistics. This is the recommended way to set *			the tuner parameters and should be used on newer *			drivers. * @set_analog_params:	callback function used to tune into an analog TV *			channel on hybrid tuners. It passes @analog_parameters *			to the driver. * @set_config:		callback function used to send some tuner-specific *			parameters. * @get_frequency:	get the actual tuned frequency * @get_bandwidth:	get the bandwidth used by the low pass filters * @get_if_frequency:	get the Intermediate Frequency, in Hz. For baseband, *			should return 0. * @get_status:		returns the frontend lock status * @get_rf_strength:	returns the RF signal strength. Used mostly to support *			analog TV and radio. Digital TV should report, instead, *			via DVBv5 API (&struct dvb_frontend.dtv_property_cache). * @get_afc:		Used only by analog TV core. Reports the frequency *			drift due to AFC. * @calc_regs:		callback function used to pass register data settings *			for simple tuners.  Shouldn't be used on newer drivers. * @set_frequency:	Set a new frequency. Shouldn't be used on newer drivers. * @set_bandwidth:	Set a new frequency. Shouldn't be used on newer drivers. * * NOTE: frequencies used on @get_frequency and @set_frequency are in Hz for * terrestrial/cable or kHz for satellite. * */struct dvb_tuner_ops { 	struct dvb_tuner_info info; 	void (*release)(struct dvb_frontend *fe);	int (*init)(struct dvb_frontend *fe);	int (*sleep)(struct dvb_frontend *fe);	int (*suspend)(struct dvb_frontend *fe);	int (*resume)(struct dvb_frontend *fe); 	/* This is the recommended way to set the tuner */	int (*set_params)(struct dvb_frontend *fe);	int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p); 	int (*set_config)(struct dvb_frontend *fe, void *priv_cfg); 	int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);	int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);	int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency); #define TUNER_STATUS_LOCKED 1#define TUNER_STATUS_STEREO 2	int (*get_status)(struct dvb_frontend *fe, u32 *status);	int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);	int (*get_afc)(struct dvb_frontend *fe, s32 *afc); 	/*	 * This is support for demods like the mt352 - fills out the supplied	 * buffer with what to write.	 *	 * Don't use on newer drivers.	 */	int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len); 	/*	 * These are provided separately from set_params in order to	 * facilitate silicon tuners which require sophisticated tuning loops,	 * controlling each parameter separately.	 *	 * Don't use on newer drivers.	 */	int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);	int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);}; /** * struct analog_demod_info - Information struct for analog TV part of the demod * * @name:	Name of the analog TV demodulator */struct analog_demod_info {	char *name;}; /** * struct analog_demod_ops  - Demodulation information and callbacks for *			      analog TV and radio * * @info:		pointer to struct analog_demod_info * @set_params:		callback function used to inform the demod to set the *			demodulator parameters needed to decode an analog or *			radio channel. The properties are passed via *			&struct analog_params. * @has_signal:		returns 0xffff if has signal, or 0 if it doesn't. * @get_afc:		Used only by analog TV core. Reports the frequency *			drift due to AFC. * @tuner_status:	callback function that returns tuner status bits, e. g. *			%TUNER_STATUS_LOCKED and %TUNER_STATUS_STEREO. * @standby:		set the tuner to standby mode. * @release:		callback function called when frontend is detached. *			drivers should free any allocated memory. * @i2c_gate_ctrl:	controls the I2C gate. Newer drivers should use I2C *			mux support instead. * @set_config:		callback function used to send some tuner-specific *			parameters. */struct analog_demod_ops { 	struct analog_demod_info info; 	void (*set_params)(struct dvb_frontend *fe,			   struct analog_parameters *params);	int  (*has_signal)(struct dvb_frontend *fe, u16 *signal);	int  (*get_afc)(struct dvb_frontend *fe, s32 *afc);	void (*tuner_status)(struct dvb_frontend *fe);	void (*standby)(struct dvb_frontend *fe);	void (*release)(struct dvb_frontend *fe);	int  (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable); 	/** This is to allow setting tuner-specific configuration */	int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);}; struct dtv_frontend_properties; /** * struct dvb_frontend_internal_info - Frontend properties and capabilities * * @name:			Name of the frontend * @frequency_min_hz:		Minimal frequency supported by the frontend. * @frequency_max_hz:		Minimal frequency supported by the frontend. * @frequency_stepsize_hz:	All frequencies are multiple of this value. * @frequency_tolerance_hz:	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). * @caps:			Capabilities supported by the frontend, *				as specified in &enum fe_caps. */struct dvb_frontend_internal_info {	char	name[128];	u32	frequency_min_hz;	u32	frequency_max_hz;	u32	frequency_stepsize_hz;	u32	frequency_tolerance_hz;	u32	symbol_rate_min;	u32	symbol_rate_max;	u32	symbol_rate_tolerance;	enum fe_caps caps;}; /** * struct dvb_frontend_ops - Demodulation information and callbacks for *			      ditialt TV * * @info:		embedded &struct dvb_tuner_info with tuner properties * @delsys:		Delivery systems supported by the frontend * @detach:		callback function called when frontend is detached. *			drivers should clean up, but not yet free the &struct *			dvb_frontend allocation. * @release:		callback function called when frontend is ready to be *			freed. *			drivers should free any allocated memory. * @release_sec:	callback function requesting that the Satellite Equipment *			Control (SEC) driver to release and free any memory *			allocated by the driver. * @init:		callback function used to initialize the tuner device. * @sleep:		callback function used to put the tuner to sleep. * @suspend:		callback function used to inform that the Kernel will *			suspend. * @resume:		callback function used to inform that the Kernel is *			resuming from suspend. * @write:		callback function used by some demod legacy drivers to *			allow other drivers to write data into their registers. *			Should not be used on new drivers. * @tune:		callback function used by demod drivers that use *			@DVBFE_ALGO_HW to tune into a frequency. * @get_frontend_algo:	returns the desired hardware algorithm. * @set_frontend:	callback function used to inform the demod to set the *			parameters for demodulating a digital TV channel. *			The properties to be used are stored at &struct *			dvb_frontend.dtv_property_cache. The demod can change *			the parameters to reflect the changes needed for the *			channel to be decoded, and update statistics. * @get_tune_settings:	callback function * @get_frontend:	callback function used to inform the parameters *			actuall in use. The properties to be used are stored at *			&struct dvb_frontend.dtv_property_cache and update *			statistics. Please notice that it should not return *			an error code if the statistics are not available *			because the demog is not locked. * @read_status:	returns the locking status of the frontend. * @read_ber:		legacy callback function to return the bit error rate. *			Newer drivers should provide such info via DVBv5 API, *			e. g. @set_frontend;/@get_frontend, implementing this *			callback only if DVBv3 API compatibility is wanted. * @read_signal_strength: legacy callback function to return the signal *			strength. Newer drivers should provide such info via *			DVBv5 API, e. g. @set_frontend/@get_frontend, *			implementing this callback only if DVBv3 API *			compatibility is wanted. * @read_snr:		legacy callback function to return the Signal/Noise *			rate. Newer drivers should provide such info via *			DVBv5 API, e. g. @set_frontend/@get_frontend, *			implementing this callback only if DVBv3 API *			compatibility is wanted. * @read_ucblocks:	legacy callback function to return the Uncorrected Error *			Blocks. Newer drivers should provide such info via *			DVBv5 API, e. g. @set_frontend/@get_frontend, *			implementing this callback only if DVBv3 API *			compatibility is wanted. * @diseqc_reset_overload: callback function to implement the *			FE_DISEQC_RESET_OVERLOAD() ioctl (only Satellite) * @diseqc_send_master_cmd: callback function to implement the *			FE_DISEQC_SEND_MASTER_CMD() ioctl (only Satellite). * @diseqc_recv_slave_reply: callback function to implement the *			FE_DISEQC_RECV_SLAVE_REPLY() ioctl (only Satellite) * @diseqc_send_burst:	callback function to implement the *			FE_DISEQC_SEND_BURST() ioctl (only Satellite). * @set_tone:		callback function to implement the *			FE_SET_TONE() ioctl (only Satellite). * @set_voltage:	callback function to implement the *			FE_SET_VOLTAGE() ioctl (only Satellite). * @enable_high_lnb_voltage: callback function to implement the *			FE_ENABLE_HIGH_LNB_VOLTAGE() ioctl (only Satellite). * @dishnetwork_send_legacy_command: callback function to implement the *			FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl (only Satellite). *			Drivers should not use this, except when the DVB *			core emulation fails to provide proper support (e.g. *			if @set_voltage takes more than 8ms to work), and *			when backward compatibility with this legacy API is *			required. * @i2c_gate_ctrl:	controls the I2C gate. Newer drivers should use I2C *			mux support instead. * @ts_bus_ctrl:	callback function used to take control of the TS bus. * @set_lna:		callback function to power on/off/auto the LNA. * @search:		callback function used on some custom algo search algos. * @tuner_ops:		pointer to &struct dvb_tuner_ops * @analog_ops:		pointer to &struct analog_demod_ops */struct dvb_frontend_ops {	struct dvb_frontend_internal_info info; 	u8 delsys[MAX_DELSYS]; 	void (*detach)(struct dvb_frontend *fe);	void (*release)(struct dvb_frontend* fe);	void (*release_sec)(struct dvb_frontend* fe); 	int (*init)(struct dvb_frontend* fe);	int (*sleep)(struct dvb_frontend* fe);	int (*suspend)(struct dvb_frontend *fe);	int (*resume)(struct dvb_frontend *fe); 	int (*write)(struct dvb_frontend* fe, const u8 buf[], int len); 	/* if this is set, it overrides the default swzigzag */	int (*tune)(struct dvb_frontend* fe,		    bool re_tune,		    unsigned int mode_flags,		    unsigned int *delay,		    enum fe_status *status); 	/* get frontend tuning algorithm from the module */	enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe); 	/* these two are only used for the swzigzag code */	int (*set_frontend)(struct dvb_frontend *fe);	int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings); 	int (*get_frontend)(struct dvb_frontend *fe,			    struct dtv_frontend_properties *props); 	int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);	int (*read_ber)(struct dvb_frontend* fe, u32* ber);	int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);	int (*read_snr)(struct dvb_frontend* fe, u16* snr);	int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks); 	int (*diseqc_reset_overload)(struct dvb_frontend* fe);	int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);	int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);	int (*diseqc_send_burst)(struct dvb_frontend *fe,				 enum fe_sec_mini_cmd minicmd);	int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone);	int (*set_voltage)(struct dvb_frontend *fe,			   enum fe_sec_voltage voltage);	int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);	int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);	int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);	int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);	int (*set_lna)(struct dvb_frontend *); 	/*	 * These callbacks are for devices that implement their own	 * tuning algorithms, rather than a simple swzigzag	 */	enum dvbfe_search (*search)(struct dvb_frontend *fe); 	struct dvb_tuner_ops tuner_ops;	struct analog_demod_ops analog_ops;};

Lines 1–500 of 834.