blob: f05cd7b94a2cf9eda7c2bdea397ffc5f29f40b05 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * dvb_frontend.h
3 *
Mauro Carvalho Chehabd26a5d42016-07-17 07:20:06 -03004 * The Digital TV Frontend kABI defines a driver-internal interface for
5 * registering low-level, hardware specific driver to a hardware independent
6 * frontend layer.
7 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Copyright (C) 2001 convergence integrated media GmbH
9 * Copyright (C) 2004 convergence GmbH
10 *
11 * Written by Ralph Metzler
12 * Overhauled by Holger Waechtler
13 * Kernel I2C stuff by Michael Hunold <hunold@convergence.de>
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public License
17 * as published by the Free Software Foundation; either version 2.1
18 * of the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25
26 * You should have received a copy of the GNU Lesser General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 *
30 */
31
32#ifndef _DVB_FRONTEND_H_
33#define _DVB_FRONTEND_H_
34
35#include <linux/types.h>
36#include <linux/sched.h>
37#include <linux/ioctl.h>
38#include <linux/i2c.h>
39#include <linux/module.h>
40#include <linux/errno.h>
41#include <linux/delay.h>
Matthias Kaehlcke03b761232007-07-30 14:58:10 -030042#include <linux/mutex.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090043#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45#include <linux/dvb/frontend.h>
46
Mauro Carvalho Chehabfada1932017-12-28 13:03:51 -050047#include <media/dvbdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Mauro Carvalho Chehabeeacf142011-12-22 08:56:48 -030049/*
50 * Maximum number of Delivery systems per frontend. It
51 * should be smaller or equal to 32
52 */
53#define MAX_DELSYS 8
54
Mauro Carvalho Chehaba3f90c72018-07-05 18:59:35 -040055/* Helper definitions to be used at frontend drivers */
56#define kHz 1000UL
57#define MHz 1000000UL
58
Mauro Carvalho Chehabb9de1722015-08-22 09:47:04 -030059/**
60 * struct dvb_frontend_tune_settings - parameters to adjust frontend tuning
61 *
62 * @min_delay_ms: minimum delay for tuning, in ms
63 * @step_size: step size between two consecutive frequencies
64 * @max_drift: maximum drift
65 *
66 * NOTE: step_size is in Hz, for terrestrial/cable or kHz for satellite
67 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070068struct dvb_frontend_tune_settings {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080069 int min_delay_ms;
70 int step_size;
71 int max_drift;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072};
73
74struct dvb_frontend;
75
Mauro Carvalho Chehab8bcbc2f32015-08-22 09:48:05 -030076/**
77 * struct dvb_tuner_info - Frontend name and min/max ranges/bandwidths
78 *
79 * @name: name of the Frontend
Mauro Carvalho Chehaba3f90c72018-07-05 18:59:35 -040080 * @frequency_min_hz: minimal frequency supported in Hz
81 * @frequency_max_hz: maximum frequency supported in Hz
82 * @frequency_step_hz: frequency step in Hz
Mauro Carvalho Chehab8bcbc2f32015-08-22 09:48:05 -030083 * @bandwidth_min: minimal frontend bandwidth supported
84 * @bandwidth_max: maximum frontend bandwidth supported
85 * @bandwidth_step: frontend bandwidth step
Mauro Carvalho Chehab8bcbc2f32015-08-22 09:48:05 -030086 */
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -030087struct dvb_tuner_info {
88 char name[128];
89
Mauro Carvalho Chehaba3f90c72018-07-05 18:59:35 -040090 u32 frequency_min_hz;
91 u32 frequency_max_hz;
92 u32 frequency_step_hz;
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -030093
94 u32 bandwidth_min;
95 u32 bandwidth_max;
96 u32 bandwidth_step;
97};
98
Mauro Carvalho Chehab1a777632015-08-22 09:58:26 -030099/**
100 * struct analog_parameters - Parameters to tune into an analog/radio channel
101 *
102 * @frequency: Frequency used by analog TV tuner (either in 62.5 kHz step,
Mauro Carvalho Chehab4a3fad72018-01-04 06:47:28 -0500103 * for TV, or 62.5 Hz for radio)
Mauro Carvalho Chehab1a777632015-08-22 09:58:26 -0300104 * @mode: Tuner mode, as defined on enum v4l2_tuner_type
105 * @audmode: Audio mode as defined for the rxsubchans field at videodev2.h,
Mauro Carvalho Chehab4a3fad72018-01-04 06:47:28 -0500106 * e. g. V4L2_TUNER_MODE_*
Mauro Carvalho Chehab1a777632015-08-22 09:58:26 -0300107 * @std: TV standard bitmap as defined at videodev2.h, e. g. V4L2_STD_*
108 *
109 * Hybrid tuners should be supported by both V4L2 and DVB APIs. This
110 * struct contains the data that are used by the V4L2 side. To avoid
111 * dependencies from V4L2 headers, all enums here are declared as integers.
112 */
Michael Krufkye18f9442007-08-21 01:25:48 -0300113struct analog_parameters {
114 unsigned int frequency;
115 unsigned int mode;
116 unsigned int audmode;
117 u64 std;
118};
119
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300120/**
121 * enum dvbfe_algo - defines the algorithm used to tune into a channel
Manu Abrahamc59e7872008-10-14 16:34:07 -0300122 *
Mauro Carvalho Chehab1a777632015-08-22 09:58:26 -0300123 * @DVBFE_ALGO_HW: Hardware Algorithm -
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300124 * Devices that support this algorithm do everything in hardware
125 * and no software support is needed to handle them.
126 * Requesting these devices to LOCK is the only thing required,
127 * device is supposed to do everything in the hardware.
128 *
Mauro Carvalho Chehab1a777632015-08-22 09:58:26 -0300129 * @DVBFE_ALGO_SW: Software Algorithm -
Manu Abrahamc59e7872008-10-14 16:34:07 -0300130 * These are dumb devices, that require software to do everything
131 *
Mauro Carvalho Chehab1a777632015-08-22 09:58:26 -0300132 * @DVBFE_ALGO_CUSTOM: Customizable Agorithm -
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300133 * Devices having this algorithm can be customized to have specific
134 * algorithms in the frontend driver, rather than simply doing a
135 * software zig-zag. In this case the zigzag maybe hardware assisted
136 * or it maybe completely done in hardware. In all cases, usage of
137 * this algorithm, in conjunction with the search and track
138 * callbacks, utilizes the driver specific algorithm.
Manu Abrahamc59e7872008-10-14 16:34:07 -0300139 *
Mauro Carvalho Chehab1a777632015-08-22 09:58:26 -0300140 * @DVBFE_ALGO_RECOVERY: Recovery Algorithm -
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300141 * These devices have AUTO recovery capabilities from LOCK failure
Manu Abrahamc59e7872008-10-14 16:34:07 -0300142 */
143enum dvbfe_algo {
144 DVBFE_ALGO_HW = (1 << 0),
145 DVBFE_ALGO_SW = (1 << 1),
146 DVBFE_ALGO_CUSTOM = (1 << 2),
147 DVBFE_ALGO_RECOVERY = (1 << 31)
148};
149
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300150/**
151 * enum dvbfe_search - search callback possible return status
Manu Abrahamc59e7872008-10-14 16:34:07 -0300152 *
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300153 * @DVBFE_ALGO_SEARCH_SUCCESS:
154 * The frontend search algorithm completed and returned successfully
Manu Abrahamc59e7872008-10-14 16:34:07 -0300155 *
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300156 * @DVBFE_ALGO_SEARCH_ASLEEP:
157 * The frontend search algorithm is sleeping
Manu Abrahamc59e7872008-10-14 16:34:07 -0300158 *
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300159 * @DVBFE_ALGO_SEARCH_FAILED:
160 * The frontend search for a signal failed
Manu Abrahamc59e7872008-10-14 16:34:07 -0300161 *
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300162 * @DVBFE_ALGO_SEARCH_INVALID:
Mauro Carvalho Chehabe907bf32019-02-18 14:29:06 -0500163 * The frontend search algorithm was probably supplied with invalid
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300164 * parameters and the search is an invalid one
Manu Abrahamc59e7872008-10-14 16:34:07 -0300165 *
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300166 * @DVBFE_ALGO_SEARCH_ERROR:
167 * The frontend search algorithm failed due to some error
Manu Abrahamc59e7872008-10-14 16:34:07 -0300168 *
Mauro Carvalho Chehab4f1c1862015-08-22 07:19:20 -0300169 * @DVBFE_ALGO_SEARCH_AGAIN:
170 * The frontend search algorithm was requested to search again
Manu Abrahamc59e7872008-10-14 16:34:07 -0300171 */
172enum dvbfe_search {
173 DVBFE_ALGO_SEARCH_SUCCESS = (1 << 0),
174 DVBFE_ALGO_SEARCH_ASLEEP = (1 << 1),
175 DVBFE_ALGO_SEARCH_FAILED = (1 << 2),
176 DVBFE_ALGO_SEARCH_INVALID = (1 << 3),
177 DVBFE_ALGO_SEARCH_AGAIN = (1 << 4),
178 DVBFE_ALGO_SEARCH_ERROR = (1 << 31),
179};
180
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300181/**
182 * struct dvb_tuner_ops - Tuner information and callbacks
183 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400184 * @info: embedded &struct dvb_tuner_info with tuner properties
185 * @release: callback function called when frontend is detached.
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300186 * drivers should free any allocated memory.
187 * @init: callback function used to initialize the tuner device.
188 * @sleep: callback function used to put the tuner to sleep.
189 * @suspend: callback function used to inform that the Kernel will
190 * suspend.
191 * @resume: callback function used to inform that the Kernel is
192 * resuming from suspend.
193 * @set_params: callback function used to inform the tuner to tune
194 * into a digital TV channel. The properties to be used
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400195 * are stored at &struct dvb_frontend.dtv_property_cache.
196 * The tuner demod can change the parameters to reflect
197 * the changes needed for the channel to be tuned, and
Mauro Carvalho Chehabbef0e542015-11-11 19:14:44 -0200198 * update statistics. This is the recommended way to set
199 * the tuner parameters and should be used on newer
200 * drivers.
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300201 * @set_analog_params: callback function used to tune into an analog TV
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400202 * channel on hybrid tuners. It passes @analog_parameters
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300203 * to the driver.
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300204 * @set_config: callback function used to send some tuner-specific
205 * parameters.
206 * @get_frequency: get the actual tuned frequency
Mauro Carvalho Chehabe907bf32019-02-18 14:29:06 -0500207 * @get_bandwidth: get the bandwidth used by the low pass filters
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300208 * @get_if_frequency: get the Intermediate Frequency, in Hz. For baseband,
Mauro Carvalho Chehab4a3fad72018-01-04 06:47:28 -0500209 * should return 0.
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300210 * @get_status: returns the frontend lock status
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400211 * @get_rf_strength: returns the RF signal strength. Used mostly to support
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300212 * analog TV and radio. Digital TV should report, instead,
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400213 * via DVBv5 API (&struct dvb_frontend.dtv_property_cache).
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300214 * @get_afc: Used only by analog TV core. Reports the frequency
215 * drift due to AFC.
Mauro Carvalho Chehabbef0e542015-11-11 19:14:44 -0200216 * @calc_regs: callback function used to pass register data settings
217 * for simple tuners. Shouldn't be used on newer drivers.
218 * @set_frequency: Set a new frequency. Shouldn't be used on newer drivers.
219 * @set_bandwidth: Set a new frequency. Shouldn't be used on newer drivers.
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300220 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400221 * NOTE: frequencies used on @get_frequency and @set_frequency are in Hz for
Mauro Carvalho Chehab465291a2015-08-22 11:13:37 -0300222 * terrestrial/cable or kHz for satellite.
223 *
224 */
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300225struct dvb_tuner_ops {
Andrew de Quinceyf6adb912006-04-18 21:37:20 -0300226
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300227 struct dvb_tuner_info info;
228
Max Kellermann194ced72016-08-09 18:32:31 -0300229 void (*release)(struct dvb_frontend *fe);
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300230 int (*init)(struct dvb_frontend *fe);
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300231 int (*sleep)(struct dvb_frontend *fe);
Mauro Carvalho Chehab59d78892014-08-09 21:47:19 -0300232 int (*suspend)(struct dvb_frontend *fe);
233 int (*resume)(struct dvb_frontend *fe);
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300234
Mauro Carvalho Chehabe907bf32019-02-18 14:29:06 -0500235 /* This is the recommended way to set the tuner */
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300236 int (*set_params)(struct dvb_frontend *fe);
Michael Krufkye18f9442007-08-21 01:25:48 -0300237 int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300238
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -0300239 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
240
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300241 int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300242 int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
Mauro Carvalho Chehab8513e142011-09-03 11:40:02 -0300243 int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency);
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300244
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300245#define TUNER_STATUS_LOCKED 1
Michael Krufkye18f9442007-08-21 01:25:48 -0300246#define TUNER_STATUS_STEREO 2
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300247 int (*get_status)(struct dvb_frontend *fe, u32 *status);
Michael Krufky8fb3b9f2007-08-30 23:00:43 -0300248 int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
Mauro Carvalho Chehab1d432a32012-07-04 02:33:55 -0300249 int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300250
Mauro Carvalho Chehabbef0e542015-11-11 19:14:44 -0200251 /*
252 * This is support for demods like the mt352 - fills out the supplied
253 * buffer with what to write.
254 *
255 * Don't use on newer drivers.
256 */
257 int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
258
259 /*
260 * These are provided separately from set_params in order to
261 * facilitate silicon tuners which require sophisticated tuning loops,
262 * controlling each parameter separately.
263 *
264 * Don't use on newer drivers.
265 */
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300266 int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300267 int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
268};
269
Mauro Carvalho Chehab0bf6cd72015-08-22 11:35:50 -0300270/**
271 * struct analog_demod_info - Information struct for analog TV part of the demod
272 *
273 * @name: Name of the analog TV demodulator
274 */
Michael Krufky807ffe82007-12-21 02:55:43 -0300275struct analog_demod_info {
276 char *name;
277};
278
Mauro Carvalho Chehab0bf6cd72015-08-22 11:35:50 -0300279/**
280 * struct analog_demod_ops - Demodulation information and callbacks for
281 * analog TV and radio
282 *
283 * @info: pointer to struct analog_demod_info
284 * @set_params: callback function used to inform the demod to set the
285 * demodulator parameters needed to decode an analog or
286 * radio channel. The properties are passed via
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400287 * &struct analog_params.
Mauro Carvalho Chehab0bf6cd72015-08-22 11:35:50 -0300288 * @has_signal: returns 0xffff if has signal, or 0 if it doesn't.
289 * @get_afc: Used only by analog TV core. Reports the frequency
290 * drift due to AFC.
291 * @tuner_status: callback function that returns tuner status bits, e. g.
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400292 * %TUNER_STATUS_LOCKED and %TUNER_STATUS_STEREO.
Mauro Carvalho Chehab0bf6cd72015-08-22 11:35:50 -0300293 * @standby: set the tuner to standby mode.
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400294 * @release: callback function called when frontend is detached.
Mauro Carvalho Chehab0bf6cd72015-08-22 11:35:50 -0300295 * drivers should free any allocated memory.
296 * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C
297 * mux support instead.
298 * @set_config: callback function used to send some tuner-specific
299 * parameters.
300 */
Michael Krufkybc3e5c72007-12-21 11:18:32 -0300301struct analog_demod_ops {
Michael Krufky807ffe82007-12-21 02:55:43 -0300302
303 struct analog_demod_info info;
304
305 void (*set_params)(struct dvb_frontend *fe,
306 struct analog_parameters *params);
Hans Verkuildfc2e122013-04-06 04:41:29 -0300307 int (*has_signal)(struct dvb_frontend *fe, u16 *signal);
Hans Verkuila2192cf2013-04-06 04:35:27 -0300308 int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
Michael Krufky807ffe82007-12-21 02:55:43 -0300309 void (*tuner_status)(struct dvb_frontend *fe);
310 void (*standby)(struct dvb_frontend *fe);
311 void (*release)(struct dvb_frontend *fe);
312 int (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
313
314 /** This is to allow setting tuner-specific configuration */
315 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
316};
317
Mauro Carvalho Chehaba689e362011-12-22 14:47:48 -0300318struct dtv_frontend_properties;
319
Mauro Carvalho Chehabf1b1eab2018-07-05 18:59:36 -0400320/**
321 * struct dvb_frontend_internal_info - Frontend properties and capabilities
322 *
323 * @name: Name of the frontend
324 * @frequency_min_hz: Minimal frequency supported by the frontend.
325 * @frequency_max_hz: Minimal frequency supported by the frontend.
326 * @frequency_stepsize_hz: All frequencies are multiple of this value.
327 * @frequency_tolerance_hz: Frequency tolerance.
328 * @symbol_rate_min: Minimal symbol rate, in bauds
329 * (for Cable/Satellite systems).
330 * @symbol_rate_max: Maximal symbol rate, in bauds
331 * (for Cable/Satellite systems).
332 * @symbol_rate_tolerance: Maximal symbol rate tolerance, in ppm
333 * (for Cable/Satellite systems).
334 * @caps: Capabilities supported by the frontend,
335 * as specified in &enum fe_caps.
336 */
337struct dvb_frontend_internal_info {
338 char name[128];
339 u32 frequency_min_hz;
340 u32 frequency_max_hz;
341 u32 frequency_stepsize_hz;
342 u32 frequency_tolerance_hz;
343 u32 symbol_rate_min;
344 u32 symbol_rate_max;
345 u32 symbol_rate_tolerance;
346 enum fe_caps caps;
347};
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300348
349/**
Mauro Carvalho Chehaba3cccb22015-08-22 14:10:31 -0300350 * struct dvb_frontend_ops - Demodulation information and callbacks for
351 * ditialt TV
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300352 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400353 * @info: embedded &struct dvb_tuner_info with tuner properties
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300354 * @delsys: Delivery systems supported by the frontend
Max Kellermannd812b3c2016-08-09 18:32:41 -0300355 * @detach: callback function called when frontend is detached.
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400356 * drivers should clean up, but not yet free the &struct
Max Kellermannd812b3c2016-08-09 18:32:41 -0300357 * dvb_frontend allocation.
358 * @release: callback function called when frontend is ready to be
359 * freed.
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300360 * drivers should free any allocated memory.
Mauro Carvalho Chehabe907bf32019-02-18 14:29:06 -0500361 * @release_sec: callback function requesting that the Satellite Equipment
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300362 * Control (SEC) driver to release and free any memory
363 * allocated by the driver.
364 * @init: callback function used to initialize the tuner device.
365 * @sleep: callback function used to put the tuner to sleep.
366 * @write: callback function used by some demod legacy drivers to
367 * allow other drivers to write data into their registers.
368 * Should not be used on new drivers.
369 * @tune: callback function used by demod drivers that use
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400370 * @DVBFE_ALGO_HW to tune into a frequency.
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300371 * @get_frontend_algo: returns the desired hardware algorithm.
372 * @set_frontend: callback function used to inform the demod to set the
373 * parameters for demodulating a digital TV channel.
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400374 * The properties to be used are stored at &struct
375 * dvb_frontend.dtv_property_cache. The demod can change
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300376 * the parameters to reflect the changes needed for the
377 * channel to be decoded, and update statistics.
378 * @get_tune_settings: callback function
379 * @get_frontend: callback function used to inform the parameters
380 * actuall in use. The properties to be used are stored at
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400381 * &struct dvb_frontend.dtv_property_cache and update
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300382 * statistics. Please notice that it should not return
383 * an error code if the statistics are not available
384 * because the demog is not locked.
385 * @read_status: returns the locking status of the frontend.
386 * @read_ber: legacy callback function to return the bit error rate.
387 * Newer drivers should provide such info via DVBv5 API,
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400388 * e. g. @set_frontend;/@get_frontend, implementing this
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300389 * callback only if DVBv3 API compatibility is wanted.
390 * @read_signal_strength: legacy callback function to return the signal
391 * strength. Newer drivers should provide such info via
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400392 * DVBv5 API, e. g. @set_frontend/@get_frontend,
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300393 * implementing this callback only if DVBv3 API
394 * compatibility is wanted.
395 * @read_snr: legacy callback function to return the Signal/Noise
Mauro Carvalho Chehab4a3fad72018-01-04 06:47:28 -0500396 * rate. Newer drivers should provide such info via
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400397 * DVBv5 API, e. g. @set_frontend/@get_frontend,
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300398 * implementing this callback only if DVBv3 API
399 * compatibility is wanted.
400 * @read_ucblocks: legacy callback function to return the Uncorrected Error
401 * Blocks. Newer drivers should provide such info via
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400402 * DVBv5 API, e. g. @set_frontend/@get_frontend,
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300403 * implementing this callback only if DVBv3 API
404 * compatibility is wanted.
405 * @diseqc_reset_overload: callback function to implement the
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400406 * FE_DISEQC_RESET_OVERLOAD() ioctl (only Satellite)
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300407 * @diseqc_send_master_cmd: callback function to implement the
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400408 * FE_DISEQC_SEND_MASTER_CMD() ioctl (only Satellite).
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300409 * @diseqc_recv_slave_reply: callback function to implement the
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400410 * FE_DISEQC_RECV_SLAVE_REPLY() ioctl (only Satellite)
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300411 * @diseqc_send_burst: callback function to implement the
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400412 * FE_DISEQC_SEND_BURST() ioctl (only Satellite).
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300413 * @set_tone: callback function to implement the
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400414 * FE_SET_TONE() ioctl (only Satellite).
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300415 * @set_voltage: callback function to implement the
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400416 * FE_SET_VOLTAGE() ioctl (only Satellite).
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300417 * @enable_high_lnb_voltage: callback function to implement the
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400418 * FE_ENABLE_HIGH_LNB_VOLTAGE() ioctl (only Satellite).
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300419 * @dishnetwork_send_legacy_command: callback function to implement the
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400420 * FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl (only Satellite).
Mauro Carvalho Chehab4deea4c2015-11-09 23:24:10 -0200421 * Drivers should not use this, except when the DVB
422 * core emulation fails to provide proper support (e.g.
Mauro Carvalho Chehab564aaf62016-07-23 07:12:03 -0300423 * if @set_voltage takes more than 8ms to work), and
Mauro Carvalho Chehab4deea4c2015-11-09 23:24:10 -0200424 * when backward compatibility with this legacy API is
425 * required.
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300426 * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C
427 * mux support instead.
428 * @ts_bus_ctrl: callback function used to take control of the TS bus.
429 * @set_lna: callback function to power on/off/auto the LNA.
430 * @search: callback function used on some custom algo search algos.
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400431 * @tuner_ops: pointer to &struct dvb_tuner_ops
432 * @analog_ops: pointer to &struct analog_demod_ops
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300433 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434struct dvb_frontend_ops {
Mauro Carvalho Chehabf1b1eab2018-07-05 18:59:36 -0400435 struct dvb_frontend_internal_info info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436
Mauro Carvalho Chehabeeacf142011-12-22 08:56:48 -0300437 u8 delsys[MAX_DELSYS];
438
Max Kellermannd812b3c2016-08-09 18:32:41 -0300439 void (*detach)(struct dvb_frontend *fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 void (*release)(struct dvb_frontend* fe);
Andrew de Quincey94cbae52006-08-08 09:10:07 -0300441 void (*release_sec)(struct dvb_frontend* fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
443 int (*init)(struct dvb_frontend* fe);
444 int (*sleep)(struct dvb_frontend* fe);
445
lawrence rust2e4e98e2010-08-25 09:50:20 -0300446 int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);
Andrew de Quincey94cbae52006-08-08 09:10:07 -0300447
Andrew de Quincey36cb5572006-01-09 15:25:07 -0200448 /* if this is set, it overrides the default swzigzag */
449 int (*tune)(struct dvb_frontend* fe,
Mauro Carvalho Chehab7e072222011-12-26 17:48:33 -0300450 bool re_tune,
Andrew de Quincey36cb5572006-01-09 15:25:07 -0200451 unsigned int mode_flags,
Oliver Endriss260f8d72007-07-13 11:54:35 -0300452 unsigned int *delay,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300453 enum fe_status *status);
Mauro Carvalho Chehab0cfcc492015-08-22 13:28:02 -0300454
Manu Abraham0249ef12006-06-21 10:27:31 -0300455 /* get frontend tuning algorithm from the module */
Manu Abrahamc59e7872008-10-14 16:34:07 -0300456 enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);
Andrew de Quincey36cb5572006-01-09 15:25:07 -0200457
458 /* these two are only used for the swzigzag code */
Mauro Carvalho Chehabbc9cd272011-12-20 15:31:54 -0300459 int (*set_frontend)(struct dvb_frontend *fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
461
Mauro Carvalho Chehab7e3e68b2016-02-04 12:58:30 -0200462 int (*get_frontend)(struct dvb_frontend *fe,
463 struct dtv_frontend_properties *props);
Andrew de Quincey36cb5572006-01-09 15:25:07 -0200464
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300465 int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 int (*read_ber)(struct dvb_frontend* fe, u32* ber);
467 int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
468 int (*read_snr)(struct dvb_frontend* fe, u16* snr);
469 int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
470
471 int (*diseqc_reset_overload)(struct dvb_frontend* fe);
472 int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
473 int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300474 int (*diseqc_send_burst)(struct dvb_frontend *fe,
475 enum fe_sec_mini_cmd minicmd);
476 int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone);
477 int (*set_voltage)(struct dvb_frontend *fe,
478 enum fe_sec_voltage voltage);
Peter Beutner400b7082006-01-09 15:32:43 -0200479 int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
480 int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
Steven Toth611900c2006-01-09 15:25:12 -0200481 int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
Steven Tothba7e6f32006-09-25 12:41:53 -0300482 int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
Antti Palosaari33eebec2012-10-03 04:28:56 -0300483 int (*set_lna)(struct dvb_frontend *);
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300484
Mauro Carvalho Chehabbef0e542015-11-11 19:14:44 -0200485 /*
486 * These callbacks are for devices that implement their own
Manu Abrahamc59e7872008-10-14 16:34:07 -0300487 * tuning algorithms, rather than a simple swzigzag
488 */
Mauro Carvalho Chehab41da5322011-12-26 18:03:12 -0300489 enum dvbfe_search (*search)(struct dvb_frontend *fe);
Manu Abrahamc59e7872008-10-14 16:34:07 -0300490
Andrew de Quincey7eef5dd2006-04-18 17:47:09 -0300491 struct dvb_tuner_ops tuner_ops;
Michael Krufkybc3e5c72007-12-21 11:18:32 -0300492 struct analog_demod_ops analog_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493};
494
Mauro Carvalho Chehab8de85942011-12-26 20:22:50 -0300495#ifdef __DVB_CORE__
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496#define MAX_EVENT 8
497
Mauro Carvalho Chehaba3cccb22015-08-22 14:10:31 -0300498/* Used only internally at dvb_frontend.c */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499struct dvb_fe_events {
500 struct dvb_frontend_event events[MAX_EVENT];
501 int eventw;
502 int eventr;
503 int overflow;
504 wait_queue_head_t wait_queue;
Matthias Kaehlcke03b761232007-07-30 14:58:10 -0300505 struct mutex mtx;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506};
Mauro Carvalho Chehab8de85942011-12-26 20:22:50 -0300507#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
Mauro Carvalho Chehaba3cccb22015-08-22 14:10:31 -0300509/**
510 * struct dtv_frontend_properties - contains a list of properties that are
511 * specific to a digital TV standard.
512 *
513 * @frequency: frequency in Hz for terrestrial/cable or in kHz for
514 * Satellite
515 * @modulation: Frontend modulation type
516 * @voltage: SEC voltage (only Satellite)
517 * @sectone: SEC tone mode (only Satellite)
518 * @inversion: Spectral inversion
519 * @fec_inner: Forward error correction inner Code Rate
520 * @transmission_mode: Transmission Mode
521 * @bandwidth_hz: Bandwidth, in Hz. A zero value means that userspace
Mauro Carvalho Chehab4a3fad72018-01-04 06:47:28 -0500522 * wants to autodetect.
Mauro Carvalho Chehaba3cccb22015-08-22 14:10:31 -0300523 * @guard_interval: Guard Interval
524 * @hierarchy: Hierarchy
525 * @symbol_rate: Symbol Rate
526 * @code_rate_HP: high priority stream code rate
527 * @code_rate_LP: low priority stream code rate
528 * @pilot: Enable/disable/autodetect pilot tones
529 * @rolloff: Rolloff factor (alpha)
530 * @delivery_system: FE delivery system (e. g. digital TV standard)
531 * @interleaving: interleaving
532 * @isdbt_partial_reception: ISDB-T partial reception (only ISDB standard)
533 * @isdbt_sb_mode: ISDB-T Sound Broadcast (SB) mode (only ISDB standard)
534 * @isdbt_sb_subchannel: ISDB-T SB subchannel (only ISDB standard)
535 * @isdbt_sb_segment_idx: ISDB-T SB segment index (only ISDB standard)
536 * @isdbt_sb_segment_count: ISDB-T SB segment count (only ISDB standard)
537 * @isdbt_layer_enabled: ISDB Layer enabled (only ISDB standard)
538 * @layer: ISDB per-layer data (only ISDB standard)
539 * @layer.segment_count: Segment Count;
540 * @layer.fec: per layer code rate;
541 * @layer.modulation: per layer modulation;
542 * @layer.interleaving: per layer interleaving.
543 * @stream_id: If different than zero, enable substream filtering, if
544 * hardware supports (DVB-S2 and DVB-T2).
Athanasios Oikonomouf9d79122017-12-16 07:23:38 -0500545 * @scrambling_sequence_index: Carries the index of the DVB-S2 physical layer
546 * scrambling sequence.
Mauro Carvalho Chehaba3cccb22015-08-22 14:10:31 -0300547 * @atscmh_fic_ver: Version number of the FIC (Fast Information Channel)
548 * signaling data (only ATSC-M/H)
549 * @atscmh_parade_id: Parade identification number (only ATSC-M/H)
550 * @atscmh_nog: Number of MH groups per MH subframe for a designated
551 * parade (only ATSC-M/H)
552 * @atscmh_tnog: Total number of MH groups including all MH groups
553 * belonging to all MH parades in one MH subframe
554 * (only ATSC-M/H)
555 * @atscmh_sgn: Start group number (only ATSC-M/H)
556 * @atscmh_prc: Parade repetition cycle (only ATSC-M/H)
557 * @atscmh_rs_frame_mode: Reed Solomon (RS) frame mode (only ATSC-M/H)
558 * @atscmh_rs_frame_ensemble: RS frame ensemble (only ATSC-M/H)
559 * @atscmh_rs_code_mode_pri: RS code mode pri (only ATSC-M/H)
560 * @atscmh_rs_code_mode_sec: RS code mode sec (only ATSC-M/H)
561 * @atscmh_sccc_block_mode: Series Concatenated Convolutional Code (SCCC)
562 * Block Mode (only ATSC-M/H)
563 * @atscmh_sccc_code_mode_a: SCCC code mode A (only ATSC-M/H)
564 * @atscmh_sccc_code_mode_b: SCCC code mode B (only ATSC-M/H)
565 * @atscmh_sccc_code_mode_c: SCCC code mode C (only ATSC-M/H)
566 * @atscmh_sccc_code_mode_d: SCCC code mode D (only ATSC-M/H)
567 * @lna: Power ON/OFF/AUTO the Linear Now-noise Amplifier (LNA)
568 * @strength: DVBv5 API statistics: Signal Strength
569 * @cnr: DVBv5 API statistics: Signal to Noise ratio of the
Mauro Carvalho Chehab4a3fad72018-01-04 06:47:28 -0500570 * (main) carrier
Mauro Carvalho Chehaba3cccb22015-08-22 14:10:31 -0300571 * @pre_bit_error: DVBv5 API statistics: pre-Viterbi bit error count
572 * @pre_bit_count: DVBv5 API statistics: pre-Viterbi bit count
573 * @post_bit_error: DVBv5 API statistics: post-Viterbi bit error count
574 * @post_bit_count: DVBv5 API statistics: post-Viterbi bit count
575 * @block_error: DVBv5 API statistics: block error count
576 * @block_count: DVBv5 API statistics: block count
577 *
578 * NOTE: derivated statistics like Uncorrected Error blocks (UCE) are
579 * calculated on userspace.
580 *
581 * Only a subset of the properties are needed for a given delivery system.
582 * For more info, consult the media_api.html with the documentation of the
583 * Userspace API.
584 */
Steven Toth56f06802008-09-11 10:19:27 -0300585struct dtv_frontend_properties {
Steven Toth6b73eea2008-09-04 01:12:25 -0300586 u32 frequency;
Mauro Carvalho Chehaba3cccb22015-08-22 14:10:31 -0300587 enum fe_modulation modulation;
Steven Toth6b73eea2008-09-04 01:12:25 -0300588
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300589 enum fe_sec_voltage voltage;
590 enum fe_sec_tone_mode sectone;
Mauro Carvalho Chehabceb22c82017-09-18 07:32:44 -0400591 enum fe_spectral_inversion inversion;
592 enum fe_code_rate fec_inner;
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300593 enum fe_transmit_mode transmission_mode;
Steven Toth75b7f942008-09-13 16:56:34 -0300594 u32 bandwidth_hz; /* 0 = AUTO */
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300595 enum fe_guard_interval guard_interval;
Mauro Carvalho Chehabceb22c82017-09-18 07:32:44 -0400596 enum fe_hierarchy hierarchy;
Steven Toth6b73eea2008-09-04 01:12:25 -0300597 u32 symbol_rate;
Mauro Carvalho Chehabceb22c82017-09-18 07:32:44 -0400598 enum fe_code_rate code_rate_HP;
599 enum fe_code_rate code_rate_LP;
Steven Toth6b73eea2008-09-04 01:12:25 -0300600
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300601 enum fe_pilot pilot;
602 enum fe_rolloff rolloff;
Steven Toth6b73eea2008-09-04 01:12:25 -0300603
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300604 enum fe_delivery_system delivery_system;
Patrick Boettcherb6e760f2009-08-03 14:39:15 -0300605
Antti Palosaari224b6642012-08-12 22:33:21 -0300606 enum fe_interleaving interleaving;
607
Patrick Boettcherb6e760f2009-08-03 14:39:15 -0300608 /* ISDB-T specifics */
609 u8 isdbt_partial_reception;
610 u8 isdbt_sb_mode;
611 u8 isdbt_sb_subchannel;
612 u32 isdbt_sb_segment_idx;
613 u32 isdbt_sb_segment_count;
614 u8 isdbt_layer_enabled;
615 struct {
616 u8 segment_count;
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300617 enum fe_code_rate fec;
618 enum fe_modulation modulation;
Patrick Boettcherb6e760f2009-08-03 14:39:15 -0300619 u8 interleaving;
620 } layer[3];
HIRANO Takahito98293ef2009-09-18 11:17:54 -0300621
Evgeny Plehov287cefd2012-09-13 10:13:30 -0300622 /* Multistream specifics */
623 u32 stream_id;
Michael Krufkyca689482012-01-29 15:44:58 -0300624
Athanasios Oikonomouf9d79122017-12-16 07:23:38 -0500625 /* Physical Layer Scrambling specifics */
626 u32 scrambling_sequence_index;
627
Michael Krufkyca689482012-01-29 15:44:58 -0300628 /* ATSC-MH specifics */
629 u8 atscmh_fic_ver;
630 u8 atscmh_parade_id;
631 u8 atscmh_nog;
632 u8 atscmh_tnog;
633 u8 atscmh_sgn;
634 u8 atscmh_prc;
635
636 u8 atscmh_rs_frame_mode;
637 u8 atscmh_rs_frame_ensemble;
638 u8 atscmh_rs_code_mode_pri;
639 u8 atscmh_rs_code_mode_sec;
640 u8 atscmh_sccc_block_mode;
641 u8 atscmh_sccc_code_mode_a;
642 u8 atscmh_sccc_code_mode_b;
643 u8 atscmh_sccc_code_mode_c;
644 u8 atscmh_sccc_code_mode_d;
Antti Palosaari33eebec2012-10-03 04:28:56 -0300645
646 u32 lna;
Mauro Carvalho Chehab7cd4ece2013-01-07 15:41:35 -0300647
648 /* statistics data */
649 struct dtv_fe_stats strength;
650 struct dtv_fe_stats cnr;
651 struct dtv_fe_stats pre_bit_error;
652 struct dtv_fe_stats pre_bit_count;
653 struct dtv_fe_stats post_bit_error;
654 struct dtv_fe_stats post_bit_count;
655 struct dtv_fe_stats block_error;
656 struct dtv_fe_stats block_count;
Steven Toth6b73eea2008-09-04 01:12:25 -0300657};
658
Shuah Khan18ed2862014-07-12 13:44:12 -0300659#define DVB_FE_NO_EXIT 0
660#define DVB_FE_NORMAL_EXIT 1
661#define DVB_FE_DEVICE_REMOVED 2
Shuah Khan87cd0fa2014-07-24 13:02:14 -0300662#define DVB_FE_DEVICE_RESUME 3
Shuah Khan18ed2862014-07-12 13:44:12 -0300663
Mauro Carvalho Chehab35848bf2015-08-22 14:20:25 -0300664/**
665 * struct dvb_frontend - Frontend structure to be used on drivers.
666 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400667 * @refcount: refcount to keep track of &struct dvb_frontend
Sakari Ailus6eb19512017-03-09 12:19:32 -0300668 * references
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400669 * @ops: embedded &struct dvb_frontend_ops
670 * @dvb: pointer to &struct dvb_adapter
Mauro Carvalho Chehab35848bf2015-08-22 14:20:25 -0300671 * @demodulator_priv: demod private data
672 * @tuner_priv: tuner private data
673 * @frontend_priv: frontend private data
674 * @sec_priv: SEC private data
675 * @analog_demod_priv: Analog demod private data
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400676 * @dtv_property_cache: embedded &struct dtv_frontend_properties
Mauro Carvalho Chehab35848bf2015-08-22 14:20:25 -0300677 * @callback: callback function used on some drivers to call
678 * either the tuner or the demodulator.
679 * @id: Frontend ID
680 * @exit: Used to inform the DVB core that the frontend
681 * thread should exit (usually, means that the hardware
682 * got disconnected.
683 */
684
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685struct dvb_frontend {
Max Kellermann1f862a62016-08-09 18:32:51 -0300686 struct kref refcount;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300687 struct dvb_frontend_ops ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 struct dvb_adapter *dvb;
Michael Krufky482b4982007-10-22 00:12:16 -0300689 void *demodulator_priv;
690 void *tuner_priv;
691 void *frontend_priv;
692 void *sec_priv;
693 void *analog_demod_priv;
Steven Toth56f06802008-09-11 10:19:27 -0300694 struct dtv_frontend_properties dtv_property_cache;
Michael Krufkyebb8d68a2008-09-10 01:39:20 -0300695#define DVB_FRONTEND_COMPONENT_TUNER 0
Antti Palosaarib748e6a2012-01-10 20:33:43 -0300696#define DVB_FRONTEND_COMPONENT_DEMOD 1
Michael Krufkyebb8d68a2008-09-10 01:39:20 -0300697 int (*callback)(void *adapter_priv, int component, int cmd, int arg);
Steven Toth363c35f2008-10-11 11:05:50 -0300698 int id;
Shuah Khan18ed2862014-07-12 13:44:12 -0300699 unsigned int exit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700};
701
Mauro Carvalho Chehab66f4b3c2015-11-10 10:46:25 -0200702/**
703 * dvb_register_frontend() - Registers a DVB frontend at the adapter
704 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400705 * @dvb: pointer to &struct dvb_adapter
706 * @fe: pointer to &struct dvb_frontend
Mauro Carvalho Chehab66f4b3c2015-11-10 10:46:25 -0200707 *
708 * Allocate and initialize the private data needed by the frontend core to
709 * manage the frontend and calls dvb_register_device() to register a new
710 * frontend. It also cleans the property cache that stores the frontend
711 * parameters and selects the first available delivery system.
712 */
713int dvb_register_frontend(struct dvb_adapter *dvb,
Michael Krufky482b4982007-10-22 00:12:16 -0300714 struct dvb_frontend *fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715
Mauro Carvalho Chehab66f4b3c2015-11-10 10:46:25 -0200716/**
717 * dvb_unregister_frontend() - Unregisters a DVB frontend
718 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400719 * @fe: pointer to &struct dvb_frontend
Mauro Carvalho Chehab66f4b3c2015-11-10 10:46:25 -0200720 *
721 * Stops the frontend kthread, calls dvb_unregister_device() and frees the
722 * private frontend data allocated by dvb_register_frontend().
723 *
724 * NOTE: This function doesn't frees the memory allocated by the demod,
725 * by the SEC driver and by the tuner. In order to free it, an explicit call to
726 * dvb_frontend_detach() is needed, after calling this function.
727 */
728int dvb_unregister_frontend(struct dvb_frontend *fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729
Mauro Carvalho Chehab66f4b3c2015-11-10 10:46:25 -0200730/**
731 * dvb_frontend_detach() - Detaches and frees frontend specific data
732 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400733 * @fe: pointer to &struct dvb_frontend
Mauro Carvalho Chehab66f4b3c2015-11-10 10:46:25 -0200734 *
735 * This function should be called after dvb_unregister_frontend(). It
736 * calls the SEC, tuner and demod release functions:
737 * &dvb_frontend_ops.release_sec, &dvb_frontend_ops.tuner_ops.release,
738 * &dvb_frontend_ops.analog_ops.release and &dvb_frontend_ops.release.
739 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400740 * If the driver is compiled with %CONFIG_MEDIA_ATTACH, it also decreases
Mauro Carvalho Chehab66f4b3c2015-11-10 10:46:25 -0200741 * the module reference count, needed to allow userspace to remove the
742 * previously used DVB frontend modules.
743 */
744void dvb_frontend_detach(struct dvb_frontend *fe);
Andrew de Quinceyf52a8382006-08-08 09:10:09 -0300745
Mauro Carvalho Chehab41c0b782015-11-10 11:54:15 -0200746/**
747 * dvb_frontend_suspend() - Suspends a Digital TV frontend
748 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400749 * @fe: pointer to &struct dvb_frontend
Mauro Carvalho Chehab41c0b782015-11-10 11:54:15 -0200750 *
751 * This function prepares a Digital TV frontend to suspend.
752 *
753 * In order to prepare the tuner to suspend, if
Mauro Carvalho Chehab564aaf62016-07-23 07:12:03 -0300754 * &dvb_frontend_ops.tuner_ops.suspend\(\) is available, it calls it. Otherwise,
755 * it will call &dvb_frontend_ops.tuner_ops.sleep\(\), if available.
Mauro Carvalho Chehab41c0b782015-11-10 11:54:15 -0200756 *
Mauro Carvalho Chehab564aaf62016-07-23 07:12:03 -0300757 * It will also call &dvb_frontend_ops.sleep\(\) to put the demod to suspend.
Mauro Carvalho Chehab41c0b782015-11-10 11:54:15 -0200758 *
Mauro Carvalho Chehab564aaf62016-07-23 07:12:03 -0300759 * The drivers should also call dvb_frontend_suspend\(\) as part of their
760 * handler for the &device_driver.suspend\(\).
Mauro Carvalho Chehab41c0b782015-11-10 11:54:15 -0200761 */
762int dvb_frontend_suspend(struct dvb_frontend *fe);
763
764/**
765 * dvb_frontend_resume() - Resumes a Digital TV frontend
766 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400767 * @fe: pointer to &struct dvb_frontend
Mauro Carvalho Chehab41c0b782015-11-10 11:54:15 -0200768 *
769 * This function resumes the usual operation of the tuner after resume.
770 *
Mauro Carvalho Chehab564aaf62016-07-23 07:12:03 -0300771 * In order to resume the frontend, it calls the demod &dvb_frontend_ops.init\(\).
Mauro Carvalho Chehab41c0b782015-11-10 11:54:15 -0200772 *
Mauro Carvalho Chehab564aaf62016-07-23 07:12:03 -0300773 * If &dvb_frontend_ops.tuner_ops.resume\(\) is available, It, it calls it.
774 * Otherwise,t will call &dvb_frontend_ops.tuner_ops.init\(\), if available.
Mauro Carvalho Chehab41c0b782015-11-10 11:54:15 -0200775 *
776 * Once tuner and demods are resumed, it will enforce that the SEC voltage and
777 * tone are restored to their previous values and wake up the frontend's
778 * kthread in order to retune the frontend.
779 *
780 * The drivers should also call dvb_frontend_resume() as part of their
Mauro Carvalho Chehab564aaf62016-07-23 07:12:03 -0300781 * handler for the &device_driver.resume\(\).
Mauro Carvalho Chehab41c0b782015-11-10 11:54:15 -0200782 */
783int dvb_frontend_resume(struct dvb_frontend *fe);
Andrew de Quincey86f40cc2006-03-30 15:53:35 -0300784
Mauro Carvalho Chehab4deea4c2015-11-09 23:24:10 -0200785/**
Mauro Carvalho Chehab75f400b2015-11-10 10:26:39 -0200786 * dvb_frontend_reinitialise() - forces a reinitialisation at the frontend
787 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400788 * @fe: pointer to &struct dvb_frontend
Mauro Carvalho Chehab75f400b2015-11-10 10:26:39 -0200789 *
Mauro Carvalho Chehab564aaf62016-07-23 07:12:03 -0300790 * Calls &dvb_frontend_ops.init\(\) and &dvb_frontend_ops.tuner_ops.init\(\),
Mauro Carvalho Chehab75f400b2015-11-10 10:26:39 -0200791 * and resets SEC tone and voltage (for Satellite systems).
792 *
793 * NOTE: Currently, this function is used only by one driver (budget-av).
794 * It seems to be due to address some special issue with that specific
795 * frontend.
796 */
797void dvb_frontend_reinitialise(struct dvb_frontend *fe);
798
799/**
Mauro Carvalho Chehab4deea4c2015-11-09 23:24:10 -0200800 * dvb_frontend_sleep_until() - Sleep for the amount of time given by
801 * add_usec parameter
802 *
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400803 * @waketime: pointer to &struct ktime_t
Mauro Carvalho Chehab4deea4c2015-11-09 23:24:10 -0200804 * @add_usec: time to sleep, in microseconds
805 *
806 * This function is used to measure the time required for the
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400807 * FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl to work. It needs to be as precise
Mauro Carvalho Chehab4deea4c2015-11-09 23:24:10 -0200808 * as possible, as it affects the detection of the dish tone command at the
809 * satellite subsystem.
810 *
811 * Its used internally by the DVB frontend core, in order to emulate
Mauro Carvalho Chehab60093672017-09-19 16:40:33 -0400812 * FE_DISHNETWORK_SEND_LEGACY_CMD() using the &dvb_frontend_ops.set_voltage\(\)
Mauro Carvalho Chehab4deea4c2015-11-09 23:24:10 -0200813 * callback.
814 *
815 * NOTE: it should not be used at the drivers, as the emulation for the
816 * legacy callback is provided by the Kernel. The only situation where this
817 * should be at the drivers is when there are some bugs at the hardware that
818 * would prevent the core emulation to work. On such cases, the driver would
Mauro Carvalho Chehab564aaf62016-07-23 07:12:03 -0300819 * be writing a &dvb_frontend_ops.dishnetwork_send_legacy_command\(\) and
Mauro Carvalho Chehab4deea4c2015-11-09 23:24:10 -0200820 * calling this function directly.
821 */
822void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);
NooneImportant83b75b02005-11-08 21:35:27 -0800823
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824#endif