1 /*
2  * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation version 2.1 of the License.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
17  *
18  */
19 #ifndef _DVB_FE_H
20 #define _DVB_FE_H
21 
22 #include <stdio.h>
23 #include <errno.h>
24 #include <stdint.h>
25 #include <stdlib.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <fcntl.h>
29 #include <sys/ioctl.h>
30 #include <string.h>
31 #include "dvb-frontend.h"
32 #include "dvb-sat.h"
33 #include "dvb-log.h"
34 
35 /**
36  * @file dvb-fe.h
37  * @ingroup frontend
38  * @brief Provides interfaces to deal with DVB frontend.
39  * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
40  * @author Mauro Carvalho Chehab
41  *
42  * The libdvbv5 API works with a set of key/value properties.
43  * There are two types of properties:
44  *
45  * - The ones defined at the Kernel's frontent API, that are found at
46  *  /usr/include/linux/dvb/frontend.h (actually, it uses a local copy
47  *  of that file, stored at ./include/linux/dvb/frontend.h)
48  *
49  * - Some extra properties used by libdvbv5. Those can be found at
50  *   lib/include/libdvbv5/dvb-v5-std.h and start at DTV_USER_COMMAND_START.
51  *
52  * Just like the DTV properties, the stats are cached. That warrants that
53  * all stats are got at the same time, when dvb_fe_get_stats() is called.
54  *
55  * @par Bug Report
56  * Please submit bug reports and patches to linux-media@vger.kernel.org
57  */
58 
59 /**
60  * @def ARRAY_SIZE(array)
61  *	@brief Calculates the number of elements of an array
62  * @ingroup ancillary
63  */
64 #define ARRAY_SIZE(x)	(sizeof(x)/sizeof((x)[0]))
65 
66 /**
67  * @def MAX_DELIVERY_SYSTEMS
68  *	@brief Max number of delivery systems for a given frontend.
69  * @ingroup frontend
70  */
71 #define MAX_DELIVERY_SYSTEMS	20
72 
73 #ifndef _DOXYGEN
74 /*
75  * There are a few aliases for other properties. Those are needed just
76  * to avoid breaking apps that depend on the library but shoudn't be used
77  * anymore on newer apps.
78  */
79 #define DTV_MAX_STATS			DTV_NUM_STATS_PROPS
80 #define DTV_SIGNAL_STRENGTH		DTV_STAT_SIGNAL_STRENGTH
81 #define DTV_SNR				DTV_STAT_CNR
82 #define DTV_UNCORRECTED_BLOCKS		DTV_STAT_ERROR_BLOCK_COUNT
83 
84 #endif
85 
86 /**
87  * @struct dvb_v5_fe_parms
88  * @ingroup frontend
89  * @brief Keeps data needed to handle the DVB frontend
90  *
91  * @param info			Contains the DVB info properties (RO)
92  * @param version		Version of the Linux DVB API (RO)
93  * @param has_v5_stats		A value different than 0 indicates that the
94  *				frontend supports DVBv5 stats (RO)
95  * @param current_sys		Currently selected delivery system (RO)
96  * @param num_systems		Number of delivery systems  (RO)
97  * @param systems		Delivery systems supported by the hardware (RO)
98  * @param legacy_fe		A value different than 0 indicates a legacy
99  *				Kernel driver using DVBv3 API only, or that
100  *				DVBv3 only mode was forced by the client (RO)
101  * @param abort			Client should set it to abort a pending
102  *				operation like DTV scan (RW)
103  * @param lna:			Sets the LNA mode 0 disables; 1 enables, -1 uses
104  *				auto mode (RW)
105  * @param lnb			LNBf description (RW)
106  * @param sat_number		Number of the satellite (used by DISEqC setup) (RW)
107  * @param freq_bpf		SCR/Unicable band-pass filter frequency to use, in kHz
108  * @param verbose		Verbosity level of the library (RW)
109  * @param dvb_logfunc		Function used to write log messages (RO)
110  * @param default_charset	Name of the charset used by the DVB standard (RW)
111  * @param output_charset	Name of the charset to output (system specific) (RW)
112  *
113  * @details The fields marked as RO should not be changed by the client, as otherwise
114  * undesired effects may happen. The ones marked as RW are ok to either read
115  * or write by the client.
116  */
117 struct dvb_v5_fe_parms {
118 	/* Information visible to the client - don't override those values */
119 	struct dvb_frontend_info	info;
120 	uint32_t			version;
121 	int				has_v5_stats;
122 	fe_delivery_system_t		current_sys;
123 	int				num_systems;
124 	fe_delivery_system_t		systems[MAX_DELIVERY_SYSTEMS];
125 	int				legacy_fe;
126 
127 	/* The values below are specified by the library client */
128 
129 	/* Flags from the client to the library */
130 	int				abort;
131 
132 	/* Linear Amplifier settings */
133 	int				lna;
134 
135 	/* Satellite settings */
136 	const struct dvb_sat_lnb       	*lnb;
137 	int				sat_number;
138 	unsigned			freq_bpf;
139 	unsigned			diseqc_wait;
140 
141 	/* Function to write DVB logs */
142 	unsigned			verbose;
143 	dvb_logfunc                     logfunc;
144 
145 	/* Charsets to be used by the conversion utilities */
146 	char				*default_charset;
147 	char				*output_charset;
148 };
149 
150 #ifdef __cplusplus
151 extern "C" {
152 #endif
153 
154 /**
155  * @brief Allocates a dummy frontend structure
156  * @ingroup frontend
157  *
158  * @details This is useful for some applications that may want to just use the
159  * frontend structure internally, without associating it with a real hardware
160  *
161  * @return Returns a pointer to a dummy struct, or NULL if no memory.
162  */
163 struct dvb_v5_fe_parms *dvb_fe_dummy(void);
164 
165 /**
166  * @brief Opens a frontend and allocates a structure to work with
167  * @ingroup frontend
168  *
169  * @param adapter		Number of the adapter to open
170  * @param frontend		Number of the frontend to open
171  * @param verbose		Verbosity level of the messages that will be
172  *				printed
173  * @param use_legacy_call	Force to use the DVBv3 calls, instead of using
174  *				the DVBv5 API
175  * @param logfunc		Callback function to be called when a log event
176  *				happens. Can either store the event into a file
177  *				or to print it at the TUI/GUI. If NULL, the
178  *				library will use its internal handler.
179  * @param flags			Flags to be passed to open. Currently only two
180  *				flags are supported: O_RDONLY or O_RDWR.
181  *				Using O_NONBLOCK may hit unexpected issues.
182  *
183  * @todo Add/check support for O_NONBLOCK at the scan routines.
184  *
185  * @details This function should be called before using any other function at
186  * the frontend library (or the other alternatives: dvb_fe_open() or
187  * dvb_fe_dummy().
188  *
189  * In general, this is called using O_RDWR, except if all that it is wanted
190  * is to check the DVB frontend statistics.
191  *
192  * @return Returns a pointer to an allocated data pointer or NULL on error.
193  */
194 struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int frontend,
195 					  unsigned verbose,
196 					  unsigned use_legacy_call,
197 					  dvb_logfunc logfunc,
198 					  int flags);
199 
200 /**
201  * @brief Opens a frontend and allocates a structure to work with
202  * @ingroup frontend
203  *
204  * @param adapter		Number of the adapter to open
205  * @param frontend		Number of the frontend to open
206  * @param verbose		Verbosity level of the messages that will be
207  * 				printed
208  * @param use_legacy_call	Force to use the DVBv3 calls, instead of using
209  *				the DVBv5 API
210  *
211  * @details This function should be called before using any other function at
212  * the frontend library (or the other alternatives: dvb_fe_open2() or
213  * dvb_fe_dummy().
214  *
215  * @return Returns a pointer to an allocated data pointer or NULL on error.
216  */
217 struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend,
218 						  unsigned verbose,
219 						  unsigned use_legacy_call);
220 
221 /**
222  * @brief Opens a frontend and allocates a structure to work with
223  * @ingroup frontend
224  *
225  * @param adapter		Number of the adapter to open
226  * @param frontend		Number of the frontend to open
227  * @param verbose		Verbosity level of the messages that will be
228  *				printed
229  * @param use_legacy_call	Force to use the DVBv3 calls, instead of using
230  *				the DVBv5 API
231  * @param logfunc		Callback function to be called when a log event
232  *				happens. Can either store the event into a file
233  *				or to print it at the TUI/GUI.
234  *
235  * @details This function should be called before using any other function at
236  * the frontend library (or the other alternatives: dvb_fe_open() or
237  * dvb_fe_dummy().
238  *
239  * @return Returns a pointer to an allocated data pointer or NULL on error.
240  */
241 struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend,
242 				    unsigned verbose, unsigned use_legacy_call,
243 				    dvb_logfunc logfunc);
244 
245 /**
246  * @brief Closes the frontend and frees allocated resources
247  * @ingroup frontend
248  *
249  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
250  */
251 void dvb_fe_close(struct dvb_v5_fe_parms *parms);
252 
253 /**
254  * @brief Returns the string name associated with a DVBv5 command
255  * @ingroup frontend
256  *
257  * @param cmd	DVBv5 or libdvbv5 property
258  *
259  * @details This function gets an integer argument (cmd) and returns a string
260  * that corresponds to the name of that property.
261  *
262  * @return it returns a string that corresponds to the property name.
263  * For example:
264  * 	dvb_cmd_name(DTV_GUARD_INTERVAL) would return "GUARD_INTERVAL"
265  * It also returns names for the properties used internally by libdvbv5.
266  */
267 const char *dvb_cmd_name(int cmd);
268 
269 /**
270  * @brief Returns an string array with the valid string values associated with a DVBv5 command
271  * @ingroup frontend
272  *
273  * @param cmd	DVBv5 or libdvbv5 property
274  *
275  * @return it returns a string array that corresponds to the names associated
276  * with the possible values for that property, when available.
277  * For example:
278  * 	dvb_cmd_name(DTV_CODE_RATE_HP) would return an array with the
279  * possible values for the code rates:
280  *	{ "1/2", "2/3", ... NULL }
281  * @note The array always ends with NULL.
282  */
283 const char *const *dvb_attr_names(int cmd);
284 
285 /* Get/set delivery system parameters */
286 
287 /**
288  * @brief Retrieves the value of a DVBv5/libdvbv5 property
289  * @ingroup frontend
290  *
291  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
292  * @param cmd	DVBv5 or libdvbv5 property
293  * @param value	Pointer to an uint32_t where the value will be stored.
294  *
295  * This reads the value of a property stored at the cache. Before using it,
296  * a dvb_fe_get_parms() is likely required.
297  *
298  * @return Return 0 if success, EINVAL otherwise.
299  */
300 int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
301 			unsigned cmd, uint32_t *value);
302 
303 /**
304  * @brief Stores the value of a DVBv5/libdvbv5 property
305  * @ingroup frontend
306  *
307  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
308  * @param cmd	DVBv5 or libdvbv5 property
309  * @param value	Pointer to an uint32_t where the value will be stored.
310  *
311  * This stores the value of a property at the cache. The value will only
312  * be send to the hardware after calling dvb_fe_set_parms().
313  *
314  * @return Return 0 if success, EINVAL otherwise.
315  */
316 int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms,
317 		      unsigned cmd, uint32_t value);
318 
319 /**
320  * @brief Sets the delivery system
321  * @ingroup frontend
322  *
323  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
324  * @param sys	delivery system to be selected
325  *
326  * This function changes the delivery system of the frontend. By default,
327  * the libdvbv5 will use the first available delivery system. If another
328  * delivery system is desirable, this function should be called before being
329  * able to store the properties for the new delivery system via
330  * dvb_fe_store_parm().
331  *
332  * @return Return 0 if success, EINVAL otherwise.
333  */
334 int dvb_set_sys(struct dvb_v5_fe_parms *parms,
335 		   fe_delivery_system_t sys);
336 
337 /**
338  * @brief Make dvb properties reflect the current standard
339  * @ingroup frontend
340  *
341  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
342  * @param sys	delivery system to be selected
343  *
344  * This function prepares the properties cache for a given delivery system.
345  *
346  * It is automatically called by dvb_set_sys(), and should not be normally
347  * called, except when dvb_fe_dummy() is used.
348  *
349  * @return Return 0 if success, EINVAL otherwise.
350  */
351 int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *parms,
352 			  fe_delivery_system_t sys);
353 
354 /**
355  * @brief Sets the delivery system
356  * @ingroup frontend
357  *
358  * @param parms			struct dvb_v5_fe_parms pointer to the opened
359  *				device
360  * @param desired_system	delivery system to be selected
361  *
362  * This function changes the delivery system of the frontend. By default,
363  * the libdvbv5 will use the first available delivery system. If another
364  * delivery system is desirable, this function should be called before being
365  * able to store the properties for the new delivery system via
366  * dvb_fe_store_parm().
367  *
368  * This function is an enhanced version of dvb_set_sys(). It has an special
369  * logic inside to work with Kernels that supports only DVBv3.
370  *
371  * @return Return 0 if success, EINVAL otherwise.
372  */
373 int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
374 				   uint32_t desired_system);
375 
376 /**
377  * @brief Prints all the properties at the cache
378  * @ingroup frontend
379  *
380  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
381  *
382  * Used mostly for debugging issues.
383  */
384 void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms);
385 
386 /**
387  * @brief Prints all the properties at the cache
388  * @ingroup frontend
389  *
390  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
391  *
392  * Writes the properties stored at the DVB cache at the DVB hardware. At
393  * return, some properties could have a different value, as the frontend
394  * may not support the values set.
395  *
396  * @return Return 0 if success, EINVAL otherwise.
397  */
398 int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms);
399 
400 /**
401  * @brief Prints all the properties at the cache
402  * @ingroup frontend
403  *
404  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
405  *
406  * Gets the properties from the DVB hardware. The values will only reflect
407  * what's set at the hardware if the frontend is locked.
408  *
409  * @return Return 0 if success, EINVAL otherwise.
410  */
411 int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms);
412 
413 /*
414  * statistics functions
415  */
416 
417 /**
418  * @brief Retrieve the stats for a DTV layer from cache
419  * @ingroup frontend
420  *
421  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
422  * @param cmd	DVBv5 or libdvbv5 property
423  * @param layer	DTV layer
424  *
425  * Gets the value for one stats cache, on a given layer. Layer 0 is
426  * always present. On DTV standards that doesn't have layers, it returns
427  * the same value as dvb_fe_retrieve_stats() for layer = 0.
428  *
429  * For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
430  * layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
431  * frontends support per-layer stats. Also, the layer value is only valid if
432  * the layer exists at the original stream.
433  * Also, on such standards, layer 0 is typically a mean value of the layers,
434  * or a sum of events (if FE_SCALE_COUNTER).
435  *
436  * For it to be valid, dvb_fe_get_stats() should be called first.
437  *
438  * @return It returns a struct dtv_stats if succeed or NULL otherwise.
439  */
440 struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms,
441                                               unsigned cmd, unsigned layer);
442 
443 /**
444  * @brief Retrieve the stats for a DTV layer from cache
445  * @ingroup frontend
446  *
447  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
448  * @param cmd	DVBv5 or libdvbv5 property
449  * @param value	DTV value pointer
450  *
451  * Gets the value for one stats property for layer = 0.
452  *
453  * For it to be valid, dvb_fe_get_stats() should be called first.
454  *
455  * @return The returned value is 0 if success, EINVAL otherwise.
456  */
457 int dvb_fe_retrieve_stats(struct dvb_v5_fe_parms *parms,
458 			  unsigned cmd, uint32_t *value);
459 
460 /**
461  * @brief Retrieve the stats from the Kernel
462  * @ingroup frontend
463  *
464  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
465  *
466  * Updates the stats cache from the available stats at the Kernel.
467  *
468  * @return The returned value is 0 if success, EINVAL otherwise.
469  */
470 int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms);
471 
472 /**
473  * @brief Retrieve the BER stats from cache
474  * @ingroup frontend
475  *
476  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
477  * @param layer	DTV layer
478  * @param scale	retrieves the scale
479  *
480  * Gets the value for BER stats from stats cache, on a given layer. Layer 0 is
481  * always present. On DTV standards that doesn't have layers, it returns
482  * the same value as dvb_fe_retrieve_stats() for layer = 0.
483  *
484  * For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
485  * layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
486  * frontends support per-layer stats. Also, the layer value is only valid if
487  * the layer exists at the original stream.
488  * Also, on such standards, layer 0 is typically a mean value of the layers,
489  * or a sum of events (if FE_SCALE_COUNTER).
490  *
491  * For it to be valid, dvb_fe_get_stats() should be called first.
492  *
493  * @return It returns a float number for the BER value.
494  * If the statistics is not available for any reason, scale will be equal to
495  * FE_SCALE_NOT_AVAILABLE.
496  */
497 float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
498                           enum fecap_scale_params *scale);
499 
500 /**
501  * @brief Retrieve the PER stats from cache
502  * @ingroup frontend
503  *
504  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
505  * @param layer	DTV layer
506  *
507  * Gets the value for BER stats from stats cache, on a given layer. Layer 0 is
508  * always present. On DTV standards that doesn't have layers, it returns
509  * the same value as dvb_fe_retrieve_stats() for layer = 0.
510  *
511  * For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
512  * layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
513  * frontends support per-layer stats. Also, the layer value is only valid if
514  * the layer exists at the original stream.
515  * Also, on such standards, layer 0 is typically a mean value of the layers,
516  * or a sum of events (if FE_SCALE_COUNTER).
517  *
518  * For it to be valid, dvb_fe_get_stats() should be called first.
519  *
520  * @return A negative value indicates error.
521  */
522 float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer);
523 
524 
525 /**
526  * @brief Retrieve the quality stats from cache
527  * @ingroup frontend
528  *
529  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
530  * @param layer	DTV layer
531  *
532  * Gets a quality measure for a given layer. Layer 0 is
533  * always present. On DTV standards that doesn't have layers, it returns
534  * the same value as dvb_fe_retrieve_stats() for layer = 0.
535  *
536  * For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
537  * layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
538  * frontends support per-layer stats. Also, the layer value is only valid if
539  * the layer exists at the original stream.
540  * Also, on such standards, layer 0 is typically a mean value of the layers,
541  * or a sum of events (if FE_SCALE_COUNTER).
542  *
543  * For it to be valid, dvb_fe_get_stats() should be called first.
544  *
545  * @return returns an enum dvb_quantity, where DVB_QUAL_UNKNOWN means that
546  * the stat isnot available.
547  */
548 enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms,
549 					 unsigned layer);
550 
551 /**
552  * @brief Ancillary function to sprintf on ENG format
553  * @ingroup frontend
554  *
555  * @param buf	buffer to store the value
556  * @param len	buffer length
557  * @param val	value to be printed
558  *
559  * On ENG notation, the exponential value should be multiple of 3. This is
560  * good to display some values, like BER.
561  *
562  * @return At return, it shows the actual size of the print. A negative value
563  * indicates an error.
564  */
565 int dvb_fe_snprintf_eng(char *buf, int len, float val);
566 
567 
568 /**
569  * @brief Ancillary function to sprintf on ENG format
570  * @ingroup frontend
571  *
572  * @param parms		struct dvb_v5_fe_parms pointer to the opened device
573  * @param cmd		DVBv5 or libdvbv5 property
574  * @param display_name	String with the name of the property to be shown
575  * @param layer		DTV Layer
576  * @param buf		buffer to store the value
577  * @param len		buffer length
578  * @param show_layer_name	a value different than zero shows the layer name, if
579  * 			the layer is bigger than zero.
580  *
581  * This function calls internally dvb_fe_retrieve_stats_layer(). It allows to
582  * print a DVBv5 statistics value into a string. An extra property is available
583  * (DTV_QUALITY) with prints either one of the values: Poor, Ok or Good,
584  * depending on the overall measures.
585  *
586  * @return: It returns the length of the printed data. A negative value
587  * indicates an error.
588  */
589  int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
590 			  char *display_name, int layer,
591 		          char **buf, int *len, int *show_layer_name);
592 
593 /**
594  * @brief Get both status statistics and dvb parameters
595  * @ingroup frontend
596  *
597  * @param parms		struct dvb_v5_fe_parms pointer to the opened device
598  *
599  * That's similar of calling both dvb_fe_get_parms() and dvb_fe_get_stats().
600  *
601  * @return It returns 0 if success or an errorno otherwise.
602  */
603 int dvb_fe_get_event(struct dvb_v5_fe_parms *parms);
604 
605 /*
606  * Other functions, associated to SEC/LNB/DISEqC
607  *
608  * The functions below are just wrappers for the Kernel calls, in order to
609  * manually control satellite systems.
610  *
611  * Instead of using most them, the best is to set the LNBf parameters, and let
612  * the libdvbv5 to automatically handle the calls.
613  *
614  * NOTE: It currently lacks support for two ioctl's:
615  * FE_DISEQC_RESET_OVERLOAD	used only on av7110.
616  * Spec says:
617  *   If the bus has been automatically powered off due to power overload,
618  *   this ioctl call restores the power to the bus. The call requires read/write
619  *   access to the device. This call has no effect if the device is manually
620  *   powered off. Not all DVB adapters support this ioctl.
621  *
622  * FE_DISHNETWORK_SEND_LEGACY_CMD is used on av7110, budget, gp8psk and stv0299
623  * Spec says:
624  *   WARNING: This is a very obscure legacy command, used only at stv0299
625  *   driver. Should not be used on newer drivers.
626  *   It provides a non-standard method for selecting Diseqc voltage on the
627  *   frontend, for Dish Network legacy switches.
628  *   As support for this ioctl were added in 2004, this means that such dishes
629  *   were already legacy in 2004.
630  *
631  * So, it doesn't make much sense on implementing support for them.
632  */
633 
634 /**
635  * @brief DVB ioctl wrapper for setting SEC voltage
636  * @ingroup frontend
637  *
638  * @param parms		struct dvb_v5_fe_parms pointer to the opened device
639  * @param on		a value different than zero indicates to enable
640  *			voltage on a Satellite Equipment Control (SEC)
641  * @param v18		if on != 0, a value different than zero means 18 Volts;
642  *			zero means 13 Volts.
643  *
644  * If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
645  */
646 int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18);
647 
648 /**
649  * @brief DVB ioctl wrapper for setting SEC tone
650  * @ingroup frontend
651  *
652  * @param parms		struct dvb_v5_fe_parms pointer to the opened device
653  * @param tone		tone setting, as defined by DVB fe_sec_tone_mode_t type
654  *
655  * If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
656  */
657 int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone);
658 
659 /**
660  * @brief DVB ioctl wrapper for setting LNBf high voltage
661  * @ingroup frontend
662  *
663  * @param parms		struct dvb_v5_fe_parms pointer to the opened device
664  * @param on		a value different than zero indicates to produce
665  *			lightly higher voltages instead of 13/18V, in order
666  *			to compensate for long cables.
667  */
668 int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on);
669 
670 /**
671  * @brief DVB ioctl wrapper for setting SEC DiSeqC tone burst to select between
672  *	  satellite A or B
673  * @ingroup frontend
674  *
675  * @param parms		struct dvb_v5_fe_parms pointer to the opened device
676  * @param mini_b	if different than zero, sends a 22 KHz tone burst to
677  *			select satellite B. Otherwise, sends tone to select
678  *			satellite A.
679  *
680  * Valid only on certain DISEqC arrangements.
681  *
682  * If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
683  */
684 int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b);
685 
686 /**
687  * @brief DVB ioctl wrapper for setting SEC DiSeqC command
688  * @ingroup frontend
689  *
690  * @param parms		struct dvb_v5_fe_parms pointer to the opened device
691  * @param len		size of the DiSEqC command
692  * @param buf		DiSEqC command to be sent
693  *
694  * If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
695  */
696 int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
697 		      const unsigned char *buf);
698 
699 /**
700  * @brief DVB ioctl wrapper for getting SEC DiSEqC reply
701  * @ingroup frontend
702  *
703  * @param parms		struct dvb_v5_fe_parms pointer to the opened device
704  * @param len		size of the DiSEqC command
705  * @param buf		DiSEqC command to be sent
706  * @param timeout	maximum time to receive the command, in ms.
707  *
708  * If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
709  */
710 int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
711 		       int timeout);
712 
713 /**
714  * @brief DVB Ancillary routine to check if a given Delivery system is satellite
715  * @ingroup frontend
716  *
717  * @param delivery_system	delivery system to be selected
718  */
719 int dvb_fe_is_satellite(uint32_t delivery_system);
720 
721 /**
722  * @brief Set default country variant of delivery systems like ISDB-T
723  * @ingroup frontend
724  *
725  * @param parms		struct dvb_v5_fe_parms pointer to the opened device
726  * @param country	default country, in ISO 3166-1 two letter code. If
727  *			NULL, default charset is guessed from locale environment
728  *			variables.
729  *
730  * @return 0 if success or an errorno otherwise.
731  *
732  * "COUNTRY" property in dvb_fe_set_parm() overrides the setting.
733  */
734 int dvb_fe_set_default_country(struct dvb_v5_fe_parms *parms,
735 			       const char *country);
736 
737 #ifdef __cplusplus
738 }
739 #endif
740 
741 /*
742  * Arrays from dvb-v5.h
743  *
744  * Those arrays can be used to translate from a DVB property into a name.
745  *
746  * No need to directly access them from userspace, as dvb_attr_names()
747  * already handles them into a more standard way.
748  */
749 
750 #ifndef _DOXYGEN
751 
752 extern const unsigned fe_bandwidth_name[8];
753 extern const char *dvb_v5_name[72];
754 extern const void *dvb_v5_attr_names[];
755 extern const char *delivery_system_name[20];
756 extern const char *fe_code_rate_name[14];
757 extern const char *fe_modulation_name[15];
758 extern const char *fe_transmission_mode_name[10];
759 extern const unsigned fe_bandwidth_name[8];
760 extern const char *fe_guard_interval_name[12];
761 extern const char *fe_hierarchy_name[6];
762 extern const char *fe_voltage_name[4];
763 extern const char *fe_tone_name[3];
764 extern const char *fe_inversion_name[4];
765 extern const char *fe_pilot_name[4];
766 extern const char *fe_rolloff_name[5];
767 
768 #endif
769 
770 #endif
771